Add dedicated storage for paginated thread history (#32234)

## Why

Paginated thread history needs its own SQLite database to avoid adding lock
contention to the main state store.

## What changed

- Add the `thread_history_1.sqlite` path and migration scaffolding.
- Create tables and pagination indexes for projected turns and items, plus a
  per-thread projection checkpoint.
- Register the database with runtime diagnostics, Bazel inputs, and database
  telemetry.

GitOrigin-RevId: d194310835f1df2a2a29c7827d77ca37eabbd0a3
This commit is contained in:
Owen Lin authored and copyberry committed 2026-07-10 18:27:19 +00:00
1 parent 2da1b12822
commit 414217dc8a
7 files changed
+74 -7

No files matched your search

+7
View File
@@ -7,6 +7,7 @@ pub(crate) static STATE_MIGRATOR: Migrator = sqlx::migrate!("./migrations");
pub(crate) static LOGS_MIGRATOR: Migrator = sqlx::migrate!("./logs_migrations");
pub(crate) static GOALS_MIGRATOR: Migrator = sqlx::migrate!("./goals_migrations");
pub(crate) static MEMORIES_MIGRATOR: Migrator = sqlx::migrate!("./memory_migrations");
pub(crate) static THREAD_HISTORY_MIGRATOR: Migrator = sqlx::migrate!("./thread_history_migrations");
/// Allow an older Codex binary to open a database that has already been
/// migrated by a newer binary running in parallel.
@@ -41,6 +42,12 @@ pub(crate) fn runtime_memories_migrator() -> Migrator {
runtime_migrator(&MEMORIES_MIGRATOR)
}
// The paginated history projector will call this when it takes ownership of opening the database.
#[allow(dead_code)]
pub(crate) fn runtime_thread_history_migrator() -> Migrator {
runtime_migrator(&THREAD_HISTORY_MIGRATOR)
}
pub(crate) async fn repair_legacy_recency_migration_version(
pool: &SqlitePool,
migrator: &Migrator,