Honor the configured SQLite home across state consumers (#34994)

## Why

Codex and SQLite data can use separate home directories, but state consumers
could reconstruct database paths from the Codex home instead of consistently
using the resolved SQLite configuration.

## What changed

- Pass `SqliteConfig` through the core, rollout, state runtime, and thread store
  instead of passing a directory and rebuilding the configuration downstream.
- Use that shared configuration for state, logs, memories, goals, and paginated
  thread-history database access, including integrity checks and cleanup.
- Reject state database handles whose SQLite configuration does not match the
  requesting store.

## Testing

Add coverage with separate Codex and SQLite homes that verifies startup
backfill, thread listing, and paginated history all use the configured SQLite
directory.

GitOrigin-RevId: 1de1cdd1d6ff1d70bbb6c360c8352e6543fb8ebf
This commit is contained in:
Adam Perry @ OpenAI authored and copyberry committed 2026-07-23 19:19:35 +00:00
1 parent 74e9d7efc4
commit c769a05340
76 files changed
+1383 -702

No files matched your search

+7 -5
View File
@@ -437,6 +437,7 @@ impl RolloutRecorder {
search_term: Option<&str>,
) -> std::io::Result<ThreadsPage> {
let codex_home = config.codex_home();
let sqlite = config.sqlite_config();
let archived = match archive_filter {
ThreadListArchiveFilter::Active => false,
ThreadListArchiveFilter::Archived => true,
@@ -448,7 +449,7 @@ impl RolloutRecorder {
if matches!(repair_mode, ThreadListRepairMode::StateDbOnly) {
return Ok(state_db::list_threads_db(
state_db_ctx.as_deref(),
codex_home,
sqlite,
page_size,
cursor,
sort_key,
@@ -558,7 +559,7 @@ impl RolloutRecorder {
let db_page = state_db::list_threads_db(
state_db_ctx.as_deref(),
codex_home,
sqlite,
page_size,
cursor,
sort_key,
@@ -588,7 +589,7 @@ impl RolloutRecorder {
}
if let Some(repaired_db_page) = state_db::list_threads_db(
state_db_ctx.as_deref(),
codex_home,
sqlite,
page_size,
cursor,
sort_key,
@@ -629,7 +630,7 @@ impl RolloutRecorder {
if sort_key == ThreadSortKey::RecencyAt {
if let Some(repaired_db_page) = state_db::list_threads_db(
state_db_ctx.as_deref(),
codex_home,
sqlite,
page_size,
cursor,
sort_key,
@@ -701,6 +702,7 @@ impl RolloutRecorder {
filter_cwd: Option<&Path>,
) -> std::io::Result<Option<PathBuf>> {
let codex_home = config.codex_home();
let sqlite = config.sqlite_config();
let cwd_filter = filter_cwd.map(Path::to_path_buf);
let mut fallback_reason = state_db_ctx.is_none().then_some("db_unavailable");
if state_db_ctx.is_some() {
@@ -708,7 +710,7 @@ impl RolloutRecorder {
loop {
let Some(db_page) = state_db::list_threads_db(
state_db_ctx.as_deref(),
codex_home,
sqlite,
page_size,
db_cursor.as_ref(),
sort_key,