Repository navigation
fix(bin): prevent treehouse allocation from detaching live work - #25
Merged
Merged
Conversation
`treehouse status` reports a pool slot as available when it has no lease, no live process, and a clean working tree. It does not consider whether HEAD carries commits unreachable from the default branch, so a slot holding a finished-but-unlanded branch is allocatable and the next `treehouse get` detaches it. Restarts make this reachable: they leave slot ownership recorded as either nothing or a stale value, and both read as free. The check has to run before allocation. `treehouse get` resets the slot while acquiring it, before it returns a path, and fm-spawn only learns the worktree by polling the pane's current path afterwards, so a check placed there inspects a slot whose evidence has already been erased. Add bin/fm-worktree-guard.sh, called from bin/fm-spawn.sh before any endpoint exists. It reads treehouse's own available verdict from `status --json` rather than reimplementing eligibility, then applies an offline emptiness test per slot using --no-optional-locks so another lane's index is never written. On evidence it refuses and names the slot, the evidence, the apparent owning task, and what would release it. Ownership resolves through fm_pid_identity, never a bare pid: fm-spawn now records worktree_owner_pid and worktree_owner_identity into the existing state/<id>.meta. Only an identity match reads alive, only a recorded identity that no longer matches reads dead, and an absent record reads unresolved rather than as a released slot, so a post-reboot reused pid cannot read as a live owner. The guard never resets, cleans, forces, discards, or releases anything. bin/fm-teardown.sh remains the sole releaser of a slot holding work and the owner of the complete landed-work test. Uncommitted content is separately protected by treehouse itself, which reports such a slot dirty and refuses to reclaim one even when every slot in an exhausted pool is dirty, so the exposure closed here is specifically a clean working tree plus commits not on the default branch. Suites that spawn a crewmate stubbed treehouse as a silent exit 0, which the guard correctly refuses because the real binary prints [] for an empty pool and never nothing. Add fm_fake_treehouse to tests/lib.sh so that one faithful stub is shared rather than re-rolled per suite. Empirical basis: docs/verification/worktree-allocation.md.
fm-secondmate-harness builds its fakebin without any treehouse stub and runs with a BASE_PATH that excludes the real binary. That was invisible while fm-spawn only typed `treehouse get` into the pane; the guard runs `treehouse status` from fm-spawn's own environment before allocating. The Herdr presentation comparison normalizes per-run container ids; the worktree owner pid and identity vary per run for the same reason, so they belong in that normalization.
sbracewell64
force-pushed
the
fm/treehouse-lease-restart-durability
branch
from
August 2, 2026 16:24
0327bd0 to
7dee31e
Compare
CI pins Treehouse v2.0.1 via bin/fm-install-treehouse.sh, and that build has no `status --json` flag at all: passing it exits 1 with "unknown flag". The guard required that flag, so every Treehouse-backed spawn refused on the pinned build and four real-herdr-gated suites failed. The same defect exists on v2.0.1 - it also reports a clean slot holding an unlanded branch as available - so the guard must still inspect the pool there rather than refuse every spawn. Probe capability from `status --help` advertising --json, not from the error text or a version string, and fall back to the human-readable table. That table needs two compensations: a path under $HOME is abbreviated with a leading tilde, and a slot may be followed by indented process continuation lines. Every non-blank, non-indented line must parse or the guard refuses, so a dropped row cannot leave a slot uninspected. jq is now required only on the --json path.
The guard probes `status --help` for --json before choosing a format, so a stub that answers every `status` invocation with [] makes the probe see no --json, fall back to the human-readable table, and then fail to parse [] as a table row. Model all three shapes the guard uses: help advertising --json, --json returning [] for an empty pool, and plain status printing nothing, which is what an empty pool looks like in that format.
bin/fm-lint.sh pins shellcheck and refuses to run under any other version, so local and CI cannot diverge on lint. Treehouse has no equivalent: CI installs the version pinned in bin/fm-install-treehouse.sh while a developer machine runs whatever is on PATH, and nothing reconciles them. This is a fleet-wide property of how suites are verified, not a detail of any one change, and it has already cost one red CI run.
sbracewell64
added a commit
that referenced
this pull request
Aug 9, 2026
* fix(bin): refuse spawns that would reclaim a still-owned pool slot `treehouse status` reports a pool slot as available when it has no lease, no live process, and a clean working tree. It does not consider whether HEAD carries commits unreachable from the default branch, so a slot holding a finished-but-unlanded branch is allocatable and the next `treehouse get` detaches it. Restarts make this reachable: they leave slot ownership recorded as either nothing or a stale value, and both read as free. The check has to run before allocation. `treehouse get` resets the slot while acquiring it, before it returns a path, and fm-spawn only learns the worktree by polling the pane's current path afterwards, so a check placed there inspects a slot whose evidence has already been erased. Add bin/fm-worktree-guard.sh, called from bin/fm-spawn.sh before any endpoint exists. It reads treehouse's own available verdict from `status --json` rather than reimplementing eligibility, then applies an offline emptiness test per slot using --no-optional-locks so another lane's index is never written. On evidence it refuses and names the slot, the evidence, the apparent owning task, and what would release it. Ownership resolves through fm_pid_identity, never a bare pid: fm-spawn now records worktree_owner_pid and worktree_owner_identity into the existing state/<id>.meta. Only an identity match reads alive, only a recorded identity that no longer matches reads dead, and an absent record reads unresolved rather than as a released slot, so a post-reboot reused pid cannot read as a live owner. The guard never resets, cleans, forces, discards, or releases anything. bin/fm-teardown.sh remains the sole releaser of a slot holding work and the owner of the complete landed-work test. Uncommitted content is separately protected by treehouse itself, which reports such a slot dirty and refuses to reclaim one even when every slot in an exhausted pool is dirty, so the exposure closed here is specifically a clean working tree plus commits not on the default branch. Suites that spawn a crewmate stubbed treehouse as a silent exit 0, which the guard correctly refuses because the real binary prints [] for an empty pool and never nothing. Add fm_fake_treehouse to tests/lib.sh so that one faithful stub is shared rather than re-rolled per suite. Empirical basis: docs/verification/worktree-allocation.md. * test: model treehouse status in the remaining spawn fakes fm-secondmate-harness builds its fakebin without any treehouse stub and runs with a BASE_PATH that excludes the real binary. That was invisible while fm-spawn only typed `treehouse get` into the pane; the guard runs `treehouse status` from fm-spawn's own environment before allocating. The Herdr presentation comparison normalizes per-run container ids; the worktree owner pid and identity vary per run for the same reason, so they belong in that normalization. * no-mistakes(review): Align worktree guard with allocation safety contract * no-mistakes(review): Validate treehouse JSON schema before allocation * no-mistakes(document): Document safe Treehouse allocation * fix(bin): inspect Treehouse pools on builds without status --json CI pins Treehouse v2.0.1 via bin/fm-install-treehouse.sh, and that build has no `status --json` flag at all: passing it exits 1 with "unknown flag". The guard required that flag, so every Treehouse-backed spawn refused on the pinned build and four real-herdr-gated suites failed. The same defect exists on v2.0.1 - it also reports a clean slot holding an unlanded branch as available - so the guard must still inspect the pool there rather than refuse every spawn. Probe capability from `status --help` advertising --json, not from the error text or a version string, and fall back to the human-readable table. That table needs two compensations: a path under $HOME is abbreviated with a leading tilde, and a slot may be followed by indented process continuation lines. Every non-blank, non-indented line must parse or the guard refuses, so a dropped row cannot leave a slot uninspected. jq is now required only on the --json path. * test: model the treehouse status capability probe in spawn fakes The guard probes `status --help` for --json before choosing a format, so a stub that answers every `status` invocation with [] makes the probe see no --json, fall back to the human-readable table, and then fail to parse [] as a table row. Model all three shapes the guard uses: help advertising --json, --json returning [] for an empty pool, and plain status printing nothing, which is what an empty pool looks like in that format. * docs: record that local Treehouse verification does not prove CI green bin/fm-lint.sh pins shellcheck and refuses to run under any other version, so local and CI cannot diverge on lint. Treehouse has no equivalent: CI installs the version pinned in bin/fm-install-treehouse.sh while a developer machine runs whatever is on PATH, and nothing reconciles them. This is a fleet-wide property of how suites are verified, not a detail of any one change, and it has already cost one red CI run.
sbracewell64
added a commit
that referenced
this pull request
Aug 10, 2026
* fix(bin): refuse spawns that would reclaim a still-owned pool slot `treehouse status` reports a pool slot as available when it has no lease, no live process, and a clean working tree. It does not consider whether HEAD carries commits unreachable from the default branch, so a slot holding a finished-but-unlanded branch is allocatable and the next `treehouse get` detaches it. Restarts make this reachable: they leave slot ownership recorded as either nothing or a stale value, and both read as free. The check has to run before allocation. `treehouse get` resets the slot while acquiring it, before it returns a path, and fm-spawn only learns the worktree by polling the pane's current path afterwards, so a check placed there inspects a slot whose evidence has already been erased. Add bin/fm-worktree-guard.sh, called from bin/fm-spawn.sh before any endpoint exists. It reads treehouse's own available verdict from `status --json` rather than reimplementing eligibility, then applies an offline emptiness test per slot using --no-optional-locks so another lane's index is never written. On evidence it refuses and names the slot, the evidence, the apparent owning task, and what would release it. Ownership resolves through fm_pid_identity, never a bare pid: fm-spawn now records worktree_owner_pid and worktree_owner_identity into the existing state/<id>.meta. Only an identity match reads alive, only a recorded identity that no longer matches reads dead, and an absent record reads unresolved rather than as a released slot, so a post-reboot reused pid cannot read as a live owner. The guard never resets, cleans, forces, discards, or releases anything. bin/fm-teardown.sh remains the sole releaser of a slot holding work and the owner of the complete landed-work test. Uncommitted content is separately protected by treehouse itself, which reports such a slot dirty and refuses to reclaim one even when every slot in an exhausted pool is dirty, so the exposure closed here is specifically a clean working tree plus commits not on the default branch. Suites that spawn a crewmate stubbed treehouse as a silent exit 0, which the guard correctly refuses because the real binary prints [] for an empty pool and never nothing. Add fm_fake_treehouse to tests/lib.sh so that one faithful stub is shared rather than re-rolled per suite. Empirical basis: docs/verification/worktree-allocation.md. * test: model treehouse status in the remaining spawn fakes fm-secondmate-harness builds its fakebin without any treehouse stub and runs with a BASE_PATH that excludes the real binary. That was invisible while fm-spawn only typed `treehouse get` into the pane; the guard runs `treehouse status` from fm-spawn's own environment before allocating. The Herdr presentation comparison normalizes per-run container ids; the worktree owner pid and identity vary per run for the same reason, so they belong in that normalization. * no-mistakes(review): Align worktree guard with allocation safety contract * no-mistakes(review): Validate treehouse JSON schema before allocation * no-mistakes(document): Document safe Treehouse allocation * fix(bin): inspect Treehouse pools on builds without status --json CI pins Treehouse v2.0.1 via bin/fm-install-treehouse.sh, and that build has no `status --json` flag at all: passing it exits 1 with "unknown flag". The guard required that flag, so every Treehouse-backed spawn refused on the pinned build and four real-herdr-gated suites failed. The same defect exists on v2.0.1 - it also reports a clean slot holding an unlanded branch as available - so the guard must still inspect the pool there rather than refuse every spawn. Probe capability from `status --help` advertising --json, not from the error text or a version string, and fall back to the human-readable table. That table needs two compensations: a path under $HOME is abbreviated with a leading tilde, and a slot may be followed by indented process continuation lines. Every non-blank, non-indented line must parse or the guard refuses, so a dropped row cannot leave a slot uninspected. jq is now required only on the --json path. * test: model the treehouse status capability probe in spawn fakes The guard probes `status --help` for --json before choosing a format, so a stub that answers every `status` invocation with [] makes the probe see no --json, fall back to the human-readable table, and then fail to parse [] as a table row. Model all three shapes the guard uses: help advertising --json, --json returning [] for an empty pool, and plain status printing nothing, which is what an empty pool looks like in that format. * docs: record that local Treehouse verification does not prove CI green bin/fm-lint.sh pins shellcheck and refuses to run under any other version, so local and CI cannot diverge on lint. Treehouse has no equivalent: CI installs the version pinned in bin/fm-install-treehouse.sh while a developer machine runs whatever is on PATH, and nothing reconciles them. This is a fleet-wide property of how suites are verified, not a detail of any one change, and it has already cost one red CI run.
sbracewell64
added a commit
that referenced
this pull request
Aug 11, 2026
* fix(bin): refuse spawns that would reclaim a still-owned pool slot `treehouse status` reports a pool slot as available when it has no lease, no live process, and a clean working tree. It does not consider whether HEAD carries commits unreachable from the default branch, so a slot holding a finished-but-unlanded branch is allocatable and the next `treehouse get` detaches it. Restarts make this reachable: they leave slot ownership recorded as either nothing or a stale value, and both read as free. The check has to run before allocation. `treehouse get` resets the slot while acquiring it, before it returns a path, and fm-spawn only learns the worktree by polling the pane's current path afterwards, so a check placed there inspects a slot whose evidence has already been erased. Add bin/fm-worktree-guard.sh, called from bin/fm-spawn.sh before any endpoint exists. It reads treehouse's own available verdict from `status --json` rather than reimplementing eligibility, then applies an offline emptiness test per slot using --no-optional-locks so another lane's index is never written. On evidence it refuses and names the slot, the evidence, the apparent owning task, and what would release it. Ownership resolves through fm_pid_identity, never a bare pid: fm-spawn now records worktree_owner_pid and worktree_owner_identity into the existing state/<id>.meta. Only an identity match reads alive, only a recorded identity that no longer matches reads dead, and an absent record reads unresolved rather than as a released slot, so a post-reboot reused pid cannot read as a live owner. The guard never resets, cleans, forces, discards, or releases anything. bin/fm-teardown.sh remains the sole releaser of a slot holding work and the owner of the complete landed-work test. Uncommitted content is separately protected by treehouse itself, which reports such a slot dirty and refuses to reclaim one even when every slot in an exhausted pool is dirty, so the exposure closed here is specifically a clean working tree plus commits not on the default branch. Suites that spawn a crewmate stubbed treehouse as a silent exit 0, which the guard correctly refuses because the real binary prints [] for an empty pool and never nothing. Add fm_fake_treehouse to tests/lib.sh so that one faithful stub is shared rather than re-rolled per suite. Empirical basis: docs/verification/worktree-allocation.md. * test: model treehouse status in the remaining spawn fakes fm-secondmate-harness builds its fakebin without any treehouse stub and runs with a BASE_PATH that excludes the real binary. That was invisible while fm-spawn only typed `treehouse get` into the pane; the guard runs `treehouse status` from fm-spawn's own environment before allocating. The Herdr presentation comparison normalizes per-run container ids; the worktree owner pid and identity vary per run for the same reason, so they belong in that normalization. * no-mistakes(review): Align worktree guard with allocation safety contract * no-mistakes(review): Validate treehouse JSON schema before allocation * no-mistakes(document): Document safe Treehouse allocation * fix(bin): inspect Treehouse pools on builds without status --json CI pins Treehouse v2.0.1 via bin/fm-install-treehouse.sh, and that build has no `status --json` flag at all: passing it exits 1 with "unknown flag". The guard required that flag, so every Treehouse-backed spawn refused on the pinned build and four real-herdr-gated suites failed. The same defect exists on v2.0.1 - it also reports a clean slot holding an unlanded branch as available - so the guard must still inspect the pool there rather than refuse every spawn. Probe capability from `status --help` advertising --json, not from the error text or a version string, and fall back to the human-readable table. That table needs two compensations: a path under $HOME is abbreviated with a leading tilde, and a slot may be followed by indented process continuation lines. Every non-blank, non-indented line must parse or the guard refuses, so a dropped row cannot leave a slot uninspected. jq is now required only on the --json path. * test: model the treehouse status capability probe in spawn fakes The guard probes `status --help` for --json before choosing a format, so a stub that answers every `status` invocation with [] makes the probe see no --json, fall back to the human-readable table, and then fail to parse [] as a table row. Model all three shapes the guard uses: help advertising --json, --json returning [] for an empty pool, and plain status printing nothing, which is what an empty pool looks like in that format. * docs: record that local Treehouse verification does not prove CI green bin/fm-lint.sh pins shellcheck and refuses to run under any other version, so local and CI cannot diverge on lint. Treehouse has no equivalent: CI installs the version pinned in bin/fm-install-treehouse.sh while a developer machine runs whatever is on PATH, and nothing reconciles them. This is a fleet-wide property of how suites are verified, not a detail of any one change, and it has already cost one red CI run.
sbracewell64
added a commit
that referenced
this pull request
Aug 11, 2026
* fix(bin): refuse spawns that would reclaim a still-owned pool slot `treehouse status` reports a pool slot as available when it has no lease, no live process, and a clean working tree. It does not consider whether HEAD carries commits unreachable from the default branch, so a slot holding a finished-but-unlanded branch is allocatable and the next `treehouse get` detaches it. Restarts make this reachable: they leave slot ownership recorded as either nothing or a stale value, and both read as free. The check has to run before allocation. `treehouse get` resets the slot while acquiring it, before it returns a path, and fm-spawn only learns the worktree by polling the pane's current path afterwards, so a check placed there inspects a slot whose evidence has already been erased. Add bin/fm-worktree-guard.sh, called from bin/fm-spawn.sh before any endpoint exists. It reads treehouse's own available verdict from `status --json` rather than reimplementing eligibility, then applies an offline emptiness test per slot using --no-optional-locks so another lane's index is never written. On evidence it refuses and names the slot, the evidence, the apparent owning task, and what would release it. Ownership resolves through fm_pid_identity, never a bare pid: fm-spawn now records worktree_owner_pid and worktree_owner_identity into the existing state/<id>.meta. Only an identity match reads alive, only a recorded identity that no longer matches reads dead, and an absent record reads unresolved rather than as a released slot, so a post-reboot reused pid cannot read as a live owner. The guard never resets, cleans, forces, discards, or releases anything. bin/fm-teardown.sh remains the sole releaser of a slot holding work and the owner of the complete landed-work test. Uncommitted content is separately protected by treehouse itself, which reports such a slot dirty and refuses to reclaim one even when every slot in an exhausted pool is dirty, so the exposure closed here is specifically a clean working tree plus commits not on the default branch. Suites that spawn a crewmate stubbed treehouse as a silent exit 0, which the guard correctly refuses because the real binary prints [] for an empty pool and never nothing. Add fm_fake_treehouse to tests/lib.sh so that one faithful stub is shared rather than re-rolled per suite. Empirical basis: docs/verification/worktree-allocation.md. * test: model treehouse status in the remaining spawn fakes fm-secondmate-harness builds its fakebin without any treehouse stub and runs with a BASE_PATH that excludes the real binary. That was invisible while fm-spawn only typed `treehouse get` into the pane; the guard runs `treehouse status` from fm-spawn's own environment before allocating. The Herdr presentation comparison normalizes per-run container ids; the worktree owner pid and identity vary per run for the same reason, so they belong in that normalization. * no-mistakes(review): Align worktree guard with allocation safety contract * no-mistakes(review): Validate treehouse JSON schema before allocation * no-mistakes(document): Document safe Treehouse allocation * fix(bin): inspect Treehouse pools on builds without status --json CI pins Treehouse v2.0.1 via bin/fm-install-treehouse.sh, and that build has no `status --json` flag at all: passing it exits 1 with "unknown flag". The guard required that flag, so every Treehouse-backed spawn refused on the pinned build and four real-herdr-gated suites failed. The same defect exists on v2.0.1 - it also reports a clean slot holding an unlanded branch as available - so the guard must still inspect the pool there rather than refuse every spawn. Probe capability from `status --help` advertising --json, not from the error text or a version string, and fall back to the human-readable table. That table needs two compensations: a path under $HOME is abbreviated with a leading tilde, and a slot may be followed by indented process continuation lines. Every non-blank, non-indented line must parse or the guard refuses, so a dropped row cannot leave a slot uninspected. jq is now required only on the --json path. * test: model the treehouse status capability probe in spawn fakes The guard probes `status --help` for --json before choosing a format, so a stub that answers every `status` invocation with [] makes the probe see no --json, fall back to the human-readable table, and then fail to parse [] as a table row. Model all three shapes the guard uses: help advertising --json, --json returning [] for an empty pool, and plain status printing nothing, which is what an empty pool looks like in that format. * docs: record that local Treehouse verification does not prove CI green bin/fm-lint.sh pins shellcheck and refuses to run under any other version, so local and CI cannot diverge on lint. Treehouse has no equivalent: CI installs the version pinned in bin/fm-install-treehouse.sh while a developer machine runs whatever is on PATH, and nothing reconciles them. This is a fleet-wide property of how suites are verified, not a detail of any one change, and it has already cost one red CI run.
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
Stop firstmate's crewmate spawn from being handed a treehouse pool slot that still holds live work (upstream kunchenguid#1441). Twice on 2026-08-02, after host restarts wiped or staled treehouse's owner records, a slot holding an unlanded branch was allocated and detached.
Deliberate decisions behind this diff, reviewed and approved by firstmate before implementation - these are choices, not oversights:
The guard runs BEFORE
treehouse get, not after. The original task asked for a post-allocation check on the accepted worktree. I measured thattreehouse getresets the slot while acquiring it (its own help: "Unlike 'get', enter does not acquire, reset, or return the worktree"), and fm-spawn only learns the worktree by polling the pane's current path afterwards - so a post-hoc check inspects a slot whose evidence is already erased and passes every time. Firstmate approved this deviation from the original wording.The stated defect is deliberately narrow: clean working tree PLUS commits unreachable from the default branch. Uncommitted content is already protected by treehouse itself, which reports such a slot dirty and refuses to reclaim one even when an exhausted pool is entirely dirty. The original report claimed uncommitted work was the exposure; that was measured false, and firstmate approved keeping the narrowed mechanism rather than widening it back.
The guard reads treehouse's own
availableverdict fromstatus --jsoninstead of reimplementing eligibility, so a treehouse version bump cannot silently desync it. jq is required and its absence is a deliberate refusal: the human-readable status table abbreviates $HOME paths to a leading ~ and appends per-slot process continuation lines, so it is not a parseable contract. This is a knowing new dependency on the crewmate spawn path.It deliberately does NOT reuse work_is_landed() from bin/fm-teardown.sh, even though that is the repo's existing landed-work owner. That function fetches, calls
gh pr view, and computes patch-ids - per candidate slot, per spawn - and answers a different question ("may I destroy this?") where a guard must be conservative. The guard asks the strictly weaker, offline question "is this slot demonstrably empty?" and never authorizes destruction, so it does not restate or weaken teardown's contract.The guard is refuse-only by design. Even an identity-verified dead owner does not release a slot holding unlanded work; bin/fm-teardown.sh remains the sole releaser. FM_WORKTREE_RECLAIM_OK is deliberately scoped to exact worktree paths so it cannot become a standing blanket bypass.
Ownership is a process identity via fm_pid_identity, never a bare pid: a reboot reissues pid numbers, and recorded pre-reboot pids were measured resolving to unrelated live node processes. Empty owner fields deliberately read UNRESOLVED, never dead, so a missing record can never be mistaken for a released slot.
The test changes are required, not incidental. Suites that spawn a crewmate stubbed treehouse as a silent
exit 0, but the real binary prints [] for an empty pool and never nothing, so the guard correctly refuses that stub; tests/lib.sh gains fm_fake_treehouse so one faithful stub is shared instead of re-rolled. fm-secondmate-harness additionally revealed that fm-spawn never previously executed treehouse at all - it only typedtreehouse getinto the pane - so its BASE_PATH legitimately excluded the binary. The Herdr presentation test's normalize_meta gains the two new per-run owner fields alongside the per-run container ids, for the same reason those ids are normalized.Scope was deliberately limited to allocation safety: no re-anchoring of mis-rooted panes, no teardown policy change, no attempt to repair treehouse itself.
treehouse get --leasewas considered and rejected as the larger alternative - it is the real durability fix, but it restructures acquisition across five backends and every lease needs atreehouse returnor the pool leaks permanently, which is teardown policy and out of scope.Nine failures in the full 105-test run were triaged before submitting: seven reproduce identically on a clean origin/main checkout and are pre-existing (Node.js ESM environment failures and supervision/tmux suites affected by the live fleet); two were mine and are fixed.
What Changed
Risk Assessment
✅ Low: The schema-validation fix now fails closed for non-array payloads and malformed entries, preserves valid empty-pool behavior, and the cumulative change conforms to the stated allocation-safety scope.
Testing
Focused guard and spawn-path tests passed; a captured CLI simulation showed a clean available slot with an unlanded commit and stale owner identity was refused after only
treehouse status --json, while its branch, HEAD, and clean state remained unchanged. No visual artifact was applicable because this is a CLI-only change.Evidence: Restart-stale slot refusal transcript
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-worktree-guard.sh:137- The authoritative intent limits this guard to “clean working tree PLUS commits unreachable from the default branch,” but this also refuses a clean named branch whose HEAD is fully reachable from the default branch. Confirm that zero-ahead named branches are intentionally in scope, or remove this additional refusal.bin/fm-worktree-guard.sh:290- AnavailableJSON entry with a missing, null, or empty.pathbecomes an empty TSV field and is silently skipped, allowing the fail-closed guard to approve a pool slot it never inspected. Reject available rows unless required fields—especially an absolute, non-empty string path—are valid.🔧 Fix: Align worktree guard with allocation safety contract
1 error still open:
bin/fm-worktree-guard.sh:269- The fail-closed parser still accepts malformed but valid JSON as an empty/safe pool:null,"", or{}all havelength == 0, and entries missing.statusare silently excluded. Validate that the top level is an array and every entry has the required schema before treating length zero or filteringavailableslots; otherwise a treehouse schema change can bypass the guard.🔧 Fix: Validate treehouse JSON schema before allocation
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-worktree-guard.test.shbash tests/fm-spawn-worktree-settle.test.shbash tests/fm-tangle-guard.test.shManual real-Git-worktree restart simulation invokingbin/fm-worktree-guard.sh check, logging treehouse calls and comparing branch, HEAD, and working-tree state before and after refusalgit status --shortto confirm testing left no transient worktree changesbin/fm-backend.sh:313- The new guard requires jq for every Treehouse-backed spawn, but the bootstrap dependency set still omits jq for tmux. Fixing this requires executable and test changes, which this documentation-only task forbids.✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.