Firing order#
The order#
Total order#
When more than one activation matches at one clock instant, they fire by:
the rule’s source order;
within one rule, activation-creation order.
The same event trace in two conforming engines gives the same activation order. The order depends on the inputs, so it is not readable from source text alone.
The mechanism is at Agenda and actions and Determinism.
Source order#
Within a file, the rule written first fires first. Across files, the order is import-graph topological order, leaf libraries first.
(Spec: [LDET.5.4])
Creation order#
Among activations of one rule, a match that completed earlier fires first. A match completes when the last of its facts enters working memory, and a replaced fact enters anew.
Matches that complete together, from one assertion, order lexicographically by their facts, pattern by pattern from the first, each fact ranked by when it entered working memory.
(Spec: [LDET.5.5])
Blocked matches#
A match held back by a negated condition keeps its place. When released, it fires where the time it first completed puts it, not as a new match.
(Spec: [LDET.5.9])
Removal order#
One step that removes several things removes them in this order, and everything they produce follows it:
Removed |
Order |
|---|---|
facts |
when each entered working memory |
facts a TTL sweep expires |
deadline, earliest first, then when each entered working memory |
cache entries |
when each entry’s key was last set |
(Spec: [LDET.5.11])