Skip to main content

Module turn_record

Module turn_record 

Source
Expand description

BP-7 (catalog §4a “Turn/step bracketing records”, “Interrupt/abort with state preserved”, “Auto-retry on transient provider errors”): the persisted per-round-trip marker log — cc’s turn_duration/api_retry system records and cx’s turn_context/turn_aborted/responses_retry rows, in one typed shape.

Where it lands. <session>.events.jsonl, the sidecar-family member crate::store::SessionStore has always reserved and swept (archive/delete) but never had a writer for. So this is not a new store: it is the log that slot was cut for, filled in — beside the transcript, the reduction log, the usage log and the git-metadata record, exactly like every other family member (§1.13’s “typed session data, never a lossy display-only channel”).

Relationship to the usage log. crate::usage_log::UsageRecord is the ACCOUNTING projection: one row per round-trip, aggregatable by a cost dashboard. This is the BRACKETING projection: what the request was built over (Context), what it cost (Usage), how the round-trip ended (Finish), and the two things that happen between round-trips (Retry, Aborted). They are written from the same points in Agent::run_loop and never disagree; keeping them separate keeps a usage-log reader from having to skip four record kinds it does not care about.

Structs§

TurnRecord
One marker with the per-round-trip context every marker shares.

Enums§

FinishReason
Why a model round-trip (or a whole send loop) ended.
TurnMarker
One bracketing marker. The marker tag is the record’s kind.

Functions§

from_jsonl
Parse a JSONL marker log back into records — the exact inverse of to_jsonl. Blank lines are skipped; a malformed line is a hard error (this is an audit log, so a corrupt record should be visible, never silently dropped — same posture as crate::usage_log::from_jsonl).
to_jsonl
Serialize records as JSONL — the same shape every other append-log in this crate uses.