1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
//! # Rust Rule Engine v0.19.0 - Parallel Execution Edition
//!
//! A high-performance rule engine for Rust with **Parallel Execution (38x faster)**, **RETE-UL algorithm**,
//! **CLIPS-inspired features**, **Plugin System**, and **GRL (Grule Rule Language)** support.
//! Features multi-threaded execution, complete feature parity, and production-ready performance.
//!
//! ## Features
//!
//! - **🔌 Plugin System**: Modular plugin architecture with lifecycle management
//! - **🛠️ Built-in Plugin Suite**: 44+ actions & 33+ functions for common operations
//! - **🔥 GRL Support**: Full Grule-compatible syntax
//! - **🎯 Method Calls**: `$Object.method(args)` and property access
//! - **📊 Knowledge Base**: Centralized rule management with salience
//! - **💾 Working Memory**: Facts system for complex object interactions
//! - **⚡ High Performance**: Optimized execution with cycle detection
//! - **🔄 Arithmetic**: Complex calculations in conditions and actions
//! - **🛡️ Type Safety**: Rust's type system ensures runtime safety
//!
//! ## Quick Start with Plugins
//!
//! ```rust
//! use rust_rule_engine::*;
//!
//! fn main() -> Result<()> {
//! // Create Knowledge Base and Engine
//! let kb = KnowledgeBase::new("Demo");
//! let mut engine = RustRuleEngine::new(kb);
//! let mut facts = Facts::new();
//!
//! // Set up data
//! facts.set("user.age", Value::Number(25.0));
//! facts.set("user.premium", Value::Boolean(false));
//!
//! // Define GRL rule
//! let rule = r#"
//! rule "PremiumUpgrade" salience 10 {
//! when
//! user.age >= 18 && user.premium == false
//! then
//! user.premium = true;
//! user.discount = 0.1;
//! }
//! "#;
//!
//! // Parse and add rule to knowledge base
//! let rules = GRLParser::parse_rules(rule)?;
//! for r in rules {
//! engine.knowledge_base().add_rule(r)?;
//! }
//!
//! // Execute with facts
//! let result = engine.execute(&facts)?;
//! println!("User premium status: {:?}", facts.get("user.premium"));
//!
//! Ok(())
//! }
//! ```
//!
//! Built-in Plugin Suite provides comprehensive functionality for common operations:
//!
//! - **String Utilities**: 8 actions, 5 functions for text manipulation
//! - **Math Operations**: 10 actions, 6 functions for calculations
//! - **Date/Time**: 8 actions, 7 functions for temporal operations
//! - Actions: CurrentDate, CurrentTime, FormatDate, ParseDate, AddDays, AddHours, DateDiff, IsWeekend
//! - Functions: now, today, dayOfWeek, dayOfYear, year, month, day
//!
//! ### Validation (8 actions, 6 functions)
//! - Actions: ValidateEmail, ValidatePhone, ValidateUrl, ValidateRegex, ValidateRange, ValidateLength, ValidateNotEmpty, ValidateNumeric
//! - Functions: isEmail, isPhone, isUrl, isNumeric, isEmpty, inRange
//!
//! ### Collections (10 actions, 9 functions)
//! - Actions: ArrayLength, ArrayPush, ArrayPop, ArraySort, ArrayFilter, ArrayMap, ArrayFind, ObjectKeys, ObjectValues, ObjectMerge
//! - Functions: length, contains, first, last, reverse, join, slice, keys, values
//!
//! // Create engine
//! let mut engine = RustRuleEngine::new(kb);
//!
//! // Create facts
//! let facts = Facts::new();
//! let user = FactHelper::create_user("john", 25, "john@email.com", "US", false);
//! facts.add_value("User", user)?;
//!
//! // Execute rules
//! let result = engine.execute(&facts)?;
//! println!("Rules fired: {}", result.rules_fired);
//!
//! Ok(())
//! }
//! ```
/// Rule execution engine and related components
/// Error types and result handling
/// Rule parsing and language support
/// Built-in plugin system for extended functionality
/// Streaming rule engine for real-time event processing
/// Backward chaining (goal-driven reasoning) - requires 'backward-chaining' feature
/// Core type definitions for values, operators, and actions
/// RETE module for rule evaluation
/// Expression evaluation (arithmetic operations)
// Re-export core types for easy access
pub use ;
pub use ;
// Re-export Grule-style components
pub use ;
pub use ;
pub use KnowledgeBase;
pub use ;
// Re-export parsers
pub use GRLParser;
/// Builder pattern for creating a RustRuleEngine with various configurations