Context
Three test/unit/ files fail non-deterministically depending on the machine they run on,
independent of any working-tree change (reproduces on a clean checkout of main):
test/unit/local-branch.test.ts — two resolveWorkspaceCwd/normalizeMcpWorkspaceRoots
assertions compare against the raw os.tmpdir() path, but
packages/loopover-mcp/lib/local-branch.ts's safeResolvedPath correctly resolves it via
realpathSync. On macOS, os.tmpdir() lives under /var/folders/..., itself a symlink to
/private/var/folders/..., so the raw and resolved paths diverge and the assertion fails.
Linux CI runners don't have this symlink, so the bug is invisible there.
test/unit/miner-init-verify-token.test.ts and test/unit/miner-self-review-context.test.ts
— several runInit/fetchSelfReviewContext calls don't isolate env/loopoverAuth, so
packages/loopover-miner/lib/github-token-resolution.ts's resolveGitHubToken /
resolveLoopoverBackendSession fall through to process.env and read a real
~/.config/loopover/config.json on any machine that has ever run loopover-mcp login.
That fires an extra, unmocked-in-intent concurrent fetch (the ORB live-gate-thresholds
probe), which races with and corrupts other captured fetch calls/headers/timeouts in the
same Promise.all — including reusing a mockResolvedValue'd Response object across two
fetch calls, whose second .json() read silently fails since Response bodies are
single-use streams. CI has no such config file, so this is invisible there too.
Requirements
local-branch.test.ts's two affected assertions must compare against the realpathSync-
resolved form of the temp path, matching what safeResolvedPath itself does, so the test is
correct on both macOS (symlinked tmpdir) and Linux (unsymlinked tmpdir).
- Every
fetchSelfReviewContext(...) call in miner-self-review-context.test.ts that is not
itself testing the live-gate-thresholds probe feature must pass loopoverAuth: null
(mirroring the file's own existing convention for the tests that already do this), so none of
them depend on ambient machine state.
miner-init-verify-token.test.ts's makeTempEnv() helper must isolate
LOOPOVER_CONFIG_DIR/LOOPOVER_CONFIG_PATH/XDG_CONFIG_HOME/GITHUB_TOKEN (pointing
LOOPOVER_CONFIG_DIR at a fresh empty temp dir), following the same pattern
test/unit/miner-github-token-resolution.test.ts's configuredEnv helper already
establishes for this exact module.
Deliverables
Test Coverage Requirements
All changes are confined to test/**, which is outside Codecov's coverage.include
(src/** only), so this carries no codecov/patch obligation. The regression signal is the
fix itself: these are pre-existing tests whose assertions become environment-independent
rather than new tests being added.
Expected Outcome
npx vitest run test/unit/local-branch.test.ts test/unit/miner-init-verify-token.test.ts test/unit/miner-self-review-context.test.ts (and the full npm run test:coverage, unsharded)
is green regardless of the host OS or whether the machine has a real loopover-mcp session on
disk — no excluded files, no machine-specific caveats.
Links & Resources
packages/loopover-mcp/lib/local-branch.ts (safeResolvedPath, resolveWorkspaceCwd,
normalizeMcpWorkspaceRoots)
packages/loopover-miner/lib/github-token-resolution.ts (resolveGitHubToken,
resolveLoopoverBackendSession)
packages/loopover-miner/lib/self-review-context.ts (fetchSelfReviewContext,
normalizeOptions, probeLiveGateThresholds)
test/unit/miner-github-token-resolution.test.ts's configuredEnv helper (the existing,
correct isolation pattern for this exact module)
Context
Three
test/unit/files fail non-deterministically depending on the machine they run on,independent of any working-tree change (reproduces on a clean checkout of
main):test/unit/local-branch.test.ts— tworesolveWorkspaceCwd/normalizeMcpWorkspaceRootsassertions compare against the raw
os.tmpdir()path, butpackages/loopover-mcp/lib/local-branch.ts'ssafeResolvedPathcorrectly resolves it viarealpathSync. On macOS,os.tmpdir()lives under/var/folders/..., itself a symlink to/private/var/folders/..., so the raw and resolved paths diverge and the assertion fails.Linux CI runners don't have this symlink, so the bug is invisible there.
test/unit/miner-init-verify-token.test.tsandtest/unit/miner-self-review-context.test.ts— several
runInit/fetchSelfReviewContextcalls don't isolateenv/loopoverAuth, sopackages/loopover-miner/lib/github-token-resolution.ts'sresolveGitHubToken/resolveLoopoverBackendSessionfall through toprocess.envand read a real~/.config/loopover/config.jsonon any machine that has ever runloopover-mcp login.That fires an extra, unmocked-in-intent concurrent fetch (the ORB
live-gate-thresholdsprobe), which races with and corrupts other captured fetch calls/headers/timeouts in the
same
Promise.all— including reusing amockResolvedValue'dResponseobject across twofetchcalls, whose second.json()read silently fails sinceResponsebodies aresingle-use streams. CI has no such config file, so this is invisible there too.
Requirements
local-branch.test.ts's two affected assertions must compare against therealpathSync-resolved form of the temp path, matching what
safeResolvedPathitself does, so the test iscorrect on both macOS (symlinked tmpdir) and Linux (unsymlinked tmpdir).
fetchSelfReviewContext(...)call inminer-self-review-context.test.tsthat is notitself testing the live-gate-thresholds probe feature must pass
loopoverAuth: null(mirroring the file's own existing convention for the tests that already do this), so none of
them depend on ambient machine state.
miner-init-verify-token.test.ts'smakeTempEnv()helper must isolateLOOPOVER_CONFIG_DIR/LOOPOVER_CONFIG_PATH/XDG_CONFIG_HOME/GITHUB_TOKEN(pointingLOOPOVER_CONFIG_DIRat a fresh empty temp dir), following the same patterntest/unit/miner-github-token-resolution.test.ts'sconfiguredEnvhelper alreadyestablishes for this exact module.
Deliverables
test/unit/local-branch.test.ts— realpath-resolve the two expected-path comparisons.test/unit/miner-init-verify-token.test.ts— isolatemakeTempEnv()from realloopover-mcp config/session state.
test/unit/miner-self-review-context.test.ts— addloopoverAuth: nullto every callsite that isn't specifically exercising the probe.
Test Coverage Requirements
All changes are confined to
test/**, which is outside Codecov'scoverage.include(
src/**only), so this carries nocodecov/patchobligation. The regression signal is thefix itself: these are pre-existing tests whose assertions become environment-independent
rather than new tests being added.
Expected Outcome
npx vitest run test/unit/local-branch.test.ts test/unit/miner-init-verify-token.test.ts test/unit/miner-self-review-context.test.ts(and the fullnpm run test:coverage, unsharded)is green regardless of the host OS or whether the machine has a real
loopover-mcpsession ondisk — no excluded files, no machine-specific caveats.
Links & Resources
packages/loopover-mcp/lib/local-branch.ts(safeResolvedPath,resolveWorkspaceCwd,normalizeMcpWorkspaceRoots)packages/loopover-miner/lib/github-token-resolution.ts(resolveGitHubToken,resolveLoopoverBackendSession)packages/loopover-miner/lib/self-review-context.ts(fetchSelfReviewContext,normalizeOptions,probeLiveGateThresholds)test/unit/miner-github-token-resolution.test.ts'sconfiguredEnvhelper (the existing,correct isolation pattern for this exact module)