pub struct ToolPolicyEngine { /* private fields */ }Expand description
The ring regulation engine — evaluates fight rules to decide whether a fighter can throw a given move.
Uses deny-wins semantics: if ANY matching rule denies the move, the overall decision is denial. The strictest referee always prevails.
Thread-safe invocation tracking via DashMap supports concurrent bouts.
Implementations§
Source§impl ToolPolicyEngine
impl ToolPolicyEngine
Sourcepub fn add_rule(&mut self, rule: PolicyRule)
pub fn add_rule(&mut self, rule: PolicyRule)
Add a fight rule to the ring regulations.
Sourcepub fn remove_rule(&mut self, name: &str) -> bool
pub fn remove_rule(&mut self, name: &str) -> bool
Remove a fight rule by name. Returns true if a rule was removed.
Sourcepub fn evaluate(
&self,
tool_name: &str,
fighter_name: &str,
capabilities: &[String],
) -> PolicyDecision
pub fn evaluate( &self, tool_name: &str, fighter_name: &str, capabilities: &[String], ) -> PolicyDecision
Evaluate all matching rules for a tool invocation by a fighter.
The referee checks every applicable rule, sorted by priority (highest first). Deny wins: if any matching rule denies the move, the overall result is denial regardless of allow rules.
If no rules match at all, the default is to allow — permissive by default, like an unsanctioned bout.
Sourcepub fn rules(&self) -> &[PolicyRule]
pub fn rules(&self) -> &[PolicyRule]
Get all currently registered fight rules.
Sourcepub fn matching_rules(
&self,
tool_name: &str,
fighter_name: &str,
) -> Vec<&PolicyRule>
pub fn matching_rules( &self, tool_name: &str, fighter_name: &str, ) -> Vec<&PolicyRule>
Get all rules whose tool and fighter patterns match the given names. Does NOT check conditions — just pattern matching.