pub struct Scenario {
pub name: String,
pub steps: Vec<SimStep>,
}Expand description
A serializable simulation script — a deterministic, model-free test case that can be authored in code or loaded from YAML/JSON.
Fields§
§name: StringScenario name (for diagnostics).
steps: Vec<SimStep>The steps to execute, in order.
Implementations§
Source§impl Scenario
impl Scenario
Sourcepub fn from_journal(name: impl Into<String>, journal: &[StateMutation]) -> Self
pub fn from_journal(name: impl Into<String>, journal: &[StateMutation]) -> Self
Turn a recorded session into a regression scenario: the incident becomes a test.
journal is the session’s mutation journal (see
FileJournalSink and
read_journal), which a
governed session writes as one ordered timeline. The scenario replays
what the application and user contributed and checks what governance
decided:
- a slot or flag write becomes
Set; - a tool the flow admitted becomes
ExpectAllowed, one it refusedExpectDenied, and its outcomeToolResult; - every turn boundary where the flow was evaluated (a
flow:activewrite) becomes aTurnfollowed byExpectActivewith the steps the session had then.
Keys the runtime owns (session:, flow:, derived:, repair and
correction signals, …) are not replayed: the simulator must reach them
itself.
Run the result against the conversation spec in CI. If a change to the spec alters what that session would have done, the scenario fails at the step where the two diverge.
Sourcepub async fn run(
&self,
convo: &CompiledConversation,
mode: Enforcement,
) -> Result<(), String>
pub async fn run( &self, convo: &CompiledConversation, mode: Enforcement, ) -> Result<(), String>
Run the scenario against convo. Returns Ok(()) if every Expect* step
holds, else Err with the failing step index and a diagnostic.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Scenario
impl<'de> Deserialize<'de> for Scenario
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Scenario
impl JsonSchema for Scenario
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreAuto Trait Implementations§
impl Freeze for Scenario
impl RefUnwindSafe for Scenario
impl Send for Scenario
impl Sync for Scenario
impl Unpin for Scenario
impl UnwindSafe for Scenario
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].