fix(engine): dedup provider-track-record aggregation per provider+target - #8955
Closed
jeffrey701 wants to merge 1 commit into
Closed
fix(engine): dedup provider-track-record aggregation per provider+target#8955jeffrey701 wants to merge 1 commit into
jeffrey701 wants to merge 1 commit into
Conversation
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Contributor
Author
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8955 +/- ##
==========================================
+ Coverage 90.56% 93.86% +3.30%
==========================================
Files 96 807 +711
Lines 22490 80334 +57844
Branches 3884 24343 +20459
==========================================
+ Hits 20367 75408 +55041
- Misses 1945 3561 +1616
- Partials 178 1365 +1187
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
What
computeProviderTrackRecords(
packages/loopover-engine/src/calibration/provider-track-record.ts) builds astancesByTargetmap that correctly collapses multiple same-provider signals for one
targetKeyto the latest vote,but the main aggregation loop then iterated the raw
signalsarray — incrementingsignals/decided/shared/consensus/agreedonce per raw row rather than once per distinct(provider, targetKey)pair. Since the real callerloadLiveProviderTrackRecordsreads rawaudit-event rows with no dedup, a provider re-reviewing the same PR (common after a new push) had its
precision and agreement stats inflated proportionally to how many times it re-reviewed.
Change
Collapse repeated
(provider, targetKey)signals to the latest row before aggregating (aMapkeyed byprovider + targetKey, keeping the last-seen row — matchingstancesByTarget's ownlatest-vote
.setdedup), then iterate that deduped set. One distinct pair counts once, scored onits latest vote.
Validation
test/unit/provider-track-record-engine.test.ts(imports the engine source, so Codecovgrades it): a provider with two rows for the same target (
passthen a re-reviewfail) nowproduces
signals: 1scored on the latestfailvote — wassignals: 2/agreementRate: 0.5before. Existing multi-provider consensus/split/precision assertions are unaffected.
npx vitest run test/unit/provider-track-record-engine.test.ts→ 8/8 pass; 100% line+branchcoverage on every changed line.
Closes #8876