Repository navigation
feat(mutation): compile each package's mutants once and run only the tests that reach them - #13
Merged
Merged
Conversation
…tests that reach them Go mutation testing ran a fresh go test -overlay ./... for every mutant, so cost grew linearly with the diff: heimdall-v2 PR 701 (568 mutants) took 21m on a 12-core machine and was cancelled at the 40m CI timeout. All mutants of a package are now compiled into one test binary behind a runtime switch. A traced run of each test records which mutants it reaches, and a mutant is tested by running only those tests. Mutants that cannot share the build fall back to their own overlay run. Also: - classify outcomes (killed, timed out, survived, not covered, does not compile, not run) and score only mutants that compiled and ran - identify sites by offset so two sites on a line are distinct mutants - zero returned values with typed zero values so the mutant compiles - run gating tiers first; add a wall-clock budget, progress lines and a partial report on SIGINT/SIGTERM - add a result cache, sharding, early stopping and seeded sampling
cffls
approved these changes
Nov 20, 2026
Member
Author
|
@copilot resolve the merge conflicts in this pull request |
…tation-engine # Conflicts: # internal/mutation/mutation.go Co-authored-by: copilot-swe-agent[bot] <[email protected]>
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.
Summary
Go mutation testing ran a fresh
go test -overlay ./...for every mutant: a new compile, a new link and the whole suite each time. Cost grew linearly with the diff, and a large PR ran past the CI timeout with no report at all. heimdall-v2#701 (568 mutants) was cancelled at 40 minutes.This change makes the Go engine build each package once and run only the tests that can kill each mutant. On that PR the mutation run drops from 21m04s to about 1m05s on the same machine, with the same verdicts.
What was slow
Measured on heimdall-v2#701 (head
df908bf8) with the original engine:appand 196 inbridge/processorTestClerkTaskUnderStateSyncBurstis 10.9 s of an ~11 s suite and reran for all 196bridge/processormutantsappreturn_valuemutants, because every result was rewritten tonilWhat changed
Go engine (
internal/lang/goanalyzer)DIFFGUARD_MUTANT). The instrumentation is syntactic: comparisons and arithmetic go through small generic helpers that evaluate operands once in source order, statements are wrapped in guards.-test.failfast. Tests that only pass together fall back to one traced run of the whole suite../...scope.go test -overlayrun, after a compile check and an unmutated baseline.--test-timeout.a - b - c, are distinct mutants.return_valuenow returns*new(T)for each declared result type, so the mutant compiles for any signature. Returns that are already all zero values (nil,false,0,"",T{}) are skipped as equivalent.Orchestrator (
internal/mutation), all languages--mutation-budget,--mutation-cache-dir,--mutation-shard i/n,--mutation-confidence,--mutation-seed.Rust and TypeScript keep their existing appliers and runners. Languages opt in to the new path through two optional interfaces,
lang.SessionRunnerandlang.Fingerprinter.Results on heimdall-v2#701
Both engines ran with the heimdall-v2 workflow's flags on a 12-core Mac.
bridge/processor/event_owner.go:94-95) were counted as kills before only because the mutant failed to compile.Other modes on the same PR:
--mutation-workers 4--mutation-budget 20s--mutation-shard 1/4--mutation-confidence 0.99Sharding and early stop save little here: most of the minute is per-package preparation (build plus tracing each test), not the mutant runs.
Behaviour changes to know about
NOT COVEREDand counts as a survivor. A branch-removal mutant in a branch no test enters is reported this way.--test-timeoutis now a ceiling for Go, not the limit itself.generated,cached, and anoutcomesmap.go.mod/go.sum, and every file of the in-repo packages a package's tests are built from, includingtestdata. It does not capture external services or environment variables.golang.org/x/tools(forastutil).Executed tests
make build,make test: all packages pass../diffguard --base main .on this change exits 0: complexity max 8, sizes, deps, churn and dead code PASS; mutation 91.6% with Tier 1 at 97.1% (334/344), in 3m09s.Rollout notes
Tooling only. Repositories that pin a diffguard commit (heimdall-v2, sequence-store-proto) keep the old engine until the pin is bumped; bor installs
@latest. To get the most out of this in CI, add--mutation-cache-dirwith anactions/cachestep and a--mutation-budgetbelow the job timeout.This touches
collectMutants' neighbours ininternal/mutation, so it will conflict with #11.