Repository navigation
test: hold the coverage gate's unfloored set to a recorded reason (#199) - #359
Merged
Merged
Conversation
The gate already names every unfloored package in every run, so nothing was
hidden. What a run cannot supply is the only thing that matters here: whether
an absence was decided or overlooked. That lives in .coverage-floors' comment
header, and a hand-written description of state held somewhere else drifts —
which it had, three ways:
- the header said "four packages", listed five, and the gate reported six.
internal/cache/cachetest arrived with #178 and was never explained
- two of the three packages #199 names as unexplained, pkg/types and tests,
are not in the gate's report at all and cannot be: they contain no
statements. A floor for either *fails* the gate through its stale-floor arm
rather than weakening it — verified, `pkg/types 50` exits 1 — so the issue's
"floor it, or document it" choice has one available branch for them
- the third, pkg/optimization, was deleted in 4d10da0 and its explanation
outlived it by two releases
Five of the six reported packages read as 0.0%, and that number is an artifact
rather than a measurement: `go test -coverprofile` instruments only the package
under test, so a support package's statements produce count-0 lines even when a
sibling suite executes all of them. Measured with -coverpkg from each one's
consumers, they run 48.6%–88.9%. A floor there would have to be 0 to pass, and
0 is not a gate. The header now records those measurements.
Two findings the issue did not have. pkg/archive was described here as "dead
code pending a decision" — internal/archive imports it from five files, so the
claim was wrong in the direction that matters: it read as a reason not to test
a package a floored package depends on. And sdks/c is unfloorable for a
different reason than the rest: main.go is a CgoFile, so `CGO_ENABLED=0 go test
./sdks/c/` does not fall back to a tag-excluded variant, it fails to compile —
and CI sets CGO_ENABLED=0 for the cross-build and release matrices.
TestUnfloorablePackagesAreExplained asserts the two sets are equal in both
directions. It runs coverage-gate.sh rather than re-deriving the set, because
the gate's derivation has its own recorded failure: the module path was once an
awk literal, a rename stopped it matching, and every package reported "no floor
set" while the run failed naming nothing. A test re-deriving from `go list`
would have been green throughout. The profile it feeds the script is synthesized
from go list + go/parser, since a real one takes twenty minutes and only set
membership is under test — checked against CI's own coverage.out, which yields
the same six.
The header's declared set is marked `# no-floor:` / `# no-statements:` rather
than inferred from prose shape. The first parser matched indented path-shaped
tokens and reported six packages the header names for unrelated reasons as
stale entries; prose has no parseable structure.
Mutation-verified 6/6: dropped marker, marker for a floored package, marker for
a nonexistent package, a function body added to pkg/types, a new unfloored
package, and a package marked both ways. No floor values changed.
Closes #199
This was referenced Aug 5, 2026
…nlisted-199 # Conflicts: # CHANGELOG.md
…nlisted-199 # Conflicts: # CHANGELOG.md
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.
Closes #199.
The invariant the issue asks for: the set
scripts/coverage-gate.shreports as unfloored matches the set.coverage-floors' header explains, exactly. That equality is what's worth having — not a particular coverage number.Why a test and not one round of editing
The gate already names every unfloored package in every run, so nothing about the situation was hidden. What a run cannot supply is the only thing that matters: whether an absence was decided or overlooked. That distinction lives in a hand-written comment block — the same shape
labels_test.go's comment describes, a description of state held somewhere else with nothing comparing the two. It had drifted three ways.Four of the issue's premises did not survive measurement
--report-unlistedflagpkg/optimizationis unexplained4d10da0deletedpkg/optimization/interfaces.go. Its explanation outlived it by two releasespkg/typesandtestsneed "a floor or a doc"go testsayscoverage: [no statements]and no profile line is emitted. A floor fails the gate —pkg/types 50hits the stale-floor arm atcoverage-gate.sh:97-105and exits 1. Verified, not reasoned. One branch of the issue's choice is unavailable for themnode_modulesby two copies of the npmflattedpackage, whichgo list ./...reports as module packages on any machine that has runnpm ci. CI's coverage job installs no npm deps0.0% is an artifact, not a measurement
go test -coverprofileinstruments only the package under test, so a support package's statements produce count-0 profile lines even when a sibling suite executes every one of them. Measured with-coverpkgpointed at each from its consumers:A floor for any of them would have to be 0 to pass, and 0 is not a gate. Those numbers are now in the header.
Two findings the issue did not have
pkg/archivewas described as "dead code pending a decision (Part 4)".internal/archiveimports it from five files. The claim was wrong in the direction that matters: it read as a reason not to test a package that a floored package depends on.sdks/cis unfloorable for a different reason than the other five. Its number depends onCGO_ENABLED, becausemain.gois aCgoFile— soCGO_ENABLED=0 go test ./sdks/c/does not fall back to a tag-excluded variant, it fails to compile (undefined: codeFromErr,undefined: fillCStr). CI setsCGO_ENABLED=0for the cross-build matrix and the release build, so a floor there would be a claim about a file set part of CI never compiles.How the test works
TestUnfloorablePackagesAreExplainedrunscoverage-gate.shrather than re-deriving the unlisted set. The gate's derivation has its own recorded failure: the module path was once a literal inside its awk program, a rename stopped it matching anything, and every package reported "no floor set" while the run failed naming nothing. A test re-deriving fromgo listwould have been green throughout that. For the same reason the module path here is read fromgo.mod, not held as a const.The script needs a profile, and a real one takes twenty minutes, so it's synthesized from
go list+go/parser: one line per package with at least one statement, count1throughout. The counts are fiction and it doesn't matter — the unlisted set is a difference of key sets, so presence is all that decides membership. Checked against CI's owncoverage.outfrom the last green run onmain: same six packages either way. Two bugs found that way rather than by argument —CgoFilesis a separatego listfield (sosdks/cparsed as empty), andgo list's trailing empty fields collapse under a plain separator (sotests, one of the three packages the header has to classify, was unparseable).The header's declared set is marked, not inferred:
The first parser inferred the set from indented path-shaped tokens and reported six packages the header names for unrelated reasons —
internal/fuseandpkg/errorsfrom the "furthest from 80%" table,internal/cacheandinternal/adapterfrom the-coverpkgmeasurements — as stale entries. Prose has no parseable structure, and a test that pretends otherwise fails on prose edits that aren't drift.Both directions fail, and the stale-entry arm splits three ways because each cause wants a different fix: the package doesn't exist (delete the entry), it has no statements (use
# no-statements:), or it has a floor now (move to a per-floor note). That split came from a false message — markingpkg/typesas# no-floor:reported "no such package exists in this module", which is untrue.TestNoStatementPackagesStillHaveNoneholds the three# no-statements:claims, which are otherwise unfalsifiable: ifpkg/typesgrew a function body it would start producing profile lines and the header entry would simply be false.test/benchmarksis checked bystat, since//go:build benchmarkkeepsgo list ./...from reporting it at all.Verification
pkg/types, a genuinely new unfloored package, a package marked both waysgo test -race -timeout 25m ./...exit 0 ·go build ./...·go vet·gofmt -lcleangolangci-lint --new-from-merge-base=origin/main ./internal/config/...— 0 issuesmarkdownlint CHANGELOG.md— 361, byte-identical to the merge baseNo floor values changed.
Follow-ups worth filing
pkg/archive's uncovered half —metadata.go's index construction, ~19 statementsinternal/archivedoesn't exercise — and a floor forsdks/conce the coverage job's cgo posture is explicit rather than incidental.