Skip to main content

Transcript

Struct Transcript 

Source
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

Source

pub fn new(settings: TranscriptSettings) -> Self

A mirror with no history yet; the first request fills it.

Source

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).

Source

pub fn len(&self) -> usize

How many messages the log holds.

Source

pub fn is_empty(&self) -> bool

Whether the log is empty.

Source

pub fn message(&self, id: usize) -> Option<&Message>

Message id, as zoom(id, 1) reads it.

Source

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.

Source

pub fn stats(&self) -> TranscriptStats

The compaction’s benchmark snapshot.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn stage_usage_shares( &mut self, system: Option<&str>, tools: &[ToolSpec], messages: &[Message], )

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn render(&mut self) -> Option<Vec<Message>>

Builds the request view from the committed state. Called once per request, after any summarizer commits; updates the benchmark counters.

Trait Implementations§

Source§

impl Debug for Transcript

Source§

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

Formats the value using the given formatter. Read more

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<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, 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.