@@ -121,8 +121,10 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
121121 '{"models":["shared"]}\n' ,
122122 ) ;
123123 yield * writeTextFile ( path . join ( sharedHome , "auth.json" ) , '{"shared":true}\n' ) ;
124+ yield * writeTextFile ( path . join ( sharedHome , "auth.lock" ) , "" ) ;
124125 yield * fileSystem . makeDirectory ( shadowHome , { recursive : true } ) ;
125126 yield * writeTextFile ( path . join ( shadowHome , "auth.json" ) , '{"shadow":true}\n' ) ;
127+ yield * writeTextFile ( path . join ( shadowHome , "auth.lock" ) , "" ) ;
126128 yield * fileSystem . symlink (
127129 path . join ( sharedHome , "models_cache.json" ) ,
128130 path . join ( shadowHome , "models_cache.json" ) ,
@@ -149,13 +151,17 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
149151 . readLink ( path . join ( shadowHome , "auth.json" ) )
150152 . pipe ( Effect . result ) ;
151153 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 ) ;
152157
153158 expect ( sessionsTarget ) . toBe ( path . join ( sharedHome , "sessions" ) ) ;
154159 expect ( configTarget ) . toBe ( path . join ( sharedHome , "config.toml" ) ) ;
155160 expect ( mcpOauthLocksTarget ) . toBe ( path . join ( sharedHome , "mcp-oauth-locks" ) ) ;
156161 expect ( modelsCacheExists ) . toBe ( false ) ;
157162 expect ( authLinkResult . _tag ) . toBe ( "Failure" ) ;
158163 expect ( authContents ) . toContain ( "shadow" ) ;
164+ expect ( authLockLinkResult . _tag ) . toBe ( "Failure" ) ;
159165 } ) ,
160166 ) ;
161167
@@ -222,7 +228,7 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
222228 ) ;
223229
224230 it . effect . skipIf ( ! symlinksSupported ) (
225- "replaces Codex-created local thread writer locks with the shared lock directory " ,
231+ "shares local thread writer locks once no writer still holds one " ,
226232 ( ) =>
227233 Effect . gen ( function * ( ) {
228234 const fileSystem = yield * FileSystem . FileSystem ;
@@ -231,8 +237,10 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
231237 const shadowRoot = yield * makeTempDir ( "t3code-codex-shadow-root-" ) ;
232238 const shadowHome = path . join ( shadowRoot , "shadow" ) ;
233239 const shadowLocks = path . join ( shadowHome , "thread-writer-locks" ) ;
240+ const threadLock = path . join ( shadowLocks , "019a0000-0000-7000-8000-000000000000.lock" ) ;
234241
235242 yield * writeTextFile ( path . join ( shadowLocks , ".coordination.lock" ) , "" ) ;
243+ yield * writeTextFile ( threadLock , "" ) ;
236244
237245 const layout = yield * resolveCodexHomeLayout (
238246 decodeCodexSettings ( {
@@ -242,40 +250,16 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
242250 ) ;
243251
244252 yield * materializeCodexShadowHome ( layout ) ;
253+ expect ( yield * fileSystem . exists ( threadLock ) ) . toBe ( true ) ;
245254
255+ yield * fileSystem . remove ( threadLock ) ;
256+ yield * materializeCodexShadowHome ( layout ) ;
246257 expect ( yield * fileSystem . readLink ( shadowLocks ) ) . toBe (
247258 path . join ( sharedHome , "thread-writer-locks" ) ,
248259 ) ;
249260 } ) ,
250261 ) ;
251262
252- it . effect . skipIf ( ! symlinksSupported ) ( "keeps the shadow auth lock private" , ( ) =>
253- Effect . gen ( function * ( ) {
254- const fileSystem = yield * FileSystem . FileSystem ;
255- const path = yield * Path . Path ;
256- const sharedHome = yield * makeTempDir ( "t3code-codex-shared-" ) ;
257- const shadowRoot = yield * makeTempDir ( "t3code-codex-shadow-root-" ) ;
258- const shadowHome = path . join ( shadowRoot , "shadow" ) ;
259- const shadowLock = path . join ( shadowHome , "auth.lock" ) ;
260-
261- yield * writeTextFile ( path . join ( sharedHome , "auth.lock" ) , "" ) ;
262- yield * writeTextFile ( shadowLock , "" ) ;
263-
264- const layout = yield * resolveCodexHomeLayout (
265- decodeCodexSettings ( {
266- homePath : sharedHome ,
267- shadowHomePath : shadowHome ,
268- } ) ,
269- ) ;
270-
271- yield * materializeCodexShadowHome ( layout ) ;
272-
273- const lockLinkResult = yield * fileSystem . readLink ( shadowLock ) . pipe ( Effect . result ) ;
274- expect ( lockLinkResult . _tag ) . toBe ( "Failure" ) ;
275- expect ( yield * fileSystem . exists ( shadowLock ) ) . toBe ( true ) ;
276- } ) ,
277- ) ;
278-
279263 it . effect . skipIf ( ! symlinksSupported ) (
280264 "accepts Codex-created shadow-local runtime directories" ,
281265 ( ) =>
0 commit comments