pub struct EnforcementEngine { /* private fields */ }Expand description
The enforcement engine. Owns the commitment history H_t (and thus the active subset K_t), the override policy, and the in-memory audit chain.
Implementations§
Source§impl EnforcementEngine
impl EnforcementEngine
pub fn new() -> Self
Sourcepub fn from_state(state: EngineState) -> Self
pub fn from_state(state: EngineState) -> Self
From persisted state.
pub fn state(&self) -> EngineState
pub fn audit(&self) -> &[AuditChunk]
Sourcepub fn restore_audit(&mut self, chunks: Vec<AuditChunk>)
pub fn restore_audit(&mut self, chunks: Vec<AuditChunk>)
Reattach a persisted audit chain so new decisions continue it instead of re-seeding from the genesis node.
Add an override authority. An actor in this set may author a
justified override; the default set contains guardian.
Sourcepub fn add_commitment(
&mut self,
actor: &str,
forbidden_action: &str,
scope: &str,
content: &str,
expires_at_ms: Option<u64>,
) -> u64
pub fn add_commitment( &mut self, actor: &str, forbidden_action: &str, scope: &str, content: &str, expires_at_ms: Option<u64>, ) -> u64
Add a new commitment to the history H_t. Returns the new id.
Sourcepub fn with_commitments(self, commitments: Vec<Commitment>) -> Self
pub fn with_commitments(self, commitments: Vec<Commitment>) -> Self
Replace the whole history (used when loading persisted state).
Sourcepub fn history(&self) -> &[Commitment]
pub fn history(&self) -> &[Commitment]
Full commitment history H_t.
Sourcepub fn active_commitments(&self, now_ms: u64) -> Vec<&Commitment>
pub fn active_commitments(&self, now_ms: u64) -> Vec<&Commitment>
The active subset K_t subset H_t at now_ms.
Sourcepub fn violations(&self, event: &ActionEvent) -> Vec<Violation>
pub fn violations(&self, event: &ActionEvent) -> Vec<Violation>
Which active commitments does event violate?
Sourcepub fn justified_override(
&self,
event: &ActionEvent,
justification: &str,
) -> Result<(), String>
pub fn justified_override( &self, event: &ActionEvent, justification: &str, ) -> Result<(), String>
The documented override path. A justification is accepted only when (1) an authorized overrider requested it and (2) the justification is recorded (non-empty and at least MIN_JUSTIFICATION_LEN characters).
Sourcepub fn decide(
&mut self,
event: &ActionEvent,
justification: Option<&str>,
) -> Decision
pub fn decide( &mut self, event: &ActionEvent, justification: Option<&str>, ) -> Decision
The mandatory gate. Runs attribution + violates(), grants the documented override path, blocks hard on violation, and records every decision in the audit chain.
Sourcepub fn can_execute(
&mut self,
event: &ActionEvent,
justification: Option<&str>,
) -> bool
pub fn can_execute( &mut self, event: &ActionEvent, justification: Option<&str>, ) -> bool
Executor boundary gate: the native executor MUST run an action only if
this returns true. Internally this runs the same mandatory decide()
(attribution check, K_t selection, violates(), justifiedOverride())
and persists the decision to the audit chain. Blocked and
AttributionError both yield false, so a non-permitted action never
reaches an executor that respects this gate.
Sourcepub fn select_valid(&mut self, candidates: &[ActionEvent]) -> Vec<ActionEvent>
pub fn select_valid(&mut self, candidates: &[ActionEvent]) -> Vec<ActionEvent>
Restrict a candidate set to A_t^valid.
Sourcepub fn chain_valid(&self) -> bool
pub fn chain_valid(&self) -> bool
True whenever the in-memory chain is internally consistent.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EnforcementEngine
impl RefUnwindSafe for EnforcementEngine
impl Send for EnforcementEngine
impl Sync for EnforcementEngine
impl Unpin for EnforcementEngine
impl UnsafeUnpin for EnforcementEngine
impl UnwindSafe for EnforcementEngine
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<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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