Skip to content

test(selfhost): add unit-test seam for validate-selfhost-sourcemap#7491

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
jsdevninja:test/validate-selfhost-sourcemap-seam
Jul 20, 2026
Merged

test(selfhost): add unit-test seam for validate-selfhost-sourcemap#7491
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
jsdevninja:test/validate-selfhost-sourcemap-seam

Conversation

@jsdevninja

@jsdevninja jsdevninja commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Refactor scripts/validate-selfhost-sourcemap.mjs so validation is an injectable validateSourcemap({ bundlePath, mapPath, exists, readFile }) export, with the live CLI path behind an entrypoint guard.
  • Add scripts/validate-selfhost-sourcemap.d.mts for typecheck when the unit suite imports the .mjs module.
  • Add test/unit/validate-selfhost-sourcemap-script.test.ts covering every existing failure branch plus a well-formed passing case, without requiring a real dist/ build.

Closes #7458

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • Scripts-only testability refactor (scripts/** is outside Codecov coverage.include). Ran npx vitest run test/unit/validate-selfhost-sourcemap-script.test.ts (12 pass) and npx tsc --noEmit. Remaining test:ci surface is unchanged and will run in CI. CLI behavior (cwd-relative paths, console.error + exit 1 on failure) is preserved behind the entrypoint guard.

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

N/A — CI script / unit-test seam only; no visible UI change.

Notes

  • Analogues: scripts/check-miner-package.mjs injectable readContent/pack parameters; scripts/validate-observability-configs.mjs entrypoint guard + *-script.test.ts pattern.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jsdevninja
jsdevninja requested a review from JSONbored as a code owner July 20, 2026 12:40
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.41%. Comparing base (87766eb) to head (34e0282).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7491   +/-   ##
=======================================
  Coverage   91.41%   91.41%           
=======================================
  Files         717      717           
  Lines       73032    73032           
  Branches    21635    21633    -2     
=======================================
  Hits        66762    66762           
  Misses       5227     5227           
  Partials     1043     1043           
Flag Coverage Δ
shard-1 32.03% <ø> (+0.77%) ⬆️
shard-2 35.17% <ø> (-0.37%) ⬇️
shard-3 35.75% <ø> (+0.25%) ⬆️
shard-4 43.61% <ø> (+0.24%) ⬆️
shard-5 38.57% <ø> (-0.20%) ⬇️
shard-6 32.05% <ø> (-0.53%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

loopover-orb Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-20 12:58:41 UTC

3 files · 1 AI reviewer · no blockers · readiness 95/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a clean, well-scoped refactor that extracts the validation logic into an injectable `validateSourcemap()` export with a CLI entrypoint guarded by `import.meta.url === pathToFileURL(...)`, preserving the original cwd-relative + exit-1 behavior. The unit tests exercise every failure branch (missing bundle, missing map, missing sourceMappingURL, invalid JSON, wrong version, empty sources, mismatched sourcesContent length, missing server.ts, empty server.ts content, no repo-relative sources, empty repo-relative content) plus the passing case, all via a fake-fs harness that avoids needing a real dist/ build. The `.d.mts` companion file correctly types the new export for the TS test suite consuming a `.mjs` module.

Nits — 5 non-blocking
  • scripts/validate-selfhost-sourcemap.mjs:45 — `map.version !== 3` is a magic number; a named constant (e.g. `SOURCE_MAP_VERSION = 3`) would self-document intent, though this is trivial and pre-existing logic just moved.
  • The external brief flags 'console' usage and 'depth 5' nesting at scripts/validate-selfhost-sourcemap.mjs:78/85/63, but these are pre-existing patterns from the original file (console.error in `fail`, console.log in `main`) merely relocated during the refactor, not new complexity introduced by this diff.
  • Consider a brief comment on why the CLI guard uses `pathToFileURL(process.argv[1] ?? "")` (handles the case where argv[1] is undefined) since it's a slightly non-obvious defensive pattern.
  • scripts/validate-selfhost-sourcemap.mjs:23-24 — the `options.bundlePath ?? resolve(...)` pattern is clean; no change needed, just noting the injectable defaults read well.
  • test/unit/validate-selfhost-sourcemap-script.test.ts — tests are thorough and each asserts a specific real error string, avoiding fabricated/impossible states; this is a good pattern for other script test seams in the repo.

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 #7458
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: 193 registered-repo PR(s), 120 merged, 38 issue(s).
Contributor context ✅ Confirmed Gittensor contributor jsdevninja; Gittensor profile; 193 PR(s), 38 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff refactors validate-selfhost-sourcemap.mjs into an injectable validateSourcemap({bundlePath, mapPath, exists, readFile}) export with a guarded CLI entrypoint preserving prior cwd-relative/exit-1 behavior, and adds test/unit/validate-selfhost-sourcemap-script.test.ts covering all 8 named failure branches plus a passing minimal-map case, matching the issue's requirements and deliverables.

Review context
  • Author: jsdevninja
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: JavaScript, Swift, C, CSS, MDX, Python, TypeScript, Vue
  • Official Gittensor activity: 193 PR(s), 38 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 &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; 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 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit c18b123 into JSONbored:main Jul 20, 2026
16 checks passed
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.

test(selfhost): validate-selfhost-sourcemap.mjs has no unit-test seam despite gating every self-host release

1 participant