fix(scoring): clamp fixed_base_score and SRC_TOK_SATURATION_SCALE to documented bounds#1745
Conversation
…documented bounds (JSONbored#1744) The score preview consumed two repo-configurable inputs without enforcing the ranges upstream documents for them. fixed_base_score forces base_score to a constant in [0, 100] but reached the preview unbounded above (the API schema is `.min(0)` only and registry normalization accepts any finite value), so a misconfigured 150 minted a base component above the model ceiling. SRC_TOK_SATURATION_SCALE is per-repo overridable only within [10, 500] but the saturation curve only floored it at 1, letting an out-of-band value distort the curve. Clamp both to their documented ranges at the scoring boundary; in-range values are unchanged. Covered by regression tests pinning each clamp. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-06-29 21:40:50 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 5 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 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 Gittensory, 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 #1745 +/- ##
=======================================
Coverage 95.59% 95.59%
=======================================
Files 204 204
Lines 22316 22322 +6
Branches 8067 8068 +1
=======================================
+ Hits 21332 21338 +6
Misses 408 408
Partials 576 576
🚀 New features to boost your workflow:
|
Summary
Fixes #1744.
computeScoreCore(src/scoring/preview.ts) consumed two repo-configurable scoring inputs without enforcing the ranges upstream documents for them, so an out-of-range value silently distorted the preview:fixed_base_scoreforcesbase_scoreto a constant documented as[0, 100], but reached the preview unbounded above —src/api/routes.ts:567validates it asz.number().min(0)(no max) andsrc/registry/normalize.ts:73accepts any finite value. A misconfiguredfixed_base_score: 150previewedbaseScore = 150, a base component above the model ceiling that then multiplied through toestimatedMergedScore.SRC_TOK_SATURATION_SCALEis per-repo overridable only within[10, 500](default 58), butsaturationScoreonly floored it at1, so an out-of-band snapshot value distorted the saturation curve.This clamps both inputs to their documented ranges at the scoring boundary (
clampFixedBaseScore→[0, 100],clampSaturationScale→[10, 500]). A non-finite/absentfixed_base_scorestill falls through to the token-derived base score, and in-range values (e.g.12,58) are unchanged — so existing previews are unaffected.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally;codecov/patchrequires ≥97% coverage of the lines AND branches you changed (aim for 98%+ on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateRan the full
npm run test:ci(green) plusnpm audit --audit-level=moderate(0 vulnerabilities). Added four regression tests intest/unit/scoring.test.tscovering the[0,100]clamp (above-ceiling and below-floor) and the[10,500]saturation-scale clamp (below-floor and above-ceiling); each fails before the fix.Safety
UI Evidencesection below with screenshots.No auth/CORS/session/OpenAPI/UI changes: this is a backend-only clamp on values the preview already consumed (the public OpenAPI spec is unchanged;
ui:openapi:checkpasses). No UI evidence is applicable.Notes
input.fixedBaseScore) and the registry-config (config.fixedBaseScore) sources without changing the registry normalization or API schema contracts.