Skip to content

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

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
jaso0n0818:fix/810-scoring-constant-parser-coverage
Jun 21, 2026
Merged

fix(scoring): parse underscore separators and scientific notation in upstream constants (#810)#969
JSONbored merged 2 commits into
JSONbored:mainfrom
jaso0n0818:fix/810-scoring-constant-parser-coverage

Conversation

@jaso0n0818

Copy link
Copy Markdown
Contributor

Summary

Addresses #810 (constant-parser robustness). parsePythonNumberConstants matched numbers with /[-+]?\d+(?:\.\d+)?/, which stops at _ and e: 1_000_000 parsed as 1, 1e-9 as 1, 5.8e1 as 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 _ before Number(). 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.

…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).
@jaso0n0818
jaso0n0818 requested a review from JSONbored as a code owner June 21, 2026 05:56
@dosubot dosubot Bot added the size:XS 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

reviewbot — ⏳ Waiting for CI to finish before the gate review.

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

ghost commented Jun 21, 2026

Copy link
Copy Markdown

Important

Gittensory found maintainer review notes

Public GitHub metadata was checked for review readiness. Gittensor-specific context appears only when confirmed.

Readiness score: 93/100

Signal Result Evidence Action
Linked issue ⚠️ Missing No linked issue or no-issue rationale found. Explain no-issue PR.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found. No action.
Review load ✅ 20/20 Readiness component derived from cached public PR metadata and labels; size label size:XS. No action.
Validation evidence ✅ 25/25 PR body includes validation/test evidence. No action.
Open PR queue ✅ 10/10 0 open PR(s), 0 likely reviewable. No action.
Contributor context ✅ Confirmed Gittensor contributor jaso0n0818; Gittensor profile; 1012 PR(s), 5 issue(s). No action.
Gate result ✅ Passing No configured blocker found. No action.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Review load = cached public PR metadata such as size labels, changed paths, and preflight status.
  • Open PR queue = repo-wide review pressure; it is not a PR quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
Review context
  • Author: jaso0n0818
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, Rust, Shell, C++, Dart, Ruby, Scala, TypeScript
  • Official Gittensor activity: 1012 PR(s), 5 issue(s).
  • PR-specific overlap: none found.
Maintainer notes
  • No linked issue detected: The planned PR does not reference a closing issue or explicit linked issue number.
Contributor next steps
  • Explain no-issue PR.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
  • Re-run Gittensory review

💰 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

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

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.64%. Comparing base (3086386) to head (e3c0d5a).

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.
📢 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 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Held for maintainer (guardrail_area) — correct + CI green

@dosubot dosubot Bot added the lgtm label Jun 21, 2026
@JSONbored
JSONbored merged commit 1ff570a into JSONbored:main Jun 21, 2026
16 checks passed
@ghost ghost removed the reviewbot-review label Jun 21, 2026
JSONbored pushed a commit that referenced this pull request Jun 21, 2026
…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.
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