fix(scoring): parse underscore separators and scientific notation in upstream constants (#810) - #968
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. Such constants were silently misparsed and also polluted the unmodeled-constant drift list. Widen the literal match to allow underscore separators, floats, and exponents, strip underscores before Number(), and guard against non-finite results. Adds parser coverage for 1_000_000, 5.8e1, and 1e-9. Addresses JSONbored#810 (constant-parser robustness; the staleness-gate deliverable is left for a focused follow-up).
|
🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 ⛔ Maintainer review — Blockers foundReviewed 2 changed file(s) — two independent AI reviewers, synthesized.
Merge readiness: ❌ CI is red — approval withheld until it's green. Failing: see the checks tab. Summary The changes correctly extend the Python constant parser to handle underscore separators and scientific notation, add safe underscore stripping, and include a finite check. New tests verify the behavior. No security issues, and the code integrates cleanly with existing logic. CI coverage failures are noted but per policy are not blockers. 🛑 Hard blockers — must fix before merge
💡 Nits — non-blocking, optional
This repo uses one-shot review: a rejected PR is closed, not iterated in place. Address the above and open a new focused PR. |
|
Note Gittensory Gate skippedPR closed before full evaluation. No late first comment was created.
💰 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❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #968 +/- ##
==========================================
- Coverage 96.64% 96.63% -0.01%
==========================================
Files 110 110
Lines 15039 15041 +2
Branches 5434 5435 +1
==========================================
+ Hits 14534 14535 +1
Misses 104 104
- Partials 401 402 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…upstream constants (#810) (#969) 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 #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 #810 (parser deliverable; staleness gate left for a follow-up). Co-authored-by: ghost <49853598+JSONbored@users.noreply.github.com>
Summary
Addresses #810 (constant-parser robustness).
parsePythonNumberConstantsmatched numbers with/[-+]?\d+(?:\.\d+)?/, which stops at_ande:FOO = 1_000_000parsed as 1BAR = 1e-9parsed as 1BAZ = 5.8e1parsed as 5.8Such upstream constants were silently misparsed and also polluted the unmodeled-constant drift list.
Fix
Widen the numeric-literal match to allow underscore separators, floats, and exponents; strip
_beforeNumber(); guard against non-finite results.Tests
Adds parser coverage for
1_000_000→ 1500000-style values,5.8e1→ 58, and1e-9.npx vitest run test/unit/scoring.test.ts→ 39 passed ·npx tsc --noEmit→ clean ·git diff --check→ clean.Scope note: this is the parser half of #810; the staleness-gate deliverable is intentionally left for a focused follow-up PR.