Skip to content

feat: dedicated goal DB#23300

Merged
jif-oai merged 6 commits into
mainfrom
jif/dedicated-goal-DB
May 19, 2026
Merged

feat: dedicated goal DB#23300
jif-oai merged 6 commits into
mainfrom
jif/dedicated-goal-DB

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai commented May 18, 2026

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

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd1bdda453

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/state/migrations/0034_drop_thread_goals.sql
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I manually built and ran locallly to ensure that there were no db migration issues.

I found a couple of small usability issues that would be good to fix:

init_state_db_for_app_server_target in the TUI should be updated. It currently attributes all db integrity failures to the state db, which will confuse uses if the problem is actually with the goal db.

Other comment inline related to doctor reporting.

Comment thread codex-rs/state/goals_migrations/0001_thread_goals.sql Outdated
Comment thread codex-rs/state/src/runtime/goals.rs
Comment thread codex-rs/cli/src/doctor.rs
@jif-oai jif-oai requested a review from a team as a code owner May 19, 2026 08:11
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 19, 2026

Windows failure is unrelated and due to flake in the GH workers

@jif-oai jif-oai merged commit ba57aab into main May 19, 2026
29 of 31 checks passed
@jif-oai jif-oai deleted the jif/dedicated-goal-DB branch May 19, 2026 09:11
@github-actions github-actions Bot locked and limited conversation to collaborators May 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants