Skip to content

test(scoring): cover model.ts's unpinned-fallback and language-fetch-failed warning branches#8499

Closed
galuis116 wants to merge 1 commit into
JSONbored:mainfrom
galuis116:test/scoring-model-warning-branch-coverage-8327
Closed

test(scoring): cover model.ts's unpinned-fallback and language-fetch-failed warning branches#8499
galuis116 wants to merge 1 commit into
JSONbored:mainfrom
galuis116:test/scoring-model-warning-branch-coverage-8327

Conversation

@galuis116

Copy link
Copy Markdown
Contributor

Summary

  • src/scoring/model.ts's refreshScoringModelSnapshot pushes two operator-facing warning strings onto its warnings array when a fetch degrades. Both had real branch-coverage gaps in test/unit/scoring.test.ts:
    • The unpinned-fallback warning (fired when the upstream SHA can't be resolved, so scoring fetches from a mutable ref) was already triggered by the existing "is fail-open when the upstream SHA fetch fails" test, but nothing asserted on refreshed.warnings — the sole operator-facing signal that scoring is currently unpinned had zero coverage.
    • The programming-language-weights-fetch-failed warning had ZERO coverage: every existing test either had both constants.py and programming_languages.json succeed, or had constants.py fail first (short-circuiting the function before this line is ever reached). No test combined "constants succeed, languages fail."
  • Extended the existing fail-open test to assert refreshed.warnings contains the unpinned-ref message.
  • Added a new test: constants.py succeeds with a valid body, programming_languages.json 404s — asserts sourceKind === "raw-github", programmingLanguages === {}, and the fetch-failed warning text.
  • Pure test-addition — no production logic in src/scoring/model.ts changed.

Scope

Validation

  • git diff --check
  • New tests cover both previously-uncovered warning branches; no production code changed
  • npm run actionlint
  • npx tsc --noEmit (scoped, exact root tsconfig.json compiler flags) on test/unit/scoring.test.ts, src/scoring/model.ts, src/env.d.ts, worker-configuration.d.ts — clean
  • npm --workspace @loopover/engine run build (fresh dist so @loopover/engine resolves in the scoped checks)
  • npx vitest run test/unit/scoring.test.ts — 89/89 passing (2 new)
  • npx vitest run test/unit/scoring.test.ts --coverage --coverage.include='src/scoring/model.ts' --coverage.all=false — 100% statements/lines/functions; the one remaining uncovered branch (scoringUpstreamConfig's || fallbacks, lines 33-34) is pre-existing and untouched by this diff

If any required check was skipped, explain why:

  • The whole-repo npm run typecheck/npm run test:coverage (unsharded) OOM in this sandbox regardless of diff size — a known sandbox resource constraint, not a signal about this change. Verified instead via the scoped typecheck and scoped coverage run above, isolating exactly the touched file.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

UI Evidence

This is a backend test-only change with no rendered UI delta — before and after are the same production capture at each required viewport. apps/loopover-ui is dark-mode-only, so only the Dark row per viewport applies.

Viewport · Theme Before After
Desktop · Dark Desktop · Dark before Desktop · Dark after
Tablet · Dark Tablet · Dark before Tablet · Dark after
Mobile · Dark Mobile · Dark before Mobile · Dark after

Notes

…failed warning branches

Asserts the unpinned-ref fallback warning text on the existing SHA-fetch-fails
case, and adds a case where constants succeed but the language-weights fetch
fails, covering the previously-unexercised warnings.push + empty-map fallback.
@galuis116
galuis116 requested a review from JSONbored as a code owner July 24, 2026 15:47
@superagent-security

Copy link
Copy Markdown
Contributor

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

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 24, 2026
@loopover-orb

loopover-orb Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - fixes required

Review updated: 2026-07-24 16:27:16 UTC

1 file · 1 AI reviewer · no blockers · CI failing · blocked

🛑 Suggested Action - Fix Blockers

Review summary
This is a pure test-addition PR that adds coverage for two previously-untested warning branches in refreshScoringModelSnapshot: the unpinned-SHA fallback warning (extending an existing test with a new assertion) and the language-weights-fetch-failed warning (a genuinely new test). Both branches are real and reachable — confirmed against src/scoring/model.ts's visible logic: the unpinned warning fires when upstreamSourceSha is falsy (model.ts, the resolveUpstreamCommitSha fail-open path), and the language-fetch-failed warning fires when languagesResult.ok is false while constants succeed, which the new test correctly isolates by making constants.py succeed and only the languages URL 404. No production code changed, and the new test's fetch stub correctly discriminates by URL so it exercises the intended real path rather than a fabricated one.

Nits — 4 non-blocking
  • The two FAILED checks (validate-tests-merge, validate) are undetailed, and given this branch is 18 commits behind the default branch, a stale-base merge conflict or unrelated upstream change is the more likely cause than a defect in this diff — worth a rebase to confirm.
  • Consider asserting `refreshed.warnings` does NOT contain the unpinned-fallback message in the new language-fetch-failed test, to more tightly isolate that only the intended warning fired (minor, optional).
  • Possible screenshot-table issue: identical images (row 1) — Advisory only — verify the screenshot-table images against the stated change before deciding.
  • Possible screenshot-table issue: identical images (row 2) — Advisory only — verify the screenshot-table images against the stated change before deciding.

CI checks failing

  • validate
  • validate-tests-merge

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #8327
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 1895 registered-repo PR(s), 1231 merged, 56 issue(s).
Contributor context ✅ Confirmed Gittensor contributor galuis116; Gittensor profile; 1895 PR(s), 56 issue(s).
Improvement ℹ️ Insufficient signal risk: clean · value: insufficient-signal · LLM: minor
Linked issue satisfaction

Addressed
The diff adds an assertion on refreshed.warnings for the /unpinned/i pattern to the existing SHA-fetch-fails test, and adds a new test combining a successful constants fetch with a failing programming_languages.json fetch that asserts sourceKind, programmingLanguages === {}, and the /Programming language weights fetch failed/ warning text, matching both requirements verbatim.

Review context
  • Author: galuis116
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: JavaScript, Python, TypeScript, Dart, HTML, MDX, Rust, C++
  • Official Gittensor activity: 1895 PR(s), 56 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Triage stale or unlinked PRs.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb

loopover-orb Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

LoopOver is closing this pull request on the maintainer's behalf (CI is failing (validate, validate-tests-merge)). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

@loopover-orb loopover-orb Bot closed this Jul 24, 2026
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.

Add test coverage for scoring/model.ts's unpinned-fallback and programming-language-fetch-failed warning branches

1 participant