Skip to content

fix(bin): keep keyed decisions open through a terminal done/failed line - #2

Merged
max-metaplanet merged 4 commits into
mainfrom
fm/decision-drop
Sep 22, 2026
Merged

max-metaplanet merged 4 commits into
mainfrom
fm/decision-drop

Conversation

@max-metaplanet

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

Copy link
Copy Markdown
Owner

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:

  1. A worker appended needs-decision [key=eng2403-execsql-drop]: ... to its status log.
  2. It later appended a bare done: ... line reporting the parts of its work that were finished.
    No resolved line carrying that key ever landed.
  3. The wake drain's OPEN DECISIONS section did not list the decision.
    It listed an unrelated item and stopped.
  4. fm-send.sh <task> --resolve-key eng2403-execsql-drop REFUSED, 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 resolved line carrying its exact key lands, and that a later done: or working: 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:

  1. Establish whether a 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.
  2. Say plainly, before changing either, which of the two is correct.
    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.
  3. Whatever the fix, a decision that cannot be found by its key must not fail as "already closed or mistyped".
    That wording asserted the record did not exist when it did, and it is the reason this was nearly let go.

What Changed

  • The decision fold in bin/fm-classify-lib.sh no longer lets a terminal done: or failed: line wipe the whole open set on ship and scout tasks. Only a resolved line or a verified captain-held transfer 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_kind is removed, and callers stop passing a kind, including status_open_decisions in bin/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.
  • The --resolve-key refusal in bin/fm-send.sh no longer says "already closed or mistyped". It asks status_key_closing_verb what happened to the key and gives one of three messages: the key was closed by a resolved line; the key was transferred by a captain-held line, 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 because tasks-axi is not on PATH.
  • docs/architecture.md now 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 and fm-send --resolve-key still hold one open. This is filed as snapshot-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

⚠️ Medium: The change fixes the root cause in the one shared fold, so the wake drain, fm-send --resolve-key, crew-state and the captain-hold gate now agree, and it meets all three intent items; but it deliberately changes what open, parked and completion-gate state looks like fleet-wide (including a re-fold of existing logs), and the fleet snapshot divergence is documented rather than fixed.

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.

  • Live validation: ✅ go - 8 of 9 scenarios driven live against the product
Scenario Result Live Evidence
A worker writes needs-decision [key=eng2403-execsql-drop] and later a bare done: line; OPEN DECISIONS still lists the key ✅ pass live target-d0923ac-reported-sequence.txt (base transcript shows the pre-fix drop)
fm-send --resolve-key eng2403-execsql-drop delivers the answer to the real pane/inbox, appends resolved, and the drain stops listing it ✅ pass live target-d0923ac-reported-sequence.txt
The drain and fm-send agree on what is open ✅ pass live base- and target- reported-sequence transcripts
Adversarial: a mistyped key is refused without 'already closed or mistyped', says it does not prove the decision was answered, and sends nothing ✅ pass live target-d0923ac-refusals-and-kinds.txt section A
A resolved key is refused as already closed, naming the resolved line ✅ pass live target-d0923ac-refusals-and-kinds.txt section B
A captain-held key is refused as transferred and possibly still owed ✅ pass live target-d0923ac-refusals-and-kinds.txt section C
Adversarial: without tasks-axi on PATH, refusals say the ledger could not be read instead of claiming it was empty ✅ pass live target-d0923ac-refusals-and-kinds.txt sections A-C
done:/failed: lines keep a decision open and answerable on ship, scout, secondmate ✅ pass live target-d0923ac-refusals-and-kinds.txt section D
The captain-hold completion gate holds a task with a still-open keyed decision after done: ⏸️ untested no The prior payload did not establish a live result: only bash tests/fm-captain-hold-lifecycle.test.sh covered 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

=== [base] status log t1 ===
needs-decision [key=eng2403-execsql-drop]: drop the execsql path or keep it?
working: continuing on the parts not blocked
done: the other parts shipped; ruling 2 still awaits approval
=== [base] fm-wake-drain.sh OPEN DECISIONS ===
OPEN DECISIONS (still open, folded from the durable status logs - not just the latest line):
t2 [key=other-item] needs-decision: unrelated question
OPEN DECISIONS: close one by answering it: bin/fm-send.sh <task> --resolve-key <key> '<answer>'
=== [base] fm-send.sh t1 --resolve-key eng2403-execsql-drop ===
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
error: --resolve-key 'eng2403-execsql-drop': no open decision or blocker with that key in /tmp/fmdrop.8ggA/home-base/state/t1.status, and no captain-held task 'eng2403-execsql-drop' or 't1-decision-eng2403-execsql-drop' still open (already closed or mistyped). Re-check the OPEN DECISIONS listing, then resend without that key or with the right one; nothing was sent.
exit=1
=== [base] inbox after send ===
(no inbox record - nothing sent)
=== [base] status log t1 after send ===
needs-decision [key=eng2403-execsql-drop]: drop the execsql path or keep it?
working: continuing on the parts not blocked
done: the other parts shipped; ruling 2 still awaits approval
=== [base] fm-wake-drain.sh OPEN DECISIONS after send ===
OPEN DECISIONS (still open, folded from the durable status logs - not just the latest line):
t2 [key=other-item] needs-decision: unrelated question
OPEN DECISIONS: close one by answering it: bin/fm-send.sh <task> --resolve-key <key> '<answer>'
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
=== [base] real pane fm-t1 contents ===
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

=== [target] status log t1 ===
needs-decision [key=eng2403-execsql-drop]: drop the execsql path or keep it?
working: continuing on the parts not blocked
done: the other parts shipped; ruling 2 still awaits approval
=== [target] fm-wake-drain.sh OPEN DECISIONS ===
OPEN DECISIONS (still open, folded from the durable status logs - not just the latest line):
t1 [key=eng2403-execsql-drop] needs-decision: drop the execsql path or keep it?
t2 [key=other-item] needs-decision: unrelated question
OPEN DECISIONS: close one by answering it: bin/fm-send.sh <task> --resolve-key <key> '<answer>'
=== [target] fm-send.sh t1 --resolve-key eng2403-execsql-drop ===
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
exit=0
=== [target] inbox after send ===
001.msg
handled
schema=fm-task-inbox.v1
at=2026-09-22T18:58:42Z
--
keep it; drop only the legacy shim=== [target] status log t1 after send ===
needs-decision [key=eng2403-execsql-drop]: drop the execsql path or keep it?
working: continuing on the parts not blocked
done: the other parts shipped; ruling 2 still awaits approval
resolved [key=eng2403-execsql-drop] [at=1790103522]: answered: keep it; drop only the legacy shim
=== [target] fm-wake-drain.sh OPEN DECISIONS after send ===
OPEN DECISIONS (still open, folded from the durable status logs - not just the latest line):
t2 [key=other-item] needs-decision: unrelated question
OPEN DECISIONS: close one by answering it: bin/fm-send.sh <task> --resolve-key <key> '<answer>'
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
=== [target] real pane fm-t1 contents ===
ox'/*.msg and, in numeric order, read and act on each, then mv each handled file
 to '/tmp/fmdrop.8ggA/home-target/state/t1.inbox'/handled/.
: Firstmate instruction waiting: list '/tmp/fmdrop.8ggA/home-target/state/t1.inb
ox'/*.msg and, in numeric order, read and act on each, then mv each handled file
 to '/tmp/fmdrop.8ggA/home-target/state/t1.inbox'/handled/.
Evidence: Target: refusal wording and kind × terminal matrix

Source: Target: refusal wording and kind × terminal matrix

\### A. mistyped key while the real decision sits open behind a done: line
--- [typo] fm-send t1 --resolve-key eng2403-execsql-dorp  (tasks-axi on PATH: yes)
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the requested message WILL still be sent.
●  watcher supervision needs Stop-owned automatic recovery; inspect the hook registration and startup status before ending the turn.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
error: --resolve-key 'eng2403-execsql-dorp': this lookup found nothing to answer - no line in /tmp/fmdrop.8ggA/ref-typo/state/t1.status ever opened or closed that key, and the captain-hold ledger was searched for task ids 'eng2403-execsql-dorp' and 't1-decision-eng2403-execsql-dorp' and held neither open. That means the key is mistyped, belongs to a different task, or was never opened; it does NOT prove the decision was answered. Check the log itself before assuming it was, then resend with the right key; nothing was sent.
exit=1  inbox-records=0
--- [typo] fm-send t1 --resolve-key eng2403-execsql-dorp  (tasks-axi on PATH: no)
error: --resolve-key 'eng2403-execsql-dorp': this lookup found nothing to answer - no line in /tmp/fmdrop.8ggA/ref-typo/state/t1.status ever opened or closed that key, and the captain-hold ledger could not be read here (tasks-axi is not on PATH), so whether a captain-held task 'eng2403-execsql-dorp' or 't1-decision-eng2403-execsql-dorp' is open is UNKNOWN. That means the key is mistyped, belongs to a different task, or was never opened; it does NOT prove the decision was answered. Check the log itself before assuming it was, then resend with the right key; nothing was sent.
exit=1  inbox-records=0

\### B. key already answered by a resolved line
--- [resolved] fm-send t1 --resolve-key k1  (tasks-axi on PATH: yes)
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the requested message WILL still be sent.
●  watcher supervision needs Stop-owned automatic recovery; inspect the hook registration and startup status before ending the turn.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
error: --resolve-key 'k1': that decision is already closed - /tmp/fmdrop.8ggA/ref-resolved/state/t1.status carries a 'resolved' line for the key, and the captain-hold ledger was searched for task ids 'k1' and 't1-decision-k1' and held neither open. Resend without that key; nothing was sent.
exit=1  inbox-records=0
--- [resolved] fm-send t1 --resolve-key k1  (tasks-axi on PATH: no)
error: --resolve-key 'k1': that decision is already closed - /tmp/fmdrop.8ggA/ref-resolved/state/t1.status carries a 'resolved' line for the key, and the captain-hold ledger could not be read here (tasks-axi is not on PATH), so whether a captain-held task 'k1' or 't1-decision-k1' is open is UNKNOWN. Resend without that key; nothing was sent.
exit=1  inbox-records=0

\### C. key transferred to a captain-held task (not settled)
--- [held] fm-send t1 --resolve-key moved  (tasks-axi on PATH: yes)
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the requested message WILL still be sent.
●  watcher supervision needs Stop-owned automatic recovery; inspect the hook registration and startup status before ending the turn.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
error: --resolve-key 'moved': this ledger can no longer answer that decision - /tmp/fmdrop.8ggA/ref-held/state/t1.status carries a 'captain-held' line for the key, which TRANSFERS the question to a durable captain-held task rather than settling it. the captain-hold ledger was searched for task ids 'moved' and 't1-decision-moved' and held neither open; a transferred row is often keyed by neither, so the question may still be owed. Read that 'captain-held' line for the task it names and answer it there; nothing was sent.
exit=1  inbox-records=0
--- [held] fm-send t1 --resolve-key moved  (tasks-axi on PATH: no)
error: --resolve-key 'moved': this ledger can no longer answer that decision - /tmp/fmdrop.8ggA/ref-held/state/t1.status carries a 'captain-held' line for the key, which TRANSFERS the question to a durable captain-held task rather than settling it. the captain-hold ledger could not be read here (tasks-axi is not on PATH), so whether a captain-held task 'moved' or 't1-decision-moved' is open is UNKNOWN; a transferred row is often keyed by neither, so the question may still be owed. Read that 'captain-held' line for the task it names and answer it there; nothing was sent.
exit=1  inbox-records=0

\### D. failed: terminal and other kinds keep the decision open and answerable
--- kind=ship terminal=done: drain lists -> t1 [key=need-creds] blocked: need prod creds
    fm-send exit=0  closing line: resolved [key=need-creds]: answered: creds in vault
--- kind=ship terminal=failed: drain lists -> t1 [key=need-creds] blocked: need prod creds
    fm-send exit=0  closing line: resolved [key=need-creds]: answered: creds in vault
--- kind=scout terminal=done: drain lists -> t1 [key=need-creds] blocked: need prod creds
    fm-send exit=0  closing line: resolved [key=need-creds]: answered: creds in vault
--- kind=scout terminal=failed: drain lists -> t1 [key=need-creds] blocked: need prod creds
    fm-send exit=0  closing line: resolved [key=need-creds]: answered: creds in vault
--- kind=secondmate terminal=done: drain lists -> t1 [key=need-creds] blocked: need prod creds
    fm-send exit=0  closing line: resolved [key=need-creds]: answered: creds in vault
--- kind=secondmate terminal=failed: drain lists -> t1 [key=need-creds] blocked: need prod creds
    fm-send exit=0  closing line: resolved [key=need-creds]: answered: creds in vault
Evidence: Driver: reported-sequence replay

Source: Driver: reported-sequence replay

#!/usr/bin/env bash
# Replays the reported incident against a real fm-wake-drain / fm-send, with a
# real isolated tmux server (TMUX_TMPDIR) holding the worker panes.
# usage: drive-reported-sequence.sh <bin-dir> <lab-dir> <label>
set -u
BIN=$1 LAB=$2 LABEL=$3
export TMUX_TMPDIR=$LAB/tmux FM_SEND_SETTLE=0 FM_GATE_REFUSE_BYPASS=1  # sandbox fleet only (tests/lib.sh convention)
home=$LAB/home-$LABEL; rm -rf "$home"; mkdir -p "$home/state"
printf 'window=sess:fm-t1\nkind=ship\n' > "$home/state/t1.meta"
printf 'window=sess:fm-t2\nkind=ship\n' > "$home/state/t2.meta"
# unrelated open item on another task
printf 'needs-decision [key=other-item]: unrelated question\n' > "$home/state/t2.status"
# 1. worker opens keyed decision; 2. later bare done:
printf 'needs-decision [key=eng2403-execsql-drop]: drop the execsql path or keep it?\n' > "$home/state/t1.status"
printf 'working: continuing on the parts not blocked\n' >> "$home/state/t1.status"
printf 'done: the other parts shipped; ruling 2 still awaits approval\n' >> "$home/state/t1.status"
echo "=== [$LABEL] status log t1 ==="; cat "$home/state/t1.status"
echo "=== [$LABEL] fm-wake-drain.sh OPEN DECISIONS ==="
FM_STATE_OVERRIDE="$home/state" "$BIN/fm-wake-drain.sh" 2>&1 | sed -n '/OPEN DECISIONS/,$p'
echo "=== [$LABEL] fm-send.sh t1 --resolve-key eng2403-execsql-drop ==="
FM_ROOT_OVERRIDE="$home" FM_HOME="$home" "$BIN/fm-send.sh" t1 --resolve-key eng2403-execsql-drop "keep it; drop only the legacy shim" 2>&1
echo "exit=$?"
echo "=== [$LABEL] inbox after send ==="; ls "$home/state/t1.inbox" 2>/dev/null && cat "$home/state/t1.inbox"/*.msg 2>/dev/null || echo "(no inbox record - nothing sent)"
echo "=== [$LABEL] status log t1 after send ==="; cat "$home/state/t1.status"
echo "=== [$LABEL] fm-wake-drain.sh OPEN DECISIONS after send ==="
FM_STATE_OVERRIDE="$home/state" "$BIN/fm-wake-drain.sh" 2>&1 | sed -n '/OPEN DECISIONS/,$p'
echo "=== [$LABEL] real pane fm-t1 contents ==="; tmux capture-pane -p -t sess:fm-t1 | grep -v '^$' | tail -5
Evidence: Driver: refusal and kind matrix

Source: Driver: refusal and kind matrix

#!/usr/bin/env bash
# Adversarial --resolve-key refusals and kind coverage, real fm-send + drain,
# isolated tmux server, throwaway home. usage: drive-refusals.sh <bin> <lab>
set -u
BIN=$1 LAB=$2
export TMUX_TMPDIR=$LAB/tmux FM_SEND_SETTLE=0 FM_GATE_REFUSE_BYPASS=1  # sandbox fleet only
mk() { home=$LAB/ref-$1; rm -rf "$home"; mkdir -p "$home/state"; printf 'window=sess:fm-t1\nkind=%s\n' "$2" > "$home/state/t1.meta"; }
send() { # <label> <path-mode> <key>
  local p=$PATH
  [ "$2" = no-tasks-axi ] && p=$(printf '%s' "$PATH" | tr ':' '\n' | grep -v fnm_multishells | paste -sd: -)
  echo "--- [$1] fm-send t1 --resolve-key $3  (tasks-axi on PATH: $(PATH=$p command -v tasks-axi >/dev/null && echo yes || echo no))"
  PATH=$p FM_ROOT_OVERRIDE="$home" FM_HOME="$home" "$BIN/fm-send.sh" t1 --resolve-key "$3" "some answer" 2>&1 | grep -v WARNING
  echo "exit=${PIPESTATUS[0]}  inbox-records=$(ls "$home/state/t1.inbox"/*.msg 2>/dev/null | wc -l | tr -d ' ')"
}
echo "### A. mistyped key while the real decision sits open behind a done: line"
mk typo ship
printf 'needs-decision [key=eng2403-execsql-drop]: q\ndone: other parts shipped\n' > "$home/state/t1.status"
send typo with-tasks-axi eng2403-execsql-dorp
send typo no-tasks-axi eng2403-execsql-dorp
echo; echo "### B. key already answered by a resolved line"
mk resolved ship
printf 'needs-decision [key=k1]: q\nresolved [key=k1]: answered: yes\ndone: all done\n' > "$home/state/t1.status"
send resolved with-tasks-axi k1
send resolved no-tasks-axi k1
echo; echo "### C. key transferred to a captain-held task (not settled)"
mk held ship
printf 'needs-decision [key=moved]: q\ncaptain-held [key=moved]: tracked by sample-origins-call\n' > "$home/state/t1.status"
send held with-tasks-axi moved
send held no-tasks-axi moved
echo; echo "### D. failed: terminal and other kinds keep the decision open and answerable"
for kind in ship scout secondmate; do
  for term in done failed; do
    mk "$kind-$term" $kind
    printf 'blocked [key=need-creds]: need prod creds\n%s: gave up on the rest\n' "$term" > "$home/state/t1.status"
    echo "--- kind=$kind terminal=$term: drain lists -> $(FM_STATE_OVERRIDE="$home/state" "$BIN/fm-wake-drain.sh" 2>/dev/null | grep -F '[key=need-creds]' || echo '(NOT LISTED)')"
    PATH=$PATH FM_ROOT_OVERRIDE="$home" FM_HOME="$home" "$BIN/fm-send.sh" t1 --resolve-key need-creds "creds in vault" >/dev/null 2>&1
    echo "    fm-send exit=$?  closing line: $(grep '^resolved' "$home/state/t1.status" | sed -E 's/ \[at=[0-9]+\]//' || echo none)"
  done
done

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ℹ️ 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 bare resolved [key=k] with no earlier open, since that close is not a fold transition. Suggested message-only fix: when [ -f &#34;$RESOLVE_STATUS_FILE&#34; ] &amp;&amp; [ -r ... ] &amp;&amp; [ ! -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 whose needs-decision [key=...] was only retired by a later done:/failed: line will suddenly reappear in OPEN DECISIONS, make fm-crew-state report parked instead of done, and block fm-captain-hold's complete --none/verify until 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.

  • Live validation: ✅ go - 8 of 9 scenarios driven live against the product
Scenario Result Live Evidence
A worker writes needs-decision [key=eng2403-execsql-drop] and later a bare done: line; OPEN DECISIONS still lists the key ✅ pass live target-d0923ac-reported-sequence.txt (base transcript shows the pre-fix drop)
fm-send --resolve-key eng2403-execsql-drop delivers the answer to the real pane/inbox, appends resolved, and the drain stops listing it ✅ pass live target-d0923ac-reported-sequence.txt
The drain and fm-send agree on what is open ✅ pass live base- and target- reported-sequence transcripts
Adversarial: a mistyped key is refused without 'already closed or mistyped', says it does not prove the decision was answered, and sends nothing ✅ pass live target-d0923ac-refusals-and-kinds.txt section A
A resolved key is refused as already closed, naming the resolved line ✅ pass live target-d0923ac-refusals-and-kinds.txt section B
A captain-held key is refused as transferred and possibly still owed ✅ pass live target-d0923ac-refusals-and-kinds.txt section C
Adversarial: without tasks-axi on PATH, refusals say the ledger could not be read instead of claiming it was empty ✅ pass live target-d0923ac-refusals-and-kinds.txt sections A-C
done:/failed: lines keep a decision open and answerable on ship, scout, secondmate ✅ pass live target-d0923ac-refusals-and-kinds.txt section D
The captain-hold completion gate holds a task with a still-open keyed decision after done: ⏸️ untested no The prior payload did not establish a live result: only bash tests/fm-captain-hold-lifecycle.test.sh covered this. Driving the gate live needs a provisioned tasks-axi backlog for a throwaway home, s…
  • drive-reported-sequence.sh &lt;base f5735dc bin&gt;: replays needs-decision [key=eng2403-execsql-drop] → working → done:, then runs fm-wake-drain.sh and fm-send.sh t1 --resolve-key eng2403-execsql-drop, with an isolated tmux server and a throwaway FM_HOME
  • drive-reported-sequence.sh &lt;target d0923ac bin&gt;: the same replay on the target code, which delivers into a real tmux pane and inbox
  • drive-refusals.sh &lt;target bin&gt;: mistyped, resolved and captain-held keys, each run with and without tasks-axi on PATH, plus kind × terminal checks
  • bash tests/fm-send-resolve-key.test.sh
  • bash tests/fm-classify-decision-key.test.sh
  • bash tests/fm-captain-hold-lifecycle.test.sh
  • bash tests/fm-wake-drain-open-decisions-cursor.test.sh
  • bash tests/fm-fleet-snapshot-view.test.sh
  • bash tests/fm-classify-corr-token.test.sh
  • bash tests/fm-crew-state.test.sh
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

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.
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