Repository navigation
fix: verify Treehouse slot ownership before teardown - #3837
Merged
Merged
Conversation
Workers were killed when cleanup returned a Treehouse pool slot that a different, live task had already taken. Teardown now proves the slot is genuinely this task's before releasing it: it refuses when another task record claims the same live worktree path, or when the endpoint's working directory contradicts the recorded slot, and that refusal holds under --force. Slot allocation, metadata publication, ownership verification, and slot return are serialized across linked firstmate homes, and forced secondmate cleanup verifies descendant slot ownership before returning any child worktree. Regression coverage drives the scripts with two task records naming one slot path and asserts the live worker survives and its slot is not reset.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (4): Last reviewed commit: "no-mistakes(ci): Fixed teardown so an ex..." | Re-trigger Greptile |
…Git origins to the same Treehouse project-lock identity as absolute clone origins; resolved ShellCheck SC1091 with explicit conditional sourcing; and taught concurrent Herdr teardown coverage to retry expected Treehouse lock contention. Added behavioral regression coverage for bare/absolute origin lock identity. Verified endpoint-safety tests, watcher tests, full CI lint, and the previously failing Herdr teardown assertion
…nge cwd without falsely vetoing cleanup. Removed cwd-based ownership refusal while preserving cross-home record exclusivity and project locking. Updated behavioral coverage for both foreign slot ownership refusal and moved-cwd teardown success. Endpoint-safety, backend, watcher, checkpoint, and targeted lint checks pass. Real Herdr presentation E2E progressed successfully but exceeded the 600s local timeout
Intent
The captain's order in substance: workers were killed by a pool-slot collision during cleanup - never let that happen again. Make worktree-slot return verify the slot is genuinely the task's before releasing it.
What Changed
Risk Assessment
✅ Low: The change now scans registered local Firstmate homes and serializes slot allocation, publication, verification, and return using a shared project identity lock, closing the previously identified collision path without introducing a substantiated material defect.
Testing
The successful changed-test baseline was supplemented with focused teardown, secondmate, and watcher lifecycle tests plus an end-to-end cross-home collision fixture; teardown refused even with
--forcewhile preserving the live worker, slot contents, and both task records, with no regressions observed.Evidence: Cross-home Treehouse slot-collision teardown transcript
Source: Cross-home Treehouse slot-collision teardown transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/fm-teardown.sh:2065- Cross-home ownership verification enumerates the recorded project’s Git worktrees, not Firstmate homes. Real secondmate homes contain separately cloned projects (fm-home-seed.shusesgit clone), so theirstate/*.metafiles are absent from this listing; the project-common-directory locks are likewise different across clones. Concrete sequence: a stale primary record names slot S, Treehouse reuses S for a task in a secondmate clone, and that live task publishes in the secondmate home. Teardown of the stale record scans only the primary state/project worktrees, a dead endpoint supplies no contradictory cwd, and S is still returned, killing the live worker. The new cross-home test does not reproduce the production layout because it places the second home directly in the project’s worktree list. Enumerate actual registered/local Firstmate homes and serialize allocation/publication/return at an identity shared across their project clones.🔧 Fix: Protect slots across cloned Firstmate homes
✅ Re-checked - no issues remain.
🔧 **Test** - 1 issue found → auto-fixed (4) ✅
bin/fm-test-run.sh --changed --exclude-family real-herdr-gated🔧 Fix: Gate teardown locking on genuine Treehouse slots
1 error still open:
bin/fm-test-run.sh --changed --exclude-family real-herdr-gated🔧 Fix: Clarify pooled descendant slot gating
1 error still open:
bin/fm-test-run.sh --changed --exclude-family real-herdr-gated🔧 Fix: Synchronize watcher re-arm test on process exit
1 error still open:
bin/fm-test-run.sh --changed --exclude-family real-herdr-gated🔧 Fix: Wait for watcher cleanup before timeout escalation
✅ Re-checked - no issues remain.
bin/fm-test-run.sh --changed --exclude-family real-herdr-gatedBaseline:bin/fm-test-run.sh --changed --exclude-family real-herdr-gatedtests/fm-teardown-endpoint-safety.test.shtests/fm-secondmate-safety.test.shtests/fm-watch-checkpoint.test.shtests/fm-watch-arm.test.shManual cross-home pool-slot collision: ranbin/fm-teardown.sh stale-task --forceagainst a stale primary record and a live secondmate-clone record sharing one Treehouse slot; verified refusal, live worker survival, payload and metadata preservation, and zero mutating runtime calls✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.