Skip to content

fix(bin): lease and refresh the task copy before any worker shell enters it - #3529

Open
rahul2393 wants to merge 6 commits into
kunchenguid:mainfrom
rahul2393:fm/fm-herdr-freshen-before-enter-h1
Open

fix(bin): lease and refresh the task copy before any worker shell enters it#3529
rahul2393 wants to merge 6 commits into
kunchenguid:mainfrom
rahul2393:fm/fm-herdr-freshen-before-enter-h1

Conversation

@rahul2393

Copy link
Copy Markdown

Summary

bin/fm-spawn.sh created the task pane, typed treehouse get into it, and only then refreshed the pooled copy. The new shell's git prompt and the refresh both took the worktree's index.lock under the shared .git/worktrees/, so on a large repository (google-cloud-java) the refresh was refused and every Herdr spawn failed.

Spawn now leases the copy from its own process with treehouse get --lease, refreshes it with no shell inside, and creates the pane already in that path on every session-provider backend (tmux, herdr, zellij, cmux). Orca owns its own worktree and is untouched.

Behavior

  • A refusal before any backend create call returns a clean lease to the pool; from the first create call on, the lease is retained and its release command reported, because treehouse return terminates every process still in the copy.
  • A dirty copy is never reset. A reused recovery copy additionally refuses when its HEAD holds commits no remote has, rechecked after a pruned all-origin fetch immediately before the reset.
  • A fresh spawn whose durable record still names a copy (exact Herdr presentation recovery for the same task, project, kind, backend, and endpoint) refreshes that copy instead of leasing another. Recovery classifies the recorded endpoint first and moves any surviving agent-free shell out of the copy before the refresh; a reclaimed pane is sent one plain cd into the copy after it.
  • bin/fm-teardown.sh concludes the task's parked run and closes the endpoint before the cwd-rooted process reap and the copy's treehouse return, so the planned focus-preserving Herdr close still runs. The tmux process-group fallback binds a captured PGID to member identities before signalling. Teardown still returns the lease.

Tests

  • New tests/fm-spawn-lease-before-enter.test.sh: refresh completes before any pane exists; a simulated pane index.lock cannot refuse a clean copy (divergence asserted); clean-lease return, retained lease after create began, dirty copy untouched, unusable lease path, and recovery-identity refusals.
  • tests/fm-backend-herdr-presentation-e2e.test.sh audits the real pane removal and focus transition, arms the post-create abort on the settle read, and asserts copy reuse on reclaim.
  • Spawn-shaped suites use a shared leasing treehouse stub from tests/lib.sh. bin/fm-lint.sh passes.

…ers it

fm-spawn.sh created the task pane, typed `treehouse get` into it, and only
then refreshed the copy. The new shell's git prompt and the refresh both took
the worktree's index.lock under the shared .git/worktrees/, so on a large
repository the refresh was refused and the spawn failed every time.

Spawn now leases the copy from its own process with `treehouse get --lease`,
refreshes it with no shell inside, and creates the pane already in that path
on every session-provider backend (tmux, herdr, zellij, cmux). A refusal
before any create call returns a clean lease to the pool; from the first
create call on the lease is retained and reported, because `treehouse return`
terminates every process still in the copy. A fresh spawn whose record still
names a copy (a quarantined Herdr recovery) refreshes that copy instead of
leasing another, and refuses when its HEAD holds commits no remote has. A
reclaimed Herdr pane is sent one plain `cd` into the copy after the refresh.

fm-teardown.sh closes the endpoint before its worktree process reap and the
copy's return, since both would now kill the pane's own shell and skip the
planned focus-preserving Herdr close. The presentation e2e audits the
emptying-close plan's pane-death removal and asserts copy reuse on reclaim.
@greptile-apps

greptile-apps Bot commented Sep 2, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge with no concrete blocking or independently actionable non-blocking defects identified.

The changed spawn and teardown paths preserve worktree safety checks, lease ownership, recovery identity, endpoint confirmation, and retryable durable state across the investigated failure paths.

Reviews (1): Last reviewed commit: "no-mistakes(document): Correct refresh-b..." | Re-trigger Greptile

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