FlowMonitor

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

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

Create a monitor from a CompiledFlow — the validated path.

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.

pub fn into_shared(self) -> Arc<Mutex<RawMutex, FlowMonitor>>

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

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

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

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>

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>

The enter-action registered for a step, if any.

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

The enforcement mode this monitor runs in.

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 marking(&self) -> &Marking

The current marking.

pub fn violations(&self) -> &[Violation]

Recorded violations.

pub fn flow(&self) -> &Flow

The underlying flow.

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_turn(&mut self, state: &State)

Record a turn boundary, then re-latch.

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>

Steps that are eligible but not yet done.

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>

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>

Required steps not yet done (drives repair).

pub fn is_complete(&self) -> bool

Whether all required steps are done.

pub fn verdict(&self, step_id: &str, state: &State) -> Verdict

The conformance verdict for a step.

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)

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,