test(spawn): add regression test for reused pooled worktree hook identity - #24
Merged
trillium merged 1 commit intoAug 1, 2026
Conversation
…e regression test bin/fm-spawn.sh already rewrites every harness's hook artifact unconditionally on every spawn (cat/printf >, never skip-if-exists), so a worktree treehouse hands back from its reuse pool gets hooks bound to the current incarnation's id/gen, never a prior tenant's - confirmed by tracing every branch of the harness case statement and by an end-to-end spawn -> teardown -> respawn-into-the-same-worktree reproduction. Adds tests/fm-spawn-reused-worktree-hooks.test.sh as a permanent regression guard for that sequence (claude harness: settings.local.json hook identity, busy-gen uniqueness, and the Stop hook only ever touching its own task's turn-ended marker), and a short comment on the case statement making the overwrite invariant explicit for future harness wiring.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe change documents unconditional hook artifact rewrites and adds an end-to-end test for spawning, tearing down, and respawning in the same pooled worktree. ChangesReused worktree hook validation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
Fix bin/fm-spawn.sh so a reused pooled treehouse worktree never inherits the prior tenant's per-task Claude hook identity (task id, busy-gen). Investigation found the write path already unconditionally overwrites every harness's hook artifact on every spawn (no skip-if-exists), so no functional code change is needed. Add a permanent regression test (tests/fm-spawn-reused-worktree-hooks.test.sh) covering spawn -> teardown -> respawn into the same pooled worktree, asserting the new task's hooks reference only its own id/gen and that firing its Stop hook never touches the prior task's turn-ended marker, plus a one-line invariant comment in fm-spawn.sh documenting the always-overwrite contract for future harness wiring.
What Changed
tests/fm-spawn-reused-worktree-hooks.test.sh, covering spawn → teardown → respawn into the same pooled treehouse worktree, asserting the new task's hooks reference only its own task id/busy-gen and that firing its Stop hook never touches the prior tenant's turn-ended marker.bin/fm-spawn.shdocumenting that the hook-artifact write path unconditionally overwrites every harness's hook identity on each spawn (no skip-if-exists), for future harness wiring.Risk Assessment
✅ Low: The change is a comment-only addition to fm-spawn.sh (no functional code change) plus a new regression test whose assertions I verified against the actual hook-write, teardown-scrub, and busy-gen/turn-ended paths in fm-spawn.sh, fm-teardown.sh, and fm-busy-event.sh.
Testing
The diff (a one-line invariant comment in bin/fm-spawn.sh plus the new tests/fm-spawn-reused-worktree-hooks.test.sh) was exercised directly: the new test drives a real spawn -> teardown -> respawn sequence into the same pooled worktree via fm-spawn.sh/fm-teardown.sh with faked tmux/harness binaries, asserts the reused worktree's .claude/settings.local.json hooks reference only the second task's id and a distinct busy-gen, and fires the installed Stop hook to confirm it touches only the new task's turn-ended marker and never resurrects the prior tenant's — all assertions pass. The test is properly registered in the coverage guard and a portable CI lane, and sibling fm-spawn regression tests remain green, confirming the comment-only source change caused no regressions.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.
bin/fm-test-run.sh tests/fm-spawn-reused-worktree-hooks.test.sh— full end-to-end scenario, passesbin/fm-test-run.sh --check-coverage— new test is accounted for in the complete regression partition (total=106)bin/fm-test-run.sh --list --lane portable-serial— confirmed new test is scheduled in a CI lane (not silently orphaned)bin/fm-test-run.sh tests/fm-spawn-batch.test.sh tests/fm-spawn-dispatch-profile.test.sh tests/fm-spawn-worktree-settle.test.sh— sibling fm-spawn.sh regression tests still pass after the comment-only changegit status --porcelain— worktree left clean, no test artifacts committed✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Summary by CodeRabbit
Bug Fixes
Tests