Skip to content

fix(bin): look up crew run inventory by primary checkout and report unreadable reads as unreadable - #1

Merged
max-metaplanet merged 7 commits into
mainfrom
fm/crewstate-unknown
Sep 22, 2026
Merged

max-metaplanet merged 7 commits into
mainfrom
fm/crewstate-unknown

Conversation

@max-metaplanet

@max-metaplanet max-metaplanet commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Intent

The worker-state reader answers "unknown" when the underlying state is in fact perfectly readable, and that wording reads like a fact about the worker rather than a fact about the reader.

Observed at 2026-09-21 around 17:55 EDT in another firstmate home with four workers live.
Two of them read:

state: unknown - source: run-step - unreadable runs table; run ids:

while running the validation tool's own status command inside those same worktrees returned clean, well-formed output.
The other two workers, both with active runs, read correctly at the same instant.

A capture of that moment is at ~/firstmate/data/crewstate-unknown-evidence.txt.
It holds all four crew-state lines from one instant plus the raw status output from one of the unknown ones.
That capture is a dated observation from another home, not a finding: it records what the reader said and what the underlying tool said at the same moment, and nothing about why.
It must not substitute for a reproduction derived from the source.
If a reading of the code contradicts what the capture appears to show, the code wins, and that contradiction is itself wanted output.

Why this matters rather than being a shrug: a state reader that answers "unknown" when the state is readable is the precise defect class of something that cannot look reporting nothing to see.
The supervision contract tells a supervisor to reconcile a worker's current state with this exact tool before deciding that worker is stuck.
If it degrades to unknown as a fleet grows, the tool becomes least reliable exactly when a busy fleet needs it most, and the failure is silent.

Answer and deliver these four:

  1. Reproduce it and establish the real trigger, rather than confirming any offered guess.
    Two leads are offered below, both unproven and both to be disproved rather than assumed.
    If the trigger is a cap or truncation, say what the cap is and where it comes from, specifically whether the truncation is in the underlying tool's output or in firstmate's parse of that output.
  2. Say whether the reader can distinguish "I could not read this" from "this worker has no run of its own".
    Those are different answers and the current wording merges them.
  3. Fix it where the fix is small and clearly inside firstmate's own code.
    If the truncation originates in a tool firstmate only consumes, that is an upstream matter and it must be named as such before anything is changed.
    A workaround that hides someone else's truncation is not acceptable, because it reproduces this same defect one layer down.
  4. Whatever the fix, the reader must not be able to report a confident-sounding unknown again without saying why it could not read.

Carry into the PR body: what the reader will say INSTEAD of "unknown", and why that new wording cannot be mistaken for a fact about the worker.
The fix is not really the parse.
It is that a tool which cannot see must say so about itself.

What Changed

  • Trigger fixed, inside firstmate (bin/fm-nm-run-lib.sh): the runs table from no-mistakes axi stops at ten rows. That limit comes from the CLI itself, which reports it in its own count: <shown> of <total> total line. Firstmate does not cut the table. When the table is capped, firstmate rebuilds the full same-branch inventory by reading no-mistakes' state.sqlite read-only. That lookup searched working_path for the task worktree path. no-mistakes records a repository under the path of its primary checkout (verified against v1.72.0), so no crew's worktree ever matched. The new fm_nm_primary_checkout gets the primary checkout from git rev-parse --path-format=absolute --git-common-dir. The lookup now tries the worktree path first, then the primary checkout. Each is an exact match that must find exactly one row, and nothing is guessed from multiple candidates. Because of this, a branch with no run now reads as absent, and a live run pushed past the cap is found again. The ANSI banner was not the trigger, since it goes to stderr and is discarded. No upstream workaround was added.
  • The reader now says when it could not read (bin/fm-crew-state.sh, bin/fm-nm-run-lib.sh): when the run-step source cannot establish a claim about the crew, it now prints state: unreadable where it used to print state: unknown. Every such detail starts with what could not be established and why. It says could not read … when a read failed, and could not settle … / could not confirm … / could not tie … when the data read fine but still decided nothing. Examples: could not read this branch's run inventory: no-mistakes has no repository recorded at <wt> or <primary>, and could not verify this run: the no-mistakes daemon is unreachable…. The script header now defines unreadable as the only state word that describes the reader, not the crew, so it cannot be mistaken for a fact about the worker. Seeing it means nothing follows about what the crew is doing. It is also kept separate from "no run of its own", which reads as absent and falls through to the other sources. The pane, remote-endpoint and status-log sources still report unknown; they are out of scope here.
  • Consumers, docs and tests: consumers that act on crew state already match working / paused / parked / done / failed positively (crew_absorb_class, fm-inactive-reconcile.sh), so unreadable gets the same handling unknown did: no absorb, no terminal claim, and the wake is surfaced. fm-fleet-snapshot.sh now counts both unknown and unreadable children as child_current_unavailable. AGENTS.md, docs/architecture.md and the doc comments are updated to match. Tests in tests/fm-crew-state.test.sh cover: a linked-worktree branch with no run, a run found again beyond the cap, a repository recorded under neither path (the detail names both paths), a task-copy path spelled a different way, and each unreadable route. tests/fm-fleet-snapshot-view.test.sh checks that the snapshot recognizes the new state.

Report

1. The real trigger

The trigger is a crew whose own branch is missing from a capped runs table, run from a linked task worktree.
It is not the version banner.

  • The cap is ten rows and comes from the no-mistakes CLI, which declares it. no-mistakes axi prints at most ten runs and says so in its own count: <shown> of <total> total line.
    Firstmate does not truncate anything.
    The capture's count: 10 of 11 total is that declared cap.
  • The break is in firstmate's fallback, not in the tool's output. When the table is capped, firstmate rebuilds the complete same-branch inventory from no-mistakes' state.sqlite.
    At base it looked that repository up by the task worktree's own path.
    no-mistakes records a repository under its primary checkout's path, so from a linked worktree the lookup matched nothing.
    The reader then called the inventory unreadable (bin/fm-nm-run-lib.sh, the capped-inventory path; test test_task_worktree_with_no_run_of_its_own_reads_absent).
  • Lead 1 (the eleventh run) is half right. Crossing ten runs is what makes the fallback run at all.
    The workers that failed were the ones whose own branch was not in the ten shown rows.
    The two that read correctly had live runs at the top of the table.
    The fallback's lookup key is the real defect, not the parse of the table.
  • Lead 2 (the ANSI banner) is disproved. The upgrade banner goes to stderr, and the reader discards stderr before parsing.
    Its presence or absence changes nothing.

Where the code contradicts the capture

  • The capture says the CLI answered runs_on_current_branch: 0, and that was readable.
    The reader never consumes that field.
    It reads only the runs[...] table and the count: line.
    So the direct "no run for this branch" answer was on screen and ignored.
    The fix does not start consuming it; see follow-ups.
  • The capture's wording (unreadable runs table; run ids:) is not this repository's base wording.
    Base prints complete same-branch run inventory unreadable; run ids:.
    So the capturing home was running an older firstmate reader.
    The same lookup-key defect reproduces on this base (evidence S1 above).

2. Could the reader tell "could not read" apart from "no run of its own"?

At base, no.
Both came out as state: unknown · source: run-step · … unreadable; run ids: with an empty id list.
Now they are two answers:

  • No run of its own reads absent from the run-step source.
    The reader then falls through to the pane, endpoint and status sources, as for any worker that has not started validation.
  • Could not read reads state: unreadable, and its detail starts with what could not be established and why.

3. Upstream or firstmate?

It is firstmate, not upstream.
The CLI's ten-row cap is declared in the CLI's own output rather than hidden, and its data was correct.
The defect was firstmate's lookup key, so the fix is firstmate's own: an exact-match lookup by the primary checkout from git rev-parse --git-common-dir.
No upstream workaround was added and no upstream issue text is needed.

4. What the reader says instead of "unknown", and why it cannot be read as a fact about the worker

Where the run-step source used to say state: unknown, it now says state: unreadable, followed by the reader's own reason.
For example:

state: unreadable · source: run-step · could not read this branch's run inventory: no-mistakes has no repository recorded at <worktree> or <primary checkout>
state: unreadable · source: run-step · could not read this branch's run inventory: the state-database reader (python3) could not be run or did not finish

unknown read as a property of the worker, as in "its state is unknown".
unreadable is defined in the fm-crew-state.sh header as the one state word that describes the reader and not the crew.
Every detail after it opens with could not read …, could not settle …, could not confirm … or could not tie ….
That puts the reader in the grammatical subject and names what failed.
So a supervisor reading it learns something about the tool, and nothing about whether the worker is busy, stuck or finished.
Consumers match working/paused/parked/done/failed positively, so unreadable never absorbs a wake or claims an outcome.

Tests fail first

I ran the PR's tests at head 63d49943 against the pre-fix bin/ from base f5735dc2.

  • Full files: both tests/fm-crew-state.test.sh and tests/fm-fleet-snapshot-view.test.sh fail against the pre-fix code and pass at head, with 188 and 19 checks respectively.
  • Individually against the pre-fix code, each of these prints the old state: unknown … inventory unreadable; run ids: verdict and fails:
    • test_task_worktree_with_no_run_of_its_own_reads_absent
    • test_task_worktree_recovers_a_run_hidden_beyond_the_cap
    • test_unreadable_inventory_says_so_about_itself
    • test_capped_inventory_requires_a_recorded_repository
  • All four pass at head.
  • One guard passes both ways by design: test_no_branch_run_beside_a_live_run_elsewhere_reads_absent.
    It runs from the primary checkout itself, where the old lookup already worked.
    It pins that case and is not offered as regression evidence.

Follow-ups (not done here)

  • Pane, endpoint and status-log sources: these still report unknown when they cannot read.
    Giving them the same reader-voiced unreadable wording is a separate change.
  • runs_on_current_branch: the CLI's own field could serve as a direct, declared "no run for this branch" answer.
    That would avoid the state-database fallback for that case.
    It is worth considering once its stability across no-mistakes versions is confirmed.

Risk Assessment

✅ Low: The change is bounded to firstmate's own run-step reader: an exact-match primary-checkout lookup, a new reader-voiced unreadable state word, and updated detail strings. Every consumer I traced (crew_absorb_class, crew_gate_awaits_human_decision, fm-inactive-reconcile, the fleet-snapshot parser and home summary, bearings) either matches crew states positively or was updated to accept unreadable. The new tests exercise the executable interface rather than grepping source.

Testing

I built an isolated lab: a real primary checkout with a linked task worktree, a private NM_HOME, a real no-mistakes init and 11 seeded runs. In it I ran the real no-mistakes axi CLI and the base and target fm-crew-state.sh side by side. Base reproduces the empty-id unknown verdict from the capture. Target reads "absent" when the crew has no run, recovers a run hidden beyond the cap, and reports unreadable with a cause that names the reader when the reader breaks or hangs. I also ran the change's targeted crew-state and fleet-snapshot tests, and all passed. Those tests are the only coverage for the fleet-snapshot consumer and the other unreadable causes, so those two scenarios are marked untested. The lab daemon was stopped and the lab directory removed. no-mistakes init refreshed its own user-level skill files, which is expected CLI behaviour. Herdr was not needed because the change never touches pane or session mechanics.

  • Live validation: ✅ go - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Reproduce: a crew in a linked worktree whose branch has no run, behind the real CLI's 10-row cap, reads as a confident-sounding unknown at base; the cap is set by the no-mistakes CLI itself ✅ pass live s1-no-own-run-capped-overview.txt: the real CLI prints count: 10 of 11 total and repo: &lt;primary checkout&gt;; base prints `unknown · run-step · complete same-branch run inventory unreadable; run ids:…
The reader tells 'no run of its own' apart from 'could not read': a crew with no run reads absent and falls through to the other state sources instead of an unknown from the run-step source ✅ pass live s1 target: state: unknown · source: none · no backend target recorded (no run-step verdict; the lab has no pane); fm_nm_select_run returns absent
A crew's own run that sits beyond the CLI cap is recovered from the recorded primary-checkout repository and reported authoritatively ✅ pass live s2-own-run-below-cap.txt: base unknown ... inventory unreadable; target done · run-step · run passed · run: 01LABOWN...
Adversarial: when the state-database reader is broken or hangs, the verdict is unreadable and names the reader as what failed, with no inferred cause and no claim about the crew ✅ pass live s3-reader-broken.txt: state: unreadable · run-step · could not read this branch&#39;s run inventory: the state-database reader (python3) could not be run or did not finish; the hang case finishes within…
Consumer: the fleet snapshot's secondmate home summary treats a child in the unreadable state as current-state-unavailable ⏸️ untested no The prior payload did not establish a live result. Driving this live needs a running secondmate home with a child crew, and none was set up. Only the focused test test_home_summary_treats_unreadable_c…
Other unreadable reasons (repository recorded under neither path, database cannot be opened, competing live runs, a selected run that cannot be verified) name their cause ⏸️ untested no The prior payload did not establish a live result. The real CLI and the reader share one NM_HOME, so these database states cannot be set up under a working real CLI without corrupting it. Only the exe…
Evidence: S1: crew with no own run under a capped real CLI overview (base vs target)

Source: S1: crew with no own run under a capped real CLI overview (base vs target)

repo: /private/tmp/fmlab/primary count: 10 of 11 total (base) state: unknown · source: run-step · complete same-branch run inventory unreadable; run ids: (target) state: unknown · source: none · no backend target recorded

=== S1: crew branch fm/lab-crew has NO run; 11 runs on other branches; linked worktree /tmp/fmlab.5TdD/wt of primary /tmp/fmlab.5TdD/primary
--- sqlite repos (isolated NM_HOME)
f75ace03534e|/private/tmp/fmlab.5TdD/primary
--- real CLI: no-mistakes axi (from linked worktree)
repo: /private/tmp/fmlab.5TdD/primary
current_branch: fm/lab-crew
count: 10 of 11 total
runs[10]{id,branch,status,head,pr}:
--- fm-crew-state.sh labcrew (base)
state: unknown · source: run-step · complete same-branch run inventory unreadable; run ids: 
--- fm-crew-state.sh labcrew (target)
state: unknown · source: none · no backend target recorded
Evidence: S2: own run hidden beyond the CLI's 10-row cap (base vs target)

Source: S2: own run hidden beyond the CLI's 10-row cap (base vs target)

count: 10 of 12 total (base) state: unknown · source: run-step · complete same-branch run inventory unreadable; run ids: ; last reported run id: 01LABOWN... (target) state: done · source: run-step · run passed: PR state unknown (no PR identity) · run: 01LABOWN...

=== S2: crew branch fm/lab-crew has its own completed run 01LABOWN..., older than the 10 displayed rows
repo: /private/tmp/fmlab.5TdD/primary
current_branch: fm/lab-crew
count: 10 of 12 total
--- real CLI id-addressed read
outcome: passed
--- fm-crew-state.sh labcrew (base)
state: unknown · source: run-step · complete same-branch run inventory unreadable; run ids: ; last reported run id: 01LABOWN000000000000000000
--- fm-crew-state.sh labcrew (target)
state: done · source: run-step · run passed: PR state unknown (no PR identity) · run: 01LABOWN000000000000000000
Evidence: S3: broken / hung python3 reader says so about itself

Source: S3: broken / hung python3 reader says so about itself

(target) state: unreadable · source: run-step · could not read this branch's run inventory: the state-database reader (python3) could not be run or did not finish; run ids: ; last reported run id: 01LABOWN... (hang) same verdict, elapsed 11s

=== S3a: python3 on PATH exits 1 (reader broken); crew has own run below cap
--- (base)
state: unknown · source: run-step · complete same-branch run inventory reader unavailable; run ids: ; last reported run id: 01LABOWN000000000000000000
--- (target)
state: unreadable · source: run-step · could not read this branch's run inventory: the state-database reader (python3) could not be run or did not finish; run ids: ; last reported run id: 01LABOWN000000000000000000
=== S3b: python3 hangs; reader killed by per-read budget (FM_CREW_STATE_NM_TIMEOUT if honored)
203:NM_TIMEOUT=${FM_CREW_STATE_NM_TIMEOUT:-10}
204:case "$NM_TIMEOUT" in ''|*[!0-9]*) NM_TIMEOUT=10 ;; esac
state: unreadable · source: run-step · could not read this branch's run inventory: the state-database reader (python3) could not be run or did not finish; run ids: ; last reported run id: 01LABOWN000000000000000000
elapsed 11s
Evidence: Targeted crew-state and fleet-snapshot tests

Source: Targeted crew-state and fleet-snapshot tests

ok - home summary reports an unreadable child state as current-state-unavailable
ok - a repository recorded under neither path reads unreadable and says why
ok - a non-canonical task copy path still reaches its recorded repository
ok - a task worktree whose branch has no run reads absent, not unreadable
ok - a run hidden beyond the CLI cap is recovered for a task worktree
ok - an unreadable run inventory reports the read failure and its reason
ok - missing complete-inventory failure reports unknown
ok - corrupt complete-inventory failure reports unknown
ok - schema complete-inventory failure reports unknown
ok - repo complete-inventory failure reports unknown
ok - count complete-inventory failure reports unknown
ok - competing live runs report unknown with both run ids
ok - missing run selection reports unknown with candidate ids
ok - wrong-id run selection reports unknown with candidate ids
ok - wrong-branch run selection reports unknown with candidate ids
ok - wrong-head run selection reports unknown with candidate ids
ok - missing-status run selection reports unknown with candidate ids
ok - malformed-table run selection reports unknown with candidate ids
ok - inventory-error run selection reports unknown with candidate ids
ok - selected-error run selection reports unknown with candidate ids
rc=0

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ bin/fm-nm-run-lib.sh:241 - This is about the narrative, not the code. Caveat 6 in bc9a0fc's commit body says the observed home's firstmate revision at 17:55 EDT 'cannot be read from here', so its pre-43bf6d3 attribution is only an inference. That revision can in fact be read. The observed home's reflog (git -C ~/firstmate reflog) shows HEAD at b752ced from 2026-09-17 18:48 EDT until 2026-09-22 14:21 EDT. b752ced does not contain 43bf6d3 (git merge-base --is-ancestor 43bf6d3 b752cedf fails). Its awk END branch prints exactly unknown|unreadable runs table; run ids: for the uncoerced seen/expected comparison, while its sqlite fallback prints complete same-branch run inventory unreadable. So the byte-match attribution to pre-43bf6d3 code is confirmed rather than inferred. The PR body can state this as fact, which strengthens the intent's 'the code wins' reconciliation. No source change is needed.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Reproduce: a crew in a linked worktree whose branch has no run, behind the real CLI's 10-row cap, reads as a confident-sounding unknown at base; the cap is set by the no-mistakes CLI itself ✅ pass live s1-no-own-run-capped-overview.txt: the real CLI prints count: 10 of 11 total and repo: &lt;primary checkout&gt;; base prints `unknown · run-step · complete same-branch run inventory unreadable; run ids:…
The reader tells 'no run of its own' apart from 'could not read': a crew with no run reads absent and falls through to the other state sources instead of an unknown from the run-step source ✅ pass live s1 target: state: unknown · source: none · no backend target recorded (no run-step verdict; the lab has no pane); fm_nm_select_run returns absent
A crew's own run that sits beyond the CLI cap is recovered from the recorded primary-checkout repository and reported authoritatively ✅ pass live s2-own-run-below-cap.txt: base unknown ... inventory unreadable; target done · run-step · run passed · run: 01LABOWN...
Adversarial: when the state-database reader is broken or hangs, the verdict is unreadable and names the reader as what failed, with no inferred cause and no claim about the crew ✅ pass live s3-reader-broken.txt: state: unreadable · run-step · could not read this branch&#39;s run inventory: the state-database reader (python3) could not be run or did not finish; the hang case finishes within…
Consumer: the fleet snapshot's secondmate home summary treats a child in the unreadable state as current-state-unavailable ⏸️ untested no The prior payload did not establish a live result. Driving this live needs a running secondmate home with a child crew, and none was set up. Only the focused test test_home_summary_treats_unreadable_c…
Other unreadable reasons (repository recorded under neither path, database cannot be opened, competing live runs, a selected run that cannot be verified) name their cause ⏸️ untested no The prior payload did not establish a live result. The real CLI and the reader share one NM_HOME, so these database states cannot be set up under a working real CLI without corrupting it. Only the exe…
  • Lab: git init primary checkout + git worktree add -b fm/lab-crew ../wt, NM_HOME=&lt;lab&gt;/nm no-mistakes init (real v1.72.0; recorded working_path is the primary checkout), 11 runs on other branches seeded into the lab state.sqlite
  • NM_HOME=&lt;lab&gt;/nm no-mistakes axi from the linked worktree (real CLI prints repo: &lt;primary&gt; and count: 10 of 11 total)
  • bin/fm-crew-state.sh labcrew at base f5735dc vs target 63d4994 with isolated FM_HOME meta, crew branch has no run (S1)
  • fm_nm_select_run at base vs target on the real capped overview (base: unknown|...unreadable; run ids:, target: absent)
  • Same comparison after seeding a completed own-branch run older than the 10 displayed rows (S2), incl. real no-mistakes axi status --run read
  • Adversarial: python3 on PATH exits 1, and python3 hangs past the 10s per-read budget (S3a/S3b)
  • Targeted tests: fleet-snapshot test_home_summary_treats_unreadable_child_as_unavailable; crew-state test_capped_inventory_requires_a_recorded_repository, test_capped_inventory_canonicalizes_the_task_copy_path, test_task_worktree_with_no_run_of_its_own_reads_absent, test_task_worktree_recovers_a_run_hidden_beyond_the_cap, test_unreadable_inventory_says_so_about_itself, test_capped_inventory_failures_report_unreadable, test_competing_live_runs_report_unreadable_with_both_ids, test_unverifiable_run_selection_reports_unreadable
  • Teardown: NM_HOME=&lt;lab&gt;/nm no-mistakes daemon stop, lab dir removed
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…ctually recorded

The crew-state reader answered `state: unknown - source: run-step -
unreadable runs table` for crews whose branch simply had no validation
run, so a readable state read as an unknown worker.

Root cause, established from source and reproduced live against
no-mistakes v1.72.0: `no-mistakes axi`'s runs table is capped at ten rows
by the CLI itself, which declares the cap in its own `count: <shown> of
<total> total` line. Firstmate correctly refuses to treat that window as
complete and recovers the whole same-branch inventory from the CLI's own
state database - but it looked the repository up by the TASK WORKTREE
path, and no-mistakes registers a repository under its PRIMARY CHECKOUT
path, never under a linked worktree. The lookup matched zero rows for
every crew, since every crew works in an isolated worktree, and the
reader reported the whole inventory unreadable. The same failed lookup
also lost a genuinely running validation whenever the cap hid its row.

Neither offered lead was the trigger. The cap is the CLI's own and is
declared, not hidden; the ANSI version banner goes to stderr, which every
call in this path discards.

Fix, entirely in firstmate's own code: resolve the worktree's primary
checkout from `git rev-parse --path-format=absolute --git-common-dir` and
ask for it after the worktree path, each still an exact `working_path`
match requiring exactly one recorded row. Nothing is guessed among
candidates, and a repository recorded under neither path still reports
the read as unreadable - naming both paths it asked for.

A run-step read that fails now reports `state: unreadable` rather than
`state: unknown`, and every such detail opens with what could not be read
and why. `unreadable` is the one state word that is a claim about the
reader rather than about the crew; the script header owns that contract.
Five previously indistinguishable read failures now name their own cause.
Scope is the run-step reader only - the pane, remote-endpoint and
metadata sources still report `unknown`. Consumers match `working`,
`paused`, `parked`, `done` and `failed` positively, so `unreadable` is
handled exactly as `unknown` was.

Five colocated tests, each confirmed to fail against the pre-fix code
first: a task worktree whose branch has no run reads absent; a run hidden
beyond the CLI cap is recovered; an unreadable inventory reports the read
failure and its reason; a repository recorded under neither path still
reads unreadable; and a non-canonical task copy path still reaches its
recorded repository.
…ranch narrative

Two wording fixes, plus the corrected reproduction account this branch owed.

Fix 1 - the overview-failure emit spliced the ENTIRE selection reason into
its own `run ids:` field. `${run_choice##*|}` strips through the last `|`, and
the reworded reasons contain none, so a whole sentence carrying its own
`run ids:` clause landed where ids belong: one crew line asserting two
different causes, with prose sitting inside a run-id list. Reachable whenever
the bounded `no-mistakes axi` call exits non-zero after printing part of the
table. Now only the candidate ids are spliced, for every selection shape, and
an empty id list adds nothing rather than a dangling comma.

Fix 2 - `the displayed runs table names runs the state database does not have`
fires when BOTH reads succeeded and merely disagree (a run pruned between the
`axi` call and the sqlite read), yet it inherited the shared
`could not read the complete run inventory for this branch:` opening. That
contradicted the contract this branch just wrote: a read that failed says so; a
read that succeeded names the thing it could not settle. It now opens with
`could not settle ...`; the four genuine read failures keep the read wording.

=== Corrected reproduction account ===

The reproduction narrative in 44da25f is wrong and is corrected here rather
than left to stand. It opened by attributing
`state: unknown - source: run-step - unreadable runs table` to the
worktree-path repo lookup. The source disproves that: at base 8c1cdb7 the
lookup failure prints `complete same-branch run inventory unreadable; run ids: `,
while `unreadable runs table; run ids: ` comes ONLY from the awk
structural/invalid_run branches, which a well-formed `count: 10 of 11 total`
header with zero same-branch rows never reaches.

One input set - a real linked git worktree whose primary checkout is what
no-mistakes recorded, a real capped `no-mistakes axi` overview (v1.72.0)
carrying its own `count: 10 of 11 total`, and a branch with no run of its own -
run through three code generations of fm_nm_select_run:

  pre-43bf6d3 -> unknown|unreadable runs table; run ids:
  43bf6d3     -> unknown|complete same-branch run inventory unreadable; run ids:
  this change -> absent

The first line is byte-identical to the 2026-09-21 17:55 EDT capture, including
the empty run ids.

1. The captured STRING was produced by pre-43bf6d3 code. 43bf6d3 landed
   2026-09-21 03:49:53 -0700 (06:49 EDT), about eleven hours before the
   capture, and changed that wording. This change does not fix the code path
   that printed those exact words.

2. 43bf6d3 changed the wording and LEFT THE VERDICT. The same crews, in the
   same condition, still read `state: unknown - source: run-step` on
   post-43bf6d3 code; only the detail text moved. Had the observed home been
   updated before 17:55, those two crews would still have read unknown, with
   different words.

3. Two successive causes of one continuing symptom:
   - Cause 1 (pre-43bf6d3): awk's uninitialized `seen` was string-compared
     against `expected`, so a legitimately zero-row recovered inventory took
     the structural-failure branch instead of `absent`. Closed by 43bf6d3's
     `+0` coercion.
   - Cause 2 (43bf6d3 onward): the same commit switched the repo lookup from
     the overview's own `repo:` line to the task worktree path. A task worktree
     is never the recorded `working_path`, so the recovery that would establish
     `absent` fails before it starts. Closed by this change.

4. 43bf6d3 closed cause one and opened cause two. Its stated premise that the
   real CLI overview never carries a `repo: ` identity line is false: live
   `no-mistakes axi` v1.72.0 prints `repo: <primary checkout>`, verified
   read-only against a registered repository on 2026-09-21.

5. 43bf6d3's own regression test passed only because its fixture registered the
   repository at the worktree path - the shape a standalone clone has, not the
   shape a crew has. The symptom survived the test written to catch it. That
   gap is what the new linked-worktree tests in this change close.

6. Caveat, kept visible rather than tidied away: the observed home's firstmate
   revision at 17:55 cannot be read from here, so the pre-43bf6d3 attribution
   is inference from the capture plus the code - now backed by a byte-match
   reproduction rather than by resemblance.

7. Conclusion, stated rather than left to be inferred: this change fixes the
   SYMPTOM THAT WAS REPORTED, not a lookalike, because the verdict persisted
   across both causes and only the wording changed. Both things are true and
   both are said here: the fix is needed, and the fix explains what we saw.

=== Corrected consumer claim ===

44da25f also asserted that consumers match `working`, `paused`, `parked`,
`done` and `failed` positively, so `unreadable` is handled exactly as `unknown`
was. That was false. One consumer matches the unread verdict ITSELF positively:
fm-fleet-snapshot.sh's secondmate home summary selected only
`.current_state.state == "unknown"` to report `child_current_unavailable`, so
every crew reporting the new word silently dropped out of that set and the home
summary called itself valid. Review caught it; the selector now accepts BOTH
words, the sources that still emit `unknown` keep working, and the script
header names that consumer so any future one inherits the obligation.
…not know

Fix 1 - the sqlite reader's shell fallback asserted an inferred cause with
four reachable outcomes behind it: `the state-database reader (python3) did
not run here`. That branch is taken whenever `fm_nm_bounded` returns non-zero,
which covers no bounding tool on PATH and python3 absent (the claim is true),
but ALSO the reader being killed by the per-read budget and the reader dying
before printing - in both of which it ran. This change's own tests exercise
those two: the time-bound test installs a `python3` that sleeps past a 1s
budget, and the no-sqlite test drives an unimportable `sqlite3` through the
same line. It now reports the outcome the caller actually observed - `the
state-database reader (python3) could not be run or did not finish` - which is
true for all four. This was the change's own defect class turned on itself: a
reader must not advertise a precision it does not have.

Folded in, same strings: the shared opening clause is now `could not read this
branch's run inventory: ` (44 characters, from 59). bin/fm-bearings-snapshot.sh
renders an in-flight ship's `doing:` at 90 characters, so the WHY now survives
with 46 characters of cause instead of 31. Bearings itself is unchanged - only
these strings. The settle-class opening keeps its own verb for the reasons
where every read succeeded.

Fix 2 - the overview-failure emit guarded only the trailing side of its id
list, so an absent record id rendered `run ids: , 01A, 01B`. Empty is the
NORMAL shape for exactly the population this change targets: `axi status` for a
crew whose branch has no run of its own prints no `id:` key at all. The list is
now built from the non-empty parts on both sides, so each of the four
combinations renders cleanly and an empty list renders nothing.

Correction to 523d2b4's body: it claimed "an empty id list adds nothing rather
than a dangling comma". That was only half true - it held for an empty
OVERVIEW id list and not for an empty RECORD id, which is the commoner case.
Fix 2 above makes it true on both sides. The neighbouring `run id: ` emit one
line up renders the same empty tail, but that shape is base behaviour
(`run inventory unavailable; run id: ` at 8c1cdb7), so it is deliberately left
alone rather than widening this change.
…t out of date, not because of a code defect. The PR adds a test to tests/fm-fleet-snapshot-view.test.sh ("home summary reports an unreadable child state as current-state-unavailable"). Under stock Bash 3.2.57, all 19 tests in that file passed, but the "Stock macOS Bash snapshot compatibility" step in .github/workflows/ci.yml requires exactly 18 passing tests, so it failed with "expected 18 ... got 19". I changed the expected count in that step and its error message from 18 to 19. I checked it locally: running the file with /bin/bash (GNU bash 3.2.57) gives 19 `ok -` lines and no other output. The Bearings count of 59 was not changed, because this PR does not touch the Bearings test file
@max-metaplanet
max-metaplanet merged commit 5899ac1 into main Sep 22, 2026
19 checks passed
max-metaplanet added a commit that referenced this pull request Oct 6, 2026
…nreadable reads as `unreadable`

Carried from fork commit 5b96510 (#1), with its no-mistakes review fixups
already squashed in upstream of this re-pick.

Conflict resolutions against the new base:

bin/fm-nm-run-lib.sh is the genuine merge the rehearsal flagged.
Upstream has since factored the state-database path out of the Python reader
into the shell helper fm_nm_state_db, so that helper stays the one owner of
where the database lives and is passed in as an argument; this commit's
three-candidate repo lookup (the overview's own `repo:` line, then the task
worktree, then the primary checkout fm_nm_primary_checkout computes) and its
named Unreadable/Unsettled reasons layer on top of it.
The header keeps upstream's slimmer database sentence rather than reinstating
this commit's dated ten-row-cap evidence, which upstream deliberately removed
and which belongs in a verification record rather than a script header.

bin/fm-crew-state.sh splits per case arm.
The `cancelled` arms take upstream's reading, because upstream's cancelled-run
fix is exactly what this commit's older `failed` reading got wrong: a
cancellation is no verdict, not a failure.
The `*)` fallback arms keep this commit's reading, so a status or outcome word
the reader does not recognize is named as itself rather than passed through as
though it had been understood.

docs/architecture.md keeps this commit's `unreadable` wording for the two
dead-instrument sentences, matching the code this pick lands, and keeps
upstream's newer third sentence listing a declared wait still standing after
later resolved lines for other keys.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant