stefan-gorules c26c3565ac perf: typed columnar (#581)
* 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
2026-11-27 10:51:31 +01:00
2026-11-27 10:51:31 +01:00
2023-04-06 16:57:03 +02:00
2026-11-21 13:38:43 +01:00
2026-03-17 16:48:09 +01:00
2023-03-29 22:14:37 +02:00
2026-08-20 19:06:58 +02:00

ZEN 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 npm PyPI

GoRules ZEN Engine

ZEN Engine is a cross-platform, open-source Business Rules Engine (BRE) written in Rust, with native bindings for Node.js, Python, Go, Java, Kotlin and .NET, plus iOS and Android packages. Decisions evaluate in microseconds, run identically on every platform, 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.

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 on the decision model and each node type, see the JDM documentation and the ZEN Expression Language reference.

What's new in 2.0

Version 2.0 is the first stable release of the new engine line:

  • Policy documents: model decisions as readable documents with typed data models, expressions, decision tables, match blocks and assertions. Policies compile to the same engine as graphs and return the same answers.
  • Workspace analysis: static type checking across policies and graphs. Type flow, exhaustiveness checking, write-conflict detection and precise diagnostics, all available before anything runs.
  • Per-column collect: decision table output columns can collect across all matching rows (tags[]) while the rest of the table stays first-match.
  • Pre-compiled engine: decisions are parsed and compiled once at load; evaluation is allocation-light and repeat-safe.
  • Hardened runtime: out-of-range numbers, arithmetic overflow and malformed inputs return errors or nulls instead of crashing the process.
  • Unified bindings: configurable loaders, batch evaluation and consistent error envelopes across Node.js, Python, Go and FFI consumers.

Important

Migrating from 0.x (Rust crates): arbitrary_precision is no longer enabled by default in zen-engine, zen-expression, zen-types and zen-tmpl. If you rely on arbitrary-precision number handling, add features = ["arbitrary_precision"] to your dependency. Bindings (Node.js, Python, C, UniFFI) are unaffected, they opt in automatically.

Quickstart

Rust

[dependencies]
zen-engine = "2"
use serde_json::json;
use std::sync::Arc;
use zen_engine::model::DecisionContent;
use zen_engine::DecisionEngine;

async fn evaluate() {
    let decision_content: DecisionContent =
        serde_json::from_str(include_str!("jdm_graph.json")).unwrap();
    let engine = DecisionEngine::default();
    let decision = engine.create_decision(Arc::new(decision_content)).unwrap();

    let result = decision.evaluate(json!({ "input": 12 }).into()).await;
}

Node.js

npm i @gorules/zen-engine
import { ZenEngine } from '@gorules/zen-engine';
import fs from 'fs/promises';

const content = await fs.readFile('./jdm_graph.json');
const engine = new ZenEngine();

const decision = engine.createDecision(content);
const result = await decision.evaluate({ input: 15 });

Python

pip install zen-engine
import zen

with open("./jdm_graph.json", "r") as f:
    content = f.read()

engine = zen.ZenEngine()

decision = engine.create_decision(content)
result = decision.evaluate({"input": 15})

Full guides, including loaders for multi-decision graphs and batch evaluation:

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.

AI that builds rules, and stays reviewable

An AI copilot and MCP server that edits rules, runs tests and explains decisions. It never deploys. Releases stay with your reviewers.

GoRules AI

Promote like a release, run like a binary

A release moves from testing to staging to production untouched. Approvals, instant rollback, and a paper trail for every change.

Governance

Prove it before it ships

Scenario suites run on every change, coverage is measured against decision paths, and every answer comes with a replayable trace.

Testing

Support matrix

Arch Rust Node.js Python Go Java / Kotlin .NET
linux-x64-gnu ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
linux-arm64-gnu ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
darwin-x64 ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
darwin-arm64 ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
win32-x64-msvc ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
linux-x64-musl ✔️ ✔️ ❌ ❌ ❌ ❌
linux-arm64-musl ✔️ ✔️ ❌ ❌ ❌ ❌
linux-s390x ✔️ ❌ ❌ ❌ ✔️ ❌
wasm32 (WASI) ✔️ ✔️ ❌ ❌ ❌ ❌

Mobile: Swift (iOS XCFramework) and Android (AAR) packages are published from the same core via UniFFI.

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

S
Description
Open-source Business Rules Engine for your Rust, NodeJS, Python, Go, Java, C#, Kotlin (JVM), Kotlin (Android) and Swift (iOS) applications.
Readme MIT
26 MiB
Languages
Rust 92.9%
JavaScript 4.3%
TypeScript 0.7%
Python 0.5%
Java 0.4%
Other 1.2%