Summary
vitest.config.ts excludes the heavy bash-comparison suite with a root-anchored glob:
exclude: ["**/node_modules/**", "**/dist/**", "comparison/**/*.comparison.test.ts"],
comparison/**/... only matches the repo-root comparison/ directory. A git worktree checked out inside the repo therefore has its own copy of comparison/ swept into every run — along with a duplicate copy of the entire src/ suite.
This is not hypothetical: Claude Code's agent worktree isolation creates worktrees at .claude/worktrees/<id>/ by default, i.e. inside the repo.
Measured
With one agent worktree present, from a clean tree:
|
Test files |
Tests |
Result |
pnpm test:unit (worktree present) |
284 |
3014 |
3 files / 6 tests failed, 14.9s |
same, with --exclude '.claude/**' |
117 |
1195 |
passed, 5.6s |
All 6 failures were inside .claude/worktrees/<id>/comparison/*.comparison.test.ts — real-bash comparison fixtures that are deliberately excluded at the root and are not meant to gate anything.
The effect is a red, ~3x slower gate that reports failures in files the developer never edited, attributed to paths that do not exist in their branch.
Note on a wrong first guess
pnpm test:unit passes --exclude 'src/**/integration/**' on the CLI. It would be reasonable to assume that replaces the config list and loses the comparison exclusion — it does not. CLI --exclude is additive here; the root comparison/ suite stays excluded correctly. The root-anchored glob is the whole story.
Suggested fix
Make the excludes path-independent and ignore in-repo worktrees:
exclude: ["**/node_modules/**", "**/dist/**", "**/comparison/**/*.comparison.test.ts", "**/.claude/**"],
Provenance
Found while orchestrating the #164-#175 hardening stack, when an agent worktree turned the gate red for an unrelated PR.
Summary
vitest.config.tsexcludes the heavy bash-comparison suite with a root-anchored glob:comparison/**/...only matches the repo-rootcomparison/directory. A git worktree checked out inside the repo therefore has its own copy ofcomparison/swept into every run — along with a duplicate copy of the entiresrc/suite.This is not hypothetical: Claude Code's agent worktree isolation creates worktrees at
.claude/worktrees/<id>/by default, i.e. inside the repo.Measured
With one agent worktree present, from a clean tree:
pnpm test:unit(worktree present)--exclude '.claude/**'All 6 failures were inside
.claude/worktrees/<id>/comparison/*.comparison.test.ts— real-bash comparison fixtures that are deliberately excluded at the root and are not meant to gate anything.The effect is a red, ~3x slower gate that reports failures in files the developer never edited, attributed to paths that do not exist in their branch.
Note on a wrong first guess
pnpm test:unitpasses--exclude 'src/**/integration/**'on the CLI. It would be reasonable to assume that replaces the config list and loses thecomparisonexclusion — it does not. CLI--excludeis additive here; the rootcomparison/suite stays excluded correctly. The root-anchored glob is the whole story.Suggested fix
Make the excludes path-independent and ignore in-repo worktrees:
Provenance
Found while orchestrating the #164-#175 hardening stack, when an agent worktree turned the gate red for an unrelated PR.