fix(server): Codex shadow homes replace stray sqlite maintenance locks (#17663)

Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Julius MarmingeandClaude Opus 5.5 authored and GitHub committed 2026-10-10 00:25:52 +00:00
1 parent 5fe9d024d9
commit 140ee145ac
2 files changed
+32 -2

No files matched your search

@@ -140,6 +140,34 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
}),
);
it.effect.skipIf(!symlinksSupported)(
"replaces a Codex-created local sqlite maintenance lock with the shared lock",
() =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const sharedHome = yield* makeTempDir("t3code-codex-shared-");
const shadowRoot = yield* makeTempDir("t3code-codex-shadow-root-");
const shadowHome = path.join(shadowRoot, "shadow");
const sharedLock = path.join(sharedHome, ".sqlite-maintenance.lock");
const shadowLock = path.join(shadowHome, ".sqlite-maintenance.lock");
yield* writeTextFile(sharedLock, "");
yield* writeTextFile(shadowLock, "");
const layout = yield* resolveCodexHomeLayout(
decodeCodexSettings({
homePath: sharedHome,
shadowHomePath: shadowHome,
}),
);
yield* materializeCodexShadowHome(layout);
expect(yield* fileSystem.readLink(shadowLock)).toBe(sharedLock);
}),
);
it.effect.skipIf(!symlinksSupported)(
"replaces Codex-created local MCP OAuth locks with the shared lock directory",
() =>
@@ -30,7 +30,9 @@ const KNOWN_SHARED_DIRECTORIES = [
const PRIVATE_ENTRY_NAMES = new Set(["auth.json", "models_cache.json"]);
const SHADOW_LOCAL_ENTRY_NAMES = new Set(["log", "memories", "tmp"]);
const REPLACEABLE_SHARED_RUNTIME_DIRECTORIES = new Set(["mcp-oauth-locks"]);
// Codex creates these runtime locks itself when it starts in a shadow home before the shared
// home has one. They guard shared state, so a local copy is replaced with the shared link.
const REPLACEABLE_SHARED_RUNTIME_ENTRIES = new Set(["mcp-oauth-locks", ".sqlite-maintenance.lock"]);
function resolveHomePath(path: Path.Path, home: string, value: string | undefined): string {
const expanded =
@@ -241,7 +243,7 @@ const ensureSymlink = Effect.fn("CodexHomeLayout.ensureSymlink")(function* (inpu
);
if (state._tag === "NotSymlink") {
if (!REPLACEABLE_SHARED_RUNTIME_DIRECTORIES.has(input.entryName)) {
if (!REPLACEABLE_SHARED_RUNTIME_ENTRIES.has(input.entryName)) {
return yield* new CodexShadowHomeEntryConflictError({
sharedHomePath: input.sharedHomePath,
effectiveHomePath: input.effectiveHomePath,