mirror of
https://github.com/openai/codex.git
synced 2026-05-28 15:00:16 +00:00
## 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`.
36 lines
989 B
SQL
36 lines
989 B
SQL
CREATE TABLE stage1_outputs (
|
|
thread_id TEXT PRIMARY KEY,
|
|
source_updated_at INTEGER NOT NULL,
|
|
raw_memory TEXT NOT NULL,
|
|
rollout_summary TEXT NOT NULL,
|
|
rollout_slug TEXT,
|
|
generated_at INTEGER NOT NULL,
|
|
usage_count INTEGER,
|
|
last_usage INTEGER,
|
|
selected_for_phase2 INTEGER NOT NULL DEFAULT 0,
|
|
selected_for_phase2_source_updated_at INTEGER
|
|
);
|
|
|
|
CREATE INDEX idx_stage1_outputs_source_updated_at
|
|
ON stage1_outputs(source_updated_at DESC, thread_id DESC);
|
|
|
|
CREATE TABLE jobs (
|
|
kind TEXT NOT NULL,
|
|
job_key TEXT NOT NULL,
|
|
status TEXT NOT NULL,
|
|
worker_id TEXT,
|
|
ownership_token TEXT,
|
|
started_at INTEGER,
|
|
finished_at INTEGER,
|
|
lease_until INTEGER,
|
|
retry_at INTEGER,
|
|
retry_remaining INTEGER NOT NULL,
|
|
last_error TEXT,
|
|
input_watermark INTEGER,
|
|
last_success_watermark INTEGER,
|
|
PRIMARY KEY (kind, job_key)
|
|
);
|
|
|
|
CREATE INDEX idx_jobs_kind_status_retry_lease
|
|
ON jobs(kind, status, retry_at, lease_until);
|