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.
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
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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes #199
Problem
scripts/check-apm-agents-valid.shfiltered itsfindoutput with-not -path '*/.claude/worktrees/*'.findmatches 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:.claude/worktrees/. It fails against the old script and passes with the fix.GIT_*vars, the same pattern astests/run-tests.sh, so its git fixtures can't resolve to the caller's repo (see #204).tests/run-bats.shandtests/run-tests.shuse 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..claude/worktrees/checkout, validating 10 agents.🤖 Generated with Claude Code
https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi