fix: isolate Treehouse pools per Firstmate home - #57
Merged
Conversation
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.
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
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.
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 writingtreehouse.tomlinto 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 -ptraverses$FM_HOME/state/treehouse-sources/$source_keybefore the path is checked withfm_checkout_trusted_dir. A symlink attreehouse-sourcesor 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 nonzerogit ls-files --error-unmatchresult 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 trackedtreehouse.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.
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.