Repository navigation
fix(bin): keep keyed decisions open through a terminal done/failed line - #2
Merged
Merged
Conversation
A worker's `done:` line retired every open decision on a ship or scout task. The decision stopped being listed, `fm-send.sh --resolve-key` could no longer find its key to answer it, and `fm-captain-hold.sh`'s completion gate saw an empty set and let the task finish with the captain's question still owed. The contract in every worker brief (bin/fm-brief.sh rule 6) always said the opposite: a decision or blocker stays open until a `resolved` line carrying its exact key lands, and a later `done:` or `working:` line never closes it. The brief was right; the fold was wrong, so the fold changes. _fm_decision_fold_line is the one owner of "is this key open", and every reader already consults it - the whole-file fold fm-send reads, the cursor-backed fold the OPEN DECISIONS surface reads, the per-key history read, and the decision-origin walk. Removing the terminal rule there fixes all of them at once and removes the task-kind plumbing that existed only to serve it. The persisted fold version is bumped so cursors folded under the old reading are rebuilt rather than trusted. fm-send's refusal no longer asserts "already closed or mistyped" - a claim about the record it had not established. It now reports what the lookup found: a key the log really closed names the verb that closed it, and a key no line ever stated says exactly that, and says it does not prove the decision was answered.
The completion gate, the crew reading, and the fleet snapshot each had a case asserting that a `done:` or `failed:` line clears an open decision. Each now asserts what the fold actually promises: the decision survives the terminal line and clears only when its own key is closed. The fleet-snapshot case is the Lavish-103 property, and its surviving half is unchanged - report PROSE never opens or reopens a decision. What moved is how a finished scout stops being pending: it needs a real close (an answer, or the durable captain-held transfer fm-captain-hold.sh writes before completion) rather than the `done:` line discarding the record. The clean report-pointer reading is still asserted, now behind that close.
A `captain-held` line closes the status ledger by moving the question to a durable captain-held task; it does not answer it. The refusal lumped that in with a genuine resolution and told the caller the decision was "already closed", which is the same false certainty this refusal was rewritten to stop producing - the answer may still be owed. Wording only. No lookup was added: the search still covers the decision slug and the legacy derived id, and a transferred row is commonly keyed by neither. That gap is real and is left to be filed separately; what changes here is that the message now says what it searched, says the close was a transfer, and points at the transfer line for the task that holds the question.
The rewritten --resolve-key refusals removed one false claim and left another standing. Every branch asserted that no captain-held task was open, but fm_send_hold_resolved_id returns before any lookup when tasks-axi is not on PATH, so in a home without it - or any PATH-stripped context - the refusal reported an empty ledger it had never read. That is the same substitution of a fact about itself for a fact about the world that "already closed or mistyped" made, one ledger over. The three refusals now take that sentence from fm_send_hold_clause, which says whether the ledger was searched and held neither id open, or could not be read at all and its contents are unknown. No lookup behaviour is added; the code only stops claiming a result it does not have. The readability flag is computed in the caller's own shell, not inside fm_send_hold_resolved_id, because that function runs in a command substitution: a value assigned there dies with the subshell, leaving the clause to report a search that never ran. The first attempt at this fix did exactly that, and the new test is what caught it. The `needs-decision | blocked` branch is removed rather than hardened. No non-racing input reaches it - status_key_closing_verb folds a strict subset of the lines the open-set fold reads, through the same _fm_decision_fold_line - and its one reachable path was a race a retry resolves, where it told the operator they had found a reader defect and sent them chasing a bug that does not exist. The `*)` fallback already carries the rule that an unfound key is never called settled. docs/architecture.md stated the no-close-on-terminal rule without exception, which this change made false: the fleet snapshot still clears a task's published open decisions from its own lifecycle reading rather than from the fold. The two agreed on a terminal log before the fold stopped closing there, so the gap is pre-existing but newly visible. The divergence is now stated rather than contradicted, and filed as snapshot-closes-decisions; bin/fm-fleet-snapshot.sh's clearing behaviour is deliberately unchanged here. status_open_decisions and _fm_status_open_decision_origins drop the kept-but-ignored <kind> parameter, and their three in-repo call sites drop the argument. The task kind also leaves the persisted cursor version, where it discarded an otherwise-valid cursor and forced a full re-fold whenever a task's .meta kind changed, for no difference in the result. An earlier commit message in this branch claimed these reads were already deleted; they were not, and that claim is corrected here rather than quietly made true. Removing them left _fm_status_kind referenced nowhere in the repo, so the function goes too. bin/fm-crew-state.sh is deliberately untouched: its stale contract header is real but belongs to an unlanded sibling branch that owns that file.
This was referenced Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
A keyed decision record disappeared from the supported path while it was still open, and the supported way to answer it then refused.
What happened, in order:
needs-decision [key=eng2403-execsql-drop]: ...to its status log.done: ...line reporting the parts of its work that were finished.No
resolvedline carrying that key ever landed.It listed an unrelated item and stopped.
fm-send.sh <task> --resolve-key eng2403-execsql-dropREFUSED, with "no open decision or blocker with that key ... already closed or mistyped".Nothing was sent.
So the only supported route for answering that decision was shut while the decision itself sat unanswered in the log.
The answer had to be resent without the key, asking the worker to close its own record by hand.
Why this outranks an ordinary display bug: the brief every worker is given states the contract outright, that a decision stays open until a
resolvedline carrying its exact key lands, and that a laterdone:orworking:line never closes it.If a
done:line does in fact retire it, the machinery contradicts the contract the workers were told to rely on, and a decision can go permanently unanswered while every surface reports nothing outstanding.A captain-facing decision that silently stops being asked is the worst shape this failure class takes.
Deliver these three:
done:line retires a still-open keyed decision, and whether fm-send's resolve-key lookup and the OPEN DECISIONS fold share that logic or disagree with each other.Two readers disagreeing about what is open would be its own defect and must be named as one.
If the contract in the brief is what is intended, the machinery is wrong.
If the machinery is what is intended, the brief is wrong and workers have been told something false.
That wording asserted the record did not exist when it did, and it is the reason this was nearly let go.
What Changed
bin/fm-classify-lib.shno longer lets a terminaldone:orfailed:line wipe the whole open set on ship and scout tasks. Only aresolvedline or a verifiedcaptain-heldtransfer carrying the exact key now closes a decision, on every task kind. That matches rule 6 of the worker brief. The fold no longer depends on task kind:_fm_status_kindis removed, and callers stop passing a kind, includingstatus_open_decisionsinbin/fm-fleet-snapshot.sh. The cursor fold version goes up to 10, and the persisted version no longer includes the kind, so cursors built under the old reading get discarded.--resolve-keyrefusal inbin/fm-send.shno longer says "already closed or mistyped". It asksstatus_key_closing_verbwhat happened to the key and gives one of three messages: the key was closed by aresolvedline; the key was transferred by acaptain-heldline, so the answer may still be owed; or no line in the log ever opened or closed the key, which the message says does not prove the decision was answered. The captain-hold ledger part of the message now says whether the ledger was actually searched, or could not be read becausetasks-axiis not on PATH.docs/architecture.mdnow describes the new closing rule. It also records a known gap: the fleet snapshot still clears published open decisions based on the task's lifecycle state rather than the fold, so it can show no open decision while the fold andfm-send --resolve-keystill hold one open. This is filed assnapshot-closes-decisions. Tests for the fold, the wake-drain cursor, crew state, the fleet snapshot view, the captain-hold lifecycle and the resolve-key refusals are updated to the new behavior.Risk Assessment
Testing
I drove the reported sequence live on both base and target: real CLI commands, a real tmux server on an isolated socket, and a throwaway FM_HOME, never the Herdr default session or real fleet state. Base reproduces the dropped decision and the "already closed or mistyped" refusal. Target keeps the decision listed, delivers the answer to the real pane and closes it by key. I tried to break the refusals with mistyped, resolved and transferred keys, each with the captain-hold ledger readable and unreadable. Every case gives a truthful, distinct message and sends nothing. The keep-open behaviour holds for done: and failed: lines on ship, scout and secondmate tasks. All seven targeted test suites pass. The captain-hold completion gate was covered only by its test suite, not driven live, so it is marked untested. fm-fleet-snapshot.sh was not driven live either. It still clears a task's open decisions based on the task's own state, a known gap filed as snapshot-closes-decisions, and I left it unchanged as decided. This is a CLI-only change with no UI surface, so the evidence is CLI transcripts rather than screenshots. I removed the temporary lab directory and tmux server, and the worktree is clean.
Confirmed failing first. Every test added or changed in this PR was run against the pre-fix code before the fix and confirmed to FAIL there, each with its stated failure reason, and then confirmed to pass against the fix. The base-vs-target transcripts and the per-scenario table below are that evidence: the base column is the pre-fix run.
bash tests/fm-captain-hold-lifecycle.test.shcovered this. Driving the gate live needs a provisioned tasks-axi backlog for a throwaway home, s…Evidence: Base f5735dc: reported incident reproduced
Source: Base f5735dc: reported incident reproduced
Evidence: Target d0923ac: decision stays open after done:, answered and closed via real pane
Source: Target d0923ac: decision stays open after done:, answered and closed via real pane
Evidence: Target: refusal wording and kind × terminal matrix
Source: Target: refusal wording and kind × terminal matrix
Evidence: Driver: reported-sequence replay
Source: Driver: reported-sequence replay
Evidence: Driver: refusal and kind matrix
Source: Driver: refusal and kind matrix
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-send.sh:723- The*)fallback says "no line in $RESOLVE_STATUS_FILE ever opened or closed that key" even when that file was never read. status_open_decisions and status_key_closing_verb both return empty without reading anything when the status file is missing, unreadable, or a symlink (bin/fm-classify-lib.sh:742, :852). So the refusal claims a scan result it doesn't have. This is the same false certainty the user already fixed for the captain-hold ledger (fm_send_hold_clause), just on the status-log side. It also misdescribes a log that has a bareresolved [key=k]with no earlier open, since that close is not a fold transition. Suggested message-only fix: when[ -f "$RESOLVE_STATUS_FILE" ] && [ -r ... ] && [ ! -L ... ]fails, say the status log could not be read instead of claiming it holds no such line. Rare in practice because a live task normally has a readable status log.bin/fm-classify-lib.sh:996- Bumping FM_OPEN_DECISIONS_FOLD_VERSION to 10 (and removing the kind from the cursor version) throws away every persisted cursor and re-folds from byte 0 under the new rule. Any existing ship/scout log whoseneeds-decision [key=...]was only retired by a laterdone:/failed:line will suddenly reappear in OPEN DECISIONS, make fm-crew-state reportparkedinstead ofdone, and block fm-captain-hold'scomplete --none/verifyuntil each one is resolved or transferred. This is the intended contract (the fix is durable, not containment), but operators should expect a one-time wave of resurfaced decisions on upgrade. Worth one sentence in the PR body.✅ **Test** - passed
✅ No issues found.
bash tests/fm-captain-hold-lifecycle.test.shcovered this. Driving the gate live needs a provisioned tasks-axi backlog for a throwaway home, s…drive-reported-sequence.sh <base f5735dc bin>: replays needs-decision [key=eng2403-execsql-drop] → working → done:, then runs fm-wake-drain.sh andfm-send.sh t1 --resolve-key eng2403-execsql-drop, with an isolated tmux server and a throwaway FM_HOMEdrive-reported-sequence.sh <target d0923ac bin>: the same replay on the target code, which delivers into a real tmux pane and inboxdrive-refusals.sh <target bin>: mistyped, resolved and captain-held keys, each run with and without tasks-axi on PATH, plus kind × terminal checksbash tests/fm-send-resolve-key.test.shbash tests/fm-classify-decision-key.test.shbash tests/fm-captain-hold-lifecycle.test.shbash tests/fm-wake-drain-open-decisions-cursor.test.shbash tests/fm-fleet-snapshot-view.test.shbash tests/fm-classify-corr-token.test.shbash tests/fm-crew-state.test.sh✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.