pub struct Turn<'h, S> { /* private fields */ }Expand description
The typestate carrier. Phase data lives in S and is private to this
module: a phase literal cannot be forged, a phase cannot be skipped,
and no method returns an earlier phase. Everything the turn writes
goes through journal, which is the module’s only ledger door.
Implementations§
Source§impl<'h> Turn<'h, ToolWave>
impl<'h> Turn<'h, ToolWave>
Sourcepub fn execute_concurrent(
self,
interrupt: Interrupt,
ledger: &mut dyn Ledger,
tools: &mut dyn ConcurrentInvoke,
still_going: &mut dyn FnMut(u32) -> Interrupt,
) -> Result<PhaseOutcome<Turn<'h, Recording>>, AxError>
pub fn execute_concurrent( self, interrupt: Interrupt, ledger: &mut dyn Ledger, tools: &mut dyn ConcurrentInvoke, still_going: &mut dyn FnMut(u32) -> Interrupt, ) -> Result<PhaseOutcome<Turn<'h, Recording>>, AxError>
Boundary 3 (before tool execution), accounted in call order, with
the leading read-only calls run at once (see ConcurrentInvoke).
A tool Err is not a turn Err — it lands in tool_result and goes
back to the model (the model is the recovery subject).
Both tool events reach the ledger through append_redacted: a
tool’s arguments and its result are the two payloads most likely
to quote a credential the work just read.
still_going is asked before every call, with that call’s index.
One question per wave left a halted scope running whatever the
model asked for in one reply: eight edits are eight effects, and
the person who stopped the city waited for all of them. What it
answers is consumed through the one boundary consumer, so a steer
between two calls is recorded here, before the next assembly
hands it to the model. For the leading reads it is asked for every
call before any starts, in call order, and a cancel starts only
the calls a serial wave would have made before it. Each answer is
consumed just before its call is accounted, so a steer lands on
the ledger where a serial wave writes it.
Source§impl<'h> Turn<'h, Assembling>
impl<'h> Turn<'h, Assembling>
Sourcepub fn begin(
lines: &'h mut HeldLines,
t: TimeMs,
now: &'h mut dyn FnMut() -> Result<TimeMs, AxError>,
) -> Turn<'h, Assembling>
pub fn begin( lines: &'h mut HeldLines, t: TimeMs, now: &'h mut dyn FnMut() -> Result<TimeMs, AxError>, ) -> Turn<'h, Assembling>
Opens a turn on the run’s lines. t is the turn’s stamp, which
every line of this turn carries but the four it waited for; the
executor advances it between turns (determinism rule 2). now is
read for those four moments only, on this thread, and never by a
tool. Lines an earlier turn held are still held, and go down at
this turn’s first barrier ahead of its own (runtime D36).
Sourcepub fn timed(
self,
monotonic_us: &'h mut dyn FnMut() -> u64,
) -> Turn<'h, Assembling>
pub fn timed( self, monotonic_us: &'h mut dyn FnMut() -> u64, ) -> Turn<'h, Assembling>
Records how long this turn’s model call and tool calls took, in
microseconds read off monotonic_us (kernel D20). A turn opened
without it records the moments and no durations.
Sourcepub fn assemble<'c>(
self,
interrupt: Interrupt,
ledger: &mut dyn Ledger,
prompt: RunPrompt<'_>,
conversation: &'c Conversation,
tools: &'c [ToolDef],
shape: &CallShape,
) -> Result<PhaseOutcome<Turn<'h, Calling<'c>>>, AxError>
pub fn assemble<'c>( self, interrupt: Interrupt, ledger: &mut dyn Ledger, prompt: RunPrompt<'_>, conversation: &'c Conversation, tools: &'c [ToolDef], shape: &CallShape, ) -> Result<PhaseOutcome<Turn<'h, Calling<'c>>>, AxError>
Boundary 1 (before assembly). Builds the canonical request from
the frozen prefix (system blocks), the window (messages) and the
catalog’s tool defs; appends prompt_assembled with the prefix’s
full source notes unless the run has already recorded that same
payload.
Source§impl<'h> Turn<'h, Calling<'_>>
impl<'h> Turn<'h, Calling<'_>>
Sourcepub fn call<'sink>(
self,
interrupt: Interrupt,
ledger: &mut dyn Ledger,
model: &mut dyn Model,
policy: &BuildingPolicy,
generating: Generating<'_, 'sink>,
) -> Result<PhaseOutcome<Turn<'h, ToolWave>>, AxError>
pub fn call<'sink>( self, interrupt: Interrupt, ledger: &mut dyn Ledger, model: &mut dyn Model, policy: &BuildingPolicy, generating: Generating<'_, 'sink>, ) -> Result<PhaseOutcome<Turn<'h, ToolWave>>, AxError>
Boundary 2 (before the provider call). Appends model_called and
model_returned; a provider Err propagates after nothing but the
boundary consumption touched the ledger. The reads generating
starts early are not events: they ride to the wave, which uses
each only for the settled call equal to the one started.
'sink is named rather than elided because the caller holds the
sink for the whole run and hands it to every turn: with an elided
lifetime the reborrow would have to shrink the trait object’s own
lifetime, which &mut does not permit.
Source§impl Turn<'_, Recording>
impl Turn<'_, Recording>
Sourcepub fn record(
self,
interrupt: Interrupt,
ledger: &mut dyn Ledger,
) -> Result<PhaseOutcome<TurnReport>, AxError>
pub fn record( self, interrupt: Interrupt, ledger: &mut dyn Ledger, ) -> Result<PhaseOutcome<TurnReport>, AxError>
Closes the turn. Recording is the accounting boundary: nothing
extra is appended here, because every effect is already on the
ledger. What the phase exists for is the fourth boundary — the
last moment before the run acts on what this turn decided,
including the work it handed down — and for the one compaction
door a turn has. The wave is whole by now, so this is the one
moment its snapshot may be replaced; a compactor meeting a
half-landed wave would group what this boundary groups once, and
runtime::fork rebuilding one turn at a time would answer
different bytes for the same history.
It pays no barrier: what the wave held waits in the run’s lines
for the next turn’s model call, or for the run’s freeze, and the
report names model_returned by its Entry until then
(runtime D36).
§Errors
Propagates the ledger’s refusal to record the boundary event and a text the compaction cannot count.