fix(scripts): discover agents when the checkout is a Claude worktree #228

Merged
Defame1297 merged 1 commits from fix/worktree-agent-discovery into main 2026-11-27 08:03:59 +00:00
Owner

Fixes #199

Problem

scripts/check-apm-agents-valid.sh filtered its find output with -not -path '*/.claude/worktrees/*'. find matches that glob against absolute paths. When the checkout is itself an agent worktree at <repo>/.claude/worktrees/<name>/, every path contains that segment, so every agent file was excluded. The gate then failed with "N of N tracked agent files were not discovered", and agents running in isolated worktrees couldn't push.

Change

  • scripts/check-apm-agents-valid.sh: dropped the filter. The search starts at $REPO_ROOT/plugins, so it can never reach a worktree nested at $REPO_ROOT/.claude/worktrees/. The filter had nothing real to exclude.
  • tests/test-check-apm-agents-valid.sh:
    • New case 8 runs the gate from a fixture under .claude/worktrees/. It fails against the old script and passes with the fix.
    • The suite now unsets inherited GIT_* vars, the same pattern as tests/run-tests.sh, so its git fixtures can't resolve to the caller's repo (see #204).

tests/run-bats.sh and tests/run-tests.sh use the same glob but match it against paths relative to the repo root, so they're unaffected. Both already have their own tests for this case.

Verification

  • bash tests/test-check-apm-agents-valid.sh: 10/10 pass. Before the fix: 7 passed, 3 failed.
  • The real gate passes from a .claude/worktrees/ checkout, validating 10 agents.
  • Every pre-push hook passed on push.
  • Clean-context review: no blocking findings.

🤖 Generated with Claude Code

https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi

Fixes #199 ## Problem `scripts/check-apm-agents-valid.sh` filtered its `find` output with `-not -path '*/.claude/worktrees/*'`. `find` matches that glob against **absolute** paths. When the checkout is itself an agent worktree at `<repo>/.claude/worktrees/<name>/`, every path contains that segment, so every agent file was excluded. The gate then failed with "N of N tracked agent files were not discovered", and agents running in isolated worktrees couldn't push. ## Change - **`scripts/check-apm-agents-valid.sh`:** dropped the filter. The search starts at `$REPO_ROOT/plugins`, so it can never reach a worktree nested at `$REPO_ROOT/.claude/worktrees/`. The filter had nothing real to exclude. - **`tests/test-check-apm-agents-valid.sh`:** - New case 8 runs the gate from a fixture under `.claude/worktrees/`. It fails against the old script and passes with the fix. - The suite now unsets inherited `GIT_*` vars, the same pattern as `tests/run-tests.sh`, so its git fixtures can't resolve to the caller's repo (see #204). `tests/run-bats.sh` and `tests/run-tests.sh` use the same glob but match it against paths relative to the repo root, so they're unaffected. Both already have their own tests for this case. ## Verification - `bash tests/test-check-apm-agents-valid.sh`: 10/10 pass. Before the fix: 7 passed, 3 failed. - The real gate passes from a `.claude/worktrees/` checkout, validating 10 agents. - Every pre-push hook passed on push. - Clean-context review: no blocking findings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
Claude added the Kind/Bug label 2026-11-26 23:08:07 +00:00
Claude added 1 commit 2026-11-26 23:08:07 +00:00
check-apm-agents-valid.sh filtered find output with
`-not -path '*/.claude/worktrees/*'`, matched against absolute paths.
When the checkout itself lives at <repo>/.claude/worktrees/<name>/,
every path contains that segment, so every agent file was excluded
and the gate reported "N of N tracked agent files were not discovered".

The walk starts at $REPO_ROOT/plugins, so a nested worktree is
unreachable and the filter is dropped. The test suite gains a case that
runs the gate from a fixture under .claude/worktrees/, and now unsets
inherited GIT_* variables so its git fixtures never resolve to the
caller's repository.

Fixes #199

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
Defame1297 merged commit 5dc924e0f7 into main 2026-11-27 08:03:59 +00:00
Defame1297 deleted branch fix/worktree-agent-discovery 2026-11-27 08:03:59 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Holocron#228