Skip to content

fix(scoring): parse underscore separators and scientific notation in upstream constants (#810) - #968

Closed
jaso0n0818 wants to merge 1 commit into
JSONbored:mainfrom
jaso0n0818:fix/810-scoring-constant-parser
Closed

fix(scoring): parse underscore separators and scientific notation in upstream constants (#810)#968
jaso0n0818 wants to merge 1 commit into
JSONbored:mainfrom
jaso0n0818:fix/810-scoring-constant-parser

Conversation

@jaso0n0818

Copy link
Copy Markdown
Contributor

Summary

Addresses #810 (constant-parser robustness). parsePythonNumberConstants matched numbers with /[-+]?\d+(?:\.\d+)?/, which stops at _ and e:

  • FOO = 1_000_000 parsed as 1
  • BAR = 1e-9 parsed as 1
  • BAZ = 5.8e1 parsed as 5.8

Such 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 _ before Number(); guard against non-finite results.

Tests

Adds parser coverage for 1_000_000 → 1500000-style values, 5.8e1 → 58, and 1e-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.

…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).
@jaso0n0818
jaso0n0818 requested a review from JSONbored as a code owner June 21, 2026 05:04
@dosubot dosubot Bot added the size:S label Jun 21, 2026
@ghost ghost added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jun 21, 2026
@ghost

ghost commented Jun 21, 2026

Copy link
Copy Markdown

🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥

⛔ Maintainer review — Blockers found

Reviewed 2 changed file(s) — two independent AI reviewers, synthesized.

ℹ️ This PR conflicts with main and can't be merged as-is. Conflicting file(s): src/scoring/model.ts, test/unit/scoring.test.ts. Resolve the conflict(s) and open a fresh PR.

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

  • The code coverage for the patch is below the target (75.00% vs 96.64%).

💡 Nits — non-blocking, optional

  • Minor style: trailing spaces in comment lines could be cleaned.
  • Consider adding a comment about the regex limitations (e.g., no underscores after decimal point) for future maintainers.
  • Update documentation of parsePythonNumberConstants to reflect new supported formats.
  • Consider adding a comment explaining why the regex change is necessary.
  • Consider adding more test cases for edge cases in the parsePythonNumberConstants function.

This repo uses one-shot review: a rejected PR is closed, not iterated in place. Address the above and open a new focused PR.

@ghost ghost added the reviewbot-review label Jun 21, 2026
@ghost

ghost commented Jun 21, 2026

Copy link
Copy Markdown

Note

Gittensory Gate skipped

PR closed before full evaluation. No late first comment was created.

Signal Result Evidence Action
Gate result ⚠️ Skipped #968 is no longer open. No action.

💰 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.

@ghost ghost added the gittensory:reviewed label Jun 21, 2026
@superagent-security

superagent-security Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.63%. Comparing base (dd93fb5) to head (a854ba0).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
src/scoring/model.ts 75.00% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ghost ghost closed this Jun 21, 2026
@ghost ghost removed reviewbot-review labels Jun 21, 2026
JSONbored added a commit that referenced this pull request Jun 21, 2026
…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>
@JSONbored JSONbored reopened this Jun 21, 2026
@ghost ghost closed this Jun 21, 2026
@JSONbored JSONbored reopened this Jun 21, 2026
@ghost ghost closed this Jun 21, 2026
@JSONbored JSONbored reopened this Jun 21, 2026
@ghost ghost closed this Jun 21, 2026
@JSONbored JSONbored reopened this Jun 21, 2026
@ghost ghost closed this Jun 21, 2026
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants