pub struct GovernanceEngine { /* private fields */ }Expand description
Governance engine.
Evaluates actions against governance rules and the environment’s
risk threshold. Without the governance feature gate, all
evaluations return Permit.
Implementations§
Source§impl GovernanceEngine
impl GovernanceEngine
Sourcepub fn new(risk_threshold: f64, human_approval_required: bool) -> Self
pub fn new(risk_threshold: f64, human_approval_required: bool) -> Self
Create a governance engine with the given risk threshold.
Sourcepub fn add_rule(&mut self, rule: GovernanceRule)
pub fn add_rule(&mut self, rule: GovernanceRule)
Add a governance rule.
Sourcepub fn active_rules(&self) -> Vec<&GovernanceRule>
pub fn active_rules(&self) -> Vec<&GovernanceRule>
Get all active rules.
Sourcepub fn rules_by_branch(&self, branch: &GovernanceBranch) -> Vec<&GovernanceRule>
pub fn rules_by_branch(&self, branch: &GovernanceBranch) -> Vec<&GovernanceRule>
Get rules by branch.
Sourcepub fn evaluate(&self, request: &GovernanceRequest) -> GovernanceResult
pub fn evaluate(&self, request: &GovernanceRequest) -> GovernanceResult
Evaluate a governance request.
Decision logic:
- If any blocking/critical rule applies, deny.
- If effect magnitude exceeds threshold:
- If human_approval_required, escalate.
- Otherwise deny.
- If any warning rule applies, permit with warning.
- Otherwise permit.
Sourcepub fn risk_threshold(&self) -> f64
pub fn risk_threshold(&self) -> f64
Get the configured risk threshold.
Sourcepub fn rule_count(&self) -> usize
pub fn rule_count(&self) -> usize
Get total rule count.
Sourcepub fn evaluate_in_environment(
&self,
request: &GovernanceRequest,
env: &Environment,
) -> GovernanceResult
pub fn evaluate_in_environment( &self, request: &GovernanceRequest, env: &Environment, ) -> GovernanceResult
Evaluate a governance request in the context of a specific environment.
Different environment classes apply different risk thresholds:
- Development: uses the environment’s own
risk_threshold(lenient, typically 0.9). - Staging: uses the environment’s own
risk_threshold(moderate, typically 0.6). - Production: uses half the environment’s
risk_threshold(strict, typically 0.15). - Custom: uses the custom class’s
risk_thresholddirectly.
After normal rule evaluation, an additional effect-magnitude check is
performed against the environment-adjusted threshold. If the magnitude
exceeds it, the decision is overridden to Deny.
Sourcepub fn evaluate_logged(
&self,
request: &GovernanceRequest,
chain: Option<&ChainManager>,
) -> GovernanceResult
pub fn evaluate_logged( &self, request: &GovernanceRequest, chain: Option<&ChainManager>, ) -> GovernanceResult
Evaluate a governance request and log the decision to the chain.
This is the recommended entry point when a ChainManager is
available. It calls evaluate and records an
ipc.dead_letter-style audit event via [ChainLoggable].
If no chain manager is provided, behaves identically to evaluate.
Sourcepub fn evaluate_in_environment_logged(
&self,
request: &GovernanceRequest,
env: &Environment,
chain: Option<&ChainManager>,
) -> GovernanceResult
pub fn evaluate_in_environment_logged( &self, request: &GovernanceRequest, env: &Environment, chain: Option<&ChainManager>, ) -> GovernanceResult
Evaluate in an environment and log the decision to the chain.
Sourcepub fn chain_log_result(
cm: &ChainManager,
request: &GovernanceRequest,
result: &GovernanceResult,
)
pub fn chain_log_result( cm: &ChainManager, request: &GovernanceRequest, result: &GovernanceResult, )
Log a governance result to the ExoChain.
Can be called after any evaluate / evaluate_in_environment
call to record the decision in the audit trail.
Source§impl GovernanceEngine
impl GovernanceEngine
Sourcepub fn to_rvf_mode(&self) -> GovernanceMode
pub fn to_rvf_mode(&self) -> GovernanceMode
Derive the equivalent RVF GovernanceMode from this engine’s config.
risk_threshold >= 1.0(open) →Autonomoushuman_approval_required→Approved- otherwise →
Restricted
Sourcepub fn to_rvf_policy(&self) -> GovernancePolicy
pub fn to_rvf_policy(&self) -> GovernancePolicy
Build an RVF GovernancePolicy from this engine’s configuration.
Uses the default tool lists and cost budgets for each mode. Callers can customize the returned policy further if needed.
Auto Trait Implementations§
impl Freeze for GovernanceEngine
impl RefUnwindSafe for GovernanceEngine
impl Send for GovernanceEngine
impl Sync for GovernanceEngine
impl Unpin for GovernanceEngine
impl UnsafeUnpin for GovernanceEngine
impl UnwindSafe for GovernanceEngine
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
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