Make the ThreadStore contract coherent: append_items is now a raw canonical
history append, and update_thread_metadata is the single metadata write API.
ThreadStore implementations no longer infer metadata by inspecting appended
rollout items.
LiveThread now owns the live append flow. It applies the rollout persistence
policy before writing JSONL history, observes the canonical items with a small
ThreadMetadataSync helper, and sends the derived facts back through
update_thread_metadata. ThreadManager becomes the single app-facing metadata
entrypoint, routing loaded threads through LiveThread and cold threads directly
to the store.
LocalThreadStore preserves the local compatibility requirements inside the
local implementation. SQLite, when available, receives explicit metadata
updates. JSONL and name-index compatibility are still maintained for explicit
metadata mutations such as rename, memory-mode, and git changes, so old rollout
files and SQLite-less local storage remain readable.
RolloutRecorder is reduced to local JSONL writing for thread-store appends.
The shared rollout persistence policy remains in codex-rollout, but recorder no
longer owns live metadata synthesis. The added thread-store README captures the
new ownership boundaries for future remote and local implementations.
Migrate token usage replay, rollback responses, and detached review
setup (a special case of forking) to be served from ThreadStore reads
rather direct rollout files.
- replay restored token usage from already-loaded `RolloutItem` history
instead of reopening `Thread.path`
- rebuild rollback responses from loaded `ThreadStore` snapshots and
history
- start detached reviews from store-backed parent history and stored
review-thread metadata
- remove obsolete app-server rollout-summary helper code that became
dead after the store-backed migration
- preserve response/notification ordering for resume, fork, rollback,
and detached review flows
- add integration test coverage for the affected paths
- Route `thread/metadata/update` through
`ThreadStore::update_thread_metadata`.
- Add `LocalThreadStore` git metadata patch support for set, partial
update, and clear semantics.
- Add some unit tests for the new thread store code
- Remove a lot of dead code/tests!
Begin migrating the thread write codepaths to ThreadStore.
This starts using ThreadStore inside of core session code, not only in
the app server code.
Rework the interfaces around thread recording/persistence. We're left
with the following:
* `ThreadManager`: owns the process-level registry of loaded threads and
handles cross-thread orchestration: start, resume, fork, lookup, remove,
and route ops to running CodexThreads.
* `CodexThread`: represents one loaded/running thread from the outside.
It is the handle app-server and callers use to submit ops, inspect
session metadata, and shut the thread down.
* `LiveThread`: session-owned persistence lifecycle handle for one
active thread. Core session code uses it to append rollout items,
materialize lazy persistence, flush, shutdown, discard init-failed
writers, and load that thread’s persisted history.
* `ThreadStore`: storage backend abstraction. It answers “how are
threads persisted, read, listed, updated, archived?” Local and remote
implementations live behind this trait.
* `LocalThreadStore`: local ThreadStore implementation. It owns the
file/sqlite-specific details and keeps RolloutRecorder as a local
implementation detail.
This is a few too many Thread abstractions for my liking, but they do
all represent different concepts / needs / layers.
Migration note: in places where the core code explicitly requires a
path, rather than a thread ID, throw an error if we're running with a
remote store.
Cover the new local live-writer lifecycle with focused tests and
preserve app-server thread-start behavior, including ephemeral pathless
sessions.