From 8238efcae987d1472d09c4342a29d3d5ef5a30d4 Mon Sep 17 00:00:00 2001 From: JUN Date: Fri, 16 Oct 2026 18:39:09 +0900 Subject: [PATCH 1/2] test(config): isolate owner registry from Windows home resolution Windows homedir() follows USERPROFILE at call time. Keep the production fixture default home stable and restore the protected home before testing guarded unpinned refusal, while retaining worker-home rewrite coverage for guarded callers. --- tests/config/owner-registry-isolation.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/config/owner-registry-isolation.test.ts b/tests/config/owner-registry-isolation.test.ts index 19cef25d2dd..c13c16ade39 100644 --- a/tests/config/owner-registry-isolation.test.ts +++ b/tests/config/owner-registry-isolation.test.ts @@ -34,7 +34,9 @@ describe("owner registry home isolation", () => { import { ownerRegistryDir, readOwnerRegistry, registerOwnerRegistryHome, unregisterOwnerRegistryHome } from ${JSON.stringify(registryModule)}; const startupHome = homedir(); - process.env.HOME = process.env.USERPROFILE = ${JSON.stringify(home.path("worker"))}; + // Windows homedir() follows USERPROFILE changes. Keep production's default + // home stable; only guarded callers exercise a rewritten worker home. + if (${guarded}) process.env.HOME = process.env.USERPROFILE = ${JSON.stringify(home.path("worker"))}; // No preload and no registry override: child callers must still be isolated. delete process.env.OCX_OWNER_REGISTRY_DIR; const dir = ownerRegistryDir(); @@ -54,6 +56,8 @@ describe("owner registry home isolation", () => { unregisterOwnerRegistryHome(${JSON.stringify(foreignHome)}); } delete process.env.OCX_OWNER_REGISTRY_DIR; + // Unpin into the protected home on cached and dynamic homedir() runtimes. + process.env.HOME = process.env.USERPROFILE = startupHome; delete process.env.OPENCODEX_HOME; try { readOwnerRegistry(); } catch { unpinnedRefused = true; } } From 000037d4011e6ba2322c056fc56b7a561238b413 Mon Sep 17 00:00:00 2001 From: JUN Date: Fri, 16 Oct 2026 18:42:53 +0900 Subject: [PATCH 2/2] test(service): keep production default home stable on Windows --- tests/service/service-state-isolation.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/service/service-state-isolation.test.ts b/tests/service/service-state-isolation.test.ts index 5464adc3f49..68c449584c7 100644 --- a/tests/service/service-state-isolation.test.ts +++ b/tests/service/service-state-isolation.test.ts @@ -30,9 +30,10 @@ describe("service state home isolation", () => { import { homedir } from "node:os"; import { readServiceInstallState, serviceStatePathsForOpenCodexHome, writeServiceInstallState } from ${JSON.stringify(stateModule)}; - // Match the preload: changing HOME cannot move Bun's cached startup home. const startupHome = homedir(); - process.env.HOME = process.env.USERPROFILE = ${JSON.stringify(home.path("worker"))}; + // Windows homedir() follows USERPROFILE changes. Keep production's default + // home stable; only guarded callers exercise a rewritten worker home. + if (${guarded}) process.env.HOME = process.env.USERPROFILE = ${JSON.stringify(home.path("worker"))}; const before = readServiceInstallState(); const pinned = serviceStatePathsForOpenCodexHome(${JSON.stringify(nextConfigHome)}); writeServiceInstallState("scheduler", null);