Skip to content

fix: require durable leases for dead-endpoint relaunches - #150

Merged
dnth merged 8 commits into
mainfrom
fm/fm-relaunch-dead-endpoint
Sep 19, 2026
Merged

dnth merged 8 commits into
mainfrom
fm/fm-relaunch-dead-endpoint

Conversation

@dnth

@dnth dnth commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

Intent

Captain decision 2026-09-19: require the durable fm- Treehouse lease as the sole worktree-ownership proof on the dead-endpoint relaunch path - relaunch_worktree_lease_proven must refuse a same-task .fm-slot-owner claim that lacks a live lease; fix lands on this branch into PR #150 before merge

What Changed

  • Require a live durable Treehouse fm-<id> lease before reusing a recorded worktree during dead-endpoint relaunches, rejecting same-task slot claims without lease proof.
  • Harden relaunch endpoint handling across tmux, Herdr, zellij, cmux, and related control paths, including fail-closed absence and live-endpoint checks.
  • Add extensive relaunch/backend regression coverage and update runtime and spawn-relaunch verification documentation.

Risk Assessment

⚠️ Medium: The change is source-consistent with the durable-lease requirement and adds guarded recovery paths across several runtime backends, but its broad backend-specific control flow carries moderate inherent complexity.

Testing

Ran the focused end-to-end relaunch harness against the real shell product. All scenarios passed, including durable lease success and refusal of a same-task slot-owner marker without a live lease. Evidence was saved to the dedicated evidence directory.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Durable lease permits relaunch into the recorded worktree ✅ pass live bash tests/fm-spawn-relaunch-dead-endpoint.test.sh
Same-task slot-owner claim without a durable lease is refused ✅ pass live bash tests/fm-spawn-relaunch-dead-endpoint.test.sh
Control relaunch completes for a proven-missing endpoint ✅ pass live bash tests/fm-spawn-relaunch-dead-endpoint.test.sh
Foreign, unowned, ambiguous, live, and non-pool states fail closed ✅ pass live bash tests/fm-spawn-relaunch-dead-endpoint.test.sh
Herdr, Zellij, cmux, and Orca backend-specific relaunch guards behave safely ✅ pass live bash tests/fm-spawn-relaunch-dead-endpoint.test.sh
Evidence: Dead-endpoint relaunch E2E transcript
ok - fm-spawn --relaunch: proven-missing tmux endpoint recreates the window in the recorded worktree
ok - fm-spawn --relaunch: a durable fm-<id> Treehouse lease proves worktree ownership
ok - fm-spawn --relaunch: a slot-owner claim without a durable lease refuses
ok - fm-control relaunch: a proven-missing endpoint counts as already stopped and the transaction completes
ok - fm-spawn --relaunch: a live endpoint in a foreign cwd still refuses
ok - fm-spawn --relaunch: a live agent at the recorded endpoint still refuses
ok - fm-spawn --relaunch: an ambiguous endpoint state still refuses
ok - fm-spawn --relaunch: a proven-gone endpoint with a non-pool worktree refuses
ok - fm-spawn --relaunch: a slot claimed by another task refuses
ok - fm-spawn --relaunch: a worktree with no ownership evidence refuses
ok - fm-spawn --relaunch: a worktree leased to another task refuses
ok - fm-spawn --relaunch: a stopped herdr session server recreates the endpoint in the worktree
ok - fm-spawn --relaunch: a drifted herdr shell gets one cd back to the worktree
ok - fm-spawn --relaunch: a herdr shell that cannot return to the worktree refuses
ok - fm-spawn --relaunch: a proven-absent zellij endpoint recreates the tab in the worktree
ok - fm-spawn --relaunch: a live zellij endpoint still refuses
ok - fm-spawn --relaunch: a proven-absent cmux endpoint recreates the workspace in the worktree
ok - fm-spawn --relaunch: a live cmux endpoint still refuses
ok - fm-spawn --relaunch: orca remains refused
ok - all dead-endpoint relaunch tests

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - medium risk

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Durable lease permits relaunch into the recorded worktree ✅ pass live bash tests/fm-spawn-relaunch-dead-endpoint.test.sh
Same-task slot-owner claim without a durable lease is refused ✅ pass live bash tests/fm-spawn-relaunch-dead-endpoint.test.sh
Control relaunch completes for a proven-missing endpoint ✅ pass live bash tests/fm-spawn-relaunch-dead-endpoint.test.sh
Foreign, unowned, ambiguous, live, and non-pool states fail closed ✅ pass live bash tests/fm-spawn-relaunch-dead-endpoint.test.sh
Herdr, Zellij, cmux, and Orca backend-specific relaunch guards behave safely ✅ pass live bash tests/fm-spawn-relaunch-dead-endpoint.test.sh
  • bash tests/fm-spawn-relaunch-dead-endpoint.test.sh
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

A task whose recorded endpoint disappears (ic-prod-outage-astra-fix,
2026-09-17) could not be relaunched: fm-spawn --relaunch probed the dead
pane's cwd, read empty, and refused, while fm-control relaunch refused
earlier with "no agent to stop" - leaving an intact leased worktree
unreachable through any supported path.

Port the upstream herdr recovery (commit 3e817d3, PR kunchenguid#4120, issue
kunchenguid#4091): an uninterpretable pane read upgrades to `missing` only when
`herdr status --json` positively reports .server.running false, rather
than trusting the version-fragile per-pane error code; a drifted live
shell gets one `cd` back to the recorded worktree before refusing.

fm-spawn --relaunch now classifies the recorded endpoint first: tmux
and herdr use the recovery-grade agent_state (only `missing` is gone),
while zellij and cmux use a new fm_backend_endpoint_absent structural
proof (recorded session/workspace and pane/surface verifiably gone,
with a reused id in another task's tab counting as absent). A proven-
gone endpoint skips the impossible cwd probe and is recreated inside
the recorded worktree - but only after the task proves it still owns
that worktree through its .fm-slot-owner claim or its durable fm-<id>
Treehouse lease. Live agents, ambiguous/unreadable/unverified states,
foreign worktrees, and unprovable ownership all still refuse, and orca
stays refused.

fm-control relaunch treats a proven-missing endpoint as already
stopped - there is no agent to exit - journals the verdict, and
continues the transaction so the launch owner recreates the endpoint;
the same brief and progress note are preserved throughout.
@dnth
dnth force-pushed the fm/fm-relaunch-dead-endpoint branch from bc04b64 to 39ebd76 Compare September 18, 2026 23:56
@dnth dnth changed the title fix: recover relaunches from dead agent endpoints fix(spawn): recover dead endpoints with lease-verified worktrees Sep 18, 2026
@dnth dnth changed the title fix(spawn): recover dead endpoints with lease-verified worktrees fix: require durable leases for dead-endpoint relaunches Sep 19, 2026
@dnth
dnth merged commit 898f45d into main Sep 19, 2026
30 of 31 checks passed
@dnth
dnth deleted the fm/fm-relaunch-dead-endpoint branch September 19, 2026 03:03
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