@@ -1068,9 +1068,7 @@ describe("codex bin wrapper", () => {
10681068 'const cacheShmPath = path.join(process.env.CODEX_HOME ?? "", "plugin_cache.sqlite-shm");' ,
10691069 'console.log(`CACHE_SQLITE_MIRRORED:${fs.existsSync(cachePath)}`);' ,
10701070 'console.log(`CACHE_WAL_MIRRORED:${fs.existsSync(cacheWalPath)}`);' ,
1071- 'let cacheShmPlaceholder = "false";' ,
1072- 'try { cacheShmPlaceholder = String(fs.lstatSync(cacheShmPath).isSymbolicLink()); } catch { cacheShmPlaceholder = process.platform === "win32" ? "skipped" : "false"; }' ,
1073- 'console.log(`CACHE_SHM_PLACEHOLDER:${cacheShmPlaceholder}`);' ,
1071+ 'console.log(`CACHE_SHM_MIRRORED:${fs.existsSync(cacheShmPath)}`);' ,
10741072 'const logPath = path.join(process.env.CODEX_HOME ?? "", "logs_2.sqlite");' ,
10751073 'const logWalPath = path.join(process.env.CODEX_HOME ?? "", "logs_2.sqlite-wal");' ,
10761074 'const logShmPath = path.join(process.env.CODEX_HOME ?? "", "logs_2.sqlite-shm");' ,
@@ -1176,6 +1174,7 @@ describe("codex bin wrapper", () => {
11761174 writeFileSync ( join ( originalHome , "LOGS_3.sqlite" ) , "upper log\n" , "utf8" ) ;
11771175 writeFileSync ( join ( originalHome , "plugin_cache.sqlite" ) , "cache\n" , "utf8" ) ;
11781176 writeFileSync ( join ( originalHome , "plugin_cache.sqlite-wal" ) , "cache wal\n" , "utf8" ) ;
1177+ writeFileSync ( join ( originalHome , "plugin_cache.sqlite-shm" ) , "cache shm\n" , "utf8" ) ;
11791178 writeFileSync (
11801179 join ( originalHome , "config.toml" ) ,
11811180 [
@@ -1228,7 +1227,7 @@ describe("codex bin wrapper", () => {
12281227 expect ( output ) . toContain ( "GLOBAL_STATE_TMP_ISOLATED:true" ) ;
12291228 expect ( output ) . toContain ( "CACHE_SQLITE_MIRRORED:true" ) ;
12301229 expect ( output ) . toContain ( "CACHE_WAL_MIRRORED:true" ) ;
1231- expect ( output ) . toMatch ( / ^ C A C H E _ S H M _ P L A C E H O L D E R : (?: t r u e | s k i p p e d ) $ / m ) ;
1230+ expect ( output ) . toContain ( "CACHE_SHM_MIRRORED: true" ) ;
12321231 expect ( output ) . toContain ( "LOG_SQLITE_MIRRORED:false" ) ;
12331232 expect ( output ) . toContain ( "LOG_WAL_MIRRORED:false" ) ;
12341233 expect ( output ) . toContain ( "LOG_SHM_MIRRORED:false" ) ;
@@ -1368,10 +1367,57 @@ describe("codex bin wrapper", () => {
13681367 "#!/usr/bin/env node" ,
13691368 'const fs = require("node:fs");' ,
13701369 'const path = require("node:path");' ,
1370+ 'const cachePath = path.join(process.env.CODEX_HOME ?? "", "plugin_cache.sqlite");' ,
1371+ 'const cacheWalPath = path.join(process.env.CODEX_HOME ?? "", "plugin_cache.sqlite-wal");' ,
13711372 'const cacheShmPath = path.join(process.env.CODEX_HOME ?? "", "plugin_cache.sqlite-shm");' ,
1372- 'let cacheShmPlaceholder = "false";' ,
1373- 'try { cacheShmPlaceholder = String(fs.lstatSync(cacheShmPath).isSymbolicLink()); } catch { cacheShmPlaceholder = "false"; }' ,
1374- 'console.log(`CACHE_SHM_PLACEHOLDER:${cacheShmPlaceholder}`);' ,
1373+ 'console.log(`CACHE_SQLITE_MIRRORED:${fs.existsSync(cachePath)}`);' ,
1374+ 'console.log(`CACHE_WAL_MIRRORED:${fs.existsSync(cacheWalPath)}`);' ,
1375+ 'console.log(`CACHE_SHM_MIRRORED:${fs.existsSync(cacheShmPath)}`);' ,
1376+ "process.exit(0);" ,
1377+ ] ) ;
1378+ const originalHome = join ( fixtureRoot , "codex-home" ) ;
1379+ const markerPath = join ( fixtureRoot , "proxy-marker.txt" ) ;
1380+ mkdirSync ( originalHome , { recursive : true } ) ;
1381+ writeFileSync ( join ( originalHome , "plugin_cache.sqlite" ) , "cache\n" , "utf8" ) ;
1382+ writeFileSync ( join ( originalHome , "plugin_cache.sqlite-wal" ) , "cache wal\n" , "utf8" ) ;
1383+ writeFileSync ( join ( originalHome , "plugin_cache.sqlite-shm" ) , "cache shm\n" , "utf8" ) ;
1384+
1385+ const result = runWrapper ( fixtureRoot , [ "exec" , "status" ] , {
1386+ CODEX_MULTI_AUTH_REAL_CODEX_BIN : fakeBin ,
1387+ CODEX_HOME : originalHome ,
1388+ CODEX_MULTI_AUTH_RUNTIME_ROTATION_PROXY : "1" ,
1389+ CODEX_MULTI_AUTH_TEST_PROXY_BASE_URL : "http://127.0.0.1:4567" ,
1390+ CODEX_MULTI_AUTH_TEST_PROXY_MARKER : markerPath ,
1391+ CODEX_MULTI_AUTH_TEST_FORCE_SHADOW_SQLITE_SIDECAR_LINK_FAILURE : "1" ,
1392+ CODEX_MULTI_AUTH_TEST_FORCE_SHADOW_SIDECAR_PLACEHOLDER_FAILURE : "1" ,
1393+ OPENAI_API_KEY : undefined ,
1394+ } ) ;
1395+
1396+ const output = combinedOutput ( result ) ;
1397+ expect ( result . status ) . toBe ( 0 ) ;
1398+ expect ( output ) . toContain ( "CACHE_SQLITE_MIRRORED:false" ) ;
1399+ expect ( output ) . toContain ( "CACHE_WAL_MIRRORED:false" ) ;
1400+ expect ( output ) . toContain ( "CACHE_SHM_MIRRORED:false" ) ;
1401+ expect ( output ) . toContain (
1402+ "codex-multi-auth: skipped SQLite shadow-home sidecar placeholder for" ,
1403+ ) ;
1404+ expect ( output ) . toContain ( "plugin_cache.sqlite-wal" ) ;
1405+ expect ( output ) . toContain ( "simulated SQLite sidecar placeholder failure" ) ;
1406+ } ) ;
1407+
1408+ it ( "removes sqlite materialization when a missing sidecar placeholder fails" , ( ) => {
1409+ const fixtureRoot = createWrapperFixture ( ) ;
1410+ createRuntimeRotationProxyFixtureModule ( fixtureRoot ) ;
1411+ const fakeBin = createCustomFakeCodexBin ( fixtureRoot , [
1412+ "#!/usr/bin/env node" ,
1413+ 'const fs = require("node:fs");' ,
1414+ 'const path = require("node:path");' ,
1415+ 'const cachePath = path.join(process.env.CODEX_HOME ?? "", "plugin_cache.sqlite");' ,
1416+ 'const cacheWalPath = path.join(process.env.CODEX_HOME ?? "", "plugin_cache.sqlite-wal");' ,
1417+ 'const cacheShmPath = path.join(process.env.CODEX_HOME ?? "", "plugin_cache.sqlite-shm");' ,
1418+ 'console.log(`CACHE_SQLITE_MIRRORED:${fs.existsSync(cachePath)}`);' ,
1419+ 'console.log(`CACHE_WAL_MIRRORED:${fs.existsSync(cacheWalPath)}`);' ,
1420+ 'console.log(`CACHE_SHM_MIRRORED:${fs.existsSync(cacheShmPath)}`);' ,
13751421 "process.exit(0);" ,
13761422 ] ) ;
13771423 const originalHome = join ( fixtureRoot , "codex-home" ) ;
@@ -1392,7 +1438,9 @@ describe("codex bin wrapper", () => {
13921438
13931439 const output = combinedOutput ( result ) ;
13941440 expect ( result . status ) . toBe ( 0 ) ;
1395- expect ( output ) . toContain ( "CACHE_SHM_PLACEHOLDER:false" ) ;
1441+ expect ( output ) . toContain ( "CACHE_SQLITE_MIRRORED:false" ) ;
1442+ expect ( output ) . toContain ( "CACHE_WAL_MIRRORED:false" ) ;
1443+ expect ( output ) . toContain ( "CACHE_SHM_MIRRORED:false" ) ;
13961444 expect ( output ) . toContain (
13971445 "codex-multi-auth: skipped SQLite shadow-home sidecar placeholder for" ,
13981446 ) ;
0 commit comments