pub enum Guard {
Spec(Pred),
Custom(Arc<dyn Fn(&FlowCtx<'_>) -> bool + Send + Sync>),
}Expand description
A boolean predicate over (state, marking) — the only predicate type.
Use the constructors (Guard::is_true, Guard::captured,
Guard::called_ok, …) for the serializable closed atoms, or
Guard::custom for a bespoke closure (not serializable).
Variants§
Spec(Pred)
A serializable predicate built from the closed atom set.
Custom(Arc<dyn Fn(&FlowCtx<'_>) -> bool + Send + Sync>)
A code-only escape hatch. Not serializable.
Implementations§
Source§impl Guard
impl Guard
Sourcepub fn eq(key: impl Into<String>, value: impl Into<Value>) -> Guard
pub fn eq(key: impl Into<String>, value: impl Into<Value>) -> Guard
State key equals the given JSON value.
Sourcepub fn captured<I, S>(fields: I) -> Guard
pub fn captured<I, S>(fields: I) -> Guard
All of the given state keys are present (extracted slots).
Sourcepub fn resolved(name: impl AsRef<str>) -> Guard
pub fn resolved(name: impl AsRef<str>) -> Guard
True once an orchestrated agent named name has produced a result
(its {name}:result state key is set). Pairs with the
orchestration call/dispatch/background.
Sourcepub fn all(guards: impl IntoIterator<Item = Guard>) -> Guard
pub fn all(guards: impl IntoIterator<Item = Guard>) -> Guard
Conjunction.
If every input is a serializable atom, the result is a serializable
Pred::All. If any input is a Guard::custom, the result is itself a
custom guard that evaluates the conjunction at runtime — the custom guard
is never silently dropped (it merely makes the combinator
non-serializable, which surfaces as an error only if you try to serialize
the flow).
Sourcepub fn any(guards: impl IntoIterator<Item = Guard>) -> Guard
pub fn any(guards: impl IntoIterator<Item = Guard>) -> Guard
Disjunction.
Mirrors Guard::all: custom inputs are preserved as a runtime closure
rather than erased.
Sourcepub fn describe(&self) -> String
pub fn describe(&self) -> String
This guard as a short prose clause, for telling a model what a refusal is waiting on.
A refusal that names only the tool leaves the model to guess the
precondition, and a wrong guess is indistinguishable from a wrong model:
in the governed collections evaluation, record_promise_to_pay was
refused with “not available in the current step”, and the model — with
nothing else to go on — decided it must need to re-verify the caller and
asked for the card digits it had already checked.
Sourcepub fn custom(f: impl Fn(&FlowCtx<'_>) -> bool + Send + Sync + 'static) -> Guard
pub fn custom(f: impl Fn(&FlowCtx<'_>) -> bool + Send + Sync + 'static) -> Guard
A bespoke closure over (state, marking). Not serializable.
Sourcepub fn eval_state(&self, state: &State) -> bool
pub fn eval_state(&self, state: &State) -> bool
Evaluate against state alone, with an empty Marking.
For contexts outside a governed flow (phase transitions, watcher
conditions) where no marking exists: called_ok/done atoms evaluate
false there — a validator should reject them in such positions.
Sourcepub fn explain_trace(&self, ctx: &FlowCtx<'_>) -> GuardTrace
pub fn explain_trace(&self, ctx: &FlowCtx<'_>) -> GuardTrace
Evaluate to a GuardTrace — the predicate tree with per-node truth
values. A Guard::custom yields a single opaque node.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Guard
impl<'de> Deserialize<'de> for Guard
Source§fn deserialize<D>(d: D) -> Result<Guard, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<Guard, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl JsonSchema for Guard
impl JsonSchema for Guard
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§fn schema_name() -> String
fn schema_name() -> String
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§impl Serialize for Guard
impl Serialize for Guard
Source§fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Auto Trait Implementations§
impl Freeze for Guard
impl !RefUnwindSafe for Guard
impl Send for Guard
impl Sync for Guard
impl Unpin for Guard
impl !UnwindSafe for Guard
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> 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].