fix(bin): untrack committed hook artifacts and gitignore per-task hook files - #31
Conversation
…ifacts bin/fm-spawn.sh's hook-install writes were already correct (unconditional cat >/printf > on every spawn, verified by the existing tests/fm-spawn-reused-worktree-hooks.test.sh, which passes as-is). The actual bug: PR #20 accidentally committed .claude/settings.local.json - a per-task worktree-resident file that binds one task incarnation's id and busy-gen - onto the default branch, with the content of a torn-down task (teardown-stale-teardown-tooling-cannot-reclaim-stale-wi-c9). Every worktree checked out since then, fresh or handed back from the treehouse pool, starts with that stale file already tracked at HEAD. fm-spawn.sh's runtime overwrite papers over it in the live working tree, but the underlying tracked blob keeps re-seeding new checkouts, and it also makes every such worktree read as dirty in fm-teardown.sh's landed-work check (git status reports it modified, not untracked, so the existing `^\?\? \.claude/` exclusion never matches it). This is what a spawned crewmate actually observed in firstmate-ed399d/6 and /1: hooks still naming the dead task, which touch the wrong state/<id>.turn-ended and report busy/idle under the wrong id. Fix: git rm --cached the file (keeping the live working-tree copy) and gitignore it plus the same class of per-task artifact (.opencode/plugins/fm-busy-state.js, the older fm-turn-end.js name, and the grok/kimi turnend token pointers) so none of them can ever be committed again - bin/fm-spawn.sh's own exclude_path() calls are a per-worktree-local backstop for files git has never tracked, but cannot undo an accidental commit once one lands on the default branch. Adds tests/fm-hook-artifacts-not-tracked.test.sh as a permanent guard: every per-task hook artifact must be gitignored and never tracked, with a control asserting the shared .claude/settings.json stays tracked and visible.
…ok-artifact gitignoring
|
Warning Review limit reached
Next review available in: 35 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
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 |
Intent
fix the reused-worktree stale-hooks bug — root cause was .claude/settings.local.json accidentally COMMITTED to main in PR #20 with a dead task's hooks, so every worktree checked it out as tracked baseline; fix = untrack .claude/settings.local.json + gitignore all per-task hook artifacts (.claude/settings.local.json, .opencode/plugins/fm-busy-state.js, .fm-grok-turnend, .fm-kimi-turnend) so none can be committed again; fm-spawn hook-install was already correct; added tests/fm-hook-artifacts-not-tracked.test.sh regression guard; did not touch fm-teardown.sh per collision
What Changed
.claude/settings.local.jsonfrom tracking — it had been accidentally committed tomainwith a dead task's busy-hook commands, so every worktree checked it out as tracked baseline instead of getting fresh per-task hooks fromfm-spawn..gitignoreentries for all per-task, worktree-resident hook artifacts (.claude/settings.local.json,.opencode/plugins/fm-busy-state.js,.opencode/plugins/fm-turn-end.js,.fm-grok-turnend,.fm-kimi-turnend) so none of them can be committed again, with a comment explaining why a pooled worktree's next tenant would otherwise inherit a stale task's hooks.tests/fm-hook-artifacts-not-tracked.test.shas a regression guard, and corrected a stale claim in.agents/skills/harness-adapters/SKILL.mdthat gitinfo/excludealone gitignores these files — it's now documented as a per-worktree-local backstop, with the tracked root.gitignoreas the actual mechanism.Risk Assessment
✅ Low: The change only deletes a previously-accidentally-committed per-task artifact file and adds matching .gitignore entries plus a regression test; it's non-functional repo hygiene, verified consistent with fm-spawn.sh's actual exclude_path() call sites (settings.local.json, fm-busy-state.js, .fm-grok-turnend, .fm-kimi-turnend), and the shared .claude/settings.json remains tracked.
Testing
Ran the new regression test plus the directly related fm-spawn hook-refresh test and the adjacent gitignore-contract test, all passing on the target commit; additionally reproduced the pre-fix bug in a scratch worktree checked out at the base commit (showing .claude/settings.local.json was tracked and not gitignored there), which confirms the target commit's untrack+gitignore change is a genuine, verifiable fix rather than just passing tests.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
.gitignore:24- The gitignore/test list includes /.opencode/plugins/fm-turn-end.js, but bin/fm-spawn.sh's opencode hook-install writes .opencode/plugins/fm-busy-state.js, not fm-turn-end.js — there's no exclude_path() call site for fm-turn-end.js in fm-spawn.sh despite the .gitignore comment claiming to be 'in sync with the exclude_path() call sites'. It's only referenced in fm-teardown.sh's rm -f scrub list (likely a vestigial/renamed artifact). Harmless (ignoring a path that's never created doesn't hurt), but the comment is slightly inaccurate and the test's coverage for that entry is vacuous.✅ **Test** - passed
✅ No issues found.
bin/fm-test-run.sh tests/fm-hook-artifacts-not-tracked.test.sh (new regression guard) — passbin/fm-test-run.sh tests/fm-spawn-reused-worktree-hooks.test.sh (related fm-spawn hook-refresh logic test) — passbin/fm-test-run.sh tests/fm-gitignore-config.test.sh (adjacent gitignore contract test) — passManual:git worktree add --detach <tmp> 56369d05198713c05da89f18e1fcabe0340c67c4thengit check-ignore -q .claude/settings.local.json(not ignored) andgit ls-files -- .claude/settings.local.json(tracked) — confirmed the bug is present at base commit, absent at target✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.