The problem
The mutation gate blocks merge and demands zero survivors on every changed line. Combined with textual diff scoping, that makes the cost of a PR proportional to how many lines it touches and how long it stays open — not to how much risk it introduces.
Measured on PR #976 before it was closed:
| Cause of mutation scope | Share |
|---|---|
Pure re-indentation (git diff counts it; runtime identical) | 26% |
dict[str, Any] → dict[str, object] annotations | 21% |
.get(k, d) → typed accessor (same semantics) | 15% |
That PR ended up with 1457 survivors across 28 modules — almost all of it pre-existing untested code that a mechanical refactor happened to brush against, not defects it introduced.
Three amplifiers make it compound:
- Long-lived branches can't converge. Every merge of
masterreshuffles the diff, which reshuffles the mutants, which invalidates proof already produced. PRs #1007 and #1025 were re-merged repeatedly in one day; each time the gate demanded fresh work. - Parallel branches on the same core files. #881, #997, #1025 and #1007 all edited
client.py,rate_limiting.py,result_delivery.py. Conflicts weren't textual — they were two versions of the same idea, which turns merge resolution into design work. - No budget. A PR with 1457 survivors is told "write 1457 tests" instead of "this PR is too large, or this area has no tests — decide."
How this is done elsewhere
Google has the best-documented large-scale deployment (Petrović & Ivanković, State of Mutation Testing at Google / Practical Mutation Testing at Scale). Their design is close to the inverse of ours:
- Advisory, never blocking. Surviving mutants appear as review comments on the diff; a human decides.
- Aggressive suppression of "arid" nodes (logging and similar), so most mutants never reach a person.
- A handful surfaced per review, so developers actually engage.
- A feedback loop: developers mark a mutant unproductive, and that feeds central suppression rules.
Most companies gate on line/branch coverage and don't run mutation testing at all. Where it is blocking, it's on a small safety-critical core.
What we get right
Diff scoping, per-module sharding, and an equivalence classifier are all state of the art. The gate has real value — in one session it caught a Chroma collection race (reproduced 8/8) and a bug where the agent streamed one answer to the user and persisted a different one. This is not a proposal to delete it.
What to change
- Demote to advisory. Post survivors as PR review comments; block on nothing. Single biggest change — it removes the Sisyphean dynamic outright.
- If it must block, block only on new files/functions. Treat "legacy you touched" as advisory, so the ratchet stops punishing cleanup.
- Scope with
git diff -winscripts/ci/mutation-matrix.py::_changed_line_ranges. One flag; removes ~a quarter of the false scope. Consider also skipping hunks whose only change is a type annotation. - Cap surfaced mutants per PR (~10). Above the cap, the finding is "this PR is too large" — which is the true signal.
- Central suppression with reasons, instead of
# pragma: no mutateaccumulating in product code. Pairs with #1026.
Why the classifier being blocking is itself a risk
The equivalence classifier can be silently wrong in both directions. A container-truncation bug in it (splitting on any def, so container functions were cut at their first nested def) stamped 788 real survivors as equivalent — the gate was green while proving nothing. A component that can fail open and closed should inform a human, not gate a merge.
Related
- #1026 — lint-suppression governance (same "suppression needs a reviewable home" theme)
Activity
0No activity yet.