Repository navigation
fix(tests): repo-mutation guard classifies sibling-worktree activity instead of blaming the suite - #220
Merged
Conversation
The session-scoped mutation guard fingerprinted `git worktree list`, which is repo-wide, so a sibling worktree of the same clone committing during the run failed the suite with a GIT_DIR-leak accusation it had no evidence for. Fingerprint is now structured and the before/after pair classified into three states: mutation of the launching worktree (fails, original wording kept), concurrent sibling activity (warns, passes), and an unattributable change to the worktree set (fails, says it cannot attribute it). Closes #219 Co-Authored-By: Max <noreply>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
tests/conftest.py's session-scoped_guard_launching_repo_is_not_mutatedfingerprints four things, one of which —git worktree list— is repo-wide rather than worktree-local. The fixture brackets the whole run, so any commit or checkout in any worktree of the same clone during those ten minutes changes the string and fails the suite, with:The guard observed "the clone's state changed". It reported "this suite changed it, and here is the defect class". Parallel worktrees are the normal working mode here, so this keeps firing — at the end of a ten-minute run, after all the work.
The fix — classify, don't compare
Deleting the
worktrees=line would fix the false positive by deleting coverage: an escaped test registering a pytest tmp dir as a live worktree is exactly what the 2026-07 incident did. So the fingerprint became structured (RepoFingerprint) and the before/after pair is classified (_classify_repo_change) into three states rather than two, per theok/ finding / cannot tell contract:okconcurrentmutatedGIT_DIR-leak wording verbatimunattributablemutatedis evaluated first, so a real mutation concurrent with sibling activity is still reported as a mutation.unattributablefails — an escapedworktree addand a humangit worktree addare indistinguishable from here, and an unexplained change to the clone must never be waved through; what changes is that the guard says which question it could not answer instead of asserting the most alarming one.Why this does not weaken the guard
toplevelwas added.tests/test_repo_mutation_guard.pypins it from both sides: stray commit,core.bareflip, dirty working tree, deleted tracked file, and mutation-plus-concurrent-activity all assertmutated; and the fixture is driven end-to-end in a throwaway clone — an inner suite whose test commits into its own launching repo still fails the inner run withGIT_DIR-leak/DO NOT ignore this, while an inner suite whose test only moves a sibling worktree passes.Verification
conftest.pyat fixture level — the sibling-only inner run failed on aworktrees=line differing solely in the sibling's SHA.Closes #219