fix(engine): recover calibration composers to the default blend on invalid weights - #8724
Conversation
…valid weights The three sibling calibration composers claimed convergence with pairwise-calibration.ts's invalid-weight handling but only replicated the explicit-all-zero half. Calling computeGateVerdictCompositeCalibrationScore, computeReviewerConsensusCompositeCalibrationScore, or computeFindingSeverityCompositeCalibrationScore with a NaN/negative weight alongside otherwise-valid weights silently collapsed to a 100%-objective-anchor composite instead of the documented 45/35/20 default -- a real miscalibration on both the miner (AMS) and review (ORB) sides that share this module. Add the same isInvalidWeight() distinction to each normalizeCompositeWeights, mirroring pairwise-calibration.ts:58-83: an empty clamped total recovers to DEFAULT_COMPOSITE_WEIGHTS when any input weight was NaN/negative, while the explicit-all-zero case still returns real zeros for the objective-only fallback. Adds an invalid-weight test to each engine suite (mirroring pairwise-calibration.test.ts) and the matching cases to the Codecov-graded vitest convergence suite so the changed engine-src branches are covered. Closes JSONbored#8643
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8724 +/- ##
==========================================
- Coverage 93.80% 93.80% -0.01%
==========================================
Files 797 797
Lines 79493 79508 +15
Branches 24085 24094 +9
==========================================
+ Hits 74567 74580 +13
Misses 3555 3555
- Partials 1371 1373 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-26 05:25:09 UTC
Review summary Nits — 4 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed 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. 🟩 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.
|
What & why
Closes #8643.
pairwise-calibration.ts'snormalizePairwiseWeightsdistinguishes twototal <= 0situations viaisInvalidWeight(): a caller that passed NaN/negative weight(s) by mistake recovers to thedocumented default blend, while a caller that explicitly zeroed every weight gets real zeros (the
objective-only fallback). The three sibling composers claimed convergence with that behavior in their
comments but only replicated the explicit-all-zero half — so calling any of them with a NaN/negative
weight alongside otherwise-valid weights silently collapsed to a 100%-objective-anchor composite
instead of the documented 45/35/20 default. Because this module is shared by both the miner (AMS) and
review (ORB) sides, that was a real double-blast-radius miscalibration.
Change
Added the same
isInvalidWeight()distinction tonormalizeCompositeWeightsin all three files,mirroring
pairwise-calibration.ts:58-83exactly:gate-verdict-calibration.tsreviewer-consensus-calibration.tsfinding-severity-calibration.tsWhen the clamped total is empty and any input weight was NaN/negative, each function now returns
its own
DEFAULT_COMPOSITE_WEIGHTS; the explicit-all-zero case still returns real zeros unchanged.Validation
pairwise-calibration.test.ts:146-155): one NaN weight + one negative weight, real dependent scorespresent, asserts the result matches that file's
DEFAULT_COMPOSITE_WEIGHTS, not an objective-onlycollapse.
test/unit/engine-calibration-convergence.test.ts)gains the matching invalid-weight cases for all three composers, so the changed engine-src branches
are covered under vitest.
npm run test:ci); bug-catch verified (reverting the fix fails exactly thethree new invalid-weight assertions).