Repository navigation
chore(lint): Landmines' test rules, and sleeps, flakes and comments only shrink - #490
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Nov 18, 2026
AVGVSTVS96
added a commit
that referenced
this pull request
Nov 18, 2026
…y machine (#481) Adds `hex rollback <commit>`: the way back for a ship that starts but misbehaves, which the supervisor never sees because its hub keeps running. It goes back in seconds, with no check and no store deploy, since an older hex runs on a newer store. The revert PR follows through main as usual. **Order: apply the takeover-step patch below on every machine that can take hex over, then ship this.** Each machine's own copy of the step needs it. A machine left unpatched keeps a ship its checkout holds when it takes hex over. ``` hex rollback <earlier commit> runs where hex runs (the cli's forwarding, now a function) refuses: no commit (usage), an unknown commit, one hex isn't built on, uncommitted edits fetch main (10s, best effort) under state/checkout.lock (bin/update merges under it too): state/refused += "<newest refused> <commit gone back to>" written first; if it can't be, hex stays and says so git reset --keep <commit> if that fails, the line comes out again state/bad = <newest refused> main's one-commit format, so an older bin/update holds too rm state/good so "up" can only mean a hub on <commit> restart the hub (relink + restart hex.service if systemd/ or services.json differ from HEAD@{1}); the run loop installs as the hub starts wait until state/good == <commit> (a hub on it, General connected); 2 min up: "hex is back on <commit>: a hub runs it, and General connected to it." exit 0 not up: the old hub's pid if it hasn't stopped, else where its log is exit 1 running it again restarts and waits again, and says "already" only when a hub runs it ``` **What is refused, and where.** `hex refused <commit>` is the one rule. `bin/update` and the takeover step ask it, and it prints why. A commit is refused when either of these holds: - It falls in a range `hex rollback` went back from: after the commit gone back to, up to the newest refused. The newest is main's tip when main held the commit left, so commits already on top of the ship are covered. - It is the commit in `state/bad`, which the supervisor's automatic rollback writes exactly as on main. The message is then main's "couldn't start here". Where a range's newest commit isn't on this machine, every commit here after the one gone back to is refused, since none can be past a commit the machine doesn't have. So the rule needs no fetch, and it holds with GitHub down. Only `state/refused` goes to the store: a hub sends it when it claims hex, and the store keeps every line any hub has sent (newest 100) in a `refused` column beside `hub`, answered on `/version`. So a hand rollback holds on whichever machine runs hex next, and an automatic one stays on its own machine, since a hub can fail to start for that machine's reasons. A commit merged after the rollback, such as the revert, ships. **An update in flight.** - `bin/update` asks again right before it merges, under the lock the rollback writes and resets under. An update that asked before the rollback finds the commit refused and stops, naming where hex now stays. - The merge runs with the lock's file closed, so git's cleanup after it doesn't keep the lock and stall a rollback. - An update that a rollback overtakes between its merge and its restart says "not updated: hex rollback took hex back to …" and exits 1. **When the commit gone back to can't start.** The supervisor's rollback goes only back, to an ancestor of HEAD, so it never runs a commit hex went back from. hex stays down and says so ("no earlier hex to go back to"). **Size.** What came out this round: - the fetch inside `refused` and the hoisted `limit`, replaced by the rule above; - the rollback's own `bun install`, since the run loop installs at every hub start. What came out before that: - the shared `back_to` and its note template; `roll_back` is main's code plus the "only back" condition; - the mixed-format `state/bad`; - one diagnosis branch; - the `hub_pid` helper. Code is about 180 lines (`bin/hex` +113/−25, `bin/update` +20/−11, the store +57), plus about 400 lines of tests. **Takeover-step patch (owner-side, not in this repo).** Apply it on every machine before this ships. - Beside main's `bin/hex`, `hex refused` exits 2, so the patch behaves as the live script does: an ahead checkout stays, `state/bad` is honored as before, and everything else moves forward. - Once this PR is live, a checkout goes back only when it is itself a commit `hex rollback` went back from. A checkout that's merely ahead of the hub's commit stays, as after an update whose hub hasn't restarted, or a reboot in that window. - A hub commit this machine hasn't seen is fetched before it's judged. ```diff --- a/bin/store-code +++ b/bin/store-code @@ -9,10 +9,22 @@ commit=$(printf %s "$says" | jq -r '.hub // empty') of="the hub that last held hex runs" [ -n "$commit" ] || { commit=$(printf %s "$says" | jq -r .version | cut -s -d@ -f2) of="its store's code is from"; } [ -n "$commit" ] || { echo "store-code: the store names no commit: $says" >&2; exit 1; } -git -C "$hex" merge-base --is-ancestor "$commit" HEAD 2>/dev/null && exit 0 -# A commit hex was rolled back from stays away until an update brings a later one (bin/hex's state/bad). -[ "$(cat "$HOME/hex/state/bad" 2>/dev/null)" != "$commit" ] || { echo "store-code: hex runs $commit elsewhere, which it was rolled back from here, so the code stays"; exit 0; } -git -C "$hex" cat-file -e "$commit^{commit}" 2>/dev/null || timeout 30 git -C "$hex" fetch -q origin -git -C "$hex" merge -q --ff-only "$commit" +here=$(git -C "$hex" rev-parse HEAD) +[ "$here" != "$commit" ] || exit 0 +# Whether hex rollback went back from a commit, here or on a machine whose hub told the store; a hex without the +# command reads as not. +refused() { "$hex/bin/hex" refused "$1" >/dev/null 2>&1; } +if git -C "$hex" merge-base --is-ancestor "$commit" HEAD 2>/dev/null; then + # The code here is ahead of the hub's, as after an update whose hub hasn't restarted yet: it stays, unless hex went + # back from it. + refused "$here" || exit 0 + git -C "$hex" reset -q --keep "$commit" +else + # A commit hex was rolled back from stays away until an update brings a later one (bin/hex's state/bad). + [ "$(cat "$HOME/hex/state/bad" 2>/dev/null)" != "$commit" ] || { echo "store-code: hex runs $commit elsewhere, which it was rolled back from here, so the code stays"; exit 0; } + git -C "$hex" cat-file -e "$commit^{commit}" 2>/dev/null || timeout 30 git -C "$hex" fetch -q origin + ! refused "$commit" || { echo "store-code: hex runs $commit elsewhere, which hex went back from, so the code stays"; exit 0; } + git -C "$hex" merge -q --ff-only "$commit" +fi timeout 60 bun install --cwd "$hex" --silent echo "store-code: hex's code is at $commit, which $of" ``` **Drills for the patch and the rule** (the reviewer's three rounds, plus mine), with stand-in machines and a stand-in store; all came out as below: - `github-down`: a machine on the ship that never saw the newest refused commit, with no answer from GitHub, goes back. - `hub-unknown`: a refused hub commit the machine never fetched is fetched, found refused, and the code stays. - `unknown-newest`: the same machine with GitHub up goes back. - `old-hex`: next to main's `bin/hex`, the patch matches the live script, holding a commit main rolled back from, keeping an ahead checkout, and moving a behind one forward. - `unpatched`: the live script holds only while main's tip is the ship; with a commit on top it moves to the ship. Hence patch first. - A: an ahead machine goes back after a rollback elsewhere. - B: a behind machine moves forward, and its `bin/update --now` refuses. - C: the store names the ship as the hub's commit, so the code stays. - D and D': a real `bin/update --now` merges a `systemd/hex.service` change and restarts hex.service with the patch as its start step; the code stays on the merged commit, including with an unrelated earlier rollback in the store. - `inflight` and `after-merge`: an update before and after its merge, across a rollback; neither takes hex forward, and each says so. - `full-disk`: hex stays, in hex's words. - `keep-fails`: a checkout whose edit the reset can't keep stays on the ship with git's error, as today's script does. - Merge lock: a real `bin/update` with 9,000 loose objects written between its fetch and merge. The lock was held 1,019 ms after HEAD moved without the fix, and was free by the time the move was seen with it. **Lint (#490's rules, on main 7e6bdfc):** it passes with no new comments; the store field's three comments were taken out rather than counted. oxlint reads only JS and TS, so `bin/hex` and `bin/update`, which are shell, are outside it. The tests use no sleeps or doubles: the fake `ssh` and `systemctl` are scripts on disk. **Proof for this PR:** `bin/hex.run.test.ts` on a scratch hex folder with the real `bin/hex run` loop and stand-in hubs, 32 of 33 passing. The 33rd is main's "no hub starts on records that are moving": it failed 3 of 3 on main's own code at this load, because the login shell runs before the stop trap is in place. Each of these tests fails with its fix taken out: - an update waiting in `bin/quiet` across a rollback doesn't merge; - an update overtaken while it installs says so; - a rollback refused a write says hex stayed; - a machine refuses past a newest commit it can't fetch. The file also covers: - "back" only once a hub is up, and refusals across two rollbacks and commits on top; - an old hub that won't stop, then a second run finishing; - a failed relink, then a second run finishing; - a commit gone back to that can't start; - an automatic rollback writing nothing shared, with main's "couldn't start here"; - argument refusals and the ssh forward. Also passing: the store test 49/49, the claim and `/version` tests on Cloudflare's runtime, `kept.hub` 31/31, and the cli, update and `bin/hex` store tests. Limits: - A rollback to a commit from before this PR runs that commit's `bin/update`. It still refuses `state/bad`'s one commit, main's tip at the rollback, on that machine, until main moves. That older hub doesn't tell the store. - Shipping this deploys the store's Worker, and `hex rollback` can't undo this PR on the other machine; the way back from it is a revert PR. Not checked: a real hub and General through a real rollback, and a real jump between two machines.
AVGVSTVS96
added a commit
that referenced
this pull request
Nov 18, 2026
`app.ts` (the phone apps' API) imported two things from the call side:
`card` and `talkAbout` from `engine.ts`, and the topic words from
`prompt.ts`. Now it imports neither. Structure only: no behavior
changes.
```
before: app.ts ──► engine.ts, prompt.ts
after: serve.ts ──► app.startApp(state, shared, { talkAbout, card })
engine.ts, prompt.ts ──► app.ts (type About only)
```
- **The app says what to talk about as data.** `app.ts` exports `About =
{ run } | { entry } | { asks }`. Talk it through, Discuss and Go through
them pass that to `talkAbout`; `prompt.ts`'s new `topicOf(about)` turns
it into the call's words, which stay in `prompt.ts` (`runTopic`,
`feedTopic`, `walkTopic` are now private to it).
- **`serve.ts` hands the app what calls offer.** `app.ts` declares the
shape it uses, `Calls` (`talkAbout`, and `card` with the five things a
card hears from the app). `serve.ts` passes `engine.talkAbout` and
`engine.card`, so the type-check holds the engine to that shape.
- **`app.topicOf` is now `app.aboutOf`.** It returns `About`, not a
`Topic`. The engine's `Hex.topic` became `Hex.about`, and the engine
turns the result into a `Topic` itself when a call starts with `about`.
In `engine.ts`, `about` now always means `About`: the request's string
is read as `id`, and `follow`'s option that carries a `Topic` is called
`topic`.
Two departures from the design, both small: the function was renamed
rather than kept as `topicOf`, since it no longer returns a `Topic` and
`topicOf` now names the function in `prompt.ts`; and `engine.ts` imports
the `About` type from `app.ts`. That is the direction the later move to
`app/` keeps (voice depends on the app, never the reverse).
**Checked**, on main 03b3acc (after #472, #486, #490 and #494):
- `bin/check channels/voice`: type-check and 255 voice tests pass. Lint
and format pass across the repo.
- Main and this branch run side by side on a scratch hex, with #453's
script: 138 app and call requests give the same answers, except
`/tasks/summary`'s clock-based version.
- The opening a call sends OpenAI is identical for every `about` tried:
a running thread, the questions (`asks`), a feed entry, and the ones
that fall back to a greeting (a thread with no session, a finished task,
unknown, empty).
- During a live call, on both: the card flow from the app and the call
(note, answer, undo, dismiss, the call's own answer tool), Talk it
through on a working thread, and Go through them. The delivers (with
#486's call-start message), voice instructions, thread relays,
`/activity` and call record are the same; only timings differ.
**What a real call still has to show:** that a call started from a
thread, a feed entry or Go through them opens on that topic, and that
tapping a card's answer on the phone during the call gets told to the
voice. The tests run each step against a fake OpenAI and Twilio, not the
real ones.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Landmines (Interfere's oxlint rules against tests that pass without proving anything) and stops hex's debt from growing while it's paid down. Config and lint tools only; no source or test file changes.
no-comments(hex's own rule and the cap below cover it until the cleanup lands, then it replaces them) andno-explicit-return-types(749 sites, after the open hub PRs).tools/oxlint/allowances.json. A file over its count fails; a file under it fails until its count is lowered, so cleanup PRs lower the numbers as they go.no-comments/most): counts every comment but lint directives, so the-- a fact the code can't showdisable no longer lets a new comment in.no-test-doublesoff, listed asdoublesIn, until they're fixed.SAFETY:on a type assertion, and now a one-lineWARNING:for a footgun from outside hex.