diff --git a/tests/codex-transition-state-race.test.ts b/tests/codex-transition-state-race.test.ts index 2bfe1749b93..12644eb892d 100644 --- a/tests/codex-transition-state-race.test.ts +++ b/tests/codex-transition-state-race.test.ts @@ -35,14 +35,13 @@ const transitionProbe = ` } from ${JSON.stringify(transitionStateModuleUrl)}; import { resolveCodexCoordinatorDatabasePath, - resolveEffectiveUserIdentity, } from ${JSON.stringify(userIdentityModuleUrl)}; import { existsSync, realpathSync, writeFileSync } from "node:fs"; const payload = JSON.parse(process.env.CCX_TEST_PAYLOAD); const canonicalCodexHome = realpathSync.native(payload.codexHome); const databasePath = resolveCodexCoordinatorDatabasePath( - resolveEffectiveUserIdentity(), + payload.identity, canonicalCodexHome, ); const next = txId => ({ txId }); @@ -111,19 +110,26 @@ interface Sandbox { codexHome: string; codexCommanderHomes: [string, string]; coordinatorPath: string; + identity: ReturnType; } +let sandboxUserIdentity: ReturnType | undefined; + function createSandbox(label: string): Sandbox { const root = mkdtempSync(join(tmpdir(), `ccx-transition-race-${label}-`)); const codexHome = join(root, "codex"); const codexCommanderHomes: [string, string] = [join(root, "ccx-a"), join(root, "ccx-b")]; mkdirSync(codexHome); for (const path of codexCommanderHomes) mkdirSync(path); + // A sandbox's identity is process-wide. On Windows this lookup starts + // PowerShell, so reuse the verified identity across sandboxes in this test + // file instead of repeating that subprocess under full-suite load. + sandboxUserIdentity ??= resolveEffectiveUserIdentity(); const coordinatorPath = resolveCodexCoordinatorDatabasePath( - resolveEffectiveUserIdentity(), + sandboxUserIdentity, realpathSync.native(codexHome), ); - return { root, codexHome, codexCommanderHomes, coordinatorPath }; + return { root, codexHome, codexCommanderHomes, coordinatorPath, identity: sandboxUserIdentity }; } function cleanupSandbox(sandbox: Sandbox): void { @@ -139,7 +145,11 @@ function spawnProbe(sandbox: Sandbox, codexCommanderHome: string, payload: Recor ...process.env, CODEX_HOME: sandbox.codexHome, CODEXCOMMANDER_HOME: codexCommanderHome, - CCX_TEST_PAYLOAD: JSON.stringify({ ...payload, codexHome: sandbox.codexHome }), + CCX_TEST_PAYLOAD: JSON.stringify({ + ...payload, + codexHome: sandbox.codexHome, + identity: sandbox.identity, + }), }, stdin: "ignore", stdout: "pipe",