Supersedure and restart semantics#
The as <expr> clause on call and
after, and the per-fact supersedure semantics it produces.
as is the DS correlation/identity-key keyword. One concept,
two surfaces:
call ... as <expr>— call correlation, drives response-fact supersedure per [LCRS.6.2] and capture-fact supersedure per [LCCO.5].after <dur> as <expr>:— synthetic timer correlation, drives timer supersedure on re-fire.
Mental model: correlation identity drives supersedure. A new assertion of a fact with the same correlation as an existing fact retracts the prior fact. The mechanism is per-fact.
Paired with:
[LTAC] —
after-clause grammar.[LCRS] —
call ascorrelation semantics and response-fact supersedure at [LCRS.6.2].[LCCO.5] — capture-fact lifecycle.
[LSCP] —
scope activation, the lifetime of the facts an activation asserts.[LEXP] — the
as <expr>evaluation context (snapshot at activation start).
What this is not#
Not a cascade-cancellation primitive. The activation has no lifetime as a unit beyond its scope-activation facts' individual lifetimes.
Not a queueing surface.
as-supersedure replaces the prior artefact; it does not buffer.
Surface [LRST.1]#
[LRST.1.1] Both call and after admit an as <expr> clause that declares
a correlation key. A call's is [LGRA.10.1]'s call_as, after every argument
on the head line, or an as line in its block ([LGRA.10.8]). An after's
follows its duration in [LGRA.6.1]'s after_clause.
ratified — see also: LGRA.10.1, LGRA.10.8, LGRA.6.1
[LRST.1.2] The expression evaluates against the rule's LHS bindings at activation start per [LCCO.5.4]. The evaluated value becomes the synthesized fact's correlation key.
A key that evaluates to the empty String is no key: the engine must not
supersede anything for it, exactly as for a declaration with no as. The
compiler must reject an as whose expression is the literal "", with
DS_VALIDATE_AS_EMPTY_KEY. A computed key that evaluates to "" compiles and
supersedes nothing.
On a call, the engine must give a call whose key evaluates to "" the
correlation it gives a call with no as ([LCCO.3.4]), so that the call's
correlation is never empty ([LCRS.3.1]). That value is unique to the firing,
so the call supersedes nothing.
ratified — checks: tla idris×5 — see also: LCCO.3.4, LCCO.5.4, LCRS.3.1
[LRST.1.3] The colon form call ... as: "<literal>" is not
accepted. as is a control clause on the call form, parallel
to cooldown: and retain:, not a kwarg. The compiler must
reject as: with DS_VALIDATE_LEGACY_AS_COLON, naming the form
that replaces it: as followed by the expression, with no colon
([LRST.1.1]).
ratified — see also: LRST.1.1
[LRST.1.4] <expr> must evaluate to a scalar value that admits
equality. The legal types are String, Int, Float, Bool, Date,
Time, Duration and Bytes, and no other. The compiler must reject
as <expr> of any other type with DS_VALIDATE_AS_NON_EQUATABLE_TYPE. A
call's key is narrower still: a String only ([LRST.1.4.1]). A
Json value is a document, not a scalar key, so an author projects a typed
leaf first. An interval, a fact reference and an opaque value name nothing a
later firing can match as a key.
Two keys of one declaration are the same key exactly when == between them is
true. So -0.0 and 0.0 are one key; a NaN is the same key as nothing, and
supersedes nothing ([LEXP.4.2]); and two Time values are one key when they
denote the same UTC instant, whatever their offsets ([LTIM.5.2]).
ratified — see also: LEXP.4.2, LRST.1.4.1, LTIM.5.2
[LRST.1.4.1] A call's key is a String. On a call … as <expr>, <expr>
must be a String. The compiler must reject any other type, including the other
seven [LRST.1.4] admits, with DS_VALIDATE_CALL_AS_NOT_STRING, naming the
type. An after … as key keeps [LRST.1.4]'s eight types.
A call's key leaves the engine as its correlation ([LCCO.3.4]), and the
correlation is text wherever it travels: the integrator receives it, the
recording carries it ([RFCS.15.2]), and the answer's corr slot holds it and
is compared with it by equality ([LCCO.3.3]). An author who wants a number as
the key writes it as text, as "{j.n}".
ratified — see also: LCCO.3.3, LCCO.3.4, LRST.1.4, RFCS.15.2
[LRST.1.5] <expr> must be type-stable and non-nullable. If it references a
Json path that may be missing ([LNUL.8.4]), the compiler must reject the
declaration with DS_VALIDATE_AS_SOFTFAIL_EXPRESSION and a message asking the
author to provide a fallback or to project to a guaranteed-present value before
the as clause. If its type is T?, the as key is a concrete-value position
and the compiler must reject it as [LNUL.5.1] states.
The key identifies a restart across firings, so a null key would make
per-fact identity undefined rather than merely absent.
ratified — see also: LNUL.5.1, LNUL.8.4
[LRST.1.5.1] When the correlation is an interpolated string
(as "prefix-{binding}", an interpolation-eligible position per
[LGRA.2.9.6.8]), the string's type is always String — a legal
[LRST.1.4] key — but each interpolated binding is itself subject
to [LRST.1.5]: a segment that reads a nullable slot or a Json
sub-path is rejected (DS_VALIDATE_AS_SOFTFAIL_EXPRESSION). This
is stricter than a general interpolation, where a null value
renders as the empty string and compiles; a correlation key
must be non-nullable and non-absent so per-fact identity is
well defined.
ratified — see also: LGRA.2.9.6.8, LRST.1.4, LRST.1.5
Per-fact supersedure semantics [LRST.2]#
[LRST.2.1] When a fact is asserted with the same correlation key as an existing fact from the same originating clause, the prior fact retracts. Only that fact retracts, with the capture fact of a superseded response or timer ([LRST.4.1], [LRST.4.5]); the activation's other facts are unaffected.
[LRST.2.2] Supersedure scope for timers and capture facts is the triple (rule, clause-position, evaluated-key):
A re-fire of the same rule's same
after-clause-position with the same evaluated key supersedes the prior timer.A re-fire of the same rule's same
call-clause-position with the same evaluated key supersedes the prior timer of each of that call'stimeoutclauses ([LCCO.7.2]).A re-fire of the same rule's same
call-clause-position with the same evaluated key supersedes the prior capture fact (per [LRST.4]).A call's response fact ([LCRS.4.3.1]) and
CallErrorare scoped by service and evaluated key instead, whichever rule or clause position issued the call ([LCRS.6.2.1]).Two
afterclauses at different positions in the same rule with the sameasexpression do not supersede each other — different clause positions produce distinct synthetic identities.Two rules with the same
asexpression do not supersede each other — different rules produce distinct synthetic identities.
ratified — see also: LCCO.7.2, LCRS.4.3.1, LRST.4, LCRS.6.2.1
[LRST.2.3] No cascade. Supersedure of one synthesized fact does not trigger retraction of the activation's other facts, its capture fact aside ([LRST.2.1]). The activation has no lifetime as a unit; its scope-activation facts each handle their own retract triggers per [LSCP.3].
Capture-fact supersedure [LRST.4]#
[LRST.4.1] Capture facts per [LCCO.5.2] are tied to a call's
correlation. When call ... as Y is re-fired with the same
correlation, the new call's capture fact supersedes the prior
one via the same per-fact supersedure mechanism that
supersedes the response fact or CallError ([LCRS.6.2.1]). That mechanism is
keyed by correlation, not by identity: a response schema has no identity key
([LCRS.4.3.2]).
see also: LCCO.5.2, LCRS.4.3.2, LCRS.6.2.1
[LRST.4.2] On supersedure of a call's response fact or CallError
and capture fact:
The prior activation's continuation rules tied to that correlation no longer match (no response fact, no capture to join on). Their deferred actions do not fire.
The prior activation may have other scope-activation facts (other
aftertimers, etc.) that retract on their own triggers per [LRST.2.3]. Those are unaffected by this call's supersedure.
see also: LRST.2.3
[LRST.4.3] Capture facts retain their scope activation
lifecycle per [LSCP.2.4]; the supersedure path is an
additional retract trigger on top of the standard
completion-path enumeration. Both paths are idempotent per
[LSCP.3.3]; whichever fires first wins, the other is a no-op.
[LRST.4.4] An activation whose call has been superseded does not "complete" through this supersedure. The activation has no formal completion event under per-fact supersedure; its remaining scope-activation facts persist until their own triggers fire.
[LRST.4.5] An after … as clause supersedes its capture fact with its
timer. The timer fact ([LTAC.3.2]) and the capture fact ([LTAC.3.5]) of one
after clause carry the same correlation — the clause's evaluated as key —
and a new activation with that key must retract both before asserting its own
pair. This is [LRST.4.1]'s rule for a call's capture fact, on the clause that
carries the other kind of deferred body.
The pair is what makes it a rule of its own rather than a consequence of [LRST.2.1]. Superseding the timer alone leaves the prior capture fact live on a correlation the surviving follow-up joins, so one timer fires a body once per capture snapshot ever taken under that key.
An after clause with no as supersedes nothing: its correlation is unique to
the activation ([LTAC.3.5]), so there is no prior pair to find.
Supersedure commitments [LRST.6]#
[LRST.6.1] as <expr> extends to after clauses. Same
syntactic shape and supersedure semantics as call as.
[LRST.6.2] call ... as <expr> is the canonical correlation form.
The compiler refuses as: ([LRST.1.3]).
ratified — see also: LRST.1.3
[LRST.6.3] as is the DS correlation/identity-key keyword.
One concept, two surfaces. Documentation teaches "correlation
identity drives supersedure."
[LRST.6.4] Per-fact supersedure, no cascade. Each fact has its own retract trigger; the activation has no lifetime as a unit. Restates [LRST.2.3].
see also: LRST.2.3
[LRST.6.5] Supersedure scope is (rule, clause-position, evaluated-key). Cross-rule and cross-clause keys do not collide.
[LRST.6.6] Capture facts inherit as-correlation
supersedure. Per [LRST.4]. New call's capture supersedes
prior; the response fact or CallError and the capture clean up via the
same per-fact mechanism.
see also: LRST.4
[LRST.6.9] Key types are equality-comparable scalars. Per
[LRST.1.4]. Json is excluded.
ratified — see also: LRST.1.4
[LRST.6.10] Keys must be non-nullable. Per [LRST.1.5]. The
compiler rejects as <expr> whose value can be absent, as it rejects any
un-narrowed T? where a value is required ([LNUL.5.1]):
DS_VALIDATE_NULLABLE_UNNARROWED.
ratified — see also: LNUL.5.1, LRST.1.5
[LRST.6.11] Snapshot timing matches capture facts. as <expr> evaluates at activation start per [LCCO.5.4].
see also: LCCO.5.4
[LRST.6.12] Per-rule activation cancellation is not a primitive.
Per-fact supersedure covers every motivated use case; motion-light and
analogous patterns use after as.
ratified
[LRST.6.13] The engine owns activation identity. Authors do not manage activation ids; per-(rule, clause-position, key) bookkeeping ([LRST.6.5]) is what supersedure needs.
see also: LRST.6.5