Skip to content

fix(bin): extend treehouse worktree wait - #9

Merged
roderik merged 1 commit into
mainfrom
fm/fm-spawn-wait
Oct 23, 2026
Merged

roderik merged 1 commit into
mainfrom
fm/fm-spawn-wait

Conversation

@roderik

@roderik roderik commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Intent

The machine is under load, so give treehouse some time to install dependencies and prepare the worktree before fm-spawn gives up.

Context: bin/fm-spawn.sh waits for treehouse get to enter an isolated worktree with a fixed loop of 60 one-second polls (around the "did not enter an isolated worktree within 60s" error, roughly line 5165-5185). On a loaded machine a large project's worktree needs longer for its dependency install, so the spawn fails at 60 s, leaving an empty Rex tab and a leased worktree behind that the next spawn then trips over ("a Rex block labeled ... already exists").

What Changed

  • Replace the fixed 60-second treehouse get worktree-settling limit with a configurable FM_SPAWN_WORKTREE_WAIT_SECS poll window, defaulting to 600 seconds and falling back for blank, zero, or non-numeric values.
  • Include the effective timeout and configuration variable in the failure message, and document the setting in the configuration reference.
  • Extend the worktree-settling regression test to cover the 600-second default and a seven-second override.

Risk Assessment

✅ Low: The change is narrowly scoped to making the existing treehouse worktree-settle polling duration configurable, documents the default and fallback behavior, and adds behavioral coverage without changing the surrounding spawn state transitions.

Testing

The targeted spawn regression suite passed, including transient-path protection, the 600-second default, the environment override, and deadline refusal. A real Herdr lab drove a Treehouse-backed spawn and produced backend/worktree metadata; all disposable lab and accidental checkout residue was removed, and the source worktree remains clean. No linters or full-suite tests were run.

  • Live validation: ⚠️ inconclusive - 1 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Real Herdr Treehouse spawn records isolated worktree ✅ pass live Real Herdr lab transcript artifact: task metadata recorded backend=herdr and an isolated Treehouse worktree after running fm-spawn.sh with FM_SPAWN_WORKTREE_WAIT_SECS=7.
Transient and delayed worktree settling uses configurable wait ⏸️ untested no The prior payload only recorded a deterministic fake tmux/treehouse regression harness, not a live product run, so it did not establish a live result for this scenario.
Pane stuck outside an isolated worktree refuses at the deadline ⏸️ untested no The prior payload only recorded a deterministic fake pane regression harness, not a live product run, so it did not establish a live result for this scenario.
Evidence: Focused spawn regression output
bash tests/fm-spawn-worktree-settle.test.sh
ok - a single transient stale pane_current_path read is not accepted as the worktree
ok - an already-settled pane confirms on the next read, not a whole extra cycle
ok - a transient primary-checkout pane read is not accepted as the worktree
ok - a pane stuck on the primary checkout fails loudly at the deadline
ok - the worktree wait defaults to 600s and FM_SPAWN_WORKTREE_WAIT_SECS overrides it
ok - a project with an unborn HEAD is refused at once with its cause named
# all fm-spawn-worktree-settle tests passed
Evidence: Real Herdr spawn transcript
Isolated named Herdr lab (fm-lab-spawn-wait-live-*), disposable lab home, real Treehouse, and real Herdr pane.
Spawn command used FM_SPAWN_WORKTREE_WAIT_SECS=7 and completed without gate bypasses.
Observed task metadata:
worktree=~/.treehouse/project-ba71de/1/project
backend=herdr
The exact live-run checkout was subsequently removed and the disposable lab was deleted.
- Outcome: ⚠️ 1 warning across 1 run (17m20s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (1 of 3 scenarios were driven live against the product); untested: Transient and delayed worktree settling uses configurable wait, Pane stuck outside an isolated worktree refuses at the deadline
  • Live validation: ⚠️ inconclusive - 1 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Real Herdr Treehouse spawn records isolated worktree ✅ pass live Real Herdr lab transcript artifact: task metadata recorded backend=herdr and an isolated Treehouse worktree after running fm-spawn.sh with FM_SPAWN_WORKTREE_WAIT_SECS=7.
Transient and delayed worktree settling uses configurable wait ⏸️ untested no The prior payload only recorded a deterministic fake tmux/treehouse regression harness, not a live product run, so it did not establish a live result for this scenario.
Pane stuck outside an isolated worktree refuses at the deadline ⏸️ untested no The prior payload only recorded a deterministic fake pane regression harness, not a live product run, so it did not establish a live result for this scenario.
  • bash tests/fm-spawn-worktree-settle.test.sh
  • Real named-lab Herdr lifecycle via bin/fm-herdr-lab.sh provision, run, and teardown
  • Real Herdr pane execution of fm-spawn.sh with FM_SPAWN_WORKTREE_WAIT_SECS=7 and the runbook environment scrub
  • treehouse destroy --include-unlanded --yes on the exact damaged disposable checkout left by the live run
  • git status --short
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T20:07:12.673820Z ebe0a67 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ebe0a6713d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bin/fm-spawn.sh
Comment on lines +5175 to +5176
case $worktree_wait_secs in
'' | *[!0-9]* | 0) worktree_wait_secs=600 ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat all zero-valued waits as the documented default

When FM_SPAWN_WORKTREE_WAIT_SECS is set to a zero-valued string such as 00 or 000, this case statement does not match it, so seq 1 "$worktree_wait_secs" produces no polls and spawn refuses immediately instead of using the documented 600-second default for zero values. Normalize numeric zero values before entering the loop (or reject them consistently with the documentation).

Useful? React with 👍 / 👎.

@roderik

roderik commented Oct 22, 2026

Copy link
Copy Markdown
Owner Author

Notes on scope and decisions

  • Live validation scenarios "transient and delayed worktree settling uses configurable wait" and "pane stuck outside an isolated worktree refuses at the deadline" were covered by unit tests with a fake treehouse (tests/fm-spawn-worktree-settle.test.sh), not driven live. The maintainer approved this: driving them live would mean running real spawns against a deliberately slowed or stuck treehouse on a live Rex server.
  • Design choice (smallest option): the wait is a count of 1-second polls rather than a wall-clock deadline, so the fake sleep makes the test instant. A real run lasts slightly longer than the configured seconds.
  • Cleanup of a timed-out spawn was left unchanged. The existing abort cleanup closes the endpoint and returns the leased worktree only for polytoken spawns, by design; extending it to other harnesses is not cheap or safe with the existing helpers. A timed-out spawn on another harness can therefore still leave its empty tab and leased worktree. The much longer default wait is meant to make that timeout rare.
  • CI is waived (Actions disabled on the fork).

@roderik
roderik merged commit 409f886 into main Oct 23, 2026
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