Rule Cascade
Examples

Batch

Evaluate a file of records against one compiled bundle, in process or through one engine process.

A batch job evaluates each record on the server channel before writing anything. Two forms, both run against the published bundle conformance/bundles/acme.payments.transfer.bundle.json, which is the compiled form of the payments contract:

rules = RuleSet.from_bundle(json.loads(Path(bundle_path).read_text(encoding="utf-8")))
now = "2026-10-03T00:00:00Z"            # one clock for the whole run: results are reproducible

for number, line in enumerate(records, start=1):
    result = rules.evaluate({
        "entity": "Transfer",
        "operation": "create",
        "data": json.loads(line),
        "actor": {"id": "batch-import", "roles": ["system"]},
        "ctx": {"now": now},
    })

The complete script, its input and its verified output are in the batch processing playbook.

For throughput, the engine clients README has the measurements: about 0.14 ms per evaluation with one command process kept alive (about 7,000 per second), against 3.4 ms when a process is started per request. Run a pool of processes, one request in flight each, for parallel work.

A runnable version is in examples/batch: a script that streams a CSV or JSON Lines file through the engine protocol of the Python, TypeScript or Go engine and writes one decision per record, with a sample input and tests that CI runs on every push.

Source: site/content/docs/examples/batch.mdx