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

+8 -4
View File
@@ -669,10 +669,14 @@ fn terminal_summary(check: &DoctorCheck) -> String {
}
fn state_summary(check: &DoctorCheck) -> String {
let state_ok =
detail::detail_value(check, "state DB integrity").is_some_and(|value| value == "ok");
let log_ok = detail::detail_value(check, "log DB integrity").is_some_and(|value| value == "ok");
if state_ok && log_ok {
let databases_ok = [
"state DB integrity",
"log DB integrity",
"goals DB integrity",
]
.into_iter()
.all(|label| detail::detail_value(check, label).is_some_and(|value| value == "ok"));
if check.status == CheckStatus::Ok && databases_ok {
"databases healthy".to_string()
} else {
check.summary.clone()
+3
View File
@@ -294,6 +294,7 @@ fn state_details(parsed: &[ParsedDetail]) -> Vec<HumanDetail> {
push_row_if_present(&mut out, parsed, "sqlite home", "sqlite home");
push_database_row(&mut out, parsed, "state DB");
push_database_row(&mut out, parsed, "log DB");
push_database_row(&mut out, parsed, "goals DB");
for (source, label) in [
("active rollout files", "active rollouts"),
@@ -317,8 +318,10 @@ fn state_details(parsed: &[ParsedDetail]) -> Vec<HumanDetail> {
"sqlite home",
"state DB",
"log DB",
"goals DB",
"state DB integrity",
"log DB integrity",
"goals DB integrity",
"active rollout files",
"archived rollout files",
],