Repository navigation
fix(bin): restore downtime on host pass-through and add an idle-session wake backstop - #10
Merged
Merged
Conversation
…on wake backstop On 2026-10-23 a main-only close queued during a host engine turn reached the Claude Stop hook with the recovery marker in handling (the engine's own drain had begun handling on the shared generation), so the hook refused the rewake and exited 0 beside the healthy successor the pass-through left. Nothing else could wake the idle primary, and it stayed unsupervised for 197 minutes. - fm-supervision-host.sh: every attended pass-through republishes downtime before printing the close; a failed republication leaves no successor and exits 1, so the hook's lost-hand-back path delivers a failure notice. - fm-wake-backstop.sh: a detached, home-scoped loop per Claude primary session, ensured at session start and every owned Stop. When the oldest durable wake has waited past FM_WAKE_BACKSTOP_SECS with no open Stop-hook claim, it rings the idle primary's pane once with a record-backed watcher doorbell through the away daemon's guards. It never starts or stops a watcher and is inert in secondmate homes and under away or quiet mode. - fm-host-mirror.sh: a live record-backed doorbell is machinery, not captain dialog. - Tests replay the incident state and the drain race; docs describe the backstop and the cause.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Figure out what died in firstmate so that the primary firstmate lost several hours, and make sure it cannot happen silently again.
Context: on 2026-10-23 at 02:38:04 local (00:38:04Z) the primary firstmate session (Claude, pid 85903, home ~/code/firstmate-rex) ended a turn. Its three Stop hooks started (fm-turnend-guard.sh, fm-claude-stop-autoarm.sh asyncRewake, fm-host-mirror.sh). The supervision host handled one wake and at 02:39:10 passed a further wake (check: inactive-outcome for a finished worker) through to main. That wake should have reached the primary through the autoarm hook's exit-2 rewake. It never did: the session stayed idle for 197 minutes (transcript gap 00:38:04Z to 03:55:21Z) until the captain typed 'What's up? Are you stuck?'. During that time the workers kept running and merged PRs, but nothing was supervised. Hundreds of earlier rewakes the same day worked. Evidence in the firstmate workspace, state/: .supervision-host.log (last line 1792715950 'pass-through attended main-only check: inactive-outcome'), .claude-autoarm-epoch (epoch=216 owner_pid=9021 outcome=arming updated_at=1792715884, never finalised; pid 9021, host pid 9713 and the left arm pid 91245 are all dead), .supervision-host-left (02:39:10 bash fm-watch-arm.sh), .last-watcher-beat (stale since about 02:40), .guard-watcher-stale-banner, plus the Claude session transcript ~/.claude/projects/-Users-roderik-code-firstmate-rex/1302ae45-9d44-4c67-ae51-b33d4eb0b61b.jsonl (stop_hook_summary at 00:38:04.119Z, then nothing). The session's own commands afterwards printed 'WATCHER DOWN' banners, but only when it ran a command; an idle session never sees them.
What Changed
bin/fm-wake-backstop.sh(ensure/check/stop/run), a per-home loop independent of Stop hooks. When the oldest durable wake has waited pastFM_WAKE_BACKSTOP_SECSwith no open Stop-hook claim, it rings the primary's pane with a record-backed doorbell. It does this only after two consecutive passes see the same stranded wake, and only if the pane is idle with an empty composer. It recordsstate/.wake-backstop-alarmwhen no pane was found.bin/fm-session-start.shandbin/fm-claude-stop-autoarm.shnow start it.bin/fm-host-mirror.shdrops these doorbells from the dialog mirror.bin/fm-supervision-host.shnow republishes thedowntimerecovery marker before it prints a pass-through close. Previously an engine turn's drain could move the marker tohandling, so the re-arm owner skipped delivering the close to main. A failed republication stops the successor and exits 1 so the owner takes its lost-hand-back path.tests/fm-wake-backstop.test.shand extended the supervision-host, autoarm and host-mirror tests andtests/lib.sh. Updateddocs/watcher-continuity.md,docs/supervision-host.md,docs/turnend-guard.mdanddocs/scripts.md.Risk Assessment
Testing
I ran the four test files this change touches. The wake-backstop tests replay the incident state, ring the idle primary once, change no supervision state, and stay inert in away mode and secondmate homes. The supervision-host tests cover the pass-through that restores downtime and the failed-republish case that sends a failure notice. The autoarm and host-mirror tests passed. The wake-backstop run's output was cut at its last visible line, so I did not see whether its remaining tests passed. The supervision-host suite is slow: the first run was killed by my 550-second timeout and the rerun by its time limit, so its last tests did not run. I did not stand up a real Claude primary in a disposable lab, so nothing was driven against the live product.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-wake-backstop.test.sh(the first nine tests, up to pane delivery)bash tests/fm-supervision-host.test.sh(45 ok, 0 not ok before the run hit the time limit)bash tests/fm-claude-stop-autoarm.test.sh(all ok)bash tests/fm-host-mirror.test.sh(all ok, exit 0)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Pre-existing environment-only test failure
tests/fm-daemon.test.shcase "bare fallback (no override, no TMUX_PANE, no HERDR_ENV) should return non-zero" fails when the suite runs inside a Rex pane, because the inheritedREX_BLOCK/REX_SESSION/REX_SERVERlet supervisor-pane discovery prove a Rex pane.It fails identically on clean
main(409f886) in the same environment and passes with those variables unset; this PR does not touch that discovery code, and the test is left unchanged.