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
impl SidecarWriter
Sourcepub fn create(path: &Path, session: &Session) -> Result<Self>
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.
Sourcepub fn create_with_timestamp(
path: &Path,
session: &Session,
timestamp: impl Into<String>,
) -> Result<Self>
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.
Sourcepub fn open_append(path: &Path) -> Result<Self>
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).
Sourcepub fn path(&self) -> &Path
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).
Sourcepub fn append(&mut self, msg: &ChatMessage) -> Result<()>
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).