pub struct EnforcementStateMachine { /* private fields */ }Expand description
Per-extension enforcement state machine with hysteresis tracking.
Implementations§
Source§impl EnforcementStateMachine
impl EnforcementStateMachine
Sourcepub const fn with_config(
bands: EnforcementScoreBands,
hysteresis: EnforcementHysteresis,
) -> Self
pub const fn with_config( bands: EnforcementScoreBands, hysteresis: EnforcementHysteresis, ) -> Self
Create with custom bands and hysteresis.
Sourcepub const fn state(&self) -> EnforcementState
pub const fn state(&self) -> EnforcementState
Current enforcement state.
Sourcepub const fn evaluation_count(&self) -> u64
pub const fn evaluation_count(&self) -> u64
Total evaluations processed.
Sourcepub fn evaluate(&mut self, score: f64) -> EnforcementTransition
pub fn evaluate(&mut self, score: f64) -> EnforcementTransition
Evaluate a risk score and return the enforcement transition.
Escalation (moving to a more severe state) is immediate. De-escalation (moving to a less severe state) requires:
- The score to fall below (entry_threshold -
de_escalation_margin). - At least
cooldown_callsconsecutive evaluations in the lower band.
Terminate is a terminal state — once entered, it cannot be de-escalated.
Sourcepub fn merge_with_policy(
enforcement: EnforcementState,
policy: PolicyDecision,
) -> EnforcementState
pub fn merge_with_policy( enforcement: EnforcementState, policy: PolicyDecision, ) -> EnforcementState
Combine the enforcement state machine decision with a capability policy decision. The most restrictive outcome wins.
- If the policy denies the capability outright, the result is Deny regardless of the risk score.
- If the enforcement machine says Terminate, that overrides everything.
Trait Implementations§
Source§impl Clone for EnforcementStateMachine
impl Clone for EnforcementStateMachine
Source§fn clone(&self) -> EnforcementStateMachine
fn clone(&self) -> EnforcementStateMachine
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EnforcementStateMachine
impl Debug for EnforcementStateMachine
Source§impl<'de> Deserialize<'de> for EnforcementStateMachine
impl<'de> Deserialize<'de> for EnforcementStateMachine
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for EnforcementStateMachine
impl RefUnwindSafe for EnforcementStateMachine
impl Send for EnforcementStateMachine
impl Sync for EnforcementStateMachine
impl Unpin for EnforcementStateMachine
impl UnsafeUnpin for EnforcementStateMachine
impl UnwindSafe for EnforcementStateMachine
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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 moreSource§impl<T> ModelDump for Twhere
T: Serialize,
impl<T> ModelDump for Twhere
T: Serialize,
Source§fn model_dump(&self, options: DumpOptions) -> Result<Value, Error>
fn model_dump(&self, options: DumpOptions) -> Result<Value, Error>
Serialize a model to a JSON value. Read more
Source§fn model_dump_json(&self) -> Result<String, Error>
fn model_dump_json(&self) -> Result<String, Error>
Serialize a model to a JSON string with default options.
Source§fn model_dump_json_pretty(&self) -> Result<String, Error>
fn model_dump_json_pretty(&self) -> Result<String, Error>
Serialize a model to a pretty-printed JSON string.
Source§fn model_dump_json_with_options(
&self,
options: DumpOptions,
) -> Result<String, Error>
fn model_dump_json_with_options( &self, options: DumpOptions, ) -> Result<String, Error>
Serialize a model to a JSON string with full options support. Read more
Source§impl<T> ModelValidate for Twhere
T: DeserializeOwned,
impl<T> ModelValidate for Twhere
T: DeserializeOwned,
Source§fn model_validate(
input: impl Into<ValidateInput>,
options: ValidateOptions,
) -> Result<T, ValidationError>
fn model_validate( input: impl Into<ValidateInput>, options: ValidateOptions, ) -> Result<T, ValidationError>
Create and validate a model from input. Read more
Source§fn model_validate_json(json: &str) -> Result<Self, ValidationError>
fn model_validate_json(json: &str) -> Result<Self, ValidationError>
Create and validate a model from JSON string with default options.
Source§fn model_validate_dict(
dict: HashMap<String, Value>,
) -> Result<Self, ValidationError>
fn model_validate_dict( dict: HashMap<String, Value>, ) -> Result<Self, ValidationError>
Create and validate a model from a HashMap with default options.