mirror of
https://github.com/openai/codex.git
synced 2026-04-27 16:15:09 +00:00
feat: add phase 1 mem db (#10634)
- Schema: thread_id (PK, FK to threads.id with cascade delete),
trace_summary, memory_summary, updated_at.
- Migration: creates the table and an index on (updated_at DESC,
thread_id DESC) for efficient recent-first reads.
- Runtime API (DB-only):
- `get_thread_memory(thread_id)`: fetch one memory row.
- `upsert_thread_memory(thread_id, trace_summary, memory_summary)`:
insert/update by thread id and always advance updated_at.
- `get_last_n_thread_memories_for_cwd(cwd, n)`: join thread_memory with
threads and return newest n rows for an exact cwd match.
- Model layer: introduced ThreadMemory and row conversion types to keep
query decoding typed and consistent with existing state models.
This commit is contained in:
9
codex-rs/state/migrations/0006_thread_memory.sql
Normal file
9
codex-rs/state/migrations/0006_thread_memory.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE thread_memory (
|
||||
thread_id TEXT PRIMARY KEY,
|
||||
trace_summary TEXT NOT NULL,
|
||||
memory_summary TEXT NOT NULL,
|
||||
updated_at INTEGER NOT NULL,
|
||||
FOREIGN KEY(thread_id) REFERENCES threads(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX idx_thread_memory_updated_at ON thread_memory(updated_at DESC, thread_id DESC);
|
||||
Reference in New Issue
Block a user