Skip to content

fix: isolate worktree pools per operational home - #2804

Open
josecarvallo wants to merge 19 commits into
kunchenguid:mainfrom
josecarvallo:fm/fm-pool-por-hogar-r2
Open

fix: isolate worktree pools per operational home#2804
josecarvallo wants to merge 19 commits into
kunchenguid:mainfrom
josecarvallo:fm/fm-pool-por-hogar-r2

Conversation

@josecarvallo

Copy link
Copy Markdown

Summary

  • namespace new Treehouse leases by canonical operational FM_HOME, with FM_POOL_ROOT_BASE as the relocation override
  • fail closed when spawn ownership metadata or pool configuration cannot be authenticated, and serialize custody through destructive teardown
  • resolve custody opt-ins from canonical Git provenance, enforce bounded hooks, and preserve existing live leases
  • update Herdr relaunch coverage and shared documentation for the new ownership contract

Validation

  • no-mistakes review completed with no remaining findings
  • focused custody, spawn, cleanup, timeout, rollback, and Herdr end-to-end tests passed
  • documentation validation completed
  • bin/fm-lint.sh passed

@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (3): Last reviewed commit: "no-mistakes(document): Document Git-prov..." | Re-trigger Greptile

Comment thread bin/fm-project-script-lib.sh Outdated
Comment thread bin/fm-pool-root.sh Outdated
Comment thread bin/fm-pool-root.sh Outdated
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

VISION: mixed. Per-home pool isolation serves peace of mind (two homes must not share a Treehouse pool). Fail-closed custody and authenticated pool config align with scripts stopping safely. It misses "the first mate reads projects but does not change them": Treehouse-backed dispatch writes treehouse.toml into the captain's primary project clone. New pool namespacing is default-on for that dispatch path, not an option. Branch also carries unrelated fork-sync / secondmate-stall commits, which is not a small isolated fix.

Class: default-behavior.

Security: not a product exploit in the review, but Greptile P1s (mutable node_modules influencing custody verdicts; unescaped pool paths in TOML) are real follow-ups after rebase. No bin/backends/herdr.sh. No workflow file. Not a fork-CI approve-block this pass because there are no action_required runs on this HEAD.

Overlap / HOLD: edits bin/fm-spawn.sh, bin/fm-teardown.sh, and bin/fm-watch.sh. Do not land with hold-pair #2637 / #2692, and do not land with #2760 / #2770. Spawn-freshen #2622 / #2693 / #2154 still OPEN and also edit fm-spawn.sh. May relate to #2340. Also edits Herdr docs/tests (docs/herdr-backend.md, tests/fm-backend-herdr-presentation-e2e.test.sh) without touching herdr.sh.

CI: HEAD 55f182cc46c063f8cdf7623b2d358f04a9bf2054. mergeable CONFLICTING, mergeStateStatus DIRTY. ahead 12 / behind 34 (diverged). No workflow runs on this HEAD. No structured no-mistakes-pipeline-attestation:v1 whose head_sha matches THIS HEAD. Greptile FAILURE — not a gate. Do not rebase from this box.

Workflows approved: no (nothing action_required / no runs on HEAD). Land-eligible: NO. Waiting on the author to rebase onto main and isolate the pool work, not on the captain. Captain-flag NOW: no.

Comment thread bin/fm-pool-root.sh
Comment thread bin/fm-spawn.sh Outdated
Treehouse keys a worktree pool by the repository plus the clone's directory
name, not by the checkout, and firstmate clones every project to
$FM_HOME/projects/<name>. Two homes therefore drew from ONE pool while neither
could see the other's task records, so the pool re-leased a slot that the other
home's task still named and whichever task was cleaned up first hard-reset the
copy the other was working in.

Four pieces close that, each the smallest thing that removes the class and none
of them a control layer over treehouse:

- bin/fm-pool-root.sh gives each home its own pool root through the one knob
  treehouse's config exposes, and bin/fm-spawn.sh claims it before asking for a
  slot. It is idempotent, preserves other keys, keeps the file out of the
  clone's status, and refuses a tracked treehouse.toml rather than rewriting
  project content.
- bin/fm-spawn.sh refuses an acquired copy that another task in this home
  already claims, after the slot is acquired and before the base refresh
  touches it. The refusal deliberately returns nothing: `treehouse return`
  terminates processes and hard-resets the copy, which is the damage being
  prevented.
- bin/fm-teardown.sh asks a project's own `check:worktree-custody` script, when
  it published one, after the landed-work verdict and before anything
  destructive, and refuses on its exit 1.
- bin/fm-spawn.sh asks a project's own `pool:release-delivered` script, when it
  published one, before leasing, so a pool exhausted by delivered copies nobody
  handed back stops blocking dispatch. That one is capacity rather than safety,
  so a failure warns and the spawn continues.

Existing leases are untouched: a worktree already handed out keeps its path and
is still returned normally after its clone is re-rooted, so shared pools drain
on their own and only new leases separate.

bin/fm-project-script-lib.sh is the single owner of the "a project opts in by
publishing a script" contract both callers use.
@josecarvallo
josecarvallo force-pushed the fm/fm-pool-por-hogar-r2 branch from 327e106 to 6baafc2 Compare August 23, 2026 01:25
@josecarvallo

Copy link
Copy Markdown
Author

Summary

  • namespace new Treehouse leases by canonical operational FM_HOME, using the full SHA-256 identity so distinct homes cannot collide, with FM_POOL_ROOT_BASE only as the relocation base
  • fail closed when spawn ownership metadata or pool configuration cannot be authenticated, and serialize custody through destructive teardown
  • resolve custody opt-ins from canonical Git provenance, enforce bounded hooks, and preserve existing live leases
  • keep routine dispatch and authenticated custody hooks out of the primary clone, and update Herdr relaunch coverage and shared documentation

Validation

  • no-mistakes review completed through the accepted final gate; central home-pool collision r18 was fixed and proven with the two formerly colliding canonical homes
  • focused custody, spawn, cleanup, timeout, rollback, relaunch, and Herdr end-to-end tests passed, including Treehouse v2.0.0 consumer behavior
  • documentation validation completed
  • ShellCheck 0.11.0 passed; local workflow lint was unavailable because actionlint 1.7.12 is not installed in the validation environment, so CI remains authoritative for workflow lint

Accepted follow-up

  • residual low-probability/atypical transaction, custody, primary-clone, long-basename, and fixture-concurrency findings are recorded with reviewer text, files, and rounds in local backlog card tcglas-firstmate-pool-custody-followup
  • r16 documentation drift was fixed in this PR and remains in that card only as historical evidence

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Re-inspect after the 3:10pm PT 8/22 pass (then HEAD 55f182cc46c0, CONFLICTING/DIRTY, ahead 12 / behind 34). Author pushed; this HEAD is 6baafc21bc6244b44001b1d4a94d445097f78b21. Conflicts are gone (MERGEABLE, UNSTABLE, ahead 19 / behind 0). bin/fm-watch.sh is no longer in the diff. Still HOLD. Do not rebase.

VISION (read current main 1231b6a in full). Inspected bin/fm-pool-root.sh (header + pool-root/view/TOML encoding), bin/fm-spawn.sh (pool-root claim, pool:release-delivered, custody publish), bin/fm-teardown.sh (check:worktree-custody before destructive cleanup), plus docs/tests in the file list. Per-rule: per-home isolation / peace of mind aligns (two homes must not share a Treehouse pool); fail-closed scripts aligns; first mate reads projects but does not change them mixed — this HEAD generates a Git config view under $FM_HOME/state/treehouse-config and claims the primary checkout's treehouse.toml is untouched, which is better than the prior write-into-clone shape, but Greptile still has a P1 that dispatch mutates primary clones and I cannot certify the whole spawn/teardown surface from a patch excerpt; new capability as opt-in does not align — pool namespacing is default-on for Treehouse dispatch, not an option. Custody hooks themselves are opt-in by published script presence.

Class: default-behavior. NEVER auto-eligible.

Security: flag. Greptile P1s still on the thread (mutable node_modules influencing custody verdicts; unescaped/DEL pool paths in TOML; primary-clone mutation; pool:release-delivered running against the primary clone). Not a CI-workflow exploit (no .github files). Not a product remote-exploit in the review, but custody-script authenticity is a real follow-up. Coordinator should flag Firstmate. No bin/backends/herdr.sh.

Overlap / HOLD: still edits bin/fm-spawn.sh and bin/fm-teardown.sh. Do not land with hold-pair #2637 / #2692 (both OPEN), nor with #2760 / #2770 / #2768. Spawn-freshen #2622 / #2693 / #2154 still OPEN and also edit fm-spawn.sh. May relate to open #2340. #2586 teardown rewrite still waiting on author. Isolate the pool work from the spawn/teardown lifecycle before any land discussion.

CI / NM: no structured no-mistakes-pipeline-attestation:v1 whose head_sha matches THIS HEAD. After this-pass first-time-fork approval, Require no-mistakes run 32610308908 completed FAILURE (body compliance). CI run 32610308915 was in_progress at stamp. Greptile is not a gate.

Workflows approved this pass (diff review, no workflow-file risk): 32610308908 (Require no-mistakes), 32610308915 (CI).

Land-eligible: NO. Waiting on the author to isolate the pool work, attach a matching attestation, and get green CI+NM — not on a rebase from this box, and not on the captain. Captain-flag NOW: no.

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.

2 participants