@@ -210,6 +210,57 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
210210 } ) ,
211211 ) ;
212212
213+ it . effect ( "keeps a SQLite family local when Codex creates it between passes" , ( ) =>
214+ Effect . gen ( function * ( ) {
215+ const fileSystem = yield * FileSystem . FileSystem ;
216+ const path = yield * Path . Path ;
217+ const sharedHome = yield * makeTempDir ( "t3code-codex-shared-" ) ;
218+ const shadowRoot = yield * makeTempDir ( "t3code-codex-shadow-root-" ) ;
219+ const shadowHome = path . join ( shadowRoot , "shadow" ) ;
220+ const layout = yield * resolveCodexHomeLayout (
221+ decodeCodexSettings ( {
222+ homePath : sharedHome ,
223+ shadowHomePath : shadowHome ,
224+ } ) ,
225+ ) ;
226+
227+ yield * materializeCodexShadowHome ( layout ) ;
228+
229+ for ( const suffix of [ "" , "-wal" , "-shm" ] ) {
230+ yield * writeTextFile ( path . join ( sharedHome , `queue_1.sqlite${ suffix } ` ) , `shared${ suffix } ` ) ;
231+ yield * writeTextFile ( path . join ( shadowHome , `queue_1.sqlite${ suffix } ` ) , `shadow${ suffix } ` ) ;
232+ yield * writeTextFile (
233+ path . join ( sharedHome , `future_runtime.sqlite${ suffix } ` ) ,
234+ `future-shared${ suffix } ` ,
235+ ) ;
236+ }
237+ yield * writeTextFile ( path . join ( shadowHome , "future_runtime.sqlite" ) , "future-shadow" ) ;
238+
239+ yield * materializeCodexShadowHome ( layout ) ;
240+ yield * materializeCodexShadowHome ( layout ) ;
241+
242+ for ( const suffix of [ "" , "-wal" , "-shm" ] ) {
243+ const entryName = `queue_1.sqlite${ suffix } ` ;
244+ const sharedPath = path . join ( sharedHome , entryName ) ;
245+ const shadowPath = path . join ( shadowHome , entryName ) ;
246+
247+ expect ( yield * fileSystem . readFileString ( sharedPath ) ) . toBe ( `shared${ suffix } ` ) ;
248+ expect ( yield * fileSystem . readFileString ( shadowPath ) ) . toBe ( `shadow${ suffix } ` ) ;
249+ expect ( ( yield * fileSystem . readLink ( shadowPath ) . pipe ( Effect . result ) ) . _tag ) . toBe ( "Failure" ) ;
250+ }
251+
252+ expect (
253+ yield * fileSystem . readFileString ( path . join ( shadowHome , "future_runtime.sqlite" ) ) ,
254+ ) . toBe ( "future-shadow" ) ;
255+ expect ( yield * fileSystem . exists ( path . join ( shadowHome , "future_runtime.sqlite-wal" ) ) ) . toBe (
256+ false ,
257+ ) ;
258+ expect ( yield * fileSystem . exists ( path . join ( shadowHome , "future_runtime.sqlite-shm" ) ) ) . toBe (
259+ false ,
260+ ) ;
261+ } ) ,
262+ ) ;
263+
213264 it . effect ( "rejects shadow homes that point at the shared home" , ( ) =>
214265 Effect . gen ( function * ( ) {
215266 const sharedHome = yield * makeTempDir ( "t3code-codex-shared-" ) ;
@@ -235,6 +286,7 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
235286
236287 it . effect ( "rejects shared entries that already exist in the shadow home as real files" , ( ) =>
237288 Effect . gen ( function * ( ) {
289+ const fileSystem = yield * FileSystem . FileSystem ;
238290 const path = yield * Path . Path ;
239291 const sharedHome = yield * makeTempDir ( "t3code-codex-shared-" ) ;
240292 const shadowRoot = yield * makeTempDir ( "t3code-codex-shadow-root-" ) ;
@@ -262,6 +314,19 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
262314 expect ( error . message ) . toBe (
263315 `Cannot create Codex shadow home entry 'config.toml' because '${ path . join ( shadowHome , "config.toml" ) } ' already exists and is not a symlink.` ,
264316 ) ;
317+ expect ( yield * fileSystem . readFileString ( path . join ( sharedHome , "config.toml" ) ) ) . toBe (
318+ 'model = "gpt-5-codex"\n' ,
319+ ) ;
320+ expect ( yield * fileSystem . readFileString ( path . join ( shadowHome , "config.toml" ) ) ) . toBe (
321+ 'model = "local"\n' ,
322+ ) ;
323+
324+ yield * fileSystem . remove ( path . join ( shadowHome , "config.toml" ) ) ;
325+ yield * materializeCodexShadowHome ( layout ) ;
326+
327+ expect ( yield * fileSystem . readLink ( path . join ( shadowHome , "config.toml" ) ) ) . toBe (
328+ path . join ( sharedHome , "config.toml" ) ,
329+ ) ;
265330 } ) ,
266331 ) ;
267332
0 commit comments