pub struct RuleEngine { /* private fields */ }Expand description
Deterministic registry and evaluator for declarative reasoning rules.
Rules are always evaluated in stable rule-ID order against one shared snapshot. Conclusions are written only after every rule has been evaluated, preventing earlier rules from changing later conditions in the same cycle.
Implementations§
Source§impl RuleEngine
impl RuleEngine
Sourcepub fn register(
&mut self,
rule: ReasoningRule,
) -> Result<RuleWrite, RuleEngineError>
pub fn register( &mut self, rule: ReasoningRule, ) -> Result<RuleWrite, RuleEngineError>
Registers an idempotent rule definition.
Sourcepub fn evaluate(
&self,
knowledge: &KnowledgeBase,
subject: &EntityId,
) -> Result<Vec<RuleEvaluation>, RuleEngineError>
pub fn evaluate( &self, knowledge: &KnowledgeBase, subject: &EntityId, ) -> Result<Vec<RuleEvaluation>, RuleEngineError>
Evaluates all rules without mutating the knowledge base.
Sourcepub fn evaluate_snapshot(
&self,
snapshot: &KnowledgeSnapshot,
) -> Result<Vec<RuleEvaluation>, RuleEngineError>
pub fn evaluate_snapshot( &self, snapshot: &KnowledgeSnapshot, ) -> Result<Vec<RuleEvaluation>, RuleEngineError>
Evaluates all rules against one immutable snapshot.
Sourcepub fn apply(
&self,
knowledge: &KnowledgeBase,
subject: &EntityId,
) -> Result<Vec<RuleApplication>, RuleEngineError>
pub fn apply( &self, knowledge: &KnowledgeBase, subject: &EntityId, ) -> Result<Vec<RuleApplication>, RuleEngineError>
Evaluates one decision cycle and atomically writes matched hypotheses.
All rules first evaluate in stable rule-ID order against one immutable
snapshot. Every matched hypothesis is then preflighted and committed in
one knowledge-base write transaction, so one late identity conflict
cannot leave earlier conclusions stored. Existing verifier-owned
Confirmed and Rejected states are preserved under that same write
lock, so a concurrent reasoning pass cannot reverse a verification result.
Trait Implementations§
Source§impl Clone for RuleEngine
impl Clone for RuleEngine
Source§fn clone(&self) -> RuleEngine
fn clone(&self) -> RuleEngine
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more