Files
zen/core/engine
stefan-gorules 39916c9d18 feat: date input (#529)
* feat: declared dates as date values

- graph format:date/date-time inputs and policy date properties arrive as
  dates that keep their original text for output, string() and string
  functions
- d() keeps the instant of offset/Z strings, resolves DST gaps and accepts
  ISO forms without offset, compact, slash-separated, YYYY-MM and YYYY
- dates compare with date strings in ==, !=, <, >, in and contains, and
  concatenate with strings; deprecated date helpers accept dates
- string(date), type() reports date, and date-to-string at string inputs

* fix: close review gaps in date inputs

- parse new date formats by exact shape; keep master formats first and
  guard DST-gap and extreme-year overflows
- text-carrying dates act as strings for object keys, in-object, index,
  slice, concatenation and bool
- deprecated helpers fall back to the date instant; time() accepts dates
- schema-less child inputs receive date text; dates satisfy string
  parameters and slicing in the type checker
- convert policy input before validation so dates are parsed once;
  share rewrite helpers between graph and policy conversion

* fix: align date text, unions, references and child inputs

- every valid date exposes a text form (original or RFC3339), so string
  functions and slicing on computed dates match the type checker
- date and string types merge to string; reference ids typed as dates
  resolve through their text
- input nodes convert declared dates and hand every other converted date
  back as its original text, following combinators only for structure
- date format checks no longer allocate
2026-09-29 09:59:44 +02:00
..
2026-06-23 18:51:47 +02:00
2024-07-16 11:22:51 +02:00
2026-09-29 09:59:44 +02:00
2026-08-22 13:27:31 +02:00
2026-08-22 13:27:31 +02:00

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.

License: MIT crates.io

GoRules ZEN Engine

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.

Readable rules

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.

Graphs and documents

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_precision is 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

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.

License

MIT License