Other languages
The same two evaluations from Python, Node.js, Ruby, PHP, Java, shell, Rust, C# and PowerShell through the command, and from Node.js and Python through the WebAssembly module.
Every client starts the engine once, sends version, loads the payments bundle, evaluates two
requests and prints exactly this:
engine: Rule Cascade 1.1.0, bundle format 1.0.0
loaded: acme.payments.transfer 1.0.0
domestic transfer: allow
warning ORG-TRF-003 Adding a memo makes this transfer easier to reconcile.
blocked country: deny
error ORG-TRF-001 Transfers to KP are not permitted.The core of each client is one function: write a request line, read a response line, check it.
From process/client.py:
def call(self, command, **members):
self.sent += 1
line = json.dumps({"id": self.sent, "command": command, **members}, ensure_ascii=False)
try:
self.process.stdin.write(line.encode("utf-8") + b"\n")
self.process.stdin.flush()
except OSError:
fail("the engine closed its input")
answer = self.process.stdout.readline() # a whole line, however long
if not answer:
fail("the engine closed its output")
response = json.loads(answer)
if response.get("id") != self.sent:
fail("expected the response to request %d, got %r" % (self.sent, response.get("id")))
if response.get("ok") is not True:
error = response.get("error") or {}
fail("%s: %s" % (error.get("code"), error.get("message")))
return response["result"]PHP, Java, shell, Rust, C# and PowerShell follow the same shape in process/; wasm/client.mjs
and wasm/client.py run the WebAssembly module inside the client's own process.
Run them
Download and verify rcas and point a client at it with
RULE_CASCADE_ENGINE:
export RULE_CASCADE_ENGINE=$(command -v rcas)Then send it your own bundle the way the clients above do: Evaluate from another language has the protocol, request by request.
CI runs the Python, Node.js, Ruby, PHP, Java, shell and Rust clients and both WebAssembly clients
on Linux. Client.cs and client.ps1 were written against the documented behaviour of .NET and
PowerShell and have not been executed.
Step by step: Run rules from any other language.
Post-save commands
An action rule that asks the host to publish an event after a large transfer is saved - once, keyed by a deterministic idempotency key.
rcas command reference
rcas is the Rule Cascade command: it checks, compiles and evaluates rulesets, serves the engine protocol to other languages, scaffolds projects, derives rules from API schemas, finds rules in existing code, and serves the Model Context ...