pub struct FlowMonitor { /* private fields */ }Expand description
Observes the session trace, maintains the Marking, answers tool
admissibility, and projects active postures.
Implementations§
Source§impl FlowMonitor
impl FlowMonitor
Sourcepub fn new(flow: Flow, mode: Enforcement) -> Self
pub fn new(flow: Flow, mode: Enforcement) -> Self
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).
Sourcepub fn compiled(flow: CompiledFlow, mode: Enforcement) -> Self
pub fn compiled(flow: CompiledFlow, mode: Enforcement) -> Self
Create a monitor from a CompiledFlow — the validated path.
Sourcepub fn try_new(flow: Flow, mode: Enforcement) -> Result<Self, FlowErrors>
pub fn try_new(flow: Flow, mode: Enforcement) -> Result<Self, 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).
Sourcepub 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.
Sourcepub fn on_enter(self, step: impl Into<String>, action: StepAction) -> Self
pub fn on_enter(self, step: impl Into<String>, action: StepAction) -> Self
Attach an action fired the first time step becomes active (see
on_enter). Chainable at construction time.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub fn mode(&self) -> Enforcement
pub fn mode(&self) -> Enforcement
The enforcement mode this monitor runs in.
Sourcepub fn set_posture(&mut self, step_id: &str, posture: Option<String>) -> bool
pub fn set_posture(&mut self, step_id: &str, posture: Option<String>) -> bool
Replace a step’s posture in place. Returns false if no such step.
Postures are re-projected at every turn boundary, so an edit takes effect on the next turn — the safe subset of live spec editing. The DAG, guards, and tool gates are structural and stay fixed.
Sourcepub fn set_ground(&mut self, step_id: &str, ground: Option<String>) -> bool
pub fn set_ground(&mut self, step_id: &str, ground: Option<String>) -> bool
Replace a step’s grounding template in place. Returns false if no
such step. Same next-turn semantics as set_posture.
Sourcepub 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.
Sourcepub fn violations(&self) -> &[Violation]
pub fn violations(&self) -> &[Violation]
Recorded violations.
Sourcepub 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).
Constraint::Reset constraints are applied first, on their guard’s
rising edge: the named steps un-latch, their on_enter re-arms, and
the called_ok evidence their completion guards reference is forgiven
— the loop primitive over an otherwise monotonic marking.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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).
Sourcepub fn unmet_requirements(&self) -> Vec<String>
pub fn unmet_requirements(&self) -> Vec<String>
Required steps not yet done (drives repair).
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Whether all required steps are done.
Sourcepub fn verdict(&self, step_id: &str, state: &State) -> Verdict
pub fn verdict(&self, step_id: &str, state: &State) -> Verdict
The conformance verdict for a step.
Sourcepub 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).
Sourcepub 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.
Auto Trait Implementations§
impl Freeze for FlowMonitor
impl !RefUnwindSafe for FlowMonitor
impl Send for FlowMonitor
impl Sync for FlowMonitor
impl Unpin for FlowMonitor
impl !UnwindSafe for FlowMonitor
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
§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].