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

+10 -9
View File
@@ -1,10 +1,11 @@
use codex_state::SqliteConfig;
use std::path::Path;
use std::path::PathBuf;
use std::sync::Arc;
pub trait RolloutConfigView {
fn codex_home(&self) -> &Path;
fn sqlite_home(&self) -> &Path;
fn sqlite_config(&self) -> &SqliteConfig;
fn cwd(&self) -> &Path;
fn model_provider_id(&self) -> &str;
fn generate_memories(&self) -> bool;
@@ -13,7 +14,7 @@ pub trait RolloutConfigView {
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct RolloutConfig {
pub codex_home: PathBuf,
pub sqlite_home: PathBuf,
pub sqlite: SqliteConfig,
pub cwd: PathBuf,
pub model_provider_id: String,
pub generate_memories: bool,
@@ -25,7 +26,7 @@ impl RolloutConfig {
pub fn from_view(view: &impl RolloutConfigView) -> Self {
Self {
codex_home: view.codex_home().to_path_buf(),
sqlite_home: view.sqlite_home().to_path_buf(),
sqlite: view.sqlite_config().clone(),
cwd: view.cwd().to_path_buf(),
model_provider_id: view.model_provider_id().to_string(),
generate_memories: view.generate_memories(),
@@ -38,8 +39,8 @@ impl RolloutConfigView for RolloutConfig {
self.codex_home.as_path()
}
fn sqlite_home(&self) -> &Path {
self.sqlite_home.as_path()
fn sqlite_config(&self) -> &SqliteConfig {
&self.sqlite
}
fn cwd(&self) -> &Path {
@@ -60,8 +61,8 @@ impl<T: RolloutConfigView + ?Sized> RolloutConfigView for &T {
(*self).codex_home()
}
fn sqlite_home(&self) -> &Path {
(*self).sqlite_home()
fn sqlite_config(&self) -> &SqliteConfig {
(*self).sqlite_config()
}
fn cwd(&self) -> &Path {
@@ -82,8 +83,8 @@ impl<T: RolloutConfigView + ?Sized> RolloutConfigView for Arc<T> {
self.as_ref().codex_home()
}
fn sqlite_home(&self) -> &Path {
self.as_ref().sqlite_home()
fn sqlite_config(&self) -> &SqliteConfig {
self.as_ref().sqlite_config()
}
fn cwd(&self) -> &Path {