Repository navigation
Description
What happens
tests/conftest.py's session-scoped _guard_launching_repo_is_not_mutated fails a run when a sibling worktree of the same clone moves its HEAD while the suite is running. The suite did nothing wrong; the guard reports it as though it did, in the strongest available terms.
Hit while running the full suite from ~/Documents/rm-wt/204 with a second agent working in ~/Documents/rm-wt/197.
Why
_repo_fingerprint (conftest.py:82) snapshots four things, one of which is repo-wide rather than worktree-local:
return "\n".join([
f"bare={_git('config', '--get', 'core.bare')}",
f"head={_git('rev-parse', 'HEAD')}",
f"worktrees={_git('worktree', 'list')}", # <-- every worktree of the clone
f"status={_git('status', '--porcelain')}",
])git worktree list prints the checked-out commit and branch of every linked worktree, not just this one. The guard is session-scoped — before at the start, after at the end (conftest.py:114–116) — so it brackets a window of minutes. Any commit, checkout, or worktree add anywhere in the clone during that window changes the string, before != after, and the run fails.
Why this is worth fixing rather than working around
The failure message is (conftest.py:117–120):
Test suite mutated the repo it was launched from — this is the exact
GIT_DIR-leak class of bug tracked by _sanitize_ambient_git_env. DO NOT
ignore this.
That message is correct about a real and serious class of bug — the GIT_DIR leak this repo fixed in 2026-07, which is exactly the sort of thing that must never be waved through. But when it fires for this reason it is asserting something it did not measure. The guard observed "the clone's state changed"; it reports "this suite mutated the repo", names a specific defect class, and instructs the reader not to ignore it.
The likely reactions are both bad. Someone believes it and goes hunting for a GIT_DIR leak that isn't there. Or — worse, and more likely the second and third time — someone learns the guard cries wolf under parallel worktrees and starts discounting it, which is how the real thing gets waved through later. A guard whose false positives are indistinguishable from its true positives loses the authority that makes it worth having.
This is the same shape as claude-supertool#428: a repo-state guard that cannot separate "concurrent sibling activity" from "the thing I exist to catch", and attributes the former to whatever innocent test happened to be running.
Constraint on the fix
Do not weaken the guard. Dropping the worktrees= line entirely would fix the false positive by removing coverage — a worktree add performed by an escaped test is precisely something worth catching, and the whole point of the incident this guard commemorates is that repo mutation must not be able to happen quietly. Trading a noisy false positive for a silent blind spot is a worse deal than the bug.
Directions worth weighing:
- Fingerprint only this worktree's entry from
git worktree list, keeping the others out of the comparison — narrower, but still catches a new worktree appearing if that entry set is scoped carefully. - Diff the before/after fingerprints and classify: a change confined to other worktrees' HEADs is concurrent activity, a change to bareness / this worktree / working-tree status is the real thing. Then say which one it is rather than emitting one message for both.
- If concurrent-sibling activity is genuinely indistinguishable from a real mutation in some case, the guard should say that — "the clone changed during this run and I cannot attribute it" is honest and actionable; "this suite mutated the repo, DO NOT ignore" is neither, when it isn't true.
The third option is the house rule: three states, not two — ok, a finding, and cannot tell. See docs/validators.md in claude-supertool for the canonical write-up of that contract.
Reproduction
git worktree add ../wt-aandgit worktree add ../wt-bfrom the same clone.- Start the full suite in
wt-a(~10 min). - While it runs, commit anything in
wt-b. - The run fails at teardown with the mutation assertion, listing a
worktrees=line that differs only inwt-b's commit.
Verified by reading tests/conftest.py:82–122 — the worktrees= line is repo-wide and the fixture is scope="session". test_worktree_memory.py passes clean in isolation.
Context
Parallel worktrees are the normal working mode here — it is how more than one agent works this repo at once without colliding. So this will keep firing, and it fires at the end of a ten-minute run, after all the work.
Activity
fix(tests): classify repo-guard changes instead of blaming the suite (D…