Skip to content

fix(bin): let relaunch replace the worker of a held in-flight task - #124

Merged
Pibomeister merged 1 commit into
mainfrom
fm/fm-relaunch-captain-held
Nov 3, 2026
Merged

Pibomeister merged 1 commit into
mainfrom
fm/fm-relaunch-captain-held

Conversation

@Pibomeister

Copy link
Copy Markdown
Owner

Intent

bin/fm-control.sh relaunch cannot replace a dead worker whose backlog item is held for the captain. Evidence: agent-kit-mate data/ak-gate-evidence-hash-domain/driver-recovery-20261103.md under ~/orca/workspaces/firstmate/. The relaunch stopped the endpoint, then failed with: this home's backlog item ak-gate-evidence-hash-domain is not dispatchable in state in_flight yes no; refusing before creating its endpoint or local copy. No agent now runs for that task. The hold exists for publication and merge authority and must stay in force.

What Changed

  • bin/fm-backlog-transition-lib.sh adds fm_backlog_row_relaunchable. It admits a held In-flight row (in_flight yes no) for a relaunch and keeps the hold as it is. A held Queued row and any blocked row still refuse. The lib also adds fm_backlog_relaunch_admission, and fm_backlog_dispatch_transition gets a relaunch mode that leaves a held In-flight row where it is.
  • bin/fm-control.sh relaunch now runs the admission check before it stops the old agent. If the backlog row cannot take a replacement worker, the command refuses and the running agent is not touched. Before this change, the old agent was stopped first and the task was left with no worker.
  • bin/fm-spawn.sh uses the relaunch rule on relaunch spawns, both in the pre-endpoint check and in the atomic backlog transition. It also reports a held In-flight row as preserved. A fresh dispatch of a held item still refuses. docs/configuration.md documents the rule, and tests/fm-control-relaunch.test.sh adds coverage for it.

Risk Assessment

✅ Low: The change is narrow. It admits only the in_flight yes no row, and only on the relaunch path (the fm-spawn preflight, the commit-time transition and the preservation readback). Fresh dispatch still refuses held rows. It never issues an unhold or start against a held row, so the captain hold stays in force as the intent requires. The new pre-stop admission in fm-control reuses the same config, data dir and kind that fm-spawn uses, so a refusal now happens before the running agent is touched.

Testing

I ran the change's targeted relaunch tests at the target commit, where they pass, and at the base commit, where the held relaunch test reproduces the exact reported failure: "not dispatchable in state in_flight yes no", then "no agent is running". I then built a disposable live lab with bin/fm-live-lab.sh: a real Claude primary and a real Claude worker on a private tmux server. In that lab I held the worker's In-flight item for the captain. Then I relaunched it twice through bin/fm-control.sh, once with the worker running and once after killing its Claude process. Both relaunches started a fresh worker in the same worktree, with a new spawn generation, and the captain hold stayed unchanged. Two adversarial checks also passed. A held and dependency-blocked item refused before the stop, with the worker process and task record untouched. A fresh dispatch of a held Queued item refused before it created any endpoint or record. I tore the lab down cleanly and removed all temporary files. This is a CLI change, so the evidence is transcripts, not screenshots.

  • Live validation: ✅ go - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Relaunch replaces the running worker of a captain-held In-flight item and keeps the hold ✅ pass live live-held-relaunch.txt sections 1-5: hold set (in_flight, held yes, captain); fm-control relaunch exit 0 'relaunched ...'; new spawn_gen, same worktree; fresh Claude in pane; hold reason and kind unch…
Relaunch replaces a dead worker (its Claude process killed) of a held In-flight item, which is the reported incident ✅ pass live live-held-relaunch.txt sections 6-8: worker pid gone, pane at zsh; relaunch exit 0; pane runs Claude again; item still in_flight, held yes, captain
Regression: the base code fails this scenario with the reported error and no agent left ⏸️ untested no The prior payload did not establish a live result: this was a hermetic regression test at the base commit (targeted-tests-base.txt), not a live run. The live runs cover only the fixed code.
Adversarial: relaunch of a held and dependency-blocked item refuses before stopping the worker ✅ pass live live-held-relaunch.txt section 9: 'cannot take a relaunched worker in state in_flight yes yes; refusing to relaunch, and the running agent was not touched'; worker pid alive; task record hash unchange…
Adversarial: a fresh dispatch of a held Queued item still refuses (the hold still blocks new dispatch) ✅ pass live live-held-relaunch.txt section 10: fm-spawn 'not dispatchable in state queued yes no; refusing before creating its endpoint or local copy'; no task record and no window created
Relaunch of a held Queued item refuses before the running agent is touched ⏸️ untested no The prior payload did not establish a live result: only a hermetic test with a stubbed tmux covered this case (test_relaunch_refuses_a_held_queued_item_before_stopping_the_agent). The live lab drove t…
Evidence: Live held-relaunch transcript (hold, live relaunch, dead-worker relaunch, adversarial refusals)

Source: Live held-relaunch transcript (hold, live relaunch, dead-worker relaunch, adversarial refusals)

## 1. Captain hold on the In-flight item (publication and merge authority)
$ bin/fm-captain-hold.sh hold labc9a999eb9c6f-worker --reason 'captain owns publication and merge'
labc9a999eb9c6f-worker
exit=0
  state: in_flight
  held: yes
  hold_reason: "fm-hold-v1:Y2FwdGFpbiBvd25zIHB1YmxpY2F0aW9uIGFuZCBtZXJnZQ=="
  hold_kind: captain
  hold_until: "-"

## 2. Worker before relaunch
window=firstmate:fm-labc9a999eb9c6f-worker
worktree=/private/tmp/fmlab.heldrl/treehouse/.treehouse/notes-a499d4/1/notes
harness=claude
spawn_gen=s1793672638.82528.31997
lab pid=69563 cmd=zsh
fm-labc9a999eb9c6f-worker pid=14837 cmd=2.1.317
main pid=58528 cmd=2.1.317

## 3. Relaunch the held task's worker
$ bin/fm-control.sh labc9a999eb9c6f-worker relaunch --note 'replace the worker; hold stays for captain'
NOTICE: wake rows held by the live supervision branch - it presents and acknowledges them; do not drain them from here.
relaunched labc9a999eb9c6f-worker harness=claude from=claude model=sonnet effort=low backend=tmux endpoint=firstmate:fm-labc9a999eb9c6f-worker worktree=/private/tmp/fmlab.heldrl/treehouse/.treehouse/notes-a499d4/1/notes
exit=0

## 4. After relaunch
  state: in_flight
  held: yes
  hold_reason: "fm-hold-v1:Y2FwdGFpbiBvd25zIHB1YmxpY2F0aW9uIGFuZCBtZXJnZQ=="
  hold_kind: captain
  hold_until: "-"
window=firstmate:fm-labc9a999eb9c6f-worker
worktree=/private/tmp/fmlab.heldrl/treehouse/.treehouse/notes-a499d4/1/notes
harness=claude
spawn_gen=s1793672796.71795.28206
lab pid=69563 cmd=zsh
fm-labc9a999eb9c6f-worker pid=14837 cmd=2.1.317
main pid=58528 cmd=2.1.317

## 5. Worker pane after relaunch (children of pane shell 14837)
15801 treehouse
--- pane tail ---
 ▐▛███▛█   Claude Code v2.1.317
▝▜██████▀  Sonnet 5.5 with low effort · Claude Ultra
 ▝▝   ▝▝   /private/tmp/fmlab.heldrl/treehouse/.treehouse/notes-a499d4/1/notes
❯ : Firstmate operational input waiting: read '/private/tmp/fmlab.heldrl/home/state/operational-inbox/1793672799-431a16fd8aa8210a.msg' and handle its contents as Firstmate operational input.
✻ Meandering…
  #1 : Firstmate operational input waiting: read '/private/tmp/fmlab.heldrl/home/state/operational-inbox/1793672799-431a16fd8aa8210a.msg' and handle its contents as Firstmate operational input.                       [-]
  ┃
                                                                                                                         tmux detected · scroll with PgUp/PgDn · or add 'set -g mouse on' to ~/.tmux.conf for wheel scroll
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯ 
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ⏵⏵ auto mode on (shift+tab to cycle)

## 6. Kill the worker's Claude process (dead worker, pane shell stays)
$ kill 21478
worker process 21478 gone
lab pid=69563 cmd=zsh
fm-labc9a999eb9c6f-worker pid=14837 cmd=zsh
main pid=58528 cmd=2.1.317

## 7. Relaunch the dead worker of the held task
$ bin/fm-control.sh labc9a999eb9c6f-worker relaunch --note 'worker died; replace it, hold stays'
relaunched labc9a999eb9c6f-worker harness=claude from=claude model=sonnet effort=low backend=tmux endpoint=firstmate:fm-labc9a999eb9c6f-worker worktree=/private/tmp/fmlab.heldrl/treehouse/.treehouse/notes-a499d4/1/notes
exit=0

## 8. After dead-worker relaunch
  state: in_flight
  held: yes
  hold_reason: "fm-hold-v1:Y2FwdGFpbiBvd25zIHB1YmxpY2F0aW9uIGFuZCBtZXJnZQ=="
  hold_kind: captain
  hold_until: "-"
worktree=/private/tmp/fmlab.heldrl/treehouse/.treehouse/notes-a499d4/1/notes
spawn_gen=s1793672842.45639.12058
lab pid=69563 cmd=zsh
fm-labc9a999eb9c6f-worker pid=14837 cmd=2.1.317
main pid=58528 cmd=2.1.317
15801 treehouse

## 9. Adversarial: held AND dependency-blocked In-flight item must still refuse, before the worker is touched
worker claude pid before: 80812
  state: in_flight
  blocked: yes
  blocked_by: lab-dep-x
  held: yes
  deps: "blocked-by:lab-dep-x"
$ bin/fm-control.sh labc9a999eb9c6f-worker relaunch --note 'should refuse'
error: this home's backlog item labc9a999eb9c6f-worker cannot take a relaunched worker in state in_flight yes yes; refusing to relaunch, and the running agent was not touched
exit=1
worker claude pid 80812 still alive
task record unchanged
  state: in_flight
  blocked: yes
  held: yes
  hold_kind: captain

## 10. Adversarial: a fresh dispatch of a held Queued item still refuses (hold blocks new dispatch)
  state: queued
  held: yes
  hold_kind: captain
$ bin/fm-spawn.sh labc9a999eb9c6f-fresh projects/notes --mode local-only --yolo on --harness claude
error: this home's backlog item labc9a999eb9c6f-fresh is not dispatchable in state queued yes no; refusing before creating its endpoint or local copy
exit=
no task record created
lab
fm-labc9a999eb9c6f-worker
main
  state: queued
  held: yes
(note: section 10 exit= is blank because the evidence shell is zsh; the refusal line and the absent task record are the result)
Evidence: Live lab readiness (real Claude primary and worker)

Source: Live lab readiness (real Claude primary and worker)

lab: /private/tmp/fmlab.heldrl (tear down with: bin/fm-live-lab.sh down /private/tmp/fmlab.heldrl)
tree: 3237472836ccda025d28014f32c247d9b5f90017 from ~/.no-mistakes/worktrees/075d7f40c28a/01M6FK4XM4W1JBVT8MW3423XQD
spawned labc9a999eb9c6f-worker harness=claude kind=ship mode=local-only yolo=on window=firstmate:fm-labc9a999eb9c6f-worker worktree=/private/tmp/fmlab.heldrl/treehouse/.treehouse/notes-a499d4/1/notes
gate: /private/tmp/fmlab.heldrl/home/data/labc9a999eb9c6f-worker/gate (touch, then message the worker to resume)
primary: claude --setting-sources project,local --model sonnet --effort medium --permission-mode auto
ok primary: claude pid 58528 in /private/tmp/fmlab.heldrl/home
ok probe: the primary answered LABREADY-c9a999eb9c6f
ok trust: /private/tmp/fmlab.heldrl/home is trusted in the Claude store
ok mirror: verified writer, check passed, captain=1 main=1
ok host: supervision host pid 1643
ok watcher: live watcher with a fresh beacon
ok worker: labc9a999eb9c6f-worker parked on /private/tmp/fmlab.heldrl/home/data/labc9a999eb9c6f-worker/gate
ok treehouse: ~/.treehouse unchanged
ready: /private/tmp/fmlab.heldrl
exit=0
Evidence: Live lab teardown

Source: Live lab teardown

stopped: lab tmux server and lab processes
removed: task temp /tmp/fm-labc9a999eb9c6f-worker+4330888c2a627beb95a33dadbc4df5b018689206841fc911b2e7f83968405a60
removed: task temp /tmp/fm-labc9a999eb9c6f-worker
removed: 3 Claude project entries under /private/tmp/fmlab.heldrl
removed: /private/tmp/fmlab.heldrl
Evidence: Targeted tests at target commit

Source: Targeted tests at target commit

ok - fm-spawn --relaunch: tracked opencode wiring is retired as on main
ok - fm-control removes the dialog file after exit and after relaunch
ok - fm-control exit removes the dialog file before it releases the control lock
ok - relaunch re-reads the backlog item instead of blindly re-running the transition
ok - relaunch replaces the worker of a held In-flight item and leaves the hold in force
ok - fm-spawn --relaunch replaces a stopped worker of a held In-flight item without touching the hold
ok - relaunch refuses a held Queued item before the running agent is touched
Evidence: Targeted tests at base commit (reproduces reported failure)

Source: Targeted tests at base commit (reproduces reported failure)

ok - fm-spawn --relaunch: tracked opencode wiring is retired as on main
ok - fm-control removes the dialog file after exit and after relaunch
ok - fm-control exit removes the dialog file before it releases the control lock
ok - relaunch re-reads the backlog item instead of blindly re-running the transition
not ok - a relaunch of a held In-flight item must replace its worker
warning: /private/var/folders/93/6w1bxqxn2yb92mt6rmt5zbzw0000gn/T/fm-control-relaunch.ZkHXLX/held-relaunch-13579/home/data/rl43/launch-brief.md records no ship branch; defaulting to legacy branch fm/rl43
warning: /private/var/folders/93/6w1bxqxn2yb92mt6rmt5zbzw0000gn/T/fm-control-relaunch.ZkHXLX/held-relaunch-13579/home/data/rl43/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 rl43 is not dispatchable in state in_flight yes no; refusing before creating its endpoint or local copy
error: the replacement agent for rl43 could not be launched on claude
error: rl43'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/93/6w1bxqxn2yb92mt6rmt5zbzw0000gn/T/fm-control-relaunch.ZkHXLX/held-relaunch-13579/wt: expected exit 0, got 1
exit=1
Evidence: Key live result
$ bin/fm-control.sh labc9a999eb9c6f-worker relaunch --note 'worker died; replace it, hold stays'
relaunched labc9a999eb9c6f-worker harness=claude from=claude model=sonnet effort=low backend=tmux endpoint=firstmate:fm-labc9a999eb9c6f-worker worktree=.../notes
exit=0
state: in_flight
held: yes
hold_kind: captain

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Relaunch replaces the running worker of a captain-held In-flight item and keeps the hold ✅ pass live live-held-relaunch.txt sections 1-5: hold set (in_flight, held yes, captain); fm-control relaunch exit 0 'relaunched ...'; new spawn_gen, same worktree; fresh Claude in pane; hold reason and kind unch…
Relaunch replaces a dead worker (its Claude process killed) of a held In-flight item, which is the reported incident ✅ pass live live-held-relaunch.txt sections 6-8: worker pid gone, pane at zsh; relaunch exit 0; pane runs Claude again; item still in_flight, held yes, captain
Regression: the base code fails this scenario with the reported error and no agent left ⏸️ untested no The prior payload did not establish a live result: this was a hermetic regression test at the base commit (targeted-tests-base.txt), not a live run. The live runs cover only the fixed code.
Adversarial: relaunch of a held and dependency-blocked item refuses before stopping the worker ✅ pass live live-held-relaunch.txt section 9: 'cannot take a relaunched worker in state in_flight yes yes; refusing to relaunch, and the running agent was not touched'; worker pid alive; task record hash unchange…
Adversarial: a fresh dispatch of a held Queued item still refuses (the hold still blocks new dispatch) ✅ pass live live-held-relaunch.txt section 10: fm-spawn 'not dispatchable in state queued yes no; refusing before creating its endpoint or local copy'; no task record and no window created
Relaunch of a held Queued item refuses before the running agent is touched ⏸️ untested no The prior payload did not establish a live result: only a hermetic test with a stubbed tmux covered this case (test_relaunch_refuses_a_held_queued_item_before_stopping_the_agent). The live lab drove t…
  • tests/fm-control-relaunch.test.sh filtered to the new held-relaunch tests plus the existing re-verify test: run at the target commit (all ok)
  • The same filtered tests run at base a7b84ef8 (extracted, one local commit added for history): the held In-flight relaunch reproduces the reported error and leaves no agent running
  • bin/fm-live-lab.sh up --harness claude --worker --supervision-host none /tmp/fmlab.heldrl: real Claude primary and real gated Claude worker on a private tmux server, all readiness checks ok
  • bin/fm-captain-hold.sh hold <worker> --reason 'captain owns publication and merge' in the lab, giving item state in_flight yes no
  • bin/fm-control.sh <worker> relaunch --note ... against the running held worker
  • kill of the worker's Claude process (dead worker), then bin/fm-control.sh <worker> relaunch --note ...
  • Adversarial: tasks-axi block <worker> --by lab-dep-x, then relaunch; checked that the worker PID and task record were unchanged
  • Adversarial: new held Queued item with a scaffolded brief, then a fresh bin/fm-spawn.sh <id> projects/notes --mode local-only --yolo on --harness claude
  • bin/fm-live-lab.sh down /tmp/fmlab.heldrl teardown
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

fm-control.sh relaunch could not replace a dead worker whose backlog item
was held in flight: fm-spawn's dispatchability gate refused the row after
the old agent had already been stopped, leaving the task with no agent.

A relaunch now admits a held In-flight row (fm_backlog_row_relaunchable),
reuses the recorded local copy, and leaves the hold untouched at both the
preflight and the commit point. Fresh dispatch of a held item still
refuses. fm-control.sh checks the same admission before it stops the old
agent, so a row that cannot take a replacement refuses with the running
agent untouched.
@Pibomeister
Pibomeister marked this pull request as ready for review November 3, 2026 03:22
@Pibomeister
Pibomeister merged commit 43921b8 into main Nov 3, 2026
27 checks passed
cursor Bot pushed a commit that referenced this pull request Nov 3, 2026
Bring in #122, #124, #123, and #121. No textual conflicts; keep the
published-head resync owner on main's driving-block signature,
freshen_spawn_worktree_base, and t3code skip.

Co-authored-by: Eduardo Picazo <[email protected]>
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