Repository navigation
fix(bin): report an unreadable crew state as unreadable, not unknown - #7363
max-metaplanet wants to merge 4 commits into
Conversation
|
Speaking as Kun's firstmate: thank you @max-metaplanet — first stamp on tip Contract-class: restore (my read, not the PR's claim). The run-step reader was labeling instrument / inventory failures as crew VISION.md: one captain — aligns (honest fleet state); authority — aligns; scripts/judgment — aligns (deterministic reader); restart — aligns; delegation — aligns (supervisor sees instrument failure); vendor — aligns (no-mistakes inventory semantics); scope — aligns. This pass: attestation MATCHES tip (live go 4/6; untested rows are stub-only paths real NM never emits). Security clean (workflow edit is count-only) → approved fork CI |
`bin/fm-crew-state.sh` prints one state word per task, and every one of them reads as a claim about the worker. A run-step read that fails printed `state: unknown`, which says the worker's state is unknowable when what actually happened is that this reader could not see. The supervision contract tells a supervisor to reconcile a worker's current state with this reader before deciding the worker is stuck, so the two cases have to be told apart, and on a busy repository the read failure is routine rather than rare. The reader's own failures were also indistinguishable from each other. Five of them shared two labels - `unreadable runs table` and `complete same-branch run inventory unreadable` - so a contradicted count header, a malformed row, a state database that could not be opened, a repository the CLI never recorded, and a reader that never finished all produced the same sentence, and none of them said which had happened. A run-step read that cannot establish a verdict now reports `state: unreadable` with a detail that opens on the specific thing it could not read or could not settle. `unreadable` is the one state word that is a claim about the reader rather than about the worker; `bin/fm-crew-state.sh`'s header owns that contract, including which consumers must accept it. The other sources - pane, status log, remote endpoint, missing metadata - still report `unknown` and are unchanged. Consumers that act on a worker claim match `working`, `paused`, `parked`, `done` and `failed` positively, so the new word is handled exactly as `unknown` was. One consumer matches the unread verdict itself: the secondmate home summary in `bin/fm-fleet-snapshot.sh` reported a child whose current state could not be read as `child_current_unavailable` by selecting only `unknown`, and now accepts both words, so an unread child cannot silently promote a home to valid. One defect fixed along the way: when `no-mistakes axi` exits nonzero after printing part of its table, the verdict spliced the whole selection reason into its own `run ids:` field, because the trailing-field split that reads ids off a `selected|...` choice finds no `|` in a reason sentence. That produced one line asserting two different causes with prose inside an id list, for example `run ids: 01OLD, competing live runs; run ids: 01NEW, 01OLD`. Only the candidate ids are spliced now. Regressions are colocated in `tests/fm-crew-state.test.sh` and `tests/fm-fleet-snapshot-view.test.sh`: an unreadable read names the specific thing it could not read and two different failures do not share one reason; a failed inventory call reports one cause and only run ids; and the home summary reports an unreadable child as current-state-unavailable. Each fails against the code before this change. The stock-Bash snapshot step in `.github/workflows/ci.yml` pins an exact test count for the fleet-view suite, so it moves from 18 to 19 with the test added there.
126ac12 to
562dd14
Compare
|
Speaking as Kun's firstmate: thanks @max-metaplanet for re-raising this on current main. My last stamp was on What I checked: 9 files against main I'm correcting my contract class, and that's on me, not on anything you changed: new-default, not restore. On 15 Oct I called this a restore. Looking again, VISION, rule by rule: One captain aligns (it names the failure plainly instead of a bare unknown). Authority aligns (it adds no autonomy). Scripts/judgment aligns (a deterministic reader with named reasons). Restart aligns. Delegation aligns (a supervisor can tell can't-read from no-run). Vendor aligns (it binds to no-mistakes' exposed axi output). Scope aligns. CI: run |
Intent
Contribute to upstream firstmate a fix so that the worker-state reader (bin/fm-crew-state.sh and the shared run-inventory helpers) never reports a confident-sounding "unknown" when the validation tool's run state is in fact readable.
The problem: for a worker in a task worktree, the reader printed
state: unknown - source: run-step - unreadable runs tablewhile running the validation tool's own status command inside that same worktree returned clean, well-formed output; other workers read correctly at the same instant.The supervision contract tells a supervisor to reconcile a worker's current state with this reader before deciding the worker is stuck, so a reader that degrades to unknown as a fleet grows is least reliable exactly when a busy fleet needs it most, and fails silently.
The fix: the run inventory must be looked up where the validation tool actually keys it (the primary checkout rather than the task worktree path), the reader must distinguish "I could not read this" from "this worker has no run of its own", and whenever it genuinely cannot read it must say
unreadablewith the reason, never a bare unknown that reads like a fact about the worker.What Changed
bin/fm-crew-state.shgains anunreadablestate word for the run-step source. It means the reader could not establish anything about the crew, so it is not a claim about the crew. A failed or timed-out primaryno-mistakes axi status, a failed or emptyno-mistakes axiinventory, a selected run whose status read fails or mismatches, contradicting records, an unrecognized status or outcome word, an untied head, and a daemon proven down all used to reportunknown. Each now emitsunreadablewith a reason that starts withcould not read …,could not settle …, orcould not verify …. A failed primary status read no longer falls through to the pane or status log. When the inventory read fails, therun ids:list is rebuilt from candidate ids only, so a selection reason is no longer spliced into it.bin/fm-nm-run-lib.sh,fm_nm_select_runnow gives each structural failure of the runs table its own reason: a missing or duplicate count line, a malformed count line, a repeated or unrecognized header, a wrong field count, or a row-count mismatch. Before, they all shared one "unreadable runs table" message. The Python reader for the state database also names its failure: the overview'srepo:line is missing or invalid JSON, the path is not absolute, the database cannot be opened, the repository is missing or recorded twice, or the rows do not validate. The displayed table naming runs the database lacks is reported ascould not settle. The selector still returnsunknown|…internally, andfm-crew-state.shturns that intounreadable.fm-fleet-snapshot.sh's secondmate home summary counts bothunknownandunreadablechildren as current-state unavailable. Comments infm-classify-lib.shandfm-inactive-reconcile.sh, anddocs/architecture.md, now sayunreadablewhere the dead-daemon verdicts used to sayunknown.tests/fm-crew-state.test.shnow expects the newunreadablelines.tests/fm-fleet-snapshot-view.test.shgains one home-summary test, so the CI check now expects 19 tests instead of 18.Looking up the run inventory by the primary checkout rather than the task worktree path already landed in #5327. Separately, #5888 already distinguishes a worker with no run of its own from everything else, using its own
runs_on_current_branch: 0check fromno-mistakes axi status. This change builds on both: it adds theunreadablestate word and a per-cause reason for every remaining case where the reader itself failed to read or settle the run, and it leaves #5888's no-run branch untouched. The other reader-side sources - the pane fallback and the ledger/daemon-down read - are deliberately left as they were; this change does not touch them.Risk Assessment
✅ Low: The change is bounded: run-step verdicts are relabelled, more precise reasons are added, and one consumer is widened. Every positive-match consumer (crew_absorb_class, fm-inactive-reconcile, the fleet-snapshot state parser) handles
unreadablethe same way it handledunknown. The fix round's new branch for a failed primaryaxi statusread fires only on a non-zero exit with empty stdout, so the uninitialized-repo error that the CLI prints on stdout still falls through to the pane as before.Testing
I drove six live scenarios. Each one ran the real fm-crew-state.sh, at both the target and the base commit, against the real no-mistakes CLI in a disposable NM_HOME and lab FM_HOME. The task-worktree happy path reads
workingwith the run id even though the run is outside the overview window. A hung primaryaxi status, an unreadable state DB, and an invalid same-branch DB row each now reportstate: unreadablewith a named cause; the base reportedunknown, and for the hang it fell through to the pane. A comma in a branch name does not cause a false unreadable, and a worker with no run is not called unreadable. The secondmate home-summary scenario is untested live; its unit suite passed 19/19. The 6k-line crew-state suite stopped at the 10-minute background limit after 249 passing cases and no failures, so CI owns its full run. The lab, the base worktree, and any stopped processes were all torn down. The result is go.no-mistakes axioverview (10 of 26) readsstate: working · source: run-stepwith its run idstate: working · source: run-step · validating (running) · run: 01TASKRUN001no-mistakes axi statushangs (real CLI SIGSTOPped, 3s budget): reader reportsunreadablenaming the call instead of falling back to pane/status logstate: unreadable · source: run-step · could not read the run: \no-mistakes axi status` did not answer(3s); basestate: unknown · source: none`unreadablewith the reason, never a bare unknownstate: unreadable ... \no-mistakes axi` failed; basestate: unknown ... run inventory unreadable`unreadablewith the specific validation cause and candidate run idsunreadablestate: working · source: run-stepruns_on_current_branch: 0) is not reportedunreadable(has-no-run is distinguished from could-not-read)state: unknown · source: none · backend target gone(pane-source claim, not run-step unreadable)unreadableas current-state-unavailabletests/fm-fleet-snapshot-view.test.shwas run (19/19 ok), and a unit test is not live. A live check needs a ru…Evidence: Live crew-state transcript: target vs base across six scenarios
Source: Live crew-state transcript: target vs base across six scenarios
Evidence: fm-fleet-snapshot-view test run (19 ok)
Source: fm-fleet-snapshot-view test run (19 ok)
Evidence: Key before/after lines
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
🔧 **Rebase** - 1 issue found → auto-fixed ✅
bin/fm-crew-state.sh- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/fm-crew-state.sh:1022- One run-step read failure still ends in a bareunknown. That is the failed or timed-out primaryno-mistakes axi statuscall.nm_run→fm_nm_run(bin/fm-nm-run-lib.sh:110-112) swallows the failure with|| true, soRUN_OUTis empty and the whole[ -n "$RUN_OUT" ]block is skipped. The reader then treats the crew exactly as if it had no run (fallback at bin/fm-crew-state.sh:1345). Concrete sequence: a ship crew is mid-validation on a busy fleet,axi statusexceedsNM_TIMEOUTagainst the contended daemon, and the pane is idle. If the status log has no mappable verb, the output isstate: unknown · source: none · no current-state source available(line 1440). If the log saysworking:, a status-log claim answers instead and the run is never mentioned. The intent requires that the reader "distinguish 'I could not read this' from 'this worker has no run of its own'" and that "whenever it genuinely cannot read it must sayunreadablewith the reason, never a bare unknown". This path does neither, and it is exactly the busy-fleet degradation the intent describes. The new header comment (lines 43-44, "the other sources still reportunknownand are unchanged") and the existing "nonresponding CLI is not retried" comment suggest this was a deliberate scope choice. Fixing it would change fallback behavior: a timeout would emitunreadable run-step "could not read the run: \no-mistakes axi status` did not answer"` instead of falling back to the pane or status log. So the author needs to decide whether this path is in scope.🔧 Fix applied.
✅ Re-checked - no issues remain.
bin/fm-crew-state.sh:1061- When the overview read fails and no run ids are available, the unreadable detail ends with an emptyrun ids:clause (S3 live output). This is cosmetic only: the state and reason are correct, and it is cleaner than the base'srun ids: , unavailable.no-mistakes axioverview (10 of 26) readsstate: working · source: run-stepwith its run idstate: working · source: run-step · validating (running) · run: 01TASKRUN001no-mistakes axi statushangs (real CLI SIGSTOPped, 3s budget): reader reportsunreadablenaming the call instead of falling back to pane/status logstate: unreadable · source: run-step · could not read the run: \no-mistakes axi status` did not answer(3s); basestate: unknown · source: none`unreadablewith the reason, never a bare unknownstate: unreadable ... \no-mistakes axi` failed; basestate: unknown ... run inventory unreadable`unreadablewith the specific validation cause and candidate run idsunreadablestate: working · source: run-stepruns_on_current_branch: 0) is not reportedunreadable(has-no-run is distinguished from could-not-read)state: unknown · source: none · backend target gone(pane-source claim, not run-step unreadable)unreadableas current-state-unavailabletests/fm-fleet-snapshot-view.test.shwas run (19/19 ok), and a unit test is not live. A live check needs a ru…Disposable no-mistakes home (NM_HOME=/tmp/fmcs.*/nm): the real CLI created the schema skeleton without starting a daemon; then I seededrepos/runsrows with sqlite3, added a gate bare repo plus ano-mistakesremote, and checked thatno-mistakes axi statusandno-mistakes axianswer from the task worktree (count: 10 of 26 total,repo: <primary checkout>)Lab FM home viabin/fm-lab-home.sh create, with akind=shipmeta for the task worktree; ranbin/fm-crew-state.sh taskfrom both the target and a base (127f0f30) worktree, with TMUX/fleet overrides unset and TMUX_TMPDIR pointing at a private dirS2: ran a lab-only copy of the realno-mistakesbinary on PATH, SIGSTOPped only theaxi statusprocess descended from my own reader, setFM_CREW_STATE_NM_TIMEOUT=3, and had aworking:status log presentS3:chmod 000on the lab state.sqlite, so the real CLI fails witherror: open database ...S4: inserted a same-branch run row withhead_sha='not-a-sha'into the lab DBS5: inserted a newest run on the branch namefm/a,bso it appears in the displayed runs tableS6: second task worktree onfm/none, which has no runs (runs_on_current_branch: 0)bash tests/fm-fleet-snapshot-view.test.sh(19/19 ok, including the case where the home summary reports an unreadable child state as current-state-unavailable)bash tests/fm-crew-state.test.sh: stopped at the 10-minute background limit after 249 passing cases and no failures; CI owns the full run✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.