linear_scan: false — programs without linear scans

Contents

linear_scan: false — programs without linear scans#

The linear_scan: false capability setting. Prefix LNLS.

This document is an overlay on the base language specs. It does not modify any base spec paragraph; it only states how those paragraphs are interpreted or restricted when linear_scan: false is active. Each overlay section names the base paragraph it constrains.


What linear_scan: false is [LNLS.1]#

Purpose [LNLS.1.1]#

linear_scan: false is a capability setting that restricts DS programs to a subset where every runtime data-structure operation is provably sub-linear in the working-memory population or series depth. The name reflects the implementation guarantee, not the programming model: the compiler enforces language-level constraints whose collective effect is that no engine subsystem scans a list or array proportional to fact count.

A program compiled with linear_scan: false trades away certain language features — dynamic strings, JSON slots, unbounded sketch aggregations, and range-only join conditions — in return for algorithmic guarantees that hold at any WM population size.

What the user accepts [LNLS.1.2]#

linear_scan: false is an advanced, opt-in constraint. Users who choose it accept:

  • No json-typed slots.

  • No interpolated string producing run-time-novel strings.

  • No regex match without a declared slot width bound.

  • No cross-pattern comparison that lacks an equality anchor.

  • No sketch-backed series aggregations (quantile, count_distinct with tolerance, HLL via tolerance, entropy) — the sketch / accuracy forms are already removed for everyone ([LNLS.3.5]), so linear_scan: false adds no restriction here.

  • No series membership / frequency read (contains, count_of) without a capacity ([LSER.13.14]) or the sample <n> reservoir — see [LNLS.3.11].

  • No string ordering (<, >, <=, >= on String-typed values in cross-pattern position).

In return they get the algorithmic properties in [LNLS.5] and the simplified T_wcet formula in [LNLS.7].

see also: LNLS.3.11, LNLS.3.5, LNLS.5, LNLS.7, LSER.13.14

What linear_scan: false is not [LNLS.1.3]#

  • Not a synonym for realtime. The two are orthogonal and can be used independently or together. linear_scan: false is about algorithmic shape; realtime is about the allocation and lifecycle model.

  • Not a performance dial. It is a semantic constraint. A program that compiles under linear_scan: false has certain complexity guarantees regardless of engine version or hardware.

  • Not a subset of valid DS programs. It is a different set of programs. A linear_scan: false program may use any feature not listed in [LNLS.3]; those features are not "disabled", they are fully active.


see also: LNLS.3

Extension-capability registration [LNLS.2]#

Name and registration [LNLS.2.1]#

linear_scan is a strategy capability of [LCAP.1]. A program has linear_scan: false through its dialect or a line of its use block ([LDIA.2.1]), resolved per [LDIA.3.3]. Every built-in dialect but base has linear_scan: true ([LDIA.9]).

see also: LCAP.1, LDIA.2.1, LDIA.9, LDIA.3.3

Combination with other extensions [LNLS.2.2]#

linear_scan: false combines with any other setting. Interactions:

With linear_scan: false and

Effect

realtime: true

See [LNLS.2.4] for the precise overlap. Together they produce the tightest possible T_wcet guarantee — both allocation and algorithmic bounds.

Any other setting

No interaction unless it permits a construct excluded by [LNLS.3].

The realtime: true row is deferred with that capability, and the compiler refuses it in this edition ([LCAP.2.1.5]).

see also: LCAP.2.1.5, LNLS.2.4, LNLS.3

What realtime already enforces from linear_scan: false [LNLS.2.3]#

realtime does not imply linear_scan: false in full, but it automatically enforces a subset of the linear_scan: false constraints — specifically the ones where violation causes truly unbounded execution or allocation (not merely a larger T_wcet). The following linear_scan: false exclusions are compile errors under realtime whether or not linear_scan: false is declared:

LNLS constraint

Why realtime also requires it

LNLS.3.2 — no novel strings

Intern table is locked after go_live; a novel string causes DS_ERR_OOM mid-firing. Must be a compile error, not a runtime error.

LNLS.3.5 — no sketch backends

O(n) compaction can trigger any time in the pump; cost is unbounded and cannot be included in T_wcet.

LNLS.3.7 — regex without capacity

O(L×P) where L is run-time length; unbounded without a declared capacity.

LNLS.3.8 — string ordering without capacity

O(len) strncmp; unbounded without a declared capacity.

LNLS.3.9 — JSON_PATH

Already blocked by the no-json-slots rule (LNLS.3.1); listed for completeness.

LNLS.3.11 — series scan without capacity

O(D) scan where D (series depth) grows with the event trace; unbounded without a sample cap ([LSER.13.14]) — already a compile error under realtime (DS_VALIDATE_RT_SERIES_UNBOUNDED).

Deferred: not binding in this edition.

see also: LSER.13.14, LNLS.3.11, LNLS.3.2, LNLS.3.5, LNLS.3.7, LNLS.3.8, LNLS.3.9

What realtime does NOT enforce from linear_scan: false [LNLS.2.4]#

The following linear_scan: false constraints are not required for hard RT and are not automatically enforced by realtime:

LNLS constraint

Why realtime does not need it

What it means for T_wcet

LNLS.3.1 — no JSON slots

Borrow semantics make JSON slot assert O(1). JSON_PATH is already blocked (LNLS.3.9). LIVE blocks re-assertion. JSON slots are RT-compatible.

No impact

LNLS.3.3 — logical identity join required

Multi-pattern joins not anchored to logical identity slots fall back to O(L_β × T_j), bounded by N_max — finite, computable, valid hard RT.

T_wcet contains O(N_max × T_j) beta term instead of O(1)

Practical implication: realtime alone is sufficient for hard RT as defined by the realtime contract ([RTCT.1]). Adding linear_scan: false eliminates the O(N_max) dependency from join costs entirely (beta joins become O(1) via the logical-identity-slot constraint). This is a T_wcet improvement, not an RT prerequisite.

Deferred: not binding in this edition.

see also: LNLS.3.1, LNLS.3.3, RTCT.1

When to use each [LNLS.2.5]#

Goal

Dialect

Overrides

Hard RT, no language restrictions beyond the constant-space gate

realtime

—

Hard RT with N_max-independent join costs

realtime

linear_scan: false

Non-RT with O(1) join guarantee at any scale

default

linear_scan: false

Maximum performance, no RT lifecycle required

default

linear_scan: false

Tightest possible T_wcet and all guarantees

realtime

linear_scan: false

The rows that use the realtime dialect are deferred with it, and the compiler refuses them in this edition ([LCAP.2.1.5]).

see also: LCAP.2.1.5

Scope [LNLS.2.6]#

The extension is program-scoped per [LDIA.2.9]. A project may mix linear_scan: false programs with others. A linear_scan: false program may import schemas from any library provided the imported schemas comply with [LNLS.3.1] (no json slots) when used in a linear_scan: false rule.


see also: LDIA.2.9, LNLS.3.1

Excluded features and compile errors [LNLS.3]#

When linear_scan: false is active, the following are compile errors. Each error message must identify the specific paragraph violated.

JSON-typed slots [LNLS.3.1]#

A schema declaration that includes a json-typed slot is a compile error (DS_VALIDATE_NOLINSCAN_JSON_SLOT) when the schema is used in a program with linear_scan: false.

Rationale: JSON slot evaluation (JSON_PATH expressions) calls JSON parsing — O(L) with per-node allocation.

ratified

Dynamic-string production [LNLS.3.2]#

An interpolated string whose result is not a compile-time-provable member of the DSC's interned string vocabulary is a compile error (DS_VALIDATE_NOLINSCAN_NOVEL_STRING).

The compiler may approve an interpolated string only when every value it renders is a string literal, a schema name, or a slot-name literal — values whose interned identity is guaranteed to be in the table after DSC load. One that renders a slot binding, or formats a number, is excluded because the result may be a novel string not in the intern table.

Rationale: a string a rule produces at run time would be a novel intern entry on every firing, and so a table resize in the pump path. Strings that arrive on asserted facts are a separate population ([LNLS.5.5]).

see also: LNLS.5.5

Identity-slot join required on all multi-pattern rules [LNLS.3.3]#

A where clause in a multi-pattern rule (one that references bindings from two or more patterns) must contain equality constraints that pin the full declared key ([LFAC.1.7]) of a logical-lifecycle schema on one side to that of a logical-lifecycle schema on the other side — one equality per key slot when the key is composite. Any other form of cross-pattern equality or inequality is a compile error.

Formally: the required constraint is a conjunction of equalities, one per key slot:

$\bigwedge_{i} ; A.k_i = B.k_i$

where:

  • $A$ and $B$ are bindings from distinct patterns,

  • the schema of $A$ uses logical lifecycle and $A.k_i$ ranges over its declared key slots,

  • the schema of $B$ uses logical lifecycle and $B.k_i$ ranges over its declared key slots,

  • the anchor pins each side's complete key, so each side resolves to at most one live fact.

A singleton is pinned by construction. A logical schema whose key is empty holds at most one live fact ([LFAC.1.7.2]), so its side of a join resolves to at most one fact with no equality at all. Between a singleton and a keyed logical schema, the anchor pins the keyed schema's full key, each key slot equal to a slot of the singleton, and each such slot of the singleton must be declared non-nullable: it stands in for a key slot, and a key slot is never null ([LNUL.8.10]). The compiler refuses an anchor on a nullable singleton slot with DS_VALIDATE_NOLINSCAN_JOIN_ANCHOR_C. Between two singletons, no equality is required.

Every pattern after the first is anchored to an earlier one, positive or negated. In pattern-declaration order, each pattern after the first must be pinned this way to a pattern declared before it. A negated pattern whose where references no earlier binding is exempt: it asks only whether a matching fact exists, and when that answer changes, every token it blocks or releases is part of the result, not a scan. One anchored pair is not enough in a rule of three or more patterns: a pattern anchored to nothing before it joins by scan, and [LNLS.5.1]'s right-activation half — a new fact probing for exactly one candidate token — needs a complete key on the side the fact arrives at.

Additional constraints (range comparisons, further equality tests between other slots) are allowed on top of this anchor. Single-pattern where clauses (alpha tests) are unrestricted.

Why this is the complete no-linear-scan condition: the index (lmem_idx / ralpha_idx) gives O(matched) where matched is the number of facts sharing the join-key value. An EQ anchor alone only guarantees an index exists — it does not guarantee O(1). An EQ anchor on the full declared key of a logical schema guarantees O(1) because logical retract-and-replace semantics ensure at most one live fact per key-tuple. J_max = 1 is enforced by the schema lifecycle, not by the programmer's discipline.

Joining on a non-key slot, or on only part of a composite key, even of a logical schema, can produce J_max > 1 (multiple facts sharing the matched value) and is therefore excluded. Joining on any slot of a ttl-lifecycle schema is excluded because ttl facts accumulate — multiple events per key is the normal case.

The idiomatic linear_scan: false pattern for "join entity state with the latest event" is a logical projection maintained by a separate rule.

The refusals and their codes are [LNLS.3.3a], [LNLS.3.3b] and [LNLS.3.3c].

ratified — checks: idris×34 — see also: LFAC.1.7, LFAC.1.7.2, LNLS.5.1, LNLS.3.3a, LNLS.3.3b, LNLS.3.3c, LNUL.8.10

[LNLS.3.3a] The anchor must pin the full key on both sides. A cross-pattern equality that does not pin the complete declared key of a logical schema on each side is a compile error. Joining on a non-key slot, or on part of a composite key, admits more than one live fact per matched value, so J_max > 1 and the join is not bounded.

ratified

[LNLS.3.3b] Only logical lifecycle qualifies. A multi-pattern rule that joins against a ttl-lifecycle schema is a compile error. ttl facts accumulate — several per key is the normal case — so no lifecycle guarantee bounds the match set.

ratified

[LNLS.3.3c] A multi-pattern rule needs an anchor at all. A multi-pattern rule carrying no cross-pattern equality constraint is a compile error: with nothing pinning the two sides together the join degenerates to a scan, which is the whole condition linear_scan: false exists to exclude.

ratified

Sketch-backed series aggregations [LNLS.3.5]#

A series declaration that uses an aggregation whose only available backing is a sketch, with an O(n) worst-case absorb ([LNLS.4.8]), is a compile error in a program with linear_scan: false.

An accuracy phrase never reaches this check: the validator refuses it first ([LSER.15]).

Every aggregation [LSER.16] defines is allowed, the signal-processing set included — active_fraction (SeriesBackendIntervalPulse), onset_rate (SeriesBackendRingBuffer), and integral (SeriesBackendNumericIntegral) — all bounded, non-sketch backings ([LSIG.1.1]).

see also: LNLS.4.8, LSER.15, LSER.16, LSIG.1.1

distance.levenshtein() built-in [LNLS.3.6]#

Any call to distance.levenshtein(a, b) ([LIMP.3.3.4]) is a compile error (DS_VALIDATE_NOLINSCAN_LEVENSHTEIN) in a linear_scan: false file.

Rationale: Levenshtein edit distance is O(L × S) by the standard DP algorithm. L and S are slot-content lengths, not compile-time constants; no bounded alternative exists.

Deferred: not binding in this edition.

see also: LIMP.3.3.4

Regex without a slot width bound [LNLS.3.7]#

A ~ or !~ regex expression whose left-hand operand is a String slot without a declared capacity ([LSTR.11.1]) is a compile error (DS_VALIDATE_NOLINSCAN_UNBOUNDED_REGEX) in a linear_scan: false file.

When the slot declares capacity N, the regex match cost is O(N × P), where both N (the slot's bound in codepoints, at most 4N bytes) and P (pattern length, fixed in DSC) are compile-time constants. This is bounded and allowed.

ratified — see also: LSTR.11.1

String ordering in cross-pattern position [LNLS.3.8]#

A where clause that compares String-typed slot values from different patterns using <, >, <=, or >= is a compile error (DS_VALIDATE_NOLINSCAN_STRING_ORDER).

String ordering uses strncmp — O(min(a.len, b.len)). In a single-pattern where clause (alpha test), this cost is bounded and allowed even in linear_scan: false if the slot carries a capacity. In cross-pattern position it would become a join test that also prevents lmem_idx construction (violating LNLS.3.3).

ratified — see also: LNLS.3.3

Json traversal expressions [LNLS.3.9]#

Any expression of the form <binding>["key"] or <binding>.key that traverses a json-typed value is a compile error. This is a consequence of LNLS.3.1 (no json slots); it is listed separately because json values can arise from call responses.

ratified — see also: LNLS.3.1

String slots used in string operations must carry capacity [LNLS.3.10]#

A String-typed slot that appears as an operand to any of the following built-in string operations must declare capacity N ([LSTR.11.1]) in its schema declaration, and the compiler refuses one that does not with DS_VALIDATE_NOLINSCAN_UNBOUNDED_STRING_OP:

Operation

Without capacity

With capacity N

<, >, <=, >= on String (single-pattern only)

O(len) strncmp

O(N) = O(1)

~, !~ regex (already LNLS.3.7)

O(L×P)

O(N×P) = O(1)

len(s) is exempt.

== and != comparisons are O(1) for interned strings (pointer equality) and do not require capacity.

Rationale: without a declared bound, the runtime cost of these operations grows with the string content — a data-dependent quantity not visible at compile time. With capacity N, the cost is O(N) where N is a compile-time constant (N codepoints are at most 4N bytes); the operation is O(1) in the algorithmic sense.

Interaction with LNLS.3.7: LNLS.3.7 (regex requires capacity) is a special case of LNLS.3.10. When both would apply, the compiler reports [LNLS.3.7]'s code, DS_VALIDATE_NOLINSCAN_UNBOUNDED_REGEX.

The error must name the first use of the slot in a string operation in the file. Subsequent uses of the same slot do not generate additional diagnostics for the same root cause.

ratified — see also: LNLS.3.7, LSTR.11.1

Series membership / frequency scan without a sample bound [LNLS.3.11]#

A contains(s, v) or count_of(s, v) read over a series s whose declaration carries no capacity ([LSER.13.14]) is a compile error (DS_VALIDATE_NOLINSCAN_SERIES_UNBOUNDED) in a program with linear_scan: false. The same applies to any series read whose cost is linear in the window's sample depth.

Read

Without capacity

With capacity N

contains(cursor, value)

O(D) window scan

O(N) = O(1)

count_of(cursor, value)

O(D) window scan

O(N) = O(1)

Rationale: these reads scan the window's stored samples — O(D), where D is the series depth. On a sliding (or other time-windowed) backing with no capacity, D is O(window × event-rate): it grows with the event trace, is not a compile-time constant, and the read is a linear scan in series depth ([LNLS.1.1]). The O(1)-incremental reads — count, sum, mean, min, max, first, last, bool_and, bool_or — do not scan and are unaffected.

With capacity N the scan is O(N), bounded by a compile-time constant — exactly the discipline linear_scan: false applies to bounded strings ([LNLS.3.10]) — and is allowed.

This is the same cut realtime makes from the WCET side ([LNLS.2.3]).


ratified — see also: LNLS.1.1, LNLS.2.3, LNLS.3.10, LSER.13.14

Overlays on base spec paragraphs [LNLS.4]#

Each sub-section below names the base paragraph it overlays and states the additional constraint. Nothing in this section modifies the base paragraph for programs not using linear_scan: false.

Grammar — use directive [LNLS.4.1]#

Overlays [LGRA.2.1] / [LDIA.2.1].

A program has linear_scan: false through a use block line ([LDIA.2.1]) or a dialect that sets it. The grammar is unchanged; linear_scan is a capability name ([LCAP.1]).

see also: LCAP.1, LDIA.2.1, LGRA.2.1

Expressions — comparison operators [LNLS.4.2]#

Overlays [LEXP.1.1] (operator table) and [LEXP.2.1] (comparison chains).

Comparison operators <, >, <=, >= remain legal in:

  • Single-pattern where clauses on String slots with capacity.

  • Single-pattern where clauses on numeric slots (unrestricted).

  • RHS action argument expressions (not join tests; no restriction).

Comparison operators <, >, <=, >= become a compile error in:

  • Cross-pattern where clauses on String-typed bindings (LNLS.3.8).

see also: LEXP.1.1, LEXP.2.1, LNLS.3.8

Expressions — cross-pattern constraints [LNLS.4.3]#

Overlays [LEXP.8.2] (where clauses on patterns) and [LTHE.2.4.1] (cross-pattern slot constraints).

Under linear_scan: false, a where clause that references bindings from two or more patterns must satisfy [LNLS.3.3]: its equalities pin the full declared key of a logical-lifecycle schema on each side, one per key slot. Additional constraints are allowed.

This constraint becomes the join-key index at compile time. Because logical retract-and-replace ensures at most one live fact per identity value, exactly one candidate is found per probe — O(1), not O(matched). Remaining constraints are evaluated once against that single candidate.

see also: LEXP.8.2, LNLS.3.3, LTHE.2.4.1

Expressions — string operations [LNLS.4.4]#

Overlays [LEXP.3.X] (string built-ins) and [LSTR.3.2] (string ordering).

An interpolated string — subject to LNLS.3.2 (output vocabulary must be compile-time-known).

Substring and prefix/suffix tests are regex ([LREG.10.11]) and are bounded by LNLS.3.7 rather than by this rule.

len — always O(1) for interned strings; allowed unconditionally.

==, != — O(1) pointer equality on interned strings; always allowed.

String ordering via <, >, <=, >=:

  • Allowed in single-pattern position on slots with capacity (LNLS.3.10).

  • A compile error in cross-pattern position regardless of capacity (LNLS.3.8).

With capacity declared on all String slots, every string operation in a linear_scan: false program evaluates in O(1) time (see [LNLS.5.7]).

see also: LEXP.3, LREG.10.11, LNLS.3.10, LNLS.3.2, LNLS.3.8, LNLS.5.7, LSTR.3.2

Expressions — JSON path [LNLS.4.5]#

Overlays [LEXP.6] (Json introspection).

All JSON path expressions are compile errors in linear_scan: false files. This is a consequence of LNLS.3.1 (no json slots) and LNLS.3.9.

see also: LEXP.6, LNLS.3.1, LNLS.3.9

Fact model — slot type restrictions [LNLS.4.6]#

Overlays [LFAC.X] (slot type declarations) and schema slot type semantics.

Under linear_scan: false:

  • json as a slot type is a compile error (LNLS.3.1).

  • String slots are allowed. Slots used in string operations (ordering, regex) must carry capacity N (LNLS.3.10 / LNLS.3.7). Slots used only for ==/!= or as alpha-test literals do not require capacity.

  • Numeric slots (Int, Float) with tolerance markers are allowed.

  • Bool, Bytes, fact-ref types — unrestricted.

see also: LNLS.3.1, LNLS.3.10, LNLS.3.7

Fact model — schema dedup constraint [LNLS.4.7]#

Overlays retract-and-replace ([LFAC.1.2.2]).

Under linear_scan: false the engine must find the fact an assertion supersedes in O(1) amortized, for every logical schema. No further constraint on the schema is needed: the lookup reads the declared key ([LFAC.1.7.5]), and a schema whose key is empty holds at most one live fact ([LFAC.1.7.2]). tolerance does not enter it, because a tolerance is admissible only on a mutable slot, never a key slot ([LFAC.1.7.1]).

Removal is O(1) amortized as well. Under linear_scan: false the engine must remove a fact from working memory in O(1) amortized in the live facts of its schema, whatever removes it: the supersedure above, a retraction, a withdrawal or an expiry. The bound covers every structure the removal itself updates, not only the indexes over live facts: bookkeeping a rule keeps per fact, such as the facts a rule has already fired on, and the release of the values the fact held. Two terms are outside the bound. A fact with a deadline also leaves dynamic_ttl's deadline heap, at the O(log N_ttl) [LDTL.1.2] states. A TimeZoneOffset fact also leaves its zone's index ([LTIM.10.7]), at O(log r) in the live facts of that zone. What the removal sets off downstream is bounded where it is stated: the beta joins by [LNLS.5.1], and each fact a cascade removes by this clause.

see also: LDTL.1.2, LFAC.1.2.2, LFAC.1.7.1, LFAC.1.7.2, LFAC.1.7.5, LNLS.5.1, LTIM.10.7

Series — backend restrictions [LNLS.4.8]#

Overlays [LSER.13] (series declaration body) and [LSER.15] (accuracy phrases).

Under linear_scan: false:

  • Aggregations that resolve to sketch backends with O(n) worst-case absorb cost are compile errors ([LNLS.3.5]). Every v1 series aggregation is exact and non-sketch.

  • All series aggregations are otherwise unrestricted under linear_scan: false, except the unbounded membership / frequency scans of [LNLS.3.11].

The set of always-allowed series backends in linear_scan: false (the v1 exact set):

Backend

Absorb

Notes

Ring buffer

O(1)

FIFO deque

O(1) amortized

Pre-allocated in realtime, capacity in .dsrt

Welford (cumulative)

O(1)

cumulative only

Monotonic deque

O(1) amortized

Pre-allocated in realtime, capacity in .dsrt

Reservoir (SeriesBackendReservoir)

O(1)

sample <n>

SeriesBackendIntervalPulse (interval pulse)

O(1) amortized

active_fraction; deque append/evict + running sum; pre-allocated in realtime, capacity in .dsrt

SeriesBackendNumericIntegral (numeric integral)

O(1) amortized

integral; pre-allocated in realtime, capacity in .dsrt

Series RT capacity source. The deque-family time-windowed backends — FIFO deque (SeriesBackendFifoDeque), monotonic deque (SeriesBackendMonotonicDeque), SeriesBackendIntervalPulse, SeriesBackendNumericIntegral — take their realtime pre-allocated buffer capacity from the .dsrt contract (series[i].capacity), sized per deployment. The contract's capacity bounds a series' declared capacity and wins over it ([LSER.13.14]). A count declared in source — a series' capacity: N, a reservoir's sample <n> — defines the buffer and lowers into the backing's max_samples in the DSC.

see also: LNLS.3.11, LNLS.3.5, LSER.13, LSER.13.14, LSER.15

Regex — capacity requirement [LNLS.4.9]#

Overlays [LREG.1] (match operators) and [LREG.5] (compiled patterns).

Under linear_scan: false, the ~ and !~ operators are allowed only when the left-hand operand is a String slot with a declared capacity N (LNLS.3.7). The compiler must:

  1. Resolve the operand to its source slot.

  2. Check for a capacity on that slot.

  3. Produce a compile error if the slot declares none.

  4. Record capacity N in the alpha test metadata so that T_wcet computation can use N as the per-match cost bound.

see also: LNLS.3.7, LREG.1, LREG.5

Hydration — JSON slots [LNLS.4.10]#

Overlays [LHYD.2] (hydrate_* action slots).

Under linear_scan: false, any call hydrate_* action that populates a json-typed slot is a compile error. Hydration may populate any slot type allowed by LNLS.4.6.

Deferred: not binding in this edition.

see also: LHYD.2, LNLS.4.6

Then / temporal correlation [LNLS.4.11]#

Overlays [LTHE.2.4] (cross-pattern correlation in then sequences).

Cross-pattern correlation where clauses in then expressions are subject to the same equality-anchor requirement as standard multi-pattern rules (LNLS.4.3). Each correlated pair of patterns must share at least one EQ constraint.


see also: LNLS.4.3, LTHE.2.4

Runtime behavioral guarantees [LNLS.5]#

When linear_scan: false is active and the DSC has been compiled cleanly, the following guarantees hold at all WM population sizes up to N_max.

Beta join — both directions are always O(1) [LNLS.5.1]#

Every beta node in a linear_scan: false program has its lmem_idx and ralpha_idx join-key indexes always active, and — because LNLS.3.3 requires joining on the identity slot of logical-lifecycle schemas — each index probe returns exactly one candidate (J_max = 1).

  • beta_right_activate(fact) → O(1): identity-slot probe via lmem_idx; exactly one left-memory token (if any) shares that key.

  • beta_left_activate(token) → O(1): identity-slot probe via ralpha_idx; exactly one right-alpha fact (if any) shares that key.

  • beta_right_retract(fact) → O(1): right_idx holds exactly one joined token per fact (J_max = 1).

  • beta_left_retract(token) → O(1): ltok_idx holds exactly one joined right fact per token (J_max = 1); no join tests needed.

  • NOT-node equivalents: same O(1) guarantees via ltok_idx for not_left_retract.

The "fallback scan" code paths and the J_max iteration loops are provably unreachable for any DSC compiled with linear_scan: false. In a dedicated linear_scan: false build configuration they may be stripped.

Deferred: not binding in this edition.

checks: idris×6 — see also: LNLS.3.3

Beta join in this edition [LNLS.5.8]#

[LNLS.5.1]'s bounds do not bind this edition. In a linear_scan: false program the engine's joins cost this:

  • A positive beta node indexes its left memory and its right alpha memory on one equality anchor, the first in its join-test list ([IRET.7.5.1]). A probe returns every entry that shares the anchor's value, and the node's other join tests decide among them. When the anchor is the whole of a schema's identity, a probe returns at most one entry. When the identity has several key slots and the anchor is one of them, it returns every entry sharing that slot's value.

  • A negated (no) node holds no index: an activation of it tests every entry of the memory it joins against.

see also: IRET.7.5.1, LNLS.5.1

Alpha test — bounded per test [LNLS.5.2]#

Every alpha test in a linear_scan: false program is a scalar comparison (int, float, bool), an interned-string pointer comparison, or an ordering or regex test on a String slot that declares capacity N ([LNLS.3.10]), whose cost [LNLS.5.7] bounds by N. N is a compile-time constant, so each test is bounded by a constant.

The total alpha test cost per fact assert is O(T) where T is the number of tests per alpha node — a compile-time constant.

see also: LNLS.3.10, LNLS.5.7

Supersedure lookup — always O(1) [LNLS.5.3]#

The supersedure lookup of [LNLS.4.7] is O(1) amortized for every schema a linear_scan: false program declares: keyed on the declared key, or, for a schema whose key is empty, over at most one live fact. Removing the superseded fact from working memory costs what the same clause bounds removal at.

see also: LNLS.4.7

Series absorb — O(1) amortized [LNLS.5.4]#

Every series backend in a linear_scan: false program absorbs a sample at the cost [LNLS.4.8]'s table gives it: O(1), or O(1) amortized. No sketch backing reaches such a program ([LNLS.3.5]).

see also: LNLS.3.5, LNLS.4.8

Intern table — rules add no strings [LNLS.5.5]#

No expression in a linear_scan: false program produces a novel string at run time ([LNLS.3.2]), so no rule action adds an entry to the intern table after DSC load.

[LNLS.3.2] does not reach a String slot value that arrives on an asserted fact. The engine may intern such a value when it pumps the fact, so the table may grow during the operational phase. Where the table is locked ([RTCT.12.4]), the engine refuses that intern with DS_ERR_OOM instead of growing the table.

see also: LNLS.3.2, RTCT.12.4

String operations — always O(1) [LNLS.5.7]#

When all String slots used in string operations carry capacity N (LNLS.3.10), every string operation in the pump path evaluates in O(1):

Operation

Bound

Single-pattern string ordering </>

O(capacity) = O(1)

Regex ~/!~

O(capacity × P) = O(1); P fixed in DSC

==, != on String

O(1) always (interned pointer eq)

len

O(1) always (stored with intern)

capacity values are compile-time integer literals; they are deployment constants that appear in T_wcet coefficient calculations the same way T_s (alpha tests per node) does.

The T_wcet formula therefore contains no O(len) terms under linear_scan: false when LNLS.3.10 is satisfied. String operation costs become fixed additive constants.

see also: LNLS.3.10

Join test evaluation — direct comparison [LNLS.5.6]#

Because all join tests have an EQ anchor (LNLS.3.3), the compiler can generate a specialized direct-comparison function per beta node. The boolean expression-tree walk (O(E)) for the equality anchor test is replaced with a single scalar or pointer comparison at the machine level. Remaining join tests (range checks on the same pair) continue to use the expression evaluator but fire only against that single candidate (O(1) by LNLS.3.3).

The net effect: the equality-anchor portion of every join test evaluates in O(1), not O(E).


see also: LNLS.3.3

Implementation overlays (IRET) [LNLS.6]#

linear_scan: false changes what the reference engine may assume at load and in the pump path. Those changes are stated where an implementer will look for them — beside the base behaviour they supplement, in the implementation tree:

  • [IRET.7.5.1] — the equality anchor is extracted at load, and the join-test hot path becomes O(1) for it.

  • [IRET.6.2.1] — alpha tests over types known at node-creation time, and the capacity bound that makes a regex test's cost a compile-time constant.

  • [IRET.9.8] — the expression kinds the exclusions in [LNLS.3] make unreachable.

They supplement, and do not replace, the base behaviour. The guarantees they serve are stated as properties in [LNLS.5.1] and [LNLS.5.3].

see also: IRET.6.2.1, IRET.7.5.1, IRET.9.8, LNLS.3, LNLS.5.1, LNLS.5.3

T_wcet improvements [LNLS.7]#

Deferred: not binding in this edition.

Simplified formula [LNLS.7.1]#

The T_wcet formula of [RTCT.12.1] / [RTCT.12.2] applies. Under linear_scan: false, the beta terms collapse to O(1) per join because LNLS.3.3 guarantees J_max = 1 for every beta node:

T_wcet(linear_scan=false) =
    c_alpha  × Σ_s(α_s × T_s)                      ← alpha dispatch
  + c_join   × F_max × 1                             ← all joins O(1)
  + c_agenda × F_max × log₂(F_max)                   ← agenda heap
  + c_fire   × F_max × A_max × E_rhs                 ← RHS actions
  + c_ttl    × expired_max × log₂(N_max)             ← TTL heap drain

Where:

  • α_s = facts of schema s matching any alpha node (≤ N_max)

  • T_s = alpha tests per alpha node for schema s; each O(1) under linear_scan=false

  • J_max = 1 — proven at compile time by LNLS.3.3; not a deployment parameter

  • E_rhs = max expression tree depth in RHS actions (join test expressions removed)

  • All string operation costs are O(capacity) per slot = O(1) under LNLS.3.10

see also: LNLS.3.10, LNLS.3.3, RTCT.12.1, RTCT.12.2

Key improvement [LNLS.7.2]#

The dominant beta term in the general formula is O(L_β × T_j) or O(R_α × T_j), both O(N_max) worst case.

Under linear_scan: false, J_max = 1 is statically proven by the compiler, not assumed or approximated. Every join is a single hash probe with at most one candidate — no loop, no scan, no iteration. Beta operations are unconditionally O(1) per fact assert or retract, independent of N_max and any deployment parameter.

The beta terms drop from O(N_max × T_j) to O(1). For N_max = 100,000 this eliminates the dominant term from T_wcet entirely.

No J_max deployment parameter [LNLS.7.3]#

Unlike the general case where J_max must be declared or measured, linear_scan: false programs have no J_max parameter — the compiler proves J_max = 1 structurally from the schema lifecycle declarations. There is nothing to declare, measure, or tune. The beta cost is O(1) by construction for all deployments.


Composition with realtime [LNLS.8]#

The precise relationship between linear_scan: false and realtime is defined in [LNLS.2.3] and [LNLS.2.4]. This section provides the benefit comparison and the combined-mode guarantee.

Deferred: not binding in this edition.

see also: LNLS.2.3, LNLS.2.4

What each extension provides [LNLS.8.1]#

  • linear_scan: false constrains algorithmic shape — which operations are O(1) or O(J_max) vs O(N_max). It does not require pool allocation, presz, or go_live.

  • realtime constrains the allocation and lifecycle model — all memory pre-allocated before go_live, INIT/LIVE phase discipline. It automatically enforces LNLS.3.2, 3.5, 3.6, 3.7, 3.8 as compile errors (see [LNLS.2.3]). It does not enforce LNLS.3.1, 3.3, 3.4.

A program can use either, both, or neither.

see also: LNLS.2.3, LNLS.3.1, LNLS.3.2

Benefits of each combination [LNLS.8.2]#

Property

realtime alone

linear_scan: false alone

Both

Zero malloc in pump

✓

✗ (ridx overflow still possible)

✓

Beta joins O(1) — J_max = 1 proven

✗ (O(N_max) without identity join)

✓ (LNLS.3.3 enforces)

✓

Series O(1) always

✓ (sketch excluded by realtime)

✓

✓

Intern frozen

✓ (locked by go_live)

✓ (no novel strings)

✓

wm_dedup O(1) always

✗ (all-tolerance schemas possible)

✓

✓

T_wcet N_max-independent for joins

✗

✓

✓

String ops O(1) (capacity required)

✗

✓ (LNLS.3.10)

✓

T_wcet finite and computable

✓

✓ (larger beta term)

✓

go_live lifecycle required

✓

✗

✓

Pool allocation required

✓

✗

✓

JSON slots allowed

✓ (with borrow semantics)

✗

✗

Range-only joins allowed

✓ (bounded by N_max)

✗

✗

see also: LNLS.3.10, LNLS.3.3

Tightest T_wcet: both together [LNLS.8.3]#

When both realtime and linear_scan: false are active:

  • Beta joins are O(1) per assert/retract — J_max = 1 proven by LNLS.3.3, pool-allocated, both index directions always active, fallback scan unreachable.

  • All series are O(1), included in RT T_wcet calculations.

  • The intern table is locked. No rule produces a novel string ([LNLS.5.5]), and a novel string arriving on an asserted fact is refused rather than interned ([RTCT.12.4]).

  • All hash tables are pre-sized when the engine goes live.

  • J_max replaces N_max as the dominant beta cost parameter.

  • The supersedure lookup is always O(1), with no fallback scan ([LNLS.5.3]).

The T_wcet formula from [LNLS.7.1] applies with the additional guarantee that all memory was pre-allocated and no allocation path is reachable in LIVE.


see also: LNLS.3.3, LNLS.5.3, LNLS.5.5, LNLS.7.1, RTCT.12.4

Compile errors and diagnostic format [LNLS.9]#

All linear_scan: false violations are compile errors — never warnings and never runtime errors. The program fails to compile. There is no override; the constraints are absolute.

Diagnostic format [LNLS.9.1]#

Each diagnostic must include:

  1. The file and line of the violating form.

  2. The human-readable description of what was found.

  3. The LNLS paragraph number being violated.

  4. A suggested fix where one exists.

All error codes [LNLS.9.2]#

Code

Paragraph

Condition

LNLS.3.1

JSON slot type

Schema has json-typed slot used under linear_scan: false

LNLS.3.2

Novel string

an interpolated string may produce a non-interned string

LNLS.3.3a

Non-identity EQ anchor

Cross-pattern equality not on identity slot of both schemas

LNLS.3.3b

TTL schema in join

Multi-pattern join includes a ttl-lifecycle schema

LNLS.3.3c

Unanchored pattern

A pattern after the first, positive or negated, is not anchored to an earlier one; or a singleton slot an anchor uses is nullable

LNLS.3.5

Sketch backend

Series aggregation requires O(n) sketch

LNLS.3.7

Unbounded regex

~/!~ on slot without capacity

LNLS.3.8

String ordering in join

</>/<=/>= on String in cross-pattern position

LNLS.3.9

JSON path

Any JSON path expression

LNLS.3.10

Unbounded string op

String operation on slot without capacity


see also: LNLS.3.1, LNLS.3.10, LNLS.3.2, LNLS.3.3a, LNLS.3.3b, LNLS.3.3c, LNLS.3.5, LNLS.3.7, LNLS.3.8, LNLS.3.9

What linear_scan: false does not restrict [LNLS.10]#

The following are fully available in linear_scan: false programs:

  • All numeric types (Int, Float, Bool) and all their operations.

  • String slots, interned string literals, string comparisons using == and != (always O(1); no annotation needed).

  • len(s) — O(1) for interned strings; no annotation needed.

  • Single-pattern where clauses with any numeric comparison operator.

  • String ordering </>/<=/>= in single-pattern position on slots with capacity (LNLS.3.10).

  • Regex match on slots with a declared capacity (LNLS.3.7).

  • All fact lifecycle types (logical, ttl).

  • All schema slot markers (retained, tolerance with at least one non-tolerance anchor slot).

  • Cooldown rules (the cooldown modifier).

  • TMS / logical facts (the logical lifecycle and emit X logical).

  • then / temporal sequencing, within the equality-anchor constraint of [LNLS.4.11].

  • call, cache, publish, log, emit actions.

  • Any series aggregation not listed in LNLS.3.5.

  • All arithmetic operators.

  • now() and dwell time expressions.

  • Imports and multi-file programs.

  • const declarations (string literals only — already compile-time constants).

  • The .dstest test surface.


see also: LNLS.3.10, LNLS.3.5, LNLS.3.7, LNLS.4.11