A test in go test ./... commits staged files into the real checkout #866

Open
opened 2026-10-21 17:09:06 +00:00 by hexajon · 0 comments
Owner

While I worked on a branch, a go test ./... -count=1 run made a real commit, feat: x, in the worktree it ran in. The commit held the one file that was staged at that moment, internal/mdstripper/LICENSE. The author was the checkout's own git identity.

With nothing staged, the same leak is silent: the stray commit has nothing to commit, so it fails with "nothing to commit" and the run stays green. So the leak shows only when the index holds staged files.

The hermetic test guard (ADR 0022) has a git-mutation half: under go test, service-layer repo discovery refuses a worktree root that is not under the OS temp dir, so a mutating service op fails before it writes. This commit landed in a worktree outside the temp dir, so some path reached git without that guard.

What I know

  • The subject feat: x matches the test titles in internal/service/workflow/finish_agit_test.go (lines 407, 504, and 538). Those are the likely source, but I have not proven it.
  • The commit-seam callers in internal/service/git and internal/cmd/git stub their commit step, so they are less likely.
  • I do not know yet which call skipped the guard: a git run below the service layer, or a repo path that the guard resolved under the temp dir by mistake.

Acceptance criteria

  • A test fails when any test in go test ./... creates a commit, moves HEAD, or changes the index of the checkout that runs the suite. It runs with a staged file in the index, so the leak cannot hide.
  • The path that skipped the ADR 0022 git-mutation guard is found, and the guard covers it, with a test that fails when that coverage is removed.
  • With a file staged, go test ./... -count=1 leaves HEAD and the index unchanged.
While I worked on a branch, a `go test ./... -count=1` run made a real commit, `feat: x`, in the worktree it ran in. The commit held the one file that was staged at that moment, `internal/mdstripper/LICENSE`. The author was the checkout's own git identity. With nothing staged, the same leak is silent: the stray commit has nothing to commit, so it fails with "nothing to commit" and the run stays green. So the leak shows only when the index holds staged files. The hermetic test guard (ADR 0022) has a git-mutation half: under `go test`, service-layer repo discovery refuses a worktree root that is not under the OS temp dir, so a mutating service op fails before it writes. This commit landed in a worktree outside the temp dir, so some path reached git without that guard. ## What I know - The subject `feat: x` matches the test titles in `internal/service/workflow/finish_agit_test.go` (lines 407, 504, and 538). Those are the likely source, but I have not proven it. - The commit-seam callers in `internal/service/git` and `internal/cmd/git` stub their commit step, so they are less likely. - I do not know yet which call skipped the guard: a git run below the service layer, or a repo path that the guard resolved under the temp dir by mistake. ## Acceptance criteria - A test fails when any test in `go test ./...` creates a commit, moves HEAD, or changes the index of the checkout that runs the suite. It runs with a staged file in the index, so the leak cannot hide. - The path that skipped the ADR 0022 git-mutation guard is found, and the guard covers it, with a test that fails when that coverage is removed. - With a file staged, `go test ./... -count=1` leaves HEAD and the index unchanged.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sixfold-space/madtea#866
No description provided.