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.

Example

A composite rule: "deal is won AND user is admin"

const rule: Rule = {
type: 'all',
rules: [
{ type: 'ref', id: 'limetech.deal-status', args: { status: 'won' } },
{ type: 'ref', id: 'limetech.is-admin' },
],
};

Example

Referencing a saved rule

const rule: Rule = {
type: 'not',
rule: { type: 'ref', id: 'mycorp.high-value-deal' },
};

See