Repository navigation
fix: resurface queued wakes from handling successors - #7466
Conversation
|
Speaking as Kun's firstmate: thanks @calebl — this is a careful fix for a real gap (main-only rows, like a captain inbox note, sitting in the durable queue while the supervision host is parked on a handled wake's successor). I reviewed the diff (bin/fm-supervision-host.sh, bin/fm-wake-lib.sh, bin/fm-watch.sh, docs, tests; no workflow or CI-script changes) and approved the first-time-contributor CI and no-mistakes workflow runs for head Status: waiting on CI for this head. Nothing needed from you right now unless CI comes back red. Note that #7467 (supervision-host test fixtures) just landed on main and touches tests/fm-supervision-host.test.sh too, so if CI or mergeability flags a conflict, a rebase onto latest main would be the fix. |
|
Speaking as Kun's firstmate: thanks @calebl. CI on My contract-class verdict is unchanged: restore. Rows queued for main reach main again, which is the default promise the handling-successor path was breaking. Next step: we're waiting on CI only. Nothing is needed from you. If CI and no-mistakes come back green and the PR is still mergeable against latest main, I'll merge it. |
|
Speaking as Kun's firstmate (triage pass) — re-check at head Thanks @calebl. CI on I reviewed what changed in Contract-class: restore (unchanged): rows queued for main reach main again on the handling-successor path, which is the existing default promise. Waiting on CI only. Nothing is needed from you. If CI and no-mistakes come back green and the PR is still cleanly mergeable against latest main, it gets merged. |
34b6ff6 to
573b92b
Compare
|
Speaking as Kun's firstmate: thanks @calebl for re-raising this through no-mistakes on current main. What I checked (head Fork CI approved for this head: CI Contract-class: restore (my own read, unchanged). Main's VISION.md: One captain aligns (a captain inbox note no longer sits silently) · Authority aligns · Scripts aligns (exact lock-guarded state transition) · Restart aligns (obligations are closed by the durable queue, which is the point of the fix) · Delegation aligns (regression fixtures) · Vendor aligns · Scope aligns. One thing I'd ask of you, when you have a moment: live validation on this head is 0 of 3. All three rows are deterministic fixtures with a stubbed engine and fake tmux, which is good coverage but not the product running. Could you post a short trace from a real supervision host? Ideally it shows a main-only row (an inbox note works) appended while the host is parked on a handled wake's successor, and main waking to drain it. Re-raising through no-mistakes with live rows works just as well. Once that's in and CI is green, this can take the merge path. |
|
Live trace from a real supervision host on head 573b92bb, as requested. Setup: an isolated lab copy of this branch opted into the supervision host, a real interactive Claude Code 2.1.306 primary (haiku) sitting idle at its prompt with the tracked Stop hook, and the default Claude print-mode engine. The only inputs after the primary's setup prompt are the two appends below. So the main-only inbox row appended while the host was parked on the handled wake's successor closed that successor about a second later, passed through the host as main-only, and woke the idle primary, which drained and acknowledged it; about 3 seconds from the note to the rewake. |
|
Speaking as Kun's firstmate: thank you @calebl. That live trace is exactly what I asked for. A main-only inbox row appended while the host was parked on the handled wake's successor closed that successor, passed through as main-only, and woke the idle primary, which drained and acknowledged it. I'm counting live validation as done. One real blocker in CI, and it looks like it comes from this branch rather than a flake.
On other branches that same test passes in about 10 seconds. For example, on #7607's run Waiting on you: could you run Contract-class: restore (my own read, unchanged). Main's Once serial 2 completes green on a head with a matching no-mistakes attestation, this can take the merge path. |
573b92b to
50fe57f
Compare
|
Thanks for pinning the "Behavior portable serial 2" hang to Cause. After a handled engine turn the host now settles the successor handoff under the wake-queue and recovery-marker locks. That test stops the session the moment the host logs Second defect behind it. With the hang gone, Fix (50fe57f, rebased on current main).
Regression. One known edge left as a follow-up: between a handling successor's final queue check and its recovery wake, a concurrent main drain could consume the row, costing one empty recovery turn (never a lost wake). CI on 50fe57f needs workflow approval to run. |
|
Speaking as Kun's firstmate: thank you @calebl. That's a clear diagnosis. A TERM landing inside the handled-turn settle left the host's own queue lock blocking its grant release, and behind that the at-turn main-only hand-back was re-announcing its own close. Fixing both in the host's I read head contract-class: restore (my own read, unchanged): main's Nothing is waiting on you now. If serial 2 finishes and the run is green on this head, it can take the merge path. |
The supervision host parks on the handling successor it starts for a wake its engine handled, and a handling successor never resurfaced recovery, so a row another script appended during the park (a captain inbox note from the Basecamp integration) sat queued until an unrelated close - four hours in the observed case. A handling successor now records the newest queued sequence at its start and closes once with the recovery wake while a newer row is still queued; a newer row already consumed only advances that mark, so the predecessor's delivered episode is still never re-announced. Follow-ups, not built here: - A row appended in the short window between a handled close and its successor's start (about a second) is below the successor's mark; if the engine handles that close without claiming the row, the row waits for the next close. Closing that window needs the host to treat rows left queued after a handled attended turn as main's, which is a separate host change. - After a machine reboot the primary session does not restart on its own, so queued wakes wait until it is resumed by hand. Either auto-resume the primary session after boot, or alert the owner when the primary session is down while wakes are queued.
…t by extending the auto-relaunch watcher deadline from ~30 to ~60 seconds. The CI runner exceeded the old deadline by about 3 seconds; the changed production branch was not reachable in this fixture. `bash -n` and `git diff --check` pass. The full test was attempted but exceeded the 600-second local execution limit before reaching this case
…rying only documented session-lock contention after both competitors finish. Cleanup now handles fixture-owned read-only hooks. Targeted E2E passed; bash syntax and diff checks passed. Shellcheck reported only existing SC1091 source-following notices
…ded-back closes Two defects in this branch's handling-successor changes surfaced as the "Behavior portable serial 2" shard hanging at its 30-minute limit. A TERM that lands while the host settles a handled turn's successor handoff left the host holding the wake-queue and recovery-marker locks; its exit cleanup then waited forever on the queue lock it still owned. The cleanup now releases those locks if this process owns them before releasing its grant. When an accepted close turns main-only at its turn, the host hands it back and leaves the successor running, but republished the episode as pending downtime, so that successor re-announced the same close and exited. The handback now republishes the episode as already announced; a later durable append still opens a pending episode the successor recovers.
50fe57f to
e898e1f
Compare
|
Speaking as Kun's firstmate: thanks @calebl for the follow-up push. I read what changed since the head I last reviewed ( Contract-class: restore (my own read, unchanged): main's Nothing is waiting on you. We're waiting on CI only; if it comes back green and the PR is still cleanly mergeable, it takes the merge path. |
|
Speaking as Kun's firstmate: this is merged. Thank you @calebl — really appreciate you taking the time on this. Rows queued while the host sits parked on a handled wake's successor now reliably make it back to main. |
What Changed
Risk Assessment
✅ Low: The concurrency fix is narrowly scoped, preserves the documented handoff invariants, and includes behavioral regression coverage for startup, parked-successor, handback, and termination paths.
Testing
The two authorized deterministic supervision-host cases passed, confirming inherited-handling restoration and restore-failure delivery after the tab-delimited logging correction. Per the recorded maintainer decision, no additional live primary-session validation was attempted, so the accepted live verdict remains inconclusive.
Evidence: Focused supervision-host settlement regression transcript
Source: Focused supervision-host settlement regression transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found ✅
bin/fm-watch.sh:3347- The post-arm confirmation still releases the queue lock at bin/fm-watch.sh:3159 beforewakeat bin/fm-watch.sh:3348. A concurrently active main turn can drain the detected row in that interval, after the arm check has marked the episode announced, producing an empty synthetic recovery turn without error. This contradicts the “only while that row is still queued” contract at docs/watcher-continuity.md:200; the regression at tests/fm-watch-recovery-loop.test.sh:301 keeps the row queued and does not exercise the concurrent drain. Make the final queue-presence decision and recovery-wake commitment atomic against drains, with cleanup safely releasing any held queue lock.✅ No issues found.
FM_TEST_EVIDENCE=1 timeout 130 tests/fm-watch-recovery-loop.test.shFocused execution oftest_claude_stop_hook_rewakes_main_for_an_inbox_note_after_a_handled_wakefromtests/fm-supervision-host.test.shLive validation:⚠️ inconclusive - 0 of 3 scenarios driven live against the product
FM_TEST_EVIDENCE=1 timeout 130s bash tests/fm-watch-recovery-loop.test.shFocused execution oftest_claude_stop_hook_rewakes_main_for_an_inbox_note_after_a_handled_wakefromtests/fm-supervision-host.test.sh🔧 Fix applied.
1 warning still open:
bash tests/fm-supervision-host.test.shbash tests/fm-watch-recovery-loop.test.shbash tests/fm-claude-stop-autoarm.test.shbash tests/fm-wake-queue.test.shbash tests/fm-watch-arm.test.shInspected the target diff and verifiedgit status --shortwas clean after testing.🔧 Fix applied.
1 warning still open:
Generated and ran a focused copy oftests/fm-supervision-host.test.shinvokingtest_main_only_close_after_handled_turn_restores_inherited_handlingandtest_main_only_close_after_handled_turn_delivers_restore_failure.✅ **Document** - passed
✅ No issues found.
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
✅ No issues found.