mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
dae56994da
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.
29 lines
1.1 KiB
Rust
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<()>;
|
|
}
|