Skip to content

fix(bin): restore downtime before supervision-host hand-backs - #7428

Open
WTF-Am-ID wants to merge 13 commits into
kunchenguid:mainfrom
WTF-KRP:fm/fm-6704-handback
Open

WTF-Am-ID wants to merge 13 commits into
kunchenguid:mainfrom
WTF-KRP:fm/fm-6704-handback

Conversation

@WTF-Am-ID

@WTF-Am-ID WTF-Am-ID commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Refs #6704

Intent

Offer local commit 32b02383 ("fix(bin): republish watcher downtime on every supervision-host hand-back") upstream as its own PR to https://github.com/kunchenguid/firstmate, referencing issue #6704 and open PR #6588, rather than pushing onto #6588's branch. Approved as a one-task upstream contribution.

Context: issue #6704 reports that the supervision host's attended pass-through hands a wake back to main without republishing watcher downtime, so the Claude Stop hook's rewake commit refuses and the hook exits 0 silently (production gaps of 22 min and 8 h 49 min). The maintainer's triage comment (#6704 (comment)) says #6588 fixes the main-only arm and invites a follow-up PR (after #6588 or as a revision of it) that sends every exit handing main a wake through one function that republishes downtime first, then leaves or detaches the successor. Commit 32b02383 is that change: exit_to_main, the attended pass-through, the turn-start pass-through and the park boundary all go through one hand_back function, with a host+hook regression test.

What Changed

  • Routed exit_to_main, the non-main-only attended pass-through, the turn-start pass-through, and the park boundary through hand_back to restore watcher downtime before returning wakes to main.
  • Restored downtime before detaching a successor, and stopped the successor with a failure message and nonzero exit when restoration failed.
  • Added a host and Stop hook regression for failed branch eligibility after a handled turn, and documented the hand-back publication contract.

This implements the unified hand-back follow-up requested in the triage comment, after the main-only fix in #6588 merged.

Since 6ef7b27

Forward-merged current main, including #7731, without rebasing or force-pushing.
The initial attended main-only path from #6588 keeps its own publication code.
The remaining default paths restore downtime through hand_back.
With config/supervision-handoff-ack present, #7731's acknowledged hand-back still publishes downtime before starting and verifying its detached successor owner.
The turn-start pass-through preserves #7466's announced-downtime hand-back so the retained successor does not repeat the close.

Strengthened test_uncomputable_close_after_handled_turn_restores_inherited_handling to run a real drain after handled-turn settling and before the failed offer returns.
Against upstream 147b2672, it fails with pending:handling and auto-arm outcome=failed; against candidate a614a55d, it passes with downtime restored and outcome=rewake.
Both current hooks exit 2 because upstream now emits a failure notice; the silent exit 0 described in #6704 is the historical incident.

The Test gate was approved with the existing no-live-testing exception.
The pipeline's nine targeted fixtures passed; live Claude delivery remains unverified.

Risk Assessment

✅ Low: The change routes the remaining wake hand-backs through one hand_back function. Every republish I traced (watcher-close downtime, inherited handling, idle and in-turn boundary, publication failure) either keeps the existing downtime generation or performs the intended handling-to-downtime repair. The opt-in acknowledged path and the #6588 main-only path are unchanged.

Testing

Nine targeted fixtures passed with retained hook output and recovery-state evidence. Real Claude validation was blocked before launch. Fixtures were removed and the worktree remains unchanged. No baseline rerun, full suite, lint, or other pipeline phase was executed.

  • Live validation: ⚠️ inconclusive - 0 of 6 scenarios driven live against the product
Scenario Result Live Evidence
S1: A close passes through after an engine turn; main receives it with downtime restored. ⏸️ untested no The real Claude lab launch was refused before execution because its required cleanup used a variable recursive-delete target. An approved lab lifecycle command is needed. No alternate route was attemp…
S2: A wake becomes main-only at turn start; main receives it while the successor watcher remains running. ⏸️ untested no The same command-review refusal prevented launching the real Claude primary. An approved lab lifecycle command is needed; the passing fixture uses a fake parent and engine.
S3: A successor closes or an engine result is incomplete; the host restores downtime and hands the wake to main. ⏸️ untested no The real-primary lab was blocked by command review before launch. An approved lab lifecycle command is needed to verify Claude delivery beyond the passing fixtures.
S4: The park reaches its boundary; the watcher stops and main receives a boundary wake with downtime published. ⏸️ untested no The real-primary lab could not launch under the cleanup guard. An approved lab lifecycle command is needed; the fixture uses an injected clock and fake Claude parent.
S5: Downtime publication fails; the Stop hook delivers a failure notice instead of silently dropping the wake. ⏸️ untested no Command review prevented the real Claude lab launch. An approved lab lifecycle command is needed to verify actual notification delivery; fixture output alone is insufficient.
S6: Opt-in acknowledged hand-back survives a lost continuation, retries delivery, and transfers one watcher after acknowledgement. ⏸️ untested no The cleanup guard blocked the real-primary lab before execution. An approved lab lifecycle command is needed; the passing retry fixture does not exercise real Claude delivery.
Evidence: Focused fixture results and product output

Source: Focused fixture results and product output

Candidate: a614a55d559cd17a77320b6549c73c2403c051f6
Existing fixture selectors, with real host/watcher/Stop-hook scripts and fake Claude parent/engine. Not live Claude validation.
SELECTOR: test_uncomputable_close_after_handled_turn_restores_inherited_handling
ok - host+hook: a pass-through for any reason after a handled turn restores inherited handling and rewakes main

PRODUCT OUTPUT hook-inherited-handling-uncomputable/hook.err
firstmate watcher wake - one supervision event needs a handling turn now.
signal: /private/var/folders/gn/m0fr4_4962q75gpmcl14_z0w0000gn/T/fm-supervision-host.h7PsJA/hook-inherited-handling-uncomputable/state/beta.status
Run bin/fm-wake-drain.sh first, handle the wake, then run its exact WAKE_ACK_REQUIRED --ack-through command. Until that post-handling acknowledgement, interruption leaves the wake durable for idempotent re-handling. This Stop hook owns watcher continuity: when the handling turn ends, the next needed cycle arms automatically - do NOT run bin/fm-watch-arm.sh after an ordinary wake.

PRODUCT OUTPUT hook-inherited-handling-uncomputable/hook.rc
2

PRODUCT OUTPUT hook-inherited-handling-uncomputable/offer-drain-marker
pending:handling:17209.1792936209.WYy11N

PRODUCT OUTPUT hook-inherited-handling-uncomputable/state/.watcher-down
pending:downtime:17209.1792936209.WYy11N

PRODUCT OUTPUT hook-inherited-handling-uncomputable/state/.claude-autoarm-epoch
epoch=1 owner_pid=16234 outcome=rewake updated_at=1792936222 session_pid=16070 recovery_generation=17209.1792936209.WYy11N
Sun Oct 25 09:50:06 2026     bash /private/var/folders/gn/m0fr4_4962q75gpmcl14_z0w0000gn/T/fm-supervision-host.h7PsJA/hook-inherited-handling-uncomputable/bin/fm-claude-stop-autoarm.sh

PRODUCT OUTPUT hook-inherited-handling-uncomputable/state/.supervision-host.log
1792936207	start	gen=host-16402-1792936206	primary=claude
1792936219	handled	turn=host-16402-1792936206.1	posture=attended	rc=0	reports=1	error=0 cost=0.25 conversation_cost=0.25 input=5 cache_read=100 cache_write=10 output=20 turns=3	signal: /private/var/folders/gn/m0fr4_4962q75gpmcl14_z0w0000gn/T/fm-supervision-host.h7PsJA/hook-inherited-handling-uncomputable/state/demo.status
1792936222	pass-through	attended	branch eligibility could not be computed	signal: /private/var/folders/gn/m0fr4_4962q75gpmcl14_z0w0000gn/T/fm-supervision-host.h7PsJA/hook-inherited-handling-uncomputable/state/beta.status
SELECTOR: test_main_only_close_after_handled_turn_restores_inherited_handling
ok - host+hook: a main-only close after a handled turn restores inherited handling and rewakes main

PRODUCT OUTPUT hook-inherited-handling-restore/hook.err
firstmate watcher wake - one supervision event needs a handling turn now.
signal: /private/var/folders/gn/m0fr4_4962q75gpmcl14_z0w0000gn/T/fm-supervision-host.h7PsJA/hook-inherited-handling-restore/state/beta.status
Run bin/fm-wake-drain.sh first, handle the wake, then run its exact WAKE_ACK_REQUIRED --ack-through command. Until that post-handling acknowledgement, interruption leaves the wake durable for idempotent re-handling. This Stop hook owns watcher continuity: when the handling turn ends, the next needed cycle arms automatically - do NOT run bin/fm-watch-arm.sh after an ordinary wake.

PRODUCT OUTPUT hook-inherited-handling-restore/hook.rc
2

PRODUCT OUTPUT hook-inherited-handling-restore/state/.watcher-down
announced:downtime:51387.1792936224.qAtXJY

PRODUCT OUTPUT hook-inherited-handling-restore/state/.claude-autoarm-epoch
epoch=1 owner_pid=50930 outcome=rewake updated_at=1792936231 session_pid=50664 recovery_generation=51387.1792936224.qAtXJY
Sun Oct 25 09:50:23 2026     bash /private/var/folders/gn/m0fr4_4962q75gpmcl14_z0w0000gn/T/fm-supervision-host.h7PsJA/hook-inherited-handling-restore/bin/fm-claude-stop-autoarm.sh

PRODUCT OUTPUT hook-inherited-handling-restore/state/.supervision-host.log
1792936223	start	gen=host-51174-1792936223	primary=claude
1792936230	handled	turn=host-51174-1792936223.1	posture=attended	rc=0	reports=1	error=0 cost=0.25 conversation_cost=0.25 input=5 cache_read=100 cache_write=10 output=20 turns=3	signal: /private/var/folders/gn/m0fr4_4962q75gpmcl14_z0w0000gn/T/fm-supervision-host.h7PsJA/hook-inherited-handling-restore/state/demo.status
1792936230	pass-through	attended	main-only	signal: /private/var/folders/gn/m0fr4_4962q75gpmcl14_z0w0000gn/T/fm-supervision-host.h7PsJA/hook-inherited-handling-restore/state/beta.status
SELECTOR: test_claude_stop_hook_delivers_a_close_that_turns_main_only_at_its_turn
ok - host+hook: a close that turns main-only at its turn rewakes main and keeps its successor watcher

PRODUCT OUTPUT hook-turns-main-only/hook.err
firstmate watcher wake - one supervision event needs a handling turn now.
signal: /private/var/folders/gn/m0fr4_4962q75gpmcl14_z0w0000gn/T/fm-supervision-host.h7PsJA/hook-turns-main-only/state/demo.status
Run bin/fm-wake-drain.sh first, handle the wake, then run its exact WAKE_ACK_REQUIRED --ack-through command. Until that post-handling acknowledgement, interruption leaves the wake durable for idempotent re-handling. This Stop hook owns watcher continuity: when the handling turn ends, the next needed cycle arms automatically - do NOT run bin/fm-watch-arm.sh after an ordinary wake.

PRODUCT OUTPUT hook-turns-main-only/hook.rc
2

PRODUCT OUTPUT hook-turns-main-only/state/.watcher-down
pending:downtime:66152.1792936235.q8jH7X

PRODUCT OUTPUT hook-turns-main-only/state/.claude-autoarm-epoch
epoch=1 owner_pid=62971 outcome=rewake updated_at=1792936235 session_pid=62509 recovery_generation=66152.1792936235.q8jH7X
Sun Oct 25 09:50:32 2026     bash /private/var/folders/gn/m0fr4_4962q75gpmcl14_z0w0000gn/T/fm-supervision-host.h7PsJA/hook-turns-main-only/bin/fm-claude-stop-autoarm.sh

PRODUCT OUTPUT hook-turns-main-only/state/.supervision-host.log
1792936232	start	gen=host-63240-1792936232	primary=claude
1792936235	pass-through	attended	main-only	signal: /private/var/folders/gn/m0fr4_4962q75gpmcl14_z0w0000gn/T/fm-supervision-host.h7PsJA/hook-turns-main-only/state/demo.status
SELECTOR: test_claude_stop_hook_restores_handoff_when_successor_closed_before_exit_to_main
ok - host+hook: a successor closed before exit_to_main does not suppress the branch-outcome rewake

PRODUCT OUTPUT hook-successor-closed-before-return/hook.err
firstmate watcher wake - one supervision event needs a handling turn now.
supervision-host: branch-outcome: the supervision session handled this wake and recorded captain outcomes for you (store rows 1); run bin/fm-wake-drain.sh, act on its BRANCH OUTCOMES section, and acknowledge them as it prints
Run bin/fm-wake-drain.sh first, handle the wake, then run its exact WAKE_ACK_REQUIRED --ack-through command. Until that post-handling acknowledgement, interruption leaves the wake durable for idempotent re-handling. This Stop hook owns watcher continuity: when the handling turn ends, the next needed cycle arms automatically - do NOT run bin/fm-watch-arm.sh after an ordinary wake.

PRODUCT OUTPUT hook-successor-closed-before-return/hook.rc
2

PRODUCT OUTPUT hook-successor-closed-before-return/state/.watcher-down
pending:downtime:73746.1792936241.8COYit

PRODUCT OUTPUT hook-successor-closed-before-return/state/.claude-autoarm-epoch
epoch=1 owner_pid=69229 outcome=rewake updated_at=1792936242 session_pid=68605 recovery_generation=73746.1792936241.8COYit
Sun Oct 25 09:50:36 2026     bash /private/var/folders/gn/m0fr4_4962q75gpmcl14_z0w0000gn/T/fm-supervision-host.h7PsJA/hook-successor-closed-before-return/bin/fm-claude-stop-autoarm.sh

PRODUCT OUTPUT hook-successor-closed-before-return/state/.supervision-host.log
1792936236	start	gen=host-69703-1792936236	primary=claude
1792936242	handled	turn=host-69703-1792936236.1	posture=attended	rc=0	reports=1	error=0 cost=0.25 conversation_cost=0.25 input=5 cache_read=100 cache_write=10 output=20 turns=3	signal: /private/var/folders/gn/m0fr4_4962q75gpmcl14_z0w0000gn/T/fm-supervision-host.h7PsJA/hook-successor-closed-before-return/state/demo.status
1792936242	to-main	branch-outcome: the supervision session handled this wake and recorded captain outcomes for you (store rows 1); run bin/fm-wake-drain.sh, act on its BRANCH OUTCOMES section, and

... [47759 bytes truncated] ...

  printf "{\"session_id\":\"sess-host-hook\",\"stop_hook_active\":false}\n" \
              | "$FM_HOME/bin/fm-claude-stop-autoarm.sh" > "$FM_HOME/hook.out" 2> "$FM_HOME/hook.err"
            printf "%s\n" "$?" > "$FM_HOME/hook.rc"
          fi
        fi
        sleep 0.1
      done
    ' 2>> "$home/claude.err"
bash: line 183: 68605 Terminated: 15          FM_HOME="$home" FM_ROOT_OVERRIDE="$home" FM_CREW_STATE_BIN="$home/fakebin/fm-crew-state.sh" PATH="$home/fakebin:$PATH" "$FAKE_CLAUDE" -c '
      printf "%s\n" "$$" > "$FM_HOME/state/.lock"
      printf "%s\n" "$$" >> "$FM_HOME/claude-pids"
      for seed in "$FM_HOME"/mirror-seed.*; do
        [ -f "$seed" ] || continue
        "$FM_HOME/bin/fm-host-mirror.sh" hook claude < "$seed"
      done
      while [ ! -e "$FM_HOME/session.stop" ] && [ -d "$FM_HOME" ] \
        && kill -0 "$FM_TEST_SUITE_PID" 2>/dev/null; do
        if [ -e "$FM_HOME/stop.go" ]; then
          rm -f "$FM_HOME/stop.go"
          if [ -e "$FM_HOME/hook.own-group" ]; then
            # Claude owns the hook as a process group of its own and tears the
            # whole group down once the hook has exited.
            printf "{\"session_id\":\"sess-host-hook\",\"stop_hook_active\":false}\n" > "$FM_HOME/hook.stdin"
            set -m
            "$FM_HOME/bin/fm-claude-stop-autoarm.sh" < "$FM_HOME/hook.stdin" > "$FM_HOME/hook.out" 2> "$FM_HOME/hook.err" &
            printf "%s\n" "$!" > "$FM_HOME/hook.pgid"
            wait "$!"
            printf "%s\n" "$?" > "$FM_HOME/hook.rc"
            set +m
          else
            printf "{\"session_id\":\"sess-host-hook\",\"stop_hook_active\":false}\n" \
              | "$FM_HOME/bin/fm-claude-stop-autoarm.sh" > "$FM_HOME/hook.out" 2> "$FM_HOME/hook.err"
            printf "%s\n" "$?" > "$FM_HOME/hook.rc"
          fi
        fi
        sleep 0.1
      done
    ' 2>> "$home/claude.err"
bash: line 183: 78403 Terminated: 15          FM_HOME="$home" FM_ROOT_OVERRIDE="$home" FM_CREW_STATE_BIN="$home/fakebin/fm-crew-state.sh" PATH="$home/fakebin:$PATH" "$FAKE_CLAUDE" -c '
      printf "%s\n" "$$" > "$FM_HOME/state/.lock"
      printf "%s\n" "$$" >> "$FM_HOME/claude-pids"
      for seed in "$FM_HOME"/mirror-seed.*; do
        [ -f "$seed" ] || continue
        "$FM_HOME/bin/fm-host-mirror.sh" hook claude < "$seed"
      done
      while [ ! -e "$FM_HOME/session.stop" ] && [ -d "$FM_HOME" ] \
        && kill -0 "$FM_TEST_SUITE_PID" 2>/dev/null; do
        if [ -e "$FM_HOME/stop.go" ]; then
          rm -f "$FM_HOME/stop.go"
          if [ -e "$FM_HOME/hook.own-group" ]; then
            # Claude owns the hook as a process group of its own and tears the
            # whole group down once the hook has exited.
            printf "{\"session_id\":\"sess-host-hook\",\"stop_hook_active\":false}\n" > "$FM_HOME/hook.stdin"
            set -m
            "$FM_HOME/bin/fm-claude-stop-autoarm.sh" < "$FM_HOME/hook.stdin" > "$FM_HOME/hook.out" 2> "$FM_HOME/hook.err" &
            printf "%s\n" "$!" > "$FM_HOME/hook.pgid"
            wait "$!"
            printf "%s\n" "$?" > "$FM_HOME/hook.rc"
            set +m
          else
            printf "{\"session_id\":\"sess-host-hook\",\"stop_hook_active\":false}\n" \
              | "$FM_HOME/bin/fm-claude-stop-autoarm.sh" > "$FM_HOME/hook.out" 2> "$FM_HOME/hook.err"
            printf "%s\n" "$?" > "$FM_HOME/hook.rc"
          fi
        fi
        sleep 0.1
      done
    ' 2>> "$home/claude.err"
bash: line 183: 62509 Terminated: 15          FM_HOME="$home" FM_ROOT_OVERRIDE="$home" FM_CREW_STATE_BIN="$home/fakebin/fm-crew-state.sh" PATH="$home/fakebin:$PATH" "$FAKE_CLAUDE" -c '
      printf "%s\n" "$$" > "$FM_HOME/state/.lock"
      printf "%s\n" "$$" >> "$FM_HOME/claude-pids"
      for seed in "$FM_HOME"/mirror-seed.*; do
        [ -f "$seed" ] || continue
        "$FM_HOME/bin/fm-host-mirror.sh" hook claude < "$seed"
      done
      while [ ! -e "$FM_HOME/session.stop" ] && [ -d "$FM_HOME" ] \
        && kill -0 "$FM_TEST_SUITE_PID" 2>/dev/null; do
        if [ -e "$FM_HOME/stop.go" ]; then
          rm -f "$FM_HOME/stop.go"
          if [ -e "$FM_HOME/hook.own-group" ]; then
            # Claude owns the hook as a process group of its own and tears the
            # whole group down once the hook has exited.
            printf "{\"session_id\":\"sess-host-hook\",\"stop_hook_active\":false}\n" > "$FM_HOME/hook.stdin"
            set -m
            "$FM_HOME/bin/fm-claude-stop-autoarm.sh" < "$FM_HOME/hook.stdin" > "$FM_HOME/hook.out" 2> "$FM_HOME/hook.err" &
            printf "%s\n" "$!" > "$FM_HOME/hook.pgid"
            wait "$!"
            printf "%s\n" "$?" > "$FM_HOME/hook.rc"
            set +m
          else
            printf "{\"session_id\":\"sess-host-hook\",\"stop_hook_active\":false}\n" \
              | "$FM_HOME/bin/fm-claude-stop-autoarm.sh" > "$FM_HOME/hook.out" 2> "$FM_HOME/hook.err"
            printf "%s\n" "$?" > "$FM_HOME/hook.rc"
          fi
        fi
        sleep 0.1
      done
    ' 2>> "$home/claude.err"
bash: line 183: 68605 Terminated: 15          FM_HOME="$home" FM_ROOT_OVERRIDE="$home" FM_CREW_STATE_BIN="$home/fakebin/fm-crew-state.sh" PATH="$home/fakebin:$PATH" "$FAKE_CLAUDE" -c '
      printf "%s\n" "$$" > "$FM_HOME/state/.lock"
      printf "%s\n" "$$" >> "$FM_HOME/claude-pids"
      for seed in "$FM_HOME"/mirror-seed.*; do
        [ -f "$seed" ] || continue
        "$FM_HOME/bin/fm-host-mirror.sh" hook claude < "$seed"
      done
      while [ ! -e "$FM_HOME/session.stop" ] && [ -d "$FM_HOME" ] \
        && kill -0 "$FM_TEST_SUITE_PID" 2>/dev/null; do
        if [ -e "$FM_HOME/stop.go" ]; then
          rm -f "$FM_HOME/stop.go"
          if [ -e "$FM_HOME/hook.own-group" ]; then
            # Claude owns the hook as a process group of its own and tears the
            # whole group down once the hook has exited.
            printf "{\"session_id\":\"sess-host-hook\",\"stop_hook_active\":false}\n" > "$FM_HOME/hook.stdin"
            set -m
            "$FM_HOME/bin/fm-claude-stop-autoarm.sh" < "$FM_HOME/hook.stdin" > "$FM_HOME/hook.out" 2> "$FM_HOME/hook.err" &
            printf "%s\n" "$!" > "$FM_HOME/hook.pgid"
            wait "$!"
            printf "%s\n" "$?" > "$FM_HOME/hook.rc"
            set +m
          else
            printf "{\"session_id\":\"sess-host-hook\",\"stop_hook_active\":false}\n" \
              | "$FM_HOME/bin/fm-claude-stop-autoarm.sh" > "$FM_HOME/hook.out" 2> "$FM_HOME/hook.err"
            printf "%s\n" "$?" > "$FM_HOME/hook.rc"
          fi
        fi
        sleep 0.1
      done
    ' 2>> "$home/claude.err"
bash: line 183: 78403 Terminated: 15          FM_HOME="$home" FM_ROOT_OVERRIDE="$home" FM_CREW_STATE_BIN="$home/fakebin/fm-crew-state.sh" PATH="$home/fakebin:$PATH" "$FAKE_CLAUDE" -c '
      printf "%s\n" "$$" > "$FM_HOME/state/.lock"
      printf "%s\n" "$$" >> "$FM_HOME/claude-pids"
      for seed in "$FM_HOME"/mirror-seed.*; do
        [ -f "$seed" ] || continue
        "$FM_HOME/bin/fm-host-mirror.sh" hook claude < "$seed"
      done
      while [ ! -e "$FM_HOME/session.stop" ] && [ -d "$FM_HOME" ] \
        && kill -0 "$FM_TEST_SUITE_PID" 2>/dev/null; do
        if [ -e "$FM_HOME/stop.go" ]; then
          rm -f "$FM_HOME/stop.go"
          if [ -e "$FM_HOME/hook.own-group" ]; then
            # Claude owns the hook as a process group of its own and tears the
            # whole group down once the hook has exited.
            printf "{\"session_id\":\"sess-host-hook\",\"stop_hook_active\":false}\n" > "$FM_HOME/hook.stdin"
            set -m
            "$FM_HOME/bin/fm-claude-stop-autoarm.sh" < "$FM_HOME/hook.stdin" > "$FM_HOME/hook.out" 2> "$FM_HOME/hook.err" &
            printf "%s\n" "$!" > "$FM_HOME/hook.pgid"
            wait "$!"
            printf "%s\n" "$?" > "$FM_HOME/hook.rc"
            set +m
          else
            printf "{\"session_id\":\"sess-host-hook\",\"stop_hook_active\":false}\n" \
              | "$FM_HOME/bin/fm-claude-stop-autoarm.sh" > "$FM_HOME/hook.out" 2> "$FM_HOME/hook.err"
            printf "%s\n" "$?" > "$FM_HOME/hook.rc"
          fi
        fi
        sleep 0.1
      done
    ' 2>> "$home/claude.err"

Driver exit status: 0
Evidence: Real Claude lab launch refusal

Source: Real Claude lab launch refusal

Candidate: a614a55d559cd17a77320b6549c73c2403c051f6
Real Claude lab launch attempted with bin/fm-lab-home.sh create, a private tmux -L fm-lab server with 120x40 grid, FM_HOME scoped to the disposable lab, and same-turn teardown.
PreToolUse refused the entire command before execution:
BLOCKED: Recursive delete check: rm target '"$LAB"' depends on a variable, command substitution or other expansion, so it cannot be checked
No lab was created, no Claude session launched, and no alternative deletion or launch route was attempted.
This is the previously declined live-lab cleanup refusal, not a new product defect.
- Outcome: ⚠️ 1 warning across 1 run (11m57s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

⏭️ **Rebase** - skipped

Step was skipped.

⚠️ **Review** - 1 info
  • ℹ️ bin/fm-supervision-host.sh:1199 - Simplification: hand_back always exits, so after the new if [ &#34;$ATTENDED_WHY&#34; != main-only ]; then hand_back ...; fi the following if [ &#34;$ATTENDED_WHY&#34; = main-only ] test is always true when reached, and the trailing emit; exit 0 (lines 1211-1212) serves only the main-only path. Fold into a single if/else (main-only -> leave_successor_for_main/emit/exit; else -> hand_back) so the two exits read directly. Non-functional.
⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (0 of 6 scenarios were driven live against the product); untested: S1: A close passes through after an engine turn; main receives it with downtime restored., S2: A wake becomes main-only at turn start; main receives it while the successor watcher remains running., S3: A successor closes or an engine result is incomplete; the host restores downtime and hands the wake to main., S4: The park reaches its boundary; the watcher stops and main receives a boundary wake with downtime published., S5: Downtime publication fails; the Stop hook delivers a failure notice instead of silently dropping the wake., S6: Opt-in acknowledged hand-back survives a lost continuation, retries delivery, and transfers one watcher after acknowledgement.
  • Live validation: ⚠️ inconclusive - 0 of 6 scenarios driven live against the product
Scenario Result Live Evidence
S1: A close passes through after an engine turn; main receives it with downtime restored. ⏸️ untested no The real Claude lab launch was refused before execution because its required cleanup used a variable recursive-delete target. An approved lab lifecycle command is needed. No alternate route was attemp…
S2: A wake becomes main-only at turn start; main receives it while the successor watcher remains running. ⏸️ untested no The same command-review refusal prevented launching the real Claude primary. An approved lab lifecycle command is needed; the passing fixture uses a fake parent and engine.
S3: A successor closes or an engine result is incomplete; the host restores downtime and hands the wake to main. ⏸️ untested no The real-primary lab was blocked by command review before launch. An approved lab lifecycle command is needed to verify Claude delivery beyond the passing fixtures.
S4: The park reaches its boundary; the watcher stops and main receives a boundary wake with downtime published. ⏸️ untested no The real-primary lab could not launch under the cleanup guard. An approved lab lifecycle command is needed; the fixture uses an injected clock and fake Claude parent.
S5: Downtime publication fails; the Stop hook delivers a failure notice instead of silently dropping the wake. ⏸️ untested no Command review prevented the real Claude lab launch. An approved lab lifecycle command is needed to verify actual notification delivery; fixture output alone is insufficient.
S6: Opt-in acknowledged hand-back survives a lost continuation, retries delivery, and transfers one watcher after acknowledgement. ⏸️ untested no The cleanup guard blocked the real-primary lab before execution. An approved lab lifecycle command is needed; the passing retry fixture does not exercise real Claude delivery.
  • In-memory Bash selection from tests/fm-supervision-host.test.sh: test_uncomputable_close_after_handled_turn_restores_inherited_handling, test_main_only_close_after_handled_turn_restores_inherited_handling.
  • Selected test_claude_stop_hook_delivers_a_close_that_turns_main_only_at_its_turn.
  • Selected test_claude_stop_hook_restores_handoff_when_successor_closed_before_exit_to_main, test_claude_stop_hook_restores_handoff_when_successor_closed_mid_engine_turn, test_incomplete_engine_result_hands_the_wake_to_main.
  • Selected test_park_boundary_ends_the_park_before_the_hook_timeout, test_main_only_close_after_handled_turn_delivers_restore_failure, test_lost_boundary_handoff. Combined driver exited 0.
  • Attempted bin/fm-lab-home.sh create with real claude on private tmux -L fm-lab, a 120×40 grid, isolated FM_HOME, and same-turn teardown. Command review refused before execution.
  • Captured hook output, recovery markers, host ledgers, and refusal evidence; confirmed fixture-root removal and unchanged git status --short.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

A Claude primary running the supervision host could sleep for hours with
wakes queued. When a handling successor closed with a main-only wake before
the engine turn's first drain, that branch drain moved the recovery marker
from the downtime the close had published to handling. The routine turn
then parked on the closed successor and passed its close through to main
without republishing downtime, so the Claude Stop hook's rewake commit
refused, the live successor left for main masked the lost-hand-back
fallback, and the hook exited 0.

Every host exit that hands main a wake (exit_to_main, the attended
pass-through, the turn-start pass-through, and the park boundary) now goes
through one hand_back function that republishes downtime first, the same
transition a watcher close makes, and leaves or detaches a successor only
after that succeeds. A failed publication leaves no successor running, so
the hook's existing lost-hand-back notice fires.

The new host+hook regression holds the stub engine before its drain so the
successor's main-only close lands first; it fails on the previous host
(hook exit 0, marker pending:handling) and passes here.
…h. Verified that only those deletions remain, no untracked files remain, and git diff --check passes
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @WTF-Am-ID, both for the #6704 repro and for picking up the single hand-back follow-up so quickly.

Diff reviewed tip d4ab8ff2 vs main 7099556d (3 files; the scratch tests/.fm-6704-* scripts are added and then removed, so they won't survive a squash). The new hand_back republishes downtime and then leaves or detaches the successor. On a failed publish it retires the successor, logs downtime-unrestored, and exits nonzero. It's now used by exit_to_main, the attended pass-through (main-only and not), the turn-start pass-through (HANDLE_RC=2) and boundary_exit. There is no workflow or secret surface, so I approved the first-time fork runs: CI 38965793957 and Require no-mistakes 38965793598 / 38966181986.

Overlap with #6588: yes, these overlap. Both rewrite the same main-only attended pass-through block, so only one can land as-is. #6588 is the narrow restore of that one arm. Its CI is green except the known serial-2 ceiling (#7255), and it is with the captain for a land-despite decision. This PR is the broader shape the #6704 triage suggested. My read: #6588 is the better near-term landing because it's proven and validated. This PR is the better long-term structure, and once #6588 lands it would rebase as the follow-up for the remaining exits. Which one lands is Kun's call.

Contract-class: cannot-tell (my own read). The main-only arm is a restore of a specified, broken path. This PR also changes mechanics on paths I couldn't confirm were broken: boundary_exit now publishes downtime and can exit nonzero, exit_to_main publishes even when no successor generation was recorded (main only does that when one was), and the non-main-only attended pass-through now publishes too. The new test only pins the main-only arm.

VISION.md: one captain aligns (stops silent multi-hour gaps) · authority aligns · scripts aligns (exact republish) · restart aligns (close retired by delivery) · spine aligns (a failure is visible, not silent) · vendor neutral · scope aligns.

What's needed from you (this is waiting on you, not the captain):

  1. Re-raise through no-mistakes. The PR body has no head-bound pipeline attestation, which the Require no-mistakes check needs.
  2. Live validation. The body says it wasn't exercised against a live Claude session. Could you live-test and post the evidence, or let the no-mistakes Test step record it? The most useful scenarios are the Supervision host: attended pass-through can still drop the main rewake when the parked successor already closed #6704 repro on a real session, a park that ends at its bound (boundary_exit) without a spurious main rewake or a nonzero exit, and an exit_to_main with no recorded successor generation.

Keep only the hand-back exits kunchenguid#6588 does not cover: its main-only arm stays as merged, and exit_to_main, the non-main-only attended pass-through, the turn-start pass-through and the park boundary go through hand_back.
@WTF-Am-ID WTF-Am-ID changed the title fix(bin): restore watcher downtime before every hand-back to main fix(bin): restore downtime on remaining supervision hand-backs Oct 22, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @WTF-Am-ID for rebasing this as the follow-up now that #6588 has landed (05a68cb2), and for keeping the initial main-only arm on #6588's own code.

What I checked: tip ca566fc8 vs main d906d442 (3 files). The new hand_back republishes downtime, then leaves or detaches the successor. On a failed publish it retires the successor, logs downtime-unrestored, and exits nonzero. It's now used by exit_to_main, the attended non-main-only pass-through, the turn-start pass-through (HANDLE_RC=2) and boundary_exit. The new uncomputable host+hook test pins a non-main-only pass-through after a handled turn. The attestation now matches this head, so that earlier ask is done. There's no workflow or secret surface, so I approved the fork runs at this tip: CI 39812632495 and Require no-mistakes 39812632567 / 39812746793.

Contract-class: new-default (my own read, firmer than my earlier cannot-tell). The non-main-only and turn-start pass-throughs fix the #6704 gap, and that part is a restore. But boundary_exit (a normal park ending at its bound) now publishes downtime and can exit nonzero. exit_to_main also publishes even when no successor generation was recorded. Those change paths that weren't shown broken, so landing it is Kun's call, not an auto-merge.

What's needed from you (this is waiting on you, not the captain): live validation. The body records 0 of 5 scenarios driven live. Could you live-test on a real session and post the evidence, or re-raise through git push no-mistakes with the Test step driving it? The most useful scenarios are the #6704 repro, a park that ends at its bound without a spurious main rewake or nonzero exit, and an exit_to_main with no recorded successor generation.

VISION.md: one captain, one interface — aligns (ends silent multi-hour gaps) · authority explicit — aligns · scripts/agents — aligns (exact republish) · restart is a non-event — aligns (the close is retired by delivery) · delegation with a spine — aligns (a failed publish is loud, not silent) · outlives any vendor — aligns · scope — aligns.

@WTF-Am-ID

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Here is the live validation you asked for, covering your three scenarios plus a pre-fix control on main.

Scenario ca566fc8 main 1935d27b (includes #6588)
#6704 path, main-only pass-through after a handled turn PASS: rewake, downtime restored same (fixed by #6588)
#6704 path, non-main-only pass-through (no supervision engine) PASS: ordinary rewake, downtime restored gap reproduced: marker stuck pending:handling, rewake refused, close reached main only via auto-arm FAILED
Park reaches its bound (boundary_exit), two consecutive boundaries PASS: one wake per boundary, no spurious rewake, no restore failure -
exit_to_main with no recorded successor generation PASS: identical-token republish, one rewake same single delivery, no host write

Live validation at ca566fc8 against a real interactive Claude Code 2.1.308 primary (haiku) with the tracked Stop auto-arm and the default sonnet engine, in an isolated lab home on macOS (stock bash 3.2). After its setup prompt the primary was never typed to again, so every main turn was a Stop-hook rewake. Baseline 1935d27b (origin/main, includes #6588).

  1. Supervision host: attended pass-through can still drop the main rewake when the parked successor already closed #6704 path: a routine close handled by the engine while a main-only close on another task closed the successor, then the parked successor's close read after the handled turn. Main-only pass-through: rewake delivered and downtime republished for the same generation on both revisions (fix(bin): restore watcher downtime before main-only hand-back #6588's arm). Non-main-only pass-through (no supervision engine, from a mid-turn config edit): on main the marker stayed pending:handling, the rewake commit was refused, and main got the close only with auto-arm FAILED - the supervision host returned an actionable wake, but its rewake could not be committed (ledger outcome=failed). On ca566fc8, hand_back republished downtime 0.27 s after the turn and main got one ordinary rewake, drained and acknowledged.
  2. Park bound (90 s via FM_SUPERVISION_HOST_PARK_SECONDS, two consecutive boundaries): at each boundary the watcher stopped, the host republished the same pending:downtime token (write attributed to the host pid through the marker lock), and the hook committed exactly one rewake carrying only the cycle boundary line. There were 2 deliveries for 2 boundaries, none between them, and no downtime-unrestored row or restore-failure line, so the host exited 0.
  3. exit_to_main as the host's first close (away record plus an unverified engine in config, so no successor generation was recorded): on ca566fc8 the host rewrote the identical pending:downtime:<closed watcher's generation> token; on main there was no host write. Both gave one rewake with the same banner and the same drain and acknowledgement, so the new publication is a no-op in this case.
    Not driven live: the turn-start pass-through (HANDLE_RC=2), the branch eligibility could not be computed reason, and the publication-failure paths. The host's own exit status is inferred from its ledger and output, because the hook does not log it on the wake path.

No defect was found in the changed paths. On the two paths you flagged as changed but not shown broken, the new publication was a same-generation, identical-token republish with exactly one main wake, attributed write by write to the host process.

CI: 19 of 20 checks pass at this head. "Behavior portable serial 1" was cancelled at the 30-minute job limit (run 39812632495), a timeout rather than a test assertion.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @WTF-Am-ID — this is exactly the live evidence I asked for, and the pre-fix control on main is especially useful. The non-main-only pass-through reproducing the stuck pending:handling / auto-arm FAILED on main and coming through as one ordinary rewake on ca566fc8 makes the #6704 gap concrete, and the two-boundary park run (one wake per boundary, host exits 0) and the no-generation exit_to_main run answer my two concerns about those paths.

Where it stands: head is still ca566fc8 (attestation matches, mergeable). Everything in CI is green except Behavior portable serial 1, which was cancelled at the 30-minute job ceiling while its tests were still passing (the last ~25 host tests, including the park-boundary ones, all ok). That's the known serial-ceiling flake, so I've re-run the failed job on run 39812632495.

Contract-class stays new-default (my own read): your evidence shows the changed boundary_exit and exit_to_main paths behave well, but they're still default paths that change, so landing this is Kun's merge-or-leave call rather than an auto-merge. Once the rerun is green I'll put it in front of him. Nothing more is needed from you right now — this is waiting on CI, then the captain.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks again @WTF-Am-ID — your CI run on ca566fc8 came back fully green and the attestation still matches, so this was about to go to Kun.

Unfortunately #7466 just landed on main (ac8a767f) and touches the same attended pass-through block in bin/fm-supervision-host.sh (plus docs/supervision-host.md), so this branch now conflicts. It's more than textual: #7466 changed that hand-back to fm_recovery_marker_handback, which republishes downtime as already announced so the successor left running doesn't resurface the episode the close itself delivers. Your hand_back helper should keep that behaviour on the attended pass-through (and it's worth deciding whether your other hand-backs want the plain publish or the announced handback).

Could you rebase onto current main, resolve that, and re-raise through git push no-mistakes so the attestation binds the new head? Your live evidence from 20:15Z can carry over if the delta is just the rebase reconciliation — a one-line note on that in the PR is enough.

Contract-class stays new-default (my own read), so once it's rebased and green this goes to Kun as a merge-or-leave decision. This one is waiting on you (rebase) for now.

Reconcile with kunchenguid#7466: hand_back hands downtime back as already announced
(fm_recovery_marker_handback) when it leaves a successor running, as the
turn-start pass-through now does on main, and publishes plain downtime when
no successor stays up (exit_to_main, the park boundary, and the
non-main-only attended pass-through).
@WTF-Am-ID WTF-Am-ID changed the title fix(bin): restore downtime on remaining supervision hand-backs fix(bin): restore downtime on remaining supervision-host hand-backs Oct 23, 2026
@kunchenguid

kunchenguid commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @WTF-Am-ID for merging main back in after #7466. Head 6ef7b273 merges cleanly onto current main cfe91b0, and you've re-raised it.

The CI and Require no-mistakes runs for this head are waiting for a maintainer to approve them as fork runs. I'll approve them after I've read the delta, in a pass where this PR is in the queue. Nothing is needed from you right now. Once it's green with the attestation on this head, it goes to Kun as a merge-or-leave decision, because it's new-default.

Reconcile with kunchenguid#7466: hand_back hands downtime back as already announced
(fm_recovery_marker_handback) when it leaves a successor running, as the
turn-start pass-through now does on main, and publishes plain downtime when
no successor stays up (exit_to_main, the park boundary, and the
non-main-only attended pass-through).
@WTF-Am-ID WTF-Am-ID changed the title fix(bin): restore downtime on remaining supervision-host hand-backs fix(bin): restore downtime before supervision-host hand-backs Oct 25, 2026
@kunchenguid

kunchenguid commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @WTF-Am-ID for keeping this current with main.

I read the delta on head 5165f995 since 6ef7b273. It's the main merge-backs, a docs consolidation, and one test-fixture change: the uncomputable case now races a real fm-wake-drain.sh against the failed offer and asserts that the episode moves back to handling first, so the regression stays red after the handled-turn settling on main. There are no workflow edits, no network calls and nothing credential-related, so I've approved the fork runs for this head: CI 40201723599 and Require no-mistakes 40201723598, 40202388851, 40202693769. The attestation binds this head, and your earlier live evidence still covers the hand-back behavior, since the product logic didn't change in this delta.

My verdict is unchanged. Contract-class is new-default: boundary_exit now publishes downtime and can exit nonzero, and exit_to_main publishes without a successor generation. VISION aligns on every rule.

Next step: this is waiting on CI, not on you. If it comes back green and stays clean, it goes to Kun as a merge-or-leave decision. #6588, the narrow fix, has already landed on main, and this head merges cleanly on top of it, so he'll weigh it as the broader follow-up to that fix.

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.

2 participants