mirror of
https://github.com/openai/codex.git
synced 2026-06-03 03:41:58 +00:00
## Why Local rollout compression needs a cold `.jsonl.zst` representation without letting compressed physical paths leak into append-mode writers. The unsafe case is resume or metadata update code successfully reading a compressed rollout and then appending raw JSONL bytes to the zstd file. This PR folds the former #25088 materialization slice into the read-support PR so the reader changes and append-safety invariant land together. ## What Changed - Teach rollout readers, discovery, listing, search, and ID lookup to understand compressed `.jsonl.zst` rollouts. - Keep `.jsonl` as the logical/stored rollout path while allowing read paths to open either plain or compressed storage. - Materialize compressed rollouts back to plain `.jsonl` before append-mode writes, including resume and direct metadata append paths. - Preserve compressed-file permissions when materializing back to plain JSONL. - Refresh thread-store resolved rollout paths after compatibility metadata writes so reconciliation follows the materialized file. - Avoid treating transient compression temp files as real rollout lookup results. ## Remaining Stack #25089 remains the separate worker PR. It is based directly on this PR and stays behind the disabled `local_thread_store_compression` feature flag. The worker still has a broader coordination question: a resume or metadata update can race with background compression while a plain file is being replaced by `.jsonl.zst`. This PR handles the read and materialize-before-append primitives; it does not make the worker production-ready. ## Validation - `just test -p codex-rollout` - `just test -p codex-thread-store` - `just fix -p codex-rollout` - `just fix -p codex-thread-store` - `just bazel-lock-check`
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 canonical history append API. It does not infer metadata from item contents.ThreadStore::update_thread_metadatais the only thread metadata write API. It accepts a single literal metadata patch shape, regardless of whether the caller is applying a user/API mutation or facts derived above the store from appended history.LiveThreadis the preferred API for active session persistence. It owns a per-thread metadata sync helper, applies the rollout persistence policy, appends canonical history, and then sends metadata patches throughThreadStore::update_thread_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 persists queryable metadata through the 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; it no longer decides metadata updates for live thread-store appends.core/sessioncreates or resumesLiveThreadhandles and does not need to know whether persistence is backed by local files or another store.
Direction
New metadata observation semantics should live above ThreadStore. Stores
persist explicit metadata fields, but raw history appends remain history-only.