feat: dedicated goal DB (#23300)

## Why

Thread goals are moving toward extension-owned runtime behavior, but
their persisted state was still stored in the shared state database.
This makes the goal store harder to isolate and keeps future storage
splits tied to ad hoc runtime plumbing.

This PR gives goals their own SQLite database while keeping the existing
`StateRuntime` entry point. The goal is to make this the pattern for
adding more dedicated runtime databases later.

This also reduce load on existing DB and reduce contention

## Limitation
Thread preview from goal is not supported anymore. I'm looking into this
[EDIT]: solved

## What changed

- Added a dedicated `goals_1.sqlite` database with its own
`goals_migrations` directory.
- Moved `thread_goals` creation into the goals DB migration set.
- Dropped the old `thread_goals` table from the main state DB with a
normal state migration. There is intentionally no backfill for existing
goal rows.
- Changed `GoalStore` to be backed only by the goals DB pool.
- Removed the old goal-write side effect that filled empty
`threads.preview` values from the goal objective.
- Added shared runtime DB path metadata so startup, telemetry, `codex
doctor`, and repair handling can include future DBs without bespoke path
lists.
- Updated Bazel compile data so the new goals migration directory is
available to `sqlx::migrate!`.

## Verification

- `cargo check --tests -p codex-state -p codex-cli -p codex-core -p
codex-app-server`
- `just fix -p codex-state`
- `just fix -p codex-cli`
- `just fix -p codex-app-server`
This commit is contained in:
jif-oai authored and GitHub committed 2026-05-19 11:11:41 +02:00
1 parent 826b2182ed
commit ba57aab13a
18 files changed
+330 -116

No files matched your search

+4 -6
View File
@@ -1943,13 +1943,11 @@ async fn state_check(config: &Config) -> DoctorCheck {
path_readiness(&mut details, "CODEX_HOME", &config.codex_home);
path_readiness(&mut details, "log dir", &config.log_dir);
path_readiness(&mut details, "sqlite home", &config.sqlite_home);
let state_db = codex_state::state_db_path(&config.sqlite_home);
let log_db = codex_state::logs_db_path(&config.sqlite_home);
path_readiness(&mut details, "state DB", &state_db);
path_readiness(&mut details, "log DB", &log_db);
let mut integrity_failures = Vec::new();
sqlite_integrity_detail(&mut details, &mut integrity_failures, "state DB", &state_db).await;
sqlite_integrity_detail(&mut details, &mut integrity_failures, "log DB", &log_db).await;
for db in codex_state::runtime_db_paths(&config.sqlite_home) {
path_readiness(&mut details, db.label, &db.path);
sqlite_integrity_detail(&mut details, &mut integrity_failures, db.label, &db.path).await;
}
rollout_stats_details(&mut details, &config.codex_home);
standalone_release_cache_details(&mut details);