Repository navigation
fix(bin): resolve Treehouse locks for remote secondmate homes - #3883
Merged
Merged
Conversation
…ondmate homes Every spawn and teardown inside a remote-seeded secondmate home refused, because the project lock's anchor could not be resolved there. fm_firstmate_root_home walks a home's parent bindings upward to find the anchor the lock lives in, and treated a remote parent binding as an error. A remote-seeded home's parent is on another machine, so that walk can never succeed from there - and neither can the home's own local descendants, whose chain terminates at the same record. Both fail closed on every Treehouse-backed spawn and every pool-slot teardown. A remote parent now terminates the walk at the home holding it, which is the correct anchor: a lock taken on this filesystem is neither held nor observable across that boundary, and that home is already the top of the local tree teardown's collect_local_firstmate_states enumerates, since that walk skips remote registry entries for the same reason. Mutual exclusion is unchanged - every home reachable through local parent links still derives one identical lock file per project, and an unreadable binding, an unsupported route, an unreachable local parent, a cycle, and an over-deep chain all still refuse. Origin-less local-only projects keep resolving through their worktree top. Regression coverage pins the anchor for the main-home layout, a local secondmate, a remote-seeded home, and its local child; drives teardown end-to-end in a remote-seeded home; keeps the cross-home slot-ownership refusal across that boundary; and proves two homes still serialize on the one shared lock file.
Confidence Score: 5/5The PR appears safe to merge, with the changed lock boundary matching remote-home provisioning and Treehouse pool ownership. Remote-seeded homes and their project clones are independently provisioned, while each local descendant resolves the same root lock and ownership-state tree; no blocking failure remains. Reviews (1): Last reviewed commit: "no-mistakes(document): Clarify machine-l..." | Re-trigger Greptile |
Intent
Fix the fleet-wide regression where PR 3837's shared Treehouse lock cannot resolve a local root across the remote secondmate boundary, failing every remote spawn and teardown closed. Remote work is fully blocked until this lands.
Context for the PR 3837 reference above: PR 3837 ("verify Treehouse slot ownership before teardown") introduced a per-project lock that serializes Treehouse pool-slot allocation and return across linked firstmate homes, so a cleanup cannot return a pool slot that a different live task has already been handed. That lock is anchored in the root firstmate home's state directory, resolved by walking a home's .fm-secondmate-parent bindings upward until a home with no parent binding is reached. Both bin/fm-spawn.sh and bin/fm-teardown.sh refuse outright when that lock path cannot be resolved.
The regression: a home seeded onto another machine records a parent binding whose route is "remote", and the upward walk treats any non-local route as an error. So inside a remote-seeded secondmate home - and inside every local secondmate home beneath it, whose own chain terminates at that same remote record - the lock never resolves, and every Treehouse-backed spawn and every pool-slot teardown refuses. That is the whole of remote secondmate work.
What Changed
Risk Assessment
✅ Low: The change is narrowly scoped to treating a valid remote parent binding as the local traversal boundary and includes behavioral coverage for resolution, teardown, collision refusal, and lock contention.
Testing
Targeted spawn and teardown suites passed; end-to-end fixtures showed a remote-seeded home successfully spawning and returning its Treehouse slot, preserving both records and the slot on cross-home collision, sharing the lock with local descendants, and changing the reported regression from base failure to local-root resolution. Focused behavioral coverage and reviewer-visible CLI transcripts were added; no broad suite, lint, formatter, or static analysis was run.
Evidence: Remote-seeded Treehouse spawn transcript
Source: Remote-seeded Treehouse spawn transcript
Evidence: Remote-seeded teardown success and collision-refusal transcript
Source: Remote-seeded teardown success and collision-refusal transcript
Evidence: Executable base-versus-fix lock-resolution comparison
Source: Executable base-versus-fix lock-resolution comparison
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.
Inspected the target diff from29015a2604c990233010ee864e9a4d4d14a08b21to5ebf85b8c94f3695c7f784c7598607cdde5da9df.bash tests/fm-teardown-endpoint-safety.test.shAdded and ran focused executable spawn coverage withbash tests/fm-spawn-pool-base-freshen.test.sh.FM_TEST_EVIDENCE=1 bash tests/fm-spawn-pool-base-freshen.test.shFM_TEST_EVIDENCE=1 bash tests/fm-teardown-endpoint-safety.test.shExecutedfm_treehouse_project_lock_pathagainst the base and fixed wake libraries using the same remote-parent fixture; the base refused while the fix resolved the home-local state lock.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.