fix(spawn): skip treehouse get's transient cwd in worktree-discovery poll#480
Closed
psacc wants to merge 1 commit into
Closed
fix(spawn): skip treehouse get's transient cwd in worktree-discovery poll#480psacc wants to merge 1 commit into
psacc wants to merge 1 commit into
Conversation
…poll The worktree-discovery poll accepted the first non-project cwd, but treehouse get transits / and ~/.treehouse before it settles in the pooled worktree. herdr's foreground_cwd exposes those transients (tmux's pane_current_path reports the settled shell cwd and never did), so a herdr spawn resolved WT to / , failed the isolation gate, and aborted - orphaning the still-initializing treehouse get, which then held the pool's only slot forever with no crewmate (the single-slot wedge). Gate the poll on a new non-fatal is_isolated_worktree predicate (also the one validate_spawn_worktree now delegates to) so it skips the transients until the pane settles in a real worktree. Remember the last non-worktree cwd so a genuine tangle still gets the precise resolved-path refusal instead of a vague timeout, and make the poll budget configurable. No-op for tmux. Regression test drives real fm-spawn against a pane that reports / then the worktree; reproduces the exact 'resolved /' failure pre-fix.
psacc
marked this pull request as ready for review
July 12, 2026 20:22
Author
|
Superseded by #648, which carries the same worktree-poll fix raised through the no-mistakes pipeline (the gate this PR could not pass). Closing in its favor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
herdr-backend spawns intermittently aborted with:
and — worse — left a stuck
treehouse getholding the pool's only slot with no crewmate attached, so the next spawn also failed (the single-slot wedge). tmux-backend spawns were unaffected.Root cause
treehouse gettransits intermediate cwds while it sets the worktree up — it is momentarily at/and at the treehouse root (~/.treehouse) before it creates and enters the pooled worktree.bin/fm-spawn.sh's worktree-discovery poll accepted the first cwd that merely differed from the project directory, so it captured/(or~/.treehouse), handed that transient tovalidate_spawn_worktree, and aborted — while the still-initializingtreehouse getcompleted and held the slot forever.herdr's
foreground_cwdexposes those transients because it reads the actively-running foreground process's cwd; tmux'spane_current_pathreports the settled interactive-shell cwd and never surfaced them — which is why only the herdr path wedged.Fix
The poll now gates on a new non-fatal
is_isolated_worktree <path>predicate (a real git-worktree root, physically distinct from the primary checkout — the same rulevalidate_spawn_worktreenow delegates to), so it skips/and~/.treehouseand keeps polling until the pane settles in the actual worktree. No-op for tmux, whose first observed non-project cwd already is that worktree.Testing
tests/fm-backend.test.sh:test_spawn_worktree_poll_skips_treehouse_get_transient_cwd, which drives the realbin/fm-spawn.shagainst a fake pane whose polls return the project dir, then a transient/, then the real worktree. It reproduces the exactresolved '/'failure against the pre-fix poll and passes against the fix.fm-backendandfm-tangle-guardsuites green;shellcheck bin/*.sh bin/backends/*.sh tests/*.shclean.Opened as a draft for maintainer review before publishing.