Repository navigation
fix(bin): reclaim a task whose herdr endpoint was destroyed - #5007
kunchenguid merged 12 commits into
Conversation
A destroyed pane or workspace made `missing` a terminal state. Relaunch accepted only `dead` and said to stop the agent first; exit refused `missing` and said to reconcile the task first; there is no reconcile verb. Each command named the other as its prerequisite, so a task whose terminal went away could not be reclaimed by anything, and a no-mistakes approval it was parked on had no seat left to answer it. `missing` is agent-free a fortiori: there is no endpoint, so there is no agent in it. Widen the existing guards rather than add a verb. - fm-spawn --relaunch accepts a positively proven `missing` and creates one fresh endpoint in the recorded worktree; the record it already republishes rebinds the task to it. A `dead` endpoint is still adopted in place. - fm-control exit reports `endpoint-gone` instead of dying, so the relaunch transaction's stop step no longer dead-ends, and re-resolves the endpoint from the record before verifying the replacement. The duplicate-agent refusal is untouched: both verdicts come from the same recovery-grade classifier, which claims `missing` only from positive absence, so `alive`, `ambiguous`, and `unreadable` all still refuse. The backends' own create paths refuse a live same-labeled endpoint as a second independent guard. The worktree, its branch, commits, uncommitted changes, armed poll and registration, record rows, and status log are all untouched - a reclaim is a recovery, never a teardown. A secondmate is excluded: its gone-endpoint recovery already has one owner in the session-start liveness sweep, so relaunch refuses and names it rather than becoming a second path to the same outcome. Tests reproduce both halves of the deadlock, the reclaim succeeding, unlanded work surviving it, and the refusals that still hold.
…rdr rebind session
Rebasing onto main picked up kunchenguid#4994, which stages a long worker launch command into a script and delivers the short `. '<path>'` line instead of the literal command. The tmux fake and tests/fixtures.sh were updated for that; the herdr fake this branch adds was written before it and still keyed "an agent now exists on this pane" off the literal `encode launch-brief` text, so after the rebase it never marked the rebound pane live and the reclaim's alive-wait read `dead`. Dereference the staged file first, exactly as the tmux fake above does. Test-fixture only; no production path changes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
0eb3aed to
8894ab4
Compare
|
Speaking as Kun's firstmate: this is merged. Thank you @RooseveltAdvisors — really appreciate you taking the time on this. First look on HEAD Contract-class: restore. Main tip's VISION.md (each rule)
Auto-merged (restore + MATCH + green CI/NM + safe). Squash |
…uid#5007) * fix(control): let the owning seat reclaim a task whose endpoint is gone A destroyed pane or workspace made `missing` a terminal state. Relaunch accepted only `dead` and said to stop the agent first; exit refused `missing` and said to reconcile the task first; there is no reconcile verb. Each command named the other as its prerequisite, so a task whose terminal went away could not be reclaimed by anything, and a no-mistakes approval it was parked on had no seat left to answer it. `missing` is agent-free a fortiori: there is no endpoint, so there is no agent in it. Widen the existing guards rather than add a verb. - fm-spawn --relaunch accepts a positively proven `missing` and creates one fresh endpoint in the recorded worktree; the record it already republishes rebinds the task to it. A `dead` endpoint is still adopted in place. - fm-control exit reports `endpoint-gone` instead of dying, so the relaunch transaction's stop step no longer dead-ends, and re-resolves the endpoint from the record before verifying the replacement. The duplicate-agent refusal is untouched: both verdicts come from the same recovery-grade classifier, which claims `missing` only from positive absence, so `alive`, `ambiguous`, and `unreadable` all still refuse. The backends' own create paths refuse a live same-labeled endpoint as a second independent guard. The worktree, its branch, commits, uncommitted changes, armed poll and registration, record rows, and status log are all untouched - a reclaim is a recovery, never a teardown. A secondmate is excluded: its gone-endpoint recovery already has one owner in the session-start liveness sweep, so relaunch refuses and names it rather than becoming a second path to the same outcome. Tests reproduce both halves of the deadlock, the reclaim succeeding, unlanded work surviving it, and the refusals that still hold. * no-mistakes(review): prove endpoint absence per backend before reclaim rebinds * no-mistakes(review): give exit and relaunch one absence proof; pin herdr rebind session * no-mistakes(review): narrow endpoint reclaim to herdr; tmux refuses honestly * no-mistakes(review): stop refusals and docs asserting unestablished causes * no-mistakes(review): stop herdr fixture helper losing tmp-root registration * no-mistakes(review): document workspace drift and absence-probe server residue * no-mistakes(review): correct rebind limitation to its one reachable case * no-mistakes(review): stop claiming reclaim leaves instructions untouched * no-mistakes(document): scope fm-control-lib purity claim, note reclaim coverage * no-mistakes(rebase): read the staged launch file in the herdr fixture Rebasing onto main picked up kunchenguid#4994, which stages a long worker launch command into a script and delivers the short `. '<path>'` line instead of the literal command. The tmux fake and tests/fixtures.sh were updated for that; the herdr fake this branch adds was written before it and still keyed "an agent now exists on this pane" off the literal `encode launch-brief` text, so after the rebase it never marked the rebound pane live and the reclaim's alive-wait read `dead`. Dereference the staged file first, exactly as the tmux fake above does. Test-fixture only; no production path changes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * no-mistakes(document): note reclaim placement in herdr and scripts inventories --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
* fix(bin): preserve Claude lock ownership after helper recycling (kunchenguid#4894) * fix(bin): let a background Claude session keep owning its session lock Session-lock ownership was decided by process ancestry alone. Under an unattended Claude session the model loop runs in a transient bg-spare bridged to the front-end by a shared daemon; when that bridge is recycled the contiguous claude-named ancestry from a hook to the recorded owner breaks while the owner pid stays alive, so the Stop auto-arm stood down as a foreign live owner, the turn-end guard ended every turn with its read-only diagnostic, and fm-lock.sh refused - a self-sustaining outage until res
Intent
The main firstmate routed this as a structural order: an endpoint re-binding deadlock is blocking real work across the fleet. I confirmed the deadlock from source before dispatching, so these are verified facts, not a relayed report.
The deadlock, exactly:
deadexactly. Anything else is refused, with advice to "stop the agent first withbin/fm-control.sh <id> exit".missingby dying: "recorded endpoint is gone, so there is no agent to stop; reconcile the task before any further control action".Each command names the other as its prerequisite, so
missingis a terminal state with no way out.Trigger / mask / symptom, kept separate:
missingrather thandead.deadworks perfectly (exit returns already-stopped, relaunch proceeds), so this only bites when the endpoint vanished rather than just its agent. That is why it looks intermittent.Blast radius: 5+ stranded tasks, the fork-converge home's parked gates on fm-zeel and fm-sesh-sync-20260912, and PR 4031's orphaned ask-user gate. This home's own firstmate-endpoint-binding-backfill is the same deadlock, already escalated separately.
What Changed
fm_control_endpoint_absence_verdicttobin/fm-control-lib.shas the single owner of the per-backend proof that an endpoint readingmissingis actually gone rather than merely unreachable: herdr proves it by starting the recorded session's server and re-reading the recorded pane (newfm_backend_herdr_endpoint_absence_recheckinbin/backends/herdr.sh), while tmux always answersunprovenbecause a task record carries no socket identity for its endpoint.bin/fm-spawn.sh --relaunchnow treats a proven-gone endpoint as relaunchable — it mints one fresh tab in the recorded worktree and the recorded herdr session (fm_backend_herdr_container_ensuregained an explicit session parameter) and the republished record rebinds the task to it; secondmate rebinds and every tmuxmissingstill refuse.bin/fm-control.sh exitroutesmissingthrough the same proof and reportsendpoint-goneoralready-stoppedinstead of dying, re-resolves the endpoint after a rebinding launch, and now restores the prior instructions when rollback cannot prove the old agent stopped.docs/agent-control.md, with pointers fromdocs/herdr-backend.md,docs/scripts.md, and the stuck-crewmate-recovery skill; adds 11 cases totests/fm-control-relaunch.test.sh(tmux refusals, herdr adopt-vs-rebind, recorded-session pinning, task-wholeness, secondmate refusal) and rewrites the tmuxmissingcase intests/fm-control.test.shto assert refusal with nothing sent.Risk Assessment
✅ Low: The reclaim is tightly gated - absence is re-proven per backend before any rebind, herdr reads are pinned to the recorded session, tmux and secondmates refuse, and the relaunch transaction re-resolves its endpoint through the same shared validation - with new behavior-level tests covering adopt, rebind, returning-agent refusal, and task-integrity, leaving only two non-behavioral wording defects in explanatory text.
Testing
Ran both targeted suites green (
tests/fm-control-relaunch.test.sh,tests/fm-control.test.sh, no skips), then proved the intent at the CLI level by replaying the same stranded herdr task through the realfm-control.sh/fm-spawn.shon the base tree and the fix: base reproduces the exact circular deadlock (exitsays reconcile first,relaunchsays stop the agent first), while the fix reportsendpoint-gone, rebinds the task to a fresh pane in its recorded session, and leaves the worktree, uncommitted work, status log and armed check whole. Also captured the duplicate-agent guardrails (surviving pane adopted, returning agent refused, tmuxmissingrefused with its note rolled back) and a per-test fail-before/pass-after matrix in which 10 of the 11 new reclaim tests fail on base and pass on target. No product failures; the one fix I made was to a stale evidence script whose herdr stub predated the base's staged-launch-file delivery. This change has no UI surface, so the reviewer-visible evidence is CLI transcripts rather than screenshots.Evidence: Operator transcript - the deadlock on base 90cd351
Source: Operator transcript - the deadlock on base 90cd351a
$ bin/fm-control.sh fmzeela exit error: task fmzeela's recorded endpoint is gone, so there is no agent to stop; reconcile the task before any further control action -> exit 1 $ bin/fm-spawn.sh fmzeelb --relaunch --harness claude error: task fmzeelb's endpoint reads 'missing'; a relaunch requires a positively agent-free endpoint (stop the agent first with bin/fm-control.sh fmzeelb exit) -> exit 1 $ bin/fm-control.sh fmzeelc relaunch --note "the pane was destroyed; pick the work back up" error: task fmzeelc's recorded endpoint is gone, so there is no agent to stop; reconcile the task before any further control action error: relaunch of fmzeelc failed while stopping the old agent and its state is 'missing'; the durable record and progress note were retained for recovery -> exit 1Evidence: Operator transcript - the reclaim on target 8b2d669
Source: Operator transcript - the reclaim on target 8b2d6692
$ bin/fm-control.sh fmzeela exit endpoint-gone fmzeela harness=claude backend=herdr endpoint=fmlab:%7 worktree=.../wt -> exit 0 $ bin/fm-spawn.sh fmzeelb --relaunch --harness claude spawned fmzeelb harness=claude kind=ship mode=no-mistakes yolo=off window=fmlab:%9 worktree=.../wt -> exit 0 $ bin/fm-control.sh fmzeelc relaunch --note "the pane was destroyed; pick the work back up" relaunched fmzeelc harness=claude from=claude model=default effort=default backend=herdr endpoint=fmlab:%9 worktree=.../wt -> exit 0 the task afterwards: record: window=fmlab:%9 record: herdr_session=fmlab record: herdr_pane_id=%9 worktree HEAD unchanged: yes branch: task-fmzeelc uncommitted change: uncommitted change the agent never got to save status log: working: parked on a no-mistakes approval nobody can answer progress note in brief: delivered to the replacement herdr calls the reclaim made (all scoped to the RECORDED session fmlab): pane get %7 --session fmlab tab create --workspace wsnew --cwd .../wt --label fm-fmzeelc --no-focus --session fmlab pane send-text %9 . '/tmp/fm-fmzeelc+.../launch.sh' --session fmlabEvidence: Reclaim guardrails - adopt, refuse-alive, tmux refuses
Source: Reclaim guardrails - adopt, refuse-alive, tmux refuses
CASE 1 - server was STOPPED; the recorded pane survives a restart $ bin/fm-control.sh idle1 exit already-stopped idle1 ... endpoint=fmlab:%7 [exit 0] $ bin/fm-control.sh idle1 relaunch --note "server bounced; carry on" relaunched idle1 ... endpoint=fmlab:%7 [exit 0] endpoint after : fmlab:%7 (unchanged - the pane was ADOPTED) tabs created : none - no second tab beside the surviving pane CASE 2 - the server comes back and so does the AGENT $ bin/fm-spawn.sh back1 --relaunch --harness claude error: task back1's endpoint reads 'alive'; a relaunch requires a positively agent-free endpoint [exit 1] endpoint after : fmlab:%7 (record untouched) tabs created: none CASE 3 - a TMUX window absent from a readable inventory $ bin/fm-control.sh tmux1 exit error: task tmux1's endpoint fmses:fm-tmux1 reads 'missing', but tmux absence cannot be proven from a task record ...; exit will not claim an agent stopped at an address it cannot trust [exit 1] $ bin/fm-control.sh tmux1 relaunch --note "this note must never reach a live agent" error: ... its original instructions were restored and the durable record was retained for recovery [exit 1] windows created: none bytes sent into any pane: none instructions : byte-identical - the progress note was rolled backEvidence: Fail-before / pass-after matrix for the 11 new reclaim tests
Source: Fail-before / pass-after matrix for the 11 new reclaim tests
test BASE TARGET test_tmux_refuses_a_window_missing_from_its_session FAIL pass test_tmux_refuses_a_session_that_cannot_be_found FAIL pass test_tmux_refuses_when_the_server_is_gone FAIL pass test_reclaim_refuses_an_unreadable_endpoint pass pass test_herdr_reclaim_adopts_a_pane_that_outlived_its_server FAIL pass test_herdr_exit_reports_already_stopped_when_the_pane_outlived_its_server FAIL pass test_herdr_rebind_stays_in_the_recorded_session FAIL pass test_herdr_reclaim_refuses_an_agent_that_came_back FAIL pass test_herdr_reclaim_keeps_the_task_whole FAIL pass test_herdr_reclaim_of_a_secondmate_names_its_own_owner FAIL pass test_herdr_rebind_failure_from_a_plain_shell_names_the_real_cause FAIL passEvidence: Replayable driver behind the before/after transcripts
Source: Replayable driver behind the before/after transcripts
Evidence: Evidence index (names which transcripts are current for 8b2d669)
Source: Evidence index (names which transcripts are current for 8b2d6692)
Pipeline
Updates from git push no-mistakes
... (7 earlier update rounds omitted to keep the PR body within GitHub's 65536-char limit; full history is in the run log.)
🔧 Fix: narrow endpoint reclaim to herdr; tmux refuses honestly
3 issues (2 warnings, 1 info) still open:
bin/fm-spawn.sh:2894- The rebind refusal asserts a cross-session cause that its condition does not establish, misdirecting the operator on the exact recovery path this change exists to enable.HERDR_AMBIENT_SES=$(fm_backend_herdr_session)returns the literal stringdefaultwhen the process is in no herdr pane at all (bin/backends/herdr.sh:546,${HERDR_SESSION:-default}), so the inequality is true for EVERY task recorded on a named session whenever the reclaim runs from a plain shell. Concrete case: a task recordedherdr_session=fmlab, reclaimed from an ssh/cron seat with no HERDR_* env, wherefm_backend_herdr_container_ensurefails becauseworkspace createreturned an error (bin/backends/herdr.sh:1989).fm_backend_herdr_launcher_identityreturned 2 there, not 1 (bin/backends/herdr.sh:1752) - cross-session launcher identity was never consulted - yet the operator is told "this seat is running in herdr session 'default', and a reclaim never moves a task to another session", implying they should re-run from a seat infmlab, which neither describes what failed nor would fix it. The condition should additionally require that this process actually claims a launcher pane, i.e.[ -n "$RELAUNCH_LAUNCHER_PANE_ID" ] && [ "$HERDR_AMBIENT_SES" != "$HERDR_REBIND_SES" ], falling through to the accurate "see the refusal above" branch otherwise. docs/agent-control.md:112 carries the same overstatement ("A seat that cannot prove it belongs to the recorded session is refused rather than allowed to place the endpoint somewhere else"): a seat with no herdr pane cannot prove membership and is NOT refused - it proceeds through the label search and places the tab in the recorded session - so that sentence should be corrected alongside the message.docs/agent-control.md:119- The documented known limitation states a failure mode the code contradicts, so it gives operators manual-cleanup guidance for a leak that self-heals. Line 119 claims "Retrying the reclaim proves the old pane absent again and mints another pane, leaving the previous one too, so the leak compounds one pane per attempt", and line 120 instructs "Close the stray panes by hand". On retry,fm_backend_herdr_create_tasklists the workspace's tabs and finds the leaked tab, which carries the samefm-<id>label it was minted with (bin/fm-spawn.sh:2905 passes$W), then callsfm_backend_herdr_tab_is_husk(bin/backends/herdr.sh:2296). The stray pane holds a bare shell with no agent registration, sofm_backend_herdr_pane_agent_statereturnsno-agent(bin/backends/herdr.sh:2274), which IS a husk, and create_task closes and replaces it (bin/backends/herdr.sh:2475-2497). The retry therefore leaves exactly zero extra panes, not one more. The paragraph's stated trigger is also the least reachable one: the worktree-position check it names (bin/fm-spawn.sh:3423) runs against a tab thattab create --cwd "$WT"already opened in the recorded worktree. The honest limitation is narrower - a refusal AFTER the harness has started leaves alivepane that is not a husk, which makes the next create_task refuse outright with "herdr tab ... already exists" rather than compound. Correct the paragraph (and thefm-herdr-rebind-leak-20260913bead's premise) to describe that, and drop the by-hand cleanup instruction for the shell-only case.tests/fm-control-relaunch.test.sh:1815- Three of the six new herdr cases inline the four-line setup thatherdr_case_or_skip(line 1905) was added in the same change to encapsulate:test_herdr_reclaim_adopts_a_pane_that_outlived_its_server(1815-1823),test_herdr_exit_reports_already_stopped_when_the_pane_outlived_its_server(1854-1862), andtest_herdr_rebind_stays_in_the_recorded_session(1875-1886) each repeat the jq guard,new_case,add_herdr_ship_task, andmake_herdr_stubcalls, while the other three use the helper. Routing all six throughherdr_case_or_skipremoves the duplication without changing any assertion, and keeps the skip message in one place.🔧 Fix: stop refusals and docs asserting unestablished causes
1 warning still open:
tests/fm-control-relaunch.test.sh:1819-herdr_case_or_skipcommunicates the case directory on stdout, so every one of its seven call sites invokes it asdir=$(herdr_case_or_skip ...)(lines 1830, 1866, 1888, 1911, 1933, 1987, 2005). That runsadd_herdr_ship_task(line 1823) inside a command-substitution subshell, where itsTASK_TMPS+=("/tmp/fm-$id")at line 1816 mutates a copy of the array and is discarded on subshell exit. The suite's EXIT trap (relaunch_cleanup, line 40) iteratesTASK_TMPSprecisely to remove the out-of-tmproot/tmp/fm-<id>roots thatbin/fm-spawn.sh:3576creates (mkdir -p "$TASK_TMP/gotmp"), so the three herdr cases that reach a real spawn - rl68 (adopt), rl73 (rebind), rl75 (full relaunch) - now leave/tmp/fm-rl68,/tmp/fm-rl73, and/tmp/fm-rl75behind after the suite passes. The tmux cases are unaffected becauseadd_ship_task(line 216) is still called as a plain statement. Fix by having the helper communicate through a global (e.g. setHERDR_CASE_DIRandreturn 0, called as a plain statement) or by registering the tmp root in the caller, so the array mutation happens in the test shell. Note the earlier round's finding asked for exactly this consolidation; the helper itself is right, only its subshell invocation shape defeats the cleanup trap.🔧 Fix: stop herdr fixture helper losing tmp-root registration
2 infos still open:
bin/fm-spawn.sh:2886- The rebind pins the herdr SESSION but not the WORKSPACE, so a reclaim run from a seat inside the recorded session silently relocates the task's container.HERDR_REBIND_SESis threaded intofm_backend_herdr_container_ensurespecifically so the tab cannot land on another server, but the relationship stayslauncher-home, sofm_backend_herdr_workspace_ensure(bin/backends/herdr.sh:1963-1972) short-circuits onfm_backend_herdr_launcher_identityreturning 0 and usesFM_BACKEND_HERDR_LAUNCHER_WORKSPACE_ID— the reclaiming seat's own workspace — never the recordedherdr_workspace_id, even when that workspace still exists and only the pane was destroyed. Concretely: task recorded atfmlab:%7withherdr_workspace_id=ws1; pane%7destroyed,ws1intact; firstmate reclaims from its own herdr pane inws9(same sessionfmlab); launcher_identity returns 0 withws9,create_taskopensfm-<id>there, and the record republishesherdr_workspace_id=ws9. The record stays self-consistent and no work is lost, so this is not a wrong result — but it is the path docs/agent-control.md:113 actively recommends ("reclaim such a task from a seat in the recorded session"), and that doc only promises the session is preserved, saying nothing about the workspace moving. Either pin the recorded workspace when it is still present, or state in that paragraph that the workspace follows the reclaiming seat. Flagging rather than fixing because the choice oflauncher-homelooks deliberate (it matches the ordinary spawn placement rule) and pinning the workspace would add new validation logic beyond this change's stated intent.bin/backends/herdr.sh:2386- The absence proof makesfm-control.sh <id> exitstart a herdr daemon as a side effect, and for a session that no longer exists that daemon is left behind empty.fm_backend_herdr_endpoint_absence_recheckcallsfm_backend_herdr_server_ensure "$FM_BACKEND_HERDR_SESSION", which launchesherdr server --session <name>whenstatus --jsonreportsrunning:false(bin/backends/herdr.sh:1656-1672). Trace: the recorded sessionfmlaband its server were destroyed outright (the "session restart" trigger named in the intent); an operator runsexitto see whether the agent stopped;server_ensurestands up a brand-new emptyfmlabserver,pane get %7answerspane_not_found, the verdict isgone, andexitprintsendpoint-gone. The verdict is correct — a destroyed session does mean a destroyed pane — but a fresh idle herdr server for every destroyed session name is now created by a command that reads as read-only, and unlike the relaunch path nothing ever uses it. docs/agent-control.md:99 does disclose that the recheck "starts that server", though its parenthetical "(only the server: nothing is created)" is about workspaces and tabs and does not cover the residue. Worth either a sentence in that paragraph or accepting it explicitly. Not auto-fixable: stopping a server the probe started would require tracking whether this process started it, which is new state beyond the change's intent.🔧 Fix: document workspace drift and absence-probe server residue
1 warning still open:
docs/agent-control.md:121- The "Known limitation" paragraph (lines 121-126) documents a failure state the code cannot reach, and gives operator advice that is harmful in the state it names. The replacement record is republished at bin/fm-spawn.sh:4153 (fm_backlog_atomic_transition publishinside theRELAUNCH -eq 1block), and the harness launch is not delivered until bin/fm-spawn.sh:4336 (spawn_send_literal "$T" "$LAUNCH"); the only sends in between are shellexportlines. So the combination the paragraph describes - a stray pane that readslivewhile "the record still names the old, gone one" - is unreachable: by the time any harness is running, the record already names the new pane. Concrete trace: task rl75 recorded atfmlab:%7, pane destroyed; reclaim mintsfmlab:%9at fm-spawn.sh:2912, publisheswindow=fmlab:%9at 4153, launches claude at 4336, then agy/kimi/rovo readiness (or fm-control'swait_agent_state alive) refuses. Next attempt:fm_backend_validate_task_endpointresolvesfmlab:%9,fm_backend_agent_statereadsalive, fm-spawn.sh:1418'scasetakes the*branch ("endpoint reads 'alive'"), andbin/fm-control.sh <id> relaunchsucceeds normally by stopping that agent and adopting the pane - nothing is blocked and herdr'stab already existsis never reached, because the rebind gate is only entered onmissing. Following line 126 ("Close that one pane before retrying") in that state kills a running replacement agent that the record correctly points at. Only line 124 is accurate: a refusal in the window betweentab create(2912) and publication (4153) leaves a bare-shell pane, whichfm_backend_herdr_create_taskclassifies as a husk and replaces on the next attempt - and even that self-heals only when the retry resolves the same workspace, which docs line 116 already says is not guaranteed (the container follows the reclaiming seat). Remedy is a correction, not new machinery: restate the limitation as "a refusal before the record is republished leaves a stray husk pane, which the next reclaim from the same workspace closes and replaces", and drop the unreachable live-pane case and its close-the-pane instruction.🔧 Fix: correct rebind limitation to its one reachable case
3 issues (2 warnings, 1 info) still open:
docs/agent-control.md:109- The "What a reclaim is not" bullet states that on a reclaim "The task id, its instructions, its armed poll and registration, and its status log are untouched", but the instructions ARE rewritten on every ship/scout reclaim.record_note(bin/fm-control.sh:827-847) copiesdata/<id>/brief.mdto$BRIEF_PRIORand appends a## Progress note (<ts>)block plus the--notetext to it beforedo_exitis ever called, and that happens on the reclaim path exactly as on an ordinary relaunch. This change's own test proves it: tests/fm-control-relaunch.test.sh assertsassert_contains "$(cat "$dir/home/data/rl75/brief.md")" "the pane was destroyed"("the replacement must inherit the progress note") intest_herdr_reclaim_keeps_the_task_whole. Concrete consequence: an operator reading line 109 before reclaiming a task with a stranded approval gate concludes the brief is byte-identical afterwards and does not re-read it, yet the brief now carries an appended note and, after a failed-then-retried reclaim, more than one. The bullet two lines above already acknowledges "the ordinary--noterequirement still applies", so the fix is to dropits instructionsfrom the untouched list (the note append is the ordinary relaunch contract, not something the reclaim adds).bin/fm-control-lib.sh:265- The deadlock the intent names remains fully in place for tmux, which is the DEFAULT backend for any task record without abackend=line (bin/fm-backend.sh:case "$backend_count" in 0) backend=tmux). For those tasksfm_control_endpoint_absence_verdictreturnsunprovenunconditionally, soexitstill dies (bin/fm-control.sh:513) andrelaunchstill dies (bin/fm-spawn.sh:1413) - the exact "each command names the other as its prerequisite" state the intent asks to break, with no reconcile verb added. The stated justification is also narrower than the rest of the control plane: the refusal argues "a window absent from it may still be alive on another" tmux server, but bin/backends/tmux.sh addresses every endpoint through the AMBIENT socket with no-S/TMUX_TMPDIRfrom the record (tmux send-keys -t "$1"at lines 50/113/121,tmux list-windows -t "$session"at line 266). The adjacent, unchanged tmuxdeadpath already launches a brand-new agent into$RELAUNCH_TARGETover that same ambient socket on exactly the same assumption, somissingis being held to a stricter standard than the duplicate-agent risk it is defending against. Trace: taskfm-zeelrecordedwindow=fmses:fm-zeelwith nobackend=row; its window is destroyed;bin/fm-control.sh fm-zeel exit->agent_state=missing -> tmux verdictunproven-> die;bin/fm-control.sh fm-zeel relaunch --note ...-> same -> die. Still stranded. Flagging rather than fixing because the remedy is a scope decision, not a correction: either accept the same ambient-socket assumption thedeadpath already makes, or add socket identity to the task record - the latter is new durable record state beyond this change's stated intent. Please confirm the tasks named in the intent's blast radius (fm-zeel, fm-sesh-sync-20260912, PR 4031's gate, firstmate-endpoint-binding-backfill) are all herdr-backed; if any are tmux, this change does not unblock them.bin/fm-spawn.sh:2909- The rebind branch (lines 2909-2921) re-implements the flat herdr container/task sequence that already exists at lines 3086-3098: the same${RAW%%$'\t'*}/${RAW#*$'\t'}split offm_backend_herdr_container_ensure's output, the sameHERDR_SES/HERDR_WORKSPACE_IDderivation, the samecreate_taskcall threading the seeded default tab id, the sameread -r HERDR_TAB_ID HERDR_PANE_IDheredoc, and the same empty-id refusal with a byte-identical message. Only two things differ (the create_task cwd is$WTrather than$PROJ_ABS, and noFM_HOMEshadow is needed because secondmate rebinds are refused upstream). The seeded-tab split is a contract thatfm_backend_herdr_create_taskis the sole permitted pruner of, so having two copies of it is the kind of thing that drifts silently. No defect today - both copies are currently correct. Noting only; a shared helper taking (cwd-for-workspace, create-task-cwd, session) would collapse them, but that is refactoring beyond this change's scope.🔧 Fix: stop claiming reclaim leaves instructions untouched
2 infos still open:
ℹ️
bin/fm-spawn.sh:2874- The KNOWN LIMITATION comment on the rebind branch says a refusal "leaves that pane behind and a retry mints another", implying the stray-pane leak accumulates per attempt. docs/agent-control.md:127-129 - the file this comment explicitly defers to - says the opposite: the next reclaim'stab createfinds the samefm-<id>label, classifies it a husk, and closes and replaces it, so it self-heals whenever the retry resolves the same workspace. The doc is the accurate one: fm_backend_herdr_create_task (bin/backends/herdr.sh:2449-2459) collects same-labelled tabs, checks each via fm_backend_herdr_tab_is_husk, and a stray rebind pane holds a bare shell (the harness is not delivered until bin/fm-spawn.sh:4336, long after the tab is minted at 2913), so fm_backend_herdr_pane_agent_state returnsno-agentand the tab is closed after the replacement exists. Consequence: whoever picks up bead fm-herdr-rebind-leak-20260913 from this comment sizes the leak as unbounded growth per failed attempt, when the only real residue is one pane per workspace a retry fails to re-resolve. Remedy is a comment correction only - restate it to match the doc (residue persists only across a workspace change), no code change.ℹ️
bin/fm-control-lib.sh:249- The tmuxunprovenrationale - in the header comment here and in the refusal string at line 266 ("a server-wide window inventory only describes the tmux server this process addresses"), mirrored at docs/agent-control.md:97 as "list-windows -a" - names a read the absence classifier does not perform. fm_backend_tmux_agent_state runstmux list-windows -t "$session"(bin/backends/tmux.sh:266), a per-session inventory. The only-areads in the tree are fm_backend_tmux_find_window (bin/backends/tmux.sh:35) and bin/fm-supervise-daemon.sh:1217, neither of which feeds this proof. The socket-scoping conclusion is unaffected, but the per-session form has an additional failure mode the "server-wide" framing obscures: a renamed session fails the read even on a server this process can reach. docs/agent-control.md:99 already lists "a renamed session" among the refused cases, so only the named command is wrong. This matters because this text is the stated justification for leaving tmux deadlocked and is the starting point for follow-up bead fm-es2ri. Remedy is a wording correction in the comment, the refusal string, and the doc sentence - name the per-session inventory the classifier actually reads; no behavior change.ℹ️
bin/fm-control-lib.sh:270- The tmuxunprovenrationale names a read the absence classifier never performs. The operator-facing refusal string here says "a server-wide window inventory only describes the tmux server this process addresses", the header comment at bin/fm-control-lib.sh:254 says "list-windows -adescribes only the server the CURRENT process addresses", and docs/agent-control.md:101 repeats "list-windows -a". What actually produces themissingverdict isfm_backend_tmux_agent_state(bin/backends/tmux.sh:322) callingfm_backend_tmux_window_inventory(bin/backends/tmux.sh:146), which runstmux list-windows -t "$session"at bin/backends/tmux.sh:148 - a PER-SESSION inventory. The only-areads in the tree arefm_backend_tmux_find_window(bin/backends/tmux.sh:35) and bin/fm-supervise-daemon.sh:1217, neither of which feeds this proof. The socket-scoping conclusion still stands, but the "server-wide" framing hides a second failure mode the per-session read has: it also returns status 2 (can't find session:) for a renamed session on a server this process CAN reach - which this branch's own test test_tmux_refuses_a_session_that_cannot_be_found stages deliberately, and which docs/agent-control.md:104 already lists among the refused cases. Concrete consequence: this text is the stated justification for leaving tmux deadlocked and the starting point for follow-up bead fm-es2ri, so whoever picks that bead up goes looking for a socket-scoping fix to a server-wide read that is not the read being made. Remedy is wording in three places - the comment, the refusal string, and the doc sentence - naming the per-session inventory the classifier actually reads; no behavior change.ℹ️
bin/fm-spawn.sh:3156- The KNOWN LIMITATION comment on the rebind branch contradicts the document it explicitly defers to. It says the minted tab "is registered with no abort cleanup, so a later refusal leaves that pane behind and a retry mints another", which reads as residue accumulating once per failed attempt. docs/agent-control.md:127-129 says the opposite and is the accurate one: the next reclaim'stab createfinds the samefm-<id>label, classifies it a husk, and closes and replaces it, so it self-heals whenever the retry resolves the same workspace. Verified against source:fm_backend_herdr_create_task(bin/backends/herdr.sh:2444) collects every same-labelled tab in the target workspace and tests each withfm_backend_herdr_tab_is_husk(bin/backends/herdr.sh:2296), which acceptsdeadandno-agent; a stray rebind pane holds a bare shell because the harness is not delivered until long after the tab is minted at bin/fm-spawn.sh:3197, sofm_backend_herdr_pane_agent_statereturnsno-agentand the husk is closed after the replacement tab exists. Concrete consequence: whoever picks up bead fm-herdr-rebind-leak-20260913 from this comment sizes the leak as unbounded per-attempt growth, when the only real residue is one pane per workspace a retry fails to re-resolve. Remedy is a comment correction restating it to match the doc (residue persists only across a workspace change); no code change.✅ **Test** - passed
✅ No issues found.
bash tests/fm-control-relaunch.test.sh- 64 assertions, exit 0 (includes the 11 new reclaim/refusal tests)bash tests/fm-control.test.sh- 35 assertions, exit 0bash tests/fm-backend-herdr.test.sh- 206 assertions, exit 0 (covers the changedfm_backend_herdr_container_ensuresignature on the ordinary spawn path)Manual CLI evidence:reclaim-demo.shdrives the realbin/fm-control.sh <id> exitandbin/fm-control.sh <id> relaunch --note ...against a hermetic herdr fixture (destroyed panefmlab:%7, session server up), run once against agit archiveexport of base b182d0f and once against the worktreeManual CLI evidence:guardrails-demo.shruns three refusal/adoption transcripts on the fixed tree - stopped-server pane adoption,bin/fm-spawn.sh <id> --relaunchagainst a returned agent, and tmuxmissingon both verbs with a brief byte-identity checkFail-before/pass-after matrix: each new test run individually from the same test file against both trees (head -2066 tests/fm-control-relaunch.test.sh+ one test name)✅ No issues found.
bash tests/fm-control-relaunch.test.sh- full file, 67 assertions pass, exit 0 (includes all 11 new reclaim tests)bash tests/fm-control.test.sh- full file, 35 assertions pass, exit 0 (includes the rewrittentest_missing_tmux_endpoint_refuses_rather_than_claiming_a_stop)Operator transcript on the BASE tree (git archive 90cd351ainto a temp root):bin/fm-control.sh <id> exit,bin/fm-spawn.sh <id> --relaunch --harness claude,bin/fm-control.sh <id> relaunch --note ...against a herdr task whose recorded panefmlab:%7answerspane_not_foundon a running server - all three refuse, each naming the other as prerequisiteSame three commands on the TARGET tree, each against its own fresh copy of the stranded task -endpoint-gone(exit 0), rebind tofmlab:%9(exit 0), andrelaunched ... endpoint=fmlab:%9(exit 0)Post-reclaim record and worktree inspection:window=/herdr_session=/herdr_pane_id=rows,git rev-parse HEADunchanged, branch stilltask-<id>, uncommitted file intact, status log intact, progress note present inbrief.mdHerdr call log assertion that every call the reclaim made carries--session fmlab(the recorded session), never the ambientdefaultGuardrail transcripts on the target tree: stopped-server pane ADOPTED atfmlab:%7with no second tab; returning agent refused withendpoint reads 'alive'; tmuxmissingrefused on both verbs with instructions restored byte-exact and nothing sent into any panePer-test fail-before/pass-after matrix: each of the 11 reclaim tests invoked individually from the target's test file against both trees - 10 FAIL on base / pass on target, 1 passes on both🔧 **Document** - 1 issue found ✅
docs/tmux-backend.md:53- Terminology overlap worth a follow-up, not fixed here. docs/tmux-backend.md:53 states "Onlydeadandmissingauthorize recovery because a false dead result could launch a duplicate agent." That sentence is about which liveness verdicts recovery paths may act on at all, and it remains true of the session-start secondmate liveness sweep (bin/fm-bootstrap.sh relaunches fromdeadormissing). But this change added the opposite-sounding statement for the control plane in the new owner text - docs/agent-control.md:82 and :155, "On tmux, both verbs refuse amissingendpoint" - so a reader who lands on tmux-backend.md first can conclude thatbin/fm-control.sh <id> exit|relaunchwill act on a tmuxmissingendpoint, which it never does. tmux behavior itself is unchanged by this branch, so I left the sentence alone rather than rewriting another doc's ownership claim; the minimal follow-up is one clause there distinguishing the sweep from the control plane, or a pointer to docs/agent-control.md "Reclaiming a task whose endpoint is gone".✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
✅ No issues found.