Skip to content

Repository files navigation

Go 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 Go Reference

GoRules ZEN Engine

ZEN Engine is a cross-platform, open-source Business Rules Engine (BRE) written in Rust with native Go bindings, alongside Node.js, Python, Java, Kotlin and .NET. 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. Learn more about the Go 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 Go SDK documentation, the decision graph guide 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.

Installation

go get github.com/gorules/zen-go/v2

Quickstart

package main

import (
	"fmt"
	"os"
	"path"

	zen "github.com/gorules/zen-go/v2"
)

func readTestFile(key string) ([]byte, error) {
	filePath := path.Join("test-data", key)
	return os.ReadFile(filePath)
}

func main() {
	engine := zen.NewEngine(zen.EngineConfig{Loader: zen.Loader(readTestFile)})
	defer engine.Dispose() // Call to avoid leaks

	output, err := engine.Evaluate("rule.json", map[string]any{})
	if err != nil {
		fmt.Println(err)
	}

	fmt.Println(output)
}

Loader Configurations

EngineConfig.Loader accepts either a loader callback wrapped in zen.Loader (as above) or a loader configuration of a known type. With a configuration, decisions are pre-loaded and pre-compiled at engine creation for faster evaluations.

engine := zen.NewEngine(zen.EngineConfig{Loader: zen.FilesystemLoader{Path: "test-data"}})

engine := zen.NewEngine(zen.EngineConfig{Loader: zen.StaticLoader{
	Content: map[string]json.RawMessage{"rule.json": ruleJson},
}})

engine := zen.NewEngine(zen.EngineConfig{Loader: zen.ZipLoader{Bytes: zipBytes}})

If the loader configuration is invalid (e.g. corrupted zip bytes), the error is returned by the first call to Evaluate, GetDecision or CreateDecision.

The same callback pattern works for loading from a REST API, S3, a database, or anywhere else. Full guides, including multi-decision graphs and batch evaluation, are in the Go 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.

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 Go
linux-x64-gnu ✔️
linux-arm64-gnu ✔️
darwin-x64 ✔️
darwin-arm64 ✔️
win32-x64-msvc ✔️

We do not support linux-musl currently.

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

About

Open-source business rules engine for Go

Resources

Stars

172 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages