fix(scoring): parse underscores in fractional upstream constants - #1039
Conversation
Closes JSONbored#992 Co-authored-by: Cursor <cursoragent@cursor.com>
|
🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 🛠️ Maintainer review — Held for maintainer reviewReviewed 2 changed file(s) — two independent AI reviewers, synthesized. ✅ Safe to merge — both reviewers found no blocking issues.
Merge readiness: ✅ Mergeable · all CI checks green/neutral/skipped. Summary The change updates the regex in 💡 Nits — non-blocking, optional
|
|
Note 🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦 💡 Gittensory review — advisory only
💡 Advisory only — no action taken
💰 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. |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
ghost
left a comment
There was a problem hiding this comment.
Held for maintainer (guardrail_area) — correct + CI green
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1039 +/- ##
=======================================
Coverage 96.85% 96.85%
=======================================
Files 141 141
Lines 17501 17501
Branches 6334 6334
=======================================
Hits 16951 16951
Misses 104 104
Partials 446 446 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #992
Summary
#969 added underscore support to
parsePythonNumberConstantsfor integer parts (1_500_000) and scientific notation (1e-9), but the fractional digit classes still rejected_. Per PEP 515, underscores are valid between digits in any part of a numeric literal.A valid upstream constant like
RATE = 0.000_001was truncated at the first fractional underscore and read as0, silently skewing score previews and breakdowns that depend on the fetched scoring snapshot.Root cause
RATE = 0.000_001SCALE = 3.14_15VAL = 1_000.000_5BARE = .5_0Integer grouping (
1_500_000), plain floats (0.90), and exponents (5.8e1,1e-9) continue to parse as before.Changes
src/scoring/model.ts— extend fractional digit classes to allow_in both123.456_789and.5_0forms.test/unit/scoring.test.ts— regression test for fractional underscore literals (#992).Number(raw.replace(/_/g, ""))already strips underscores before parsing; no other logic changes.Reachability
refreshScoringModelSnapshotfetches upstreamgittensor/constants.pyand runs it throughparsePythonNumberConstants, merging results into scoring constants used bybuildScorePreview, score breakdown, and unmodeled-constant detection. Any upstream maintainer using fractional digit-grouping for readability hits this path.API / OpenAPI / MCP contract
No schema changes. Parsed upstream constant values may change when fractional underscores are present in
constants.py.Migration / deploy / secrets
None.
Security / privacy
None.
Validation
Run from repo root (Node
>= 22):All gates passed locally on branch
fix/fractional-underscore-upstream-constants.Distinct from #994
Unrelated to label multiplier selection (#994). This completes the fractional-underscore gap left by #969.