Skip to content

Move memory state to a dedicated SQLite DB#24591

Merged
jif-oai merged 8 commits into
mainfrom
jif/dedicated-memories-db
May 26, 2026
Merged

Move memory state to a dedicated SQLite DB#24591
jif-oai merged 8 commits into
mainfrom
jif/dedicated-memories-db

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

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

Summary

Generated memory rows and their stage-one/stage-two job state currently live in state_5.sqlite alongside thread metadata. That makes memory cleanup and regeneration share the main state schema even though those rows are memory-pipeline data and can be rebuilt independently from the durable thread records.

This PR moves the memory-owned tables into a dedicated memories_1.sqlite runtime database while keeping thread metadata in state_5.sqlite.

Changes

  • Adds a separate memories DB runtime, migrator, path helpers, telemetry kind, and Bazel compile data for state/memory_migrations.
  • Introduces MemoryStore behind StateRuntime::memories() and moves memory table/job operations onto that store.
  • Drops the old memory tables from the state DB and recreates their schema in state/memory_migrations/0001_memories.sql.
  • Updates memory startup, citation usage tracking, rollout pollution handling, debug clear-memories, and app-server memory/reset to operate through the memories DB.
  • Preserves cross-DB behavior by hydrating thread metadata from the state DB when selecting visible memory outputs and checking stage-one staleness.

Verification

  • Added/updated codex-state tests for deleted-thread memory visibility and already-polluted phase-two enqueue behavior.
  • Updated debug clear-memories, app-server memory/reset, and memories startup tests to seed and assert memory rows through memories_1.sqlite.

@jif-oai jif-oai requested a review from a team as a code owner May 26, 2026 13:53
@jif-oai jif-oai changed the title feat: dedicated memories DB Move memory state to a dedicated SQLite DB May 26, 2026
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 26, 2026

@codex review

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: 4912f62b0d

ℹ️ 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/0035_drop_memory_tables.sql
Comment thread codex-rs/state/migrations/0035_drop_memory_tables.sql
Comment thread codex-rs/state/src/runtime/memories.rs
Comment thread codex-rs/cli/src/main.rs Outdated
Comment thread codex-rs/state/src/runtime/memories.rs
Comment thread codex-rs/state/src/runtime/memories.rs
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 26, 2026

@codex review

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: c415545cee

ℹ️ 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/0035_drop_memory_tables.sql
Comment thread codex-rs/state/src/runtime.rs
Copy link
Copy Markdown
Contributor

@fcoury-oai fcoury-oai left a comment

Choose a reason for hiding this comment

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

Performed some basic smoke test and it worked as expected. Left one nit and one question, but none are blockers.

Approved 👍

Comment thread codex-rs/state/src/runtime.rs
Comment thread codex-rs/state/src/runtime/memories.rs
@jif-oai jif-oai enabled auto-merge (squash) May 26, 2026 17:39
@jif-oai jif-oai disabled auto-merge May 26, 2026 18:07
@jif-oai jif-oai merged commit aad59a0 into main May 26, 2026
31 checks passed
@jif-oai jif-oai deleted the jif/dedicated-memories-db branch May 26, 2026 18:07
@github-actions github-actions Bot locked and limited conversation to collaborators May 26, 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