pub enum TraceAssertion {
TraceMustCallTool {
tool: String,
min_calls: Option<u32>,
},
TraceMustNotCallTool {
tool: String,
},
TraceToolSequence {
sequence: Vec<String>,
allow_other_tools: bool,
},
TraceMaxSteps {
max: u32,
},
ArgsValid {
tool: String,
test_args: Option<Value>,
policy: Option<Value>,
expect: Option<String>,
},
SequenceValid {
test_trace: Option<Vec<ToolCallRow>>,
test_trace_raw: Option<Vec<Value>>,
policy: Option<Value>,
expect: Option<String>,
},
ToolBlocklist {
test_tool_calls: Option<Vec<String>>,
policy: Option<Value>,
expect: Option<String>,
},
}Expand description
An assertion carrying a key this enum does not define is rejected at parse time.
Without deny_unknown_fields serde drops the unrecognised key silently, and where the
intended field has a default the assertion falls back to a shape that cannot fail. The
documented max_calls: 0 “must NOT use a forbidden tool” example is the worked case: the
key is dropped, min_calls defaults to 1 in matchers.rs, and the assertion inverts into
“must be called at least once” with no signal at any stage (#1961).
deny_unknown_fields is applied at the container, which is the only place serde accepts
it — it is not a variant attribute, and the compiler rejects it as one. There is folklore
that container-level rejection is unreliable on an internally-tagged enum (serde-rs/serde
#2294, #1358). Those defects are about unit-like variants and flatten; every variant here
is a struct variant with named fields and none flattens, and rejection was verified on this
exact shape for the hardest case in it — tool_blocklist, whose fields are all defaulted, so
nothing but the tag is required. A stray key there is rejected too. Nested free-form values
(policy, test_args) are serde_json::Value and stay unconstrained, which is intended:
the guard covers the assertion’s own field vocabulary, not policy contents.
Keep the guard at the container. Per-variant allow-set validation was considered and is not
needed here; the tests in tests/assertions_unknown_fields.rs pin the behaviour that makes
it unnecessary, including the all-defaulted variant.
Variants§
TraceMustCallTool
TraceMustNotCallTool
TraceToolSequence
TraceMaxSteps
ArgsValid
SequenceValid
Fields
test_trace: Option<Vec<ToolCallRow>>ToolBlocklist
Trait Implementations§
Source§impl Clone for TraceAssertion
impl Clone for TraceAssertion
Source§fn clone(&self) -> TraceAssertion
fn clone(&self) -> TraceAssertion
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TraceAssertion
impl Debug for TraceAssertion
Source§impl<'de> Deserialize<'de> for TraceAssertion
impl<'de> Deserialize<'de> for TraceAssertion
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>,
Auto Trait Implementations§
impl Freeze for TraceAssertion
impl RefUnwindSafe for TraceAssertion
impl Send for TraceAssertion
impl Sync for TraceAssertion
impl Unpin for TraceAssertion
impl UnsafeUnpin for TraceAssertion
impl UnwindSafe for TraceAssertion
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<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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