Skip to content

fix: retry supervision hand-back through an inherited Herdr pane - #65

Merged
peterOC26 merged 1 commit into
mainfrom
fm/fm-handoff-retry-herdr-transport-h1
Nov 15, 2026
Merged

peterOC26 merged 1 commit into
mainfrom
fm/fm-handoff-retry-herdr-transport-h1

Conversation

@peterOC26

Copy link
Copy Markdown
Owner

Intent

Supervision hand-back retry only submits through tmux; add the herdr transport so a herdr-hosted primary is re-woken

Resolution recorded by fm-captain-hold.
Decision digest: 5bdc02baef9afb174011b9518ace85ceccc9553f92fc3327f30be8528c439697
Resolution mode: released

Captain decision:
Captain 2026-11-15 (Jobs page note 1794703235-3uxISq): "The 11 firstmate fixes - do all of these". Start now instead of the staggered dates; Grok builds, DeepSeek checks, firstmate repo reviews one at a time (fleet 133), captain merges each.

Parent: fm-watcher-lapse-20261110-d1. From data/fm-watcher-lapse-20261110-d1/report.md section 4 item 3: bin/fm-supervision-handoff.sh:86-105 submits only through an inherited TMUX_PANE with fm_backend_source tmux; this primary runs under herdr (claude -> bash -> herdr server), so retries stay deferred (docs/supervision-host.md:268). Use bin/backends/herdr.sh fm_backend_send_text_submit; needs live verification.

"The 11 firstmate fixes - do all of these" (2026-11-15)

What Changed

  • bin/fm-supervision-handoff.sh adds a Herdr fallback for the hand-back retry. When no TMUX_PANE is inherited, the retry can submit the watcher doorbell through fm_backend_send_text_submit herdr to the inherited Herdr pane. This requires HERDR_ENV=1, a valid HERDR_PANE_ID, and HERDR_SESSION (or Herdr's default session). The fallback never starts a Herdr server.
  • Before it types anything, the Herdr path checks that the server is already running. It also checks that the pane's shell is an ancestor of the pinned session pid and that the session is in the foreground process group. It reads the rendered busy state, Herdr's native agent status and the composer, and goes ahead only when all three show the agent is idle with an empty composer. Then it rechecks that the session still owns the hand-back, the token is still pending and the server is still running. If any check fails, the retry stays deferred. An inherited TMUX_PANE still takes priority, even when its own checks defer the retry.
  • The helper header and docs/supervision-host.md now describe delivery through the inherited pane's submit primitive instead of tmux only. tests/fm-supervision-host-hook.test.sh adds a test where a fake Herdr backend checks that the retry submits with Enter in the inherited Herdr session and writes a watcher operational record.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The new Herdr retry path is narrow. It runs only when TMUX_PANE is absent and the session is still owned. It does not start a Herdr server, and it checks the same things the tmux path does: the pane's shell owns the pinned session, the session is in the foreground, Claude looks idle on screen and in Herdr's native agent state, and the composer is empty. Every check that fails or can't be read leaves the retry deferred. The new test uses a fake herdr CLI and covers each of these cases.

Testing

I ran the change's new targeted hook test, which passed against a fake herdr. I then drove the real bin/fm-supervision-handoff.sh live against a real Claude primary in a guarded Herdr lab session (fm-lab-*). The retry submitted the hand-back through the inherited Herdr pane and re-woke Claude, with the submit confirmed (verdict empty). Later retries deferred and left a human composer draft untouched. The lab was torn down and the default Herdr session was never touched. The stopped-server guard and the Herdr checks that fire before a submit is attempted (foreign pane, backgrounded session, busy footer, Claude working) were checked only by the fake-herdr test, so they are recorded as untested live. Overall result: go.

  • Live validation: ✅ go - 2 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Herdr-hosted Claude primary (no TMUX_PANE) with an unacknowledged hand-back is re-woken: the retry types and submits the supervision-handoff operational input through the inherited Herdr pane ✅ pass live supervision-handoff.log shows retry tok1 empty; herdr-pane-after-retry.txt shows the 'Firstmate operational input waiting' prompt submitted and Claude taking a new turn; operational-record.msg holds…
Adversarial: a human draft is sitting in the Herdr-hosted Claude composer, so the retry defers and does not overwrite it ✅ pass live draft-retry-log.txt shows two deferred retries; herdr-pane-with-human-draft.txt shows the composer still reading '❯ human draft do not overwrite'
Adversarial guards: a stopped Herdr server is never started or typed into; a foreign pane or process-info for another pane, a backgrounded session, a busy footer, and Claude working all defer ⏸️ untested no The earlier result did not show a live result here: these guards were checked only by tests/fm-supervision-host-hook.test.sh with a fake herdr. Stopping the real lab server kills the Claude primary it…
Evidence: Lab Herdr pane after retries: Claude re-woken by the hand-back operational input

Source: Lab Herdr pane after retries: Claude re-woken by the hand-back operational input

▝▜██████▀  Opus 5.5 with medium effort · Claude Max
 ▝▝   ▝▝   ~/.no-mistakes/worktrees/7f0ec18181b6/01M7EBJ2PNR3KH2J12SN4RP2A7
❯ Lab test. Run exactly this one bash command with the Bash tool, then reply only DONE and end your turn: cd
  {run-worktree} && FM_HOME=/tmp/fm-lab.0AOa4W
  FM_SUPERVISION_HANDOFF_RETRY_SECONDS=20 nohup bin/fm-supervision-handoff.sh tok1 999999 >
  /tmp/fm-lab.0AOa4W/handoff.out 2>&1 < /dev/null & sleep 2; cat /tmp/fm-lab.0AOa4W/handoff.out
  Ran 1 shell command
● DONE
✻ Brewed for 6s · done 2:04 AM
❯ : Firstmate operational input waiting: read
  '/tmp/fm-lab.0AOa4W/state/operational-inbox/1794704690-27c29d6db91891ee.msg' and handle its contents as Firstmate
  operational input.
  Read 1 file, ran 1 shell command
● Captain, the automatic monitoring notice asked me to clear the lab's pending notifications. I ran the cleanup and it
  returned nothing: there was no queued work and no acknowledgement step to run, so this lab needs nothing from you.
✻ Baked for 8s · done 2:05 AM
❯ : Firstmate operational input waiting: read
  '/tmp/fm-lab.0AOa4W/state/operational-inbox/1794704712-e0a7ff2966f08b5f.msg' and handle its contents as Firstmate
  operational input.
  Reading the new operational inbox message
  ⎿  $ cat /tmp/fm-lab.0AOa4W/state/operational-inbox/1794704712-e0a7ff2966f08b5f.msg
· Razzle-dazzling… (2s · ↓ 97 tokens)
                                          ✘ Auto-update failed: no write permission to npm prefix · Run claude doctor
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ⚠ Transcript saving is off — inherited CLAUDE_CODE_CHILD_SESSION marker · restart with CLAUDE_CODE_FORCE_SESSION_P…
  ⏵⏵ bypass permissions on (shift+tab to cycle) · esc to interrupt
Evidence: Supervision handoff retry log (empty then deferred verdicts)

Source: Supervision handoff retry log (empty then deferred verdicts)

1794704691	retry	tok1	empty
1794704713	retry	tok1	empty
Evidence: Durable operational watcher record delivered by the herdr retry

Source: Durable operational watcher record delivered by the herdr retry

⁣FIRSTMATE_OP: v1 watcher: check: supervision-handoff - the host hand-back is still unacknowledged. Run bin/fm-wake-drain.sh, handle its queued work, and run its exact WAKE_ACK_REQUIRED command. This is automatic supervision, not a captain return.⁣FIRSTMATE_OP: v1 watcher: check: supervision-handoff - the host hand-back is still unacknowledged. Run bin/fm-wake-drain.sh, handle its queued work, and run its exact WAKE_ACK_REQUIRED command. This is automatic supervision, not a captain return.
Evidence: Retry log during human draft (deferred x2)

Source: Retry log during human draft (deferred x2)

1794704713	retry	tok1	empty
1794704734	retry	tok1	deferred
1794704755	retry	tok1	deferred
Evidence: Lab pane showing the human draft preserved after retries

Source: Lab pane showing the human draft preserved after retries

  20 seconds. That may be the behaviour this test is meant to show. If it isn't, the retry needs a fix.
✻ Sautéed for 9s · done 2:05 AM
                                          ✘ Auto-update failed: no write permission to npm prefix · Run claude doctor
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯ human draft do not overwrite
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ⚠ Transcript saving is off — inherited CLAUDE_CODE_CHILD_SESSION marker · restart with CLAUDE_CODE_FORCE_SESSION_P…
  ⏵⏵ bypass permissions on (shift+tab to cycle)
Evidence: Lab home and Herdr lab session ids

Source: Lab home and Herdr lab session ids

LAB=/tmp/fm-lab.0AOa4W S=fm-lab-handback-3733196-17460
Evidence: Retry log excerpt
1794704691 retry tok1 empty
1794704713 retry tok1 empty
1794704734 retry tok1 deferred
1794704755 retry tok1 deferred

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ℹ️ bin/fm-supervision-handoff.sh:144 - The new Herdr branch copies the tmux branch's watcher doorbell text word for word (bin/fm-supervision-handoff.sh:144 and :170), along with its pane-shell ancestor walk and foreground pgid/tpgid proof (:116-125 vs :157-164). If someone later edits only one copy, the two transports will send different doorbells or apply different ownership checks. Fix: move the message into one variable and the ancestor/foreground proof into a helper that takes the pane's shell pid, then call it from both branches. This is a refactor only; behavior does not change.
  • ℹ️ docs/supervision-host.md:269 - The intent says the Herdr path "needs live verification". The change proves the behavior only against a fake herdr CLI (tests/fm-supervision-host-hook.test.sh). The docs say so honestly: "No new live-harness verification is claimed." No source change is needed. Someone still needs to confirm on a real Herdr-hosted primary that the retry wakes Claude.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 2 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Herdr-hosted Claude primary (no TMUX_PANE) with an unacknowledged hand-back is re-woken: the retry types and submits the supervision-handoff operational input through the inherited Herdr pane ✅ pass live supervision-handoff.log shows retry tok1 empty; herdr-pane-after-retry.txt shows the 'Firstmate operational input waiting' prompt submitted and Claude taking a new turn; operational-record.msg holds…
Adversarial: a human draft is sitting in the Herdr-hosted Claude composer, so the retry defers and does not overwrite it ✅ pass live draft-retry-log.txt shows two deferred retries; herdr-pane-with-human-draft.txt shows the composer still reading '❯ human draft do not overwrite'
Adversarial guards: a stopped Herdr server is never started or typed into; a foreign pane or process-info for another pane, a backgrounded session, a busy footer, and Claude working all defer ⏸️ untested no The earlier result did not show a live result here: these guards were checked only by tests/fm-supervision-host-hook.test.sh with a fake herdr. Stopping the real lab server kills the Claude primary it…
  • tests/fm-supervision-host-hook.test.sh new function test_handoff_retry_submits_through_the_inherited_herdr_pane only (fake herdr: stopped server, foreign pane/response, backgrounded session, busy footer, native working, human draft, then idle submit) -> ok
  • bin/fm-lab-home.sh create $LAB + bin/fm-herdr-lab.sh name/provision fm-lab-handback-3733196-17460 + workspace create for a guarded Herdr lab
  • Real claude --dangerously-skip-permissions launched in lab pane w1:p1 with FM_HOME=$LAB (HERDR_ENV=1, HERDR_PANE_ID=w1:p1, HERDR_SESSION=lab, no TMUX_PANE)
  • Lab Claude ran FM_SUPERVISION_HANDOFF_RETRY_SECONDS=20 nohup bin/fm-supervision-handoff.sh tok1 999999 as a detached child of its own session, with state/.lock pinned to the Claude pid
  • Observed retry verdict empty, the operational-inbox record, and Claude waking for a new turn (herdr pane read, agent get)
  • Typed a human draft with herdr pane send-text (no Enter), waited two retry cycles, and checked the log showed deferred and the composer still held the draft
  • Teardown: stopped the handoff owner and watcher, bin/fm-herdr-lab.sh teardown, rm -rf $LAB, then checked that only the default session remains
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

… pane

The hand-back retry submitted only through an inherited tmux pane, so a
primary hosted by Herdr stayed deferred. An inherited Herdr pane now uses
the same ownership, foreground, busy, and composer guards, and does not
start a Herdr server.
@peterOC26
peterOC26 merged commit 4f53948 into main Nov 15, 2026
30 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