Repository navigation
test: isolate attribution suites from leaked auth, beta and routing mocks (TA-001 slice 5) - #2334
Conversation
…ports are polluted (TA-001 slice 5)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
jatmn
left a comment
There was a problem hiding this comment.
— jatmn's PR Review agent
Merge readiness
Pinned head f81285a0c7b720685d4f07c11935a153dfe46f16 is mergeable against main with merge-base 3a646df82182c5d63bff2587e2df070aed7209ad (live-base-three-dot, not behind default). Required CI on that commit is green (typecheck, smoke-and-tests, dedicated-tests, unit shards, CodeQL, pr-intent-scan). The diff is test-only (TA-001 slice 5), does not depend on stacking #2332, and matches the stated auth/beta/routing isolation scope.
🟢 Thanks for the contribution. I do not see any actionable issues from my review.
Summary
sideQuery.attributionandauthRouting.attribution. Test files only.fastMode.test.tsstubsutils/auth(API keytest-key, no OAuth, not a subscriber), and its cleanup re-registers the live namespace, which Bun has already redirected to the mock. A laterbetas.test.tsre-registers the real provider functions, so the provider-only check inproviderModuleIsolation.tssaw nothing wrong and the attribution suites ran in-process against mocked auth. That produced the 5 sideQuery failures (OAuth attribution off,test-keysent instead of the suite's key) and 2 authRouting failures when run after those two files.src/test/providerModuleIsolation.ts: adds an attribution detector. It compares the canonical and cache-busted export surfaces of providers, auth, betas, authRouting, routeMetadata and the API client. It counts missing exports and changed function source, and treats anything it can't compare as needing a child. Inside the child it skips detection, so it can't recurse. The existing API, child launcher and deadline are unchanged.describe.skipcopies. When isolation is needed, the parent registers only the wrapper, and the suites' setup and hooks stay inside the real-suite branch. All 8 sideQuery and 13 authRouting cases and their assertions are unchanged.src/test/providerModuleIsolation.test.tswith fixturesrc/test/fixtures/providerModuleIsolation.fixture.ts. These are regression tests for clean exports, polluted auth, beta-only and routing-only replacement, missing exports, recursion prevention and child failure propagation. Deliberate pollution runs only in disposable subprocesses.Impact
--isolate, and no CONTRIBUTING change is needed because this extends the existing child-isolation pattern.Testing
bun run build, temp config dirs):bun teston main: before 20 fail, after 17 fail. All 5 sideQuery failures are gone; remaining failures belong to other TA-001 slices, plus the 2 gitSettings tests below.describe.skipduplicate copies are gone.bun run typecheck: pass.bun run check: every step passes except 2gitSettings.test.tstests (shard 1).fastMode+betas, afteruseApiKeyVerification, andproviderModuleIsolation.test.ts.gitSettings.test.ts"omits git instructions outside a git repository" and "follows the session cwd" fail on unmodified main in the same worker environment, including when the file runs alone. That makes them environmental and unrelated to this diff.Notes
fastMode.test.tsanduseApiKeyVerification.test.tsxstill re-register a live auth namespace on cleanup. Restoring those is a separate polluter slice.Summary by CodeRabbit