Files
codex/codex-rs/thread-store/src/recorder.rs
T
Tom dae56994da ThreadStore interface (#17659)
Introduce a ThreadStore interface for mediating access to the filesystem
(rollout jsonl files + sqlite db) based thread storage.

In later PRs we'll move the existing fs code behind a "local"
implementation of this ThreadStore interface.

This PR should be a no-op behaviorally, it only introduces the
interface.
2026-04-14 13:51:00 -07:00

29 lines
1.1 KiB
Rust

use async_trait::async_trait;
use codex_protocol::ThreadId;
use codex_protocol::protocol::RolloutItem;
use crate::ThreadStoreResult;
/// Live append handle for a thread.
///
/// This is the storage-neutral version of the existing rollout recorder API. The local
/// implementation is expected to wrap `codex_rollout::RolloutRecorder` and preserve its lazy
/// materialization, filtering, flush, and shutdown behavior.
#[async_trait]
pub trait ThreadRecorder: Send + Sync {
/// Returns the thread id this recorder appends to.
fn thread_id(&self) -> ThreadId;
/// Queues items for persistence according to this recorder's filtering policy.
async fn record_items(&self, items: &[RolloutItem]) -> ThreadStoreResult<()>;
/// Materializes the thread if persistence is lazy, then persists all queued items.
async fn persist(&self) -> ThreadStoreResult<()>;
/// Flushes all queued items and returns once they are durable/readable.
async fn flush(&self) -> ThreadStoreResult<()>;
/// Flushes pending items and closes the recorder.
async fn shutdown(&self) -> ThreadStoreResult<()>;
}