Repository navigation
fix(bin): treat a live no-mistakes run as current after rebase - #4973
Merged
kunchenguid merged 19 commits intoSep 20, 2026
Merged
Conversation
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.
Intent
Finish the crew-state rebase fix. The implementation is already committed as a8887dd1 (live no-mistakes run is current after rebase). Run the firstmate no-mistakes pipeline and land it. Captain said finish everything.
What Changed
bin/fm-crew-state.shnow binds an EXECUTING no-mistakes run (pending,running,fixing,ci) on the crew's own branch regardless of head, via the newfm_nm_run_is_executingpredicate inbin/fm-nm-run-lib.sh, so a pipeline that rebased the branch or committed a fix round in its own checkout no longer reads as an older failed run at the local head. Every other run — parked or terminal — keeps the strict head-equality/ancestry rule, and the ledger fallback still refuses branch-name-only acceptance.daemon statusprobe:nm_daemon_probecaches one bounded call per crew read with three distinguishable answers (up,unanswered,down),nm_daemon_answered_downwithdraws the bind only on an answered-down daemon (a slow/unanswered probe no longer flaps the crew between working and failed), and an id-addressed anchored continuation whose daemon answered down reportsunknownwith the record named as unverified. Runs parked at a gate keep their gate and findings, and an openneeds-decision/blockedevent from the crew's own log still answers with the unverified record given as the reason.bin/fm-nm-run-lib.sh(FM_NM_GATE_LINE_RE,FM_NM_AWAITING_AGENT_RE,FM_NM_GATE_SCALAR_RE,FM_NM_GATE_ROW_RE) consumed by bothfm_nm_run_is_parkedand the crew-state gate readers;tests/fm-crew-state.test.shadds ~35 cases covering rebased live binds, diverged/unprovable heads, parked-gate exemption, and each daemon-probe answer, withAGENTS.mdanddocs/architecture.mdupdated to match.Risk Assessment
Testing
I stood up real crew worktrees (real git repos with genuinely diverged 'pipeline rebased' heads, real append-only status logs, real state dirs) and ran the actual bin/fm-crew-state.sh, bin/fm-fleet-snapshot.sh and bin/fm-fleet-view.sh against them; only the external
no-mistakesCLI is stubbed, since its daemon-down, rebased-run and ledger states cannot be manufactured on this host. The reported regression reproduces on the base commit (the crew readsfailed / status-logfrom a stale event while its run is live) and is fixed on this change (working / run-step · validating (running) · run: 01LIVE), visible all the way up in the human Fleet View table an operator reads. Every adversarial guard held: a parked run at a rebased head is still refused, an answered-down daemon suppresses the head-free live bind, an unanswered probe does not drop a working crew back to a stale log, an open decision stays parked and names the unreachable daemon, and the coarse ledger route keeps exactly the pre-existing readings the last two review rounds asked for. The targeted crew-state suite and the fleet-snapshot-view suite pass in full. The only failure I saw anywhere,herdr-preflight-missing-adapterin the teardown suite, fails identically from a clean base-commit tree and is therefore pre-existing. No screenshot/GIF applies: every surface this change touches is a text CLI line and a markdown fleet-view table, both captured verbatim as artifacts.bin/fm-crew-state.sh s1over a real worktree whose live run head diverged ->state: working · source: run-step · validating (running) · run: 01LIVE(crew-state-scenarios.txt, S1)git archive 2bcb88c bin) ->state: failed · source: status-log · earlier stage run(crew-state-scenarios.txt, S1 'before')bin/fm-crew-state.sh, each readingstate: working · source: run-stepwith the matching detail (run active (pending),validating (running),validating (fixing),ci running) (…state: working · source: status-log · implementing; nosource: run-stepand noparked at reviewleak (crew-state-scenarios.txt, S3)state: blocked · source: status-log · waiting on review; the run step does not answer (crew-state-scenarios.txt, S4)state: working · source: run-step · validating (running)(crew-state-scenarios.txt, S5)needs-decisiontip -> `state: parked · source: status-log · approve the schema change · no-mistakes daemon unreachable;…runningrow, daemon answered down ->state: working · source: run-step · validating (background run) · status-log superseded by active run; no `dae…failedrow + daemon down + openneeds-decisiontip -> `state: unknown · source: run-step · no-mistakes daemon unreachable; last ledger record failed - unverified · status-log supe…bin/fm-fleet-snapshot.sh --json+bin/fm-fleet-view.shover a fixture FM_HOME: row goes fromfailed / status-log(base) toworking / run-step(this change) while the status log's last event st…Evidence: Crew-state scenario transcript (8 scenarios, incl. base-commit before/after)
Source: Crew-state scenario transcript (8 scenarios, incl. base-commit before/after)
Evidence: Fleet View (operator surface) before vs after, same fixture
Source: Fleet View (operator surface) before vs after, same fixture
Evidence: Targeted suite output for the rebase / daemon / coarse cases
Source: Targeted suite output for the rebase / daemon / coarse cases
Evidence: Fleet View row flip (the one-line operator-visible result)
Pipeline
Updates from git push no-mistakes
... (86 earlier update rounds omitted to keep the PR body within GitHub's 65536-char limit; full history is in the run log.)
🔧 Fix applied.
3 issues (2 warnings, 1 info) still open:
bin/fm-crew-state.sh:71- The rewritten header states at :70-72 that "A record whose daemon has ANSWERED down reads unknown and names the dead instrument - but only once identity is already proven, by head equality/ancestry or by the ledger anchor." The head-equality half of that is not implemented, and the same header contradicts it 20 lines earlier at :52 ("must not answer once the worktree has moved off the run head").Concrete trace: pipeline run on fm/feat-x, run head == worktree HEAD (no rebase yet), run record
running, daemon dead. bin/fm-crew-state.sh:796nm_run_head_matches_worktreeis true, so HAVE_RUN=1 on the first arm and RUN_DEAD_DAEMON is never set (it is only set in the :798 unresolvable-head elif and in the :870-876 coarse block). The full TOON parse at :959 readsrunningand the crew emitsstate: working | source: run-step | validating (running)- indefinitely, for a run that is not progressing. Rebase the same branch once and the same dead daemon now yieldsstate: unknown | no-mistakes daemon unreachable; last ledger record running - unverified(:870-876). Same failure, two opposite verdicts to the supervisor, and the header claims the second one for both.This is not a regression - the head-match route behaved this way at the base commit - but the change introduces the dead-instrument verdict on every neighbouring route and writes the broad rule into the contract header, so the gap is now a live inconsistency rather than an absent feature.
Remedy is a product decision, hence ask-user: either narrow :70-72 to say the verdict applies only to the ledger-anchor and moved-off-head routes (comment-only, no behavior change), or extend the verdict to the head-match arm (changes the emitted state for every head-matching live run whenever the daemon is down - a user-visible fleet-wide change that also needs the parked exemption applied there). Note the second option extends the change beyond its stated intent, so it needs authorization either way.
tests/fm-crew-state.test.sh:3656- Four tests added by the fix rounds are named and commented as proving how the dead-daemon VERDICT behaves, but after commit 5fea3d3 dropped the two unproven-record binds their scenarios no longer set RUN_DEAD_DAEMON at all - they exercise the plain no-run status-log fallback and would still pass if the reconciliation emit at bin/fm-crew-state.sh:1033-1035 were deleted outright.Traced for test_needs_decision_survives_the_dead_daemon_verdict (:3656): FM_FAKE_AXI_HOME is unset so the fake
axiwith no args echoes the run TOON, fm_nm_select_run answersunavailableand the case at bin/fm-crew-state.sh:772 falls through -> legacy route at :827: run_branch matches, head is the rebased (resolvable but diverged) sha so nm_run_head_matches_worktree fails, branch_sync issyncedso the custody exemption fails, andfm_nm_run_is_executing && ! nm_daemon_answered_downfails because the daemon answered down -> else branch at :850 with FM_FAKE_RUNS_LIST="" -> COARSE_STATUS empty -> HAVE_RUN stays 0. The whole HAVE_RUN block, including RUN_DEAD_DAEMON, is skipped;state: parkedcomes from the status-log fallback.assert_not_contains "$out" "superseded"can never fail on that path.Same for test_socket_refused_log_survives_the_dead_daemon_verdict (:3631) and test_selected_run_dead_daemon_leaves_the_open_decision_open (:3917, selected route -> neither arm at :796/:798 fires -> HAVE_RUN=0 with SELECTED_RUN_ID set, so the coarse fallback at :816 is skipped too). test_selected_run_diverged_head_reports_the_dead_daemon (:3604) is named "reports the dead daemon" while asserting the record does NOT bind and the status log answers.
Consequence beyond the misleading names: the RUN_DEAD_DAEMON reconciliation emit is now covered only by the two coarse needs-decision tests (:3792, :3950); no test reaches it with a
blockedlog tip, which the header at :107-115 says must stay blocked with the unverified record named.Remedy (mechanical, no behavior change): retarget these to a shape that actually binds - an anchored ledger row like test_anchored_continuation_still_needs_a_live_daemon (:3820) uses - or rename them to what they now prove, and add one anchored dead-daemon case with a
blocked:tip.bin/fm-crew-state.sh:1037- The guard&& ! { [ "$RUN_SOURCE" = coarse ] && [ "$RUN_STATE" = unknown ]; }at bin/fm-crew-state.sh:1037 is left over from the round-10 shape and is now almost entirely unreachable: every coarse-unknown case it was written for now sets RUN_DEAD_DAEMON and exits through the emit at :1034 (the coarsefailed+ probe-down case was routed through RUN_DEAD_DAEMON at :913, and the :870-876 coarse live case sets it directly).The one surviving reachable case is the
*)default arm at :920, where fm_nm_runs_status_for_worktree returns a word outside completed|failed|cancelled|running -pendingis real (tests/fm-crew-state.test.sh:3897 asserts it), and the function prints any lowercase ledger word it decides on (bin/fm-nm-run-lib.sh:437/458). Concretely: foreignaxi statusanswer, ledger rowpending fm/feat-x <local head>, daemon up, log tipneeds-decision: approve X-> RUN_STATE=unknown, RUN_DETAIL="runs list status: pending", guard suppresses the append, so the crew emitsstate: unknown | source: run-step | runs list status: pendingwhere the base emitted the same state plusstatus-log superseded (run unknown). The emitted STATE is unchanged either way, so this is cosmetic, not a wrong verdict - but it is a component the intent does not require and the round-11 finding already noted it becomes unnecessary once the dead-daemon cases route through RUN_DEAD_DAEMON.Recommended remedy: delete the guard (restores the base detail note for the unrecognised-word case; no other path changes). ask-user because it alters emitted detail text.
🔧 Fix applied.
3 issues (2 warnings, 1 info) still open:
bin/fm-crew-state.sh:918- The coarsefailedarm sets RUN_DEAD_DAEMON fromnm_daemon_probe_down(line 917), which is fail-closed:fm_nm_run_checked ... || return 0returns true for ANY non-zero rc, including 124 (the bounded call's did-not-answer code). Since commit f18d135 routed this arm through RUN_DEAD_DAEMON, that variable no longer only degrades the record tounknown- it also drives the state override at line 1039, which hands the verdict back to the status-log tip.Concrete failing sequence: crew on fm/feat-x;
axi statusanswers another branch's run (the shared daemon serves the whole repo), so attribution falls to the coarse ledger; the branch's newest row isfailed <local head>; the run genuinely failed after its review gate was approved, butstatus_current_linekeeps open decisions alive across unrelated events, so the log tip is stillneeds-decision: approve the schema change. Thedaemon statusprobe merely runs slow under fleet load and is killed at the timeout -> rc 124 ->nm_daemon_probe_downreturns 0 -> RUN_DEAD_DAEMON set -> line 1034 case matchesneeds-decision-> LOG_TIP_STATE=parked ->emit parked status-log "approve the schema change · no-mistakes daemon unreachable; last ledger record failed - unverified". The supervisor is told a human decision is pending on a run that actually failed and needs a rerun. Before this change the same input emittedunknown- ambiguous, but not falsely actionable.This contradicts the change's own contract in two places: the header at :116-117 scopes the reading to "when the run record itself is UNVERIFIED (its daemon answered down)", and
nm_daemon_answered_down's comment at :633-641 states the fail-closed probe "is safe when it degrades a terminal record to unknown, but on a live record it would drop a working crew back to a possibly-stale status log every time the probe merely ran slow".test_unanswered_daemon_probe_does_not_suppress_live_run(tests/fm-crew-state.test.sh:4102) enshrines exactly that principle for the live route; nothing guards it here, becausetest_unverified_coarse_failed_record_makes_no_supersede_claim(:4073) andtest_coarse_failed_ledger_with_daemon_down_reports_unknown(:1413) both use FM_FAKE_DAEMON_DOWN=1 (an ANSWERED rc 1), never FM_FAKE_DAEMON_TIMEOUT=1.Smallest honest remedy: keep
nm_daemon_probe_downfor theunknowndegrade at :919-920, but gate the RUN_DEAD_DAEMON assignment onnm_daemon_answered_downso probe latency falls back to the pre-changeunknown … status-log superseded (run unknown)reading instead of asserting a parked gate.bin/fm-crew-state.sh:1049- Simplification/scope: the change introduces a coarse-row-vs-open-gate special case that the User intent does not require. The intent is "live no-mistakes run is current after rebase" (implementation already committed as a8887dd1/0619120). This branch changes a pre-existing path that has nothing to do with rebase or with a dead daemon.The component: when RUN_SOURCE=coarse, RUN_STATE=working and LOG_VERB=needs-decision, line 1049 now emits
parkedfrom the status log instead of the previousworking · status-log superseded by active run. Concrete input: crew fm/feat-cg;axi statusanswers fm/other-crew; ledger newest rowrunning fm/feat-cg <local head>; daemon HEALTHY (FM_FAKE_DAEMON_DOWN=0); log tipneeds-decision: review gate has an ask-user findingthat the crew already resolved. Reachability is identical at the base commit (branch mismatch -> else at :852 -> RUN_SOURCE=coarse), so nothing in this change makes the path newly reachable; only the verdict changed. A crew whose run is visible only coarsely and is genuinely validating now reportsparked(awaiting a human) until the run terminates - which is the stale-decision-hides-a-working-crew failure the supersede machinery exists to prevent.Note the escalation history: commit 3c59616 first added this as a DETAIL-only note (
status-log not superseded: a coarse run record cannot tell working from parked), leaving the state atworking; a later fix round promoted it to a full state override viaemit "$LOG_TIP_STATE". The detail-only form is the strictly narrower version of the same concern.Recommended remedy: remove the state override (revert to the detail-only note, or drop the special case entirely) unless you want the fleet-wide reading change. The reciprocal negative control
test_coarse_live_row_over_ordinary_blocked_keeps_superseded_reading(tests/fm-crew-state.test.sh:3748) andtest_coarse_live_row_does_not_claim_gate_superseded(:4158) would need updating with it. Flagging rather than fixing because which reading is correct is the author's product call.bin/fm-crew-state.sh:1039- On the selected-run route the dead-daemon message built at :812 carries no run id, and the reconciliationemitat :1039 exits before :1065 appends· run: $SELECTED_RUN_ID. The coarse route deliberately appends; run id: …at :881 for the same verdict, so the two routes disagree about whether the supervisor gets an id to go look at.Concrete: the shape
test_selected_run_dead_daemon_leaves_the_open_decision_openbuilds (tests/fm-crew-state.test.sh:3957) - selected run 01RUN at an unfetched pipeline head, ledger-anchored, daemon answered down, log tipneeds-decision:- emitsstate: parked · source: status-log · approve the schema change · no-mistakes daemon unreachable; last run record running - unverifiedwith norun: 01RUN. Remove the needs-decision tip from the same fixture and the final emit at :1067 does include it. Exactly the case where a human is being asked to look at a dead run is the case that omits the id.Remedy: append
; run id: $selected_idwhen building RUN_DEAD_DAEMON at :812, matching :881.🔧 Fix applied.
3 issues (1 warning, 2 infos) still open:
bin/fm-crew-state.sh:925- The coarsefailedarm runs the boundedno-mistakes daemon statusprobe TWICE whenever the daemon is not up.nm_daemon_probe_down(:629-633) short-circuits only on a cacheddownand never writesNM_DAEMON_ANSWERitself, so after it returns 0 the cache is still empty andnm_daemon_answered_down(:645-656) re-probes from scratch.Concrete sequence (the shape
test_unverified_coarse_failed_record_makes_no_supersede_claimbuilds): crew fm/feat-cfs;axi statusanswers fm/other-crew; ledger newest rowfailed fm/feat-cfs <local head>; daemon down. Line 918 -> probe #1 -> rc 1 -> return 0 -> RUN_STATE=unknown; line 925 -> NM_DAEMON_ANSWER still "" -> probe #2 -> rc 1 -> NM_DAEMON_ANSWER=down. Twono-mistakes daemon statussubprocesses for one question.Cost: in the case this path exists for - a daemon that is dead or wedged rather than answering - each probe burns the full bounded wait, so the worst case is 2 x NM_TIMEOUT (20s by default, FM_CREW_STATE_NM_TIMEOUT at :175) per crew, in the supervisor's per-crew polling loop. Before this branch the same input cost one probe. The two probes can also disagree (probe #1 rc 1, probe #2 killed at the timeout with rc 124 -> NM_DAEMON_ANSWER=other -> RUN_DEAD_DAEMON left unset), making the verdict depend on which of two identical questions was asked when.
Remedy (mechanical, no behavior change): make ONE cached probe with three answers instead of two - record
upfor rc 0,unansweredfor rc 124,downotherwise; thennm_daemon_probe_downis[ "$NM_DAEMON_ANSWER" != up ]andnm_daemon_answered_downis[ "$NM_DAEMON_ANSWER" = down ], both reading the same single call. The current two-value cache (down/other) cannot express this because it collapses rc 0 and rc 124 into one bucket, which is exactly why the second probe is unavoidable today.bin/fm-crew-state.sh:813- Round 13 appended; run id: $selected_idto the selected-route RUN_DEAD_DAEMON message (:813), but that route always reaches the unconditional[ -z "$SELECTED_RUN_ID" ] || RUN_DETAIL="$RUN_DETAIL${SEP}run: $SELECTED_RUN_ID"at :1065, so whenever the reconciliation emit at :1044 does NOT fire the id is printed twice.Concrete:
test_selected_run_anchored_continuation_needs_a_live_daemon(tests/fm-crew-state.test.sh:3897) - selected run 01RUN at an unfetched pipeline head, ledger-anchored, daemon answered down, status-log tipworking: implementing(so LOG_VERB=working and the needs-decision|blocked case at :1032 is skipped). Output:state: unknown · source: run-step · no-mistakes daemon unreachable; last run record running - unverified; run id: 01RUN · run: 01RUN.The test's
assert_contains "$out" "run: 01RUN"is satisfied by the :1065 append alone, so it passes identically with or without the :813 suffix - it cannot detect the duplication it was retargeted alongside.Remedy: drop the
; run id: $selected_idsuffix at :813 and instead append${SEP}run: $SELECTED_RUN_IDinside the RUN_DEAD_DAEMON emit at :1044 (which exits before :1065). That keeps the id on the gate-tip path the original finding cared about without duplicating it on the ordinary path. The coarse route at :881 needs no change - it runs only when SELECTED_RUN_ID is empty, so it never duplicates.bin/fm-crew-state.sh:1044- Scope note, acknowledged tradeoff - no action requested. TheRUN_DEAD_DAEMONverdict plus the status-log reconciliation emit at :1042-1045 is the one component this branch introduced that reaches beyond "a live run is current after rebase": it changes the reading of the pre-existing coarse-failed path, which has nothing to do with a rebase. Same input before and after - crew on fm/feat-x,axi statusanswers another branch, ledger newest rowfailed <local head>, daemon answered down, log tipneeds-decision: approve the schema change- used to emitstate: unknown ... status-log superseded (run unknown)and now emitsstate: parked · source: status-log · approve the schema change · no-mistakes daemon unreachable; last ledger record failed - unverified.I am recording this rather than reporting it as an unrequired component because it is already settled: the daemon-answered-down guard is what makes the intent's own head-free bind safe (without it a zombie
runningrecord permanently masks a crew's real state), and round 13's user instruction explicitly kept the answered-down handoff while reverting only the coarse working/parked override.test_unanswered_probe_does_not_turn_a_failed_coarse_record_into_a_gate(tests/fm-crew-state.test.sh:4033) is the reciprocal negative control and is correctly asserted - it would fail if the arm still keyed off the fail-closed probe.🔧 Fix applied.
3 issues (2 warnings, 1 info) still open:
bin/fm-crew-state.sh:886- The dead-daemon verdict is applied to a coarse ledger row whose head TIES to the worktree, which the header at :70-76 says it must not be. That comment scopes the verdict to "the two routes that bind a run the worktree has MOVED OFF" and adds: "It is deliberately NOT extended to the head-matching arm - while the run head still equals or precedes the worktree HEAD the record keeps its original working reading." A head-tied coarse row is precisely a row whose head equals or precedes the worktree HEAD, so the two sentences name the same case on both sides of the rule, and line 886 implements the extension.Concrete divergence, same crew and same run:
running fm/feat-x <H>. Daemon answered down.axi statusanswers THIS crew's run (branch fm/feat-x, head H). Line 842nm_run_head_matches_worktreeis true, so the probe is never reached: HAVE_RUN=1, RUN_SOURCE=full, status running ->state: working · source: run-step · validating (running).axi statusanswers ANOTHER crew's run (the else branch at :862). COARSE_STATUS=running from the same ledger row at H; :886 sees class live, the parked guard is skipped because run_branch != CREW_BRANCH,nm_daemon_answered_downis true ->state: unknown · source: run-step · no-mistakes daemon unreachable; last ledger record running - unverified.Nothing about the run, its head, or the daemon differs between A and B - only which run the shared daemon's bare
axi statushappened to name, which the module's own comment at :722-726 calls "routine once several crews validate the same underlying repo concurrently".test_coarse_live_row_with_daemon_down_is_unverified(its ledger row is at${local_short}, the worktree's own head) locks in the B side; the head-matching arm locks in A.The defect lives inside the coarse-live extension the fix rounds added at :886-893, which is not required by the intent (the intent's fix is the head-free executing bind, not a new reading of head-tied coarse rows). The smallest honest remedy is to remove that extension, or to restrict it to coarse answers the worktree has genuinely moved off. Note that the narrower form is not currently expressible:
fm_nm_runs_status_for_worktreereturns the same status word for its head-matching path and its anchored-continuation path, so distinguishing them requires changing that shared helper's contract - the remedy, not the defect, is what needs authorization.bin/fm-crew-state.sh:812- The daemon-down guard the fix rounds added does not cover the sibling head-free route, so the zombie-record failure it exists for is still reachable.At :811-812 (and identically at :842-843) the condition is
nm_run_head_matches_worktree || fm_nm_run_is_pipeline_owned_active "$RUN_OUT" || { fm_nm_run_is_executing "$RUN_OUT" && ! nm_daemon_answered_down; }.fm_nm_run_is_pipeline_owned_active(bin/fm-nm-run-lib.sh:311-314) isbranch_sync.state=pipeline_owned && fm_nm_run_is_active- it binds ANY active run head-free, executing or parked - and it short-circuits the probe clause that follows it.Concrete sequence: crew fm/feat-x;
axi statusanswers its own run withstatus: running, no gate markers,branch_sync:\n state: pipeline_owned, andhead:at the pipeline's rebased/unfetched head; the daemon has died andno-mistakes daemon statusexits non-zero. Line 811 -> head does not match ->fm_nm_run_is_pipeline_owned_activetrue -> HAVE_RUN=1 with no probe and RUN_DEAD_DAEMON unset -> RUN_SOURCE=full ->state: working · source: run-step · validating (running). The identical record withstate: syncedinstead takes the executing clause, gets the probe, and readsunknown(test_anchored_continuation_still_needs_a_live_daemon) or leaves HAVE_RUN=0 (test_live_record_at_diverged_head_does_not_bind_an_unproven_record).branch_sync.stateis daemon-written state that goes stale in exactly the same way therunningword does, so it is not independent liveness evidence.The change also re-documented this predicate as parked-only without changing it: the header at :59-61 now says custody "binds an ACTIVE parked run without head equality" and bin/fm-nm-run-lib.sh:308-309 now says "a parked run whose pipeline currently owns the branch binds without head equality". Both previously said "ACTIVE run" / "a live run". The predicate still returns 0 for an executing run, so the comments assert a narrowing the code does not implement, which makes the gap invisible to a reader auditing the guard.
Remedy is a scope decision the author owns: either extend the guard (
fm_nm_run_is_pipeline_owned_active "$RUN_OUT" && ! nm_daemon_answered_downat both :812 and :843, which changes the reading of a pre-existing route the intent does not touch), or revert the two comments to say the custody exemption binds any active run and is deliberately outside the daemon rule. Do not leave the comments claiming parked-only while the code binds executing runs.bin/fm-nm-run-lib.sh:352-fm_nm_run_is_executing's contract comment justifies its accepted-word list with a claim the same change disproves: "The overview table fm_nm_select_run validates carries only pending|running|completed|failed|cancelled (:196), so on the modern selected-run route only pending and running ever reach here." The mirrored claim is in bin/fm-crew-state.sh:40-42 ("pending or running through the overview-backed route; also fixing or ci on the legacy bare-status surface").On the selected route,
RUN_OUTis reassigned at bin/fm-crew-state.sh:797 to the id-addressed DETAIL (axi status --run <id>), not the overview row, and that detail's vocabulary is validated at :803-806 aspending|running|fixing|ci|awaiting_approval|fix_review|completed|failed|cancelled. A run whose overview column readsrunningwhile its detail readsfixingpasses the class agreement check at :807-809 (both live) and reachesfm_nm_run_is_executingwith statusfixing. Sofixingandcireach the predicate on the modern route too.No behavior is wrong today - the predicate accepts those words either way. The risk is that the comment is the stated rationale for the word list: acting on it by narrowing the modern route to
pending|runningwould stop binding a fix round at a rebased head on the overview-backed surface, which is the exact misreport this change exists to prevent. Correct both comments to say the detail object carriesfixingandcion either surface.🔧 Fix applied.
4 issues (1 error, 1 warning, 2 infos) still open:
bin/fm-crew-state.sh:894- The round-16 fix gates the coarse dead-daemon verdict onrun_branch = CREW_BRANCH, justified at :887-889 as "Reaching this branch at all proves the head rule rejected the record, so a SAME-branch answer is necessarily moved-off". That proof applies to theaxi statusRECORD's head, butCOARSE_STATUSat :880 comes from the LEDGER (fm_nm_runs_status_for_worktreewith no expected-head), whose head-matching path (bin/fm-nm-run-lib.sh:452-457) returns the newest same-branch row's status word when THAT row's sha resolves and equals/precedes the worktree HEAD. The two heads are independent, so a same-branch answer is not necessarily moved-off and the verdict still lands on a head-tied row — exactly what the header at :70-76 says it must not do ("deliberately NOT extended to a head-tied record") and what the author's round-15 instruction forbade.Concrete trace, taken from this change's OWN new test (tests/fm-crew-state.test.sh:4109, the
selfiteration):axi status(legacy bare surface — the fake overview is not a runs table, so fm_nm_select_run returnsunavailableand SELECTED_RUN_ID stays empty) answers this branch's run 01RUN withstatus: running,head: abc1234(not an object here),branch_sync.state: synced.running fm/feat-htied <short(H)>. Daemon answered down (exit 1).! nm_daemon_answered_downfalse ⇒ whole condition false ⇒ else branch at :878.fm_nm_head_matches_worktreetrue ⇒ COARSE_STATUS=running. HAVE_RUN=1; :886 leaves RUN_SOURCE=full.state: unknown · source: run-step · no-mistakes daemon unreachable; last ledger record running - unverified; run id: 01RUN.The test asserts
state: workingandassert_not_contains "state: unknown", so the code and the test shipped in the same commit disagree; theotheriteration (foreign-branch, no verdict) does read working, so the head-tied row still reads differently depending on which run the shared daemon's bareaxi statusnames — the very divergence round 15 asked to remove. The same wrong label also reaches apendingledger word, which only the head-matching path can ever produce.The defect lives entirely inside the coarse dead-daemon extension the fix rounds added (:887-899), which the User intent does not require — the intent's fix is the head-free executing bind at :846-848, not a new reading of coarse ledger rows. The smallest honest remedy is to DELETE :887-899 (the author's round-15 instruction already authorized "or drop the extension"); restricting it properly is not expressible today because
fm_nm_runs_status_for_worktreereturns the same word for its head-matching and anchored-continuation paths, so a narrower gate would require changing that shared helper's contract — the remedy, not the defect, is what needs authorization. Dropping it also lets tests/fm-crew-state.test.sh:4109 pass as written.bin/fm-crew-state.sh:1065- Simplification: the[ "$RUN_SOURCE" = coarse ] && [ "$LOG_VERB" = needs-decision ]arm (added by fix round 3c59616) replaces the pre-existing user-visible detail "status-log superseded by active run" with "status-log not superseded: a coarse run record cannot tell working from parked" for every coarse live row over an open decision. The User intent is only "treat a live no-mistakes run as current after rebase"; it requires nothing about the coarse runs-ledger fallback, which the intent's fix (the head-free executing bind at :846-848) does not touch. No intent requirement needs this arm, and it changes what operators read for a pre-existing route. Recommend removing it and letting the coarse route keep its original supersede note; if the ambiguity note is wanted, that is a separate product decision.bin/fm-nm-run-lib.sh:11- The file header says both callers reachfm_nm_runs_status_for_worktreeas "crew-state for an ACTIVE parked run". On the selected route that elif (bin/fm-crew-state.sh:817-833) is reached by any active run the three head-free binds rejected, which now includes an EXECUTING run whose daemon answered down — the code inside it says so explicitly at :826 (! fm_nm_run_is_parked "$RUN_OUT" && nm_daemon_answered_down), and test_selected_run_anchored_continuation_needs_a_live_daemon exercises exactly that. A reader auditing the daemon guard from this header would conclude the executing case never reaches the ledger rule. Correct it to "an ACTIVE run — parked, or executing with the daemon answered down".bin/fm-crew-state.sh:41- The header justifies the pending|running|fixing|ci word list with "every route reads the id-addressed detail object". The legacy bare-status route (:846-848) does not: it passes the bareaxi statusoutput captured at :778, never re-read with--run <id>. The corresponding comment in bin/fm-nm-run-lib.sh:346-351 states this correctly ("the legacy bare-status route passes the same detail SHAPE"). Align the header with it so the rationale is not read as a claim about how the record was fetched.🔧 Fix applied.
5 issues (1 warning, 4 infos) still open:
bin/fm-crew-state.sh:924- The round-16 instruction was to "DELETE the coarse dead-daemon extension entirely: the block that sets RUN_DEAD_DAEMON from a coarse ledger row". Commit 9b4bfc4 deleted only the LIVE-row block (:887-899); the coarse TERMINALfailedcase at :920-926 still setsRUN_DEAD_DAEMON=$RUN_DETAILfrom a coarse ledger row, and that value is what the new status-log hand-off at :1044-1046 consumes.Concrete trace, taken verbatim from this change's own new test tests/fm-crew-state.test.sh:3960 (test_answered_down_failed_coarse_record_leaves_the_decision_open):
needs-decision: approve the schema change.axi statusnames another crew's run (fm/other-crew) -> run_branch != CREW_BRANCH -> else branch at :873 -> coarse ledger read.failed fm/feat-cfad <short(H)>. Its sha resolves and equals HEAD, so fm_nm_head_matches_worktree is true and fm_nm_runs_status_for_worktree returnsfailed. HAVE_RUN=1, RUN_SOURCE=coarse.state: parked · source: status-log · approve the schema change · no-mistakes daemon unreachable; last ledger record failed - unverified.Before this change the same inputs produced
state: unknown · source: run-step · ... · status-log superseded (run unknown). The new label is a confident claim the evidence does not support: the ledger row is head-tied, so its identity is PROVEN, and it records a run that progressed all the way to a terminal failure at this worktree's exact head - which is positive evidence the earlier gate was answered and the decision closed. A dead daemon afterwards does not unmake a recorded terminal outcome. Reportingparkedtells the supervisor a human decision is pending on a crew whose run actually failed, routing it to the decision queue instead of surfacing the failure;unknownwas the honest reading for that ambiguity and is what the unanswered-probe sibling (test_unanswered_probe_does_not_turn_a_failed_coarse_record_into_a_gate, :3936) still asserts.The defect lives entirely inside machinery a prior fix round introduced (538aa6b) on a route the User intent does not touch - the intent's fix is the head-free executing bind at :818 and :847-849, not a new reading of coarse terminal ledger rows. The smallest honest remedy is to revert that round's coarse addition: DELETE :920-926 (the
if nm_daemon_answered_down; then RUN_DEAD_DAEMON=$RUN_DETAIL; fiblock and its comment), restoring the pre-existingunknown · run-step · ... · status-log superseded (run unknown)reading, and delete test_answered_down_failed_coarse_record_leaves_the_decision_open plus the now-unreachable half of test_coarse_failed_path_probes_the_daemon_once's rationale. Because the remedy removes behavior a fix round deliberately added, it needs your authorization rather than an automatic repair; the selected-route verdict at :825-830 (the one route the header at :74-76 names) is unaffected and stays.bin/fm-crew-state.sh:882- Commit 9b4bfc4 deleted one line too many from this comment, leaving the sentence cut off mid-clause: "(RUN_SOURCE stays full); only a foreign-branch answer leaves" with no object, immediately followed by the code line. Restore the trailing "coarse status-word detail." so the rule the next line implements is actually stated.bin/fm-crew-state.sh:124- The step-3 header at :124-129 still documents the coarse needs-decision detail arm that commit 9b4bfc4 removed: "A COARSE live row over an open DECISION ... It therefore records the ambiguity in the DETAIL and leaves the state working." The code no longer records any such ambiguity - the coarse route now falls through to the originalstatus-log superseded by active runnote, which is exactly what the change's own test_coarse_live_row_does_not_claim_gate_superseded (tests/fm-crew-state.test.sh:4279) asserts. Delete those six lines so the header stops describing a detail string no route can emit.bin/fm-crew-state.sh:731- The nm_runs_list header now claims the coarse fallback only ever sees "a run that is parked or terminal, since an executing same-branch run binds before this fallback is reached." That is false on the route this change added: at :847-849 an EXECUTING same-branch record whose head does not match, is not pipeline-owned, and whose daemon ANSWERED down fails the bind and falls straight into the else branch at :873, reaching this fallback. The change's own test_coarse_head_tied_row_is_exempt_even_when_the_record_head_diverged (tests/fm-crew-state.test.sh:4087) drives exactly that path. A reader auditing the daemon gate from this comment would conclude the executing case cannot reach the coarse route and miss that a head-tied ledger row re-binds it asworking. Reword to "parked, terminal, or executing with the daemon answered down".tests/fm-crew-state.test.sh:4251- Commit 9b4bfc4 inverted two tests' assertions to match the deleted extension but left their names and doc comments stating the opposite. test_coarse_live_row_with_daemon_down_is_unverified (:4251) is prefaced "an answered-down daemon must unverify it the same way - and say so" yet now assertsstate: workingand assert_not_contains "daemon unreachable"; test_coarse_live_row_does_not_claim_gate_superseded (:4279) is prefaced "must never claim the crew's own needs-decision event was superseded" yet now assertssuperseded by active runis present. Both names/comments describe behavior the code deliberately does not have, so a future reader will read them as a regression rather than the intended exemption. Rename to match what they now prove (e.g. ..._is_exempt_from_the_dead_daemon_verdict, ..._keeps_the_original_supersede_note) and rewrite the two comment blocks.🔧 Fix applied.
3 infos still open:
bin/fm-crew-state.sh:840- The comment added at :835-842 states an unconditional guarantee the adjacent code does not provide: "The head-free route additionally needs the daemon not provably down, so a record left sayingrunningby a dead daemon stops answering once the worktree moves off the run head."Concrete reachable sequence on the legacy surface (no overview table, so fm_nm_select_run answers
unavailable, SELECTED_RUN_ID stays empty and this block runs - the same surface this change's own test_legacy_live_rebased_run_is_authoritative at tests/fm-crew-state.test.sh:3520 exercises):axi statusrecord: branch fm/x, status running, head R (diverged, resolvable or not), branch_sync synced.! nm_daemon_answered_downfalse -> whole condition false -> else branch at :872.[ "$run_branch" = "$CREW_BRANCH" ] || RUN_SOURCE=coarse- run_branch IS CREW_BRANCH here, so RUN_SOURCE staysfull.state: working · source: run-step · validating (running).So the record does not stop answering; it answers through the fallback with its own status word. The change's own negative test (tests/fm-crew-state.test.sh:3548 test_live_record_at_diverged_head_does_not_bind_an_unproven_record) passes only because it sets FM_FAKE_RUNS_LIST="", and its doc comment already concedes the real rule: "Once the daemon answers down AND no ledger row anchors the run".
This is a comment defect only - the else branch is untouched by this change and produced the identical reading before it, so no behavior regressed. Remedy: qualify the comment to match the code, e.g. "...stops answering once the worktree moves off the run head AND no ledger row ties this branch to the worktree's head; when such a row exists the fallback below re-binds the record with RUN_SOURCE=full."
tests/fm-crew-state.test.sh:3722- Two test rationales left behind by commit 4086a61 still describe the coarse dead-daemon / gate-ambiguity arm that the same commit deleted::3722 test_coarse_live_row_over_ordinary_blocked_keeps_superseded_reading is prefaced "Only a gate is ambiguous under a coarse live row." Nothing is ambiguous under a coarse live row any more - the coarse route carries no special open-decision reading at all, which is exactly what its neighbour test_coarse_live_row_keeps_the_original_supersede_note (:4219) now asserts. The comment tells a future reader a distinction exists that the code cannot make.
:3934-3935 test_unanswered_probe_does_not_turn_a_failed_coarse_record_into_a_gate is prefaced "A probe that did not ANSWER proves nothing, so it must not hand the verdict to a stale open decision". The coarse failed arm at bin/fm-crew-state.sh:914 now calls only nm_daemon_probe_down, which maps both
unanswered(124) anddownto the same not-up bucket, so no probe answer can hand any verdict anywhere on this route. As a result this test is behaviorally identical to test_coarse_failed_record_with_dead_daemon_reads_unknown (:4144): same fixture shape, same three assertions, differing only in FM_FAKE_DAEMON_TIMEOUT vs FM_FAKE_DAEMON_DOWN, which the code no longer distinguishes here.Remedy: rewrite the :3722 comment to say the coarse route simply keeps the pre-existing supersede reading, and either delete the now-redundant :3935 test or re-point its comment at what it still proves (that nm_daemon_probe_down is deliberately fail-closed, so an unanswered probe degrades the terminal record to unknown rather than reporting
failed).tests/fm-crew-state.test.sh:110- FM_FAKE_DAEMON_PROBE_LOG was introduced by fix round 4b46afd purely to support test_coarse_failed_path_probes_the_daemon_once, and commit 4086a61 deleted that test. The plumbing survives in three places with no consumer: the fake daemon's append at :110, the reset at :306, and the export at :318. Nothing in the suite sets it, so it is dead scaffolding the change introduced and then orphaned.The caching it was written to prove is still load-bearing (bin/fm-crew-state.sh:814 and :823 both call nm_daemon_answered_down on the selected executing + unresolvable-head + anchored-continuation path, so nm_daemon_probe saves one bounded 10s subprocess there). So the remedy is either to delete the three lines, or to re-point a probe-count assertion at that surviving double-call path - not to leave the hook unused.
tests/fm-teardown.test.sh:2207- tests/fm-teardown.test.sh fails onherdr-preflight-missing-adapter: teardown continued without its required preflight. I re-ran the same suite from a clean extract of the base commit (2bcb88c) and it fails identically there, so it is pre-existing and unrelated to this change (which only adds predicates/regex constants to bin/fm-nm-run-lib.sh that teardown does not call). Informational only - no action taken.bin/fm-crew-state.sh s1over a real worktree whose live run head diverged ->state: working · source: run-step · validating (running) · run: 01LIVE(crew-state-scenarios.txt, S1)git archive 2bcb88c bin) ->state: failed · source: status-log · earlier stage run(crew-state-scenarios.txt, S1 'before')bin/fm-crew-state.sh, each readingstate: working · source: run-stepwith the matching detail (run active (pending),validating (running),validating (fixing),ci running) (…state: working · source: status-log · implementing; nosource: run-stepand noparked at reviewleak (crew-state-scenarios.txt, S3)state: blocked · source: status-log · waiting on review; the run step does not answer (crew-state-scenarios.txt, S4)state: working · source: run-step · validating (running)(crew-state-scenarios.txt, S5)needs-decisiontip -> `state: parked · source: status-log · approve the schema change · no-mistakes daemon unreachable;…runningrow, daemon answered down ->state: working · source: run-step · validating (background run) · status-log superseded by active run; no `dae…failedrow + daemon down + openneeds-decisiontip -> `state: unknown · source: run-step · no-mistakes daemon unreachable; last ledger record failed - unverified · status-log supe…bin/fm-fleet-snapshot.sh --json+bin/fm-fleet-view.shover a fixture FM_HOME: row goes fromfailed / status-log(base) toworking / run-step(this change) while the status log's last event st…bash tests/fm-crew-state.test.sh(full targeted suite for the changed reader - all cases pass, including the 35 new rebase/daemon cases)bash tests/fm-fleet-snapshot-view.test.sh(snapshot + fleet-view consumers of the changed reader)Manual product drive: real git crew worktrees + real state/<id>.meta,.status + fakeno-mistakesCLI, runningbin/fm-crew-state.sh <id>for 8 scenarios / 12 assertions (script: /tmp/fmdrive/scenarios.sh)A/B of the identical rebase fixture against the base-commit helper extracted withgit archive 2bcb88c bin, reproducing the reported misreportOperator surface:bin/fm-fleet-snapshot.sh --jsonandbin/fm-fleet-view.shover a fixture FM_HOME with one in-flight ship crew, base vs changebash tests/fm-teardown.test.sh(shared fm-nm-run-lib consumer) and the same suite from a base-commit tree extract, to classify its one failure as pre-existing✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → no changes applied ✅
🔧 No changes applied.
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.