Skip to content

fix(bin): untrack committed hook artifacts and gitignore per-task hook files - #31

Merged
trillium merged 2 commits into
mainfrom
fm/spawn-hook-refresh-pooled-worktree-gitignore-untrack-b6
Aug 2, 2026
Merged

fix(bin): untrack committed hook artifacts and gitignore per-task hook files#31
trillium merged 2 commits into
mainfrom
fm/spawn-hook-refresh-pooled-worktree-gitignore-untrack-b6

Conversation

@trillium

@trillium trillium commented Aug 2, 2026

Copy link
Copy Markdown
Owner

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

  • Removed .claude/settings.local.json from tracking — it had been accidentally committed to main with a dead task's busy-hook commands, so every worktree checked it out as tracked baseline instead of getting fresh per-task hooks from fm-spawn.
  • Added root .gitignore entries 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.
  • Added tests/fm-hook-artifacts-not-tracked.test.sh as a regression guard, and corrected a stale claim in .agents/skills/harness-adapters/SKILL.md that git info/exclude alone gitignores these files — it's now documented as a per-worktree-local backstop, with the tracked root .gitignore as 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.

⚠️ **Review** - 1 info
  • ℹ️ .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) — pass
  • bin/fm-test-run.sh tests/fm-spawn-reused-worktree-hooks.test.sh (related fm-spawn hook-refresh logic test) — pass
  • bin/fm-test-run.sh tests/fm-gitignore-config.test.sh (adjacent gitignore contract test) — pass
  • Manual: git worktree add --detach <tmp> 56369d05198713c05da89f18e1fcabe0340c67c4 then git check-ignore -q .claude/settings.local.json (not ignored) and git 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.

…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.
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@trillium, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 35 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ca45c024-bdf7-4dbf-bbec-bff8b3d9b4a2

📥 Commits

Reviewing files that changed from the base of the PR and between 56369d0 and 80554e1.

📒 Files selected for processing (4)
  • .agents/skills/harness-adapters/SKILL.md
  • .claude/settings.local.json
  • .gitignore
  • tests/fm-hook-artifacts-not-tracked.test.sh

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@trillium
trillium merged commit 4cabd72 into main Aug 2, 2026
11 checks passed
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.

1 participant