pub struct Flow {
pub steps: Vec<Step>,
pub constraints: Vec<Constraint>,
pub confirm_tools: Vec<String>,
pub ambient: Vec<String>,
}Expand description
A governed conversation/tool DAG.
Fields§
§steps: Vec<Step>The steps (DAG nodes).
constraints: Vec<Constraint>Cross-cutting constraints.
confirm_tools: Vec<String>Tools that require confirmation when reached (set by commit).
ambient: Vec<String>Cross-cutting tools exempt from step allow whitelists.
A step’s allow list excludes by omission, which is correct for the
domain tools a step is about and wrong for infrastructure no step is
about — memory recall, escalation, logging. Naming a tool here says “this
is not part of any step’s repertoire”, not “this is ungovernable”:
deny, once and never(..).until(..) all still bind, because each of
those names the tool and so is a decision about it.
Implementations§
Source§impl Flow
impl Flow
Sourcepub fn new() -> FlowBuilder
pub fn new() -> FlowBuilder
Start building a flow.
Sourcepub fn validate(&self) -> Result<(), ConfigError>
pub fn validate(&self) -> Result<(), ConfigError>
Validate referential integrity and acyclicity. Every problem found is
reported in the returned ConfigError, not just the first.
Sourcepub fn state_keys_read(&self) -> BTreeSet<String>
pub fn state_keys_read(&self) -> BTreeSet<String>
Every state key any guard in the flow reads (is_true/is_set/eq/
captured atoms in step gates, completion guards, and never…until
constraints).
A key in this set that nothing in the session writes — no tool, no
extractor, no promotion — can never latch, which is the dominant silent
failure in data-authored flows. Validators diff this set against the
declared writers to catch it at load time, the way
compile_with_tools catches tool typos.
Sourcepub fn compile(self) -> Result<CompiledFlow, FlowErrors>
pub fn compile(self) -> Result<CompiledFlow, FlowErrors>
Compile and validate the flow into a CompiledFlow, turning a class of
runtime surprises into load-time errors.
On top of validate’s referential/acyclicity checks this
reports: unreachable steps, commit tools guarded by an always-true
condition (an effectively unguarded commit, which defeats the
confirm-before-commit contract), never…until guards whose done(step)
atoms reference unknown steps (unsatisfiable — the tool would be forbidden
forever), and ordering cycles across the combined after + before edges
(which deadlock every step on the cycle). Precomputes the ToolSurface
universe.
To additionally validate tool names against a known registry, use
compile_with_tools.
Sourcepub fn compile_with_tools(
self,
tools: &[&str],
) -> Result<CompiledFlow, FlowErrors>
pub fn compile_with_tools( self, tools: &[&str], ) -> Result<CompiledFlow, FlowErrors>
Compile like compile, additionally validating every
tool name the flow references (step allow/deny, once,
never…until, and commit/confirm tools) against the given registry of
known tool names.
A referenced tool missing from tools is reported as
FlowError::UnknownTool — catching typos and drift between a flow
script and the tools actually registered on the session.
let compiled = flow.compile_with_tools(&["lookup_account", "charge_card"])?;Sourcepub fn to_mermaid(&self) -> String
pub fn to_mermaid(&self) -> String
Render the flow as a Mermaid flowchart — the spec is the diagram.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Flow
impl<'de> Deserialize<'de> for Flow
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 Flow
impl JsonSchema for Flow
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 Flow
impl !RefUnwindSafe for Flow
impl Send for Flow
impl Sync for Flow
impl Unpin for Flow
impl !UnwindSafe for Flow
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> 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].