fix(scoring): cap non-code explicit totals - #1102
Conversation
|
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 #1102 +/- ##
=======================================
Coverage 94.77% 94.77%
=======================================
Files 153 153
Lines 18550 18554 +4
Branches 6705 6706 +1
=======================================
+ Hits 17580 17584 +4
Misses 418 418
Partials 552 552 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review — safe to merge
✅ Approved — safe to merge Review summary Blockers
<details>
Nits — 1 non-blocking
Review context
Contributor next steps
Signal definitions
Review detailsGenerated from public PR metadata and the diff. Advisory only; deterministic signals remain authoritative. The change introduces a new helper `applyNonCodeCapToTotal` and adjusts `computeScoreCore` to apply the non‑code line cap to both derived and caller‑provided total token scores. The logic correctly caps explicit totals by subtracting the uncapped non‑code excess, and a regression test validates the behavior. The implementation compiles and aligns with the described intent. Blockers
<details>
🟩 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.
|
Motivation
applyNonCodeLineCap, but the cap was only applied whentotalTokenScorewas not provided, allowing callers (and the local-branch path which always setstotalTokenScore) to bypass the cap and inflate previews.MAX_LINES_SCORED_FOR_NON_CODE_EXTcap affects both derived totals and caller-supplied aggregatetotalTokenScorewhennonCodeTokenScore/nonCodeLinesare present.Description
derivedTotalTokenScore) wheninput.totalTokenScoreis undefined and otherwise apply a new cap-adjustment to caller-supplied totals viaapplyNonCodeCapToTotalincomputeScoreCore(src/scoring/preview.ts).applyNonCodeCapToTotal(totalTokenScore, input, cappedNonCodeTokenScore)which subtracts the uncapped non-code excess from an explicit total without double-capping derived totals.totalTokenScoreis not supplied.test/unit/scoring.test.tsthat verifies an explicittotalTokenScorewith excessivenonCodeLinesis normalized to match the capped non-code case.Testing
npx vitest run test/unit/scoring.test.tsand the suite passed (48 tests, 0 failures).npm run typecheck(tsc --noEmit) and it succeeded with no errors.MAX_LINES_SCORED_FOR_NON_CODE_EXT.Codex Task