feat: add candidateScoreNonWinnerQMGMRatio to cast explanation (78787878)#749
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthroughAdds ChangesNon-winner QM/GM ratio in cast explanation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/78787878-cast-explain-non-winner-qm-gm-ratio.test.ts`:
- Around line 100-104: The assertions in the test file are guarded by
conditional checks that allow tests to pass without validating the contract when
preconditions are not met. Remove the if guards from the assertion blocks to
ensure they always execute and catch regressions. This applies at file
test/78787878-cast-explain-non-winner-qm-gm-ratio.test.ts at lines 100-104
(around the candidateScoreNonWinnerQMGMRatio assertions), lines 116-125,
137-145, 157-170, 211-216, and 228-236. Either restructure the test to guarantee
preconditions are always satisfied so guards are unnecessary, or remove the if
conditions entirely and let the assertions run unconditionally to catch when
fields are missing or preconditions drift.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2fb4179b-ab53-4fd2-ac98-7fdc234174ed
📒 Files selected for processing (2)
src/aggregator.tstest/78787878-cast-explain-non-winner-qm-gm-ratio.test.ts
| if (explanation.candidateCount >= 3 && explanation.lowestCandidateScore > 0) { | ||
| assert.ok('candidateScoreNonWinnerQMGMRatio' in explanation, | ||
| `candidateScoreNonWinnerQMGMRatio should be present; keys: ${Object.keys(explanation).join(', ')}`); | ||
| assert.equal(typeof explanation.candidateScoreNonWinnerQMGMRatio, 'number', 'should be a number'); | ||
| } |
There was a problem hiding this comment.
Vacuous if guards let core regression checks pass without validating the contract.
Several assertions are conditional, so tests can pass even if the new field is never emitted (or if candidate-count assumptions drift). For this PR objective, these should fail loudly when the expected preconditions are not met.
Suggested tightening (example pattern)
@@
- if (explanation.candidateCount >= 3 && explanation.lowestCandidateScore > 0) {
- assert.ok('candidateScoreNonWinnerQMGMRatio' in explanation,
- `candidateScoreNonWinnerQMGMRatio should be present; keys: ${Object.keys(explanation).join(', ')}`);
- assert.equal(typeof explanation.candidateScoreNonWinnerQMGMRatio, 'number', 'should be a number');
- }
+ assert.ok(explanation.candidateCount >= 3, `expected >=3 candidates, got ${explanation.candidateCount}`);
+ assert.ok(explanation.lowestCandidateScore > 0, `expected all candidate scores > 0, got lowest=${explanation.lowestCandidateScore}`);
+ assert.ok('candidateScoreNonWinnerQMGMRatio' in explanation,
+ `candidateScoreNonWinnerQMGMRatio should be present; keys: ${Object.keys(explanation).join(', ')}`);
+ assert.equal(typeof explanation.candidateScoreNonWinnerQMGMRatio, 'number', 'should be a number');
@@
- if ('candidateScoreNonWinnerQMGMRatio' in explanation) {
+ assert.ok('candidateScoreNonWinnerQMGMRatio' in explanation, 'ratio should be present for this fixture');
+ {
@@
- if (explanation.candidateCount < 3) {
- assert.ok(
- !('candidateScoreNonWinnerQMGMRatio' in explanation),
- `should be absent with < 3 candidates`,
- );
- }
+ assert.ok(explanation.candidateCount < 3, `expected <3 candidates, got ${explanation.candidateCount}`);
+ assert.ok(
+ !('candidateScoreNonWinnerQMGMRatio' in explanation),
+ `should be absent with < 3 candidates`,
+ );Also applies to: 116-125, 137-145, 157-170, 211-216, 228-236
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@test/78787878-cast-explain-non-winner-qm-gm-ratio.test.ts` around lines 100 -
104, The assertions in the test file are guarded by conditional checks that
allow tests to pass without validating the contract when preconditions are not
met. Remove the if guards from the assertion blocks to ensure they always
execute and catch regressions. This applies at file
test/78787878-cast-explain-non-winner-qm-gm-ratio.test.ts at lines 100-104
(around the candidateScoreNonWinnerQMGMRatio assertions), lines 116-125,
137-145, 157-170, 211-216, and 228-236. Either restructure the test to guarantee
preconditions are always satisfied so guards are unnecessary, or remove the if
conditions entirely and let the assertions run unconditionally to catch when
fields are missing or preconditions drift.
Adds
candidateScoreNonWinnerQMGMRatioto theexplain:trueoutput ofch1tty/cast.Field:
candidateScoreNonWinnerQuadraticMean / candidateScoreNonWinnerGeometricMeansqrt((r²+t²)/(2·r·t))ratio * GM === QMQM/GM === QMToAMRatio * AMGMRatioTests (8/8): presence, bounds (>= 1), identity, n=3 formula, no_match absence, sub-3 absence, product decomposition, description check.
Generated by Claude Code
Summary by CodeRabbit
New Features
Tests