* perf(engine): run graph expressions and tables typed on the columnar path Lower most expression and table shapes found in graphs to typed programs: fallible membership, mixed-type equality, computed table fields, collect tables and first-hit collect columns, number() and type(), objects and arrays produced by expressions, index access, split text, member chains on computed values, list literals written by tables, and fields of unknown shape or object lists written by earlier nodes. Fix the typed results that differed from version 1 along the way: errors kept through contains, filters, bool() and `?? []`, missing text against missing dates, fractional division, set items written earlier in the node, oversized list indexes. * perf(engine): choose typed plans without timing and run them per distinct key Replace timing-based path choice with static rules for graphs and policies, so the same input always takes the same path. Run typed units once per distinct key with constant key parts left out, re-run one row per key when a deduplicated unit fails, fall back to the lane when a 64-row sample fails typed, and stop key sampling early on distinct data. Add faster kernels for numeric ranges, text classes, mixed-scale comparisons, bool folds, rounding, ASCII trim, legacy date text, wide decimals between nodes and table choice masks. * perf(engine): keep policy rows on the columnar path Validate date columns, dictionary properties and nested lists by column, delegate a refused block for its own rows instead of sharing every row, keep blocks whose lazy reads have no writers in one step, run declared date inputs and strict tables with empty output cells typed, and resolve references to a pool by columns. Rows whose delegated block fails are re-run on the row engine, and a resolved reference stays missing where its key is missing. Rows are shared again by a static rule when most member blocks would be delegated. * feat(expression): borrow Arrow Decimal128 and temporal buffers as columns Add Values::Decimal128 and Values::Temporal (date32, date64, timestamp, time32, time64) so Arrow buffers can be handed over without copying. Values behave exactly like the same data given as decimals or ISO text. * perf(engine): convert float and date columns once Convert f64 columns to decimals without printing them, through the new Values::Float64. Read declared policy dates once per distinct text with the version 2 parser, type declared date fields of list items, parse timestamps without a zone on the fast path, and render foreign columns only when a graph reads them. * perf(engine): validate and convert policy lists by field Convert declared dates of entity lists once per field and only when first read, validate list columns field by field, keep policy columns when every re-run row fails, and run member blocks that read their own or another list typed. * perf(engine): run policy relationships and date methods typed Run blocks on a single relationship as root blocks under the relationship's path, keeping version 1's required-input errors for every goal set. Resolve lists of references onto the pool's columns. Run date methods with fixed units as typed kernels and share one parse per date text between validation and typed programs. * perf(engine): run policy tables typed and cut per-row validation Run strict collect tables and collect tables with first-hit outputs as typed units, read optional fields that mix values with nulls as typed columns, keep selects whose cells read already demanded fields in one segment, lower powers with computed integer exponents, run membership in another list of the row typed, and keep lifted declared dates typed. Validate enums and primitive arrays without the row validator, shred lists without copying their items, and remember settled selects and table typability per plan. * perf(engine): build objects and read validity without converting columns Build objects from dictionary columns with one shared value per code and read the validity of float columns without converting them, which removes the regressions float columns had introduced on graphs that write coded text or never read a float input. * style(engine): format with cargo fmt
Rust Rules Engine
Business logic humans can read and machines can run. One copy of your rules: the owner reads it, every system runs it.
ZEN Engine is a cross-platform, open-source Business Rules Engine (BRE) written in Rust. This crate is the core: the same engine that powers the Node.js, Python, Go, Java, Kotlin and .NET bindings, available with zero FFI overhead. Decisions evaluate in microseconds and are stored as portable JSON. Loading the JSON is up to you: file system, database or service call.
Try it in the free Online Editor with a built-in simulator, or embed the open-source React JDM Editor in your own product. Learn more about the Rust rules engine on the GoRules website.
Rules that read like sentences
Conditions are written the way the business says them, in the ZEN Expression Language. The developer view is one toggle away, and the two can never drift apart: there is only one source of truth, and this engine runs it.
Rules as graphs, or as documents
Model a decision on a visual canvas of decision tables, switches, expressions, functions and reusable sub-decisions. Or write it as a policy document with prose, typed data models and tables. Both compile to the same engine and return the same answers.
To go deeper, see the Rust SDK documentation, the decision graph guide and the ZEN Expression Language reference.
Installation
[dependencies]
zen-engine = "2"
Upgrading from 0.x?
arbitrary_precisionis no longer a default feature. If you rely on arbitrary-precision number handling, enable it explicitly:zen-engine = { version = "2", features = ["arbitrary_precision"] }. Language bindings are unaffected.
Quickstart
use zen_engine::DecisionEngine;
use zen_engine::model::DecisionContent;
use serde_json::json;
#[tokio::main]
async fn main() {
let decision_content: DecisionContent =
serde_json::from_str(include_str!("./pricing-rules.json")).unwrap();
let engine = DecisionEngine::default();
let decision = engine.create_decision(decision_content.into()).unwrap();
let response = decision.evaluate(json!({
"customer": { "tier": "gold", "yearsActive": 3 },
"order": { "subtotal": 150, "items": 5 }
}).into()).await.unwrap();
println!("{}", response.result);
// => {"discount":0.15,"freeShipping":true}
}
Loaders
Attach a loader to serve decisions by key. Build one declaratively from LoaderConfig (Static, Filesystem, Zip), or construct the loader structs in zen_engine::loader directly. With a configuration, decisions are pre-loaded and pre-compiled for faster evaluations.
use zen_engine::DecisionEngine;
use zen_engine::loader::LoaderConfig;
use serde_json::json;
#[tokio::main]
async fn main() {
let loader = LoaderConfig::Filesystem { path: "./rules".to_string() }
.into_loader()
.unwrap();
let engine = DecisionEngine::default().with_loader(loader);
let response = engine.evaluate("pricing.json", json!({ "amount": 100 }).into()).await.unwrap();
println!("{}", response.result);
}
Custom backends (REST API, S3, database) implement the DecisionLoader trait. Full guides, including all loader variants and expression evaluation, are in the Rust SDK documentation.
Other platforms
- Node.js - GitHub | Documentation | npm
- Python - GitHub | Documentation | PyPI
- Go - GitHub | Documentation
- Java / Kotlin - GitHub | Documentation | Maven Central
- .NET - GitHub | Documentation | NuGet
- Swift (iOS) - GitHub | Documentation
The GoRules platform
The engine is open at the core; GoRules is the platform around it. Managed cloud, self-hosted, or embedded with no network hop. SOC 2 Type II.
Contribution
The JDM standard is growing and we need to keep tight control over its development and roadmap, as a number of companies use GoRules ZEN Engine and GoRules BRMS. For this reason we can't accept code contributions at this moment, apart from help with documentation and additional tests.