Skip to content

fix: isolate Treehouse pools per Firstmate home - #57

Merged
ruby-dlee merged 4 commits into
mainfrom
fm/fm-per-home-treehouse-pool
Aug 1, 2026
Merged

fix: isolate Treehouse pools per Firstmate home#57
ruby-dlee merged 4 commits into
mainfrom
fm/fm-per-home-treehouse-pool

Conversation

@ruby-dlee

Copy link
Copy Markdown
Owner

Intent

Give every Firstmate operational home its own Treehouse pool root so a secondmate can acquire a worktree from its own declared project clone even when a different same-origin clone populated the legacy shared pool first. Preserve and do not weaken the exact Git common-directory assertion in fm-spawn. Firstmate must manage the root without writing treehouse.toml into the declared project clone, must scan both managed and legacy pools, must preserve existing live pooled worktrees without reclaiming, pruning, destroying, migrating, or forcibly taking them over, and must prove main-home ship and scout spawning still works. Also let teardown clear bookkeeping for the exact direct-spawn state where no endpoint was created, without weakening the report requirement for scouts that actually ran. Include regression tests for secondmate ownership, main-home ship and scout behavior, and the never-created scout teardown case; bin/fm-lint.sh must exit zero. Treat the known clean-main fm-account-routing endpoint/sync-race failure as pre-existing rather than changing unrelated behavior.

What Changed

  • Isolate Treehouse pools per Firstmate home using managed control worktrees, while keeping declared project clones clean and scanning both managed and legacy pools.
  • Harden source-path and config inspection safeguards, including fail-closed handling for unsafe paths and Git inspection errors.
  • Allow teardown to skip the scout report gate only when a direct spawn never created an endpoint, with regression coverage and updated documentation.

Risk Assessment

✅ Low: The latest change now fails closed on tracked-config inspection errors, preserves the explicit tracked-file refusal, and the full branch remains consistent with the per-home pool, legacy scanning, ownership, and never-launched teardown requirements.

Testing

Completed 1 recorded test check.

  • Outcome: ⚠️ 1 error across 1 run (8m36s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed (2) ✅
  • 🚨 bin/fm-checkout-refresh.sh:993 - The required behavior says “every Firstmate operational home” must acquire from its declared project clone without writing treehouse.toml into that clone, but this hunk rejects any project that already tracks the standard Treehouse config. Such a declared clone can no longer spawn at all. The managed control worktree should support overriding its own checked-out config while leaving the declared clone untouched.
  • 🚨 bin/fm-checkout-refresh.sh:963 - mkdir -p traverses $FM_HOME/state/treehouse-sources/$source_key before the path is checked with fm_checkout_trusted_dir. A symlink at treehouse-sources or the keyed child can therefore cause an out-of-home directory creation before the function rejects it. Validate and create each component without following symlinks before writing.

🔧 Fix: Harden Treehouse source isolation and refusal diagnostics
1 error still open:

  • 🚨 bin/fm-checkout-refresh.sh:976 - The tracked-config guard treats every nonzero git ls-files --error-unmatch result as “untracked.” If inspection fails (for example, an unreadable/corrupt index) while a previously created control worktree exists, execution continues and overwrites that worktree’s tracked treehouse.toml, violating the required fail-closed behavior. Run a non-erroring path query, require the Git command itself to succeed, and then refuse when its output is nonempty.

🔧 Fix: Fail closed on Treehouse config inspection errors
✅ Re-checked - no issues remain.

⚠️ **Test** - 1 error
  • 🚨 tests failed with exit code -1
  • command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; uv run --directory tools/agent-fleet --locked pytest || rc=1; uv run --directory tools/agent-fleet --locked python -m compileall -q src || rc=1; exit "$rc"
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@ruby-dlee
ruby-dlee merged commit 6248d9b into main Aug 1, 2026
5 checks passed
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