pub struct Sim { /* private fields */ }Expand description
A deterministic, model-free driver for a compiled conversation.
Implementations§
Source§impl Sim
impl Sim
Sourcepub fn new(convo: &CompiledConversation, mode: Enforcement) -> Self
pub fn new(convo: &CompiledConversation, mode: Enforcement) -> Self
Build a simulator over convo in the given enforcement mode.
Sourcepub fn set(&self, key: impl Into<String>, value: impl Serialize) -> &Self
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.
Sourcepub async fn user(&mut self, utterance: &str) -> &mut Self
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.
Sourcepub fn turn(&mut self) -> &mut Self
pub fn turn(&mut self) -> &mut Self
Advance a turn with no new user input (e.g. waiting on a tool/resolver).
Sourcepub fn tool_ok(&mut self, tool: &str) -> &mut Self
pub fn tool_ok(&mut self, tool: &str) -> &mut Self
A tool succeeds now; records it and advances a turn (processing any digression resume).
Sourcepub fn schedule_tool(
&mut self,
tool: impl Into<String>,
after: u32,
) -> &mut Self
pub fn schedule_tool( &mut self, tool: impl Into<String>, after: u32, ) -> &mut Self
Schedule a tool to succeed after turns — models tool latency.
Sourcepub fn active_overlay(&self) -> Option<&str>
pub fn active_overlay(&self) -> Option<&str>
The active digression, if one is suspending the main flow.
Sourcepub fn denied(&self) -> BTreeMap<String, String>
pub fn denied(&self) -> BTreeMap<String, String>
Currently-blocked tools, mapped to the reason.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Whether the conversation is complete.
Sourcepub fn slot<T: DeserializeOwned>(&self, key: &str) -> Option<T>
pub fn slot<T: DeserializeOwned>(&self, key: &str) -> Option<T>
Read a slot value.
Sourcepub fn explain(&self) -> FlowExplanation
pub fn explain(&self) -> FlowExplanation
The active layer’s control-plane explanation.