Skip to content

feat(bin): add fm-gate-decide.sh to send parked gate decisions as one steer - #17

Merged
ryannmicua merged 10 commits into
mainfrom
fm/fm-gate-decide-helper
Oct 10, 2026
Merged

ryannmicua merged 10 commits into
mainfrom
fm/fm-gate-decide-helper

Conversation

@ryannmicua

@ryannmicua ryannmicua commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Intent

Decision helper - build inside fm.

Context: item 2 of the approved Firstmate improvements. When a no-mistakes gate parks on ask-user findings, firstmate decides and hand-writes a long steer to the worker naming the decision key, step, per-finding action, instructions and the exact no-mistakes axi respond command, restating the same etiquette each time (never --yes, keep processing returns). Later review rounds often re-raise findings already fixed at the pipeline head (Quarterdeck QD-8/9/10/14 over four rounds), so firstmate re-verifies the head by hand, and hand-typed commands are sometimes malformed. Firstmate still makes every decision and the worker still drives the pipeline; the helper only removes the busywork. Approach approved: build in firstmate, propose upstream once proven.

Designs and cautions (item 2 of the two cross-review reports, in substance): one firstmate script that resolves the task's run and parked gate read-only through the existing no-mistakes run attribution, takes firstmate's per-finding decision (fix, no change, approve with a reason) plus optional instructions, and sends the worker one composed steer through fm-send with --resolve-key for the gate's decision key, with the standing etiquette from one fixed template, never running respond itself. It must refuse an ID that is not in the current round, any --yes, and an incomplete or mismatched decision; render an exact, argument-safe preview; and verify the gate again immediately before sending. Carried-over IDs must not be dropped automatically, because a recurring ID may be a regression, an unfixed defect, or a new head: annotate them with the earlier decision and fix evidence, always paired with the pipeline's current head (not the worker checkout), so the fixer re-verifies at head before re-raising. The no-mistakes state database is no-mistakes' private schema, so read it only where the CLI lacks the data and fail loudly on schema drift. Retain the decision durably for later rounds. If decision text is actually lost inside no-mistakes, that fix belongs upstream in no-mistakes, not here.

What Changed

  • Added bin/fm-gate-decide.sh, which finds a task's parked no-mistakes run and gate without changing any state, using the existing run-attribution rules in fm-nm-run-lib.sh and a read-only query of the no-mistakes state database. It takes firstmate's decision for each finding (--fix, --no-change, or --approve with a --reason, plus optional --instructions) and builds one steer with an exact, shell-quoted no-mistakes axi respond --step <step> command and the standard etiquette from a fixed template. It never runs respond itself.
  • Running it without --confirm only prints a preview. With --confirm <digest>, it checks the run, step, round, findings, and pipeline head again, then sends through fm-send.sh --resolve-key only if the new steer still matches the preview's digest. It refuses, without sending or recording anything, when given --yes/-y, an ID that isn't in the current round, an ID decided twice, a finding left undecided, --approve without --reason, --instructions without any --fix, or a state-database schema it doesn't recognise. Findings carried over from earlier rounds are kept: each one is annotated with its earlier rounds, fix evidence and firstmate's earlier decision, paired with the current pipeline head. Each delivered decision is appended to <data>/<task>/gate-decisions.jsonl (fm-gate-decision.v1).
  • Added tests/fm-gate-decide.test.sh. Updated the validation-supervision skill so it sends gate decisions through the helper instead of a hand-written steer, and listed the script in docs/scripts.md.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The round-6 fix snapshots the names of inbox records before calling fm-send. On a nonzero exit, it counts a record as proof of delivery only when the name is new. This is sound because fm_task_inbox_next_seq scans both the inbox and handled/, so a sequence number is never reused, and a record moved to handled/ keeps its name. The new regression test fails if the snapshot check is missing, and the earlier decided fixes are intact.

Testing

I drove the helper end to end against a real, private no-mistakes daemon whose review step parked on two real ask-user findings, using a marked lab FM_HOME and a private tmux socket. All 9 scenarios passed live: - The preview was read-only. - Every guarded refusal (--yes, unknown or duplicate id, incomplete decision, approve without a reason, digest mismatch) wrote nothing. - A refused fm-send and a repeat of a successful confirm both exited 4 and left no record. - A gate-agent caller on an unmarked home exited 3 and nothing in the home changed. - A real send closed the decision key and wrote the durable record. - The composed commands, run verbatim, were accepted by the real gate. - Round 2 annotated the carried-over finding with its round-1 decision and the pipeline head (962f2fb), not the worker checkout (b2029bc). - A stale preview confirmed after the run completed was refused. I also ran the branch's own test file, and all 14 cases passed. The lab was torn down afterwards: daemon stopped, tmux server killed, temp tree removed. This is a CLI with no visual surface, so the evidence is transcripts and the persisted record. Note: no-mistakes init on the throwaway repo printed that it installed its /no-mistakes skill at user level, which is a user-level write outside the worktree.

  • Live validation: ✅ go - 9 of 9 scenarios driven live against the product
Scenario Result Live Evidence
Firstmate previews a decision for a real parked review gate and gets an exact, single-quoted respond command with decision key, per-finding decisions and etiquette; nothing is sent or recorded ✅ pass live 01-preview.txt
Firstmate passes --yes, an id not in the current round, an incomplete decision, approve without a reason, a duplicate id or a wrong digest, and is refused with exit 1 and no home mutation ✅ pass live 02-refusals.txt
Firstmate confirms the previewed digest: steer lands in state/t1.inbox, the nm-<run>-review key is resolved, and gate-decisions.jsonl records delivery=delivered ✅ pass live 04-confirm-send.txt, 12-gate-decisions.jsonl
fm-send refuses (no open decision for the key): helper exits 4, says a resend is safe, and writes no inbox entry or record ✅ pass live 03-refused-send.txt
Adversarial: repeating a successful confirm while the earlier identical steer is in the inbox does not create a second (delivered-unconfirmed) record ✅ pass live 05-repeat-confirm.txt
Adversarial: a gate agent (NO_MISTAKES_GATE=1) confirming against an unmarked home is refused with exit 3 before any home mutation; the marked lab home is still permitted ✅ pass live 06-gate-agent-refused.txt, 04-confirm-send.txt
Worker runs the composed respond command verbatim and the real no-mistakes gate accepts it (fix round, then approve round to completion); the helper never ran respond itself ✅ pass live 07-worker-respond.txt, 10-worker-respond-round2.txt
A later round that re-raises a finding annotates it with the earlier round, firstmate's recorded decision and the pipeline head (962f2fb), not the worker checkout (b2029bc) ✅ pass live 08-round2-carried-over.txt, 09-round2-send.txt
Adversarial: confirming a stale preview after the gate moved (run completed) is refused and sends nothing ✅ pass live 11-stale-gate-refused.txt
Evidence: Preview against a real parked review gate

Source: Preview against a real parked review gate

$ fm-gate-decide.sh t1 --fix forbidden-host-aliases --approve test-noop-config --reason "deliberate stub for this lab repo" --instructions "Keep --port; delete only --bind/--listen."
--- steer preview for task t1 (not sent) ---
Gate decision from firstmate for no-mistakes run 01M4HKGCNAM38N169M7Z57TE67, step review, round 1, pipeline head b2029bcbb6df271d6226addde142f0b53c0725ba.
This answers decision key nm-01M4HKGCNAM38N169M7Z57TE67-review.

Decisions:
- forbidden-host-aliases [ask-user]: fix
- test-noop-config [ask-user]: approve - deliberate stub for this lab repo

Run exactly this command in your worktree, the way your brief describes driving the pipeline, without editing it:
no-mistakes axi respond --step review --action fix --findings forbidden-host-aliases --instructions 'Keep --port; delete only --bind/--listen.

Leave these findings unchanged:
- test-noop-config: approve - deliberate stub for this lab repo'

Never add --yes or -y. Process every return of that call and of any reattach until checks-passed, a final outcome, or a genuinely new escalation; report a new ask-user gate with your brief's needs-decision format and stop.
--- end of preview ---
digest: 9ce037ccdbf98c94
send it with: FM_HOME=/tmp/fm-gd-live.foJ48h/fm ~/.no-mistakes/worktrees/ff5e17b6f5de/01M4HK0EWD0VAR23HEMDQNBN0M/bin/fm-gate-decide.sh t1 --fix forbidden-host-aliases --approve test-noop-config --reason deliberate\ stub\ for\ this\ lab\ repo --instructions Keep\ --port\;\ delete\ only\ --bind/--listen. --confirm 9ce037ccdbf98c94
exit=0
Evidence: Refusals: --yes, foreign id, incomplete, approve without reason, duplicate, digest mismatch

Source: Refusals: --yes, foreign id, incomplete, approve without reason, duplicate, digest mismatch

$ fm-gate-decide.sh t1 --fix forbidden-host-aliases --no-change test-noop-config --yes
error: --yes is banned fleet-wide: it auto-resolves gates, including ask-user findings, without a decision
exit=1

$ fm-gate-decide.sh t1 --fix forbidden-host-aliases,QD-99 --no-change test-noop-config
error: finding QD-99 is not in the current round of step review (current: forbidden-host-aliases,test-noop-config)
exit=1

$ fm-gate-decide.sh t1 --fix forbidden-host-aliases
error: incomplete decision: no decision for test-noop-config
exit=1

$ fm-gate-decide.sh t1 --fix forbidden-host-aliases --approve test-noop-config
error: --approve test-noop-config needs a --reason
exit=1

$ fm-gate-decide.sh t1 --fix forbidden-host-aliases --no-change forbidden-host-aliases,test-noop-config
error: finding forbidden-host-aliases is decided more than once
exit=1

$ fm-gate-decide.sh t1 --fix forbidden-host-aliases --no-change test-noop-config --confirm deadbeefdeadbeef
error: the gate changed since the preview (digest deadbeefdeadbeef, now 84a28b6c834e81d2); preview again before sending
exit=1
Evidence: fm-send refusal records nothing (exit 4)

Source: fm-send refusal records nothing (exit 4)

# state/t1.status emptied: no open decision for the key
$ fm-gate-decide.sh t1 ... --confirm 9ce037ccdbf98c94
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-gd-live.foJ48h/fm
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-gd-live.foJ48h/fm
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  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 'nm-01M4HKGCNAM38N169M7Z57TE67-review': no open decision or blocker with that key in /tmp/fm-gd-live.foJ48h/fm/state/t1.status, and no captain-held task 'nm-01M4HKGCNAM38N169M7Z57TE67-review' or 't1-decision-nm-01M4HKGCNAM38N169M7Z57TE67-review' 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.
error: fm-send failed and the steer is not in the worker inbox; nothing was sent or recorded, so a resend is safe
exit=4
inbox:
ls: cannot access '/tmp/fm-gd-live.foJ48h/fm/state/t1.inbox': No such file or directory
records:
ls: cannot access '/tmp/fm-gd-live.foJ48h/fm/data/t1': No such file or directory
Evidence: Confirmed send: inbox steer, key resolved, durable record

Source: Confirmed send: inbox steer, key resolved, durable record

$ fm-gate-decide.sh t1 ... --confirm 9ce037ccdbf98c94
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-gd-live.foJ48h/fm
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-gd-live.foJ48h/fm
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
fm-send: doorbell not typed because the agent in fmw:fm-t1 has exited; the steer is durably recorded at /tmp/fm-gd-live.foJ48h/fm/state/t1.inbox/001.msg for recovery (stuck-crewmate-recovery), and the watcher will not re-ring a dead pane
sent: decision for task t1, run 01M4HKGCNAM38N169M7Z57TE67 (key nm-01M4HKGCNAM38N169M7Z57TE67-review, digest 9ce037ccdbf98c94); recorded in /tmp/fm-gd-live.foJ48h/fm/data/t1/gate-decisions.jsonl
exit=0
--- state/t1.inbox:
/tmp/fm-gd-live.foJ48h/fm/state/t1.inbox:
001.msg
handled

/tmp/fm-gd-live.foJ48h/fm/state/t1.inbox/handled:
--- 001.msg:
schema=fm-task-inbox.v1
at=2026-10-10T00:31:50Z
--
Gate decision from firstmate for no-mistakes run 01M4HKGCNAM38N169M7Z57TE67, step review, round 1, pipeline head b2029bcbb6df271d6226addde142f0b53c0725ba.
This answers decision key nm-01M4HKGCNAM38N169M7Z57TE67-review.

Decisions:
- forbidden-host-aliases [ask-user]: fix
- test-noop-config [ask-user]: approve - deliberate stub for this lab repo

Run exactly this command in your worktree, the way your brief describes driving the pipeline, without editing it:
no-mistakes axi respond --step review --action fix --findings forbidden-host-aliases --instructions 'Keep --port; delete only --bind/--listen.

Leave these findings unchanged:
- test-noop-config: approve - deliberate stub for this lab repo'

Never add --yes or -y. Process every return of that call and of any reattach until checks-passed, a final outcome, or a genuinely new escalation; report a new ask-user gate with your brief's needs-decision format and stop.
--- state/t1.status:
needs-decision [key=nm-01M4HKGCNAM38N169M7Z57TE67-review]: ask-user findings=forbidden-host-aliases,test-noop-config
resolved [key=nm-01M4HKGCNAM38N169M7Z57TE67-review] [at=1791592310]: answered: Gate decision from firstmate for no-mistakes run 01M4HKGCNAM38N169M7Z57TE67, step review, round 1, pipeline head b2029bcbb6df271d [truncated]
--- data/t1/gate-decisions.jsonl:
{
  "command": "no-mistakes axi respond --step review --action fix --findings forbidden-host-aliases --instructions 'Keep --port; delete only --bind/--listen.\n\nLeave these findings unchanged:\n- test-noop-config: approve - deliberate stub for this lab repo'",
  "decisions": [
    {
      "action": "fix",
      "id": "forbidden-host-aliases",
      "reason": ""
    },
    {
      "action": "approve",
      "id": "test-noop-config",
      "reason": "deliberate stub for this lab repo"
    }
  ],
  "delivery": "delivered",
  "digest": "9ce037ccdbf98c94",
  "instructions": "Keep --port; delete only --bind/--listen.",
  "key": "nm-01M4HKGCNAM38N169M7Z57TE67-review",
  "pipeline_head": "b2029bcbb6df271d6226addde142f0b53c0725ba",
  "respond": {
    "action": "fix",
    "findings": [
      "forbidden-host-aliases"
    ],
    "instructions": "Keep --port; delete only --bind/--listen.\n\nLeave these findings unchanged:\n- test-noop-config: approve - deliberate stub for this lab repo"
  },
  "round": 1,
  "run": "01M4HKGCNAM38N169M7Z57TE67",
  "schema": "fm-gate-decision.v1",
  "step": "review",
  "task": "t1"
}
Evidence: Repeated confirm after success writes no duplicate record

Source: Repeated confirm after success writes no duplicate record

# same --confirm repeated after a successful send (gate still parked, key already closed)
$ fm-gate-decide.sh t1 ... --confirm 9ce037ccdbf98c94
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-gd-live.foJ48h/fm
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-gd-live.foJ48h/fm
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
error: --resolve-key 'nm-01M4HKGCNAM38N169M7Z57TE67-review': no open decision or blocker with that key in /tmp/fm-gd-live.foJ48h/fm/state/t1.status, and no captain-held task 'nm-01M4HKGCNAM38N169M7Z57TE67-review' or 't1-decision-nm-01M4HKGCNAM38N169M7Z57TE67-review' 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.
error: fm-send failed and the steer is not in the worker inbox; nothing was sent or recorded, so a resend is safe
exit=4
--- inbox:
/tmp/fm-gd-live.foJ48h/fm/state/t1.inbox:
001.msg
handled

/tmp/fm-gd-live.foJ48h/fm/state/t1.inbox/handled:
--- record count:
1
Evidence: Gate agent refused on an unmarked home (exit 3)

Source: Gate agent refused on an unmarked home (exit 3)

# unmarked home, NO_MISTAKES_GATE=1 (caller is a gate agent); preview digest=47e08352015fa036
$ fm-gate-decide.sh t1 ... --confirm 47e08352015fa036
error: no-mistakes gate agent must not drive the fleet (NO_MISTAKES_GATE set)
exit=3
--- home after:
plain/state/t1.meta
plain/state/t1.status
Evidence: Worker runs the composed respond command verbatim; real gate accepts it

Source: Worker runs the composed respond command verbatim; real gate accepts it

# worker runs the steer's command verbatim (sh /tmp/fm-gd-live.foJ48h/respond.sh)
    phase: pre_push
    submitted_head: b2029bcbb6df271d6226addde142f0b53c0725ba
    current_head: 962f2fb47056281f34d27bc91ada5c2b98cb4f45
    pushed_head: ""
    pushed_at: 0
    push_generation: 0
  target:
    kind: ""
    remote: origin
    url: /tmp/fm-gd-live.foJ48h/remote.git
    ref: ""
  remote:
    observed_head: ""
    freshness: pipeline_push
    observed_at: 0
  relation: unknown
  safety: blocked_pipeline_owned
  pr_state: none
  note: the pipeline head has moved but has not been successfully pushed; do not make local follow-up commits yet
  next_action:
    code: continue_active_run
    command: no-mistakes axi status
gate:
  step: review
  status: fix_review
  risk: high
  note: "Review auto-fix is disabled by default (`auto_fix.review: 0`; a repo or global `auto_fix.review > 0` override re-enables it), so blocking and ask-user review findings park for your decision rather than being silently self-fixed."
  findings[1]{id,severity,file,action,description}:
    test-noop-config,warning,.no-mistakes.yaml,ask-user,"The change adds .no-mistakes.yaml with `test: \"true\"`, which turns the pipeline's test step into a command that always passes. Nothing in the intent (add --port) calls for this file, and with it in place the new --port behavior is never actually tested. Unless this stub is a deliberate repository setup decision, remove it or replace it with a real test command."
help[6]: Run `no-mistakes axi respond --action approve` to accept this step and continue,Run `no-mistakes axi respond --action fix --findings <ids>` to have the pipeline fix the selected findings (do not edit files yourself),Run `no-mistakes axi respond --action skip` to skip this step,Run `no-mistakes axi logs --step review --full` to read the full step log,"A long-running call is working, not stalled - background it if your harness needs to, but the run never advances past a gate on its own. Read every return; on a `gate:`, respond; loop until an `outcome:`.","Commit post-pipeline follow-up work on top of the existing branch so every pipeline fix commit remains present. Never abort-and-restart, reset, or replace the branch in a way that drops prior gate-fix commits."
Evidence: Round-2 carried-over annotation with earlier decision and pipeline head

Source: Round-2 carried-over annotation with earlier decision and pipeline head

# worker checkout head: b2029bcbb6df271d6226addde142f0b53c0725ba
$ fm-gate-decide.sh t1 --fix test-noop-config --instructions "Replace the stub with a real test."
--- steer preview for task t1 (not sent) ---
Gate decision from firstmate for no-mistakes run 01M4HKGCNAM38N169M7Z57TE67, step review, round 2, pipeline head 962f2fb47056281f34d27bc91ada5c2b98cb4f45.
This answers decision key nm-01M4HKGCNAM38N169M7Z57TE67-review.

Decisions:
- test-noop-config [ask-user]: fix

Carried over from earlier rounds - re-verify each at pipeline head 962f2fb47056 before re-fixing or re-raising; if that head already satisfies it, leave it as is:
- test-noop-config: in round 1; round 1 firstmate decision at head b2029bcbb6df: approve: deliberate stub for this lab repo

Run exactly this command in your worktree, the way your brief describes driving the pipeline, without editing it:
no-mistakes axi respond --step review --action fix --findings test-noop-config --instructions 'Carried over from earlier rounds - re-verify each at pipeline head 962f2fb47056 before re-fixing or re-raising; if that head already satisfies it, leave it as is:
- test-noop-config: in round 1; round 1 firstmate decision at head b2029bcbb6df: approve: deliberate stub for this lab repo

Replace the stub with a real test.'

Never add --yes or -y. Process every return of that call and of any reattach until checks-passed, a final outcome, or a genuinely new escalation; report a new ask-user gate with your brief's needs-decision format and stop.
--- end of preview ---
digest: 4c63852ab22deb6c
send it with: FM_HOME=/tmp/fm-gd-live.foJ48h/fm ~/.no-mistakes/worktrees/ff5e17b6f5de/01M4HK0EWD0VAR23HEMDQNBN0M/bin/fm-gate-decide.sh t1 --fix test-noop-config --instructions Replace\ the\ stub\ with\ a\ real\ test. --confirm 4c63852ab22deb6c
exit=0

$ fm-gate-decide.sh t1 --approve test-noop-config --reason "kept deliberately"
--- steer preview for task t1 (not sent) ---
Gate decision from firstmate for no-mistakes run 01M4HKGCNAM38N169M7Z57TE67, step review, round 2, pipeline head 962f2fb47056281f34d27bc91ada5c2b98cb4f45.
This answers decision key nm-01M4HKGCNAM38N169M7Z57TE67-review.

Decisions:
- test-noop-config [ask-user]: approve - kept deliberately

Carried over from earlier rounds - re-verify each at pipeline head 962f2fb47056 before re-fixing or re-raising; if that head already satisfies it, leave it as is:
- test-noop-config: in round 1; round 1 firstmate decision at head b2029bcbb6df: approve: deliberate stub for this lab repo
(Context only: an approval sends no instructions to the fixer.)

Run exactly this command in your worktree, the way your brief describes driving the pipeline, without editing it:
no-mistakes axi respond --step review --action approve

Never add --yes or -y. Process every return of that call and of any reattach until checks-passed, a final outcome, or a genuinely new escalation; report a new ask-user gate with your brief's needs-decision format and stop.
--- end of preview ---
digest: fecb434df15729b3
send it with: FM_HOME=/tmp/fm-gd-live.foJ48h/fm ~/.no-mistakes/worktrees/ff5e17b6f5de/01M4HK0EWD0VAR23HEMDQNBN0M/bin/fm-gate-decide.sh t1 --approve test-noop-config --reason kept\ deliberately --confirm fecb434df15729b3
exit=0
Evidence: Round-2 approval sent and recorded

Source: Round-2 approval sent and recorded

$ fm-gate-decide.sh t1 --approve test-noop-config --reason "kept deliberately" --confirm fecb434df15729b3
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-gd-live.foJ48h/fm
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-gd-live.foJ48h/fm
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
fm-send: doorbell not typed because the agent in fmw:fm-t1 has exited; the steer is durably recorded at /tmp/fm-gd-live.foJ48h/fm/state/t1.inbox/002.msg for recovery (stuck-crewmate-recovery), and the watcher will not re-ring a dead pane
sent: decision for task t1, run 01M4HKGCNAM38N169M7Z57TE67 (key nm-01M4HKGCNAM38N169M7Z57TE67-review, digest fecb434df15729b3); recorded in /tmp/fm-gd-live.foJ48h/fm/data/t1/gate-decisions.jsonl
exit=0
--- records:
{"round":1,"pipeline_head":"b2029bcbb6df271d6226addde142f0b53c0725ba","delivery":"delivered","decisions":[{"action":"fix","id":"forbidden-host-aliases","reason":""},{"action":"approve","id":"test-noop-config","reason":"deliberate stub for this lab repo"}],"command":"no-mistakes axi respond --step review --action fix --findings forbidden-host-aliases --instructions 'Keep --port; delete only --bind/--listen.\n\nLeave these findings unchanged:\n- test-noop-config: approve - deliberate stub for this lab repo'"}
{"round":2,"pipeline_head":"962f2fb47056281f34d27bc91ada5c2b98cb4f45","delivery":"delivered","decisions":[{"action":"approve","id":"test-noop-config","reason":"kept deliberately"}],"command":"no-mistakes axi respond --step review --action approve"}
Evidence: Worker round-2 respond completes the run

Source: Worker round-2 respond completes the run

run: running
  intent: completed
  rebase: completed
  review: completed
  test: running
  test: completed
  document: skipped
  lint: skipped
  push: running
  push: completed
  pr: running
  pr: skipped
  ci: running
run: completed
  ci: skipped
run:
  id: "01M4HKGCNAM38N169M7Z57TE67"
  branch: fm/t1
  status: completed
  head: 962f2fb4
  head_sha: 962f2fb47056281f34d27bc91ada5c2b98cb4f45
  verification_plan: none
  findings: 1 awaiting
  steps[9]{step,status,findings,duration_ms}:
    intent,completed,0,11
    rebase,completed,0,160
    review,completed,1,38539
    test,completed,0,19329
    document,skipped,0,0
    lint,skipped,0,0
    push,completed,0,153
    pr,skipped,0,27
    ci,skipped,0,9
  automatic_skips[2]{step,reason}:
    pr,provider unknown is not supported yet
    ci,provider unknown is not supported yet
branch_sync:
  state: behind
  changed: false
  local:
    branch: fm/t1
    head: b2029bcbb6df271d6226addde142f0b53c0725ba
    clean: true
  pipeline:
    run: "01M4HKGCNAM38N169M7Z57TE67"
    status: completed
    phase: ""
    submitted_head: b2029bcbb6df271d6226addde142f0b53c0725ba
    current_head: 962f2fb47056281f34d27bc91ada5c2b98cb4f45
    pushed_head: 962f2fb47056281f34d27bc91ada5c2b98cb4f45
    pushed_at: 1791592392
    push_generation: 1
  target:
    kind: upstream
    remote: origin
    url: /tmp/fm-gd-live.foJ48h/remote.git
    ref: refs/heads/fm/t1
  remote:
    observed_head: 962f2fb47056281f34d27bc91ada5c2b98cb4f45
    freshness: pipeline_push
    observed_at: 1791592392
  relation: behind
  safety: refresh_required
  pr_state: none
  next_action:
    code: sync
    command: no-mistakes axi sync
outcome: passed-with-skips
fixes[1]{step,summary}:
  review,changes applied
help[5]: Publication or CI verification did not run (see `run.automatic_skips` and `run.head_sha`). Report the missing evidence and its cause; this outcome does not establish CI readiness or a code failure.,"Summarize this pipeline run for the user in a concise, easily readable format: what was validated and what was found.",The pipeline fixed findings the original change missed (see `fixes`) - acknowledge the misses and list each fix so the user can review them.,"Commit post-pipeline follow-up work on top of the existing branch so every pipeline fix commit remains present. Never abort-and-restart, reset, or replace the branch in a way that drops prior gate-fix commits.","Before a post-pipeline local commit or fresh run, follow the exact structured `branch_sync.next_action.command`. A `sync` action may be a strict fast-forward or a content-equivalent diverged advance that anchors the pre-sync head before moving the branch with reset semantics. A `recover_custody` action may be ordinary `no-mistakes axi sync --recover` when unpublished pipeline commits are preserved in the local gate, or exact `no-mistakes axi sync --recover --keep-local` when a bound archive preserves a divergent later head while custody returns at the reported required head, or when that preserved head is unavailable and you are explicitly discarding the missing commits; never substitute one recovery command for the other. An `adopt_published` action is exact `no-mistakes axi sync --adopt-published`: it verifies the configured push target already has the exact rebased local head, then updates only the stale gate lane. A `user_owned` state means cancellation released the branch before changing the submitted head: the exact branch and head are yours, immediately usable, and no sync action is needed. Process blocked or pipeline-owned states instead of improvising reset, stash, merge, rebase, force, or branch replacement."
Evidence: Stale preview refused after the run completed

Source: Stale preview refused after the run completed

# run has completed; confirm the stale round-2 fix preview (digest 4c63852ab22deb6c)
$ fm-gate-decide.sh t1 --fix test-noop-config --instructions "Replace the stub with a real test." --confirm 4c63852ab22deb6c
error: run 01M4HKGCNAM38N169M7Z57TE67 is no longer active
exit=1
--- inbox:
001.msg
002.msg
handled
--- record count:
2
Evidence: Persisted gate-decisions.jsonl after two rounds

Source: Persisted gate-decisions.jsonl after two rounds

{"command": "no-mistakes axi respond --step review --action fix --findings forbidden-host-aliases --instructions 'Keep --port; delete only --bind/--listen.\n\nLeave these findings unchanged:\n- test-noop-config: approve - deliberate stub for this lab repo'", "decisions": [{"action": "fix", "id": "forbidden-host-aliases", "reason": ""}, {"action": "approve", "id": "test-noop-config", "reason": "deliberate stub for this lab repo"}], "delivery": "delivered", "digest": "9ce037ccdbf98c94", "instructions": "Keep --port; delete only --bind/--listen.", "key": "nm-01M4HKGCNAM38N169M7Z57TE67-review", "pipeline_head": "b2029bcbb6df271d6226addde142f0b53c0725ba", "respond": {"action": "fix", "findings": ["forbidden-host-aliases"], "instructions": "Keep --port; delete only --bind/--listen.\n\nLeave these findings unchanged:\n- test-noop-config: approve - deliberate stub for this lab repo"}, "round": 1, "run": "01M4HKGCNAM38N169M7Z57TE67", "schema": "fm-gate-decision.v1", "step": "review", "task": "t1"}
{"command": "no-mistakes axi respond --step review --action approve", "decisions": [{"action": "approve", "id": "test-noop-config", "reason": "kept deliberately"}], "delivery": "delivered", "digest": "fecb434df15729b3", "instructions": "", "key": "nm-01M4HKGCNAM38N169M7Z57TE67-review", "pipeline_head": "962f2fb47056281f34d27bc91ada5c2b98cb4f45", "respond": {"action": "approve", "findings": [], "instructions": ""}, "round": 2, "run": "01M4HKGCNAM38N169M7Z57TE67", "schema": "fm-gate-decision.v1", "step": "review", "task": "t1"}
- Outcome: ⚠️ 1 info across 1 run (5m1s)

QD-8 re-raise trace

Traced read-only from the no-mistakes state database and review log for Quarterdeck run 01M44G82VRN6WNZX0R3SAHANYE (review step).

  • Round 1: the reviewer raised QD-8 (ask-user: the --bind alias duplicates --host, quarterdeck.py:2455).
  • Decision steer to respond payload: the round-2 row's user_findings_json carries QD-8's user_instructions ("drop --bind alias, keep repeatable --host ... Verify these are actually applied"), QD-8 is in selected_finding_ids, and the fixer session (started, then resumed in later rounds) applied it (fix_summary: changes applied, head cacdb132 to 86e6acfe).
  • Next round: the cold reviewer did not re-raise QD-8; its round-2 output held only QD-11 to QD-16, and QD-8 appears in the review log only in round 1.
  • QD-8 still reappeared in the round-2 gate table, with an identical description and line, because that table is cumulative: earlier findings carry forward, and only some auto-fix ones drop out. Rounds 3 to 6 repeated this, and the worker re-selected every carried ID each round, which triggered another fix round each time.

Conclusion: no-mistakes did not drop the decision text, which was preserved per finding in every round's respond payload and reached the fixer. The repeat came from the gate re-presenting carried findings, not from the reviewer re-raising them. This helper annotates such carried IDs with their earlier decision, fix evidence, and the pipeline head instead of dropping them. Nothing was filed upstream.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed (2) ✅
  • 🚨 bin/fm-gate-decide.sh:573 - The round-5 decision to fix review-5 is still not in the code. The target commit a66ea74 ends with the round-4 change, and the durable record is still appended before fm-send runs (bin/fm-gate-decide.sh:573-576, then the send at :577). fm-send can still refuse after that append, so the refused decision stays on disk:
  • the supervision-actor and away check at bin/fm-send.sh:659 (fm_lease_forbid_branch);
  • the task-lease guard at bin/fm-send.sh:454 (fm_lease_guard);
  • the 'no open decision for that key' refusal at bin/fm-send.sh:643.
    Later rounds then read that record at bin/fm-gate-decide.sh:446-460 and show it as 'round N firstmate decision' at :483. A concrete case: a supervision branch previews while it has away authority, the authority is withdrawn, and it then runs --confirm. The record is appended, fm-send exits 1, and the next round's carried-over annotation reports a decision that was never authorized or delivered.

The user's instructions for review-5 are binding:

  • call fm-send first, and append the record only when it exits 0;
  • on a nonzero exit, append the record only when the exact steer body is present in state/<task>.inbox/*.msg or its handled/ directory, mark that record delivered-unconfirmed, and tell firstmate not to resend;
  • otherwise record nothing and say that a resend is safe.

Other places that must change with it:

  • the header at :69-73 says the record is written 'before attempting delivery';
  • the exit codes at :79-80 say 3 means 'delivery uncertain' and 4 means 'nothing sent';
  • the failure message at :578 always says the decision is preserved;
  • the earlier-decision reader at :457-460 should show the delivered-unconfirmed mark;
  • tests/fm-gate-decide.test.sh:285-296 (test_failed_send_preserves_decision) asserts the opposite of the decided behavior: a refused send must leave no record;
  • tests/fm-gate-decide.test.sh:299-325 should assert the delivered-unconfirmed mark on the enqueued-then-failed record.

The round-3 fm_refuse_if_gate_agent call at :566 and the round-4 template wording at :531 are already applied and stay as they are.

🔧 Fix applied.
2 issues (1 error, 1 warning) still open:

  • 🚨 bin/fm-gate-decide.sh:573 - The round-5 decision to fix review-5 is still not in the code. The target commit a66ea74 ends with the round-4 change, and the durable record is still appended before fm-send runs (bin/fm-gate-decide.sh:573-576, then the send at :577). fm-send can still refuse after that append, so the refused decision stays on disk:
  • the supervision-actor and away check at bin/fm-send.sh:659 (fm_lease_forbid_branch);
  • the task-lease guard at bin/fm-send.sh:454 (fm_lease_guard);
  • the 'no open decision for that key' refusal at bin/fm-send.sh:643.
    Later rounds then read that record at bin/fm-gate-decide.sh:446-460 and show it as 'round N firstmate decision' at :483. A concrete case: a supervision branch previews while it has away authority, the authority is withdrawn, and it then runs --confirm. The record is appended, fm-send exits 1, and the next round's carried-over annotation reports a decision that was never authorized or delivered.

The user's instructions for review-5 are binding:

  • call fm-send first, and append the record only when it exits 0;
  • on a nonzero exit, append the record only when the exact steer body is present in state/<task>.inbox/*.msg or its handled/ directory, mark that record delivered-unconfirmed, and tell firstmate not to resend;
  • otherwise record nothing and say that a resend is safe.

Other places that must change with it:

  • the header at :69-73 says the record is written 'before attempting delivery';
  • the exit codes at :79-80 say 3 means 'delivery uncertain' and 4 means 'nothing sent';
  • the failure message at :578 always says the decision is preserved;
  • the earlier-decision reader at :457-460 should show the delivered-unconfirmed mark;
  • tests/fm-gate-decide.test.sh:285-296 (test_failed_send_preserves_decision) asserts the opposite of the decided behavior: a refused send must leave no record;
  • tests/fm-gate-decide.test.sh:299-325 should assert the delivered-unconfirmed mark on the enqueued-then-failed record.

The round-3 fm_refuse_if_gate_agent call at :566 and the round-4 template wording at :531 are already applied and stay as they are.

  • ⚠️ bin/fm-gate-decide.sh:581 - The round-5 fix for review-5 added steer_in_inbox, which treats any inbox record whose body matches as proof that this attempt enqueued the steer. It does not check whether that record existed before fm-send ran. A matching record left by an earlier successful send therefore turns a refusal into a recorded delivery.

Concrete sequence:

  1. Firstmate runs --confirm &lt;digest&gt;. fm-send succeeds, the steer becomes state/t1.inbox/001.msg, and the closed key is recorded as delivered.
  2. Before the worker runs respond, the gate is still parked on the same run, step, round, findings and head. Firstmate repeats the same --confirm, for example after losing the tool output. The digest and the snapshot verification at :576-578 both still pass.
  3. fm-send refuses at bin/fm-send.sh:643 ('no open decision ... already closed') and exits 1, before it enqueues anything.
  4. steer_in_inbox matches the old 001.msg (or handled/001.msg). The helper appends a second record marked delivered-unconfirmed (:600) and exits 5 with 'fm-send failed after the steer reached the worker inbox'.

That breaks the decided invariant that every fm-send refusal leaves no record. Later rounds then show the duplicate as an extra 'round N firstmate decision (delivered-unconfirmed)' annotation (:463-467, :490-491). Any other refusal reached while an identical earlier steer is in the inbox follows the same path: gate agent, supervision actor or away check, or task lease.

Fix: before calling fm-send at :595, capture the set of *.msg names in $STATE/$TASK.inbox and its handled/. On failure, compare only records that are new since that capture. A record the worker moves into handled/ keeps its name, so it still counts as new. This corrects the existing proof and adds no new state.

The nonzero-exit branch at :596-605 is the only consumer of this proof. tests/fm-gate-decide.test.sh test_refused_send_records_nothing (:285) cannot catch the defect because its inbox starts empty. Add a case that repeats a successful confirm and asserts that no second record is written.

🔧 Fix applied.
✅ Re-checked - no issues remain.

⚠️ **Test** - 1 info
  • ℹ️ To build the disposable gate, the test phase ran no-mistakes init on a throwaway repo under a private NM_HOME. It reported installing the /no-mistakes agent skill at user level, which is a user-level write outside the worktree. All lab state (daemon, tmux lab socket, temp repo and homes) was torn down.
  • Live validation: ✅ go - 9 of 9 scenarios driven live against the product
Scenario Result Live Evidence
Firstmate previews a decision for a real parked review gate and gets an exact, single-quoted respond command with decision key, per-finding decisions and etiquette; nothing is sent or recorded ✅ pass live 01-preview.txt
Firstmate passes --yes, an id not in the current round, an incomplete decision, approve without a reason, a duplicate id or a wrong digest, and is refused with exit 1 and no home mutation ✅ pass live 02-refusals.txt
Firstmate confirms the previewed digest: steer lands in state/t1.inbox, the nm-<run>-review key is resolved, and gate-decisions.jsonl records delivery=delivered ✅ pass live 04-confirm-send.txt, 12-gate-decisions.jsonl
fm-send refuses (no open decision for the key): helper exits 4, says a resend is safe, and writes no inbox entry or record ✅ pass live 03-refused-send.txt
Adversarial: repeating a successful confirm while the earlier identical steer is in the inbox does not create a second (delivered-unconfirmed) record ✅ pass live 05-repeat-confirm.txt
Adversarial: a gate agent (NO_MISTAKES_GATE=1) confirming against an unmarked home is refused with exit 3 before any home mutation; the marked lab home is still permitted ✅ pass live 06-gate-agent-refused.txt, 04-confirm-send.txt
Worker runs the composed respond command verbatim and the real no-mistakes gate accepts it (fix round, then approve round to completion); the helper never ran respond itself ✅ pass live 07-worker-respond.txt, 10-worker-respond-round2.txt
A later round that re-raises a finding annotates it with the earlier round, firstmate's recorded decision and the pipeline head (962f2fb), not the worker checkout (b2029bc) ✅ pass live 08-round2-carried-over.txt, 09-round2-send.txt
Adversarial: confirming a stale preview after the gate moved (run completed) is refused and sends nothing ✅ pass live 11-stale-gate-refused.txt
  • Private no-mistakes v1.84.0 daemon (NM_HOME=&lt;tmp&gt;/nmhome no-mistakes daemon run, agent: claude) on a disposable repo/remote; no-mistakes axi run --skip document,lint parked the review step on 2 real ask-user findings
  • Marked lab FM_HOME via bin/fm-lab-home.sh create, task t1 meta/status with the open needs-decision key, worker window on the private tmux -L fm-lab socket
  • fm-gate-decide.sh t1 --fix forbidden-host-aliases --approve test-noop-config --reason ... --instructions ... (preview)
  • Refusals: --yes, unknown id QD-99, incomplete decision, --approve without --reason, duplicate id, wrong --confirm digest
  • --confirm &lt;digest&gt; with the open decision key removed (fm-send refusal) -> exit 4, no inbox, no record
  • --confirm &lt;digest&gt; real send -> inbox 001.msg, key resolved in status, gate-decisions.jsonl record delivery=delivered
  • Repeated identical --confirm after success -> exit 4, no second record
  • Unmarked disposable home with NO_MISTAKES_GATE=1 -> exit 3, home unchanged
  • Worker step: ran the steer's respond command verbatim via sh against the real gate (fix round, then approve round)
  • Round-2 previews: annotation of the carried-over finding plus the earlier decision, using the pipeline head rather than the worker checkout; round-2 approve sent and recorded
  • Stale round-2 fix preview confirmed after the run completed -> refused
  • bash tests/fm-gate-decide.test.sh (the branch's own regression file; all 14 cases ok)
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed ✅
  • ⚠️ linter found issues (exit code 1)

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

… decisions

Firstmate previews and sends its per-finding decision for a task's parked
no-mistakes gate through one helper instead of a hand-written steer. The
helper resolves the run and gate read-only, refuses foreign, duplicate,
or missing finding ids and any --yes, annotates findings carried over
from earlier rounds with their earlier decision, fix evidence, and the
pipeline head, composes an argument-safe respond command plus the
standing etiquette, sends it through fm-send with --resolve-key, and
records each decision for later rounds. It never runs respond itself.
…e-expansion loops in the gate-decide test. Syntax, lint, all 14 gate-decide tests, and both Linux failure suites passed locally. Linux failures involved unchanged code and did not reproduce. Bash 3.2 was unavailable locally; macOS verification remains for CI
…ments inside command substitutions in tests/fm-gate-decide.test.sh. All 14 behavior tests, targeted lint, and the local shell parse sweep passed. Bash 3.2 is unavailable locally; stock-macOS verification remains for CI
@ryannmicua
ryannmicua merged commit 8ae6402 into main Oct 10, 2026
20 checks passed
@ryannmicua
ryannmicua deleted the fm/fm-gate-decide-helper branch October 10, 2026 03:05
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