The best way to control Claude Code, Codex and more from any computer or phone
fix(server): Codex shadow homes share thread writer locks with the main home (#26286)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Theo Browne committed
Oct 27, 2026 at 21:58 UTC
c4606e564d562a3aab978952fb28dd97bcb1ed57
2 files changed
+72
-2
apps/server/src/provider/Drivers/CodexHomeLayout.test.ts
+40
@@ -121,8 +121,10 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
121
'{"models":["shared"]}\n',
122
);
123
yield* writeTextFile(path.join(sharedHome, "auth.json"), '{"shared":true}\n');
124
+ yield* writeTextFile(path.join(sharedHome, "auth.lock"), "");
125
yield* fileSystem.makeDirectory(shadowHome, { recursive: true });
126
yield* writeTextFile(path.join(shadowHome, "auth.json"), '{"shadow":true}\n');
127
+ yield* writeTextFile(path.join(shadowHome, "auth.lock"), "");
128
yield* fileSystem.symlink(
129
path.join(sharedHome, "models_cache.json"),
130
path.join(shadowHome, "models_cache.json"),
@@ -149,6 +151,9 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
151
.readLink(path.join(shadowHome, "auth.json"))
152
.pipe(Effect.result);
153
const authContents = yield* fileSystem.readFileString(path.join(shadowHome, "auth.json"));
154
+ const authLockLinkResult = yield* fileSystem
155
+ .readLink(path.join(shadowHome, "auth.lock"))
156
+ .pipe(Effect.result);
157
158
expect(sessionsTarget).toBe(path.join(sharedHome, "sessions"));
159
expect(configTarget).toBe(path.join(sharedHome, "config.toml"));
@@ -156,6 +161,7 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
161
expect(modelsCacheExists).toBe(false);
162
expect(authLinkResult._tag).toBe("Failure");
163
expect(authContents).toContain("shadow");
164
+ expect(authLockLinkResult._tag).toBe("Failure");
165
}),
166
);
167
@@ -221,6 +227,40 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
227
}),
228
);
229
230
+ it.effect.skipIf(!symlinksSupported)(
231
+ "shares local thread writer locks once no writer still holds one",
232
+ () =>
233
+ Effect.gen(function* () {
234
+ const fileSystem = yield* FileSystem.FileSystem;
235
+ const path = yield* Path.Path;
236
+ const sharedHome = yield* makeTempDir("t3code-codex-shared-");
237
+ const shadowRoot = yield* makeTempDir("t3code-codex-shadow-root-");
238
+ const shadowHome = path.join(shadowRoot, "shadow");
239
+ const shadowLocks = path.join(shadowHome, "thread-writer-locks");
240
+ const threadLock = path.join(shadowLocks, "019a0000-0000-7000-8000-000000000000.lock");
241
+
242
+ yield* writeTextFile(path.join(shadowLocks, ".coordination.lock"), "");
243
+ yield* writeTextFile(path.join(shadowLocks, ".DS_Store"), "");
244
+ yield* writeTextFile(threadLock, "");
245
+
246
+ const layout = yield* resolveCodexHomeLayout(
247
+ decodeCodexSettings({
248
+ homePath: sharedHome,
249
+ shadowHomePath: shadowHome,
250
+ }),
251
+ );
252
+
253
+ yield* materializeCodexShadowHome(layout);
254
+ expect(yield* fileSystem.exists(threadLock)).toBe(true);
255
+
256
+ yield* fileSystem.remove(threadLock);
257
+ yield* materializeCodexShadowHome(layout);
258
+ expect(yield* fileSystem.readLink(shadowLocks)).toBe(
259
+ path.join(sharedHome, "thread-writer-locks"),
260
+ );
261
+ }),
262
+ );
263
+
264
it.effect.skipIf(!symlinksSupported)(
265
"accepts Codex-created shadow-local runtime directories",
266
() =>
apps/server/src/provider/Drivers/CodexHomeLayout.ts
+32
-2
@@ -26,13 +26,19 @@ const KNOWN_SHARED_DIRECTORIES = [
26
"cache",
27
"logs",
28
"mcp-oauth-locks",
29
+ "thread-writer-locks",
30
] as const;
31
31
-const PRIVATE_ENTRY_NAMES = new Set(["auth.json", "models_cache.json"]);
32
+// auth.lock guards the shadow home's private auth.json.
33
+const PRIVATE_ENTRY_NAMES = new Set(["auth.json", "auth.lock", "models_cache.json"]);
34
// Finder maintains metadata separately for each directory, including shadow homes.
35
const SHADOW_LOCAL_ENTRY_NAMES = new Set(["log", "memories", "tmp", ".DS_Store"]);
36
// Shadow homes may create local runtime locks first; replace them with shared links because they guard shared state.
35
-const REPLACEABLE_SHARED_RUNTIME_ENTRIES = new Set(["mcp-oauth-locks", ".sqlite-maintenance.lock"]);
37
+const REPLACEABLE_SHARED_RUNTIME_ENTRIES = new Set([
38
+ "mcp-oauth-locks",
39
+ "thread-writer-locks",
40
+ ".sqlite-maintenance.lock",
41
+]);
42
43
function resolveHomePath(path: Path.Path, home: string, value: string | undefined): string {
44
const expanded =
@@ -253,6 +259,30 @@ const ensureSymlink = Effect.fn("CodexHomeLayout.ensureSymlink")(function* (inpu
259
});
260
}
261
262
+ if (input.entryName === "thread-writer-locks") {
263
+ const lockNames = yield* input.fileSystem.readDirectory(link).pipe(
264
+ Effect.catchTags({
265
+ PlatformError: (cause) =>
266
+ new CodexShadowHomeFileSystemError({
267
+ sharedHomePath: input.sharedHomePath,
268
+ effectiveHomePath: input.effectiveHomePath,
269
+ operation: "readDirectory",
270
+ path: link,
271
+ entryName: input.entryName,
272
+ cause,
273
+ }),
274
+ }),
275
+ );
276
+ // Codex deletes a thread lock on release, so one that is left may still guard a live
277
+ // writer. Keep the local directory until a later setup finds none.
278
+ if (lockNames.some((name) => name.endsWith(".lock") && name !== ".coordination.lock")) {
279
+ return yield* Effect.logWarning(
280
+ "Codex shadow home still has thread writer locks; it will share them on a later setup.",
281
+ { path: link },
282
+ );
283
+ }
284
+ }
285
+
286
yield* input.fileSystem.remove(link, { recursive: true }).pipe(
287
Effect.catchTags({
288
PlatformError: (cause) =>