Module simulation

Module simulation 

Source
Expand description

Model-free conversation simulation.

A deterministic harness that drives a CompiledConversation without any live API: a fake user supplies utterances (run through the conversation’s recognizers) or sets slots directly, tools succeed on demand or after a latency, and the FlowStack advances turn by turn. Everything is driven by State + guards, so motifs, repair, policies, and digressions become testable in CI — “a flow SDK with simulation is infra; without it, a demo framework”.

let convo = Conversation::new("booking")
    .stage("check").collect(["party_size", "slot"])
        .next("confirm", Guard::captured(["party_size", "slot"]))
    .stage("confirm").commit("book", Guard::is_true("user_confirmed"))
        .next("done", Guard::called_ok("book"))
    .stage("done").terminal()
    .require(["done"])
    .compile()?;
let mut sim = Sim::new(&convo, Enforcement::Enforce);
sim.user("a table for 4 tomorrow at 7pm").await;
assert!(sim.active().contains(&"check".to_string()));
assert!(!sim.allowed("book"));            // not confirmed yet
sim.set("user_confirmed", true);
sim.tool_ok("book");
assert!(sim.is_complete());

Structs§

Scenario
A serializable simulation script — a deterministic, model-free test case that can be authored in code or loaded from YAML/JSON.
Sim
A deterministic, model-free driver for a compiled conversation.

Enums§

SimStep
One step in a serializable Scenario.