fix(scoring): parse underscore separators and scientific notation in upstream constants (#810) - #969
Conversation
…upstream constants (JSONbored#810) parsePythonNumberConstants matched numbers with /[-+]?\d+(?:\.\d+)?/, which stops at `_` and `e`: an upstream constant written 1_000_000 parsed as 1, and 1e-9 / 5.8e1 parsed as 1 / 5.8 — silently misparsing such constants and polluting the unmodeled-constant drift list. Widen the literal match to allow underscore separators, floats, and exponents, and strip `_` before Number(). Adds parser coverage for 1_000_000, 5.8e1, and 1e-9. (Reopens the parser fix from JSONbored#968, which the gate closed for a patch-coverage miss on an unreachable guard line; that guard is removed so every changed line is exercised.) Addresses JSONbored#810 (parser deliverable; staleness gate left for a follow-up).
|
reviewbot — ⏳ Waiting for CI to finish before the gate review. |
|
Important Gittensory found maintainer review notesPublic GitHub metadata was checked for review readiness. Gittensor-specific context appears only when confirmed. Readiness score: 93/100
Signal definitions
Review context
Maintainer notes
Contributor next steps
💰 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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #969 +/- ##
=======================================
Coverage 96.64% 96.64%
=======================================
Files 110 110
Lines 15041 15041
Branches 5435 5435
=======================================
Hits 14536 14536
Misses 104 104
Partials 401 401 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ghost
left a comment
There was a problem hiding this comment.
Held for maintainer (guardrail_area) — correct + CI green
…984) getOrCreateScoringModelSnapshot served the last-good (or DEFAULT) scoring snapshot with no staleness signal, so a failed or long-stale upstream refresh silently kept previews on old constants — Pipeline B (upstream/ruleset.ts) has UPSTREAM_STALE_MS but the scoring side had none. Add SCORING_SNAPSHOT_STALE_MS (mirrors Pipeline B's 2h window) and a pure scoringSnapshotStalenessWarning(snapshot, now) helper; getOrCreateScoringModelSnapshot now appends that warning when the served snapshot is older than the window, so previews surface it. Pure helper + serve-path covered by tests (fresh/stale boundary, served-old, freshly-refreshed). Completes #810 (the parser-robustness deliverable landed in #969). Closes #810.
Summary
Addresses #810 (constant-parser robustness).
parsePythonNumberConstantsmatched numbers with/[-+]?\d+(?:\.\d+)?/, which stops at_ande:1_000_000parsed as 1,1e-9as 1,5.8e1as 5.8 — silently misparsing such upstream constants and polluting the unmodeled-constant drift list.Fix
Widen the numeric-literal match to allow underscore separators, floats, and exponents; strip
_beforeNumber(). Every changed line is exercised by tests (100% patch coverage).Tests
Adds parser coverage for
1_000_000,5.8e1,1e-9.npx vitest run test/unit/scoring.test.ts→ 39 passed ·npx tsc --noEmit→ clean ·git diff --check→ clean.Re-opens the parser fix from #968 (closed by the gate on a patch-coverage miss from an unreachable guard line, since removed). Scope: parser half of #810; staleness-gate deliverable left for a focused follow-up.