Rule-level cooldown#
One rule-header modifier,
cooldown T, that gives rules first-class rate
control, and the where-condition form an on-delay
takes instead ([LCDB.3.2.3]). The author-facing grammar
is [LGRA.6.6]; this doc specifies the semantics.
Paired with:
[LGRA.6.6] — the author-facing grammar.
[LCRS.8.1] —
cooldownoncall; rule-levelcooldownuses the same word and concept.LOGICAL_FACTS— the truth-maintenance construct a logical-fact sentinel uses.
Cooldown [LCDB.3]#
[LCDB.3.1] One rule-header modifier, cooldown T, limits how often a rule
fires ([LCDB.3.2.1]). An on-delay — fire only once a match has held for T — is
not a modifier: it is a where condition on dwell ([LCDB.3.2.3]).
ratified — see also: LCDB.3.2.1, LCDB.3.2.3
Semantics [LCDB.3.2]#
[LCDB.3.2.1]
cooldown T— when this rule activation fires, suppress further fires of the same activation key for duration T. Matchescall's cooldown semantics precisely.
ratified — checks: idris×33
[LCDB.3.2.1.1] Suppression level. The
cooldown gate operates at the RHS level, not the
LHS activation level. The rule continues to activate
on every matching LHS (Rete propagation, refraction,
binding capture, all unchanged); the dispatcher's
ds-rate-allow builtin wraps the whole RHS as
(if (ds-rate-allow "<rule>" <activation-key>) then <body>). A within-cooldown activation has its RHS
short-circuited but still consumes the activation
budget — refraction tracks it as fired for the
purposes of LCRS / LCDB.5 interactions. This matters
for two observable behaviours: (a) cooldown does
not skip pattern-side side effects (capture-let
evaluation, slot reads) inside the LHS — the LHS
always runs; (b) the activation key is computed
every time the LHS matches, not lazily inside the
gate.
checks: idris×18 — see also: LCDB.5
[LCDB.3.2.3] An on-delay is a
wherecondition, not a modifier. A rule that must fire only once a match has held forTstates it on the matched fact, aswhere x.dwell >= Ton alogicalbinding ([LEXP.9.5.1]). The condition is time-dependent, so the engine re-evaluates it on every pump ([LTIM.2.4.2]) and fires on the pump at which it first holds ([LTIM.2.5.1]). If the fact is retracted or replaced beforeThas passed, the match ends and nothing fires. The engine keeps no rate state for it; the rule header has no on-delay modifier ([LCDB.5.1]).
ratified — checks: idris×3 — see also: LCDB.5.1, LEXP.9.5.1, LTIM.2.4.2, LTIM.2.5.1
Per-activation-key [LCDB.3.3]#
[LCDB.3.3.1] Cooldown is keyed by the declared key slots of
each logical fact the activation binds (per [LFAC.1.7]) — not
by every bound slot. The same rule matching different entities
cools independently — "don't spam me about the
same sensor" doesn't mean "don't tell me about a different
sensor." Keying on the declared key excludes volatile mutable
slots (a churning ts) from the cooldown key, so a payload
change does not reset the cooldown.
checks: idris×2 — see also: LFAC.1.7
[LCDB.3.3.3] Composition across bound facts. When a rule binds more than one fact, the activation key is the ordered concatenation, per bound pattern in source order, of each fact's contributing slots:
a
logicalfact contributes its declaredkeyslots. A schema whose key is ∅ (every slotmutable) contributes nothing, so a single-pattern rule on such a schema is rule-global (theAmbientTemp{ts mutable, celsius mutable}case);a
ttl/ event fact carries no identity markers ([LFAC.1.7.6]) and contributes nothing on its own. A rule that binds one and carries a rate modifier must declare its key withby:([LCDB.3.3.4]);when no bound fact contributes a slot, the key is empty and the cooldown is rule-global.
ratified — checks: idris×5 — see also: LCDB.3.3.4, LFAC.1.7.6
[LCDB.3.3.4] by: declares the activation key, and where a
non-logical fact is bound it is required. A rule header may carry one
by: modifier ([LCDB.5.1]). When it is written, the activation key is
what it names — an ordered tuple of <binding>.<slot> paths, or the single
global key by: none — for the cooldown, in place of
[LCDB.3.3.3]'s composition.
A rule that carries a rate modifier and binds, in a positive pattern, a fact of
any lifecycle other than logical must carry one, because no such fact has
identity slots ([LFAC.1.7.6]): omitting it is DS_VALIDATE_RATE_KEY_REQUIRED. A rule binding
only logical facts may omit it and takes [LCDB.3.3.3]'s key. A path naming
a binding the rule does not declare, or a slot the bound schema does not
have, is DS_VALIDATE_RATE_KEY_BAD_PATH.
Why it is required rather than defaulted. A ttl fact has no declared
identity ([LFAC.1.7.6]), and both available defaults are wrong in a way the
author cannot see. Every slot gives an event carrying a ts
or any other per-event value a tracker of its own, so the cooldown never
suppresses anything; that is [LCDB.3.3.1]'s churn failure, moved from
mutable slots to event payloads. No slots at all quietly makes the rule
single-windowed across every entity, which is the opposite of what
[LCDB.3.3.1] says rate control is for. The declaration is one line and it is
the only form that says which the author meant, which is the same reason a
series on a schema with no identity must name by: ([LSER.7.6.1]).
ratified — checks: idris×4 — see also: LCDB.3.3.1, LCDB.3.3.3, LCDB.5.1, LFAC.1.7.6, LSER.7.6.1
Rule-header rate modifiers [LCDB.5]#
[LCDB.5.1] A rule header's modifiers are the rate modifier and its key.
The tail-side rule_modifier* list of [LGRA.6.1], whose productions are the
grammar's, admits exactly two members: cooldown, the rate modifier
([LCDB.3.2]), and by:, the activation key it is keyed on ([LCDB.3.3.4]).
ratified — see also: LCDB.3.2, LCDB.3.3.4, LGRA.6.1
[LCDB.5.2] The grammar permits any number of rate_mods in any
order. The compiler rejects:
[LCDB.5.3] Duplicate
cooldown(more than one on the same rule) (DS_PARSE_DUP_RATE_MOD).
[LCDB.5.5] Negative durations (
DS_VALIDATE_RATE_NEGATIVE_DURATION).
ratified
[LCDB.5.6] cooldown 0_s is legal but degenerate (a no-op). Rule body, pattern grammar, and
action grammar are unchanged.
ratified
[LCDB.5.7] See [LGRA] for the author-facing grammar.
Cooldown commitments [LCDB.7]#
[LCDB.7.1] Per-activation-key cooldown is the default. The key is the
by:modifier where the rule carries one, and otherwise the declaredkeyslots of thelogicalfacts it binds — never every bound slot ([LCDB.3.3.3], [LCDB.3.3.4]).
ratified — see also: LCDB.3.3.3, LCDB.3.3.4
[LCDB.7.2] Suppression is keyed on
(rule, activation_key), and there is noglobalmodifier. The grammar offers no rule-wide variant to write.⚠ Rule-wide suppression is nevertheless REACHABLE, with no modifier and no author opt-in. A schema with no
keyslot — the default for a schema written without identity in mind — gives every activation the empty activation key, so(rule, [])is one window for the whole rule.The grammar claim holds. No
globalmodifier exists, so nothing here is spellable; what an author gets instead is the behaviour arriving as a consequence of the schema they wrote. The logical-fact sentinel is a way to express rule-wide suppression deliberately, and not the only way to reach it.The behaviour stands, and because an author who never chose a key never chose a rule-wide window either, the compiler says so ([LCDB.7.9]).
see also: LCDB.7.9
[LCDB.7.9] A rule-wide window is warned about. When
cooldownsits on a rule whose activation key is empty ([LCDB.3.3.3]) — every bound fact contributes nothing, so the rule has one window for all its activations ([LCDB.7.2]) — the compiler must emit the warningDS_VALIDATE_RULE_WIDE_RATE_WINDOW, naming the rule. It is a warning, not a refusal: the program compiles and the rule-wide window is what it gets.
ratified — see also: LCDB.3.3.3, LCDB.7.2
[LCDB.7.3] Cold-start across engine restart. Cooldown state does not persist; matches refraction.
[LCDB.7.5] Cooldown is orthogonal to firing order. A rule's ordinal orders firing within a pump ([LDET.5.1]); cooldown suppresses firing across pumps.
see also: LDET.5.1
[LCDB.7.6]
cooldown 0_sis legal. Degenerate (a no-op) but not an error. Restates [LCDB.5.6].
ratified — see also: LCDB.5.6
[LCDB.7.8] Compile-time rejection of duplicates. The grammar accepts
rate_mod*; the compiler must reject a duplicatecooldownon the same rule, withDS_PARSE_DUP_RATE_MOD, naming the rule.
ratified
Out of scope [LCDB.8]#
[LCDB.8.1] Cross-rule rate sharing. "These three rules share one budget of ten alerts per hour" — a different feature (budget buckets, not cooldowns). Out of scope here.
[LCDB.8.2] Time-of-day gating. "Only fire between 8am and 10pm" — a different feature; addressed by a
whereclause overnow().
[LCDB.8.3] Exponential backoff. "First retry after 1_s, then 2_s, then 4_s." A different feature: cooldown is a fixed window, not a stateful sequence.
[LCDB.8.4] Rule-wide suppression. Not provided; see [LCDB.7.2].
see also: LCDB.7.2