Skip to content

fix: keep Claude watcher owned until handling starts - #71

Merged
peterOC26 merged 16 commits into
mainfrom
fm/fm-claude-rewake-owner-fix-f1
Nov 19, 2026
Merged

peterOC26 merged 16 commits into
mainfrom
fm/fm-claude-rewake-owner-fix-f1

Conversation

@peterOC26

@peterOC26 peterOC26 commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Intent

Q2244 ALL (2026-11-18, main chat): "q2244 all. feel free to do whatever you think is the good idea amd is safe" - use the Claude allowance before its reset on three Claude-only jobs.
This job is part of option C: build this held Firstmate fix now, with Claude writing the code.
A Claude rewake idle gap: when Claude's requested follow-up turn never starts, supervision can go idle for hours. The 2026-10-31 investigation found that gap still reproduces. A recorded rewake only proves a follow-up was requested; it does not prove the follow-up turn started. If that turn never starts, the watcher can exit and leave queued work with nobody watching for hours.

Keep a watcher owner until there is a generation-bound receipt that handling actually started, rather than treating the rewake request as that receipt. The owner has to keep or replace the watcher across later closes while that receipt is absent, including when a session parks or a hand-back fails, because those paths can leave no watcher at all. One extra watcher that exits on the next close is not enough. Retry in a bounded way when the follow-up turn is missing. Do not invent a vendor scheduling fix from the lost historical trace. Keep the already-shipped successor-before-rewake correction; do not recreate it.

Make the health check stricter: require observed handling before treating a long idle stretch as a healthy long turn, and record a failed successor as failed continuity even when a rewake was requested.

The regression should withhold the handling turn, send a second decision, and require the watcher to stay owned without another turn ending. Keep the case where the next turn does start as a control, and cover the park boundary and a failed successor.

Later captain word: "q2252 y". That choice skips this pipeline's own test step for this pull request and relies on GitHub CI.

What Changed

  • Add a detached Claude continuation owner for host hand-backs and auto-arm rewakes. It replaces closed watcher cycles and retries guarded delivery until main starts handling the matching generation, or acknowledges in opt-in ack mode.
  • Tighten stale-rewake health checks to require observed handling or a fresh epoch, and record failed continuity when a successor cannot be verified.
  • Update documentation and regression coverage for withheld follow-up turns, later closes, park boundaries, handling-start controls, and failed successors.

Risk Assessment

⚠️ Medium: The change reworks watcher-continuity ownership across the Claude Stop hook, the supervision host, the drain, and the guard. The new owner/receipt state machine looks correct for the intended sequences, but its many concurrent processes and timing-sensitive paths warrant CI confirmation before merge.

Testing

  • ⏭️ Test - skipped

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ bin/fm-supervision-host.sh:809 - continuation_handback now runs for every Claude hand-back, including the default handling mode where config/supervision-handoff-ack is absent. Sequence: the opt-in is off, the handling owner fails to start (for example, the main session identity cannot be read), and leave_successor_for_main also fails. Main's rewake then carries 'supervision-host: the acknowledged hand-back successor could not be verified', which wrongly tells main that an acknowledged hand-back was configured and is pending. Choose the line by $mode: keep this one for ack, and use a neutral 'the hand-back continuation successor could not be verified' for handling. tests/fm-supervision-host-hook.test.sh:65/80/101 assert on the current string; keep the ack-mode assertion and adjust any assertion that covers handling mode.
⏭️ **Test** - skipped

Step was skipped.

✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

A Claude rewake only requests the handling turn. The mid-turn health
predicate accepted any rewake bound to the live session and recovery
generation with no age bound, so a continuation that never started read
as healthy indefinitely. Long-turn tolerance now requires the recovery
marker to show handling, or the rewake to still be inside grace.

With acknowledged hand-backs on, the away return on a captain inbox note
now goes through the same acknowledged owner as every other host
hand-back instead of resting on one successor cycle.
… handling receipt, stale-beacon failure case, and unverified host successor. The focused ancestry, auto-arm, host, and host-park tests pass; `bin/fm-lint.sh` and `git diff --check` pass. CI-3 remains tied to the same-generation receipt case explicitly declined in this run, CI-4 is an unrelated timeout in the unmodified remote lifecycle test, and Full suite aggregates lane failures
…k marker failures

Code:
- A handling-mode continuation owner exits once main has begun handling a
  generation it followed, instead of re-reading the marker and reviving on a
  later downtime episode (for example one an explicit stop opens), which
  raced fresh arms for the watcher lock.
- A Claude hand-back whose downtime republication fails now logs
  pass-through downtime-unrestored, as the main-only path did before the
  continuation owner took over that path.

Fixtures (both encoded the old idle gap, where no watcher survived a
hand-back):
- park_again treated a live watcher as proof the next park started; the
  continuation owner now leaves one live between parks, so it also waits for
  the park's own output.
- The stream case stopped the hand-back's watcher and expected a fresh arm's
  watcher to stay up; that stop now opens a downtime episode, so main handles
  it before the orphan arm starts.
The gated-actionable arm fixture replaced the shared fixture header, so the
handling successor now started by fm-supervision-handoff.sh ran the gated
foreground body and never reported a healthy watcher. Append to the shared
header instead and count the two foreground arms and the one successor
separately; product behaviour is unchanged.
@peterOC26 peterOC26 changed the title fix: preserve Claude watcher continuity through hand-backs fix: retain Claude watcher coverage until handling starts Nov 19, 2026
Keep the fixture successor alive until handling is observed instead of repeating the old immediate-exit arm behavior. Give each phase its own generation and retire its watcher before testing the next session's identity. Add the missing ShellCheck source directive for the engine library.
@peterOC26 peterOC26 changed the title fix: retain Claude watcher coverage until handling starts fix: keep Claude watcher owned until handling starts Nov 19, 2026
@peterOC26
peterOC26 merged commit 8f409be into main Nov 19, 2026
55 of 60 checks passed
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