pub struct Transcript { /* private fields */ }Expand description
The mirror: the log as the last request carried it, the stepped compaction state over it, and the benchmark counters. Shared between the decorator (which refreshes it) and the zoom tool (which reads the log).
Implementations§
Source§impl Transcript
impl Transcript
Sourcepub fn new(settings: TranscriptSettings) -> Self
pub fn new(settings: TranscriptSettings) -> Self
A mirror with no history yet; the first request fills it.
Sourcepub fn observe(&mut self, messages: &[Message])
pub fn observe(&mut self, messages: &[Message])
Folds a request’s messages into the log: an extension of what is already here extends it; anything else — a fresh session, a resume — replaces it, and the compaction state rebuilds from nothing (the first request re-derives it; nothing derived is ever persisted).
Sourcepub fn range(&self, range: Range) -> Option<&[Message]>
pub fn range(&self, range: Range) -> Option<&[Message]>
The messages of range, as zoom reads them; None past the
log’s end. The range arrives from the model’s tool call, so
the arithmetic is checked: a huge n is a malformed call
answered with nothing, not a panic.
Sourcepub fn stats(&self) -> TranscriptStats
pub fn stats(&self) -> TranscriptStats
The compaction’s benchmark snapshot.
Sourcepub fn carry(&mut self, saved: &TranscriptStats)
pub fn carry(&mut self, saved: &TranscriptStats)
Folds a saved session’s benchmark counters in: a resumed
session’s stats keep reading as one run. See
TranscriptStats::carry for what sums and what does not.
Sourcepub fn saved_sections(&self) -> Vec<Section>
pub fn saved_sections(&self) -> Vec<Section>
The committed sections, oldest first: what a session save carries so the next session skips the re-fill.
Sourcepub fn adopt_sections(&mut self, sections: Vec<Section>)
pub fn adopt_sections(&mut self, sections: Vec<Section>)
Hands a previous session’s sections over. They are not adopted
on the spot: the resumed log is unknown until the first
request, and Transcript::observe validates them against it.
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Zeroes the benchmark counters; the log and the compaction state stay — the next request rebuilds both anyway. A conversation cleared mid-agent starts its accounting over.
Sourcepub fn set_skills_bytes(&mut self, bytes: usize)
pub fn set_skills_bytes(&mut self, bytes: usize)
Sets the skills section’s byte share of the system prompt —
measured by the agent that rendered it, since the section’s
shape is the template’s to decide. Zero (the default) folds the
whole system prompt into system_prompt_tokens.
Sourcepub fn set_skills(&mut self, skills: Vec<SkillText>)
pub fn set_skills(&mut self, skills: Vec<SkillText>)
Sets the skills whose bodies pin whole into the block. A tool result carrying one becomes its own verbatim section at flush time instead of a digest; a re-read becomes a pointer to the section already carrying the body. Safe to call at any point — setting re-detects over the whole log — and normally called once at wiring, from the same discovery the prompt rendered.
Stages the byte shares of the request about to go out: what the
next Transcript::record_usage spreads the reported input
tokens over. The decorator calls it after the view is applied,
so the shares read what is actually sent.
Sourcepub fn record_usage(&mut self, usage: &Usage)
pub fn record_usage(&mut self, usage: &Usage)
Records one provider response’s usage: the ground truth the cache-hit rate reports from. The decorator calls this once per forwarded request; the reported input tokens spread over the staged shares by byte proportion.
Sourcepub fn record_worker_call(&mut self, outcome: WorkerOutcome)
pub fn record_worker_call(&mut self, outcome: WorkerOutcome)
Records one summarizer call the decorator issued outside the
mirror’s lock; a WorkerOutcome::Failed counts it against the
worker.
Sourcepub fn commit_summary(&mut self, pending: &PendingSummary, text: String) -> bool
pub fn commit_summary(&mut self, pending: &PendingSummary, text: String) -> bool
Commits an upgraded section text from a PendingSummary a
worker task filled outside the request. false when the section no
longer matches — a concurrent plan rebuilt it — and the text is
dropped: every intermediate state stays a valid view.
Sourcepub fn plan_flush(&mut self) -> Vec<PendingSummary>
pub fn plan_flush(&mut self) -> Vec<PendingSummary>
The flush planner: decides whether the budget is breached, and
if so moves the cut and commits the new sections — extractive
stand-ins first — returning the summaries a Summarizer
should upgrade. Between flushes this touches nothing: the block
is append-only by construction.
Called under the mirror’s lock with observe already applied;
never blocks and never calls a model.
Sourcepub fn view(&mut self, messages: &[Message]) -> Option<Vec<Message>>
pub fn view(&mut self, messages: &[Message]) -> Option<Vec<Message>>
The view of the log: None passes it through unchanged — below
the budget, or nothing sectioned yet. Past it, the block
followed by the whole band from the cut.
The one-stop form for callers without a summarizer:
Transcript::plan_flush plus this, with the extractive
stand-ins final. The decorator plans and renders under the
lock and hands the fill a background task.