test(stats): assert the totals/parity invariant instead of describing it - #9972
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-31 02:47:37 UTC
Review summary Nits — 6 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionPartially addressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. Decision record
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9972 +/- ##
==========================================
- Coverage 91.88% 91.00% -0.88%
==========================================
Files 928 928
Lines 113722 113722
Branches 27436 27436
==========================================
- Hits 104489 103495 -994
- Misses 7936 9125 +1189
+ Partials 1297 1102 -195
Flags with carried forward coverage won't be shown. Click here to find out more. |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
loopover-ui | d713746 | Jul 31 2026, 12:30 AM |
#9963 was an Orb publishing `totals.handled: 0` in the same payload as `reviewParity.verdicts: 2123`, both derived from the same ledger. #9967 fixed the aggregate and covered it well -- but per surface, which is the blind spot the defect lived in. Both halves were individually correct and individually green while production served the contradiction, and the verifier's own source says why per-surface testing cannot catch this class: "the two are computed by different code over the same ledger, which is the divergence no amount of per-surface testing catches, because each surface is individually self-consistent." `getPublicStats` and `loadReviewParityRollups` remain separate reads with separate gating, so nothing stopped the next change to either from reintroducing the disagreement with every existing test still green. These build BOTH halves over one seeded ledger and compare them through the verifier's own `checkStatsParity` -- the function that printed the original FAIL against the Orb -- rather than restating its rule, so the test cannot drift from the tool that decides whether production is publishing a contradiction. Covers the case a hand-written equality assertion would get wrong: a re-decided pull request appends a verdict row, so parity counts 3 while `handled` counts 2 pull requests. That is consistent, not a contradiction, and only parity EXCEEDING all-time handled is the accounting error. Mutation-tested against #9967's fix: reverting the ledger fallback fails exactly the two behavioural assertions, while the empty-ledger case and the failing-direction guard correctly stay green. Closes #9971
d713746 to
600312e
Compare
What this adds
A test, and nothing else. #9967 already fixed #9963.
#9963's third acceptance criterion asked for a regression test pinning that
totals.handledandreviewParity.verdictscannot disagree on the same payload. #9967's tests cover the new aggregate read thoroughly, but the cross-surface invariant itself appears only in a comment:Why the gap is worth closing specifically here
This is the one defect class per-surface testing structurally cannot catch, and
verify-public-claims.tssays so in as many words:Both halves were individually correct and individually green while production served
handled: 0besideverdicts: 2123.getPublicStatsandloadReviewParityRollupsare still separate reads with separate gating, so the next change to either can reintroduce the disagreement with every existing test passing.How it asserts
Both halves are built over one seeded ledger on a real migrated D1, then compared by calling the verifier's own
checkStatsParity— the function that printed the original FAIL against the Orb — rather than restating its rule. A hand-written>=would drift from the tool; this cannot.Four cases:
handled=12,verdicts=12, claim passes. Before #9967:handled=0.handledcounts 2 pull requests. Consistent, not contradictory; only parity exceeding all-time handled is the accounting error.handledbeneath a populated rollupMutation testing
Reverting #9967's ledger fallback (
ledgerTotals = null) fails exactly the two behavioural assertions, while the empty-ledger case and the failing-direction guard correctly stay green — so the suite is sensitive to the fix without being sensitive to unrelated noise.Verification
npx tsc --noEmitcleantypecheck,fixture-clock-races:check,dead-source-files:check,dead-exports:check,coverage-boltons:check,import-specifiers:checkgreenCloses #9971