Skip to main content

SidecarWriter

Struct SidecarWriter 

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

Append-only writer for a native-v2 sidecar file (A2 store layout; A3 live persistence): the durable, full-fidelity home for a live agent conversation. Every append is line-atomic — full line + \n, then flushed — so a crash mid-write can only ever leave the next unwritten record torn, never corrupt one already on disk; Session::from_native_str tolerates a torn trailing line exactly as the per-source loaders already tolerate corrupt lines.

Implementations§

Source§

impl SidecarWriter

Source

pub fn create(path: &Path, session: &Session) -> Result<Self>

Create a new sidecar file at path for session (the just-imported session about to be recorded): writes the v2 header plus every session.raw line verbatim, via Session::to_native_jsonl_v2 with an empty appended slice — reusing that header+body construction rather than duplicating it, since the imported prefix already has its own raw lines and no turns have been appended yet. Overwrites whatever was previously at path.

Source

pub fn create_with_timestamp( path: &Path, session: &Session, timestamp: impl Into<String>, ) -> Result<Self>

Create the same production sidecar writer with a fixed RFC3339 framing timestamp. This isolates time as the sole nondeterministic field when byte-comparing two independently driven runtime surfaces; message content, ordering, metadata, flushing, and persistence all use the normal writer path. Ordinary callers should use Self::create.

Source

pub fn open_append(path: &Path) -> Result<Self>

Open an already-existing sidecar file at path for appending (resuming a session that was already being recorded).

Source

pub fn path(&self) -> &Path

The file this writer appends to. TR-1’s rehydration intrinsics use this to reload the recorded full-fidelity messages when resolving an expand_reduction/sidecar_search call — the recorded copy is the only place a cap_tool_output-capped tool result’s full bytes still exist (Agent::run_loop records the full output BEFORE capping).

Source

pub fn append(&mut self, msg: &ChatMessage) -> Result<()>

Append one ChatMessage as a NativeTurn record: full line + \n, then flushed immediately (line-atomic — see the struct docs).

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more