pub struct Flow {
pub steps: Vec<Step>,
pub constraints: Vec<Constraint>,
pub confirm_tools: 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).
Implementations§
Source§impl Flow
impl Flow
Sourcepub fn new() -> FlowBuilder
pub fn new() -> FlowBuilder
Start building a flow.
Sourcepub fn validate(&self) -> Result<(), Vec<String>>
pub fn validate(&self) -> Result<(), Vec<String>>
Validate referential integrity and acyclicity.
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 ToolPolicy
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.