A serializable boolean tree, persisted as config and consumed by
RuleRegistry.compile.
Leaves reference primitives or saved rules by id
({ type: 'ref'; id }). Branches combine children with all, any,
or not.
Primitives and saved rules share a single id namespace, so a ref
resolves to one or the other when compile runs. If the id belongs
to a registered primitive, the supplied args are bound and a
predicate is built. If it belongs to a saved rule, the saved tree
is expanded in place, any args on the outer ref are ignored at
compile time (a saved rule is already a complete tree), and
validate reports the
args-on-saved-rule diagnostic so authoring tools can prompt for
cleanup. Registering a primitive with the same id as an existing
saved rule, or vice versa, is an error.
Saved rules are loaded by the host client from its own config layer
at boot, there is no public API on RuleRegistry for
registering or listing them. A ref to an unknown id surfaces as an
unknown-ref diagnostic at compile or validate time.
all and any short-circuit during evaluation: all stops at the
first child that returns false, any at the first that returns
true. Later children are not evaluated.
A serializable boolean tree, persisted as config and consumed by RuleRegistry.compile.
Leaves reference primitives or saved rules by id (
{ type: 'ref'; id }). Branches combine children withall,any, ornot.Primitives and saved rules share a single id namespace, so a
refresolves to one or the other whencompileruns. If the id belongs to a registered primitive, the suppliedargsare bound and a predicate is built. If it belongs to a saved rule, the saved tree is expanded in place, anyargson the outerrefare ignored at compile time (a saved rule is already a complete tree), and validate reports theargs-on-saved-rulediagnostic so authoring tools can prompt for cleanup. Registering a primitive with the same id as an existing saved rule, or vice versa, is an error.Saved rules are loaded by the host client from its own config layer at boot, there is no public API on RuleRegistry for registering or listing them. A
refto an unknown id surfaces as anunknown-refdiagnostic at compile or validate time.allandanyshort-circuit during evaluation:allstops at the first child that returnsfalse,anyat the first that returnstrue. Later children are not evaluated.Example
A composite rule: "deal is won AND user is admin"
Example
Referencing a saved rule
See