Skip to content

fix(bin): acknowledge opt-in supervision-host hand-backs to main - #7731

Merged
kunchenguid merged 4 commits into
kunchenguid:mainfrom
tiago-peixoto:fm/upstream-7725-handoff-ack
Oct 25, 2026
Merged

kunchenguid merged 4 commits into
kunchenguid:mainfrom
tiago-peixoto:fm/upstream-7725-handoff-ack

Conversation

@tiago-peixoto

@tiago-peixoto tiago-peixoto commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #7725

This change is opt-in: it does nothing unless a home creates config/supervision-handoff-ack.
Automatic retry delivery needs a verified tmux pane, while other terminals keep watching but wait for a normal turn.
The two lost-continuation scenarios, the park boundary and the attended main-only pass-through, are covered by the suite and were not driven against a live Claude primary.
The assertion in test_acknowledged_handoff_at_the_turn_keeps_the_pass_through_row waits for the watcher because the owner replaces the stopped arm within its one-second poll.
Behavior portable serial 1 was cancelled at the 30-minute job cap while every test that ran passed, and upstream main hits the same cap in https://github.com/kunchenguid/firstmate/actions/runs/40101665463 (tracked as #7706).

Intent

Fix the supervision-host handoff defect reported in #7725, as an upstream pull request after the maintainer approved the issue.
When the attended supervision host hands responsibility back to the main conversation, at the park boundary or on an attended main-only pass-through, it leaves no watcher that outlives a lost continuation, so a home can sit unsupervised for hours with no alarm.
A host hand-back must be acknowledged, not fire-and-forget: a verified home-scoped successor keeps watching until the main conversation confirms it owns supervision, and raises the lost hand-back again when that confirmation never comes.
The change is opt-in, off unless a home enables it.
The maintainer triage asks the pull request to carry the three checks from the issue "How to verify" section as behavior tests: the park boundary with no continuation, the attended main-only pass-through with no continuation, and exactly one owning watcher after an acknowledgement.

What Changed

  • bin/fm-supervision-host.sh gains an acknowledged_handback path, active only on a Claude primary with the new home-local config/supervision-handoff-ack flag, that runs at the park boundary, in exit_to_main, and on both attended main-only pass-throughs: it writes a generation token to state/.supervision-handoff-pending, queues a check: supervision-handoff:<token> wake, republishes watcher downtime, and only emits the close after a detached successor reports a healthy watcher (otherwise it prints a supervision-host: failure line and exits nonzero). The next host activation stops the recorded retry owner before taking over its arm, so one watcher remains. Without the flag every hand-back path is unchanged.
  • New bin/fm-supervision-handoff.sh is that detached owner: it records itself in state/.supervision-handoff-owner, replaces each closed one-shot arm via fm-watch-arm.sh and records it in .supervision-host-left, and every FM_SUPERVISION_HANDOFF_RETRY_SECONDS (default 300) retries a record-backed watcher doorbell, submitting through the tmux primitive only when the inherited pane owns the pinned session, is in the foreground, is idle, and has an empty composer. It stops when the token is acknowledged, the opt-in is removed, the session is lost, or away mode starts. bin/fm-wake-drain.sh removes the pending token only when main's sequence-bound ack covers that specific check row.
  • tests/fm-supervision-host.test.sh adds four cases: a lost continuation at the boundary and at the main-only pass-through (watcher survives, retry is logged, stale ack is rejected, real ack clears the token, next park owns exactly one watcher), an acknowledged hand-back at the turn keeping its pass-through log row, and retry transport guards against human drafts, foreign panes, and background sessions. Default-path tests now assert the flag's absence changes nothing. Docs (docs/configuration.md, docs/supervision-host.md, docs/watcher-continuity.md, the operational-home-layout skill) describe the flag, state files, retry knob, and limits, and bin/fm-test-run.sh maps the new script to the host test family.

Risk Assessment

⚠️ Medium: The change is opt-in and leaves every default hand-back path untouched (the gate returns immediately without the flag, and the tests assert the default boundary and successor behavior unchanged), and the three required behavior checks are present, but it adds a detached process lifecycle with four new state files interacting with the recovery marker, the wake queue, and arm take-over, and the branch that prevents two watcher owners at an unacknowledged next park is traced correct yet untested.

Testing

Ran the seven targeted supervision-host suite cases on the target tree (four new hand-back tests plus three default-path tests), all passing; ran the restored-log-row assertions against a plain copy of the pre-fix parent commit 9509bfd, where both the pass-through-row and boundary-row checks fail as expected; then drove real Claude twice in disposable lab checkouts: one run covering the park boundary, the attended main-only pass-through, and the one-watcher take-over after each acknowledgement, and a second run landing the bound on a busy primary to exercise the retry owner's deferral and the eventual acknowledgement. Every live check passed except two rows in the first run's busy segment, which failed only because this machine's global Claude hook blocked the bare sleep command (fixture problem, annotated in the evidence and superseded by the second run). The lost-continuation contract, the opt-in-absent default paths, and the human-draft/foreign-pane/background-terminal transport guards were exercised only by the suite under a fake harness, not against the live product, and are reported as untested. Both labs were torn down and the worktree is clean.

  • Live validation: ✅ go - 4 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Park boundary hand-back on a real Claude primary with the opt-in: the host log shows boundary after 60s then handoff, a pending receipt, a live detached owner and a live watcher exist before main… ✅ pass live r2-live-claude-handoff-ack.md steps 2-4 (PASS rows at 17:10:33Z-17:10:42Z) and the host log start | boundary after 60s | handoff host-4007999-… | start | take-over arm=4061122
Attended main-only pass-through hand-back on a real Claude primary with the opt-in: a needs-decision append produces pass-through attended main-only then handoff, pending receipt, live owner and w… ✅ pass live r2-live-claude-handoff-ack.md steps 5-7 (PASS rows at 17:11:15Z-17:11:25Z); pane capture shows the drain listing the needs-decision signal and the supervision-handoff check followed by the exact --ack…
Hand-back lands while the real primary is busy: the retry owner keeps retrying but defers every time, types nothing into the busy pane, the watcher never drops, main acknowledges once free, and the ne… ✅ pass live r2-live-claude-busy-pane.md: handoff log retry … deferred x3 during a 52s busy window, pane shows the running wait loop with no retry text, then Stop hook feedback -> drain -> ack -> `take-over ar…
Park boundary with no continuation (hook process group torn down, no drain or Stop follows): a verified successor keeps watching, a later event is observed and re-armed, the unacknowledged hand-back i… ⏸️ untested no Not driven against the live product. Only the suite case test_lost_boundary_handoff exercised this, running the real host, Stop hook, arm, watcher, and drain scripts in a fixture home under a fake bas…
Attended main-only pass-through with no continuation: same lost-continuation contract as the boundary case ⏸️ untested no Not driven against the live product. Only the suite case test_lost_pass_through_handoff exercised this, under the same fake bash harness as the lost-boundary case. Real Claude Code 2.1.310 delivers qu…
Round-1 fix regression: with the opt-in, the host log keeps the ordinary boundary and pass-through attended main-only rows before the handoff row; the assertions fail on the pre-fix parent commi… ✅ pass live r2-prefix-regression-check.log and r2-prefix-boundary-regression-check.log show not ok … dropped the pass-through row / dropped the boundary row on 9509bfd with host logs containing only `start |…
Opt-in absent: default hand-back paths are unchanged - the boundary stops the watcher and queues no receipt, the default successor stays one-shot with no receipt, and a main-only pass-through still re… ⏸️ untested no Not driven against the live product. Both live labs in this run were configured with config/supervision-handoff-ack present, so no live run exercised the opt-in-absent default paths. Only the suite ca…
Retry transport guards (adversarial): a pane with a human draft, a pane owned by another session, or a session not in the terminal foreground receives nothing; only the idle owning pane gets a submitt… ⏸️ untested no Not driven against the live product as a whole. The human-draft, foreign-owned-pane, and background-terminal guards were exercised only by the suite case test_handoff_retry_respects_the_receiving_pane…
Evidence: Live Claude: boundary and pass-through hand-backs, acknowledgement, and one-watcher take-over (round 2, with fixed log rows)

Source: Live Claude: boundary and pass-through hand-backs, acknowledgement, and one-watcher take-over (round 2, with fixed log rows)

# Round 2 real Claude lab: acknowledged hand-back (config/supervision-handoff-ack)

Lab checkout: /tmp/fm-sh-handoff-live.MthGaY/fm (plain git checkout of 35155da3c2393dcfd20ef5fef557bf800b16682a; FM_HOME is the checkout). 2.1.310 (Claude Code), model haiku, park bound 60s, retry 20s. Claude runs interactively on a private tmux server (socket dir /tmp/fm-sh-handoff-live.MthGaY/tmux); the setup prompt is the only typed message until the busy-pane step.


\<details><summary>pane: step 0: Claude started</summary>

`` `text
 ▐▛███▛█   Claude Code v2.1.310
▝▜██████▀  Haiku 5.5 · Claude Max
 ▝▝   ▝▝   /tmp/fm-sh-handoff-live.MthGaY/fm


────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯ Try "how do I log an error?"
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ⏵⏵ bypass permissions on (shift+tab to cycle) · ← for agents                                                                                                                      ◐ medium · /effort









































`` `
</details>

- 17:09:31Z step 1: primary idle (claude pid 3999174, lock=3999174); waiting for the host park
- 17:09:32Z step 1: host parked: pending= owner=(alive=no) watcher=4008673(alive=yes) host=4007999(alive=yes) arms[pid ppid]=[4008598 4007999;] queue_rows=0

\<details><summary>pane: step 1: idle primary, host parked</summary>

`` `text
 ▐▛███▛█   Claude Code v2.1.310
▝▜██████▀  Haiku 5.5 · Claude Max
 ▝▝   ▝▝   /tmp/fm-sh-handoff-live.MthGaY/fm


❯ This is an isolated Firstmate test lab, not a real fleet. Reply with exactly READY now and use no tools. Later, whenever a "Stop hook feedback" message wakes you, do exactly this and nothing else:
  run bin/fm-wake-drain.sh once with the Bash tool, then run the exact bin/fm-wake-drain.sh --ack-through ... command that its WAKE_ACK_REQUIRED line prints, then reply with exactly ACKED. Never run
  any other command, never run bin/fm-watch-arm.sh, and never use any other tool. If I later ask you to run sleep, run exactly that sleep command with the Bash tool and then reply with exactly SLEPT.

● READY

✻ Brewed for 5s · done 7:09 PM

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯ 
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ⏵⏵ bypass permissions on (shift+tab to cycle)                                                   tmux focus-events off · add 'set -g focus-events on' to ~/.tmux.conf and reattach for focus tracking

































`` `
</details>

- 17:09:32Z step 2 (boundary): nobody types; waiting up to 120s for the park bound
- 17:10:33Z step 2 (boundary): hand-back at +61s; host log: start	gen=host-4007999-1792861771	primary=claude|boundary	after 60s|handoff	host-4007999-1792861771|
- 17:10:33Z step 2 (boundary): BEFORE main runs: pending=host-4007999-1792861771 owner=4060444(alive=yes) watcher=4061220(alive=yes) host=(alive=no) arms[pid ppid]=[4061122 4060444;] queue_rows=1
- 17:10:33Z PASS: boundary: the host log keeps its boundary row before the handoff row (round-1 fix)
- 17:10:33Z PASS: boundary: a hand-back receipt is pending
- 17:10:33Z PASS: boundary: the detached owner is alive before main runs
- 17:10:33Z PASS: boundary: a watcher is alive before main runs
- 17:10:33Z PASS: boundary: the token-bound check is queued
- 17:10:33Z step 2 (boundary): queue: check	supervision-handoff:host-4007999-1792861771	check: supervision-handoff - the host handed supervision to main; drain, handle, and acknowledge this hand-back|
- 17:10:33Z step 3 (boundary): waiting for the real primary to drain and acknowledge
- 17:10:38Z PASS: boundary: main's acknowledgement cleared the pending receipt
- 17:10:39Z step 3 (boundary): after the primary's own ack: pending= owner=(alive=no) watcher=4061220(alive=yes) host=(alive=no) arms[pid ppid]=[4061122 5856;] queue_rows=0
- 17:10:39Z PASS: boundary: the watcher is still alive after the acknowledgement

\<details><summary>pane: step 3: primary drained and acknowledged the boundary hand-back</summary>

`` `text
 ▐▛███▛█   Claude Code v2.1.310
▝▜██████▀  Haiku 5.5 · Claude Max
 ▝▝   ▝▝   /tmp/fm-sh-handoff-live.MthGaY/fm


❯ This is an isolated Firstmate test lab, not a real fleet. Reply with exactly READY now and use no tools. Later, whenever a "Stop hook feedback" message wakes you, do exactly this and nothing else:
  run bin/fm-wake-drain.sh once with the Bash tool, then run the exact bin/fm-wake-drain.sh --ack-through ... command that its WAKE_ACK_REQUIRED line prints, then reply with exactly ACKED. Never run
  any other command, never run bin/fm-watch-arm.sh, and never use any other tool. If I later ask you to run sleep, run exactly that sleep command with the Bash tool and then reply with exactly SLEPT.

● READY

✻ Brewed for 5s · done 7:09 PM

● Stop hook feedback

● Bash(bin/fm-wake-drain.sh)
  ⎿  1792861832      1       check   supervision-handoff:host-4007999-1792861771     check: supervision-handoff - the host handed supervision to main; drain, handle, and acknowledge this
     hand-back
     WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 4008673.1792861831.jWbvVF
     WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.

● Bash(bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 4008673.1792861831.jWbvVF)
  ⎿  (No output)

● ACKED

* Marinating… (running Stop hooks… 2/3 · 5s · ↓ 219 tokens)
  ⎿  Tip: Control this session from the Claude mobile app · run /remote-control

──────────────────────────────────────────────────────────────────────────────────────────────────────────

... [13004 bytes truncated] ...

nes (ctrl+o to expand)

● Bash(bin/fm-wake-drain.sh --ack-through 6 --recovery-generation 4184890.1792862013.fsfOro)
  ⎿  (No output)

● ACKED

✻ Brewed for 6s · done 7:13 PM

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯ run sleep 110 in the background
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ⏵⏵ bypass permissions on (shift+tab to cycle)


`` `
</details>

- 17:14:26Z step 9 (busy): after the sleep turn: host log since the park: boundary	after 60s|handoff	host-4107850-1792861883|start	gen=host-4183058-1792861953	primary=claude|take-over	arm=4172895|boundary	after 60s|handoff	host-4183058-1792861953|start	gen=host-53959-1792862022	primary=claude|take-over	arm=48898|; pending= owner=(alive=no) watcher=55217(alive=yes) host=53959(alive=yes) arms[pid ppid]=[54462 53959;] queue_rows=0
- 17:14:26Z step 9 (busy): pending receipt now: ''; handoff log: 
- 17:14:26Z step 9 (busy): pending= owner=(alive=no) watcher=55217(alive=yes) host=53959(alive=yes) arms[pid ppid]=[54462 53959;] queue_rows=0

\<details><summary>pane: step 9b: after the busy hand-back was handled</summary>

`` `text

❯ Run exactly this with the Bash tool: sleep 110. Then reply with exactly SLEPT.

● Bash(sleep 110)
  ⎿  Error: Blocked: standalone sleep 110. To wait for a condition, use Monitor with an until-loop (e.g. `until <check>; do sleep 2; done`). To wait for a command you started, use run_in_background:
     true. Do not chain shorter sleeps to work around this block.

● The sleep did not run. The harness blocked sleep 110 as a standalone command, and it said to use Monitor with an until-loop or a background command instead. I did not split it into shorter sleeps,
  because the block told me not to work around it. So I can't reply SLEPT, since the sleep never ran. If you want the wait anyway, tell me whether to run it as a background command or through Monitor.

✻ Cooked for 4s · done 7:11 PM

● Stop hook feedback

● Bash(bin/fm-wake-drain.sh)
  ⎿  1792861944      5       check   supervision-handoff:host-4107850-1792861883     check: supervision-handoff - the host handed supervision to main; drain, handle, and acknowledge this
     hand-back
     WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 5 --recovery-generation 4109260.1792861943.5LYc3v
     OPEN DECISIONS (still open, folded from the durable status logs - not just the latest line):
     … +3 lines (ctrl+o to expand)

● Bash(bin/fm-wake-drain.sh --ack-through 5 --recovery-generation 4109260.1792861943.5LYc3v)
  ⎿  (No output)

● ACKED

✻ Worked for 6s · done 7:12 PM

● Stop hook feedback

● Bash(bin/fm-wake-drain.sh)
  ⎿  1792862013      6       check   supervision-handoff:host-4183058-1792861953     check: supervision-handoff - the host handed supervision to main; drain, handle, and acknowledge this
     hand-back
     WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 6 --recovery-generation 4184890.1792862013.fsfOro
     OPEN DECISIONS (still open, folded from the durable status logs - not just the latest line):
     … +3 lines (ctrl+o to expand)

● Bash(bin/fm-wake-drain.sh --ack-through 6 --recovery-generation 4184890.1792862013.fsfOro)
  ⎿  (No output)

● ACKED

✻ Brewed for 6s · done 7:13 PM

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯ run sleep 110 in the background
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ⏵⏵ bypass permissions on (shift+tab to cycle)


`` `
</details>

- 17:14:26Z PASS: busy: the hand-back was eventually acknowledged by main
- 17:14:26Z step 10 (busy): host log since the park: boundary	after 60s|handoff	host-4107850-1792861883|start	gen=host-4183058-1792861953	primary=claude|take-over	arm=4172895|boundary	after 60s|handoff	host-4183058-1792861953|start	gen=host-53959-1792862022	primary=claude|take-over	arm=48898|; pending= owner=(alive=no) watcher=55217(alive=yes) host=53959(alive=yes) arms[pid ppid]=[54462 53959;] queue_rows=0
- 17:14:26Z PASS: busy: supervision ends with exactly one host-owned watcher

## full host log (state/.supervision-host.log)
`` `
1792861772	start	gen=host-4007999-1792861771	primary=claude
1792861831	boundary	after 60s
1792861833	handoff	host-4007999-1792861771
1792861840	start	gen=host-4070911-1792861840	primary=claude
1792861841	take-over	arm=4061122
1792861873	pass-through	attended	main-only	signal: /tmp/fm-sh-handoff-live.MthGaY/fm/state/demo.status
1792861875	handoff	host-4070911-1792861840
1792861884	start	gen=host-4107850-1792861883	primary=claude
1792861884	take-over	arm=4099647
1792861943	boundary	after 60s
1792861945	handoff	host-4107850-1792861883
1792861953	start	gen=host-4183058-1792861953	primary=claude
1792861953	take-over	arm=4172895
1792862013	boundary	after 60s
1792862015	handoff	host-4183058-1792861953
1792862023	start	gen=host-53959-1792862022	primary=claude
1792862023	take-over	arm=48898
`` `
## handoff log (state/.supervision-handoff.log)
`` `
<no retries were needed>
`` `
## wake queue at the end
`` `
`` `
## Claude transcript: ~/.claude/projects/-tmp-fm-sh-handoff-live-MthGaY-fm/a6e7dd84-e5e5-4ea2-a8c8-c1ca858f66a6.jsonl
- 17:14:26Z not ok - live Claude: at least one check failed (see FAIL rows above)
- 17:14:26Z teardown: killing the lab tmux server and every process still running from /tmp/fm-sh-handoff-live.MthGaY/fm
- 17:14:29Z teardown done: ls: cannot access '/tmp/fm-sh-handoff-live.MthGaY': No such file or directory

## Note on the two FAIL rows in steps 8-9 (busy pane)

Those two FAIL rows are a fixture problem, not a product failure.
The lab primary runs with this machine's global Claude hooks, and one of them blocks a standalone `sleep` command, so the primary was never busy when the bound landed.
The boundary and pass-through scenarios above (steps 1-7) passed every check.
The busy-pane scenario was re-run with an allowed wait loop in `r2-live-claude-busy-pane.md`, where every check passed.
Evidence: Live busy-pane run: host log and handoff retry log
host log since the park: boundary after 60s | handoff host-190626-1792862176 | start gen=host-295787-1792862301 | take-over arm=245204
handoff log: retry host-190626-1792862176 deferred | retry … deferred | retry … deferred
after release: pending='' owner=(alive=no) watcher=297297(alive=yes) host=295787(alive=yes) arms[pid ppid]=[296471 295787] queue_rows=0
Evidence: Selected supervision-host suite tests on the target tree

Source: Selected supervision-host suite tests on the target tree

ok - host+hook: boundary survives a lost continuation, retries, and transfers one watcher after acknowledgement
grep: /tmp/fm-supervision-host.aOFocl/lost-handoff-pass-through/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/lost-handoff-pass-through/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/lost-handoff-pass-through/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/lost-handoff-pass-through/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/lost-handoff-pass-through/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/lost-handoff-pass-through/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/lost-handoff-pass-through/state/.supervision-handoff.log: No such file or directory
ok - host+hook: pass-through survives a lost continuation, retries, and transfers one watcher after acknowledgement
ok - host+hook: an acknowledged hand-back at the turn keeps its pass-through row
grep: /tmp/fm-supervision-host.aOFocl/handoff-doorbell/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/handoff-doorbell/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/handoff-doorbell/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/handoff-doorbell/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/handoff-doorbell/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/handoff-doorbell/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/handoff-doorbell/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/handoff-doorbell/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/handoff-doorbell/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/handoff-doorbell/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/handoff-doorbell/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/handoff-doorbell/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/handoff-doorbell/state/.supervision-handoff.log: No such file or directory
grep: /tmp/fm-supervision-host.aOFocl/handoff-doorbell/state/.supervision-handoff.log: No such file or directory
ok - host+hook: hand-back retry submits only to the idle owning pane without replacing human input
ok - host: the park ends itself with a boundary wake and a stopped watcher
ok - host+hook: a successor close that lands during main's turn is delivered at the next turn end
ok - host+hook: an attended main-only pass-through rewakes main and keeps its successor watcher

real	1m15.142s
user	0m15.966s
sys	0m41.707s
rc=0
Evidence: Pre-fix parent 9509bfd: pass-through row assertion fails

Source: Pre-fix parent 9509bfd0: pass-through row assertion fails

not ok - ack turns-main-only: the hand-back dropped the pass-through row
--- /tmp/fm-supervision-host.BhXs84/hook-turns-main-only-ack/state/.supervision-host.log ---
1792861446	start	gen=host-3733886-1792861445	primary=claude
1792861452	handoff	host-3733886-1792861445

real	0m8.780s
user	0m2.862s
sys	0m7.381s
rc=1
Evidence: Pre-fix parent 9509bfd: boundary row assertion fails

Source: Pre-fix parent 9509bfd0: boundary row assertion fails

not ok - boundary: the hand-back dropped the boundary row
--- /tmp/fm-supervision-host.ioDcga/lost-handoff-boundary/state/.supervision-host.log ---
1792861563	start	gen=host-3831880-1792861563	primary=claude
1792861566	handoff	host-3831880-1792861563

real	0m5.963s
user	0m1.758s
sys	0m4.497s
rc=1
- Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (53m19s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ℹ️ bin/fm-supervision-host.sh:1216 - In the HANDLE_RC=2 pass-through branch the opt-in acknowledged_handback call sits before the log_line &#34;pass-through attended ...&#34; write, and it never returns when the flag is on, so the host log records only handoff &lt;gen&gt; and no pass-through row for that hand-back. The sibling attended pass-through at line 1168 logs first and then calls acknowledged_handback, so the two sites disagree. The host log is the forensic record the issue was diagnosed from. Remedy: move the acknowledged_handback call below the log_line at line 1217 so both pass-through sites log the hand-back reason before transferring.
  • ℹ️ bin/fm-supervision-host.sh:373 - The new activate() block that stops a live .supervision-handoff-owner before the arm take-over is the only thing that keeps the next park from running beside a still-retrying owner, and no test reaches it: both lost-hand-back tests acknowledge first, so the owner has already exited on .supervision-handoff-pending removal before turn_end starts the next park, and the doorbell test never parks again. The realistic retry flow (doorbell wakes main, main's turn ends without acknowledging, Stop hook parks) goes through this block alone. I traced it: the owner's TERM trap runs cleanup, which disowns the recorded arm and removes the owner file, and the host then takes over .supervision-host-left; identities match because _fm_engine_identity normalizes fm_pid_identity output without changing it on Linux. No defect found, but the one-watcher invariant in the unacknowledged next-park case rests on an untested branch.
🔧 **Test** - 1 issue found → auto-fixed ✅
  • ⚠️ bin/fm-supervision-host.sh:529 - With config/supervision-handoff-ack present, acknowledged_handback exits the host before the ordinary host-log row is written on two paths: boundary_exit() calls it before log_line &#34;boundary after ${PARK_ELAPSED}s&#34; (line 529 vs 538), and the handle_wake rc 2 branch calls it before log_line &#34;pass-through attended ...&#34; (line 1216 vs 1217), unlike the attended_acceptor branch at line 1167-1168 which logs first. Result: state/.supervision-host.log shows only handoff &lt;gen&gt; with no boundary or pass-through row, which is exactly the diagnostic row issue 7725 used to find the outage. Reproduced live (evidence live-claude-boundary-only.log: the real Claude run reached the bound at +62s and recorded handoff but no boundary row) and deterministically with the suite fixture (late-main-only-host-log-rows.md: identical close with the flag absent logs the pass-through row, with the flag present it does not). Fix: move the acknowledged_handback call after the respective log_line on both paths, matching line 1167-1168. The hand-back itself, the queued check, the rewake, and the acknowledgement all work; this is a logging regression on the opt-in path only.
  • Live validation: ✅ go - 10 of 11 scenarios driven live against the product
Scenario Result Live Evidence
Opt-in home reaches its park boundary and main never runs the continuation: a home-scoped watcher keeps running, a later event is observed, the one-shot successor is replaced, and the hand-back is rai… ✅ pass live test_lost_boundary_handoff (target-new-tests.log) and boundary-lost-continuation-transcript.md phases 2-3 (owner pid alive, watcher replaced, retry row, check row still queued)
Opt-in home takes an attended main-only pass-through and main never runs the continuation: same survival and re-raise ✅ pass live test_lost_pass_through_handoff and pass-through-lost-continuation-transcript.md
Main acknowledges the hand-back with the exact printed drain command: pending clears, the watcher stays up, and the next park owns exactly one watcher ✅ pass live boundary and pass-through transcripts phases 5-6 (take-over arm= and one arm whose parent is the host); live-claude-handoff-ack.md steps 3-4 and 6-7 with a real Claude primary
Adversarial: a stale acknowledgement that never presented the check row does not clear the pending hand-back ✅ pass live transcripts phase 4: --ack-through 0 leaves the pending token in place
Adversarial: the retry doorbell never overwrites a human draft, never reaches a foreign pane or a background session, and submits only to the idle owning pane as a durable operational record without t… ✅ pass live test_handoff_retry_respects_the_receiving_pane (target-new-tests.log)
Without the opt-in the boundary, successor, and pass-through behave exactly as before (no pending file, one-shot successor, watcher stopped at the bound) ✅ pass live target-default-path-tests.log: three default-path tests pass including the new absent-opt-in assertions
Adversarial: removing config/supervision-handoff-ack while a hand-back is pending stops the retry owner, leaves the current watcher, and the next park takes it over ✅ pass live opt-in-removal-transcript.md phases 2-3 and evidence-drive.log
Regression reproduction: the new tests fail on the base commit ✅ pass live base-boundary-repro.log and base-passthrough-repro.log both report lost continuation left no verified watcher
Real Claude primary (Claude Code 2.1.310) with the opt-in: a pass-through hand-back is delivered by the real Stop hook, the primary drains and acknowledges, pending clears, next park owns one watcher ✅ pass live live-claude-handoff-ack.md steps 5-7 and the full host log (pass-through attended main-only, handoff, take-over)
Real Claude primary with the opt-in: the park boundary queues the token-bound check, the primary is rewoken, drains and acknowledges it, and the next park owns one watcher ✅ pass live live-claude-boundary-only.log: host log handoff at +62s of a 60s bound, pane shows Stop hook feedback, the check row, --ack-through 1, ACKED, then take-over arm=; the script's own assertion on a…
Real Claude accepts the retry doorbell typed into its pane after a lost continuation ⏸️ untested no A real Claude session always receives the Stop hook exit-2 continuation and acknowledges within seconds, so the retry never fires; forcing a lost continuation in a live Claude Code process has no supp…
  • tests/fm-supervision-host.test.sh filtered to test_lost_boundary_handoff, test_lost_pass_through_handoff, test_handoff_retry_respects_the_receiving_pane on the target commit (all ok, 49s)
  • tests/fm-supervision-host.test.sh filtered to test_park_boundary_ends_the_park_before_the_hook_timeout, test_successor_close_during_main_turn_is_delivered_at_the_next_turn_end, test_claude_stop_hook_delivers_a_main_only_pass_through on the target commit (default paths without the opt-in, all ok)
  • The new test_lost_boundary_handoff and test_lost_pass_through_handoff run against the base commit d96bff00 scripts (git archive): both fail with lost continuation left no verified watcher, reproducing the issue
  • Custom evidence drive of the issue's three verify steps with per-phase state snapshots (boundary and pass-through transcripts): watcher survives the torn-down hook group, successor close is replaced and the hand-back re-raised, main drain re-presents the check, a stale --ack-through 0 does not clear the pending token, the exact printed ack clears it, next park take-over leaves one host-owned arm
  • Adversarial: removing config/supervision-handoff-ack while a hand-back is pending stops the retry owner within seconds, keeps the current watcher, fires no retry, and the next park takes over exactly one watcher (opt-in-removal-transcript.md)
  • Real Claude Code 2.1.310 (haiku, low effort) in an isolated lab copy of the target checkout with both opt-ins, private tmux server, real Stop hook: pass-through hand-back queued a token-bound check, left a live owner and watcher, the idle primary was rewoken, ran bin/fm-wake-drain.sh and the exact --ack-through command, pending cleared, next park took over one host-owned watcher (live-claude-handoff-ack.md)
  • Real Claude lab, boundary-only variant with one registered project and no status appends: the park reached its 60s bound, queued the check, rewoke the primary which drained and acknowledged it, and the next park took over one arm (live-claude-boundary-only.log; script assertion on the boundary log row failed, which is the reported finding)
  • Fixture comparison of a close that turns main-only at its turn with and without the opt-in: host log has the pass-through row without the flag and lacks it with the flag (late-main-only-host-log-rows.md)

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

  • Live validation: ✅ go - 4 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Park boundary hand-back on a real Claude primary with the opt-in: the host log shows boundary after 60s then handoff, a pending receipt, a live detached owner and a live watcher exist before main… ✅ pass live r2-live-claude-handoff-ack.md steps 2-4 (PASS rows at 17:10:33Z-17:10:42Z) and the host log start | boundary after 60s | handoff host-4007999-… | start | take-over arm=4061122
Attended main-only pass-through hand-back on a real Claude primary with the opt-in: a needs-decision append produces pass-through attended main-only then handoff, pending receipt, live owner and w… ✅ pass live r2-live-claude-handoff-ack.md steps 5-7 (PASS rows at 17:11:15Z-17:11:25Z); pane capture shows the drain listing the needs-decision signal and the supervision-handoff check followed by the exact --ack…
Hand-back lands while the real primary is busy: the retry owner keeps retrying but defers every time, types nothing into the busy pane, the watcher never drops, main acknowledges once free, and the ne… ✅ pass live r2-live-claude-busy-pane.md: handoff log retry … deferred x3 during a 52s busy window, pane shows the running wait loop with no retry text, then Stop hook feedback -> drain -> ack -> `take-over ar…
Park boundary with no continuation (hook process group torn down, no drain or Stop follows): a verified successor keeps watching, a later event is observed and re-armed, the unacknowledged hand-back i… ⏸️ untested no Not driven against the live product. Only the suite case test_lost_boundary_handoff exercised this, running the real host, Stop hook, arm, watcher, and drain scripts in a fixture home under a fake bas…
Attended main-only pass-through with no continuation: same lost-continuation contract as the boundary case ⏸️ untested no Not driven against the live product. Only the suite case test_lost_pass_through_handoff exercised this, under the same fake bash harness as the lost-boundary case. Real Claude Code 2.1.310 delivers qu…
Round-1 fix regression: with the opt-in, the host log keeps the ordinary boundary and pass-through attended main-only rows before the handoff row; the assertions fail on the pre-fix parent commi… ✅ pass live r2-prefix-regression-check.log and r2-prefix-boundary-regression-check.log show not ok … dropped the pass-through row / dropped the boundary row on 9509bfd with host logs containing only `start |…
Opt-in absent: default hand-back paths are unchanged - the boundary stops the watcher and queues no receipt, the default successor stays one-shot with no receipt, and a main-only pass-through still re… ⏸️ untested no Not driven against the live product. Both live labs in this run were configured with config/supervision-handoff-ack present, so no live run exercised the opt-in-absent default paths. Only the suite ca…
Retry transport guards (adversarial): a pane with a human draft, a pane owned by another session, or a session not in the terminal foreground receives nothing; only the idle owning pane gets a submitt… ⏸️ untested no Not driven against the live product as a whole. The human-draft, foreign-owned-pane, and background-terminal guards were exercised only by the suite case test_handoff_retry_respects_the_receiving_pane…
  • bash &lt;copy of tests/fm-supervision-host.test.sh running only test_lost_boundary_handoff test_lost_pass_through_handoff test_acknowledged_handoff_at_the_turn_keeps_the_pass_through_row test_handoff_retry_respects_the_receiving_pane test_park_boundary_ends_the_park_before_the_hook_timeout test_successor_close_during_main_turn_is_delivered_at_the_next_turn_end test_claude_stop_hook_delivers_a_main_only_pass_through&gt; on the target tree - 7 ok (evidence r2-target-selected-tests.log)
  • Same selected tests test_acknowledged_handoff_at_the_turn_keeps_the_pass_through_row and test_lost_boundary_handoff run against a git archive 9509bfd0 copy of the pre-fix parent - both fail on the dropped host-log row (evidence r2-prefix-regression-check.log, r2-prefix-boundary-regression-check.log)
  • Live Claude lab (real claude --model haiku --dangerously-skip-permissions in tmux -L fm-lab on a private socket, FM_HOME = disposable checkout of 35155da3 with config/supervision-host + config/supervision-handoff-ack, FM_SUPERVISION_HOST_PARK_SECONDS=60, FM_SUPERVISION_HANDOFF_RETRY_SECONDS=20): park boundary hand-back, attended main-only pass-through hand-back, acknowledgement by the primary, next-park take-over with exactly one arm owning the watcher (evidence r2-live-claude-handoff-ack.md)
  • Live Claude lab, busy primary: the bound landed while Claude blocked in a Bash wait loop; three retries logged deferred, no retry text in the pane, watcher alive throughout, acknowledgement after release, one host-owned watcher after (evidence r2-live-claude-busy-pane.md)
  • Teardown: tmux -L fm-lab kill-server on each lab socket, TERM of every process running from the lab checkout, rm -rf of each lab dir and of the temp test copies; git status --short in the worktree is empty
⚠️ **Document** - 1 info
  • ℹ️ docs/supervision-protocols/supervision-host.md:17 - docs/supervision-protocols/supervision-host.md (the agent-runtime block rendered into every Claude session on a host home) says a handed-back wake reaches main only as Stop hook feedback. With config/supervision-handoff-ack, bin/fm-supervision-handoff.sh can also type a 'check: supervision-handoff' retry message into the idle owning pane. Nothing in the protocol is wrong, and the retry message carries its own drain-and-acknowledge instruction, so I left this always-loaded surface untouched rather than add opt-in detail to it. A maintainer may prefer one tagged {claude} line pointing at supervision-host.md#acknowledged-hand-back.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

When the attended supervision host hands responsibility back to the main
conversation, at the park boundary or on a main-only pass-through, it left
no watcher that outlived a lost continuation, so a home could stay
unsupervised with no alarm.

With config/supervision-handoff-ack present, a Claude host hand-back now
queues a token-bound check and starts a verified, home-scoped successor
(bin/fm-supervision-handoff.sh). The successor keeps replacing closed
watcher cycles and raises the hand-back again until the main conversation
acknowledges it through the sequence-bound wake drain. Automatic retry
delivery needs a verified tmux pane; other terminals keep watching and wait
for a normal turn.

The behavior is off unless the flag exists, so the default hand-back paths
are unchanged.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @tiago-peixoto for turning #7725 into a PR this quickly, and for being clear about which scenarios were driven live and which weren't.

I read head 58f75eec against main d96bff00. Here's what I checked:

  • Off by default: acknowledged_handback returns right away unless the primary is Claude and config/supervision-handoff-ack exists. The activate() take-over only runs when state/.supervision-handoff-owner exists, and the fm-wake-drain.sh ack branch only runs when state/.supervision-handoff-pending exists. Only the opt-in path creates those files. The one change on the unconfigured path is that boundary_exit now writes its boundary after Ns log row before retiring the arms instead of after.
  • Safety: the new detached owner only types into the pane when that pane owns the pinned session, is in the foreground, is idle, and has an empty composer. The diff touches no workflows, secrets or network calls.
  • No-mistakes: the attestation is bound to 58f75eec.

Contract-class (my own read): opt-in. #7725 itself was new-default as an always-on change. This PR keeps it behind a home-local flag, so that doesn't apply here. VISION.md, rule by rule: One captain, one interface: aligns (a lost hand-back gets raised again instead of going silent). Authority: aligns (off unless the home turns it on, and it grants no new authority). Scripts own the mechanics: aligns (the token, ack and retry are all exact script work). Restart is a non-event: aligns strongly (the obligation is closed by a durable ack record). Delegation with a spine: partly there. The suite covers the three checks from the issue, but see CI below. Vendor: aligns (scoped to Claude, other owners unchanged). Scope: aligns.

What's blocking: CI is red, and the failure is in one of the PR's own new tests. In run 40116482451, Behavior portable serial 1 fails not ok - ack turns-main-only: the hand-back left no watcher in test_acknowledged_handoff_at_the_turn_keeps_the_pass_through_row. The two lost-continuation cases right before it pass. That check runs watcher_live once, right after the hook exits, with no wait_until. On that path acknowledged_handback exits before detach_successor runs. So it could be a timing race in the test, or a real gap in the HANDLE_RC=2 hand-back. Could you take a look and push a fix through git push no-mistakes? This isn't one of the known main-inherited flakes, so I haven't rerun it.

One more, if you can: the two lost-continuation scenarios, which are the heart of #7725, are only covered by the suite so far. If you can drive either one against a real Claude primary and post the evidence, that would really help. If you can't, just say so in the PR body.

Status: waiting on you for the serial 1 fix. Once CI is green and the attestation is bound to the new head, this is on track to merge as opt-in.

…t.sh (test_acknowledged_handoff_at_the_turn_keeps_the_pass_through_row), the only failure in "Behavior portable serial 1". Invariant: after an acknowledged hand-back at the turn, a live watcher must exist, but the owner replaces the stopped successor arm only within its one-second poll, so a one-shot watcher_live read at the hand-back instant can observe the gap. The sibling lost-continuation cases already wait for the owner's replacement, so this was the one remaining one-shot site on the hand-back path. Change, per the user's instruction: the assertion is now `wait_until 150 watcher_live "$home" || fail "ack turns-main-only: the hand-back left no watcher: $(cat "$home/state/.watch-cycle-exits.log")"`, and the timed-out agent's comment is cut to two lines saying the owner replaces the stopped arm within its poll, with no date. Nothing else changed (diff: 4 insertions, 2 deletions in that one file). Verification: ran the four hand-back tests (lost boundary, lost pass-through, acknowledged at the turn, retry respects receiving pane) via a temporary reduced copy three times, all passed with exit 0 each time; shellcheck -x on the test file passes. A full-file run and an 8-iteration reproduction loop with the original one-shot assertion were started but stopped before completing when the structured result was demanded; the three repro iterations that finished passed locally, so the race was not reproduced on this host (it depends on the owner poll timing CI hit). Temporary copies were removed; the worktree contains only the one modified test file, uncommitted
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @tiago-peixoto, that fix is exactly what was needed.

New head 1c1ba67f is the one-file test change from 58f75eec: wait_until 150 watcher_live instead of a one-shot read, because the owner replaces the stopped arm within its one-second poll. In CI run 40122643348, Behavior portable serial 1 now passes all six hand-back cases, including "an acknowledged hand-back at the turn keeps its pass-through row". The job then hit the shard's 30-minute cap and was cancelled near the end of the suite. That cap-cancel comes from main and isn't caused by your change (our own #7706 is splitting that suite), so I've rerun the failed job. The other 18 checks are green, the no-mistakes attestation is bound to this head, and GitHub reports it CLEAN.

Thanks also for saying plainly in the body that the two lost-continuation scenarios weren't driven against a live Claude primary. The four live Claude scenarios plus the suite are enough for an opt-in path, so I'm not asking for more.

Contract-class (mine): opt-in, unchanged. The gate, state files and unconfigured path are the same as at 58f75eec. VISION.md: unchanged from my last note. Delegation with a spine now aligns, since the hand-back's own test is green.

Status: waiting on CI. Nothing is needed from you. If the serial 1 rerun comes back green and it's still CLEAN, I'll squash-merge it on a later pass.

@kunchenguid
kunchenguid merged commit 3c1e468 into kunchenguid:main Oct 25, 2026
37 of 38 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

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

The serial 1 rerun came back green, so all 19 checks pass on 1c1ba67f. The no-mistakes attestation is bound to that head. I also ran your supervision-host hand-back cases locally on top of the latest main, and they pass. It's squash-merged as 3c1e4684.

cursor Bot pushed a commit that referenced this pull request Oct 25, 2026
Port #7731's acknowledged hand-back tests into the split host suites,
keep the combined host test file deleted, and add estimated CI cost
of the four new tests to the serial duration hints.

Co-authored-by: Kun Chen <[email protected]>
cursor Bot pushed a commit that referenced this pull request Oct 25, 2026
Replace the host-a/b share-of-sample hints with timing-artifact
duration_ms, cap watch-triage at the packing budget so it occupies its
own shard, refresh previously unhinted and understated companions from
the same CI artifacts, and restore the four #7731 registrations to
main's relative order.

Co-authored-by: Kun Chen <[email protected]>
prishsu0730 pushed a commit to prishsu0730/firstmate that referenced this pull request Oct 29, 2026
…chenguid#7731)

* fix(supervision): acknowledge opt-in host hand-backs

When the attended supervision host hands responsibility back to the main
conversation, at the park boundary or on a main-only pass-through, it left
no watcher that outlived a lost continuation, so a home could stay
unsupervised with no alarm.

With config/supervision-handoff-ack present, a Claude host hand-back now
queues a token-bound check and starts a verified, home-scoped successor
(bin/fm-supervision-handoff.sh). The successor keeps replacing closed
watcher cycles and raises the hand-back again until the main conversation
acknowledges it through the sequence-bound wake drain. Automatic retry
delivery needs a verified tmux pane; other terminals keep watching and wait
for a normal turn.

The behavior is off unless the flag exists, so the default hand-back paths
are unchanged.

* no-mistakes(test): log host rows before the acknowledged hand-back

* no-mistakes(document): document acknowledged hand-back flag, state files, retry knob

* no-mistakes(ci): Fixed the test race in tests/fm-supervision-host.test.sh (test_acknowledged_handoff_at_the_turn_keeps_the_pass_through_row), the only failure in "Behavior portable serial 1". Invariant: after an acknowledged hand-back at the turn, a live watcher must exist, but the owner replaces the stopped successor arm only within its one-second poll, so a one-shot watcher_live read at the hand-back instant can observe the gap. The sibling lost-continuation cases already wait for the owner's replacement, so this was the one remaining one-shot site on the hand-back path. Change, per the user's instruction: the assertion is now `wait_until 150 watcher_live "$home" || fail "ack turns-main-only: the hand-back left no watcher: $(cat "$home/state/.watch-cycle-exits.log")"`, and the timed-out agent's comment is cut to two lines saying the owner replaces the stopped arm within its poll, with no date. Nothing else changed (diff: 4 insertions, 2 deletions in that one file). Verification: ran the four hand-back tests (lost boundary, lost pass-through, acknowledged at the turn, retry respects receiving pane) via a temporary reduced copy three times, all passed with exit 0 each time; shellcheck -x on the test file passes. A full-file run and an 8-iteration reproduction loop with the original one-shot assertion were started but stopped before completing when the structured result was demanded; the three repro iterations that finished passed locally, so the race was not reproduced on this host (it depends on the owner poll timing CI hit). Temporary copies were removed; the worktree contains only the one modified test file, uncommitted

(cherry picked from commit 3c1e468)
prishsu0730 pushed a commit to prishsu0730/firstmate that referenced this pull request Oct 29, 2026
…chenguid#7731)

* fix(supervision): acknowledge opt-in host hand-backs

When the attended supervision host hands responsibility back to the main
conversation, at the park boundary or on a main-only pass-through, it left
no watcher that outlived a lost continuation, so a home could stay
unsupervised with no alarm.

With config/supervision-handoff-ack present, a Claude host hand-back now
queues a token-bound check and starts a verified, home-scoped successor
(bin/fm-supervision-handoff.sh). The successor keeps replacing closed
watcher cycles and raises the hand-back again until the main conversation
acknowledges it through the sequence-bound wake drain. Automatic retry
delivery needs a verified tmux pane; other terminals keep watching and wait
for a normal turn.

The behavior is off unless the flag exists, so the default hand-back paths
are unchanged.

* no-mistakes(test): log host rows before the acknowledged hand-back

* no-mistakes(document): document acknowledged hand-back flag, state files, retry knob

* no-mistakes(ci): Fixed the test race in tests/fm-supervision-host.test.sh (test_acknowledged_handoff_at_the_turn_keeps_the_pass_through_row), the only failure in "Behavior portable serial 1". Invariant: after an acknowledged hand-back at the turn, a live watcher must exist, but the owner replaces the stopped successor arm only within its one-second poll, so a one-shot watcher_live read at the hand-back instant can observe the gap. The sibling lost-continuation cases already wait for the owner's replacement, so this was the one remaining one-shot site on the hand-back path. Change, per the user's instruction: the assertion is now `wait_until 150 watcher_live "$home" || fail "ack turns-main-only: the hand-back left no watcher: $(cat "$home/state/.watch-cycle-exits.log")"`, and the timed-out agent's comment is cut to two lines saying the owner replaces the stopped arm within its poll, with no date. Nothing else changed (diff: 4 insertions, 2 deletions in that one file). Verification: ran the four hand-back tests (lost boundary, lost pass-through, acknowledged at the turn, retry respects receiving pane) via a temporary reduced copy three times, all passed with exit 0 each time; shellcheck -x on the test file passes. A full-file run and an 8-iteration reproduction loop with the original one-shot assertion were started but stopped before completing when the structured result was demanded; the three repro iterations that finished passed locally, so the race was not reproduced on this host (it depends on the owner poll timing CI hit). Temporary copies were removed; the worktree contains only the one modified test file, uncommitted

(cherry picked from commit 3c1e468)
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.

Supervision host: a hand-back stops every watcher before main takes over, so a lost continuation leaves the home unsupervised

2 participants