@@ -370,7 +370,7 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
370370 } ) ,
371371 ) ;
372372
373- it . effect . skipIf ( ! symlinksSupported || ! windowsHost ) (
373+ it . effect . skipIf ( ! symlinksSupported ) (
374374 "refuses a dirty legacy SQLite overlay before materialization mutates other entries" ,
375375 ( ) =>
376376 Effect . gen ( function * ( ) {
@@ -427,8 +427,8 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
427427 } ) ,
428428 ) ;
429429
430- it . effect . skipIf ( ! symlinksSupported || ! windowsHost ) (
431- "routes a clean legacy SQLite link to the shared home without deleting the link " ,
430+ it . effect . skipIf ( ! symlinksSupported ) (
431+ "refuses a clean legacy SQLite link instead of silently redirecting it " ,
432432 ( ) =>
433433 Effect . gen ( function * ( ) {
434434 const fileSystem = yield * FileSystem . FileSystem ;
@@ -443,16 +443,16 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
443443 decodeCodexSettings ( { homePath : sharedHome , shadowHomePath : shadowHome } ) ,
444444 ) ;
445445
446- yield * materializeCodexShadowHome ( layout ) ;
447- yield * materializeCodexShadowHome ( layout ) ;
448- const environment = yield * codexHomeEnvironment ( layout , { } ) ;
446+ const error = yield * materializeCodexShadowHome ( layout ) . pipe ( Effect . flip ) ;
449447
450- expect ( environment . CODEX_SQLITE_HOME ) . toBe ( sharedHome ) ;
448+ expect ( error ) . toBeInstanceOf ( CodexShadowHomeSqliteConflictError ) ;
449+ expect ( error ) . toMatchObject ( { entryName : "state_5.sqlite" } ) ;
451450 expect ( yield * fileSystem . readLink ( linkedDatabase ) ) . toBe ( database ) ;
451+ expect ( yield * fileSystem . readFileString ( database ) ) . toBe ( "shared-database" ) ;
452452 } ) ,
453453 ) ;
454454
455- it . effect . skipIf ( ! symlinksSupported || ! windowsHost ) (
455+ it . effect . skipIf ( ! symlinksSupported ) (
456456 "refuses a legacy SQLite link that points outside the shared home" ,
457457 ( ) =>
458458 Effect . gen ( function * ( ) {
@@ -509,7 +509,58 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
509509 } ) ,
510510 ) ;
511511
512- it . effect . skipIf ( ! symlinksSupported || ! windowsHost ) (
512+ it . effect (
513+ "materialization honors an explicit SQLite override without deleting dormant sidecars" ,
514+ ( ) =>
515+ Effect . gen ( function * ( ) {
516+ const fileSystem = yield * FileSystem . FileSystem ;
517+ const path = yield * Path . Path ;
518+ const sharedHome = yield * makeTempDir ( "t3code-codex-shared-" ) ;
519+ const shadowHome = yield * makeTempDir ( "t3code-codex-shadow-" ) ;
520+ const customHome = yield * makeTempDir ( "t3code-codex-custom-sqlite-" ) ;
521+ const sidecar = path . join ( shadowHome , "state_5.sqlite-wal" ) ;
522+ yield * writeTextFile ( sidecar , "legacy-wal" ) ;
523+ const layout = yield * resolveCodexHomeLayout (
524+ decodeCodexSettings ( { homePath : sharedHome , shadowHomePath : shadowHome } ) ,
525+ ) ;
526+ const launchEnvironment = { CODEX_SQLITE_HOME : customHome } ;
527+
528+ yield * materializeCodexShadowHome ( layout , launchEnvironment ) ;
529+ const environment = yield * codexHomeEnvironment ( layout , launchEnvironment ) ;
530+
531+ expect ( environment . CODEX_SQLITE_HOME ) . toBe ( customHome ) ;
532+ expect ( yield * fileSystem . readFileString ( sidecar ) ) . toBe ( "legacy-wal" ) ;
533+ } ) ,
534+ ) ;
535+
536+ it . effect . skipIf ( ! symlinksSupported ) (
537+ "explicit SQLite overrides still refuse legacy database symlinks" ,
538+ ( ) =>
539+ Effect . gen ( function * ( ) {
540+ const fileSystem = yield * FileSystem . FileSystem ;
541+ const path = yield * Path . Path ;
542+ const sharedHome = yield * makeTempDir ( "t3code-codex-shared-" ) ;
543+ const shadowHome = yield * makeTempDir ( "t3code-codex-shadow-" ) ;
544+ const customHome = yield * makeTempDir ( "t3code-codex-custom-sqlite-" ) ;
545+ const database = path . join ( sharedHome , "state_5.sqlite" ) ;
546+ const linkedDatabase = path . join ( shadowHome , "state_5.sqlite" ) ;
547+ yield * writeTextFile ( database , "shared-database" ) ;
548+ yield * fileSystem . symlink ( database , linkedDatabase ) ;
549+ const layout = yield * resolveCodexHomeLayout (
550+ decodeCodexSettings ( { homePath : sharedHome , shadowHomePath : shadowHome } ) ,
551+ ) ;
552+
553+ const error = yield * materializeCodexShadowHome ( layout , {
554+ CODEX_SQLITE_HOME : customHome ,
555+ } ) . pipe ( Effect . flip ) ;
556+
557+ expect ( error ) . toBeInstanceOf ( CodexShadowHomeSqliteConflictError ) ;
558+ expect ( error ) . toMatchObject ( { entryName : "state_5.sqlite" } ) ;
559+ expect ( yield * fileSystem . readLink ( linkedDatabase ) ) . toBe ( database ) ;
560+ } ) ,
561+ ) ;
562+
563+ it . effect . skipIf ( ! symlinksSupported ) (
513564 "refuses a legacy linked database with a shadow-local SHM without changing either file" ,
514565 ( ) =>
515566 Effect . gen ( function * ( ) {
0 commit comments