Skip to main content

Turn

Struct Turn 

Source
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>

Source

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 of them starts, in call order, and a cancel starts only the calls before it: the calls a serial wave would have made before the same cancel. 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>

Source

pub fn begin( run: RunId, who: String, t: TimeMs, now: &'h mut dyn FnMut() -> Result<TimeMs, AxError>, ) -> Turn<'h, Assembling>

Opens a turn. 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.

Source

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<'_>>

Source

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>

Source

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.

§Errors

Propagates the ledger’s refusal to record the boundary event and a text the compaction cannot count.

Trait Implementations§

Source§

impl<'h, S: Debug> Debug for Turn<'h, S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'h, S> !RefUnwindSafe for Turn<'h, S>

§

impl<'h, S> !Send for Turn<'h, S>

§

impl<'h, S> !Sync for Turn<'h, S>

§

impl<'h, S> !UnwindSafe for Turn<'h, S>

§

impl<'h, S> Freeze for Turn<'h, S>
where S: Freeze,

§

impl<'h, S> Unpin for Turn<'h, S>
where S: Unpin,

§

impl<'h, S> UnsafeUnpin for Turn<'h, S>
where S: UnsafeUnpin,

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.