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
// Project: hyperi-rustlib
// File: src/expression/mod.rs
// Purpose: CEL expression evaluation for DFE components
// Language: Rust
//
// License: FSL-1.1-ALv2
// Copyright: (c) 2026 HYPERI PTY LIMITED
//! CEL expression evaluation — compile, evaluate, validate.
//!
//! Provides a DFE-profile-restricted CEL expression evaluator built on the
//! [`cel_interpreter`] crate. Both Python (via `common-expression-language`
//! PyO3 bindings) and Rust use the **same** underlying Rust crate, ensuring
//! identical parsing and evaluation semantics across all DFE components.
//!
//! # DFE Expression Profile
//!
//! Only a high-performance subset of CEL is allowed:
//!
//! | Category | Examples |
//! |----------|---------|
//! | Comparison | `==`, `!=`, `<`, `<=`, `>`, `>=` |
//! | Logical | `&&`, `\|\|`, `!` |
//! | Membership | `in` |
//! | String | `contains()`, `startsWith()`, `endsWith()` |
//! | Existence | `has()` |
//! | Size | `size()` |
//! | Ternary | `? :` |
//! | Type casts | `int()`, `double()`, `string()`, `bool()` |
//! | Arithmetic | `+`, `-`, `*`, `/`, `%` |
//!
//! **Restricted (blocked by default, opt-in via [`ProfileConfig`]):**
//! - Regex: `matches()` — unbounded cost per record
//! - Iteration: `map()`, `filter()`, `exists()`, `all()` — O(n) per collection
//! - Time: `timestamp()`, `duration()` — ClickHouse handles natively
//!
//! # Usage
//!
//! ```rust
//! use hyperi_rustlib::expression::{compile, evaluate, evaluate_condition, validate};
//! use std::collections::HashMap;
//! use serde_json::json;
//!
//! // Validate (returns errors list, empty if valid)
//! assert!(validate(r#"severity == "critical""#).is_empty());
//!
//! // One-shot evaluation
//! let mut data = HashMap::new();
//! data.insert("amount".into(), json!(15000));
//! let result = evaluate("amount > 10000", &data).unwrap();
//! assert_eq!(result, true.into());
//!
//! // Boolean condition (missing fields → false)
//! assert!(!evaluate_condition(r#"severity == "critical""#, &HashMap::new()));
//!
//! // Compile for hot-path reuse
//! let program = compile("score > threshold").unwrap();
//! // ... program.execute(&context) per record
//! ```
//!
//! See `dfe-engine/docs/EXPRESSIONS-CEL.md` for the full profile specification.
pub use ;
pub use ;
pub use ;