Compiled engine only; the interpreted engine keeps legacy traces. The interpreted graph, policy and function code is unchanged from release/2.2: asked for a trace (true, v1 or legacy) it returns its legacy trace, never converts to v1, and ignores now, timezone and seed. - trace format v1 inside the engine (compiled/trace), public as zen_engine::trace: convert (legacy to v1), restore (v1 to legacy), inspect and redact, with the native encoder and policy writer, and TraceFormat, TraceDocument, PolicyTrace and TraceBatch; no separate crate - TraceFormat option (off, v1, legacy) replacing EvaluationTraceKind on every evaluation path; on the compiled engine legacy traces are restored from v1 - native TraceCollector for single-row, batch and columnar evaluation: a static template per compiled graph and typed facts pushed by the engine (rule hits, switch branches, expression results, sub-decision and loop levels), written as v1 without a legacy map - native policy writer for executions, members, reads, writes and absence markers - engine glue under compiled/ (compiled/trace/mod.rs, compiled/pinning.rs); workspace request, result and error types take the trace format and the policy trace as type parameters defaulting to the legacy types, with public aliases for TraceFormat and PolicyTrace; the response trace enum gains V1 and its policy variant holds a PolicyTrace - pinned evaluation context on the compiled engine: now, timezone and seed options, one clock read per evaluation and per batch, per-row random streams (row i draws from row_seed(seed, i)) in every batch and columnar path, Date and Math.random pinned in compiled function nodes; evaluatedAt, timezone and seed in the envelope - format additions: result rows for repeated keys, $redacted and $omitted with truncated, reserved context, requires flags - now, timezone, seed and trace format options in the Node, Python, C and uniffi bindings - golden tests: compiled v1 and legacy restore to the base traces for every spec case, interpreted variants return legacy traces equal to the base for any trace option, native and convert agree, batch and columnar rows equal single rows, timing stress, pinned and random-stream tests, and the interpreted engine ignores pinning; trace API, damaged-input, POC fixture (tests/fixtures/trace) and corpus tests, and the trace_corpus example for the POC cross-check
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.