a rule engine · five example rules · one 8-bit machine
A rule is a Weft-8 program with a contract: the caller puts inputs in the ports, the rule writes one byte — pass, flag or stop. Twenty lines, no model, no inference, and a machine that cannot reach a file, a network or a page. If a rule matters enough to argue about, it matters enough to be readable.
IN IN0 MOV R1, R0 LDI 2 MOV R2, R0 CMP R1, R2 JL fine IN IN1 CMP R1, R2 JL fine LDI 2 ; stop OUT VERDICT
Three properties that a rules engine in a general-purpose language struggles to promise, and that this one can state plainly.
A rule is twenty lines you can read aloud. No callbacks, no hidden state, no library deciding what "and" means.
The machine has a step limit and 27 opcodes, none of which touch a file, a network or a page. A runaway rule stops and says so.
Every rule ships its cases, and the test suite runs them on the real machine — including the case where the comparison is flipped, to prove the test bites.
The limits, stated: this machine compares signed bytes, so an input above 127 reads as negative — every rule here says so where it matters. And the four rules shipped are examples of the pattern, not clinical guidance.
Inputs at 0xD0–0xD3, verdict at 0xD7. That is the
whole interface — the same in the browser, in a test, and in any app that adopts the kit.
weft8.js and rules.js, copied in. No build
step, no dependency, no network.weft8.js from
app-jacquard, byte for byte the same engine.the weft-8 family — one machine, seven faces
Every one of these runs the same engine — weft8.js from the Loom, byte for byte. Learn it once and you have learned all seven.