Skip to content

fix(bin): isolate Treehouse crew pools per project clone - #14

Merged
twilwa merged 5 commits into
mainfrom
fm/fm-pool-per-home
Sep 25, 2026
Merged

twilwa merged 5 commits into
mainfrom
fm/fm-pool-per-home

Conversation

@twilwa

@twilwa twilwa commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Intent

In a secondmate home, Claude-harness spawns fail in fm-claude-trust.sh with 'is not a worktree of project', because that home's Treehouse pools are anchored to the main home's clones under ~/firstmate/projects/ and not to the home's own clones under /projects/. Pi spawns skip that check and are unaffected. Fix it: anchor pools per home, or have the trust check accept the pool's real git common dir. This is shared Firstmate tooling, so it ships through twilwa/firstmate's normal path and merges when green.

What Changed

  • bin/fm-spawn.sh now sends treehouse get --root "$HOME/.treehouse-fm/<hash>", where the hash comes from the physical project clone path. Each clone, including a secondmate home's own clone under <home>/projects/, gets its own pool, even when it shares a remote with another home's clone. The root sits outside every Firstmate home, so no home's AGENTS.md/CLAUDE.md is an ancestor of a crew slot. The root also overrides any inherited TREEHOUSE_ROOT or user-level Treehouse config.
  • Spawn now refuses a Treehouse slot whose physical Git common directory doesn't match the spawning clone's, and does so before any metadata is published or the slot is claimed. This happens even when the slot passed the pane isolation check. The comparison is now a shared fm_same_git_common_dir helper in bin/fm-wake-lib.sh, and fm_treehouse_pool_slot uses it too.
  • The per-clone pool layout, and how existing slots in older pools are handled, is documented in docs/architecture.md and the fm-spawn.sh header. A new regression in tests/fm-spawn-pool-base-freshen.test.sh covers two homes cloned from the same origin: the foreign slot is refused, each home's own slot is accepted and claimed, and each clone gets a distinct pool root. To support the test, tests/fixtures.sh gains an FM_TEST_USER_HOME override, and the tangle-guard assertion now expects the --root form.

Risk Assessment

🚨 High: The fix resolves the trust-check failure, but moving every crew pool inside the Firstmate home makes Pi workers (verified from the installed Pi source) load the supervisor AGENTS.md in every project, which is a fleet-wide behavior regression that needs a human decision on where pools should live.

Testing

Drove the real fm-spawn.sh and fm-teardown.sh with the real treehouse v2.3.0 on a private tmux server, using a throwaway HOME and two Firstmate homes cloned from one origin. On base 51ccbfa, a Claude-harness spawn from the secondmate home reproduced the reported 'is not a worktree of project' failure. On target 582dd57, the same sequence gave each clone its own $HOME/.treehouse-fm/<hash> pool root, and the secondmate spawn got its own clone's slot, passed the Claude trust check, and launched. No slot has an AGENTS.md or CLAUDE.md ancestor, and the old ~/.treehouse pool was unchanged. A foreign slot planted into the secondmate's pool with real treehouse was refused before launch, leaving no metadata or claim. The two changed test suites pass. Real Claude and Pi model sessions were not started; the worker was a stand-in named claude. Overall: go.

  • Live validation: ✅ go - 6 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Baseline reproduction: secondmate-home Claude spawn fails on base 51ccbfa ✅ pass live Base secondmate spawn got ~/.treehouse/proj-f280af/1/proj, whose git common dir is homes/main/projects/proj/.git. It failed with: refusing to pre-register Claude trust: '<slot>' is not a worktree of p…
Secondmate-home Claude-harness spawn succeeds with its own clone's slot ✅ pass live Target spawn printed 'spawned tgt-sm1-1 harness=claude kind=scout ... worktree=$HOME/.treehouse-fm/17e3b62289a3/.treehouse/proj-f280af/1/proj', exit=0. Slot git common dir = homes/sm1/projects/proj/.g…
Clones of one origin in different homes get separate pool roots ✅ pass live The main clone's pool root is $HOME/.treehouse-fm/109a256c3b53 and the sm1 clone's is $HOME/.treehouse-fm/17e3b62289a3. Each is the sha256 prefix of that clone's physical path.
No Firstmate AGENTS.md or CLAUDE.md is an ancestor of any crew slot ✅ pass live Walking from both new slots up to / found 0 AGENTS.md or CLAUDE.md files. Both homes had these files at their roots.
Existing ~/.treehouse slots are not moved or destroyed ✅ pass live The find listing of ~/.treehouse was identical before and after the target spawns. Slot 1 is still present and still linked to the main clone.
Adversarial: a foreign clone's slot in this home's pool is refused before worker launch ✅ pass live A real treehouse get --root <sm1 root> from the main clone created slot 2, linked to the main clone. The sm1 spawn was handed that slot and failed with: 'Treehouse pool slot <slot2> is not linked to p…
Real Claude and Pi worker sessions start in the per-clone slot ⏸️ untested no Starting a real Claude or Pi session needs model credentials inside the throwaway HOME, which the lab did not set up. The worker was a stand-in process named claude. The failing step, the real fm-clau…
Evidence: Live lab transcript: base reproduction, target fix, ancestor walk, old-pool check, foreign-slot refusal

Source: Live lab transcript: base reproduction, target fix, ancestor walk, old-pool check, foreign-slot refusal

# Live lab: per-clone Treehouse pool roots (fm/fm-pool-per-home)
# Real bin/fm-spawn.sh + bin/fm-teardown.sh, real treehouse v2.3.0, private tmux server (TMUX_TMPDIR=/tmp/nmlab-poolhome/tmuxdir),
# throwaway HOME=/tmp/nmlab-poolhome/user-home, two Firstmate homes (homes/main, homes/sm1) each with AGENTS.md+CLAUDE.md and projects/proj cloned from one origin.
# Harness=claude (real fm-claude-trust.sh; worker binary is a named 'claude' stand-in so no LLM session is started).

## BASE 51ccbfa: main-home spawn -> force teardown -> secondmate-home spawn
spawned base-main-1 harness=claude kind=scout window=firstmate:fm-base-main-1 worktree=/tmp/nmlab-poolhome/user-home/.treehouse/proj-f280af/1/proj
exit=0
--- secondmate home:
error: refusing to pre-register Claude trust: '/tmp/nmlab-poolhome/user-home/.treehouse/proj-f280af/1/proj' is not a worktree of project '/tmp/nmlab-poolhome/homes/sm1/projects/proj'
error: could not pre-register Claude workspace trust for /tmp/nmlab-poolhome/user-home/.treehouse/proj-f280af/1/proj; refusing to launch a claude worker that would wedge on the trust dialog; inspect window firstmate:fm-base-sm1-1
exit=1
slot common dir: /tmp/nmlab-poolhome/homes/main/projects/proj/.git  (foreign to sm1)

## TARGET 582dd57: same sequence
spawned tgt-main-1 harness=claude kind=scout window=firstmate:fm-tgt-main-1 worktree=/tmp/nmlab-poolhome/user-home/.treehouse-fm/109a256c3b53/.treehouse/proj-f280af/1/proj
exit=0
--- secondmate home:
spawned tgt-sm1-1 harness=claude kind=scout window=firstmate:fm-tgt-sm1-1 worktree=/tmp/nmlab-poolhome/user-home/.treehouse-fm/17e3b62289a3/.treehouse/proj-f280af/1/proj
exit=0
slot common dir: /tmp/nmlab-poolhome/homes/sm1/projects/proj/.git
slot owner claim: task=tgt-sm1-1 home=/tmp/nmlab-poolhome/homes/sm1 
hash(main clone)=109a256c3b53 hash(sm1 clone)=17e3b62289a3 -> distinct roots under $HOME/.treehouse-fm

## Instruction-file ancestor walk (slot -> /)
user-home/.treehouse-fm/109a256c3b53/.treehouse/proj-f280af/1/proj: AGENTS.md/CLAUDE.md ancestors found=0
user-home/.treehouse-fm/17e3b62289a3/.treehouse/proj-f280af/1/proj: AGENTS.md/CLAUDE.md ancestors found=0

## Old ~/.treehouse pool listing before vs after target runs
unchanged:
user-home/.treehouse
user-home/.treehouse/.gitignore
user-home/.treehouse/proj-f280af
user-home/.treehouse/proj-f280af/1
user-home/.treehouse/proj-f280af/1/proj
user-home/.treehouse/proj-f280af/treehouse-state.json
user-home/.treehouse/proj-f280af/treehouse-state.lock
user-home/.treehouse/update-check.json

## ADVERSARIAL: foreign slot (from main clone, via real 'treehouse get --root <sm1 root>') planted as sm1's free slot 2
slot 2 common dir: /tmp/nmlab-poolhome/homes/main/projects/proj/.git
error: Treehouse pool slot /tmp/nmlab-poolhome/user-home/.treehouse-fm/17e3b62289a3/.treehouse/proj-f280af/2/proj is not linked to project clone /tmp/nmlab-poolhome/homes/sm1/projects/proj; refusing to launch a worker outside that project; inspect window firstmate:fm-tgt-sm1-foreign
exit=1
state/tgt-sm1-foreign.meta exists: no
slot 2 .fm-slot-owner exists: no
Evidence: tmux pane capture of the secondmate-home Claude worker launched in its per-clone slot

Source: tmux pane capture of the secondmate-home Claude worker launched in its per-clone slot

mate or secondmate supervisor identity, delegate the task, run fleet supervision
, or address the captain.
Your steering inbox is `/tmp/nmlab-poolhome/homes/sm1/state/tgt-sm1-1.inbox`; th
is exact path belongs to your current task even when it is outside the worktree
or under the supervising firstmate home, so read and acknowledge its messages an
d do not reject it as another home's state.
Never inspect or change any other home's endpoint namespace; this authorization
is limited to the exact task paths named by this brief.
When this task works on Firstmate itself, the repository root `AGENTS.md` (also
imported by `CLAUDE.md`) is project content and the supervisor contract for the
firstmate managing you: follow this brief instead of that supervisor contract.
Project instructions still govern the work wherever they do not conflict with th
is worker identity, including `CONTRIBUTING.md` and `firstmate-coding-guidelines
` for Firstmate changes.

# Task
## Captain's intent
live lab scout tgt-sm1-1

## Firstmate spec
Exercise the spawn behavior under test.
cwd: /tmp/nmlab-poolhome/user-home/.treehouse-fm/17e3b62289a3/.treehouse/proj-f2
80af/1/proj

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 warning
  • 🚨 bin/fm-spawn.sh:4017 - Crew pools nested inside the Firstmate home make Pi (and Claude) workers load the supervisor AGENTS.md/CLAUDE.md. The new root $(dirname &#34;$PROJ_ABS_REAL&#34;)/.treehouse places every crew slot under the Firstmate home, e.g. ~/firstmate/projects/.treehouse/.treehouse/<pool>/1/<repo>, and for secondmate homes <home>/projects/.treehouse/... Both homes are checkouts of this repo with the 87K supervisor AGENTS.md and a CLAUDE.md that imports it at their root. The installed Pi harness (@earendil-works/pi-coding-agent, dist/core/resource-loader.js loadProjectContextFiles) walks every ancestor directory to / and loads AGENTS.md/CLAUDE.md from each. Its shadowing rule only drops the main-repo copy when the worktree is nested inside its own main repo, which is not the case here because the slot is a sibling of the project clone. So every Pi ship/scout worker, from the main home and every secondmate home, now loads the Firstmate supervisor contract as project instructions. Claude Code likewise loads ancestor CLAUDE.md files; its @AGENTS.md import is probably blocked by the external-import gate that fm-claude-trust.sh sets. Before this change slots lived under ~/.treehouse, with no AGENTS.md/CLAUDE.md in ~ or /home. The result is large context pollution and conflicting supervisor-vs-worker directives in other projects' workers. Remedy (a design choice, hence ask-user): keep the per-clone root but put it outside the home tree, e.g. --root &#34;$HOME/.treehouse-fm/&lt;hash of PROJ_ABS_REAL&gt;&#34;, so no Firstmate instruction file is an ancestor of any slot. The same invariant applies to the documented location at docs/architecture.md:276 and the pane-log assertion at tests/fm-spawn-pool-base-freshen.test.sh:92.
  • ⚠️ bin/fm-spawn.sh:4110 - Extra refusal for a symlinked or non-file treehouse-state.json goes beyond the stated intent. The else branch adds a second new refusal: a slot whose $(dirname &#34;$(dirname &#34;$WT&#34;)&#34;)/treehouse-state.json exists as a symlink or directory. The intent (anchor pools per home, or accept the pool's real git common dir) needs only per-clone roots and, at most, the same-clone check at 4102-4109. This hardening path is not required. Recommend removing lines 4110-4114.
  • ℹ️ bin/fm-spawn.sh:4102 - The new same-clone check exits silently and repeats fm_treehouse_pool_slot's comparison. Lines 4102-4105 use a bare || exit 1 for the git rev-parse and cd steps. A failure there aborts the spawn with no diagnostic, unlike every other refusal in this block, which names the slot and window. The same common-dir resolution and comparison already exists in fm_treehouse_pool_slot (bin/fm-wake-lib.sh:1261-1273). Emit an error naming $WT and $T on these failures, or factor out a shared common-dir comparison helper.
  • ℹ️ bin/fm-spawn.sh:4017 - --root &lt;parent&gt;/.treehouse yields a doubled .treehouse/.treehouse pool path. Treehouse v2.3 creates its own .treehouse/ under the given --root; its help says '.' means an in-project pool. Verified with the installed binary: treehouse get --root X/.treehouse creates pools at X/.treehouse/.treehouse/<name>/<n>/<repo>. docs/architecture.md:276 describes only the argument, so it reads as if pools sit directly under &lt;physical project parent&gt;/.treehouse. Passing $(dirname &#34;$PROJ_ABS_REAL&#34;) as the root gives the documented &lt;parent&gt;/.treehouse/&lt;pool&gt; layout. Update the test expectation at tests/fm-spawn-pool-base-freshen.test.sh:92 to match.

🔧 Fix applied.
6 issues (2 errors, 2 warnings, 2 infos) still open:

  • 🚨 bin/fm-spawn.sh:4017 - Crew pools nested inside the Firstmate home make Pi (and Claude) workers load the supervisor AGENTS.md/CLAUDE.md. The new root $(dirname &#34;$PROJ_ABS_REAL&#34;)/.treehouse places every crew slot under the Firstmate home, e.g. ~/firstmate/projects/.treehouse/.treehouse/<pool>/1/<repo>, and for secondmate homes <home>/projects/.treehouse/... Both homes are checkouts of this repo with the 87K supervisor AGENTS.md and a CLAUDE.md that imports it at their root. The installed Pi harness (@earendil-works/pi-coding-agent, dist/core/resource-loader.js loadProjectContextFiles) walks every ancestor directory to / and loads AGENTS.md/CLAUDE.md from each. Its shadowing rule only drops the main-repo copy when the worktree is nested inside its own main repo, which is not the case here because the slot is a sibling of the project clone. So every Pi ship/scout worker, from the main home and every secondmate home, now loads the Firstmate supervisor contract as project instructions. Claude Code likewise loads ancestor CLAUDE.md files; its @AGENTS.md import is probably blocked by the external-import gate that fm-claude-trust.sh sets. Before this change slots lived under ~/.treehouse, with no AGENTS.md/CLAUDE.md in ~ or /home. The result is large context pollution and conflicting supervisor-vs-worker directives in other projects' workers. Remedy (a design choice, hence ask-user): keep the per-clone root but put it outside the home tree, e.g. --root &#34;$HOME/.treehouse-fm/&lt;hash of PROJ_ABS_REAL&gt;&#34;, so no Firstmate instruction file is an ancestor of any slot. The same invariant applies to the documented location at docs/architecture.md:276 and the pane-log assertion at tests/fm-spawn-pool-base-freshen.test.sh:92.
  • ⚠️ bin/fm-spawn.sh:4110 - Extra refusal for a symlinked or non-file treehouse-state.json goes beyond the stated intent. The else branch adds a second new refusal: a slot whose $(dirname &#34;$(dirname &#34;$WT&#34;)&#34;)/treehouse-state.json exists as a symlink or directory. The intent (anchor pools per home, or accept the pool's real git common dir) needs only per-clone roots and, at most, the same-clone check at 4102-4109. This hardening path is not required. Recommend removing lines 4110-4114.
  • ℹ️ bin/fm-spawn.sh:4102 - The new same-clone check exits silently and repeats fm_treehouse_pool_slot's comparison. Lines 4102-4105 use a bare || exit 1 for the git rev-parse and cd steps. A failure there aborts the spawn with no diagnostic, unlike every other refusal in this block, which names the slot and window. The same common-dir resolution and comparison already exists in fm_treehouse_pool_slot (bin/fm-wake-lib.sh:1261-1273). Emit an error naming $WT and $T on these failures, or factor out a shared common-dir comparison helper.
  • ℹ️ bin/fm-spawn.sh:4017 - --root &lt;parent&gt;/.treehouse yields a doubled .treehouse/.treehouse pool path. Treehouse v2.3 creates its own .treehouse/ under the given --root; its help says '.' means an in-project pool. Verified with the installed binary: treehouse get --root X/.treehouse creates pools at X/.treehouse/.treehouse/<name>/<n>/<repo>. docs/architecture.md:276 describes only the argument, so it reads as if pools sit directly under &lt;physical project parent&gt;/.treehouse. Passing $(dirname &#34;$PROJ_ABS_REAL&#34;) as the root gives the documented &lt;parent&gt;/.treehouse/&lt;pool&gt; layout. Update the test expectation at tests/fm-spawn-pool-base-freshen.test.sh:92 to match.
  • 🚨 tests/fm-tangle-guard.test.sh:282 - An existing test will now fail because the spawn sends different text to the pane. test_spawn_tmux_window_construction checks the tmux recorder log with a fixed-string grep for send-keys -t @spawnwid treehouse get Enter. spawn_send_text_line runs tmux send-keys -t &#34;$1&#34; &#34;$2&#34; Enter (bin/backends/tmux.sh:121). bin/fm-spawn.sh:4029 now sends treehouse get --root &#39;&lt;HOME&gt;/.treehouse-fm/&lt;hash&gt;&#39;, so the recorded line becomes tmux send-keys -t @spawnwid treehouse get --root &#39;…&#39; Enter and the grep no longer matches. The original commit introduced this and neither fix round updated it. Fix: have the assertion check that send-keys -t @spawnwid treehouse get --root &#39; goes to the stable window id and that the line ends with Enter.
  • ⚠️ bin/fm-spawn.sh:4027 - Crew pools for a secondmate home's project clones are left behind when that home is retired. The round-1 fix moved the pool root from beside the clone (inside the home) to $HOME/.treehouse-fm/&lt;hash of PROJ_ABS_REAL&gt;. That fix introduced this leak. Retiring a secondmate home deletes the home directory and its projects/ clones (bin/fm-teardown.sh safe_rm_rf around 2508-2518). No code touches ~/.treehouse-fm/&lt;hash&gt;/.treehouse/&lt;pool&gt;/&lt;n&gt;/&lt;repo&gt;, so every slot that home's crew used stays on disk as a full working tree whose .git points at a deleted clone. With round-1 placement these were removed with the home. Reusing the same home path is harmless: I checked with Treehouse v2.3.0, and after the clone is recreated it skips the dead slot and makes a new one, so the old slot just stays stale. Disk use grows with each retired home. The smallest fix is new cleanup (drop the hashed root for each project clone when a home is retired), and it is that new cleanup, not the defect itself, that needs the user's approval. Note that the user's instruction not to migrate or destroy slots applies only to existing ~/.treehouse slots.

🔧 Fix applied.
1 warning still open:

  • ⚠️ bin/fm-spawn.sh:4027 - Crew pools for a secondmate home's project clones are left behind when that home is retired. The round-1 fix moved the pool root from beside the clone (inside the home) to $HOME/.treehouse-fm/&lt;hash of PROJ_ABS_REAL&gt;. That fix introduced this leak. Retiring a secondmate home deletes the home directory and its projects/ clones (bin/fm-teardown.sh safe_rm_rf around 2508-2518). No code touches ~/.treehouse-fm/&lt;hash&gt;/.treehouse/&lt;pool&gt;/&lt;n&gt;/&lt;repo&gt;, so every slot that home's crew used stays on disk as a full working tree whose .git points at a deleted clone. With round-1 placement these were removed with the home. Reusing the same home path is harmless: I checked with Treehouse v2.3.0, and after the clone is recreated it skips the dead slot and makes a new one, so the old slot just stays stale. Disk use grows with each retired home. The smallest fix is new cleanup (drop the hashed root for each project clone when a home is retired), and it is that new cleanup, not the defect itself, that needs the user's approval. Note that the user's instruction not to migrate or destroy slots applies only to existing ~/.treehouse slots.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 6 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Baseline reproduction: secondmate-home Claude spawn fails on base 51ccbfa ✅ pass live Base secondmate spawn got ~/.treehouse/proj-f280af/1/proj, whose git common dir is homes/main/projects/proj/.git. It failed with: refusing to pre-register Claude trust: '<slot>' is not a worktree of p…
Secondmate-home Claude-harness spawn succeeds with its own clone's slot ✅ pass live Target spawn printed 'spawned tgt-sm1-1 harness=claude kind=scout ... worktree=$HOME/.treehouse-fm/17e3b62289a3/.treehouse/proj-f280af/1/proj', exit=0. Slot git common dir = homes/sm1/projects/proj/.g…
Clones of one origin in different homes get separate pool roots ✅ pass live The main clone's pool root is $HOME/.treehouse-fm/109a256c3b53 and the sm1 clone's is $HOME/.treehouse-fm/17e3b62289a3. Each is the sha256 prefix of that clone's physical path.
No Firstmate AGENTS.md or CLAUDE.md is an ancestor of any crew slot ✅ pass live Walking from both new slots up to / found 0 AGENTS.md or CLAUDE.md files. Both homes had these files at their roots.
Existing ~/.treehouse slots are not moved or destroyed ✅ pass live The find listing of ~/.treehouse was identical before and after the target spawns. Slot 1 is still present and still linked to the main clone.
Adversarial: a foreign clone's slot in this home's pool is refused before worker launch ✅ pass live A real treehouse get --root <sm1 root> from the main clone created slot 2, linked to the main clone. The sm1 spawn was handed that slot and failed with: 'Treehouse pool slot <slot2> is not linked to p…
Real Claude and Pi worker sessions start in the per-clone slot ⏸️ untested no Starting a real Claude or Pi session needs model credentials inside the throwaway HOME, which the lab did not set up. The worker was a stand-in process named claude. The failing step, the real fm-clau…
  • git archive 51ccbfa / git archive HEAD into a throwaway lab, with HOME, TMUX_TMPDIR and FM_* overrides pointed at the lab
  • Base: fm-spawn.sh base-main-1 &lt;main&gt;/projects/proj --scout --harness claude --backend tmux, then fm-teardown.sh base-main-1 --force, then fm-spawn.sh base-sm1-1 &lt;sm1&gt;/projects/proj --scout --harness claude --backend tmux (reproduced the failure)
  • Target: the same main spawn, force teardown and sm1 spawn sequence (tgt-main-1, tgt-sm1-1)
  • git rev-parse --path-format=absolute --git-common-dir on each slot, .fm-slot-owner claim, ~/.claude.json trust entries, tmux capture-pane of the launched window
  • Walk from each new slot up to / looking for AGENTS.md or CLAUDE.md
  • Compare the old ~/.treehouse pool listing before and after the target runs
  • Adversarial: real treehouse get --root $HOME/.treehouse-fm/&lt;sm1 hash&gt; from the main clone to plant a foreign slot 2, then fm-spawn.sh tgt-sm1-foreign ... (refused)
  • bash tests/fm-spawn-pool-base-freshen.test.sh
  • bash tests/fm-tangle-guard.test.sh
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Summary by Sourcery

Isolate Treehouse pools per physical project clone and prevent workers from launching in slots owned by another clone.

Bug Fixes:

  • Isolate Treehouse worker pools by physical project clone so projects in separate Firstmate homes no longer share incompatible slots.
  • Reject Treehouse slots linked to a different Git clone before publishing task metadata or launching workers.

Enhancements:

  • Centralize Git common-directory validation for Treehouse slots and document per-clone pool behavior while preserving existing pools.

Build:

  • Upgrade the pinned Treehouse release to v2.3.0 and update platform checksums.

Documentation:

  • Document per-clone Treehouse roots, legacy pool handling, and secondmate allocation behavior.

Tests:

  • Add regression coverage for cross-home slot rejection, per-clone pool isolation, and updated Treehouse root invocation.

@sourcery-ai sourcery-ai 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.

Sorry @twilwa, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 day and 19 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 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-09-25T07:30:39.045663Z 186f924 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.

@sourcery-ai

sourcery-ai Bot commented Sep 25, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR prevents same-origin project clones in different Firstmate homes from sharing Treehouse slots by assigning each physical clone a hashed pool root outside the home tree, validating Git common-directory ownership before launch, and adding focused documentation and regression tests. Review the lifecycle implications of leaving hashed pools behind when homes are retired, and note that real Claude/Pi model sessions were not exercised.

Sequence diagram for per-clone Treehouse slot acquisition

sequenceDiagram
    participant Spawn as fm-spawn.sh
    participant Treehouse
    participant Pool as Hashed pool root
    participant Git
    participant Worker

    Spawn->>Git: rev-parse --path-format=absolute --git-common-dir
    Spawn->>Spawn: compute pool_hash from PROJ_ABS_REAL
    Spawn->>Treehouse: treehouse get --root $HOME/.treehouse-fm/pool_hash
    Treehouse->>Pool: allocate clone-specific slot
    Spawn->>Git: fm_same_git_common_dir(PROJ_ABS, WT)
    alt common directories match
        Spawn->>Worker: publish metadata and launch worker
    else common directories differ
        Spawn-->>Worker: refuse launch before claim/metadata
    end
Loading

File-Level Changes

Change Details Files
Isolate Treehouse pools by the physical project clone while keeping them outside Firstmate homes.
  • Hash the resolved clone path and pass a per-clone --root to Treehouse.
  • Override inherited or user-level Treehouse pool configuration.
  • Document pool placement, legacy pool behavior, and home-specific allocation semantics.
bin/fm-spawn.sh
docs/architecture.md
Reject Treehouse slots that belong to a different Git clone before launch or state publication.
  • Add a shared helper comparing canonical Git common directories.
  • Reuse the helper in pool-slot validation and spawn-time foreign-slot refusal.
  • Ensure foreign slots are neither claimed nor associated with task metadata.
bin/fm-spawn.sh
bin/fm-wake-lib.sh
Add regression coverage for same-origin clones in separate homes and the new Treehouse invocation.
  • Test distinct hashed roots, acceptance of each clone's own slot, and refusal of a foreign slot.
  • Support test-specific HOME placement outside Firstmate homes.
  • Update tangle-guard matching for the treehouse get --root command.
tests/fm-spawn-pool-base-freshen.test.sh
tests/fixtures.sh
tests/fm-tangle-guard.test.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@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: 186f9245c8

ℹ️ 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
else
pool_hash=$(printf '%s' "$PROJ_ABS_REAL" | cksum | awk '{printf "%08x", $1}')
fi
pool_root="$HOME/.treehouse-fm/$pool_hash"

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 Keep the pool root outside nested Firstmate homes

When HOME is equal to or nested beneath FM_HOME—a supported layout commonly used by containerized or isolated environments—this root remains inside the Firstmate home, so worker harnesses that discover ancestor instructions will still load that home's AGENTS.md/CLAUDE.md. This defeats the isolation this change is intended to provide and can inject the supervisor contract into ship/scout workers; canonicalize and reject or relocate the root whenever it falls beneath a Firstmate home.

AGENTS.md reference: AGENTS.md:L3-L5

Useful? React with 👍 / 👎.

… PR. bin/fm-spawn.sh now runs `treehouse get --root '<HOME>/.treehouse-fm/<hash>'`, but CI installs Treehouse v2.0.1 through bin/fm-install-treehouse.sh. That version rejects `--root` (checked against the real v2.0.1 release: `unknown flag: --root`; it doesn't read TREEHOUSE_ROOT either). The spawn pane never left the project directory, so all four failing tests (autodetect-smoke, launcher-workspace, presentation, workspace-per-home) timed out after 60s with "treehouse get did not enter an isolated worktree". Rule broken: the Treehouse that CI installs must support every flag fm-spawn.sh passes it. That installer is the only place CI installs Treehouse, so it is the only file changed. Fix: moved the pin to v2.3.0, the latest release, the version installed on this host, and the one docs/architecture.md already describes. Swapped in the four SHA-256 checksums published with the v2.3.0 release and updated the comments. Checked locally: the installer downloads, verifies and installs v2.3.0, and its `get --help` lists `--root`; a real `treehouse get --root <dir> --lease` makes the pool under <dir>/.treehouse/<pool>/1/<repo>; shellcheck passes; no test pins the old version. Not run locally: the real-Herdr tests, because the lab helper refuses to start unless exactly one default Herdr session is running and this host has none. The next CI run is the real check. ci-1 (Behavior portable serial 2): no change; not caused by this PR. The failing test, tests/fm-remote-secondmate-lifecycle-e2e.test.sh, never touches Treehouse or anything this PR changed; it only does secondmate spawns, which skip the new --root branch. In CI every assertion passed ("ALL TESTS PASSED"); only the final cleanup failed with `rm: cannot remove .../watch-liveness-unreachable: Directory not empty` because something was still writing into the temp directory. A local run failed at a different step ("the watcher did not exit on its auto-relaunch wake within the bound") and left a relaunched fm-watch.sh and an `fm-spawn.sh ios --secondmate` still writing to its temp directory, which fits the CI cleanup race. I confirmed those processes belonged to my run from their FM_HOME and state directory, then stopped them and deleted the directory. Recent main runs pass this test. It looks like a timing flake; making its cleanup wait for relaunched watchers would be a separate fix
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