Skip to content

Commit 140ee14

Browse files
fix(server): Codex shadow homes replace stray sqlite maintenance locks (pingdotgg#17663)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 5fe9d02 commit 140ee14

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

‎apps/server/src/provider/Drivers/CodexHomeLayout.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,34 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
140140
}),
141141
);
142142

143+
it.effect.skipIf(!symlinksSupported)(
144+
"replaces a Codex-created local sqlite maintenance lock with the shared lock",
145+
() =>
146+
Effect.gen(function* () {
147+
const fileSystem = yield* FileSystem.FileSystem;
148+
const path = yield* Path.Path;
149+
const sharedHome = yield* makeTempDir("t3code-codex-shared-");
150+
const shadowRoot = yield* makeTempDir("t3code-codex-shadow-root-");
151+
const shadowHome = path.join(shadowRoot, "shadow");
152+
const sharedLock = path.join(sharedHome, ".sqlite-maintenance.lock");
153+
const shadowLock = path.join(shadowHome, ".sqlite-maintenance.lock");
154+
155+
yield* writeTextFile(sharedLock, "");
156+
yield* writeTextFile(shadowLock, "");
157+
158+
const layout = yield* resolveCodexHomeLayout(
159+
decodeCodexSettings({
160+
homePath: sharedHome,
161+
shadowHomePath: shadowHome,
162+
}),
163+
);
164+
165+
yield* materializeCodexShadowHome(layout);
166+
167+
expect(yield* fileSystem.readLink(shadowLock)).toBe(sharedLock);
168+
}),
169+
);
170+
143171
it.effect.skipIf(!symlinksSupported)(
144172
"replaces Codex-created local MCP OAuth locks with the shared lock directory",
145173
() =>

‎apps/server/src/provider/Drivers/CodexHomeLayout.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ const KNOWN_SHARED_DIRECTORIES = [
3030

3131
const PRIVATE_ENTRY_NAMES = new Set(["auth.json", "models_cache.json"]);
3232
const SHADOW_LOCAL_ENTRY_NAMES = new Set(["log", "memories", "tmp"]);
33-
const REPLACEABLE_SHARED_RUNTIME_DIRECTORIES = new Set(["mcp-oauth-locks"]);
33+
// Codex creates these runtime locks itself when it starts in a shadow home before the shared
34+
// home has one. They guard shared state, so a local copy is replaced with the shared link.
35+
const REPLACEABLE_SHARED_RUNTIME_ENTRIES = new Set(["mcp-oauth-locks", ".sqlite-maintenance.lock"]);
3436

3537
function resolveHomePath(path: Path.Path, home: string, value: string | undefined): string {
3638
const expanded =
@@ -241,7 +243,7 @@ const ensureSymlink = Effect.fn("CodexHomeLayout.ensureSymlink")(function* (inpu
241243
);
242244

243245
if (state._tag === "NotSymlink") {
244-
if (!REPLACEABLE_SHARED_RUNTIME_DIRECTORIES.has(input.entryName)) {
246+
if (!REPLACEABLE_SHARED_RUNTIME_ENTRIES.has(input.entryName)) {
245247
return yield* new CodexShadowHomeEntryConflictError({
246248
sharedHomePath: input.sharedHomePath,
247249
effectiveHomePath: input.effectiveHomePath,

0 commit comments

Comments
 (0)