Repository navigation
fix(quality-gate): stop baselines from loosening - #615
Merged
Merged
Conversation
The gate reads the baseline it is given, so a PR that loosened a .gate-baseline.json passed the gate it had just weakened. A new "Baseline only tightens" job runs baseline-tightened.sh on every PR against each changed baseline: warnings up, coverage down, an identity field changed or the file deleted fails it. Replaying master's history through it found the gate itself loosening coverage: save_baseline rewrote the whole file when warnings fell, dropping coverage.hermeticLine, which save_coverage_baseline then re-established from the current run up to COVERAGE_EPSILON lower (4f1009c: 49.44 -> 49.38, 87d451e: 41.58 -> 41.30). save_baseline now merges into an existing file; baseline-overwrite-keeps-coverage pins it.
Tr00d
marked this pull request as ready for review
October 30, 2026 13:20
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.
Why
The gate compares each measurement with the committed
.gate-baseline.json, but it reads whatever baseline the PR provides. A PR that raises a warning count or lowers a coverage value therefore passes the gate it has just weakened.What changes
New check:
Baseline only tightensA new
build-and-test.ymljob runsscripts/quality-gate/baseline-tightened.shon every PR, once for each.gate-baseline.jsonthe PR changes. If the PR changes none, the job passes in seconds.The gate itself only ever moves a baseline toward stricter, so a looser value can only come from a hand edit. The job fails when:
warnings.totalrises, or disappearswarnings.byCodeentry rises (a code that wasn't there before counts as 0)coverage.hermeticLinefalls, or disappearsschema,package,projectortestProjectchangesA new package's first baseline and changes to
updatedare allowed.Fix: the gate loosened coverage itself
I replayed every baseline change on master through the new check. Two automated refreshes lowered coverage:
hermeticLine4f1009c887d451e0#369 also lowers coverage, but that one was a deliberate change to how coverage is measured.
The cause, in two steps:
save_baselinerewrote the whole file from a heredoc, which droppedcoverage.hermeticLine.save_coverage_baselinethen found no coverage key and recorded the current run's value, which can be up toCOVERAGE_EPSILON(1 point) lower.The fix:
save_baselinenow merges.warningsand.updatedinto an existing file and keeps every other key. Without it, the new check would block the next refresh PR that lowers warnings.The gate fixture
baseline-overwrite-keeps-coveragepins this. It fails on the oldwarnings.sh(expected 99.5, got null) and passes on the new one.run-fixtures.shgains abaselineKeepsassertion so the fixture can check that a key survives a write.Verification
scripts/quality-gate/fixtures-baseline-tightened/run.sh: 15/15. Every rule has a case. Aloosenedverdict counts only when the script prints aLOOSENED:line, so a jq error can't pass as a detected loosening.scripts/quality-gate/fixtures/run-fixtures.sh: 20/20, including the new fixture.This PR is independent of #614.