Skip to content

feat(scoring): warn when the served scoring snapshot is stale (#810) - #984

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
jason020818:feat/810-scoring-snapshot-staleness-gate
Jun 21, 2026
Merged

feat(scoring): warn when the served scoring snapshot is stale (#810)#984
JSONbored merged 1 commit into
JSONbored:mainfrom
jason020818:feat/810-scoring-snapshot-staleness-gate

Conversation

@jason020818

Copy link
Copy Markdown
Contributor

Summary

Completes #810 (staleness-gate deliverable; the parser-robustness deliverable landed in #969). 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.

Fix

  • Add SCORING_SNAPSHOT_STALE_MS (mirrors Pipeline B's 2h window) and a pure scoringSnapshotStalenessWarning(snapshot, now) helper.
  • getOrCreateScoringModelSnapshot appends that warning when the served snapshot is older than the window, so previews surface it (no behavior change when fresh).

Tests (full patch coverage)

Pure helper fresh/stale boundary; serve-path served-old → warning; freshly-refreshed → no warning. npx vitest run test/unit/scoring.test.ts → 42 passed · npx tsc --noEmit → clean · git diff --check → clean.

Closes #810.

…red#810)

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 JSONbored#810 (the parser-robustness deliverable landed in JSONbored#969). Closes JSONbored#810.
@jason020818
jason020818 requested a review from JSONbored as a code owner June 21, 2026 10:11
@dosubot dosubot Bot added the size:S label Jun 21, 2026
@ghost ghost added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. 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 #984 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 commented Jun 21, 2026

Copy link
Copy Markdown

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

🛠️ Maintainer review — Held for maintainer review

Reviewed 2 changed file(s) — two independent AI reviewers, synthesized. ✅ Safe to merge — both reviewers found no blocking issues.

ℹ️ Correct and green, but touches a sensitive area (src/scoring/model.ts) — held for your review.

Merge readiness: ✅ Mergeable · all CI checks green/neutral/skipped.

Summary

The changes introduce a staleness detection for scoring model snapshots, correctly compute the warning based on a configurable freshness window, and propagate the warning through getOrCreateScoringModelSnapshot. The implementation is type‑safe, does not expose secrets, and adds comprehensive unit tests covering the new logic. No existing functionality is broken and all CI checks pass.

💡 Nits — non-blocking, optional

  • Minor encoding artifact in comment strings ("â�¦").
  • Consider normalising the non‑ASCII ellipsis character ("â�¦") in the warning message to a plain "..." for readability.
  • Document the new SCORING_SNAPSHOT_STALE_MS constant in the project README or config reference for operators.

@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.60%. Comparing base (16f6e96) to head (9732919).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #984   +/-   ##
=======================================
  Coverage   96.60%   96.60%           
=======================================
  Files         110      110           
  Lines       15066    15072    +6     
  Branches     5444     5446    +2     
=======================================
+ Hits        14555    14561    +6     
  Misses        107      107           
  Partials      404      404           

☔ 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 2e1a892 into JSONbored:main Jun 21, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(scoring): sync hardening — staleness gate + robust constant parser

2 participants