Skip to content

Commit ea28950

Browse files
committed
fix(codex): preserve residue classification boundary
1 parent 5c15c37 commit ea28950

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎src/codex/native-residue.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,20 @@ export function classifyNativeRoutedResidue(): NativeRoutedResidueResult {
640640
return indeterminate("partial-write", unresolved, `CODEX_HOME cannot be resolved: ${errorReason(error)}`);
641641
}
642642

643-
const stateDatabasePath = resolveCodexStateDbPath({ codexHome });
644643
const configPath = join(codexHome, CONFIG_FILE_NAME);
644+
let stateDatabasePath: string;
645+
try {
646+
stateDatabasePath = resolveCodexStateDbPath({ codexHome });
647+
} catch (error) {
648+
// Residue classification is a total, read-only safety boundary. An
649+
// indeterminate SQLite authority must refuse coordination without escaping
650+
// as an exception or falling through to a different state database.
651+
return indeterminate(
652+
"config",
653+
configPath,
654+
`SQLite home cannot be resolved: ${errorReason(error)}`,
655+
);
656+
}
645657
const profilePath = join(codexHome, PROFILE_FILE_NAME);
646658
const modelsCachePath = join(codexHome, MODELS_CACHE_FILE_NAME);
647659
const journalPath = join(codexHome, JOURNAL_FILE_NAME);

‎tests/codex-native-residue.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,16 @@ test("duplicate configured catalog paths are indeterminate", () => {
546546
});
547547
});
548548

549+
test("an invalid sqlite_home is indeterminate instead of selecting a fallback database", () => {
550+
writeFileSync(pathInCodexHome("config.toml"), "sqlite_home = 123\n");
551+
552+
expect(classifyNativeRoutedResidue()).toMatchObject({
553+
kind: "indeterminate",
554+
surface: "config",
555+
path: canonicalPathInCodexHome("config.toml"),
556+
});
557+
});
558+
549559
const arbitraryComboAlias = randomUUID();
550560

551561
test(`production-generated arbitrary bare combo alias ${arbitraryComboAlias} is routed residue`, async () => {

0 commit comments

Comments
 (0)