fix(scoring): single-source fallbacks from DEFAULT_SCORING_CONSTANTS (Fixes #812) - #1240
Merged
JSONbored merged 2 commits intoJun 24, 2026
Conversation
Contributor
|
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 #1240 +/- ##
=======================================
Coverage 95.03% 95.03%
=======================================
Files 177 177
Lines 19882 19883 +1
Branches 7163 7163
=======================================
+ Hits 18894 18895 +1
Misses 395 395
Partials 593 593
🚀 New features to boost your workflow:
|
…ixes JSONbored#812) Derive every preview.ts constant() fallback from DEFAULT_SCORING_CONSTANTS instead of duplicated inline literals. Add density-era constants to the defaults map and regression tests proving empty-constants previews match explicit defaults. Co-authored-by: Cursor <cursoragent@cursor.com>
JSONbored
force-pushed
the
fix/812-single-source-scoring-fallbacks
branch
from
June 24, 2026 20:26
cb1dac3 to
abaadab
Compare
JSONbored
approved these changes
Jun 24, 2026
JSONbored
left a comment
Owner
There was a problem hiding this comment.
MERGE:
Code is sound:
- Faithful single-sourcing: all 25 removed inline literals exactly match their
DEFAULT_SCORING_CONSTANTS values; no numeric behavior change; detectActiveModel unaffected
(uses parsed upstream values, not the defaults-merged map). - Good invariant test: empty-constants-vs-explicit-defaults equality (scoring.test.ts:1509);
density gate both arms covered. codecov/patch + project green post-rebase.
Minor nit (non-blocking, coverage still passes): the rewritten constant() helper's
non-finite-value arm (preview.ts:1004) isn't directly asserted. Optional to add a test feeding
a NaN constant value, but not required — patch coverage is green.
Closed
12 tasks
This was referenced Jul 2, 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.
Summary
Remove duplicated fallback literals scattered across
preview.tsand derive every scoring constant lookup fromDEFAULT_SCORING_CONSTANTSinmodel.ts.Fixes #812
Problem
Every
constant(constants, "KEY", <literal>)call inpreview.tsduplicated a value already declared inDEFAULT_SCORING_CONSTANTS. When defaults changed (e.g. #807MAX_CONTRIBUTION_BONUS25→5), call-site literals could silently drift. Density-era constants (MIN_TOKEN_SCORE_FOR_BASE_SCORE,MAX_CODE_DENSITY_MULTIPLIER) were not even in the defaults map — only hardcoded at lookup sites.Changes
src/scoring/model.ts— add density-era constants toDEFAULT_SCORING_CONSTANTS;SCORING_CONSTANT_NAMESderives from keys onlysrc/scoring/preview.ts—constant()reads fallbacks fromDEFAULT_SCORING_CONSTANTS; remove all inline literal fallbacks (including feat(scoring): pull + model upstream constants not currently fetched #809 review-collateral and non-code cap constants)test/unit/scoring.test.ts— regression: empty-constants preview matches explicit-defaults preview; density branch retained; density constants no longer flagged as unmodeled driftScope boundary
Does not remove the density-model branch —
current_density_modelremains a supportedactiveModelin types, OpenAPI, andscore-breakdown.ts.API / OpenAPI / MCP contract
No schema changes. Preview math values unchanged when snapshot constants are present.
Note
Fresh PR replacing #1107 (auto-closed for merge conflicts). Rebased onto latest
main(#1102 non-code cap, #1192 upstream SHA pinning, #1235 constants body validation).Test plan
npm run test:cipassescodecov/patch≥ 97% on changed linesMade with Cursor