Skip to main content

Store

Struct Store 

Source
pub struct Store { /* private fields */ }
Expand description

An append-only store of metadata-only batches, namespaced by agent/session. Each hook writes its own batch then renames it atomically. Concurrent hooks cannot overwrite each other, and readers never see a partially written batch.

Implementations§

Source§

impl Store

Source

pub fn retained_from(&self, session: &SessionKey) -> Result<Option<i64>>

Fixed lower timestamp bound chosen by explicit retention. This also prevents a resumed session from reimporting expired transcript events.

Source

pub fn maintain( &self, session: &SessionKey, before: Option<i64>, apply: bool, ) -> Result<MaintenanceReport>

Pack history into fewer files, optionally retaining only timestamps at or after before. Preview is read-only apart from the advisory lock. Refuses damaged history. Never reconciles or discards raw observations unless an explicit retention cutoff is supplied.

Source§

impl Store

Source

pub fn new(root: impl Into<PathBuf>) -> Self

Examples found in repository?
examples/inspect.rs (line 18)
7fn main() -> Result<()> {
8    let mut args = std::env::args_os().skip(1);
9    let root = PathBuf::from(args.next().context("usage: inspect STORE_ROOT claude|codex SESSION_ID")?);
10    let agent = match args.next().and_then(|s| s.into_string().ok()).as_deref() {
11        Some("claude") => Agent::Claude,
12        Some("codex") => Agent::Codex,
13        _ => bail!("agent must be claude or codex"),
14    };
15    let session_id =
16        args.next().context("missing session ID")?.into_string().map_err(|_| anyhow::anyhow!("invalid session ID"))?;
17    anyhow::ensure!(args.next().is_none(), "unexpected argument");
18    let report = Store::new(root).read(&SessionKey { agent, session_id })?;
19    for warning in report.warnings {
20        eprintln!("{}: {}", warning.path.display(), warning.message);
21    }
22    println!("{}", serde_json::to_string_pretty(&files(report.events))?);
23    Ok(())
24}
Source

pub fn sessions(&self) -> SessionReport

Enumerate retained session directories, including ended/compacted sessions. Does not create state or follow namespace/session directory symlinks.

Source

pub fn read_all(&self) -> ReadReport

Read retained history across agents/sessions. Per-session failures become warnings so one damaged checkpoint cannot hide other sessions. This is not a globally atomic snapshot; each session is read under its own lock.

Source

pub fn append(&self, session: &SessionKey, events: &[FileEvent]) -> Result<()>

Source

pub fn events(&self, session: &SessionKey) -> Result<Vec<FileEvent>>

Strict reads remain available for callers that require complete history.

Source

pub fn read(&self, session: &SessionKey) -> Result<ReadReport>

Read every valid batch and report damaged/unreadable batches separately. Bad batches are left untouched for inspection and recovery.

Examples found in repository?
examples/inspect.rs (line 18)
7fn main() -> Result<()> {
8    let mut args = std::env::args_os().skip(1);
9    let root = PathBuf::from(args.next().context("usage: inspect STORE_ROOT claude|codex SESSION_ID")?);
10    let agent = match args.next().and_then(|s| s.into_string().ok()).as_deref() {
11        Some("claude") => Agent::Claude,
12        Some("codex") => Agent::Codex,
13        _ => bail!("agent must be claude or codex"),
14    };
15    let session_id =
16        args.next().context("missing session ID")?.into_string().map_err(|_| anyhow::anyhow!("invalid session ID"))?;
17    anyhow::ensure!(args.next().is_none(), "unexpected argument");
18    let report = Store::new(root).read(&SessionKey { agent, session_id })?;
19    for warning in report.warnings {
20        eprintln!("{}: {}", warning.path.display(), warning.message);
21    }
22    println!("{}", serde_json::to_string_pretty(&files(report.events))?);
23    Ok(())
24}

Trait Implementations§

Source§

impl Clone for Store

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Store

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Store

§

impl RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

§

impl UnwindSafe for Store

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.