Struct FlowMonitor
pub struct FlowMonitor { /* private fields */ }Expand description
Observes the session trace, maintains the Marking, answers tool
admissibility, and projects active postures.
Implementations§
§impl FlowMonitor
impl FlowMonitor
pub fn new(flow: Flow, mode: Enforcement) -> FlowMonitor
pub fn new(flow: Flow, mode: Enforcement) -> FlowMonitor
Create a monitor for a (presumed-valid) flow.
Prefer FlowMonitor::compiled or FlowMonitor::try_new, which carry
proof of compilation; this convenience skips compilation for flows already
known valid (e.g. built in-process by trusted code).
pub fn compiled(flow: CompiledFlow, mode: Enforcement) -> FlowMonitor
pub fn compiled(flow: CompiledFlow, mode: Enforcement) -> FlowMonitor
Create a monitor from a CompiledFlow — the validated path.
pub fn try_new(flow: Flow, mode: Enforcement) -> Result<FlowMonitor, FlowErrors>
pub fn try_new(flow: Flow, mode: Enforcement) -> Result<FlowMonitor, FlowErrors>
Compile flow and create a monitor, surfacing structural errors instead
of trusting the caller.
Wrap this monitor in a SharedFlowMonitor for shared ownership
between the control lane (which advances it) and runtime accessors
(which snapshot it, e.g.
LiveHandle::explain).
pub fn explain(&self, state: &State) -> FlowExplanation
pub fn explain(&self, state: &State) -> FlowExplanation
Explain the current control-plane state: active steps, which tools are admitted vs blocked (with reasons), and unmet requirements.
This is the deterministic answer to “why did the assistant ask that?” — model-readable, without the model driving control flow.
pub fn why_blocked(&self, state: &State) -> FlowExplanation
pub fn why_blocked(&self, state: &State) -> FlowExplanation
Why the flow is blocked right now — alias of explain,
named for the common debugging question.
pub fn on_enter(
self,
step: impl Into<String>,
action: StepAction,
) -> FlowMonitor
pub fn on_enter( self, step: impl Into<String>, action: StepAction, ) -> FlowMonitor
Attach an action fired the first time step becomes active (see
run). Chainable at construction time.
pub fn take_newly_active(&mut self, state: &State) -> Vec<String>
pub fn take_newly_active(&mut self, state: &State) -> Vec<String>
Steps that became active since the last call — each reported exactly once
over the session. Drives on_enter firing.
pub fn enter_action(&self, step: &str) -> Option<&StepAction>
pub fn enter_action(&self, step: &str) -> Option<&StepAction>
The enter-action registered for a step, if any.
pub async fn fire_enter_actions(&mut self, state: &State)
pub async fn fire_enter_actions(&mut self, state: &State)
Fire enter-actions for every step that just became active. Convenience
over take_newly_active + enter_action;
call it right after on_turn.
pub fn mode(&self) -> Enforcement
pub fn mode(&self) -> Enforcement
The enforcement mode this monitor runs in.
pub fn eval(&self, guard: &Guard, state: &State) -> bool
pub fn eval(&self, guard: &Guard, state: &State) -> bool
Evaluate a Guard against this monitor’s current context (the given
state plus the monitor’s marking). Used to test overlay/digression
triggers without exposing the internal context.
pub fn violations(&self) -> &[Violation]
pub fn violations(&self) -> &[Violation]
Recorded violations.
pub fn relatch(&mut self, state: &State)
pub fn relatch(&mut self, state: &State)
Re-evaluate completion latches to a fixpoint. Call after any event that can change state or the marking (turn boundary, tool completion).
pub fn on_tool_ok(&mut self, tool: &str, state: &State)
pub fn on_tool_ok(&mut self, tool: &str, state: &State)
Record a successful tool call, then re-latch.
pub fn active_steps(&self, state: &State) -> Vec<&Step>
pub fn active_steps(&self, state: &State) -> Vec<&Step>
Steps that are eligible but not yet done.
pub fn active_postures(&self, state: &State) -> Vec<String>
pub fn active_postures(&self, state: &State) -> Vec<String>
Postures of the active steps — to inject as turn-boundary steering.
pub fn active_grounds(&self, state: &State) -> Vec<String>
pub fn active_grounds(&self, state: &State) -> Vec<String>
Rendered grounding lines of the active steps — curated, State-
interpolated facts to inject as turn-boundary steering (anti-hallucination).
pub fn unmet_requirements(&self) -> Vec<String>
pub fn unmet_requirements(&self) -> Vec<String>
Required steps not yet done (drives repair).
pub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Whether all required steps are done.
pub fn admits_tool(&self, tool: &str, state: &State) -> Result<(), String>
pub fn admits_tool(&self, tool: &str, state: &State) -> Result<(), String>
Decide whether a tool call may proceed. Ok(()) admits it; Err(reason)
denies it (the caller blocks in Enforce mode, or records in Observe).
pub fn observe_tool(&mut self, tool: &str, ok: bool, state: &State)
pub fn observe_tool(&mut self, tool: &str, ok: bool, state: &State)
Observe a tool call for conformance. In Enforce mode the caller has
already gated via admits_tool; this records the
call and, in Observe mode, logs a deviation if it was inadmissible.