mirror of
https://github.com/openai/codex.git
synced 2026-09-06 15:29:32 +00:00
Thread Store
codex-thread-store is the storage boundary for Codex threads. It defines the
ThreadStore trait plus local and in-memory implementations. Other storage
implementations may live outside this repository.
Responsibilities
ThreadStore::append_itemsis the raw history append API. Implementations apply the rollout persistence policy and may derive implementation-owned metadata from canonical items.ThreadStore::update_thread_metadataapplies literal metadata patches for explicit user or API mutations.LiveThreadis the preferred API for active session persistence. It forwards history and explicit metadata operations without deriving storage metadata.ThreadManagerroutes metadata mutations for loaded and cold threads through one entrypoint. Loaded threads use theirLiveThread; cold threads go directly to the store.LocalThreadStorepersists history throughcodex-rolloutJSONL files and derives the queryable metadata needed by its SQLite state database when available. Local explicit metadata mutations also maintain JSONL/name-index compatibility so reading old or SQLite-less local storage keeps working.RolloutRecorderis the local JSONL writer. It writes already-canonical items forThreadStore::append_items; the local store owns metadata updates around that writer.core/sessioncreates or resumesLiveThreadhandles and does not need to know whether persistence is backed by local files or another store.
Direction
Each store owns any metadata it derives from appended history. Callers use
update_thread_metadata only for explicit metadata mutations.