Error-handling meta-policy#

How DS handles errors: the four error-handling policies, and which one a feature picks.

Every feature that surfaces error behaviour picks exactly one of the four policies below based on a decision tree. The policies are orthogonal — a feature doesn't mix-and-match, and the choice is made once at design time based on what the error means and when it surfaces.

What this is not#

  • Not a catalogue of error codes. Specific codes live with the feature that emits them ([LCRS], [LHYD], etc.).

  • Not an implementation spec. How the runtime delivers each policy is runtime-docs territory.

  • Not a runtime-error taxonomy. The language commits to the behavioural surface; the runtime decides internal representations.


The dispositions [LERR.1]#

One axis, ordered by how much execution is abandoned. A feature picks exactly one rung, and the rung says what the condition costs:

Disposition

Abandoned

1

Compile error ([LERR.1.1])

nothing — the program never runs

2

Bounds refusal ([LERR.1.5])

nothing — the operation does not happen

3

Errors-as-values ([LERR.1.2])

nothing — the error is ordinary data

4

Absence ([LERR.1.3])

the expression; the rule does not fire

5

TypeError ([LERR.1.4])

the activation

6

ComputationError ([LERR.1.4])

the activation

7

EngineError ([LERR.1.4])

the tier

Every rung tells someone, so that is not what varies. A compile error reaches the author; a bounds refusal returns DS_ERR_CONTRACT_BREACH to the caller ([RTCT.7.2]); an error-as-value is a fact rules match on; rungs 5 and 6 take all three fault surfaces — record the event, assert the fault fact, invoke the integrator callback ([RFCS.21.1], [LERR.9.1]) — and rung 7 takes the first and the last, because the tier it halts has no working memory to assert into. What varies is the cost.

Rungs 5 and 6 tie on cost and differ in why, which is the whole reason they are separate kinds rather than one: a consumer needs to know whether the data was wrong or the computation had no answer. Rungs 2 and 3 also tie at nothing, and are ordered by whether the caller or the program is the one that learns.

Rungs 4–7 are the five vocabularies of the absent-value and fault model; rungs 1–3 are the ones that model does not reach, because they are not faults.

checks: alloy×2 k — see also: LERR.1.1, LERR.1.2, LERR.1.3, LERR.1.4, LERR.1.5, LERR.9.1, RFCS.21.1, RTCT.7.2

Compile error — rung 1 [LERR.1.1]#

[LERR.1.1.1] When. The error is an author-declared static constraint the compiler can check before runtime.

[LERR.1.1.2] Examples from the spec:

  • [LERR.1.1.3] Capability gating: using a construct the program's settings forbid ([LDIA.3.4.2]).

see also: LDIA.3.4.2

  • [LERR.1.1.4] Schema validation: emit X logical where X is declared ttl ([LFAC]).

ratified

  • [LERR.1.1.5] Type mismatch on a typed slot: s.state > 30 where s.state is declared String ([LEXP]).

ratified

  • [LERR.1.1.6] Missing cooldown: on a call ([LCRS]).

ratified

  • [LERR.1.1.7] schema: references an adapter schema not in the manifest's hydrates: list ([LHYD]).

Deferred: not binding in this edition.

  • [LERR.1.1.8] use names an unknown dialect or capability, or resolves to settings that break a fundamental constraint ([LDIA.3]).

ratified — see also: LDIA.3

  • [LERR.1.1.9] Cycle in the rule dependency graph — rules that emit facts feeding back into their own LHS, or rules that defeat each other through negation ([LCYC]).

[LERR.1.1.10] Shape. Hard compile failure with source location, specific message, and where available a refactor hint or a list of valid alternatives. Per [LDIA.5] for capability errors; per [LCRS] for dispatch errors; feature-specific otherwise.

see also: LDIA.5

[LERR.1.1.11] Criterion. If the compiler can prove the problem at compile time from information it has (ruleset source + manifests + dialect), it's a compile error. No lazy-validation opt-out unless the manifest is intrinsically dynamic (runtime-discovered adapter schemas per [LADP]).

ratified

Bounds refusal — rung 2 [LERR.1.5]#

When. A declared cap would be exceeded. In this edition that is a cap the program declares, a String slot's capacity ([LSTR.11.3]) or a series' capacity ([LSER.13.14]), or a cache bound the integration set ([LSTO.4.7.5]); under a realtime contract it is also any of the caps of [RTCT.7.1]. The cap is the author's or integrator's own declaration, so reaching it is a stated limit being enforced, not a computation going wrong.

The tense is the criterion. This rung is for a cap the engine can decide before the work happens, leaving nothing begun to abandon. pump_wcet_ns is decided on a measurement taken after the pump completed, so it is not this rung and not this shape: it halts the tier ([RTCT.7.3], rung 7).

Shape. The operation does not happen ([LSTO.4.7.5], [RTCT.7.2]): the engine must not mutate state on a breaching call, and subsequent calls work normally. The API call that triggered the check returns DS_ERR_CONTRACT_BREACH, and a BoundsError records the cap, its declared limit, and what the operation would have reached.

Why rung 2. The refused operation is never begun, so nothing of it is abandoned — which is what separates it from rungs 5–7, where an operation is given up part-way. A breach may occur where no activation exists at all: a max_fires_per_pump trip has activation context, an intern_cap breach during load has none, and proto/bounds_error.proto carries those fields as present-where-applicable for exactly that reason.

Inside a rule's RHS. When the refused operation is one of a firing's actions, whichever action and whichever cap it breaches (an emit whose value breaches a declared capacity, [LSTR.11.3], is one), the engine must stop the firing at it, by the prefix rule of [LNUL.11.1]: the actions before it stand, the refused action does not happen, and the actions after it do not run.

Criterion. A limit was declared, and honouring the declaration means refusing. If no limit was declared and the engine simply ran out, the engine's state is in question and it is rung 7 ([LERR.1.4]).

ratified — see also: LERR.1.4, LNUL.11.1, LSER.13.14, LSTO.4.7.5, LSTR.11.3, RTCT.7.1, RTCT.7.2, RTCT.7.3

Errors-as-values — rung 3 [LERR.1.2]#

[LERR.1.2.1] When. A runtime operation has a definite outcome that rules may want to react to — success, failure, timeout — and the feature's shape is already fact-plane (matching, rule firing).

[LERR.1.2.2] Examples:

  • [LERR.1.2.3] The response fact or CallError for async calls ([LCRS.4]). A failing call asserts a CallError fact; a sibling rule pattern-matches the error code and reacts.

ratified — see also: LCRS.4

  • [LERR.1.2.4] Hydration failures: adapter emits CallError with a hydration-specific code ([LHYD], via [LCRS]).

Deferred: not binding in this edition.

  • [LERR.1.2.5] Adapter unreachable: the callback returns CallError with a code of the adapter's own choosing ([LCRS.10.6.1]). The engine synthesises nothing here — it has no concept of a disconnected adapter.

see also: LCRS.10.6.1

  • [LERR.1.2.6] A response the adapter cannot deliver in the shape it published: the adapter emits a CallError from the standard families ([LECC.2.2]) — internal.* when the fault is its own, adapter.* when the upstream answered unusably. The engine performs no decode of its own: a response is a fact of the service's response schema, and the adapter asserts it ([LCRS.4.3.1]).

see also: LCRS.4.3.1, LECC.2.2

[LERR.1.2.7] Shape. A ttl-lifecycle fact (CallError, typically; similar schemas for other call-shaped mechanisms) carrying a code slot with spec- committed values and a message slot for human- readable detail. Rules match on code; rules that don't care fall through. corr slot threads the failure to the requesting rule's context.

ratified

[LERR.1.2.8] Criterion. The error is a legitimate outcome the author should be able to express in rule logic. Authors should be able to write "if this fails with code X, do Y; if Z, do W." Expressing this via pattern matching keeps the rule surface uniform with success handling.

Absence — rung 4 [LERR.1.3]#

[LERR.1.3.1] When. A value an expression needs is absent — a missing optional field, an unresolved Json path, a failed fallible conversion. Absence is expected under normal operation, so the rule should simply not fire, without abandoning the activation.

The value is absent; the operation is not wrong. Where the operation itself is wrong or has no answer, the activation is abandoned and the disposition is a fault ([LERR.1.4]).

ratified — checks: idris×5 — see also: LERR.1.4

[LERR.1.3.2] Examples:

  • [LERR.1.3.3] Path access on a Json slot where the path doesn't resolve — the value is absent and reads as null ([LNUL.8.4]). A path resolving to a JSON null reads as null too, as a present value; has(path) is what tells the two apart.

see also: LNUL.8.4

  • [LERR.1.3.4] Not this rung. A type mismatch at a Json slot's leaf is a TypeError and abandons the activation — rung 5, [LERR.1.4] and [LEXP.7.12.1]. The leaf is present and the operation is invalid on it, which is not absence.

see also: LERR.1.4, LEXP.7.12.1

  • [LERR.1.3.5] Regex match against a malformed runtime string — the comparison evaluates false.

[LERR.1.3.7] Shape. The expression reads as null and propagates under Kleene ([LNUL.4.1]); the rule fires only on true ([LNUL.4.3]), so it does not fire. No fact is asserted and the activation continues. No sentinel is produced: nothing takes part in further computation as though it were data. An absence raises no fault, so no metric counts it and the engine writes no log entry for it.

see also: LNUL.4.1, LNUL.4.3

[LERR.1.3.8] Criterion. The condition is expected to happen under normal operation, the rule's correct response is "don't match," and the engine shouldn't halt or flag per-event.

Faults — rungs 5, 6 and 7 [LERR.1.4]#

[LERR.1.4.1] When. A computation has no honest answer — no value, null included, would be true of it. That is the whole test ([LERR.1.4.9]).

Where the input came from does not enter into it. An Int division by zero is a trap whether the denominator is a literal or a sensor reading, because in neither case is there an answer. A Float operation always has one, an infinity or a NaN included ([LDET.3.6.2]), so no Float arithmetic traps.

ratified — checks: idris — see also: LERR.1.4.9, LDET.3.6.2

[LERR.1.4.2] Examples:

  • [LERR.1.4.3] Division, floor-division or modulo of Int operands by zero ([LEXP.7.15.1]). A Float division by zero returns ±Inf or NaN ([LDET.3.6.2]).

ratified — checks: idris — see also: LEXP.7.15.1, LDET.3.6.2

  • [LERR.1.4.4] Integer overflow on an integer expression. Two's- complement wraparound is defined behaviour, not an error ([LDET.6.3]).

see also: LDET.6.3

  • [LERR.1.4.5] Resource exhaustion the engine can't recover from (out-of-memory during Rete propagation).

  • [LERR.1.4.6] Recorder write failure. Not a fault: the engine continues, and the public call that fired the event returns the failure ([NCBK.1.5]).

see also: NCBK.1.5

[LERR.1.4.7] Shape. A ComputationError event lands in the event trace (per [LFST]) with kind, rule / activation / slot context, and source-location reference through the ruleset hash. A ComputationError abandons the failing activation and the rule cycle continues past it — rung 6, and the cost stops at the activation ([LERR.1]). Where engine state is no longer trustworthy (an artefact whose values contradict its own types, memory exhaustion with no declared cap, an engine invariant found broken ([IERR.1.7]), a pump_wcet_ns overrun — [RTCT.7.3]) the disposition is an EngineError and the engine halts the tier — rung 7.

The halt stops the work in progress where it is raised. Unlike rungs 5 and 6, the rule cycle does not continue past it. From the EngineError on, the engine must run no further action of the activation that raised it, fire no further activation, propagate no further fact, and record nothing more, not even that activation's close. That binds inside a fact change already under way: the engine must not carry the change that raised it any further, through the network, into the retractions it would cascade into, or on to the rest of a sweep, an upsert or a clock step. So the EngineError is the last record of the tier.

After the halt, the engine's state is undefined, except that it is halted. The engine may leave working memory, its agenda and every series in whatever state the halt found them, and two engines halted by one input may hold different states. What a host may still call is [NCBK.2.9]'s.

ratified — see also: IERR.1.7, LERR.1, NCBK.2.9, RTCT.7.3

[LERR.1.4.8] Criterion. No value — null included — would be an honest answer ([LERR.1.4.1], [LERR.1.4.9]). Answering null would say "unknown" when the truth is "this computation is invalid", and would quietly turn a rule bug into a rule that never fires. Silent continuation would mean the engine reports progress that didn't happen.

Authors do not handle these as expression values — a trap never feeds the T? / ?? / Kleene stack ([LCST.4.5.4]), and the activation that raised it stays abandoned. A trap is recorded on the stream ([RFCS.21]), and the engine then asserts a ComputationError fault fact describing it ([LERR.9]), which a rule may match. The fact is a record of the trap, never the value of the expression that raised it: a rule reacts to that a computation failed, and still has no answer to bind in its place.


see also: LCST.4.5.4, LERR.1.4.1, LERR.1.4.9, LERR.9, RFCS.21

[LERR.1.4.9] The trap kinds are a CLOSED SET. ComputationError.kind is an enum over exactly these three values, so a rule branches on a kind rather than string-matching a message, and a kind added without a raiser is visible. Adding a fourth is a breaking wire change, not an append.

This set is closed BY THE LANGUAGE, and that is why a fourth costs a major. The language fixes what a trap is, so a new kind is new semantics. A set closed against a table is a different thing and does not inherit that cost: CapName is closed against [RTCT.7.1] and its membership is that table, so bringing it into agreement is a repair rather than an extension.

⚠ The set is closed, and the closure is not scoped to a version. A rule scoped to a version number goes stale at every bump while the rule itself never does; DS carries no format version at all ([LDET.1.10]), and the closure simply binds.

Values 4, 5 and 6 are reserved, by number and by name, at the enum level: OVERFLOW, RESOURCE_EXHAUSTED and RECORDER_FAILURE. No later append reuses one, since a reader may still hold a table entry for it ([STYL.2.8.7]). What those names describe is reported elsewhere:

  • No Int or Float operation traps on overflow. Rational is a compile-time constant type whose literals promote to Float at runtime and whose arithmetic the compiler folds exactly, refusing at compile time a constant that no runtime value holds ([LUNI.2.4.1]). Integer overflow wraps ([LEXP.7.13.1]) and float overflow yields ±Inf ([LEXP.4.2]). The exact-money path neither wraps nor saturates but refuses, and its refusals are NOT_REPRESENTABLE by the test below ([LUNI.13.10]). So does an operation on Time or Date operands whose result leaves its type's range ([LERR.1.4.10]).

  • An exhausted resource is a bounds error or an engine error. A limit that is a declared cap ([RTCT.7.1]) leaves the engine intact and is a BoundsError; one that is not leaves it untrustworthy and is an EngineError. One kind spanning two dispositions is what [LERR.1.2]'s split separates.

  • A failing stream sink is no computation error. It is reported through the status of the call that fired the callback ([NCBK.1.5]) and halts nothing, so it is no fault of any kind.

Removing a kind from a closed set is forward-compatible, but narrows an existing compare-class atom's meaning, so it lands with a minor release ([LDET.1.10]).

Recoverability is a property of the OCCURRENCE, not of the kind. The test is [LERR.1.4.7]'s: whether engine state is still trustworthy. So recoverable is carried on the wire rather than derived from kind. An occurrence of each of the three kinds is reported; the occurrences whose recoverability varies are BoundsError and EngineError.

Integer overflow is NOT in this set and that is deliberate: [LERR.1.4.4] makes two's-complement wraparound defined behaviour. The test is whether the wrapped value still MEANS anything, not whether the operation was an arithmetic one. Wrapping in ordinary Int arithmetic is an algebra — mod 2⁶⁴, closed, and an author can reason about it. Wrapping in a conversion is not: 1e30 mod 2⁶⁴ bears no relationship to 1e30, and neither does a wrapped monetary amount to the amount it came from ([LUNI.13.10]). That second class is NOT_REPRESENTABLE's, and it is the one that survives.

What is not a trap, by the same criterion. A missing Json path, a cache miss, a failed fallible conversion (String :: Int?, invalid UTF-8 in Bytes :: String) and an interpolation of a null or absent value all have an honest answer — absent, which is null ([LNUL]) — and Kleene semantics carry it. A format spec that cannot render a value that is present and of the wrong type is not in that list and is not absence: the value is present and the rendering is invalid on it, so it raises on rung 5 like any other operation over such a leaf ([LERR.1.3.4]). A trap is for a computation with no honest answer, where null would say "unknown" when the truth is "this computation is invalid", and would quietly turn a rule bug into a rule that never fires.

ratified — see also: LDET.1.10, LERR.1.2, LERR.1.3.4, LERR.1.4.10, LERR.1.4.4, LERR.1.4.7, LEXP.4.2, LEXP.7.13.1, LUNI.13.10, LUNI.2.4.1, NCBK.1.5, RTCT.7.1

[LERR.1.4.10]

kind

raised when

established by

DIVIDE_BY_ZERO

an Int division, floor-division or modulo has a zero divisor. A Float division by zero does not trap ([LDET.3.6.2])

[LERR.1.4.3]

DOMAIN

the operation is undefined at that input and is not an IEEE Float operation — a negative shift count; a bits, sign_extend or swap_bytes argument outside its domain ([LEXP.3.7.4]); now() read, or a ts filled, while the wall clock has no value ([LTIM.2.8.3]); local() or date() with no TimeZoneOffset fact in force ([LTIM.10.5.3]); a calendar field outside its range ([LTIM.14.2]); a Date plus or minus a Duration that is not a whole number of days ([LTIM.4.2.3]); an interval whose endpoints are not start <= end ([LINT.7.2])

[LEXP.7.14.1]

NOT_REPRESENTABLE

an operation has no representable result and wrapping would destroy its meaning — a total conversion (Float :: Int on a value non-finite, or finite and outside Int); a rounding builtin whose result lies outside Int or whose argument is not finite ([LEXP.3.2.1]); a conversion through an integer-stored unit with no representable result ([RLOW.6.1.10], [RLOW.7.3.9], [LADP.8.5.3]); a Json value a rule builds past a limit ([LGRA.5.8.6]), and a non-finite Float forced into a JSON body ([LDET.3.2.7]); an operation whose Time or Date result leaves its type's range ([LTIM.1.1.5], [LTIM.1.2.2], [LTIM.4.1.1], [LTIM.4.2.3], [LTIM.4.3.3], [LTIM.7.1], [LTIM.14.2]); a Duration scaled by a Float whose result is non-finite or outside Int, and a Duration sum or product above $2^{63} - 1$ nanoseconds ([LTIM.4.1.1]); a sum over a slot of the time dimension that reads negative ([LSER.17.2]); a computed time-format identifier that names no format ([LTIM.8.3.2])

[LCST.4.5.4]

ratified — checks: k idris×3 — see also: LADP.8.5.3, LCST.4.5.4, LDET.3.2.7, LDET.3.6.2, LERR.1.4.3, LEXP.3.2.1, LEXP.3.7.4, LEXP.7.14.1, LGRA.5.8.6, LINT.7.2, LSER.17.2, LTIM.1.1.5, LTIM.1.2.2, LTIM.10.5.3, LTIM.14.2, LTIM.2.8.3, LTIM.4.1.1, LTIM.4.2.3, LTIM.4.3.3, LTIM.7.1, LTIM.8.3.2, RLOW.6.1.10, RLOW.7.3.9

[LERR.1.4.11] Only the fault an expression yields reaches a surface. A fault an operand raised is not the expression's fault when a deciding operand absorbed it, or when [LNUL.4.2]'s order selected another — under and / or, or under any other operator ([LNUL.4.10]). Such a fault is not recorded ([RFCS.21.1]), not asserted as a fault fact ([LERR.9.9]), not delivered to a callback, and not counted by any metric. [LNUL.4.2] and [LNUL.4.10] leave the evaluation order free, and reporting a fault the expression did not yield would make what an engine reports depend on that order.

checks: alloy×3 k — see also: LERR.9.9, LNUL.4.10, LNUL.4.2, RFCS.21.1

[LERR.1.4.12] A fault raised while matching reaches a surface once per derivation of its pair. A join test answers a pair: a token in the node's left memory and a candidate fact in its right memory ([IRET.7.6]). A pair is live while both are there. An assertion or a retraction of a fact, with the propagation it causes, derives the pairs that are live after it and were not live before it, the pairs below a negated pattern it releases included ([IRET.7.9.3]).

For a TypeError or a ComputationError, the engine must record the fault a pair's tests yield ([LERR.1.4.11]) for each pair the operation derives, and for no other pair. A pair the engine evaluates that is not live when the operation completes, and a pair the operation ends, record nothing, whatever their tests yield. A pair that ends and is later derived again records again.

The engine must record the faults one operation derives once its propagation has completed, ordered by:

  1. the terminal ordinal of the rule the node belongs to ([LDET.5.4], [LDET.5.10]);

  2. the pair's facts, as [LDET.5.5] orders a rule's matches: the token's facts and then the candidate, pattern by pattern, each ranked by when it entered working memory;

  3. the node's position in the rule's chain, the shallower first.

Which faults one operation records, and their order, are therefore a function of working memory before and after it. How the engine traverses its memories, whether it indexes a join, and the order in which it visits alpha memories must not change them ([LDET.5.9]).

An EngineError raised while matching halts the tier where it is raised ([IRET.9.6]); a run that raises one is outside the determinism guarantee ([LDET.1.11]).

ratified — see also: IRET.7.6, IRET.7.9.3, IRET.9.6, LDET.1.11, LDET.5.10, LDET.5.4, LDET.5.5, LDET.5.9, LERR.1.4.11

Choosing a policy [LERR.2]#

[LERR.2.1] The condition a feature surfaces decides its rung ([LERR.1]). The tree walks down the axis — each question asks whether the condition gets past that rung, so the first Yes wins and the cost only rises:

Can the compiler detect this from static info?
├── Yes → Compile error                        (rung 1)
└── No:
    Is a declared cap the thing being reached?
    ├── Yes → Bounds refusal                   (rung 2)
    │         The operation does not happen and the
    │         caller is told; nothing is abandoned.
    └── No:
        Is this a legitimate runtime outcome the author
        should react to via rules?
        ├── Yes:
        │   Is the feature's shape fact-plane (matching,
        │   call-response, sibling-rule reaction)?
        │   ├── Yes → Errors-as-values           (rung 3)
        │   └── No → errors-as-values requires a fact-plane
        │             surface; without one the condition
        │             falls through to the rungs below.
        └── No:
            Is the value simply ABSENT — a missing optional
            field, an unresolved path, a failed fallible
            conversion — where "don't match" is right?
            ├── Yes → Absence, reads as `null`   (rung 4)
            └── No:  the activation cannot continue.
                Is engine state still trustworthy?
                ├── No  → EngineError            (rung 7)
                └── Yes:
                    Was the operation invalid on the
                    value it was given?
                    ├── Yes → TypeError          (rung 5)
                    └── No  → ComputationError   (rung 6)
                              Well typed, no answer exists.

The last split is the one worth reading twice. TypeError and ComputationError cost the same — one activation — and differ only in why, which is what a consumer cannot recover afterwards if the two are merged.

see also: LERR.1

Worked examples [LERR.2.2]#

[LERR.2.2.1] "Rule A calls ml_worker.classify and the model times out."

  • [LERR.2.2.2] Compile-time detectable? No (external system behaviour).

  • [LERR.2.2.3] Legitimate outcome for the author? Yes — rules may want to log, retry, fall back.

  • [LERR.2.2.4] Fact-plane shape? Yes — call/CallError is already fact-plane.

  • [LERR.2.2.5] → Errors-as-values. CallError { code: "timeout" } asserted; rule A's sibling matches on it.

[LERR.2.2.6] "Rule A uses p.body.temperature > 30 where body is a Json slot and temperature happens to be a string in some messages."

  • [LERR.2.2.7] Compile-time detectable? No (the slot is Json; the leaf type isn't known until runtime).

  • [LERR.2.2.8] Legitimate outcome? Yes, but not worth a per-event CallError — rules just want to not match on malformed messages.

  • [LERR.2.2.9] → TypeError (rung 5, [LERR.1.4]). The leaf is present and the comparison is invalid on it: the activation is abandoned and the fault reaches the fault surfaces ([LEXP.7.12.1]). The expression does not evaluate to false.

see also: LERR.1.4, LEXP.7.12.1

[LERR.2.2.10] "Rule author uses emit X logical where X is declared ttl."

  • [LERR.2.2.11] Compile-time detectable? Yes (schema lifecycle is in the compiled artefact).

  • [LERR.2.2.12] → Compile error. Rejected at compile time.

[LERR.2.2.13] "Recorder cannot write to its sink because disk is full."

  • [LERR.2.2.14] Compile-time detectable? No.

  • [LERR.2.2.15] Legitimate outcome the author should react to? No — rules don't handle disk-full.

  • [LERR.2.2.16] Expected during normal operation? No — a tier with a filled disk is in a degraded state.

  • [LERR.2.2.17] → Hard runtime error. Engine halts the tier per [RARC].


What this policy does not cover [LERR.3]#

  • [LERR.3.1] Operator-facing diagnostic output. How errors appear in logs, dashboards, and alerts is an operational concern per [NMET.1] and its deployment surface.

see also: NMET.1

  • [LERR.3.2] Recovery semantics for hard errors. Whether a tier that halted restarts automatically, how it is signalled to operators, what happens to in-flight state — all deployment / operational.

  • [LERR.3.3] Error-rate thresholds triggering alerts. Site config; outside the language's concern.


The status dictionary [LERR.8]#

The four policies above say how a feature reports failure. This section says what a failure is: an integer status, drawn from one registry, that every conforming implementation shares.

The registry is proto/status.proto#DsStatus, and the protobuf is the dictionary rather than a rendering of one ([STYL.2.14]). Nothing else in the corpus assigns a status a number.

defined in: proto/status.proto#DsStatus

[LERR.8.1] The number is the identity; the name is a label. A conforming implementation must use these numbers to mean these things, and may name them as its own language prefers. The registry is proto/status.proto#DsStatus.

defined in: proto/status.proto#DsStatus

Fault facts [LERR.9]#

A TypeError or a ComputationError abandons its activation ([LERR.1.4]) and is then asserted into working memory as a fact that describes it, so rules can react to faults. The fact is a record of the fault, never the value of the expression that raised it.

see also: LERR.1.4

[LERR.9.1] Which faults, and in what order. For a TypeError (rung 5) or a ComputationError (rung 6) that reaches a surface ([LERR.1.4.11]), the engine must, in this order: record the fault on the event trace ([RFCS.21.1]), which delivers it to the integrator on the stream callback ([NCBK.2.8]), and then assert its fault fact ([LERR.9.2], [LERR.9.3]). No further callback follows the assertion. An EngineError (rung 7) is recorded and must not be asserted: the tier it halts has no working memory left to assert into. [LERR.9.6] names the one further exception.

see also: LERR.1.4.11, LERR.9.2, LERR.9.3, LERR.9.6, NCBK.2.8, RFCS.21.1

[LERR.9.2] The ComputationError schema. scope internal ([LSCP.2.6], [LERR.9.5]); identity is (node, rule).

Slot

Type

Marker

Meaning

kind

String

"DIVIDE_BY_ZERO", "DOMAIN" or "NOT_REPRESENTABLE" — the [LERR.1.4.9] kinds, without the TRAP_ prefix

rule

String

key

the fault's rule name ([LERR.9.11]): the faulting activation's rule, or $alpha_<id> / $beta_<id> for a trap raised during matching

schema

String

the schema of the value the computation had no answer for, or "" when no slot supplied it ([LERR.9.12])

slot

String

the slot of that value, or ""

node

Int

key

the expression node that faulted; the artefact maps it to a source line (RDSC.14.3)

key here marks the latching identity, not an identity role in the artefact. The engine applies [LERR.9.5]'s latching rule by (node, rule) itself. The schema reaches the artefact as an explicit schema with no identity roles, since a lifecycle atom whose slots carry one decodes as logical ([RDSC.5.5.7]). The two key slots are never null.

kind is a closed set: the compiler must reject a comparison of kind against a string literal outside it as DS_VALIDATE_CLOSED_SET_LITERAL, naming the three members.

ratified — see also: LERR.9.12, LSCP.2.6, LERR.1.4.9, LERR.9.11, LERR.9.5, RDSC.14.3, RDSC.5.5.7

[LERR.9.3] The TypeError schema. scope internal ([LSCP.2.6], [LERR.9.5]); identity is (node, rule).

Slot

Type

Marker

Meaning

actual

String

the type tag the value actually had

rule

String

key

the fault's rule name ([LERR.9.11]): the faulting activation's rule, or $alpha_<id> / $beta_<id> for a fault raised during matching, where no activation exists yet and the node may serve several rules

schema

String

the schema of the value the operation was invalid on, or "" when no slot supplied it ([LERR.9.12])

slot

String

the slot of that value, or ""

node

Int

key

the expression node that faulted

rule is a key and is therefore never null ([LNUL.8.10]), and it is the same name the fault's FactEmit carries ([LERR.9.8]).

ratified — see also: LERR.9.11, LERR.9.12, LERR.9.5, LERR.9.8, LNUL.8.10, LSCP.2.6

[LERR.9.4] Built in and reserved. Both schemas exist in every program without a declaration, and a rule may pattern on either. Their names are reserved words of the type namespace ([LLEX.9.6], [LGRA.22.7]): an author schema declared under either name is a compile error, DS_VALIDATE_RESERVED_TYPE_NAME ([LLEX.9.5]). Both are scope internal ([LSCP.2.6]): only the engine asserts them, an emit of either is DS_VALIDATE_INTERNAL_EMIT_FORBIDDEN ([LSCP.2.6.1]), and a rule may withdraw one it matched ([LERR.9.5]).

ratified — see also: LGRA.22.7, LERR.9.5, LLEX.9.5, LLEX.9.6, LSCP.2.6, LSCP.2.6.1

[LERR.9.5] Latched per site. Both schemas are scope internal ([LSCP.2.6]), and the engine applies one replacement rule of its own when it asserts a fault fact. Before asserting, it must look for a live fault fact of the same schema with the same (node, rule):

  • if every slot is equal, the assertion is a suppressed no-op, as a no-op reassertion is ([LFAC.2.5.1]) — the live fact stays, and nothing matching it fires again;

  • if any slot differs, the engine retracts the live fact and asserts the new one ([LFAC.1.2.2]).

A rule acknowledges a fault by withdrawing the fact it matched ([LSCP.2.6.1]); the next fault at that site is then asserted afresh. The replacement rule belongs to fault facts alone: it is not a property of any scope, internal included.

So working memory holds at most one fault fact per schema per (node, rule) site, a bound the compiler knows from the artefact ([LERR.9.10]). The event trace still records every occurrence ([LERR.9.1]).

ratified — see also: LERR.9.1, LERR.9.10, LFAC.1.2.2, LFAC.2.5.1, LSCO.4.5.9, LSCP.2.6, LSCP.2.6.1

[LERR.9.6] A handler's own faults are not asserted. A rule with any pattern, positive or negated, on ComputationError or TypeError is a fault handler. A fault raised in a handler's activation, or at a network node any handler's patterns use, must be recorded and passed to the callback ([LERR.9.1]) and must not be asserted as a fault fact.

Which rules are handlers, and which nodes they use, is known at compile time. Fault facts therefore feed only handlers, and nothing a handler does produces a fault fact, so asserting fault facts cannot form a cycle, however handlers are written.

ratified — see also: LERR.9.1

[LERR.9.7] When the fact is asserted. A fault is raised part-way through something — a TypeError during matching, in the middle of propagating another fact; a fault in an activation, part-way through its actions. The engine must not assert a fault fact at that point. It must queue fault facts in the order the faults are recorded ([LERR.1.4.12] orders those raised while matching) and assert them when the current propagation has completed, or when the abandoned activation has been unwound, and in any case before the next agenda selection. Each takes its timetag when asserted, like any fact, and a handler's activation is ordered by [LDET.5] with no special case.

At most one fault is pending per (node, rule) site between a raise and the drain. A later fault at a site whose fault is still pending replaces it in place: the site keeps the queue position of its first pending fault. The stream carries the drained facts only, so the intermediate ones never appear. The queue is thereby bounded by the site count ([LERR.9.10]) in every mode: a pre-sized runtime holds it without growing, and a runtime that is not pre-sized records the same stream.

ratified — see also: LDET.5, LERR.1.4.12, LERR.9.10

[LERR.9.8] On the stream. A fault fact is recorded as a FactEmit ([RFCS.6a]), whose rule_name is the fault's rule name ([LERR.9.11]); a consumer identifies a fault fact by its schema_name. Its withdrawal is a FactWithdraw like any other. For one fault the stream carries, in order, the fault atom ([RFCS.21.1]), then the FactEmit, which [LERR.9.7] may place after other atoms of the same propagation. The integrator receives each as it is recorded, on the stream callback ([NCBK.2.8]); no separate fault callback follows the FactEmit. A replay re-derives the FactEmit and compares it, as it does every FactEmit ([LFST.9.2]).

ratified — see also: LERR.9.11, LERR.9.7, LFST.9.2, NCBK.2.8, RFCS.21.1, RFCS.6a

[LERR.9.9] Only a fault that reaches a surface becomes a fact. A fault absorbed by a deciding operand, or passed over by [LNUL.4.2]'s order, is not the expression's fault ([LERR.1.4.11]): the engine must not assert a fault fact for it.

see also: LERR.1.4.11, LNUL.4.2

[LERR.9.10] Where working memory is pre-sized, fault facts have a pool of their own. The compiler must compute the number of fault-fact sites — one per (node, rule) at which a ComputationError can be raised, plus one per (node, rule) at which a TypeError can, excluding handlers' ([LERR.9.6]) — and carry it in the artefact header of every program (RDSC.3.10). It is a function of the program, not a capacity anyone declares. A runtime that pre-sizes its working memory must allocate exactly that many fault-fact slots at load, and fault facts must use only those slots, never the working-memory capacity the author or integrator sized. The pool cannot overflow ([LERR.9.5], [LERR.9.7]), so there is no refusal path. No mode of this edition pre-sizes working memory ([NRTM.3.1]); the count travels regardless, so a runtime that does needs nothing more from the artefact.

see also: LERR.9.5, LERR.9.6, LERR.9.7, NRTM.3.1

[LERR.9.11] Every fault names a rule. The engine must give every TypeError, ComputationError and EngineError a rule name, on the fault fact where there is one ([LERR.9.2], [LERR.9.3]) and on the recorded atom and the integrator callback always:

  • a fault raised in an activation carries that activation's rule;

  • a fault raised at a network node during matching, where no activation exists yet and the node may serve several rules, carries $alpha_<id> or $beta_<id>, from the kind and compiler-assigned id of the node that faulted;

  • a fault with no node site at all carries $engine.

The name is a function of the artefact and the fault, so a replay reproduces it, and the artefact maps the node id to a source line. The last two are synthetic names ([LLEX.10.6.1]), so no author rule can bear one. No fault carries an empty rule name.

ratified — see also: LERR.9.2, LERR.9.3, LLEX.10.6.1

[LERR.9.12] A fault's slot context is its offending operand's. The schema and slot of a ComputationError or TypeError fault fact ([LERR.9.2], [LERR.9.3]), the same fields and the fact id on its recorded atom (proto/engine_error.proto#ComputationError, proto/type_error.proto#TypeError) and its integrator callback, and a TypeError's actual, describe one operand of the node that raised the fault: its offending operand. The engine must choose it, without evaluating anything a second time, as:

  1. the first operand whose value is known and null;

  2. else, at a division or remainder, the divisor;

  3. else the first operand.

An operand's value is known when it needs no evaluation: it is a literal or a slot read.

The engine must fill the schema, the slot and the fact id when the offending operand is a slot read, and must leave them unset otherwise: absent on the atom and the callback, and the empty string on the fault fact, whose slots are not nullable. In 100 / (x - x) and x // 0 no fact or slot supplied the value, so there is none to name. The engine must fill actual when the offending operand's value is known, and leave it unset otherwise.


ratified — defined in: proto/engine_error.proto#ComputationError, proto/type_error.proto#TypeError — see also: LERR.9.2, LERR.9.3