Pushing from an agent worktree (/root/ai-development/.claude/worktrees/agent-<id>) fails two pre-push gates with "4 of 4 tracked agent files were not discovered":
check-apm-agents-valid
tests/test-check-apm-agents-valid.sh (run by run-tests)
The filter means "skip worktrees nested inside this checkout". When the checkout itself is a worktree, $REPO_ROOT already contains /.claude/worktrees/, so every path matches and every agent is excluded. The comment says the filter mirrors tests/run-bats.sh, which probably has the same flaw.
Fix
Anchor the exclusion to the repo root, for example -not -path "$REPO_ROOT/.claude/worktrees/*". In this script find starts at $REPO_ROOT/plugins, so a nested worktree can't be reached and the filter may simply be dropped. Apply the same change in tests/run-bats.sh and any other copies, and add a test that runs the gate from a checkout whose path contains /.claude/worktrees/.
Impact
Agent subagents launched with worktree isolation (the Claude Code Agent tool's isolation: worktree) can't push without --no-verify, which this repo forbids. They have to hand back to a session in the main checkout.
## What happened
Pushing from an agent worktree (`/root/ai-development/.claude/worktrees/agent-<id>`) fails two pre-push gates with "4 of 4 tracked agent files were not discovered":
- `check-apm-agents-valid`
- `tests/test-check-apm-agents-valid.sh` (run by `run-tests`)
The agent files are on disk.
## Cause
`scripts/check-apm-agents-valid.sh` discovers agents with:
```sh
find "$REPO_ROOT/plugins" -type f -name '*.agent.md' \
-path '*/.apm/agents/*' \
-not -path '*/.claude/worktrees/*'
```
The filter means "skip worktrees nested inside this checkout". When the checkout itself is a worktree, `$REPO_ROOT` already contains `/.claude/worktrees/`, so every path matches and every agent is excluded. The comment says the filter mirrors `tests/run-bats.sh`, which probably has the same flaw.
## Fix
Anchor the exclusion to the repo root, for example `-not -path "$REPO_ROOT/.claude/worktrees/*"`. In this script `find` starts at `$REPO_ROOT/plugins`, so a nested worktree can't be reached and the filter may simply be dropped. Apply the same change in `tests/run-bats.sh` and any other copies, and add a test that runs the gate from a checkout whose path contains `/.claude/worktrees/`.
## Impact
Agent subagents launched with worktree isolation (the Claude Code `Agent` tool's `isolation: worktree`) can't push without `--no-verify`, which this repo forbids. They have to hand back to a session in the main checkout.
Found while working [Copilot CLI agent behaviour from docs](https://git.rkdr.net/Mortis/Holocron/issues/187).
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.
What happened
Pushing from an agent worktree (
/root/ai-development/.claude/worktrees/agent-<id>) fails two pre-push gates with "4 of 4 tracked agent files were not discovered":check-apm-agents-validtests/test-check-apm-agents-valid.sh(run byrun-tests)The agent files are on disk.
Cause
scripts/check-apm-agents-valid.shdiscovers agents with:The filter means "skip worktrees nested inside this checkout". When the checkout itself is a worktree,
$REPO_ROOTalready contains/.claude/worktrees/, so every path matches and every agent is excluded. The comment says the filter mirrorstests/run-bats.sh, which probably has the same flaw.Fix
Anchor the exclusion to the repo root, for example
-not -path "$REPO_ROOT/.claude/worktrees/*". In this scriptfindstarts at$REPO_ROOT/plugins, so a nested worktree can't be reached and the filter may simply be dropped. Apply the same change intests/run-bats.shand any other copies, and add a test that runs the gate from a checkout whose path contains/.claude/worktrees/.Impact
Agent subagents launched with worktree isolation (the Claude Code
Agenttool'sisolation: worktree) can't push without--no-verify, which this repo forbids. They have to hand back to a session in the main checkout.Found while working Copilot CLI agent behaviour from docs.