Repository navigation
fix(test): record scope provenance so a partial run cannot read as a full pass (#3763) - #3778
Merged
Merged
Conversation
…full pass
A cached test result is replayed verbatim on later runs:
✓ Fingerprint cache valid - skipping C++ unit tests [357/357 passed in 55.20s]
Nothing in that line said whether the number came from a full-suite run or a
narrowed one, so a partial result was indistinguishable from a full pass and
was reported as authoritative until something invalidated the fingerprint.
That is a silent-wrong-answer failure mode in the gate the project relies on
to decide whether to merge.
Record the run's scope alongside the counts and render it:
full -> 274/274 passed in 30.47s
filtered -> 1/1 passed in 16.98s, filtered run - NOT the full suite
legacy -> 357/357 passed in 55.20s, scope unrecorded
A fingerprint written before this field existed reports "scope unrecorded"
rather than being silently promoted to "full" -- an unknown provenance is not
evidence of a full pass.
save_all() carries scope forward together with the counts it labels. Carrying
the counts without their scope would relabel a filtered result as a full one
on the very next cache hit, which would have been a fresh instance of this
same bug.
Note on the two write sites in test_runner.py: neither previously checked
whether a filter was active before recording counts, so a filtered run's
number could land in the slot that is later replayed as authoritative. In
practice filtered runs currently do not persist a cpp_test fingerprint at all,
so that path does not fire today -- but the safety was incidental rather than
structural, which is consistent with the reporter having hit a bogus `1/1`
once under state neither of us could reconstruct. This makes it structural.
Refs #3763
Co-Authored-By: Claude <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe change adds optional scope metadata to fingerprint results. Test runners record full or partial coverage, persistence preserves the metadata, cache summaries report its provenance, and tests cover legacy and round-trip behavior. ChangesFingerprint scope provenance
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CppTestRunner
participant FingerprintManager
participant FingerprintResult
participant FingerprintFile
CppTestRunner->>FingerprintManager: Update test metadata with scope
FingerprintManager->>FingerprintResult: Store counts and scope
FingerprintManager->>FingerprintFile: Persist scope
FingerprintFile-->>FingerprintManager: Load scope
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Jul 31, 2026
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.
Refs #3763. Implements the mitigation the issue asks for, plus the structural half of it.
The problem
Cached test counts are replayed verbatim:
Nothing said whether that number came from a full-suite run or a narrowed one. A partial result read as an authoritative green until something invalidated the fingerprint — and the reporter acted on a
1/1 passedline once, believing it was evidence of suite health.What changed
FingerprintResultgains ascopefield recorded alongside the counts, andget_cache_summary()renders it:274/274 passed in 30.47s1/1 passed in 16.98s, filtered run - NOT the full suite357/357 passed in 55.20s, scope unrecordedThe third row is deliberate: an unknown provenance is not evidence of a full pass, so legacy entries are never silently promoted to "full".
save_all()carriesscopeforward together with the counts it labels — carrying counts without their scope would relabel a filtered result as a full one on the very next cache hit, which would have been a fresh instance of this same bug.Verified end to end
9 new tests in
ci/tests/test_fingerprint_scope.pycover rendering for all three scopes, JSON round-trip, legacy load, and the carry-forward-with-counts invariant.bash lintclean; 85 related Python tests pass.What I found while doing this — worth reading
I root-caused the
274in the issue, and it is not a truncated suite. Full write-up in the issue, short version:discover_test_files()(authoritative).dllbinaries builttest_list_cache.txtentries357 - 274 = 83, which is exactly the "83 test binaries" the reporter computed. Those are the example targets.--cppruns unit tests and examples, and both feed the same✅ All tests passed (N/N)line — so the headline silently means unit + examples on one run and unit only on the next, with no wording change. Reproducible on demand by deleting.cache/fingerprint/cpp_test_quick.jsonand re-running.Also worth recording: the replayed number does not come from
.full_run_cache.json(which the reporter checked and correctly found keyed separately). It comes from the fingerprint metadata for thecpp_testkey. That is the slot a wrongNlands in.Scope of this PR, honestly
This makes the labelling trustworthy. It does not fix the unit-vs-examples denominator ambiguity above — that is the larger and riskier half, and I would rather land honest labelling first than bundle them. Filing that separately.
One thing I want to be straight about: I could not reproduce the
1/1case, and filtered runs currently do not persist acpp_testfingerprint at all, so the filtered-write path does not fire today. The two write sites still had no guard, so the safety was incidental rather than structural — this makes it structural, and thescope unrecordedbehaviour is what actually changes day-to-day output.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes