Skip to content

The 100% gate rounds, and this module is over the line where that matters - #29

Merged
tannevaled merged 1 commit into
mainfrom
gate/exact-coverage
Sep 23, 2026
Merged

tannevaled merged 1 commit into
mainfrom
gate/exact-coverage

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

go tool cover -func prints its total with one decimal, so it says 100.0% for
anything from 99.95% upward. %.1f crosses that line at exactly 2000 statements:

1999 statements, 1 uncovered -> 99.949975% -> prints 99.9%  -> refused
2000 statements, 1 uncovered -> 99.950000% -> prints 100.0% -> PASSED

This module instruments 2770, so it is over it. Demonstrated here rather than
argued — zeroing one block's counts in a real profile from this workflow's own command:

go tool cover says: 100.0%
the gate says:      uncovered (1 statements): parser.go:23.36,23.52
                    2769 of 2770 statements covered

It is exact today, which is why now

Measured with this workflow's own command, -race and the /ast exclusion included:
2770 of 2770. Nothing is hidden. Changing the instrument while the code is clean is
cheaper than discovering later that it was not.

What the rounding hides is not a random statement

It hides the ones hardest to reach from a test, and that population is mostly guards.
In go-crdt, where this was first found, the two statements the rounded gate had been
passing were both allocation bounds against hostile input — one a ceiling no test
could reach from data at all.

For context on why this PR exists here and nowhere else: of 173 repositories in this
fleet carrying the rounded idiom, 201 of 253 workflow copies turn out to be floor
gates (immune — a 0.05% rounding is nothing against a floor), leaving 28 with a true
100% gate. Of those 28, this is the only one above 2000 statements. The largest of
the rest is 1596, where one uncovered statement prints as 99.9% and the gate refuses
correctly.

The gate

It counts statements in the profile, where the numbers are exact. Two details it carries
from having been got wrong before:

  • A profile from -coverpkg with ./... holds the same block once per test binary,
    so counts are summed per block before anything is called uncovered. Reading each
    line on its own reported thousands of covered statements as uncovered.
  • A pattern that matches nothing is a failure, not an empty pass, so a rename cannot
    quietly empty the gate.

Verified: exit 1 on a profile with one block zeroed, exit 0 on the real one, and the
empty-match guard fires.

Not touched: paren_singleton_def_test.go is listed by gofmt here and not by CI, which
is a toolchain difference and none of this change's business.

🤖 Generated with Claude Code

…ters

`go tool cover -func` prints its total with one decimal, so it says "100.0%" for
anything from 99.95% upward. `%.1f` crosses that line at exactly 2000 statements:

    1999 statements, 1 uncovered -> 99.949975% -> prints 99.9%  -> refused
    2000 statements, 1 uncovered -> 99.950000% -> prints 100.0% -> PASSED

This module instruments 2770, so it is over it. Demonstrated here rather than
argued: zeroing one block's counts in a real profile from this workflow's own
command leaves `go tool cover` saying 100.0% while the statement is plainly
uncovered.

    go tool cover says: 100.0%
    the gate says:      uncovered (1 statements): parser.go:23.36,23.52
                        2769 of 2770 statements covered

# It is exact today, which is why now

Measured with this workflow's command, -race and the /ast exclusion included: 2770
of 2770. Nothing is hidden. Changing the instrument while the code is clean is
cheaper than discovering later that it was not.

# What the rounding hides is not a random statement

It hides the ones hardest to reach from a test, and that population is mostly
GUARDS. In go-crdt, where this was first found, the two statements the rounded gate
had been passing were both allocation bounds against hostile input -- one of them a
ceiling no test could reach from data at all.

# The gate

It counts statements in the profile, where the numbers are exact. Two details it
carries from having been got wrong before:

  - A profile from `-coverpkg` with `./...` holds the same block once per test
    binary, so the counts are summed PER BLOCK before anything is called uncovered.
    Reading each line on its own reported thousands of covered statements as
    uncovered.
  - A pattern that matches nothing is a FAILURE rather than an empty pass, so a
    rename cannot quietly empty the gate.

Verified: exit 1 on a profile with one block zeroed, exit 0 on the real one, and
the empty-match guard fires.

Not touched: paren_singleton_def_test.go is listed by gofmt here and not by CI,
which is a toolchain difference and none of this change's business.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit e7c6c98 into main Sep 23, 2026
11 checks passed
@tannevaled
tannevaled deleted the gate/exact-coverage branch September 23, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant