Skip to content

fix(bin): let away supervision relaunch in-flight tasks - #7444

Merged
kunchenguid merged 1 commit into
kunchenguid:mainfrom
hrbuilds:fm/fm-away-relaunch
Oct 17, 2026
Merged

kunchenguid merged 1 commit into
kunchenguid:mainfrom
hrbuilds:fm/fm-away-relaunch

Conversation

@hrbuilds

@hrbuilds hrbuilds commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Intent

The bug, observed in this home on 2026-10-16/17: while the away-posture record existed, two ship workers' agents died mid-task. The supervision branch (supervision host, Claude home) detected both within minutes and tried bin/fm-control.sh <id> relaunch. Both relaunches were refused with "spawn refused - the supervision branch under the away-posture record may dispatch only queued unblocked work (already queued, or filed by the branch from the captain's away words); task has no dispatchable backlog item in this home". The tasks' backlog rows were in_flight (correct for a live task), and the relaunch path in bin/fm-spawn.sh (upstream main ce69740, the if [ "$RELAUNCH" -eq 1 ] block near line 3924) requires queued no no for the branch actor, so an away relaunch of any in-flight task always refuses. The same file's header says a relaunch replaces a worker that already counts and only a fresh spawn refuses the branch actor; main's path accepts in_flight no no via fm_backlog_row_dispatchable. The branch then recorded the refusal as a captain outcome held for return rather than handing the wake back to main, so both workers sat dead for about 10 hours until the captain returned.

What Changed

  • bin/fm-spawn.sh: the away-posture rule that limits the supervision branch to queued no no backlog rows now applies only to fresh spawns. A relaunch from the branch goes through the same fm_backlog_row_dispatchable check that main uses, so fm-control.sh <id> relaunch now works for an in_flight task while the away-posture record exists. Before this, the branch's relaunch of any live task was refused with "may dispatch only queued unblocked work".
  • tests/fm-control-relaunch.test.sh: adds test_away_branch_relaunch_accepts_existing_dispatchable_items. It enters away posture with --spend 1, then runs relaunch as FM_SUPERVISION_ACTOR=branch for an in_flight item and for a queued item. Each must exit 0, print relaunched <id> and leave the row in_flight. The test is skipped when tasks-axi is missing or too old.

Risk Assessment

✅ Low: This is a one-condition change. It makes a branch relaunch while away use the same fm_backlog_row_dispatchable check (in_flight no no or queued no no) that main already uses, which matches the documented rule that only a fresh spawn refuses the branch actor. Fresh branch spawns are unchanged: they still get the queued-only check at line 3923 and in spawn_require_relocated_queued_work under the task-set lock. Direct fm-spawn relaunches by the branch are still refused unless they come through fm-control. The new test runs fm-control end to end with a real away record and would fail on the in_flight case without the fix.

Testing

I drove the real product in a disposable lab: a marked lab home with a supervision-host opt-in, an active away record with a full spend cap of 1, and a private tmux socket. In that lab, bin/fm-control.sh &lt;id&gt; relaunch run as the branch started a real Claude agent in the dead task's pane, and the backlog row stayed in_flight. Two adversarial checks in the same lab were refused as intended: relaunching a Done task, and a fresh branch spawn of an in-flight row. I also ran the new regression test against the fix and against base bin/fm-spawn.sh, and the existing fresh-spawn guard test. Those are unit-level checks, not live runs, so that scenario is recorded as untested under the live contract. The lab, its tmux server and its Claude process were torn down, and the worktree is clean. No UI is involved, so the evidence is CLI transcripts and a capture of the tmux pane.

  • Live validation: ✅ go - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Under the away record (spend cap 1, already full), the supervision branch relaunches an in-flight ship task whose agent died; a real Claude worker starts in the same pane and the backlog row stays in_… ✅ pass live live-lab-transcript.log (Scenario A: 'relaunched live-inflight ... rc=0'), live-relaunched-claude-pane.txt (claude 2.1.302 running and reading its brief), live-lab-backlog-after.md
Regression: on base ce69740 the same away-branch relaunch of an in_flight row is refused with the reported error, and the fix makes it succeed for both in_flight and queued rows ⏸️ untested no The prior payload established this only through unit-level regression tests (tests/fm-control-relaunch.test.sh), not through a live run against the product on base ce69740, so no live result was estab…
Adversarial: an away-branch relaunch of a task whose backlog row is Done is still refused as not dispatchable ✅ pass live live-lab-transcript.log (Scenario B: 'backlog item live-done is not dispatchable in state done no no' rc=1)
Adversarial: a fresh spawn (not a relaunch) by the away branch of an in-flight row is still held to the queued-only gate ✅ pass live live-lab-transcript.log (Scenario C with cap 10: 'spawn refused - ... may dispatch only queued unblocked work ... task live-fresh' rc=1, no new window); fresh-spawn-guard-test.log
Evidence: Regression test on base: reproduces the reported refusal

Source: Regression test on base: reproduces the reported refusal

not ok - the away branch must relaunch an existing in_flight item
warning: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.8SHdqR/away-in_flight-2968/home/data/rl-away-in_flight/launch-brief.md records no ship branch; defaulting to legacy branch fm/rl-away-in_flight
warning: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.8SHdqR/away-in_flight-2968/home/data/rl-away-in_flight/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
error: spawn refused - the supervision branch under the away-posture record may dispatch only queued unblocked work (already queued, or filed by the branch from the captain's away words); task rl-away-in_flight has no dispatchable backlog item in this home
error: the replacement agent for rl-away-in_flight could not be launched on claude
error: rl-away-in_flight's agent was stopped but the replacement did not launch; no agent is running, and its work plus the recorded progress note are preserved at /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.8SHdqR/away-in_flight-2968/wt: expected exit 0, got 1
Evidence: Regression test on the fix: passes

Source: Regression test on the fix: passes

ok - away supervision relaunches existing In-flight and queued items under the saturated fresh-spawn spend cap
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks/pre-rebase: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks/pre-applypatch: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks/pre-auto-gc: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks/pre-merge-commit: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks/post-commit: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks/sendemail-validate: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks/applypatch-msg: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks/prepare-commit-msg: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks/post-checkout: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks/post-applypatch: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks/post-rewrite: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks/commit-msg: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks/pre-push: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks/post-merge: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks/pre-commit: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state/rl-away-queued.git-hooks: Directory not empty
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home/state: Directory not empty
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057/home: Directory not empty
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-queued-7057: Directory not empty
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks/pre-rebase: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks/pre-applypatch: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks/pre-auto-gc: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks/pre-merge-commit: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks/post-commit: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks/sendemail-validate: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks/applypatch-msg: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks/prepare-commit-msg: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks/post-checkout: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks/post-applypatch: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks/post-rewrite: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks/commit-msg: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks/pre-push: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks/post-merge: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks/pre-commit: Permission denied
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state/rl-away-in_flight.git-hooks: Directory not empty
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home/state: Directory not empty
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694/home: Directory not empty
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu/away-in_flight-22694: Directory not empty
rm: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-control-relaunch.FvVMJu: Directory not empty
bash $f  5.31s user 4.51s system 56% cpu 17.497 total
Evidence: Existing fresh-spawn guard test under away: passes

Source: Existing fresh-spawn guard test under away: passes

ok - relocated branch spawn admits only already-queued dispatchable work, including on a manual-backend home
Evidence: Live lab transcript: away entry, branch relaunch, Done-row refusal, fresh-spawn refusal

Source: Live lab transcript: away entry, branch relaunch, Done-row refusal, fresh-spawn refusal

TMUX=/private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-lab.cO21ik/tmux/tmux-501/fm-lab,54169,0
$ bin/fm-afk-contract.sh enter --spend 1
Away posture recorded at 2026-10-17T06:56:30Z: hold-for-return only. No phone channel is configured; anything that needs you waits for your return. No away instructions were recorded; the away session acts on standing authority only, and anything that needs you waits for your return. Destructive, irreversible, and security-sensitive actions are never pre-authorizable, whatever the words say. Expected return: not given. Spend cap: 1 concurrent workers.
Away posture (recorded):
  entered: 2026-10-17T06:56:30Z
  expected return: not given
  spend cap: 1 concurrent workers
  reach: hold-for-return only. No phone channel is configured; anything that needs you waits for your return.
  your words: (none)
rc=0
$ bin/fm-afk-contract.sh mode
away

=== Scenario A: away branch relaunches an in-flight ship task whose agent died ===
$ FM_SUPERVISION_ACTOR=branch bin/fm-control.sh live-inflight relaunch --note "agent died mid-task; continue"
fm-gate-refuse: gate agent lifecycle permitted only against lab home /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-lab.cO21ik
fm-gate-refuse: gate agent lifecycle permitted only against lab home /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-lab.cO21ik
warning: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-lab.cO21ik/data/live-inflight/launch-brief.md records no ship branch; defaulting to legacy branch fm/live-inflight
warning: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-lab.cO21ik/data/live-inflight/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
relaunched live-inflight harness=claude from=claude model=default effort=default backend=tmux endpoint=primary:fm-live-inflight worktree=/private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-lab.cO21ik/work/wt-live-inflight
rc=0
$ tasks-axi show live-inflight
error: "Task \"live-inflight\" not found in this backlog"
code: NOT_FOUND
help[1]: Run `tasks-axi list --file=/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T//fm-lab.KFt4og/data/backlog.md` to see existing tasks

=== Scenario B: away branch relaunch of a Done task is still refused ===
$ FM_SUPERVISION_ACTOR=branch bin/fm-control.sh live-done relaunch --note "should refuse"
fm-gate-refuse: gate agent lifecycle permitted only against lab home /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-lab.cO21ik
fm-gate-refuse: gate agent lifecycle permitted only against lab home /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-lab.cO21ik
warning: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-lab.cO21ik/data/live-done/launch-brief.md records no ship branch; defaulting to legacy branch fm/live-done
warning: /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-lab.cO21ik/data/live-done/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
error: this home's backlog item live-done is not dispatchable in state done no no; refusing before creating its endpoint or local copy
error: the replacement agent for live-done could not be launched on claude
error: live-done's agent was stopped but the replacement did not launch; no agent is running, and its work plus the recorded progress note are preserved at /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-lab.cO21ik/work/wt-live-done
rc=1

=== Scenario C: away branch FRESH spawn of an in-flight row is still refused ===
$ FM_SUPERVISION_ACTOR=branch bin/fm-spawn.sh live-fresh --mode no-mistakes --yolo off
fm-gate-refuse: gate agent lifecycle permitted only against lab home /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-lab.cO21ik
note: new-task spawn (fm-spawn) proceeds for the supervision branch under the away-posture record: main is parked and its standing authority is relocated; this script's own gate still applies (docs/pi-supervision-branch.md "Postures")
error: spawn refused - the away-posture record caps concurrent workers at 1 and 2 ordinary task(s) are live in this home; task live-fresh stays queued for the captain's return or for a worker to finish (spend cap: bin/fm-afk-contract.sh)
rc=1
DRIVE-DONE

$ bin/fm-afk-contract.sh archive && bin/fm-afk-contract.sh enter --spend 10
  your words: (none)
away

=== Scenario C (cap not saturated): away branch FRESH spawn of an in-flight row is still refused ===
$ FM_SUPERVISION_ACTOR=branch bin/fm-spawn.sh live-fresh --mode no-mistakes --yolo off
fm-gate-refuse: gate agent lifecycle permitted only against lab home /private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-lab.cO21ik
note: new-task spawn (fm-spawn) proceeds for the supervision branch under the away-posture record: main is parked and its standing authority is relocated; this script's own gate still applies (docs/pi-supervision-branch.md "Postures")
note: new-task spawn (fm-spawn) proceeds for the supervision branch under the away-posture record: main is parked and its standing authority is relocated; this script's own gate still applies (docs/pi-supervision-branch.md "Postures")
error: spawn refused - the supervision branch under the away-posture record may dispatch only queued unblocked work (already queued, or filed by the branch from the captain's away words); task live-fresh has no dispatchable backlog item in this home
rc=1
$ tmux list-windows
ctl
fm-live-inflight
fm-live-done
DRIVE-DONE
task:
  id: live-inflight
  title: live lab fixture live-inflight
  state: in_flight
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: ship
  repo: "-"
  priority: "-"
  created: 2026-10-17
  closed: "-"
  deps: none
  links: none
  body: ""
Evidence: tmux pane after relaunch: real Claude worker running in the task's pane

Source: tmux pane after relaunch: real Claude worker running in the task's pane



❯ : Firstmate operational input waiting: read
  '/private/var/folders/jm/zc82vdsn4xndybtssvwyvmm80000gn/T/fm-lab.cO21ik/state
  /operational-inbox/1792220195-8b7862f9793fde5c.msg' and handle its contents
  as Firstmate operational input.

  Read 1 file, ran 1 shell command

⏺ ok

  The steering inbox at live-inflight.inbox had no messages, and handled/ was
  empty too, so there was nothing to act on. The task says to do nothing, so I
  made no changes. The worktree is still clean on task-live-inflight.

✶ Fluttering… (12s · ↓ 353 tokens · thinking with high effort)
█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 2% 21k/1000k [-]
■ System prompt 4.1k  ■ System tools 5.9k  ■ Custom agents 0.7k  ■ Memory …
  tmux focus-events off · add 'set -g focus-events on' to ~/.tmux.conf and re…
────────────────────────────────────────────────────────────────────────────────
❯ 
────────────────────────────────────────────────────────────────────────────────
  [Opus 5.5 (1M context)] ░░░░░░░░░░ 5% | 5H: 5% 1W: 66% | 👑 HARSHA | 📁 wt-…
  ⏵⏵ bypass permissions on (shift+tab to cycle) · ← 2 agents
Evidence: Lab backlog after the scenarios: live-inflight still In flight

Source: Lab backlog after the scenarios: live-inflight still In flight

# Backlog

## In flight
- [ ] live-fresh - fresh spawn adversary (kind: ship) (since 2026-10-17)
- [ ] live-inflight - live lab fixture live-inflight (kind: ship) (since 2026-10-17)

## Queued
## Done
- [x] live-done - live lab fixture live-done (kind: ship) (done 2026-10-17)
Evidence: Key live result
$ FM_SUPERVISION_ACTOR=branch bin/fm-control.sh live-inflight relaunch --note "agent died mid-task; continue"
relaunched live-inflight harness=claude from=claude model=default effort=default backend=tmux endpoint=primary:fm-live-inflight worktree=.../work/wt-live-inflight
rc=0
(tasks-axi show live-inflight -> state: in_flight)
- Outcome: ⚠️ 2 infos across 1 run (5m12s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ bin/fm-spawn.sh:3923 - The intent also describes a follow-on behaviour: after the refusal, the branch recorded it as a captain outcome held for return instead of handing the wake back to main. This change does not touch that handling. It removes the refusal for in-flight relaunches, which was the reported trigger, so the 10-hour stall can no longer start this way. Any other relaunch refusal while away would still be held for the captain's return. This is noted for awareness, not as a defect in the diff.
⚠️ **Test** - 2 infos
  • ℹ️ The bug report's second failure, where the branch recorded the refusal as a captain outcome held for return instead of handing the wake back to main, is not changed by this diff. With the fix that refusal no longer happens for in-flight relaunches, so the reported 10-hour stall is resolved. Other relaunch refusals under away may still be held for return rather than handed back to main.
  • ℹ️ tests/fm-control-relaunch.test.sh - The suite's cleanup (rm -rf &#34;$TMP_ROOT&#34;) cannot remove the read-only state/&lt;id&gt;.git-hooks directories that a relaunch creates, so the new test's away-* fixture dirs are left in $TMPDIR. This is the same cleanup path the existing tests use. It does not affect results. I removed the leftovers by hand.
  • Live validation: ✅ go - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Under the away record (spend cap 1, already full), the supervision branch relaunches an in-flight ship task whose agent died; a real Claude worker starts in the same pane and the backlog row stays in_… ✅ pass live live-lab-transcript.log (Scenario A: 'relaunched live-inflight ... rc=0'), live-relaunched-claude-pane.txt (claude 2.1.302 running and reading its brief), live-lab-backlog-after.md
Regression: on base ce69740 the same away-branch relaunch of an in_flight row is refused with the reported error, and the fix makes it succeed for both in_flight and queued rows ⏸️ untested no The prior payload established this only through unit-level regression tests (tests/fm-control-relaunch.test.sh), not through a live run against the product on base ce69740, so no live result was estab…
Adversarial: an away-branch relaunch of a task whose backlog row is Done is still refused as not dispatchable ✅ pass live live-lab-transcript.log (Scenario B: 'backlog item live-done is not dispatchable in state done no no' rc=1)
Adversarial: a fresh spawn (not a relaunch) by the away branch of an in-flight row is still held to the queued-only gate ✅ pass live live-lab-transcript.log (Scenario C with cap 10: 'spawn refused - ... may dispatch only queued unblocked work ... task live-fresh' rc=1, no new window); fresh-spawn-guard-test.log
  • tests/fm-control-relaunch.test.sh limited to test_away_branch_relaunch_accepts_existing_dispatchable_items, run on the fix (passes) and on base ce69740's bin/fm-spawn.sh (fails with the reported 'spawn refused - the supervision branch under the away-posture record may dispatch only queued unblocked work' error)
  • tests/fm-branch-supervision.test.sh limited to test_away_branch_spawn_requires_queued_dispatchable_work (existing guard for fresh spawns under away)
  • Live lab: bin/fm-lab-home.sh create with a canonical path, config/supervision-host, a markdown backlog via tasks-axi, real git worktrees, and dead-agent windows on a private tmux -L fm-lab socket
  • Live: bin/fm-afk-contract.sh enter --spend 1, then from inside the lab pane FM_SUPERVISION_ACTOR=branch bin/fm-control.sh live-inflight relaunch --note ..., which started real claude in the pane
  • Live: FM_SUPERVISION_ACTOR=branch bin/fm-control.sh live-done relaunch (Done row)
  • Live: bin/fm-afk-contract.sh archive and enter --spend 10, then FM_SUPERVISION_ACTOR=branch bin/fm-spawn.sh live-fresh --mode no-mistakes --yolo off (fresh spawn of an in-flight row)
  • Teardown: tmux -L fm-lab kill-server, stopped the leftover lab claude process, rm -rf of the lab and temp files, removed the single-test runner copies from the worktree
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid
kunchenguid merged commit 11990a2 into kunchenguid:main Oct 17, 2026
37 of 38 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @hrbuilds — really appreciate you taking the time on this.

max-metaplanet added a commit to max-metaplanet/firstmate that referenced this pull request Oct 19, 2026
## Commits taken

- d20196a feat(herdr): opt-in project groups with status tags and a sorted agents view (kunchenguid#7434)
- ce69740 fix(bin): pin LC_ALL=C for remote job process identity reads (kunchenguid#7410)
- 64dddf6 fix(opencode): ignore child stdin EPIPE in guard and encoder (kunchenguid#7447)
- 11becbb fix(bin): ignore crew state overrides for other tasks (kunchenguid#5881)
- eeeeb91 fix(bin): re-anchor a Claude session's lock so /clear keeps ownership (kunchenguid#7415)
- 66c300b feat: support version URLs for watched tool updates (kunchenguid#7449)
- 3094475 fix(pi): keep a live session's extension markers when a nested Pi command loads them (kunchenguid#7287)
- f05b628 fix: reclaim orphaned Claude auto-arm claims (kunchenguid#5939)
- c4f4333 feat(bin): add Polytoken crewmate/scout worker adapter (kunchenguid#7321)
- 11990a2 Fix away branch relaunch admission (kunchenguid#7444)
- 56074d0 fix(bin): show reported checks when a pull request's base requires none (kunchenguid#7450)
- 0791268 fix: support durable per-secondmate account pins (kunchenguid#7452)
- 4e6b9f5 feat(bin): consult operator evidence guards before wedge escalation (kunchenguid#6958)
- c7b7798 fix(bin): make inbox listing succeed when the inbox is empty (kunchenguid#7460)
- 63fc5eb fix: bound remote secondmate convergence and preserve owed re-reads (kunchenguid#7394)
- 8ba34f1 fix: require positive daemon running status in crew-state (kunchenguid#7317)
- 1aa2a21 fix(tests): stabilize supervision host drain and offer fixtures (kunchenguid#7467)
- 69f9d09 fix(bin): refuse spawn into a project with an unborn HEAD (kunchenguid#6987)
- 45dd50a feat(bin): add GitLab --allow-no-pipeline merge waiver and close backlog items for GitLab MRs (kunchenguid#7462)

## Conflict decisions

- `.agents/skills/operational-home-layout/SKILL.md`: Fork seat configuration; upstream per-secondmate account configuration. Decision: Keep both configuration entries.
- `bin/backends/herdr.sh`: Fork send-failure/recovery semantics and harness variable; upstream Polytoken busy override. Decision: Keep fork send-failed and recovery handling; add Polytoken busy identity without losing the fork harness variable.
- `bin/fm-backlog-transition-lib.sh`: Fork cached library directory; upstream GitLab completion support. Decision: Keep cached source path and extend forge ownership comment to GitLab; accept GitLab completion path.
- `bin/fm-config-inherit-lib.sh`: Fork Claude/Codex seat inheritance; upstream Herdr project groups. Decision: Union the allowlist; per-secondmate account pins remain local to the primary home.
- `bin/fm-control.sh`: Fork pre-stop seat checks; upstream per-mate pins and Polytoken launch checks. Decision: Select the per-mate pin while retaining its returned account for seat conflict validation; keep all Polytoken pre-stop checks. A valid explicit pin supersedes the old recorded Claude store on relaunch.
- `bin/fm-harness.sh`: Fork in-process HARNESS_VERDICT result; upstream echo-based Polytoken detection. Decision: Add Polytoken through the fork verdict convention, retaining existing adapter detection.
- `bin/fm-lock.sh`: Fork handover reservation and runtime publication; upstream session re-anchor lease/auto-arm locks. Decision: Share the existing claim lock and release helper, add lease/auto-arm locking, then publish runtime and clear an admitted handover before releasing locks.
- `bin/fm-pr-state.sh`: Fork shared required-check evaluator from dbe11b1 and 91371c8; upstream 56074d0 adds a second gh pr checks fallback. Decision: Keep one evaluator through fm-pr-checks.sh and fm-pr-checks-lib.sh. It already checks non-advisory reported checks on unprotected bases, includes missing configured requirements, and fails closed on read errors. Adapt upstream regressions to this API; preserve the fork REQUIRED CHECK label and advisory policy.
- `bin/fm-spawn.sh`: Fork parked-session resume, seats, unclaimed-worktree guard and ticket hook; upstream Polytoken, per-mate accounts and Herdr groups. Decision: Compose both paths, retain validate_spawn_worktree_unclaimed, seat gates, profile trust and metadata, and both hooks. Extend pin/seat refusal to the selected per-mate pin while retaining the primary-home seat guard. The selected durable Claude pin owns trust and recorded store on relaunch so old seats cannot override it.
- `bin/fm-teardown.sh`: Fork merged-at/park record cleanup and isolation protections; upstream generated Polytoken wiring cleanup. Decision: Keep fork cleanup and guards; add only task-owned Polytoken files and generated untracked wiring to existing guarded teardown.
- `bin/fm-test-run.sh`: Fork timing entries and pipeline-spend suite; upstream Herdr-group and Polytoken suites. Decision: Union suite entries, preserve fork timing measurements for existing suites.
- `bin/fm-wake-lib.sh`: Fork single-read auto-arm ledger parser; upstream session-owner identity fields. Decision: Extend the single-read parser with owner_session_id and the third-line lock identity; retain orphan recovery and lease logic.
- `bin/fm-watch.sh`: Fork bounded run-activity deferral and escalation wording; upstream operator evidence guard. Decision: Keep both bounded deferrals and append operator guard evidence to both ordinary and deep-inspection escalations. Keep exact owned watcher termination semantics.
- `docs/agent-control.md`: Fork seat relaunch policy; upstream per-mate account selection. Decision: Describe both policies with account pin checked before stopping the live agent.
- `docs/configuration.md`: Fork seat sections and ticket timeout; upstream per-mate pins and remote convergence settings. Decision: Keep all sections, place per-mate pins under worker accounts before the seat sections, and retain all timeout entries.
- `tests/fm-control-relaunch.test.sh`: Fork fixture cleanup and seat regressions; upstream account and away-admission regressions. Decision: Keep fixture-scoped cleanup and all regression calls; extend the changed-pin case to check trust in the new store and recorded profile.
- `tests/fm-crew-state.test.sh`: Fork no-fork metadata parsing test; upstream override-identity tests. Decision: Keep both test bodies and calls, plus upstream positive daemon-status cases.
- `tests/fm-pr-merge.test.sh`: Fork named-case local selector; upstream GitLab waiver test definitions. Decision: Place upstream definitions before the named-case selector and retain every case.
- `tests/fm-supervision-host.test.sh`: Fork split helper/suite layout; upstream snapshot-aware offer fixture. Decision: Update the shared supervision-host-helpers.sh implementation and retain its split consumers rather than duplicate the helper in one suite.
- `tests/fm-teardown.test.sh`: Fork collision/released-claim cases; upstream Polytoken cleanup cases. Decision: Keep all regression calls.
- `tests/fm-watch-triage.test.sh`: Fork split classifier/stale/delivery suites; upstream unsplit suite with four new operator-guard cases. Decision: Keep the split and move only new guard fixtures/cases into fm-watch-triage-stale.test.sh; do not resurrect duplicated legacy test bodies.

## Additional integration and verification decisions

- Preserve fork teardown, merge, push, worktree ownership/isolation, and exact-owned watcher termination guards. GitLab no-pipeline waiver remains explicit, attended-only, GitLab-only, and only accepts an explicit null pipeline; default and existing-pipeline safety checks remain in force.
- Existing pull-request CI selects subsets and cannot prove the requested full suite. Add a manual CI workflow trigger using the existing full-suite fallback, so the feature head can run every required lane before landing; document that entry point. No local full suite or real Herdr lifecycle run is authorized.
max-metaplanet added a commit to max-metaplanet/firstmate that referenced this pull request Oct 19, 2026
* feat(herdr): opt-in project groups with status tags and a sorted agents view (kunchenguid#7434)

* feat(herdr): opt-in project groups with status tags and a sorted agents view

Add config/herdr-project-groups (absent or off: unchanged behavior). When on,
Firstmate tags each Herdr task pane, and its own projected workspace, with
display-only fm_group/fm_state/fm_task/fm_sort tokens, sets a Herdr agents
view sorted by group then status (needs-captain, problem, running, done), and
places a new projected task at the end of its own group inside the parent
block with the same single verified move as before.

The watcher reconciles tags once per poll and a spawn tags its task at once;
bin/fm-herdr-groups.sh also previews (plan), clears, and prints or appends
suggested sidebar rows with a backup. The agents view helper needs python3.
The only test-runner change is the serial weight hint for the new suite.

* docs(herdr): record the live lab check of project groups

The four hand checks for tags, the sorted agents view, placement at the
end of the group, and clear passed against a real Herdr 0.9.5 server
(protocol 22) in a guarded lab session.

* docs(herdr): align project group verification notes with the live check

* fix(bin): pin LC_ALL=C for remote job process identity reads (kunchenguid#7410)

ps -o lstart= renders in the caller's locale, so a lock or claim owner
recorded under one locale (de_DE renders "Di Okt 13 ...") failed identity
verification under another, was declared dead, and a second worker split
the queue: two serve loops reclaimed and reaped each other's live jobs,
which vanished mid-claim and failed staged jobs with exit 125 and no
output. Pin LC_ALL=C in fm_remote_job_process_start and pin the
cross-locale invariant with a regression test.

Co-authored-by: researchworldwide2026 <[email protected]>

* fix(opencode): ignore child stdin EPIPE in guard and encoder (kunchenguid#7447)

* fix(bin): ignore crew state overrides for other tasks (kunchenguid#5881)

* Guard fm-crew-state overrides by task-name basename

bin/fm-crew-state.sh honours FM_CREW_STATE_META_OVERRIDE and FM_CREW_STATE_STATUS_OVERRIDE only when the override's basename is the requested task's own .meta or .status file name.
An override naming a different task, for example one inherited through a server started inside another task's snapshot child, falls through to the task's own records under the state directory.
A snapshot's own override, which names the task it was captured for, is still honoured.
This is complementary to kunchenguid#5622, which keeps the overrides out of the Herdr server launch: whatever path leaks an override, the reader never trusts one that names a different task.
Regression tests cover a mismatched override being ignored and a matching one being honoured.

* no-mistakes(review): Make metadata override tests behaviorally distinct

* fix(bin): re-anchor a Claude session's lock so /clear keeps ownership (kunchenguid#7415)

* fix(bin): re-anchor a Claude session's lock so /clear keeps ownership

A same-session confirmation over a live lock line 1 outside the current
harness ancestry now rewrites line 1 to the session's CLAUDE_PID anchor
under the claim lock, so a later /clear re-key in the same process is
still proven by ancestry instead of being refused as a foreign owner.

Fixes kunchenguid#6820

* fix(bin): move task leases with a session-lock re-anchor

A same-session re-anchor rewrote lock line 1 off a live pid while task
leases still named that pid, so a lease held by main or the supervision
branch read as stale and the other actor could claim the task. The
re-anchor now takes the lease-command lock after the claim lock and,
in the same critical section as the line-1 write, rewrites leases
recorded against the old pid to the new anchor (fm_lease_rekey_holder).
If the lease-command lock stays busy past a short bound, the
confirmation keeps line 1 as before and a later acquisition re-anchors.

The foreign-owner reproduction now asserts the re-anchor contract: the
same trusted id from a live process outside the owner's ancestry moves
line 1 onto that process's CLAUDE_PID, and a different id is refused
against it afterwards. The ancestry membership loop is shared through
one session-lock lib helper.

The earlier commit dropped the ancestry suite's dead-front-end reclaim
phase; that coverage lives in the existing reclaim tests
(test_verified_reclaim_keeps_new_sidecar and the Stop auto-arm's
test_reclaims_stale_session_lock_before_arming).

* fix(bin): record the lock holder for a lease pinned before a re-anchor

The supervision host pins FM_LEASE_HOLDER_PID to lock line 1 at the
start of each engine turn. A same-session re-anchor inside that turn
moved line 1 to a new pid while the pinned holder stayed alive, so a
later claim or same-actor refresh in the turn recorded the old pid and
the lease read stale, letting main claim the branch's task.

A claim now records the live line 1 when the pinned holder is alive but
is no longer line 1. Another session takes the lock only from a dead
owner, so that state comes from a re-anchor; a dead pin is still
recorded as before and its lease stays stale.

* no-mistakes(review): Move auto-arm rewake session pid with lock re-anchor

* no-mistakes(review): Align startup-network downgrade test and lock-rewrite comment

* no-mistakes(review): Correct lock takeover and re-anchor signal-window comments

* no-mistakes(review): Record re-anchor rewake and pinned-claim verification evidence

* no-mistakes(document): Update network-checks diagnostic for re-anchored lock holder

* feat: support version URLs for watched tool updates (kunchenguid#7449)

* feat(bin): watch a tool's published version through version_url

A watched tool whose CLI never announces its own updates can name a version_url; the document is fetched read-only inside the probe bound, its first dotted number is the published version, and an update is reported when that is newer than the version PATH resolves. Claude Code is the shipped example entry.

* no-mistakes(review): Compare published versions against newest installed tool copy

* no-mistakes(document): Clarify watched-tool version URL documentation

* fix(pi): keep a live session's extension markers when a nested Pi command loads them (kunchenguid#7287)

* fix(pi): keep a live session's extension markers when a nested Pi command loads them

A short-lived Pi command started from inside a live session, such as the
`pi --help` capability probe, auto-loads the two primary extensions. Both
treated the session lock as owned because an ancestor holds it, so the child
rewrote `.pi-watch-extension-loaded` and `.pi-turnend-extension-loaded` with
its own pid and exited. Session start then rejected the markers and printed a
false `PI_WATCH_EXTENSION: not loaded` alarm.

Before writing, each extension now reads the marker's pid and leaves the
marker untouched when that pid is a live strict ancestor of the current
process. A missing marker, a dead pid, the current pid, or a live pid outside
the ancestry still writes as before, so a fresh start and a relaunch over a
dead session bind unchanged. Lock ownership and the reader are untouched.

Fixes