Skip to content

fix: export the computed home for supervision handoffs - #61

Closed
peterOC26 wants to merge 3 commits into
mainfrom
fm/fm-turnend-guard-host-gap-g1
Closed

peterOC26 wants to merge 3 commits into
mainfrom
fm/fm-turnend-guard-host-gap-g1

Conversation

@peterOC26

Copy link
Copy Markdown
Owner

Intent

Captain Q2074 (2026-11-13): "q2074 y use grok and/or deepseek for that. important". The question was: "Start a fix now so the supervision session keeps routine notifications instead of handing them all to the main chat? Y = start now on Grok: find the cause and fix it as one firstmate PR, which then waits for your merge word."

Evidence: /root/firstmate/data/fm-claude-use-measure-m1/report.md measured $350.30 of Claude use in 27.8 h; the main chat is 51.4%, and its watcher-wake turns alone are $144.54 (41% of everything). On 2026-11-12 and 2026-11-13 nearly every Stop-hook wake that reached the main chat carried the line "supervision-host: the acknowledged hand-back successor could not be verified" plus a queued "check: supervision-handoff - the host handed supervision to main" wake, including for routine wakes the supervision session is allowed to take (status signals, rearm-resurface, wait-claim, stale declared pauses). Earlier note (2026-11-12): the Stop guard also said no live watcher held the home lock while seconds later a new fm-watch.sh and auto-arm were live; either the guard or hand-back runs before the host's successor claim is visible, or the successor check is wrong. Related: fm-autoarm-lost-close-durable-a1, fm-turnend-guard-host-false-blind-g1, fm-handoff-retry-herdr-transport-h1. This home runs Claude Code main under herdr with the supervision host on.

What Changed

  • Export the supervision host’s computed FM_HOME so child processes can verify handoff successors and keep subsequent routine notifications with supervision.
  • Add Stop-hook fixtures and regression cases for unset FM_HOME, routine notification retention, and fallback to main when successor verification fails.
  • Update test coverage documentation and clarify historical shard timing samples.

Risk Assessment

✅ Low: The change exports a home value that every child already computes the same way, from the same bin directory or override. It fixes the confirmed root cause at the only place the hand-back owner is launched. The production Stop hook in .claude/settings.json does not export FM_HOME, so the owner's FM_HOME:? check made it exit at once, which produced the 'successor could not be verified' line. New behavioural tests cover both the verified hand-back and the unverifiable one.

Testing

The focused hook suite passed, and a base-version control reproduced the reported failure. A real Claude launch in an isolated Herdr lab stopped at workspace trust; terminal evidence was captured and the lab was removed. No live notification scenario completed.

  • Live validation: ⚠️ inconclusive - 0 of 3 scenarios driven live against the product
Scenario Result Live Evidence
With FM_HOME initially unset, a decision reaches main and its monitoring successor verifies successfully. ⏸️ untested no Claude requires interactive workspace-trust approval for this worktree. Have an operator approve the exact run directory in Claude, then rerun.
After main acknowledges a decision, the next routine notification stays in supervision without waking main. ⏸️ untested no The real Claude primary could not proceed past workspace trust. Operator approval of this exact worktree is required before rerunning.
A successor that cannot become healthy still escalates the notification to main. ⏸️ untested no The real Claude primary could not proceed past workspace trust. Operator approval of this exact worktree is required before rerunning.
Evidence: Base version reproduces reported successor-verification failure

Source: Base version reproduces reported successor-verification failure

1..1
not ok - computed home: a derivable home must not fail successor verification: firstmate watcher wake - one supervision event needs a handling turn now.
signal: /tmp/fm-supervision-host.bevBwK/computed-home-handoff/state/demo.status
supervision-host: the acknowledged hand-back successor could not be verified
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.
Evidence: Real Claude session blocked by workspace trust

Source: Real Claude session blocked by workspace trust

env -u NO_MISTAKES_GATE -u FM_GATE_REFUSE_BYPASS -u FM_ROOT_OVERRIDE -u FM_STATE_OVERRIDE -u
FM_DATA_OVERRIDE -u FM_CONFIG_OVERRIDE -u FM_PROJECTS_OVERRIDE FM_HOME=~/.no-mistake
s/worktrees/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602/.test-supervision-live-home DISABLE_AUTOU
PDATER=1 claude --model haiku --setting-sources project,local
zabi@purplevoice:~/.no-mistakes/worktrees/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602$ env -u NO_
MISTAKES_GATE -u FM_GATE_REFUSE_BYPASS -u FM_ROOT_OVERRIDE -u FM_STATE_OVERRIDE -u FM_DATA_OV
ERRIDE -u FM_CONFIG_OVERRIDE -u FM_PROJECTS_OVERRIDE FM_HOME=~/.no-mistakes/worktree
s/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602/.test-supervision-live-home DISABLE_AUTOUPDATER=1 c
laude --model haiku --setting-sources project,local

─────────────────────────────────────────────────────────────────────────────────────────────
 Accessing workspace:

 ~/.no-mistakes/worktrees/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602

 Quick safety check: Is this a project you created or one you trust? (Like your own code, a
 well-known open source project, or work from your team). If not, take a moment to review
 what's in this folder first.

 Claude Code'll be able to read, edit, and execute files here.

 Security guide

 ❯ No, exit
   Yes, I trust this folder

 Enter to confirm · Esc to cancel
Evidence: Isolated Herdr launch, inspection, and cleanup

Source: Isolated Herdr launch, inspection, and cleanup

$ bin/fm-lab-home.sh create ~/.no-mistakes/worktrees/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602/.test-supervision-live-home
~/.no-mistakes/worktrees/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602/.test-supervision-live-home

exit=0
$ bin/fm-herdr-lab.sh provision fm-lab-home-export-g1

exit=0
$ bin/fm-herdr-lab.sh viewer start fm-lab-home-export-g1
viewer attached to fm-lab-home-export-g1 (pid 409110)

exit=0
$ bin/fm-herdr-lab.sh run fm-lab-home-export-g1 workspace create --cwd ~/.no-mistakes/worktrees/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602 --label home-export-validation --env DISABLE_AUTOUPDATER=1 --env FM_HOME=~/.no-mistakes/worktrees/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602/.test-supervision-live-home
{"id":"cli:workspace:create","result":{"root_pane":{"agent_status":"unknown","cwd":"~/.no-mistakes/worktrees/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602","focused":false,"foreground_cwd":"~/.no-mistakes/worktrees/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602","pane_id":"w2:p1","revision":0,"scroll":{"max_offset_from_bottom":0,"offset_from_bottom":0,"viewport_rows":39},"tab_id":"w2:t1","terminal_id":"term_66023fac5243a2","workspace_id":"w2"},"tab":{"agent_status":"unknown","focused":false,"label":"1","number":1,"pane_count":1,"tab_id":"w2:t1","workspace_id":"w2"},"type":"workspace_created","workspace":{"active_tab_id":"w2:t1","agent_status":"unknown","focused":false,"label":"home-export-validation","number":2,"pane_count":1,"tab_count":1,"workspace_id":"w2"}}}

exit=0
$ bin/fm-herdr-lab.sh run fm-lab-home-export-g1 pane run w2:p1 'env -u NO_MISTAKES_GATE -u FM_GATE_REFUSE_BYPASS -u FM_ROOT_OVERRIDE -u FM_STATE_OVERRIDE -u FM_DATA_OVERRIDE -u FM_CONFIG_OVERRIDE -u FM_PROJECTS_OVERRIDE FM_HOME=~/.no-mistakes/worktrees/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602/.test-supervision-live-home DISABLE_AUTOUPDATER=1 claude --model haiku --setting-sources project,local'

exit=0
$ bin/fm-herdr-lab.sh run fm-lab-home-export-g1 pane read w2:p1 --source recent --lines 120
env -u NO_MISTAKES_GATE -u FM_GATE_REFUSE_BYPASS -u FM_ROOT_OVERRIDE -u FM_STATE_OVERRIDE -u
FM_DATA_OVERRIDE -u FM_CONFIG_OVERRIDE -u FM_PROJECTS_OVERRIDE FM_HOME=~/.no-mistake
s/worktrees/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602/.test-supervision-live-home DISABLE_AUTOU
PDATER=1 claude --model haiku --setting-sources project,local
zabi@purplevoice:~/.no-mistakes/worktrees/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602$ env -u NO_
MISTAKES_GATE -u FM_GATE_REFUSE_BYPASS -u FM_ROOT_OVERRIDE -u FM_STATE_OVERRIDE -u FM_DATA_OV
ERRIDE -u FM_CONFIG_OVERRIDE -u FM_PROJECTS_OVERRIDE FM_HOME=~/.no-mistakes/worktree
s/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602/.test-supervision-live-home DISABLE_AUTOUPDATER=1 c
laude --model haiku --setting-sources project,local

─────────────────────────────────────────────────────────────────────────────────────────────
 Accessing workspace:

 ~/.no-mistakes/worktrees/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602

 Quick safety check: Is this a project you created or one you trust? (Like your own code, a
 well-known open source project, or work from your team). If not, take a moment to review
 what's in this folder first.

 Claude Code'll be able to read, edit, and execute files here.

 Security guide

 ❯ No, exit
   Yes, I trust this folder

 Enter to confirm · Esc to cancel

exit=0
$ bin/fm-herdr-lab.sh teardown fm-lab-home-export-g1

exit=0
$ rm -rf ~/.no-mistakes/worktrees/7f0ec18181b6/01M79YGCNP14PWKCA68ZJKB602/.test-supervision-live-home

exit=0
- Outcome: ⚠️ 2 warnings across 1 run (7m23s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 issues (1 warning, 1 info)
  • ⚠️ bin/fm-supervision-host.sh:772 - Simplification: acknowledged_handback sets the same environment a second time. The intent does not need this, because line 214 already runs export FM_HOME. (1) The FM_HOME="$FM_HOME" prefix on the owner launch at line 775 has no effect after that export. (2) The two lines [ -z "${FM_STATE_OVERRIDE:-}" ] || export FM_STATE_OVERRIDE and the CONFIG equivalent at lines 772-773 also do nothing. The host never assigns those variables itself, so they can only come from the inherited environment, where they are already exported. The block at lines 647-649 is different: it runs inside a subshell next to export ... STATE. Recommended fix: remove lines 772-773 and the FM_HOME= prefix, and keep the single export at line 214 as the one rule. Also drop the header sentence 'The launch repeats the home on the owner.' (line 127). The header's claim about the branch offer (lines 124-126) is also overstated. fm-branch-dispatch.mjs falls back to FM_ROOT_OVERRIDE, then the script's own repository. On a home that is only computed, that repository is the same as the home, so only the hand-back owner (FM_HOME:? at fm-supervision-handoff.sh:25) actually failed.

🔧 Fix applied.
2 issues (1 warning, 1 info) still open:

  • ⚠️ bin/fm-supervision-host.sh:772 - Simplification: acknowledged_handback sets the same environment a second time. The intent does not need this, because line 214 already runs export FM_HOME. (1) The FM_HOME="$FM_HOME" prefix on the owner launch at line 775 has no effect after that export. (2) The two lines [ -z "${FM_STATE_OVERRIDE:-}" ] || export FM_STATE_OVERRIDE and the CONFIG equivalent at lines 772-773 also do nothing. The host never assigns those variables itself, so they can only come from the inherited environment, where they are already exported. The block at lines 647-649 is different: it runs inside a subshell next to export ... STATE. Recommended fix: remove lines 772-773 and the FM_HOME= prefix, and keep the single export at line 214 as the one rule. Also drop the header sentence 'The launch repeats the home on the owner.' (line 127). The header's claim about the branch offer (lines 124-126) is also overstated. fm-branch-dispatch.mjs falls back to FM_ROOT_OVERRIDE, then the script's own repository. On a home that is only computed, that repository is the same as the home, so only the hand-back owner (FM_HOME:? at fm-supervision-handoff.sh:25) actually failed.
  • ℹ️ bin/fm-supervision-host.sh:124 - The new ACKNOWLEDGED HAND-BACK header comment (lines 123-126) is still partly inaccurate. Round 1 noted this, and the fix round deliberately did not change it. The comment says the branch offer's fallback is 'the repository that contains its script rather than that home'. In fact fm-branch-dispatch.mjs:59 resolves FM_HOME || FM_ROOT_OVERRIDE || root, and the host computes its home as FM_ROOT_OVERRIDE or the script's repository too. So when the home is only computed, the offer already landed on the same home before this change. Only the hand-back owner (FM_HOME:? at bin/fm-supervision-handoff.sh:25) actually failed. The code is correct; only the comment over-claims. You could trim the clause to name only the owner. The user scoped the round-1 fix to the env lines, so this is left as information.
⚠️ **Test** - 2 warnings
  • ⚠️ Live notification delivery could not be demonstrated because Claude stopped at workspace trust. Repository guidance forbids answering that dialog through agent keys, and the workspace boundary forbids editing the global trust store. An operator must approve this exact worktree interactively, then rerun the test phase.
  • ⚠️ live validation verdict: inconclusive (0 of 3 scenarios were driven live against the product); untested: With FM_HOME initially unset, a decision reaches main and its monitoring successor verifies successfully., After main acknowledges a decision, the next routine notification stays in supervision without waking main., A successor that cannot become healthy still escalates the notification to main.
  • Live validation: ⚠️ inconclusive - 0 of 3 scenarios driven live against the product
Scenario Result Live Evidence
With FM_HOME initially unset, a decision reaches main and its monitoring successor verifies successfully. ⏸️ untested no Claude requires interactive workspace-trust approval for this worktree. Have an operator approve the exact run directory in Claude, then rerun.
After main acknowledges a decision, the next routine notification stays in supervision without waking main. ⏸️ untested no The real Claude primary could not proceed past workspace trust. Operator approval of this exact worktree is required before rerunning.
A successor that cannot become healthy still escalates the notification to main. ⏸️ untested no The real Claude primary could not proceed past workspace trust. Operator approval of this exact worktree is required before rerunning.
  • bash tests/fm-supervision-host-hook.test.sh — completed successfully.
  • bash tests/.test-baseline-home-export.sh — temporary focused driver ran the computed-home regression against the base host; failed with the reported successor-verification warning as expected.
  • python3 .test-supervision-live.py — temporary driver provisioned a named Herdr lab, attached a sized viewer, launched real Claude Code 2.1.319, and captured its workspace-trust dialog.
  • bin/fm-herdr-lab.sh teardown fm-lab-home-export-g1 — completed successfully.
  • git status --short and git diff --stat — confirmed no remaining worktree changes after cleanup.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

peterOC26 and others added 3 commits November 13, 2026 08:54
The host assigned FM_HOME without exporting it. The hand-back owner then
exits before it can arm a watcher, and the branch offer falls back to the
repository that contains its script. Export the computed home before any
child starts, and repeat it on the owner. A successor that never becomes
healthy still hands the close to main.
@peterOC26

Copy link
Copy Markdown
Owner Author

Closing: this change already landed on main as ceec3db (fix: export the computed home for supervision handoffs (#61)); a GitHub 502 during the merge left the PR open.

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