use crate::forward::Substitution;
use crate::RuleAtom;
use std::collections::HashMap;
use super::functions::NodeId;
#[derive(Debug, Clone, PartialEq)]
pub struct Token {
pub bindings: Substitution,
pub tags: Vec<String>,
pub facts: Vec<RuleAtom>,
}
impl Token {
pub fn new() -> Self {
Self {
bindings: HashMap::new(),
tags: Vec::new(),
facts: Vec::new(),
}
}
pub fn with_fact(fact: RuleAtom) -> Self {
Self {
bindings: HashMap::new(),
tags: Vec::new(),
facts: vec![fact],
}
}
}
#[derive(Debug, Clone)]
pub enum ReteNode {
Root,
Alpha {
pattern: RuleAtom,
children: Vec<NodeId>,
},
Beta {
left_parent: NodeId,
right_parent: NodeId,
join_condition: JoinCondition,
children: Vec<NodeId>,
},
Production {
rule_name: String,
rule_head: Vec<RuleAtom>,
parent: NodeId,
},
}
#[derive(Debug, Clone)]
pub struct ReteStats {
pub total_nodes: usize,
pub alpha_nodes: usize,
pub beta_nodes: usize,
pub production_nodes: usize,
pub total_tokens: usize,
}
#[derive(Debug, Clone)]
pub struct EnhancedReteStats {
pub basic: ReteStats,
pub total_beta_joins: usize,
pub successful_beta_joins: usize,
pub join_success_rate: f64,
pub memory_evictions: usize,
pub peak_memory_usage: usize,
pub enhanced_nodes: usize,
}
#[derive(Debug, Clone, Default)]
pub struct JoinCondition {
pub constraints: Vec<(String, String)>,
pub filters: Vec<String>,
}