Sim

Struct Sim 

Source
pub struct Sim { /* private fields */ }
Expand description

A deterministic, model-free driver for a compiled conversation.

Implementations§

Source§

impl Sim

Source

pub fn new(convo: &CompiledConversation, mode: Enforcement) -> Self

Build a simulator over convo in the given enforcement mode.

Source

pub fn set(&self, key: impl Into<String>, value: impl Serialize) -> &Self

Set a state value directly (information a recognizer can’t supply, or a scripted shortcut). Does not advance a turn.

Source

pub async fn user(&mut self, utterance: &str) -> &mut Self

The fake user speaks: run the conversation’s extractors over the utterance to fill slots (respecting validators), then advance a turn.

Source

pub fn turn(&mut self) -> &mut Self

Advance a turn with no new user input (e.g. waiting on a tool/resolver).

Source

pub fn tool_ok(&mut self, tool: &str) -> &mut Self

A tool succeeds now; records it and advances a turn (processing any digression resume).

Source

pub fn schedule_tool( &mut self, tool: impl Into<String>, after: u32, ) -> &mut Self

Schedule a tool to succeed after turns — models tool latency.

Source

pub fn active(&self) -> Vec<String>

Active step ids in the currently-driving layer.

Source

pub fn active_overlay(&self) -> Option<&str>

The active digression, if one is suspending the main flow.

Source

pub fn allowed(&self, tool: &str) -> bool

Whether tool is admitted right now.

Source

pub fn denied(&self) -> BTreeMap<String, String>

Currently-blocked tools, mapped to the reason.

Source

pub fn is_complete(&self) -> bool

Whether the conversation is complete.

Source

pub fn slot<T: DeserializeOwned>(&self, key: &str) -> Option<T>

Read a slot value.

Source

pub fn explain(&self) -> FlowExplanation

The active layer’s control-plane explanation.

Source

pub fn state(&self) -> &State

The simulation state (for custom assertions / slot evidence).

Auto Trait Implementations§

§

impl Freeze for Sim

§

impl !RefUnwindSafe for Sim

§

impl Send for Sim

§

impl Sync for Sim

§

impl Unpin for Sim

§

impl !UnwindSafe for Sim

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,