Skip to content

feat(bin): give each home its own treehouse worktree pool - #63

Merged
BenWilcox8 merged 4 commits into
mainfrom
fm/treehouse-pool-per-clone-p1
Nov 11, 2026
Merged

BenWilcox8 merged 4 commits into
mainfrom
fm/treehouse-pool-per-clone-p1

Conversation

@BenWilcox8

@BenWilcox8 BenWilcox8 commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Intent

Later accepted firstmate requirement (2026-11-10, after GitHub Actions was re-enabled): checks ran on the PR and "Behavior portable serial 5" failed with not ok - unmapped omp prefix returned: error: omp quota mapping covers only the openai-codex and claude-bridge prefixes: ollama/qwen3:8b. Instruction: read the failed job log, reproduce, find the real cause, decide whether it is caused by this change, an old test this change must update, or an unrelated flake (prove a flake with a re-run of the failed job); if a fix is necessary, make it on this branch and take it through no-mistakes again; do not rebase onto anything other than origin/main; report done when every GitHub check is green, or blocked with evidence. Findings: the captured error carried a second stderr line, bin/fm-control-lib.sh: line 68: printf: write error: Broken pipe. fm_control_harness_supported returned at the first match while its process-substitution feeder was still printing; with SIGPIPE ignored (as on CI runners) bash prints that diagnostic, and fm-quota-choose.test.sh compares captured stderr exactly. Reproduced locally only under concurrent load with SIGPIPE ignored (7 hits in 3,600 calls; 0 in 5,400 after the fix). The re-run of the failed job failed again (same test, and also fm-extension-binding.test.sh "inner host crash during result.silent wedged its runner before result.terminal"). Adding this PR's new test file shifted the CI shard partition so both timing-sensitive tests now run in shard 5, where every test from fm-extension-binding onward runs about 3x slower than the same tests on other PRs; that slowdown is not caused by this PR's code and its source is not identified here. Accepted fixes, both minimal and outside the treehouse feature: (1) port upstream Firstmate commit 5df1294 (kunchenguid#5389) exactly - fm_control_harness_supported reads the full harness list into a found flag before returning; behavior unchanged; (2) in tests/fm-extension-binding.test.sh, the crash-silent recovery wait changes from 400 polls of 10 ms to a 20-second wall-clock deadline (still polling every 10 ms and breaking as soon as the start process exits), chosen to stay below the section coordinator's 34-second budget so a genuinely wedged runner still fails with the specific message. The other fixed-iteration waits in that file are intentionally unchanged because they have not been seen failing.

What Changed

  • fm-spawn.sh now runs treehouse get with TREEHOUSE_ROOT set to a private root for each home. The new fm_treehouse_home_root in fm-wake-lib.sh makes this root under ~/.treehouse/firstmate-homes/<hash of home path>. This means two homes that each have their own clone of a project no longer share pool slots. The new bin/fm-treehouse.sh runs treehouse commands (status, prune, ...) against that pool, and --print-root prints the root. Slots from the old shared pool still return through treehouse return <path>.
  • fm-bootstrap.sh now reports MISSING: treehouse as an upgrade when treehouse get --help does not mention TREEHOUSE_ROOT (before v2.2.0). The CI installer now pins Treehouse v2.3.0 with new checksums. The docs and the bootstrap-diagnostics and stuck-crewmate-recovery skills now describe per-home pools.
  • Two CI flake fixes outside the treehouse feature. fm_control_harness_supported now reads the full harness list before it returns, so its feeder cannot print a Broken pipe error when SIGPIPE is ignored. In fm-extension-binding.test.sh, the crash-silent recovery wait changes from 400 polls of 10 ms to a 20-second wall-clock deadline. New tests/fm-treehouse.test.sh covers the per-home root and wrapper, and the existing tests now expect the TREEHOUSE_ROOT prefix and help text.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The change matches the intent. The two CI flake fixes are present and minimal. The control-lib loop now reads all of its input before it returns, and its return value does not change. The crash-silent wait is now a 20s wall-clock deadline, which is below the 34s coordinator budget. In the per-home pool path, the root is resolved and passed with correct quoting under the same conditions that use it. Slot checks in spawn and teardown find the pool from the slot path, so they work for per-home slots and old shared-pool slots. No new defect was found.

Testing

I drove both flake fixes directly. I used temp copies of the base tree (692aa7b) and the fixed tree, with SIGPIPE ignored as on CI runners. Broken-pipe fix: - The direct CLI repro on base gave 306 bad stderr captures in 4,800 calls. Each bad capture had the CI line bin/fm-control-lib.sh: line 68: printf: write error: Broken pipe. - The full quota test file failed 32 of 72 runs on base, including the exact CI assertion. - The fixed tree gave 0 failures in 14,400 calls and 0 in 72 runs. - Harness accept/refuse results are identical on both trees. Extension-binding deadline: - The lifecycle-flow segment passes normally. - I slowed each node launch by 2-3 s while bash polling stayed at normal speed. This matches the CI pattern. Base then fails with the exact message "wedged its runner before result.terminal", and the fix passes (recovery took 9-11 s). - A simulated never-exiting runner still fails with that specific message after 20 s. The whole segment takes 24.6 s, under the 34 s coordinator budget. - Plain CPU oversubscription slows the old poll loop as much as the recovery, so base never failed that way. At 72 busy processes, recovery took 23-25 s: the 20 s deadline failed where base passed. That segment ran 60-80 s, far over the 34 s coordinator budget, so the aggregate test fails in that case either way. This is noted only, not a finding. Environment limits on this NixOS host: - python3 is not on the system paths, so I put it beside a temp copy of node. - The full aggregate extension-binding run still fails in its remote-activation lane. Remote jobs use a fixed child PATH without python3. The base tree fails identically, so the change does not cause it. Because of that, I could not drive the wedge through the coordinator path; I drove it at segment level. Regression: the branch's treehouse and pool-freshen tests pass. No UI surface is involved. Evidence is in CLI transcripts in the evidence dir, and all temp trees and processes were removed.

  • Live validation: ✅ go - 7 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Unmapped omp prefix with SIGPIPE ignored under concurrent load returns only the single expected error line (no 'printf: write error: Broken pipe') ✅ pass live sigpipe-repro-base.txt (306/4800 bad on base) vs sigpipe-repro-fixed.txt (0/14400 on fix)
tests/fm-quota-choose.test.sh passes reliably with SIGPIPE ignored, as on CI (the failing CI check) ✅ pass live quota-choose-test-sigpipe-ignored.txt: base 32/72 failed incl. exact CI assertion; fix 0/72
Harness checks accept every verified harness and refuse unknown, empty, case-variant and prefix names exactly as before ✅ pass live harness-supported-behavior.txt (base and fix identical through fm-quota-choose.sh and direct library calls)
Crash-silent recovery that is slow because process launches are slow (CI pattern) now passes where the old 400-poll wait reported a wedge ✅ pass live extension-binding-slow-launch.txt: 2-3 s node-launch delay -> base 'wedged its runner before result.terminal', fix passes
A really wedged runner still fails with the specific 'wedged its runner' message after the 20 s deadline, below the 34 s coordinator budget (segment run) ✅ pass live extension-binding-wedged-runner.txt: elapsed 20s, specific not-ok message, segment total 24.6s
The wedged-runner failure shows through the aggregate section coordinator before its 34 s timeout ⏸️ untested no On this NixOS host, the aggregate run stops early in the remote-activation lane. bin/fm-remote-job-lib.sh builds a fixed child PATH, and on this host no python3 is reachable from it. The base tree fai…
Lifecycle-flow segment of tests/fm-extension-binding.test.sh passes normally on the fixed tree ✅ pass live FM_EXTENSION_BINDING_SEGMENT=lifecycle-flow run: 'all extension-binding tests passed'; load sweep with no extra load: fix exit=0
Per-home treehouse pool behavior of this branch still works at the target commit (regression check) ✅ pass live bash tests/fm-treehouse.test.sh with real treehouse v2.3.0 and bash tests/fm-spawn-pool-base-freshen.test.sh: both pass
Evidence: Broken-pipe repro on base tree (CI error reproduced)

Source: Broken-pipe repro on base tree (CI error reproduced)

root=/tmp/fmbase calls=4800 mismatched_stderr=306 306 /tmp/fmbase/bin/fm-control-lib.sh: line 68: printf: write error: Broken pipe

root=/tmp/fmbase calls=4800 mismatched_stderr=306
distinct extra stderr lines (count line):
    306 /tmp/fmbase/bin/fm-control-lib.sh: line 68: printf: write error: Broken pipe
Evidence: Broken-pipe repro on fixed tree

Source: Broken-pipe repro on fixed tree

root=/tmp/fmfix calls=14400 mismatched_stderr=0

root=/tmp/fmfix calls=14400 mismatched_stderr=0
Evidence: Repro harness script

Source: Repro harness script

#!/usr/bin/env bash
# Usage: sigpipe-repro.sh <fm-root> <workers> <calls-per-worker>
# Runs the exact quota-choose command from tests/fm-quota-choose.test.sh
# ("unmapped omp prefix") with SIGPIPE ignored (as on GitHub runners), many
# workers at once to create load, and counts calls whose captured stderr is
# not exactly the expected single error line.
root=$1 workers=$2 calls=$3
expected='error: omp quota mapping covers only the openai-codex and claude-bridge prefixes: ollama/qwen3:8b'
out=$(mktemp -d)
trap '' PIPE
for w in $(seq 1 "$workers"); do
  (
    bad=0
    for _ in $(seq 1 "$calls"); do
      err=$("$root/bin/fm-quota-choose.sh" --snapshot /tmp/fmq-snap.json \
        --candidate omp:ollama/qwen3:8b --candidate claude:claude-3-5-sonnet 2>&1)
      if [ "$err" != "$expected" ]; then
        bad=$((bad + 1)); printf '%s\n---\n' "$err" >> "$out/bad.$w"
      fi
    done
    echo "$bad" > "$out/count.$w"
  ) &
done
wait
total=$(cat "$out"/count.* | paste -sd+ | bc)
echo "root=$root calls=$((workers * calls)) mismatched_stderr=$total"
if [ "$total" -gt 0 ]; then echo "distinct extra stderr lines (count line):"; cat "$out"/bad.* | grep -v -e "^---$" -e "^error: omp quota" | sort | uniq -c; fi
rm -rf "$out"
Evidence: fm-quota-choose.test.sh with SIGPIPE ignored, base vs fixed

Source: fm-quota-choose.test.sh with SIGPIPE ignored, base vs fixed

fmbase: failed runs 32 / 72 (incl. 5x 'not ok - unmapped omp prefix returned: ...') fmfix: failed runs 0 / 72

tests/fm-quota-choose.test.sh, SIGPIPE ignored, 24 busy processes + 24 concurrent copies of the test, 3 rounds
fmbase: failed runs 32 / 72
      4 not ok - bare omp candidate returned: error: omp quota mapping covers only the openai-codex and claude-bridge prefixes: default
      5 not ok - trailing empty model returned: error: invalid candidate: claude:
      3 not ok - trailing unsupported harness returned: error: unknown harness: rovo
     15 not ok - trailing unsupported harness returned: /tmp/fmbase/bin/fm-control-lib.sh: line 68: printf: write error: Broken pipe
      5 not ok - unmapped omp prefix returned: error: omp quota mapping covers only the openai-codex and claude-bridge prefixes: ollama/qwen3:8b
     15 not ok - trailing unsupported harness returned: <root>/bin/fm-control-lib.sh: line 68: printf: write error: Broken pipe
    224 <root>/bin/fm-control-lib.sh: line 68: printf: write error: Broken pipe
fmfix: failed runs 0 / 72
Evidence: Harness accept/refuse results unchanged

Source: Harness accept/refuse results unchanged

# fm_control_harness_supported via bin/fm-quota-choose.sh (fixed tree vs base tree), empty quota snapshot
claude:x               base       rc=1  none
claude:x               fix        rc=1  none
agy:x                  base       rc=2  error: unknown harness: agy
agy:x                  fix        rc=2  error: unknown harness: agy
omp:ollama/qwen3:8b    base       rc=2  error: omp quota mapping covers only the openai-codex and claude-bridge prefixes: ollama/qwen3:8b
omp:ollama/qwen3:8b    fix        rc=2  error: omp quota mapping covers only the openai-codex and claude-bridge prefixes: ollama/qwen3:8b
bogus:x                base       rc=2  error: unknown harness: bogus
bogus:x                fix        rc=2  error: unknown harness: bogus
:x                     base       rc=2  error: invalid candidate: :x
:x                     fix        rc=2  error: invalid candidate: :x
claude-extra:x         base       rc=2  error: unknown harness: claude-extra
claude-extra:x         fix        rc=2  error: unknown harness: claude-extra
cla:x                  base       rc=2  error: unknown harness: cla
cla:x                  fix        rc=2  error: unknown harness: cla

# direct library check of every listed harness plus non-members
base: claude=0 codex=0 opencode=0 pi=0 pi-signed=0 grok=0 kimi=0 cursor=0 gemini=0 muse=0 rovo=0 omp=0 agy=0 <empty>=1 bogus=1 CLAUDE=1 claude =1 pi-=1 
fix: claude=0 codex=0 opencode=0 pi=0 pi-signed=0 grok=0 kimi=0 cursor=0 gemini=0 muse=0 rovo=0 omp=0 agy=0 <empty>=1 bogus=1 CLAUDE=1 claude =1 pi-=1 
Evidence: Crash-silent recovery with slow node launches (CI pattern), base vs fixed

Source: Crash-silent recovery with slow node launches (CI pattern), base vs fixed

delay 2s: base elapsed 7s not ok - ...wedged its runner before result.terminal | fix elapsed 9s exit=0 delay 3s: base elapsed 6s not ok - ...wedged... | fix elapsed 11s exit=0

== each PATH-resolved node launch delayed 0.5s (bash polling at normal speed)
base: crash-silent wait elapsed: 5s real	0m17.142s exit=0 
fix: crash-silent wait elapsed: 5s real	0m16.934s exit=0 
== each PATH-resolved node launch delayed 1s (bash polling at normal speed)
base: crash-silent wait elapsed: 6s real	0m24.526s exit=0 
fix: crash-silent wait elapsed: 6s real	0m24.561s exit=0 
== each PATH-resolved node launch delayed 2s (bash polling at normal speed)
base: crash-silent wait elapsed: 7s not ok - inner host crash during result.silent wedged its runner before result.terminal real	0m27.607s exit=1 
fix: crash-silent wait elapsed: 9s real	0m39.566s exit=0 
== each PATH-resolved node launch delayed 3s (bash polling at normal speed)
base: crash-silent wait elapsed: 6s not ok - inner host crash during result.silent wedged its runner before result.terminal real	0m35.783s exit=1 
fix: crash-silent wait elapsed: 11s real	0m54.683s exit=0 
Evidence: Simulated wedged runner still fails with specific message within budget

Source: Simulated wedged runner still fails with specific message within budget

crash-silent wait elapsed: 20s not ok - inner host crash during result.silent wedged its runner before result.terminal real 0m24.635s

not-autohandled: flow-source (left for the handler; still unacknowledged)
ok - one external adapter registers, invokes, captures unhandled evidence, classifies, and terminally retires end to end
crash-silent wait elapsed: 20s
not ok - inner host crash during result.silent wedged its runner before result.terminal

real	0m24.635s
user	0m4.425s
sys	0m5.193s
exit=1
Evidence: Aggregate wedge run blocked by host-only remote lane failure

Source: Aggregate wedge run blocked by host-only remote lane failure

ok - unknown extension conformance section selectors fail before setup
error[binding-failed]: error[process-failed]: extension handshake exited nonzero
not ok - remote transport did not publish the binding (missing: 'bound: [email protected]')
--- output ---

error: cannot establish the source launch boundary: example-file
not-autohandled: flow-source (left for the handler; still unacknowledged)
ok - the section coordinator propagates ordered failures and bounded cleanup
not ok - an isolated extension conformance section failed

real	0m3.859s
user	0m2.397s
sys	0m2.936s
exit=1
Evidence: CPU-load sweep (24/36 busy processes), base vs fixed

Source: CPU-load sweep (24/36 busy processes), base vs fixed

== no extra load
base: crash-silent wait elapsed: 4s real	0m10.131s exit=0 
fix: crash-silent wait elapsed: 3s real	0m9.875s exit=0 
== load: 24 busy 'yes' processes on 24 cores
run 1 base: crash-silent wait elapsed: 10s real	0m32.615s exit=0 
run 1 fix: crash-silent wait elapsed: 10s real	0m31.929s exit=0 
run 2 base: crash-silent wait elapsed: 9s real	0m31.631s exit=0 
run 2 fix: crash-silent wait elapsed: 11s real	0m34.266s exit=0 
== load: 36 busy 'yes' processes on 24 cores
run 1 base: crash-silent wait elapsed: 16s real	0m45.395s exit=0 
run 1 fix: crash-silent wait elapsed: 14s real	0m45.180s exit=0 
run 2 base: crash-silent wait elapsed: 13s real	0m42.031s exit=0 
run 2 fix: crash-silent wait elapsed: 12s real	0m39.829s exit=0 
Evidence: Heavy CPU load (72 busy processes): segment exceeds coordinator budget

Source: Heavy CPU load (72 busy processes): segment exceeds coordinator budget

CPU load: 72 busy 'yes' processes on 24 cores (3x oversubscribed)
run 1 base: crash-silent wait elapsed: 24s ok - inner result.silent host crash releases the parent lifecycle lock before terminal retry real	1m19.716s exit=0 
run 1 fix: crash-silent wait elapsed: 20s not ok - inner host crash during result.silent wedged its runner before result.terminal real	1m8.725s exit=1 
run 2 base: crash-silent wait elapsed: 23s ok - inner result.silent host crash releases the parent lifecycle lock before terminal retry real	1m18.310s exit=0 
run 2 fix: crash-silent wait elapsed: 20s not ok - inner host crash during result.silent wedged its runner before result.terminal real	1m2.624s exit=1 
run 3 base: crash-silent wait elapsed: 25s ok - inner result.silent host crash releases the parent lifecycle lock before terminal retry real	1m17.816s exit=0 
run 3 fix: crash-silent wait elapsed: 20s not ok - inner host crash during result.silent wedged its runner before result.terminal real	1m4.962s exit=1 

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 7 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Unmapped omp prefix with SIGPIPE ignored under concurrent load returns only the single expected error line (no 'printf: write error: Broken pipe') ✅ pass live sigpipe-repro-base.txt (306/4800 bad on base) vs sigpipe-repro-fixed.txt (0/14400 on fix)
tests/fm-quota-choose.test.sh passes reliably with SIGPIPE ignored, as on CI (the failing CI check) ✅ pass live quota-choose-test-sigpipe-ignored.txt: base 32/72 failed incl. exact CI assertion; fix 0/72
Harness checks accept every verified harness and refuse unknown, empty, case-variant and prefix names exactly as before ✅ pass live harness-supported-behavior.txt (base and fix identical through fm-quota-choose.sh and direct library calls)
Crash-silent recovery that is slow because process launches are slow (CI pattern) now passes where the old 400-poll wait reported a wedge ✅ pass live extension-binding-slow-launch.txt: 2-3 s node-launch delay -> base 'wedged its runner before result.terminal', fix passes
A really wedged runner still fails with the specific 'wedged its runner' message after the 20 s deadline, below the 34 s coordinator budget (segment run) ✅ pass live extension-binding-wedged-runner.txt: elapsed 20s, specific not-ok message, segment total 24.6s
The wedged-runner failure shows through the aggregate section coordinator before its 34 s timeout ⏸️ untested no On this NixOS host, the aggregate run stops early in the remote-activation lane. bin/fm-remote-job-lib.sh builds a fixed child PATH, and on this host no python3 is reachable from it. The base tree fai…
Lifecycle-flow segment of tests/fm-extension-binding.test.sh passes normally on the fixed tree ✅ pass live FM_EXTENSION_BINDING_SEGMENT=lifecycle-flow run: 'all extension-binding tests passed'; load sweep with no extra load: fix exit=0
Per-home treehouse pool behavior of this branch still works at the target commit (regression check) ✅ pass live bash tests/fm-treehouse.test.sh with real treehouse v2.3.0 and bash tests/fm-spawn-pool-base-freshen.test.sh: both pass
  • trap &#39;&#39; PIPE; sigpipe-repro.sh &lt;root&gt; 48 100|300: the exact 'unmapped omp prefix' bin/fm-quota-choose.sh command, 48 concurrent workers, base tree vs fixed tree
  • trap &#39;&#39; PIPE; bash tests/fm-quota-choose.test.sh x72 per tree (24 concurrent copies x3 rounds plus 24 busy CPU processes), base vs fixed
  • bin/fm-quota-choose.sh --candidate &lt;claude|agy|omp:ollama/qwen3:8b|bogus|:x|claude-extra|cla&gt; plus direct fm_control_harness_supported calls for all 13 harnesses and non-members, base vs fixed
  • FM_EXTENSION_BINDING_SEGMENT=lifecycle-flow bash tests/fm-extension-binding.test.sh on the fixed tree (python3 beside node in a temp tool dir)
  • lifecycle-flow segment, base vs fixed, with each PATH-resolved node launch delayed 0.5/1/2/3 s (models CI: slow process start, fast bash polling)
  • lifecycle-flow segment with a never-exiting start process (simulated wedge), standalone and through the aggregate bash tests/fm-extension-binding.test.sh
  • lifecycle-flow segment, base vs fixed, under CPU oversubscription of 24, 36 and 72 busy processes on 24 cores, with recovery-time instrumentation
  • bash tests/fm-treehouse.test.sh (real treehouse v2.3.0, TREEHOUSE_ROOT unset) and bash tests/fm-spawn-pool-base-freshen.test.sh as a branch regression check
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@BenWilcox8 BenWilcox8 closed this Nov 11, 2026
@BenWilcox8 BenWilcox8 reopened this Nov 11, 2026
Treehouse names a pool after the origin URL of the project. Homes that
each hold their own clone of one project used one shared pool. Treehouse
v2.3.0 gives an idle slot to any clone that asks, so a worker in one home
could get a worktree of the clone of another home. Cleanup then refused
the slot, or returned a slot that was not its own.

fm-spawn.sh now runs `treehouse get` with TREEHOUSE_ROOT set to a root
that is private to the home. fm_treehouse_home_root in fm-wake-lib.sh
makes this root from the physical path of the home. The root is under
~/.treehouse/firstmate-homes/, not inside the home, so harnesses do not
read the supervisor AGENTS.md of the home from a parent directory.

No slot moves. A slot taken before this change keeps its recorded path.
`treehouse return <path>` finds the pool of a slot from that path, so
cleanup returns old and new slots. The cross-home project lock stays
shared because old slots stay in the shared pool.

Treehouse reads TREEHOUSE_ROOT from v2.2.0. Bootstrap now reports an
older treehouse as MISSING, and the CI pin moves from v2.0.1 to v2.3.0.
The new fm-treehouse.sh runs treehouse against the pool of the home, for
example `fm-treehouse.sh <project-dir> status`.
fm_control_harness_supported returned from its loop at the first match.
The printf that fed the loop could then write to a closed pipe. When
SIGPIPE is ignored, as on CI runners, bash printed "printf: write error:
Broken pipe" to stderr. tests/fm-quota-choose.test.sh captures stderr, so
the stray line failed its error comparisons. The loop now reads the full
list before it returns. This is the same fix as upstream Firstmate
5df1294 (kunchenguid#5389).

tests/fm-extension-binding.test.sh gave crash recovery after a killed
result.silent host only 400 polls of 10 ms. On a loaded CI shard the
recovery took longer, and the test reported a wedged runner. The wait now
uses a 20-second wall-clock deadline. This is below the 34-second budget
of the section coordinator, so a real wedge still fails here.
@BenWilcox8
BenWilcox8 force-pushed the fm/treehouse-pool-per-clone-p1 branch from aeef0ef to 6833d4b Compare November 11, 2026 03:14
@BenWilcox8
BenWilcox8 merged commit 9d63b2e into main Nov 11, 2026
39 of 41 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