Conformance suite
A runtime conforms to Rule Cascade 1.0 when it passes the cases in this directory for the level it claims. Every runtime in this repository runs exactly these files, on every operating system.
A runtime conforms to Rule Cascade 1.0 when it passes the cases in this directory for the level it claims. Every runtime in this repository runs exactly these files, on every operating system.
| File | Cases | Level | What it pins down |
|---|---|---|---|
expressions.json | 499 | evaluator | Every operator: results, type errors, laziness, decimal arithmetic, dates, portable patterns, functions, custom operators, the limits of 4.7 |
bundles/*.bundle.json | 5 | evaluator | The compiled form of each fixture: what an evaluator loads. The driver also loads each client manifest on its own and repeats the client golden tests |
rulesets.json | 5 fixtures | both | Evaluator: the 66 golden tests embedded in the fixtures, run from the bundles. Compiler: checksum, bundle checksum and client manifest of each fixture |
evaluations.json | 1000 | evaluator | Seeded random requests with the complete expected result, including the order of findings and effects |
load-errors.json | 191 | compiler | Each load failure and its error code, plus loads that must succeed. Each case is a JSON Merge Patch on a base parent and child |
protocol.json | 88 | engines offered as a program | The JSON Lines engine protocol: framing, ids, error codes, requests nested too deeply |
fixtures/ | The example contracts and sources/ as JSON, so no runtime needs a YAML parser to run the suite | ||
sources/ | Rulesets that exist only for this suite: conflicts, ordering, failing closed |
Two ways to run it
In process. Each runtime has a test that reads these files directly:
python tools/rulecheck.py conformance # Python reference
npm test -w @yarlisaisolutions/rule-cascade # TypeScript
make java # Java, no Maven needed
make go # GoOver the engine protocol. One driver certifies any engine in any language, as long as it speaks the JSON Lines protocol of specification section 13:
python tools/rulecheck.py conformance --engine "rule-cascade engine --conformance-operators"
python tools/rulecheck.py conformance --engine "node packages/typescript/dist/cli.js engine --conformance-operators"This is the quickest way to bring up a new runtime: implement the protocol, point the driver at it, and fix what it reports.
The conformance operators
Every runner registers three custom operators. They exist to test the custom-operator mechanism and are small enough to write in any language in a few minutes.
| Operator | Arguments | Result |
|---|---|---|
x-test-reverse | one string | The string with its code points in reverse order. Fails (throws) for anything that is not a string |
x-test-sum | any number of numbers | Their sum as IEEE 754 doubles, added left to right starting from zero. Fails (throws) for anything that is not a number, booleans included |
x-luhn | one value | true when the value is a string of at least two ASCII digits whose Luhn checksum is valid; false for everything else, including non-strings |
Writing a runner for a new runtime
- Expressions. For each case evaluate
exprwith the roots inenv, the function table infunctionsand the conformance operators registered. Expectexpect, or an evaluation error whenerroristrue. Compare numbers numerically and everything else by type and value. - Bundles and golden tests (evaluator). Read each file in
rulesets.json>bundles. Run thetestsof the matching document indocuments: decision, the exact set of finding rules, every listed member of each expected finding against some finding of that rule, each listed effect as a subset match, and the command names in order. A test'sgivenplus itsentityandoperationis the request;channeldefaults toserver. - Evaluations. For each case evaluate
requestagainst the bundle named byrulesetonchannel, dropdetailfrom findings, and require deep equality withresult. - Rulesets (compiler). Load each document in
documentswith the others as its registry andschemaDocumentsanswering entity$reflookups. Comparechecksum, the SHA-256 of the canonical JSON of the bundle (bundleChecksum), the client manifest's rule ids and its param names. The bundle you produce must equal the published one. - Load errors (compiler). Apply the
parentandchildmerge patches tobase, load the child with both as the registry, and require thatexpectErroris among the reported codes, or that the load succeeds when it isnull.
Where the expected values come from
Expression, load-error and protocol expectations are written by hand and checked against the
reference when they are added. Checksums, bundles and the evaluation corpus are produced by the
reference implementation (python tools/rulecheck.py sync), so they prove that runtimes agree with
the reference, not that the reference is right. The golden tests and the hand-written cases are what
tie the reference to the specification.
Rendered from conformance/README.md in the repository. Edit it there.
React example
A transfer form driven entirely by the client manifest of examples/contracts/payments-transfer.ruleset.yaml.
Contributing
The conformance suite is the specification. A change to behaviour changes the specification, the reference implementation, the conformance cases and every runtime, in one pull request.