Skip to content

test(unit): isolate loopover-mcp/miner tests from real machine state#7515

Merged
loopover-orb[bot] merged 1 commit into
mainfrom
claude/cool-poincare-db0108
Jul 20, 2026
Merged

test(unit): isolate loopover-mcp/miner tests from real machine state#7515
loopover-orb[bot] merged 1 commit into
mainfrom
claude/cool-poincare-db0108

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • test/unit/local-branch.test.ts, test/unit/miner-init-verify-token.test.ts, and
    test/unit/miner-self-review-context.test.ts fail non-deterministically depending on the
    host machine, independent of any working-tree change (reproduces on a clean main
    checkout). Root-caused and fixed both distinct bugs; see #7512 for the full writeup.
  • local-branch.test.ts: two assertions compared against the raw os.tmpdir() path instead
    of the realpathSync-resolved form safeResolvedPath (the code under test) actually
    produces — diverges on macOS, where os.tmpdir() lives under a /var/private/var
    symlink. Fixed by resolving the expected path through realpathSync too.
  • miner-init-verify-token.test.ts / miner-self-review-context.test.ts: several calls
    didn't isolate env/loopoverAuth, so resolveGitHubToken / resolveLoopoverBackendSession
    fell through to a real ~/.config/loopover/config.json on any machine that has run
    loopover-mcp login, firing an extra concurrent fetch that raced with and corrupted other
    captured fetch calls/headers/timeouts in the same Promise.all (confirmed by temporarily
    moving the real config file aside — all 9 originally-reported failures vanished). Fixed by
    isolating makeTempEnv()'s LOOPOVER_CONFIG_DIR/LOOPOVER_CONFIG_PATH/XDG_CONFIG_HOME/
    GITHUB_TOKEN, and by passing loopoverAuth: null to every fetchSelfReviewContext(...)
    call site that isn't itself testing the live-gate-thresholds probe (matching that file's own
    existing convention for the tests that already do this).

Closes #7512

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:

  • npm run test:ci ran end-to-end and every one of its 35 chained steps passed except
    ui:test (which blocked the final ui:build step behind it via &&). ui:test fails in
    this sandbox because it is running Node v26.5.0, not the repo's pinned Node 22
    (.nvmrc) — under v26, jsdom 25.0.1's window.localStorage does not initialize correctly
    inside vitest's jsdom environment (Cannot read properties of undefined (reading 'clear')),
    affecting all 5 pre-existing apps/loopover-ui test files that touch localStorage, not
    just ones near this diff. Confirmed unrelated to this PR: this diff touches zero files under
    apps/loopover-ui/**; a clean npm ci reproduces the same failure; and the same failure
    reproduces on unrelated files (src/lib/use-local-storage.test.ts,
    src/lib/analytics-window.test.ts) that share nothing with this change. Real CI installs
    Node 22 per .nvmrc, so this is a local sandbox environment mismatch, not a code defect —
    not filed as a tracked issue since it isn't expected to reproduce there.

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

Not applicable — this PR touches only test/unit/** files; no UI/frontend/docs/extension change.

Notes

  • All three fixed test files are outside Codecov's coverage.include (src/** only), so this
    PR carries no codecov/patch obligation.

Three test/unit/ files pass or fail depending on the host machine rather
than the working tree: local-branch.test.ts compared against the raw
os.tmpdir() path instead of safeResolvedPath's realpathSync-resolved form
(diverges on macOS, where tmpdir lives under a /var -> /private/var
symlink), and miner-init-verify-token.test.ts / miner-self-review-
context.test.ts didn't isolate env/loopoverAuth, so resolveGitHubToken /
resolveLoopoverBackendSession fell through to a real
~/.config/loopover/config.json on any machine that has run
`loopover-mcp login`, firing an extra concurrent fetch that raced with and
corrupted other captured calls/headers/timeouts.

Closes #7512
@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 (98a8371) to head (be8d3dc).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7515      +/-   ##
==========================================
- Coverage   91.43%   91.41%   -0.02%     
==========================================
  Files         718      718              
  Lines       73214    73214              
  Branches    21692    21692              
==========================================
- Hits        66944    66932      -12     
- Misses       5227     5234       +7     
- Partials     1043     1048       +5     
Flag Coverage Δ
shard-1 26.18% <ø> (-0.01%) ⬇️
shard-2 37.31% <ø> (-0.02%) ⬇️
shard-3 36.36% <ø> (ø)
shard-4 42.83% <ø> (-0.09%) ⬇️
shard-5 38.19% <ø> (ø)
shard-6 33.60% <ø> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 3 files with indirect coverage changes

@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 19:40:27 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR isolates three flaky unit test files from real machine state: it makes local-branch.test.ts compare against realpathSync-resolved paths (fixing a macOS /var vs /private/var symlink mismatch), and forces loopoverAuth: null / isolates LOOPOVER_CONFIG_DIR/XDG_CONFIG_HOME/GITHUB_TOKEN in the miner-init and self-review-context tests so a real ~/.config/loopover/config.json or GITHUB_TOKEN on the host machine can't fire an extra concurrent fetch that races with captured mock assertions. The fixes are well-targeted at the actual test assertions and env setup rather than patching symptoms elsewhere, and CI passed on all six shards. This is a pure test-only change (no src/ modifications) closing the linked issue #7512.

Nits — 3 non-blocking
  • The inline comments explaining the realpathSync/env-isolation rationale are long for test files; could be trimmed or moved to a shared helper doc, though the historical context they preserve is genuinely useful here.
  • Consider factoring the repeated LOOPOVER_CONFIG_DIR/XDG_CONFIG_HOME/GITHUB_TOKEN isolation block in miner-init-verify-token.test.ts's makeTempEnv() into a shared test utility if other miner test files need the same isolation in the future.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.

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 #7512
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: 28 registered-repo PR(s), 21 merged, 369 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 28 PR(s), 369 issue(s).
Improvement ℹ️ Insufficient signal risk: clean · value: insufficient-signal · LLM: moderate
Linked issue satisfaction

Addressed
The diff realpath-resolves both expected-path assertions in local-branch.test.ts, adds loopoverAuth: null to essentially every non-probe fetchSelfReviewContext call site, and extends makeTempEnv() in miner-init-verify-token.test.ts to isolate LOOPOVER_CONFIG_DIR/LOOPOVER_CONFIG_PATH/XDG_CONFIG_HOME/GITHUB_TOKEN via a fresh temp dir, matching all three stated requirements.

Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 28 PR(s), 369 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Treat this as maintainer-lane context rather than normal contributor-lane activity.
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 29437e1 into main Jul 20, 2026
17 checks passed
@loopover-orb
loopover-orb Bot deleted the claude/cool-poincare-db0108 branch July 20, 2026 19:40
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/unit: local-branch, miner-init-verify-token, and miner-self-review-context leak real machine state into mocked assertions

1 participant