Cupel v0.5.1
GitHub

Go collector#

Bounded preview, within the support matrix. The Go 1.27.1 offline pure-Go profile has source and installed fixture acceptance; **real-repository acceptance is unrun**. It is not core first-release language support. Native selective PR execution is unsupported and outside the supported first release.

Run cupel collect-go --root DIR [--runs N] [--recheck UNIT…] [--out FILE] [-- packages…]. The default package pattern is ./.... A repository with a root go.mod and Go test files is detected automatically, including alongside other runners, by cupel report, check, guard, plan and label. An explicit runners.<name>.collector takes precedence. Go collection forces GOPROXY=off and GOSUMDB=off, while inheriting the user's GOTOOLCHAIN, Go caches and GOPATH; its temporary directory is under DIR/.scratch/cupel-go/. Missing local dependencies cause an error. Go mutation additionally forces GOTOOLCHAIN=local and the verified compiler environment described below.

The collector writes cupel-spec/1 input. It runs go list -json to map import paths to repository files, runs all module packages once for the coverable-line profile, and compiles one instrumented test binary per selected package with tests. Each binary lists its top-level tests. An empty -test.run '^$' run measures package initialization. Each top-level test then runs alone with -test.v and a coverprofile, in parallel at half the available cores. --runs repeats each test for duration evidence; the first isolated run supplies coverage. Every unit is listed in coverage.rechecked because its attributed coverage came from its own process. --recheck validates requested unit ids; it does not add another run.

Line mapping. Go's mode: count coverprofile lists statement blocks as file:startLine.startCol,endLine.endCol numStmts count. The end position is exclusive. A source line is coverable when a block touches at least one code character on it; it is covered when a touching block has positive count. The classifier excludes whitespace and // and /* */ comments, including blank or comment-only lines inside a block. Text in interpreted strings, raw strings and runes counts as code. Go columns are byte offsets, converted to source character positions before applying the classifier. The per-test count of a block is compared with the empty-run count; only additional execution is attributed to the test. Setup coverage is recorded by test file. Source scope excludes _test.go, vendor/, testdata/ and dot directories.

Ids are <test file>::TestName, sorted by id. Top-level TestX functions are both the test and the unit. Go subtests are not separately selectable at this cost; their names are printed as a stderr note and their coverage and status belong to the parent. Subtest names are not stored in the schema input. Example and fuzz functions are not collected as units. During mutation, however, every selected package that defines them extends its exact TestX -run expression with ^Example and/or ^Fuzz, so Examples and fuzz seed corpora run in both the baseline and mutant. Their failures remain package failures and produce mutation status error; they are never silently treated as a pass. A // cupel:critical, // cupel:standard or // cupel:minor comment immediately before func TestX sets its tag. Shapes use four-token FNV-1a shingles of the test body, with strings, runes and numbers masked. Static checks flag simple text pins on .go and documentation files, and exec.Command("go", …) or a .test binary as spawnsInterpreter. Indirect commands and dynamically built binary names are outside that static check.

The collector records a canonical sha256:<hex> hash for every production source it reports. The fixture in spec/conformance/adapters/go/ and packages/cupel/test/collect-go.test.mjs verify the collector, schema and report engine.

Mutation contract under validation#

Live cupel report, check, and guard call the native mutateGo and confirmGo module when the runner is Go and mutation is requested. It uses Go's -overlay to compile scratch mutants while leaving the project source files unchanged. For each fault it selects the recorded top-level tests whose per-test coverage reaches the line and runs their packages one at a time with an anchored -run expression. Setup or file coverage cannot identify one test, so it selects every collected test in the affected package. The faulty source's own package is always compiled first; only it and the selected test packages are compiled. The existing source-definition parser preserves the complete collected-inventory check without executing ./....

By default, mutation renders every site in every scoped file once, numbered by source, byte offset, operator and id, and adds one package-local CUPEL_FAULT helper through the overlay. The Go AST helper supplies each declaration's body span, result presence and receiver/parameter/result names; switching refuses a function when := anywhere in its body redeclares one of those names or when its body contains a Go/line directive. Certain whole-function variants then share one switched build; each needed package gets one go test -c. The helper is named 0000_cupel_fault.go so it captures CUPEL_FAULT before later package files can clear the environment; a package with a colliding or lexically earlier compiled filename is refused switching. A package is trusted only when the switched build compiles and, with CUPEL_FAULT unset, its selected tests produce exactly the ordinary baseline result. A renderer refusal, helper-name or helper-order collision, source-position observation, switched compile failure or switches-off mismatch sends the affected faults through the ordinary individual-build path. Disable switching with "runners": { "go": { "mutants": { "schemata": false } } }.

Package order comes only from inputs: packages containing a test credited with the same fault in the previous input first, then the package containing the matching foo_test.go beside foo.go, then most selected tests, collected durations and package name. A fault stops after two packages catch it (one for a first-catch guard head). If a targeted unit covers it, every selected package runs. Each exact package selection first runs unmutated and sets its own timeout; timeout/error retry uses a fresh baseline of that same selection. A kill requires a reported failure from a test that passed at baseline, including a failure reported before a timeout. Missing or unrun selected results are never treated as passes.

Survivors run twice more before being returned. Confirmation regenerates requested survivor IDs from canonically hashed source and runs two further repetitions. Build-invalid mutants are excluded only when the unmutated compile succeeds and the compiler reports a syntax or type diagnostic against the target source or its exact scratch overlay file. Signals, tool failures, process aborts and missing test results are errors rather than kills. An earlier killed, survived, or no-coverage row with the same K15 basis is copied rather than run, except when a targeted unit needs complete current evidence. Because Go compiles every _test.go file in a selected package, Cupel also requires that every collected test file in every compiled package is present in that basis; otherwise the fault runs again.

For acceptance work, CUPEL_GO_VERIFY_SWITCHED=1 reruns every switched answer on an individual build, requires the same status, and requires every credited test to fail alone. CUPEL_GO_TIMINGS=<path> writes development-only JSON. The normal log timing line reports switched and individual fault counts, compile and test time, Go command count and total wall time; none of these measured times affect ordering or statuses.

This first profile is verified on Go 1.27.1 on POSIX hosts with process-group termination. It requires offline module resolution, no workspace/build-tag/cgo/embed/assembly or other native compiler channels, and unchanged source hashes and paths. It rejects custom Go compiler flags, cross-target settings, and configured partial test inventories. scope.functions and nested subtest mutation evidence are unsupported. Runtime file I/O, subprocesses, package initialization and shared state still need separate selective PR safety cases; this module does not establish selective PR support. The S20 plan and results give the exact fixture gates. --no-mutation explicitly collects coverage without mutation when requested; missing mutation evidence remains unknown.

Edit this page on GitHub