Repository navigation
fix(bin): keep a take-over following a watcher whose TERM lands late - #6916
arthurcruzd wants to merge 1 commit into
Conversation
A supervision-host take-over stopped the left successor's watcher and waited only five seconds for it to exit. A shell that holds the TERM past that wait (stock macOS bash 3.2 holds it until a running command substitution exits, such as the watcher's Herdr event wait) let the take-over fall back to a plain attach. The watcher then died of that TERM, published downtime over main's acknowledged episode with no handover restore, the attached arm found no successor and failed, and the owner's fresh cycle resurfaced an empty check: rearm-resurface on every turn end. The take-over now keeps following the stopped cycle until it exits or its beacon reaches the stall bound, then applies the existing handover restore. A watcher that dies of anything else still leaves downtime that resurfaces.
|
Speaking as Kun's firstmate (OSS triage, not the captain). Thanks @arthurcruzd. Head Contract-class: restore. Main's VISION.md: One captain / Authority / Scripts / Restart / Delegation / Vendor / Scope: all align (watcher continuity only). Security: no workflows/secrets/network. Approved: |
Sync the fleet branch with kunchenguid/firstmate main at 45dd50a. Remote convergence and re-read handling (bootstrap, config push, remote inheritance push, the nudge library, and their tests) take main's kunchenguid#7394 version; the fleet's t3code-instances inherited item stays in the inheritable config list. The fleet's native T3 interrupt, exit, and relaunch paths are kept alongside main's polytoken additions, and the fleet's carried change from kunchenguid#6916 merged without conflict.
Bring the fork's fleet branch up to upstream main, keeping the fleet-only work upstream has not merged. Upstream's explicit-only T3 Code backend (kunchenguid#7518) is the base for every T3 file; the fleet's earlier copy of that PR is superseded by it, along with its own semantic-supervision push (upstream's pending-request watch), the T3 capture, telemetry, interrupt-verdict, and launch-ownership fixes, and the Claude env-channel ownership (upstream's FM_T3CODE_ENV_KEYS). On top of it the fleet keeps: the T3-hosted primary and its wake relay (bin/fm-t3-host.sh), remote second mates on a host's T3 server, quiet and away mode and the supervision host under the relay, Grok and Muse T3 workers, exit by archive with a relaunch that resumes the same thread, restart reconciliation, the foreign-slot refusal, local-interface telemetry, and the T3 0.1.2 standard-scope sign-in. Also kept: the open contributions for supervisor noise (kunchenguid#7726), one launch-failed wake per outage (kunchenguid#7386), status-file birth times (kunchenguid#7384), the take-over watcher TERM fix (kunchenguid#6916), and the fleet-only second-mate reply-source and CI commits.
Intent
Fix the Firstmate bug behind the supervision wake loop seen on a secondmate home on 2026-10-08, so the supervision host can be turned back on.
Context (from the affected home's report, copied in full to data/fm-host-takeover-resurface/mac-loop-report.md in the firstmate home): with the supervision host on, every turn end of that home's Claude session produced a new empty
check: rearm-resurfacewake that the host passed back to main, so each handled wake ended a turn that produced the next one, indefinitely (one model turn per loop, roughly every 25 seconds). Code at 19fcbbd, which already includes 3c58ec8 (#6787). Observed sequence: a watcher deliverscheck: rearm-resurface; the host passes it through and leaves a successor arm in its own process group; at the next turn end a new host logstake-over arm=<pid>; the taken-over watcher then exitssignal=TERM reason=signal-exit, and the taking arm's ledger row isorigin=attached ... reason=attached-cycle-ended(in a later repeat,reason=taken-over), so the handover restore intake_over_cycle(bin/fm-watch-arm.sh) appears not to run or to run without effect;.watcher-downis left as downtime (announced:handling:<gen>, lateracked:handling:<gen>), and the next fresh cycle immediately resurfacescheck: rearm-resurfacewithin 1-2 s. Two sibling homes on the same machine and code were not looping. The loop began within about two minutes of a live Herdr server handoff on that machine (herdr --remote <host> --session fm-remote --handoff), which may be the initiating trigger. The interim mitigation isconfig/supervision-host-offset fleet-wide.What Changed
--take-overno longer abandons a watcher that outlives the five-second TERM wait: it follows that cycle as an attached arm until the watcher exits or its beacon hits the stall bound, then applies the existing handover restore instead of leaving downtime.check: rearm-resurface.Risk Assessment
✅ Low: Well-bounded take-over wait so a late TERM still runs handover restore, with a behavioral regression covering both the quiet restore and a genuine outage.
Testing
Drove the real watch-arm take-over path in disposable marked lab homes: a watcher that held TERM past the five-second wait was followed, its acknowledged handling episode was restored (same
.watcher-downgeneration, ledgerreason=taken-overwith a started successor, no emptycheck: rearm-resurface), a held watcher killed by SIGKILL still resurfaced recovery, and a prompt TERM take-over stayed quiet. The matching take-over regressions in fm-watch-arm.test.sh also passed.Evidence: Live take-over transcript (stdout, watcher-down, cycle ledger)
Source: Live take-over transcript (stdout, watcher-down, cycle ledger)
Evidence: Live scenario results
Source: Live scenario results
PASS late-term-restore: followed held TERM, restored acked episode, no rearm-resurface; down=acked:handling:3982759.1791505590.QSvJ8N PASS late-term-genuine-outage: genuine outage (KILL while held) resurfaced as check: rearm-resurface PASS prompt-term-restore: prompt TERM restored acked episode, no rearm-resurface; down=acked:handling:3992515.1791505615.xKZC6AEvidence: Late-TERM take-over stdout (attached then started, no rearm-resurface)
Source: Late-TERM take-over stdout (attached then started, no rearm-resurface)
watcher: attached pid=3982206 (beacon 7s) watcher: started pid=3986537 (beacon fresh)Evidence: Genuine-outage take-over stdout (check: rearm-resurface)
Source: Genuine-outage take-over stdout (check: rearm-resurface)
watcher: attached pid=3988066 (beacon 7s) watcher: started pid=3991191 (beacon fresh) check: rearm-resurfacePipeline
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.
Livebin/fm-watch-arm.sh --take-overin markedbin/fm-lab-home.shhomes with SIGSTOP holding TERM past the five-second wait, then SIGCONT so the pending TERM landsAdversarial live take-over of a held watcher killed with SIGKILL, expectingcheck: rearm-resurfaceLive prompt-TERM--take-overof an acknowledged episode staying quiet on the same acked generationFocused take-over cases fromtests/fm-watch-arm.test.sh:test_take_over_owns_a_fresh_cycle_and_keeps_queued_work_surfacing,test_take_over_preserves_downtime_from_watcher_self_exit,test_take_over_restores_a_stop_whose_term_lands_late✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.