# Series: observations over slot history

Series declarations name the
**observations** an author wants on a slot's history —
aggregations, time models, accuracy bounds — and the compiler
picks the backing structures.

Paired with:
- [LGRA] — the series declaration grammar.
- [LEXP] — aggregation calls are
  atoms in expression grammar; compose freely with
  arithmetic.
- [LFAC] — the no-op reassertion
  discipline that meaningful-change series updates depend on.

## What this is not

- Not the series declaration grammar — see
  [LGRA].
- Not a dwell spec — `t.dwell` is a compile-time alias for
  the time since the fact entered working memory on `logical`-schema bindings, unrelated to
  series maintenance. See [LFAC].
- Not a runtime-implementation guide. Welford running stats,
  ring-buffer and deque sizing, trailing-tail buffer sizes,
  memory accounting — those are the runtime's
  ([ISBK]).
- Not a backing implementation guide. Which backing serves
  each observation triple is catalogued in [LSER.18.1]; how
  each one is built (running-stats, monotonic deque, ring
  buffer, reservoir) is the runtime's business.

---

(LSER-13)=
## The series declaration body [LSER.13]

(LSER-13-1)=
[LSER.13.1] A `series <slot-ref>` declaration's body is one or
more **observation lines**. Each line is one or more
aggregations and a time-model phrase, per the grammar at
[LSER.13.5]. Every v1 aggregation is exact, so there is no
accuracy phrase ([LSER.15.1]).

*ratified*  —  *see also:* [LSER.13.5](#LSER-13-5), [LSER.15.1](#LSER-15-1)

(LSER-13-2)=
[LSER.13.2] Each line is read left-to-right: which aggregations,
over which time model, at which accuracy. The reader can answer
"what is this slot tracking?" without knowing what data
structures back it.

(LSER-13-3)=
[LSER.13.3] **The author never names a backing structure.** The
compiler reads every observation line, groups triples by
compatible backings, coalesces shared backings, rejects
provably-empty cells, and picks structures that cover every
triple at the lowest total state cost. The matrix in
[LSER.18.1] is the backing catalogue; the spec surface stays
stable as the catalogue grows.

*see also:* [LSER.18.1](#LSER-18-1)

(LSER-13-4)=
[LSER.13.4] Block-level options live in parentheses on the
declaration line, before the colon, per the `<block-opts>`
production at [LSER.13.5]. The `by:`, `capacity:` ([LSER.13.14]) and
`nulls:` ([LNUL.8.6]) kwargs apply to the whole block.

*ratified*  —  *see also:* [LNUL.8.6](#LNUL-8-6), [LSER.13.14](#LSER-13-14), [LSER.13.5](#LSER-13-5)

(LSER-13-14)=
[LSER.13.14] **`capacity: N` caps the samples each identity retains.** `N`
is a positive integer; the compiler must refuse one below 1
(`DS_VALIDATE_CAPACITY_NOT_POSITIVE`). The cap applies per identity
([LSER.7.6.1]), to every backing the block's lines select. A backing that
retains no samples, such as the constant-state cumulative backing, is never
bound by it. A series with no `capacity` is bounded by its window alone.

When a sample reaches a backing whose identity already holds `N` samples, the
engine must do what the "At capacity" column of [LSER.18.1] and [LSIG.1.1]
gives for that backing's aggregation:

- **drop** — evict that identity's oldest sample and retain the new one. The
  fact is asserted, and the aggregation reads over the samples retained, which
  may span less than the declared window.
- **refuse** — a bounds refusal ([LERR.1.5]) naming `CAP_SERIES_CAPACITY`. The
  fact's assert does not happen ([RTCT.7.2]), so no backing of the block
  absorbs the sample, whether or not it would have dropped.

**What the engine counts against `N`.** The samples the identity's backing
retains inside the window, plus every sample admitted for that identity in the
current pump and not yet absorbed ([LSER.8.6]): the refusal is decided at the
assert, absorption happens at the end of the pump, and a cap that read the
backing alone would let two facts in one pump pass a check only one of them can
satisfy. A step backing's carry, the newest sample older than the window start
that it keeps because its value holds into the window ([LSIG.2.5.1]), is the
boundary value and not one of the `N`. A `null` reading counts when the
series' `nulls:` policy absorbs a value for it, and does not when the policy
absorbs nothing ([LNUL.8.6]).

A `sample <n>` line retains `n` samples by construction; the compiler must
refuse a block whose `capacity` is below the `n` of any of its lines
(`DS_VALIDATE_SERIES_CAPACITY_BELOW_SAMPLE`). Under `realtime`, [LSER.13.15]
bounds it as well.

*ratified*  —  *see also:* [LERR.1.5](#LERR-1-5), [LNUL.8.6](#LNUL-8-6), [LSER.13.15](#LSER-13-15), [LSER.18.1](#LSER-18-1), [LSER.7.6.1](#LSER-7-6-1), [LSER.8.6](#LSER-8-6), [LSIG.1.1](#LSIG-1-1), [LSIG.2.5.1](#LSIG-2-5-1), [RTCT.7.2](#RTCT-7-2)

(LSER-13-15)=
[LSER.13.15] **`capacity` under `realtime`.** The contract's per-series
capacity ([RTCT.7.1]) bounds the count [LSER.13.14] states, and wins. The
compiler must refuse a declared `capacity` above the contract's
(`DS_VALIDATE_SERIES_CAPACITY_EXCEEDS_CONTRACT`); a series that declares none
takes the contract's.

*Deferred: not binding in this edition.*

*see also:* [LSER.13.14](#LSER-13-14), [RTCT.7.1](#RTCT-7-1)

(LSER-13-5)=
[LSER.13.5] **A series is declared by the `series_decl` production of
[LGRA.7.1]**, whose productions are the grammar's: a slot reference, optional
block options (`by:`, `capacity:`, `nulls:`), and one or more series lines,
each an aggregation list, a time model, an optional gap policy
([LSER.13.5.1]) and an optional `as` label.

*see also:* [LGRA.7.1](#LGRA-7-1), [LSER.13.5.1](#LSER-13-5-1)

(LSER-13-5-1)=
[LSER.13.5.1] **The `gap-policy` phrase** declares how a *time-integrating*
aggregation advances across intervals where no new sample is asserted:
`gap hold` (carry the last value — the default when the phrase is omitted),
`gap zero` (absence = zero, for rate sensors), or `gap skip` (exclude
dead-sensor intervals; requires a bounded `scope ttl`/`scope explicit`
schema). `gap`, `hold`, `zero`, and `skip` are reserved ([LLEX.9.5]).
The phrase is **optional and applies only to time-integrating aggregations**
(`integral`); on any other aggregation it is a compile error — applicability
is a compile-time contract check on the same axis as [LSER.16–17], not a
grammar constraint.

*see also:* [LLEX.9.5](#LLEX-9-5), [LSER.16](#LSER-16)

(LSER-13-6)=
[LSER.13.6] One series declaration per (slot path, file) per
[LSER.7.5]. Two series declarations on the same slot path within
one file are a duplicate-declaration error. Declarations on the
same slot path in different files are independent; each file's
rules read the observations its own file declared.

*ratified*  —  *see also:* [LSER.7.5](#LSER-7-5)

(LSER-13-7)=
[LSER.13.7] **The slot path must resolve.** In the qualified
form `<Schema>.<slot>`, a schema name not declared in the
compilation unit → compile error
`DS_VALIDATE_SERIES_UNKNOWN_SCHEMA`, listing the declared
schemas.

*ratified*

(LSER-13-8)=
[LSER.13.8] **The slot must exist on the schema.** A slot path
naming a slot the resolved schema does not declare → compile
error `DS_VALIDATE_SERIES_UNKNOWN_SLOT`, listing the schema's
slots.

*ratified*

(LSER-13-9)=
[LSER.13.9] **The block-option inventory is closed.** A series declaration
accepts exactly `by:`, `capacity:` ([LSER.13.14]) and `nulls:`
([LNUL.8.6]), in parentheses on the declaration line ([LSER.13.4]).

Each is its own production, so an unknown option name is a **parse** error
rather than a validation one — there is no kwarg-name check left to fail,
because there is no open kwarg position for a wrong name to occupy. `window:`
is not an option: the window is the time-model phrase on the observation line
([LSER.13.1]).

*see also:* [LNUL.8.6](#LNUL-8-6), [LSER.13.1](#LSER-13-1), [LSER.13.14](#LSER-13-14), [LSER.13.4](#LSER-13-4)

(LSER-13-10)=
[LSER.13.10] **Block-option values are typed by the grammar.** `by:` takes a
slot name or `none` ([LSER.7.6.2]), `capacity:` takes an integer literal
([LSER.13.14]), and `nulls:` takes `skip`, `hold` or `zero` ([LNUL.8.6]).

Each is fixed in its own production, so a value of the wrong kind does not
parse. The one value-level check left is `capacity:`'s lower bound, which
[LSER.13.14] states.

*see also:* [LNUL.8.6](#LNUL-8-6), [LSER.13.14](#LSER-13-14), [LSER.7.6.2](#LSER-7-6-2)

(LSER-13-11)=
[LSER.13.11] **A kwarg appears at most once.** The same kwarg
name given twice in one declaration → compile error
`DS_VALIDATE_SERIES_DUPLICATE_KWARG`. The grammar at
[LSER.13.5] admits the repetition; this rejects it.

*see also:* [LSER.13.5](#LSER-13-5)

(LSER-13-12)=
[LSER.13.12] **Raw-sample backings store scalars.** A backing that retains raw
sample values — the ring buffer and the reservoir — stores `Bool`, `Float`,
`Int` or `String` and nothing else.

The author does not state this and cannot get it wrong: the element type follows
the slot's declared type, and a slot type no aggregation admits is already
rejected by the applicability rule ([LSER.17.1]). What the compiler enforces is
the slot type; the backing's element type is chosen from it.

*see also:* [LSER.17.1](#LSER-17-1)

(LSER-14)=
## Time models [LSER.14]

(LSER-14-1)=
[LSER.14.1] A line's time-model phrase declares over what window
of the slot's history the aggregations apply. Four forms:

| Phrase | Meaning |
|---|---|
| `all_time` | from first observation onward, no forgetting |
| `sliding <dur>` | true sliding window of width `<dur>`: at read time `t`, the half-open interval `(t−<dur>, t]` — a sample exactly `<dur>` old is outside it ([LSIG.2.2.4]) |
| `tumbling <dur>` | non-overlapping consecutive windows of width `<dur>`; aggregations read the **most-recent-completed** window. Refused in this edition ([LSER.14.4.5]) |
| `sample <n>` | uniform random sample of size `n` from the unbounded stream (reservoir; see [LSMP]) |

*ratified*  —  *see also:* [LSER.14.4.5](#LSER-14-4-5), [LSIG.2.2.4](#LSIG-2-2-4)

(LSER-14-2)=
[LSER.14.2] The author picks the time model that matches the
question. A question about "the last 10 minutes" is `sliding
10_min`. A question about "ad-hoc historical statistics" is
`sample 200`.

(LSER-14-4)=
### `tumbling` semantics [LSER.14.4]

(LSER-14-4-1)=
[LSER.14.4.1] A `tumbling <dur>` time model cuts the timeline
into non-overlapping fixed-width buckets aligned to a
deterministic epoch (per [LDET]). Each bucket carries an
aggregation value once the bucket closes.

*Deferred: not binding in this edition.*

(LSER-14-4-2)=
[LSER.14.4.2] Aggregation expressions on a `tumbling` triple
read the **most-recently-completed** bucket. The currently-in-
progress bucket is invisible to rules; its value is not
observable until it closes.

*Deferred: not binding in this edition.*

(LSER-14-4-4)=
[LSER.14.4.4] Authors who need the running count of the current
in-progress window declare `count sliding <same-dur>` alongside
the tumbling line. The two time models are independent
declarations on the same slot; labels per [LSER.6.5] resolve
companion-slot collisions.

*Deferred: not binding in this edition.*

*see also:* [LSER.6.5](#LSER-6-5)

(LSER-14-4-5)=
[LSER.14.4.5] **No aggregation is backed on `tumbling` in this edition.** The
compiler **must** refuse every `tumbling` line, whatever its aggregation, with
`DS_VALIDATE_SERIES_NO_EXACT_BACKING` ([LSER.15.2], [LSER.18]). A per-bucket
backing is what the model needs and none ships. [LSER.14.4.1], [LSER.14.4.2]
and [LSER.14.4.4] state what a `tumbling` line means where an edition admits one; none of them
binds this edition.

*ratified*  —  *see also:* [LSER.14.4.1](#LSER-14-4-1), [LSER.14.4.2](#LSER-14-4-2), [LSER.14.4.4](#LSER-14-4-4), [LSER.15.2](#LSER-15-2), [LSER.18](#LSER-18)

(LSER-14-5)=
### `sample` semantics [LSER.14.5]

(LSER-14-5-1)=
[LSER.14.5.1] `sample <n>` declares a uniform-random reservoir of
size `n` over the slot's unbounded history. Its semantics
([LSMP.1]), aggregation applicability ([LSMP.3]),
the `SeriesBackendReservoir` backing ([LSMP.5]), and — notably — its **determinism**
([LSMP.2]; replay-deterministic and cross-platform bit-exact via a fixed-seed
integer PRNG) are specified in [LSMP].

---

*see also:* [LSMP.1](#LSMP-1), [LSMP.2](#LSMP-2), [LSMP.3](#LSMP-3), [LSMP.5](#LSMP-5)

(LSER-15)=
## Accuracy [LSER.15]

(LSER-15-1)=
[LSER.15.1] **Every v1 series aggregation is exact.** A declaration is
satisfied by an exact backing or it is rejected, because v1 mandates
cross-platform bit-identity ([LDET.3.4]). The validator rejects a `tolerance` /
`confidence` / `delta` / `bound deterministic` / `exact` accuracy phrase
(`DS_VALIDATE_SERIES_NO_EXACT_BACKING` for `exact`).

*see also:* [LDET.3.4](#LDET-3-4)

(LSER-15-2)=
[LSER.15.2] When an (aggregation, time-model) combination has no exact backing
([LSER.18]), the compiler **must** refuse the declaration with
`DS_VALIDATE_SERIES_NO_EXACT_BACKING`. The percentiles (`pXX` / `median`) need
a **bounded** window for an exact quantile — the raw-sample ring buffer over a
`sliding` window, or a `sample <n>` reservoir — so their `all_time` and
`tumbling` forms are refused. Cardinality, per-value frequency and membership
are exact on a bounded `sliding` window only, so their `all_time` and
`tumbling` forms are refused too. The diagnostic **should** name the refused
combination and the bounded forms that would satisfy it.

---

*see also:* [LSER.18](#LSER-18)

(LSER-16)=
## Aggregation vocabulary [LSER.16]

(LSER-16-1)=
[LSER.16.1] All aggregations are callable as functions in any
expression position (see [LEXP]). The
first argument to every aggregation call is a series cursor per
[LSER.6.10]; the time model and accuracy come from the series
declaration. The companion-slot form `cursor.<agg>` per [LSER.6]
is the alternative shape.

*ratified*  —  *see also:* [LSER.6](#LSER-6), [LSER.6.10](#LSER-6-10)

(LSER-16-2)=
### Descriptive statistics [LSER.16.2]

| Function | Meaning | Returns |
|---|---|---|
| `mean(cursor)` | arithmetic mean | `Float?` |
| `median(cursor)` | 50th percentile | `Float?` |
| `min(cursor)` | minimum value | slot type, nullable |
| `max(cursor)` | maximum value | slot type, nullable |
| `sum(cursor)` | sum | slot type |
| `count(cursor)` | sample count | `Int` |

A nullable return is `null` exactly when the read is cold ([LSER.19.8]).

*see also:* [LSER.19.8](#LSER-19-8)

(LSER-16-2-1)=
[LSER.16.2.1] `sum` / `count` / `mean` are **exact** on `all_time` (`SeriesBackendWelfordEwma`),
`sliding` (the raw-sample ring buffer `SeriesBackendRingBuffer` at O(window·rate) state, [LSER.18.2]),
and `sample` (the `SeriesBackendReservoir` reservoir). Their `tumbling` form has no exact per-bucket
backing in v1 and is rejected (§ [LSER.18], [LSER.14.4]). No accuracy
phrase exists.

*ratified*  —  *see also:* [LSER.14.4](#LSER-14-4), [LSER.18](#LSER-18), [LSER.18.2](#LSER-18-2)

(LSER-16-2-2)=
[LSER.16.2.2] *Integer accumulator bound.* "Exact" above is exact arithmetic,
not unbounded precision. Over an `Int`-typed slot, `sum` accumulates in a 64-bit
signed integer and `count` is itself an `Int`; both therefore **wrap silently**
once the running total leaves the signed-64-bit range, per the language-wide
integer rule [LEXP.7.13]. In practice `count` cannot overflow (it would take
2⁶³ retained samples), and `sum` only does so when the slot's magnitudes and
window are large enough for the partial sum to exceed ≈9.2·10¹⁸ — at which point
the result is `sum mod 2⁶⁴` (two's-complement), with no error or saturation.
Authors summing large `Int` magnitudes over long windows should sum a `Float`
slot instead (`mean` already returns `Float`, and `integral` accumulates in
`Float64` per [LSIG.1.5.5]), trading exactness for graceful magnitude
degradation. This bound is not compiler-checkable: it depends on runtime slot
values, not on the window/rate declaration.

*ratified*  —  *see also:* [LEXP.7.13](#LEXP-7-13), [LSIG.1.5.5](#LSIG-1-5-5)

(LSER-16-3)=
### Dispersion [LSER.16.3]

(LSER-16-3-1)=
[LSER.16.3.1] Python `statistics`-module naming — sample
variants apply Bessel's correction, population variants don't.

| Function | Meaning | Returns |
|---|---|---|
| `stdev(cursor)` | sample standard deviation | `Float?` |
| `pstdev(cursor)` | population standard deviation | `Float?` |
| `variance(cursor)` | sample variance | `Float?` |
| `pvariance(cursor)` | population variance | `Float?` |

Each is `null` exactly when the read is cold ([LSER.19.8]), and `stdev` and
`variance` also when one sample is held. How each is computed is [LSER.16.3.3].

*ratified*  —  *see also:* [LSER.16.3.3](#LSER-16-3-3), [LSER.19.8](#LSER-19-8)

(LSER-16-3-2)=
[LSER.16.3.2] Default recommendation when unsure: **sample**
(`stdev` / `variance`), matching Python's default and handling
small windows gracefully. Authors writing anomaly rules over a
full-population window use the `p*` variants.

(LSER-16-3-3)=
[LSER.16.3.3] **`sum`, `mean` and the four dispersion statistics are computed in
one order per backing ([LSER.18.1]), so two conforming runtimes agree bit for bit.**
Every step below is one correctly rounded IEEE-754 binary64 operation, taken in
the order written ([LDET.3.4]). The samples are $x_1, \dots, x_n$, as `Float`: an
`Int` sample converts round-to-nearest-even, and an `Int` slot's `sum` is
[LSER.16.2.2]'s integer sum instead. Their order is the backing's:

- `all_time` (`SeriesBackendWelfordEwma`): arrival order;
- `sliding` (`SeriesBackendRingBuffer`): the live samples, oldest to newest;
- `sample` (`SeriesBackendReservoir`): the bag's slots, 0 to $n-1$ ([LSMP.2.1]).

**`sum`**, every backing: $S_0 = +0$, $S_k = S_{k-1} + x_k$; `sum` is $S_n$.

**`all_time` (`SeriesBackendWelfordEwma`)** keeps constant state. $\mu_1 = x_1$, $M_1 = +0$; for
$k = 2, \dots, n$:

$\delta = x_k - \mu_{k-1}, \quad \mu_k = \mu_{k-1} + \delta / k, \quad M_k = M_{k-1} + \delta \cdot (x_k - \mu_k)$

**`sample` (`SeriesBackendReservoir`).** $\mu_0 = +0$, $M_0 = +0$; for $k = 1, \dots, n$, the same
three steps as `SeriesBackendWelfordEwma`, with $\delta = x_k - \mu_{k-1}$.

On both, `mean` is $\mu_n$ and $M = M_n$.

**`sliding` (`SeriesBackendRingBuffer`)** makes two passes. `mean` is $\mu = S_n / n$. Then
$Q_0 = +0$, $d = x_k - \mu$, $Q_k = Q_{k-1} + d \cdot d$, and $M = Q_n$.

**On every backing**, `variance` is $M / (n - 1)$, `pvariance` is $M / n$,
`stdev` is $\sqrt{\mathit{variance}}$ and `pstdev` is $\sqrt{\mathit{pvariance}}$. On `all_time` and
`sliding` only, a variance that is not greater than $0$ gives a deviation of $+0$
rather than its square root.

**Null.** `mean` and the four dispersion statistics are `null` when the read is
cold ([LSER.19.8]). `variance` and `stdev`,
the sample forms, are also `null` when $n = 1$: one sample measures no
dispersion. `pvariance` and `pstdev` at $n = 1$ are $+0$.

*ratified*  —  *see also:* [LDET.3.4](#LDET-3-4), [LSER.16.2.2](#LSER-16-2-2), [LSER.18.1](#LSER-18-1), [LSER.19.8](#LSER-19-8), [LSMP.2.1](#LSMP-2-1)

(LSER-16-4)=
### Quantiles [LSER.16.4]

(LSER-16-4-1)=
[LSER.16.4.1] `pXX` for any integer percentile in `1..99`
inclusive, returning `Float?` — `null` exactly when the read is
cold ([LSER.19.8]). `p0` and `p100` are not legal; authors use `min`
and `max` for the extremes. Sub-percent quantiles (`p99.9`,
`p99.99`) are deferred; the grammar reserves the syntactic
space.

*ratified*  —  *see also:* [LSER.19.8](#LSER-19-8)

(LSER-16-4-2)=
[LSER.16.4.2] `p50` is equivalent to `median`; both exist for
clarity at the call site (`p50` reads distribution-analysis,
`median` reads central-tendency).

(LSER-16-5)=
### Cardinality [LSER.16.5]

(LSER-16-5-1)=
[LSER.16.5.1] `count_distinct(cursor)` returns the count of
distinct values seen.

(LSER-16-5-2)=
[LSER.16.5.2] `count_distinct` is **exact** (a distinct-value set) on a bounded
`sliding` window. Its `all_time` and `tumbling` forms have no exact unbounded
backend atom in v1, so, like the unbounded percentiles, they are not available
in v1 ([LSER.18]).

*ratified*  —  *see also:* [LSER.18](#LSER-18)

(LSER-16-6)=
### Per-value frequency [LSER.16.6]

(LSER-16-6-1)=
[LSER.16.6.1] `count_of(cursor, value)` returns the count of
`value` in the observed series. Backed by an exact frequency
table on a bounded `sliding` window; its `all_time` and `tumbling`
forms have no exact backend in v1 and are rejected (‡/§, [LSER.18]).

*ratified*  —  *see also:* [LSER.18](#LSER-18)

(LSER-16-6-2)=
[LSER.16.6.2] `count_of` is not admitted under the `sample` time
model — a reservoir bag does not preserve observation counts. The
compiler must reject it with a hint pointing at `sliding`.

(LSER-16-7)=
### Set membership [LSER.16.7]

(LSER-16-7-1)=
[LSER.16.7.1] `contains(cursor, value)` returns whether `value`
has been observed in the series. Backed by an exact set on a bounded
`sliding` window; its
`all_time` and `tumbling` forms are rejected (‡/§, [LSER.18]).

*ratified*  —  *see also:* [LSER.18](#LSER-18)

(LSER-16-7-2)=
[LSER.16.7.2] The compiler rejects `contains` under the `sample` time
model ([LSMP.3.2a]).

*see also:* [LSMP.3.2a](#LSMP-3-2a)

(LSER-16-8)=
### Boolean aggregations [LSER.16.8]

| Function | Meaning | Returns |
|---|---|---|
| `bool_and(cursor)` | true iff every sample is true | `Bool?` |
| `bool_or(cursor)` | true iff any sample is true | `Bool?` |

Each is `null` exactly when the read is cold ([LSER.19.8]).

*see also:* [LSER.19.8](#LSER-19-8)

(LSER-16-8-1)=
[LSER.16.8.1] Useful for "any alarm fired in the last 5 min" or
"continuous occupancy signal" patterns. Legal only on series
whose element type is `Bool`.

(LSER-16-8-3)=
[LSER.16.8.3] `bool_and` / `bool_or` are **not** admitted under the
`sample` time model. They are exact predicates, not statistical
summaries: a uniform reservoir can omit the one value that determines
the AND/OR, so the reduction over the sample is not faithful. The
compiler rejects `bool_and sample <n>` / `bool_or sample <n>` with
`DS_VALIDATE_SERIES_AGG_TIME_MODEL_MISMATCH` — see
[LSMP.3]. (The `SeriesBackendReservoir` runtime backing
can compute them over the bag, but that path is unreachable in v1.)

*see also:* [LSMP.3](#LSMP-3)

(LSER-16-9)=
### Temporal [LSER.16.9]

| Function | Meaning | Returns |
|---|---|---|
| `first(cursor)` | value of first (oldest) sample | slot type, nullable |
| `last(cursor)` | value of last (newest) sample | slot type, nullable |
| `rate(cursor)` | `(last - first) / elapsed_seconds` | `Float?` |
| `direction(cursor)` | `-1` falling, `0` steady or `+1` rising, the sign of the two newest samples' difference ([LSER.10.9]) | `Int?` |

Each is `null` exactly when the read is cold ([LSER.19.8]); `direction` is
also `null` when the window holds one sample ([LSER.10.9]), and `rate` is also
`null` when no time elapses between the window's first and last samples — a
window of one sample included — since there is no elapsed time to divide by.

*ratified*  —  *see also:* [LSER.10.9](#LSER-10-9), [LSER.19.8](#LSER-19-8)

(LSER-16-9-1)=
[LSER.16.9.1] `rate` and `direction` require numeric element
types; `first` and `last` are type-agnostic. `direction` uses a
small trailing-tail buffer (sized for slope computation, not
full history), independent of the declared time model.

(LSER-16-9-4)=
[LSER.16.9.4] The compiler rejects `rate` / `direction` under the
`sample` time model ([LSMP.3.2a]).

*see also:* [LSMP.3.2a](#LSMP-3-2a)

(LSER-16-9-3)=
[LSER.16.9.3] The compiler rejects `first` / `last` under the `sample`
time model ([LSMP.3.2a]).

*see also:* [LSMP.3.2a](#LSMP-3-2a)

(LSER-16-11)=
### Signal-processing aggregations [LSER.16.11]

(LSER-16-11-1)=
[LSER.16.11.1] Three v1 aggregations characterise the *temporal structure*
of event-driven boolean and rate signals — `active_fraction`
(time-in-state), `onset_rate` (rising-edge rate), and `integral`
(time-weighted ∫x dt) — and extend the matrices of [LSER.17]–[LSER.18].
Their semantics, backings (`SeriesBackendIntervalPulse`, `SeriesBackendNumericIntegral`; `onset_rate` reuses `SeriesBackendRingBuffer`), the
`gap-policy` phrase ([LSER.13.5]), determinism, and bounded-memory
availability are specified normatively in
[LSIG].

---

*see also:* [LSER.13.5](#LSER-13-5), [LSER.17](#LSER-17), [LSER.18](#LSER-18)

(LSER-17)=
## Per-type aggregation applicability [LSER.17]

*checks:* `alloy×2`

(LSER-17-1)=
[LSER.17.1] Every slot carries a value type per [LFAC]. Not
every aggregation applies to every type. The compiler must
reject declarations of aggregations whose type does not match
the slot's value type.

*checks:* `alloy`

(LSER-17-2)=
[LSER.17.2] The applicability matrix:

| Aggregation | Slot value types | Returns |
|---|---|---|
| `min`, `max` | `Float`, `Int`, `Duration` | the slot's type, nullable |
| `sum` | `Float`, `Int`, `Duration` | the slot's type |
| `mean`, `median`, `variance`, `stdev`, `pvariance`, `pstdev`, `pXX` | `Float`, `Int`, `Duration` | `Float?` |
| `count` | any sampled type | `Int` |
| `count_distinct` | any sampled type | `Int` |
| `count_of` | any sampled type | `Int` |
| `contains` | any sampled type | `Bool` |
| `bool_and`, `bool_or` | `Bool` only | `Bool?` |
| `first`, `last` | any sampled type | the slot's type, nullable |
| `rate` | `Float`, `Int`, `Duration` | `Float?` |
| `direction` | `Float`, `Int`, `Duration` | `Int?` — `-1`, `0` or `+1` |

The sampled types are `Float`, `Int`, `Bool`, `String`, `Time`, `Date` and
`Duration`, a unit-typed slot, and an opaque type over any of them. No row admits
any other slot ([LSER.17.4], [LSER.17.5]).

**`Returns` is the static type of both call forms** — `<agg>(cursor)`
([LSER.16.1]) and the companion slot ([LSER.6]) — so every downstream check
over the value has a type to work with. A nullable return is `null` exactly when
the read is cold ([LSER.19.8]), for `direction`, `variance` and `stdev` also when
the window holds one sample ([LSER.10.9], [LSER.16.3.3]), and for `rate` also when no time elapses between the
window's first and last samples ([LSER.16.9]); the others answer their concrete
cold value.

**The statistical family returns `Float` whatever the slot holds**, `median`
and `pXX` included: `p50` of an `Int` slot's `[1, 2]` is `1.5`. They
interpolate rather than select an observed value, which is what makes the
column a function of the aggregation alone and needs no tie-break rule.
`min`, `max`, `first` and `last` preserve the slot's type because they *do*
select an observed value.

**Over a slot of the `time` dimension ([LTIM.1.3.5]) `mean`, `median`, `stdev`,
`pstdev` and `pXX` return `Duration?`.** The engine computes the `Float` this
clause states, and the result rounds as a `Duration` scaled by a `Float` does
([LTIM.4.1.1]). `variance` and `pvariance` stay `Float?`.

**`pXX` interpolates linearly between the two order statistics that bracket
it, and `median` is `p50`.** $p$ is the integer `XX`. The engine sorts the
window's $n$ samples ascending as `Float`, an `Int` sample converting
round-to-nearest-even and $-0$ ordering before $+0$, giving
$x_0 \le \dots \le x_{n-1}$. In exact integers:

$\mathit{num} = (n-1)\,p, \quad \mathit{lo} = \lfloor \mathit{num}/100 \rfloor, \quad \mathit{frac} = \mathit{num} \bmod 100$

The result is $x_{\mathit{lo}}$ when $\mathit{frac} = 0$, when
$x_{\mathit{lo}} = x_{\mathit{lo}+1}$, or when $x_{\mathit{lo}} = -\infty$ and
$x_{\mathit{lo}+1} \ne +\infty$. Otherwise it is

$x_{\mathit{lo}} + \frac{\mathit{frac}}{100}\,(x_{\mathit{lo}+1} - x_{\mathit{lo}})$

and the engine **must** evaluate it as correctly rounded IEEE-754 operations in
exactly this order: the subtraction, the division $\mathit{frac}/100$, the
multiplication, the addition. A cold window ($n = 0$) reads `null`
([LSER.19.8]); $n = 1$ reads $x_0$. A window holding both $-\infty$ and
$+\infty$ as the bracketing pair reads NaN, which no slot admits ([LEXP.4.2]).

`sum` preserves the slot's type, so an `Int` slot accumulates in a 64-bit
signed integer and wraps per [LSER.16.2.2]; summing a `Float` slot is the
stated way to trade exactness for magnitude range.

The three signal aggregations are not in this matrix; [LSIG.1.1] carries
their element types, time models and returns together.

*ratified*  —  *checks:* `alloy`  —  *see also:* [LEXP.4.2](#LEXP-4-2), [LSER.10.9](#LSER-10-9), [LSER.16.1](#LSER-16-1), [LSER.16.2.2](#LSER-16-2-2), [LSER.16.3.3](#LSER-16-3-3), [LSER.16.9](#LSER-16-9), [LSER.17.4](#LSER-17-4), [LSER.17.5](#LSER-17-5), [LSER.19.8](#LSER-19-8), [LSER.6](#LSER-6), [LSIG.1.1](#LSIG-1-1), [LTIM.1.3.5](#LTIM-1-3-5), [LTIM.4.1.1](#LTIM-4-1-1)

(LSER-17-3)=
[LSER.17.3] `String` slots admit `count`, `count_distinct`,
`count_of`, `contains`, `first`, `last`. The compiler **must** refuse a
numeric aggregation on a `String` slot with
`DS_VALIDATE_SERIES_AGG_TYPE_MISMATCH`, and the diagnostic **should** name
the aggregations the slot admits.

(LSER-17-4)=
[LSER.17.4] **A `Json` slot takes no aggregation.** The compiler **must** refuse
every aggregation on a `Json` slot with `DS_VALIDATE_SERIES_AGG_TYPE_MISMATCH`.
An author who needs to aggregate a field of a `Json` slot projects it into a
typed slot and declares the series on that slot.

(LSER-17-5)=
[LSER.17.5] **A `Bytes` slot and a fact-reference slot take no aggregation.** The
compiler **must** refuse every aggregation on one with
`DS_VALIDATE_SERIES_AGG_TYPE_MISMATCH`, and likewise on a slot of an opaque type
over `Bytes` or `Json` ([LSER.17.4]).

*see also:* [LSER.17.4](#LSER-17-4)

(LSER-17-6)=
[LSER.17.6] **Quantile range.** `pXX` requires `XX` to be an
integer in `1..99` inclusive. The compiler **must** refuse any other `XX` —
`p0`, `p100`, and `p101` and higher — with
`DS_VALIDATE_SERIES_INVALID_QUANTILE`. For `p0` and `p100` the diagnostic
**should** name `min` / `max`.

*ratified*

(LSER-17-7)=
[LSER.17.7] Type applicability and time-model applicability
are orthogonal axes. A `min` aggregation requires a numeric
type (per [LSER.17.2]) **and** a time model that admits exact
min / max (`all_time`, `sliding`, `sample` — `tumbling` has no exact
backing, § [LSER.18]). Both axes must be satisfied. The compiler reports
the first failing axis.

---

*checks:* `alloy×4`  —  *see also:* [LSER.17.2](#LSER-17-2), [LSER.18](#LSER-18)

(LSER-18)=
## Agg × time-model support matrix [LSER.18]

*checks:* `alloy×2`

(LSER-18-1)=
[LSER.18.1] Normative cross-reference. Each row is one aggregation;
columns are the four v1 time models. Every v1 cell is **exact** — there is
no accuracy phrase. Cells contain:

- **✓ exact** — exact answer at O(1) state or O(N) sample count.
- **✓** — exact, nothing further to note.
- **✗** — not available in v1: either the combination has no defined semantics,
  or it has no exact backing (see the footnotes).

| Aggregation | `all_time` | `sliding` | `tumbling` | `sample` | Backing | At capacity |
|---|---|---|---|---|---|---|
| `mean` | ✓ exact | ✓ exact | ✗ § | ✓ exact | `SeriesBackendWelfordEwma` / `SeriesBackendRingBuffer` / `SeriesBackendReservoir` | drop |
| `sum` | ✓ exact | ✓ exact | ✗ § | ✓ exact | `SeriesBackendWelfordEwma` / `SeriesBackendRingBuffer` / `SeriesBackendReservoir` | drop |
| `count` | ✓ exact | ✓ exact | ✗ § | ✓ exact | `SeriesBackendWelfordEwma` / `SeriesBackendRingBuffer` / `SeriesBackendReservoir` | drop |
| `min` | ✓ exact | ✓ exact | ✗ § | ✓ exact | `SeriesBackendWelfordEwma` / `SeriesBackendMonotonicDeque` / `SeriesBackendReservoir` | drop |
| `max` | ✓ exact | ✓ exact | ✗ § | ✓ exact | `SeriesBackendWelfordEwma` / `SeriesBackendMonotonicDeque` / `SeriesBackendReservoir` | drop |
| `stdev`, `pstdev`, `variance`, `pvariance` | ✓ exact | ✓ exact | ✗ § | ✓ exact | `SeriesBackendWelfordEwma` / `SeriesBackendRingBuffer` / `SeriesBackendReservoir` | drop |
| `rate`, `direction` | ✓ | ✓ | ✗ § | ✗ | `SeriesBackendWelfordEwma` / `SeriesBackendRingBuffer` | drop |
| `first` | ✓ | ✓ exact | ✗ § | ✗ | `SeriesBackendWelfordEwma` / `SeriesBackendFifoDeque` | drop |
| `last` | ✓ | ✓ exact | ✗ § | ✗ | `SeriesBackendWelfordEwma` / `SeriesBackendFifoDeque` | drop |
| `bool_and`, `bool_or` | ✓ | ✓ exact | ✗ § | ✗ | `SeriesBackendWelfordEwma` / `SeriesBackendFifoDeque` | drop |
| `median`, `pXX` | ✗ † | ✓ exact | ✗ † | ✓ exact | `SeriesBackendRingBuffer` / `SeriesBackendReservoir` | drop |
| `count_distinct` | ✗ ‡ | ✓ exact | ✗ ‡ | ✗ | exact set (sliding) | drop |
| `count_of` | ✗ ‡ | ✓ exact | ✗ ‡ | ✗ | exact table (sliding) | drop |
| `contains` | ✗ ‡ | ✓ exact | ✗ ‡ | ✗ | exact set (sliding) | drop |

**At capacity** is what a declared `capacity` ([LSER.13.14]) does when an
identity's backing is full: **drop** evicts that identity's oldest sample, and
the read then covers the samples retained. A constant-state backing (`SeriesBackendWelfordEwma`)
retains no samples, so `capacity` never binds it. The time-normalised signal
aggregations refuse instead ([LSIG.1.1]).

† `median` / `pXX` need a **bounded** window for an exact quantile; their
`all_time` and `tumbling` forms are not available in v1.

‡ `count_distinct` / `count_of` / `contains` are exact on a **bounded**
(`sliding`) window only. Their `all_time` and `tumbling` forms have no exact
unbounded backend atom in v1, so, like the unbounded percentiles, they are
**not available in v1** ([LSER.18]).

§ **No `tumbling` form is backed in this edition** ([LSER.14.4.5]). The
per-bucket statistic over a completed bucket needs a backend that does not
ship; routing a `tumbling` line to the cumulative `SeriesBackendWelfordEwma` would return an
exponentially-weighted estimate (and `exp()` is not even cross-platform
bit-exact), and routing it to a windowed backing would read a sliding window,
not a bucket. The compiler refuses every `tumbling` line
(`DS_VALIDATE_SERIES_NO_EXACT_BACKING`, [LSER.15.2]).

*ratified*  —  *checks:* `alloy`  —  *see also:* [LSER.13.14](#LSER-13-14), [LSER.14.4.5](#LSER-14-4-5), [LSER.15.2](#LSER-15-2), [LSER.18](#LSER-18), [LSIG.1.1](#LSIG-1-1)

(LSER-18-2)=
[LSER.18.2] **Sliding descriptive and dispersion stats are exact in v1.**
`mean` / `sum` / `count` / `stdev` / `variance` on `sliding` compile to the
raw-sample ring buffer (`SeriesBackendRingBuffer`), **exact** over the true window at O(window·rate)
state — so `mean = sum/count` holds. Their **`tumbling`** forms are *not* exact
in v1: the per-bucket backing they need is unimplemented (§ above), so they are
rejected, as every `tumbling` line is in this edition ([LSER.14.4.5]). v1 has
no exponentially-weighted (`decay`) profile and no sub-linear true-window
statistic.

*ratified*  —  *see also:* [LSER.14.4.5](#LSER-14-4-5)

(LSER-6)=
## Companion-slot desugaring [LSER.6]

(LSER-6-10)=
### The series cursor [LSER.6.10]

(LSER-6-10-1)=
[LSER.6.10.1] A *series cursor* is a compile-time designator
that identifies which observation on which slot, under which
label, to access. It has up to three components:

1. **Binding** — always present (`t`, `j`, `l`, …)
2. **Slot designator** — present when cross-slot
   disambiguation is needed
3. **Label** — present when the target observation line was
   declared `as <label>`

(LSER-6-10-2)=
[LSER.6.10.2] Four syntactic forms, from shortest to most
qualified:

| Form | Components | Required when |
|---|---|---|
| `binding` | binding only | single series-carrying slot, unlabelled observation |
| `binding.label` | binding + label | single series-carrying slot, labelled observation |
| `binding.slot` | binding + slot | multi-slot schema, unlabelled |
| `binding.slot.label` | binding + slot + label | multi-slot schema, labelled |

(LSER-6-10-3)=
[LSER.6.10.3] The compiler accepts the shortest form that
resolves unambiguously. A shorter form that is ambiguous is
rejected with a diagnostic naming the conflicting candidates
and the required qualifying form.

(LSER-6-11)=
### Cursor resolution [LSER.6.11]

(LSER-6-11-1)=
[LSER.6.11.1] Given a cursor, the compiler resolves it to a
(slot, observation, backing) triple:

1. **Slot**: if a slot designator is present, restrict to
   that slot's series. If absent, collect all series across
   all slots of the binding's schema.
2. **Label**: if a label is present, restrict to
   observations declared `as <label>`. If absent, restrict
   to unlabelled observations.
3. **Aggregation**: within the resolved observation set,
   find declarations covering the requested aggregation:
   - Exactly one → resolution succeeds.
   - Zero → compile error: observation not declared. Message
     names the binding and aggregation; suggests declaring
     a `series`.
   - Two or more → compile error: ambiguous. Message names
     the conflicting (slot, label) pairs and the required
     qualifying cursor form.

(LSER-6-11-2)=
[LSER.6.11.2] **Slot-designator context.** `t.slot` has two
interpretations depending on syntactic position:

- **Slot read** — in a comparison or arithmetic expression,
  reads the slot's current fact value.
- **Cursor component** — as the cursor argument to a series
  aggregation call, designates the slot within the binding's
  schema.

The grammar distinguishes these positions as separate
productions. Because typed scalar slot values (Float, Int,
Bool, String) cannot be passed as the first argument to a
series aggregation function, no ambiguity arises at call
sites.

(LSER-6-11-3)=
[LSER.6.11.3] **A series read takes no window argument.** A series
aggregation call's arguments are its cursor, and for `count_of` and `contains`
the value ([LSER.6.5]); nothing else. The window a read sees is the window of the
declaration [LSER.6.11.1] resolves it to, and where one slot declares an
aggregation on more than one line, the cursor's label is what chooses between
them. The compiler **must** refuse any further argument, a duration or any
other value, with `DS_VALIDATE_BAD_ARITY` ([LEXP.3.1]).

*ratified*  —  *see also:* [LEXP.3.1](#LEXP-3-1), [LSER.6.11.1](#LSER-6-11-1), [LSER.6.5](#LSER-6-5)

(LSER-6-12)=
### Label–slot collision [LSER.6.12]

(LSER-6-12-1)=
[LSER.6.12.1] A label name used in `as <label>` must not
match any slot name on the schema being observed. The
compiler must reject the series declaration at declaration
time. This ensures that for any binding `t`, the dotted
chain `t.foo` is unambiguous: either `foo` is a slot name
(slot read or slot designator) or a label name — never both.

(LSER-6-1)=
[LSER.6.1] Authors can reference maintained statistics on a
series-tracked slot via a companion-slot sugar on the binding — a
declared aggregation `agg` on slot `state` is read as `t.agg`
alongside `t.state` itself.

*ratified*

(LSER-6-2)=
[LSER.6.2] Here `t.mean` resolves to the `mean sliding 10_min`
observation declared on the slot. Same for `t.stdev`,
`t.variance`, `t.direction`, and other aggregations declared on
the slot. The cursor [LSER.6.10] is the binding alone (`t`);
it resolves to `state` because it is the only series-carrying
slot on this schema.

*see also:* [LSER.6.10](#LSER-6-10)

(LSER-6-3)=
### Companion slots (resolved forms) [LSER.6.3]

The companion-slot form and expression form are equivalent
for any cursor shape [LSER.6.10.2]:

| Companion-slot form | Expression form |
|---|---|
| `cursor.<agg>` | `<agg>(cursor)` |

*see also:* [LSER.6.10.2](#LSER-6-10-2)

(LSER-6-4)=
[LSER.6.4] Companion-slot access reads the observation
declared on the slot. Cursor resolution per [LSER.6.11]
determines the (slot, label, backing) triple. If the slot
has multiple observations covering the same aggregation
under different time models, the cursor must carry a label
component per [LSER.6.8]. If only one observation covers the
aggregation, the binding-only cursor resolves directly.

*see also:* [LSER.6.11](#LSER-6-11), [LSER.6.8](#LSER-6-8)

(LSER-6-5)=
[LSER.6.5] Aggregations that take a value argument —
`count_of(cursor, value)` and `contains(cursor, value)` —
accept a cursor as their first argument. The companion-slot
form is unavailable: there is no syntactic position for the
value argument in the companion form. Use the expression form
exclusively.

(LSER-6-6)=
### Collision with schema slots [LSER.6.6]

(LSER-6-6-1)=
[LSER.6.6.1] The aggregation names are reserved words
([LLEX.9.5]) and carry rows on [LLEX.9.6]. An author must not
declare a slot under one of them, and the compiler must refuse
such a declaration at schema / series declaration time.

The reservation is **unconditional**. It does not depend on the
schema having a declared series, and a slot named `mean` is
refused whether or not one exists.

What makes these names reservable at all is a collision rather
than a position argument: [LSER.6]'s companion form
`cursor.<agg>` is syntactically identical to a slot read, so an
author-declared slot and the aggregation occupy one position and
one must yield. Conditioning the refusal on a series is what
made adding a series to a schema retroactively illegalise a slot
declared elsewhere, which is the action at a distance the single
list exists to remove.

*ratified*  —  *see also:* [LLEX.9.5](#LLEX-9-5), [LLEX.9.6](#LLEX-9-6), [LSER.6](#LSER-6)

(LSER-6-7)=
### No series, no sugar [LSER.6.7]

(LSER-6-7-1)=
[LSER.6.7.1] Referencing any cursor form — `t.mean`,
`t.recent.mean`, `mean(t.recent)` — on a binding whose
schema has no declared observation covering the (slot, label,
aggregation) triple is a compile error naming the missing
declaration ([LSER.6.9.4]). One way to introduce a series, one way to
reference it; no hidden generation.

*see also:* [LSER.6.9.4](#LSER-6-9-4)

(LSER-6-8)=
### Labels and disambiguation [LSER.6.8]

(LSER-6-8-1)=
[LSER.6.8.1] A series line may carry `as <label>` to
namespace every aggregation in the line under the label.
Labelled observations are accessed via a cursor carrying the
label component: companion form `t.<label>.<agg>` ≡
expression form `<agg>(t.<label>)`. The unlabelled companion
slot `t.<agg>` is **not** produced by a labelled line.

*ratified*

(LSER-6-8-2)=
[LSER.6.8.2] If only one line on the slot covers a given
aggregation and the line is unlabelled, both `t.<agg>` and
`<agg>(t)` are legal.

*ratified*

(LSER-6-8-3)=
[LSER.6.8.3] If multiple lines on the slot cover the same
aggregation, the compiler must reject the declaration unless
every line covering that aggregation carries `as`. The error
names the conflicting unlabelled lines and points the author
at the resolution (add `as <label>` to each).

*ratified*

(LSER-6-8-4)=
[LSER.6.8.4] Unlabelled access to an aggregation that exists
only under labels is a compile error at the call site,
listing the available labels and asking the author to pick
one (`t.recent.mean` or `t.hourly.mean`).

*ratified*

(LSER-6-8-5)=
[LSER.6.8.5] An author may add `as` to a single-line slot
for self-documentation. On a slot so labelled the
unlabelled companion form `t.<agg>` does not resolve; the
labelled form is the only access.

(LSER-6-8-6)=
[LSER.6.8.6] Two lines under the same label must not declare
the same aggregation. The compiler must reject duplicate
(label, aggregation) pairs as duplicate declarations.

(LSER-6-8-7)=
[LSER.6.8.7] A label that collides with a schema slot's name
on the schema being observed is a compile error per
[LSER.6.12].

*see also:* [LSER.6.12](#LSER-6-12)

(LSER-6-9)=
### Cross-slot disambiguation [LSER.6.9]

(LSER-6-9-1)=
[LSER.6.9.1] A schema may carry series declarations on more
than one slot (e.g. `series LayerComplete.layer_time_s` and
`series LayerComplete.ts`). Companion-slot reads on bindings
of that schema are disambiguated by which slot's series
actually declares the requested aggregation:

(LSER-6-9-2)=
[LSER.6.9.2] If exactly one slot's series declares the
aggregation, the binding-only cursor resolves to that slot's
series unambiguously. No slot designator required.

(LSER-6-9-3)=
[LSER.6.9.3] If more than one slot's series declares the
same aggregation, `t.<agg>` is ambiguous and the compiler
must raise `DS_VALIDATE_AMBIGUOUS_COMPANION_SLOT`. The author
must add the slot designator: `t.<slot>.<agg>` or
`<agg>(t.<slot>)`.

*ratified*

(LSER-6-9-4)=
[LSER.6.9.4] If no slot's series declares the aggregation,
the compiler must raise
`DS_VALIDATE_NO_SERIES_FOR_COMPANION_SLOT`, in the companion-slot form and the
call form alike ([LSER.10.6]).

*see also:* [LSER.10.6](#LSER-10-6)

(LSER-6-9-5)=
[LSER.6.9.5] The disambiguation in [LSER.6.9] is orthogonal
to the within-slot label mechanism in [LSER.6.8]. Both can
apply: a schema with two slots each having multiple labelled
time-model lines resolves first by slot ([LSER.6.9.2]–
[LSER.6.9.3]), then by label within that slot's series
([LSER.6.8.1]–[LSER.6.8.5]).

*see also:* [LSER.6.8](#LSER-6-8), [LSER.6.8.1](#LSER-6-8-1), [LSER.6.8.5](#LSER-6-8-5), [LSER.6.9](#LSER-6-9), [LSER.6.9.2](#LSER-6-9-2), [LSER.6.9.3](#LSER-6-9-3)

(LSER-6-9-6)=
[LSER.6.9.6] When both cross-slot and label disambiguation
are needed, the full cursor `binding.slot.label` carries both
components simultaneously. The slot designator is resolved
first per [LSER.6.11.1], then the label within that slot's
series.

---

*see also:* [LSER.6.11.1](#LSER-6-11-1)

(LSER-7)=
## Explicit declarations only [LSER.7]

(LSER-7-1)=
[LSER.7.1] Every series an author wants is declared explicitly
at file scope. DS does not:

(LSER-7-2)=
- [LSER.7.2] Auto-declare series on every numeric slot.

(LSER-7-3)=
- [LSER.7.3] Infer series from `t.mean` references (authors
  get a compile error if the series isn't declared).

(LSER-7-4)=
- [LSER.7.4] Allow per-adapter configuration to enable series
  behind the author's back.

(LSER-7-5)=
[LSER.7.5] This tightens the model: the grammar has exactly
one way to introduce a series (per [LSER.13.5]), and the
author always sees the declaration for any statistic their
rules reference. No surprises at runtime about what's being
maintained.

*see also:* [LSER.13.5](#LSER-13-5)

(LSER-7-6)=
### Identity slot designation [LSER.7.6]

(LSER-7-6-1)=
[LSER.7.6.1] Every series carries state per identity. That
identity is **declared, never inferred from a slot's name or
from an absence**: it is named explicitly with `by: <slot>` in
the block-options on the declaration, or follows the schema's
declared identity when `by:` is omitted:

- on a **`logical`** schema whose key is exactly one slot, an
  omitted `by:` groups by that slot ([LFAC.1.7]). A schema whose
  key is ∅ (every slot `mutable`) has no declared identity to
  follow, and the compiler must reject the declaration with
  `DS_VALIDATE_SERIES_NO_IDENTITY_SLOT` ([LSER.10.13]).
  `by: none` ([LSER.7.6.2]) is the explicit way to ask for a
  single global allocation.
- on a **`logical`** schema whose key is several slots, there is
  no default either: a composite key is not an identity a series
  can follow ([LSER.10.13] binds one slot), and the compiler must
  reject an omitted `by:` with the same code. The author names the
  one slot to group by, or `by: none`.
- on a schema of any other lifecycle (**`ttl`**, **`explicit`**,
  **`activation`**), which carries no identity markers
  ([LFAC.1.7.6]), there is no default: the declaration must
  name `by: <slot>` (or `by: none`) explicitly, and the compiler
  must reject an omitted `by:` with the same code.

The compiler errors on any `by:` naming a slot the schema does not
have. `entity_id` is an ordinary slot name with no
series-grouping privilege.

**One slot, and a composite key does not widen it.** A series row
is keyed on one identity value; grouping by a tuple would put
tuple construction and comparison on the absorb path of every
series, for a schema shape an author can express instead by
carrying the composite value in a slot of its own. Taking the
first `key` slot of a composite instead would silently merge entities
that differ only in the slots it drops, and that is the reading this
clause refuses.

*ratified*  —  *see also:* [LFAC.1.7](#LFAC-1-7), [LFAC.1.7.6](#LFAC-1-7-6), [LSER.10.13](#LSER-10-13), [LSER.7.6.2](#LSER-7-6-2)

(LSER-7-6-2)=
[LSER.7.6.2] `by: none` opts into a single state allocation
per (schema, slot) with no per-identity breakdown. Useful for
global aggregations across all entities of a schema: rolling
1_h count of all `DoorOpened` events, or of all `CallError` facts
regardless of target service. Authors
who want both per-entity and global statistics declare two
series on two slots.

(LSER-7-6-3)=
[LSER.7.6.3] A series may be declared on a schema of any
lifecycle. On `logical` schemas, sample absorption follows
the no-op reassertion discipline ([LFAC.2]) — samples enter
on meaningful updates only. On every other lifecycle, every fact
assertion absorbs as a sample; `ttl` has no no-op suppression
because each fact assertion is meaningful by `ttl`'s own
framing per [LFAC.1.3].

*ratified*  —  *see also:* [LFAC.1.3](#LFAC-1-3), [LFAC.2](#LFAC-2)

(LSER-7-7)=
### Schema scoping [LSER.7.7]

(LSER-7-7-1)=
[LSER.7.7.1] A series declaration names a slot but not (by
default) a schema. The compiler resolves the slot name to the
unique schema in scope that has a slot of that name. When two
or more schemas in scope have a slot of the named name, the
declaration is ambiguous and the compiler demands an explicit
qualifier — the schema name prefixed onto the slot reference.

(LSER-7-7-2)=
[LSER.7.7.2] Resolution rules:

- Zero matches → compile error: `no schema declares slot
  <name>`. Declared series must reach a real slot.
- Exactly one match → unqualified form binds to that schema.
- Two or more matches → compile error: `ambiguous; qualify as
  <Schema1>.<slot> or <Schema2>.<slot>`. The author picks one
  (or splits into multiple declarations).

(LSER-7-7-3)=
[LSER.7.7.3] Adding a new schema with a same-named slot in a
later edit makes the previously-unambiguous declaration
ambiguous; the build fails at the declaration site, not
silently. Authors qualify or rename in response.

(LSER-7-7-4)=
[LSER.7.7.4] Grammar accepts the qualified form
`<NAME>.<NAME>` per [LGRA.7]; unqualified `<NAME>` is
also accepted. Validator enforces the resolution rules above.

---

*see also:* [LGRA.7](#LGRA-7)

(LSER-8)=
## Interactions [LSER.8]

(LSER-8-1)=
### With `logical` emit [LSER.8.1]

(LSER-8-1-1)=
[LSER.8.1.1] A `where` that reads a series aggregation is time-dependent
([LTIM.2.4.1]), and [LTIM.2.4]–[LTIM.2.7] govern it as they govern a clock
read. It is re-evaluated when the pattern's bindings change and on every tick,
against the series as they stood when the pump began ([LTIM.2.4.3]). Its rule
fires once per false → true edge for a matched fact wrapper ([LTIM.2.5.1]). A
`logical` fact it justifies is retracted at the pump whose snapshot refuses the
match ([LLOG.3.11.1]). On a rule with more than one positive pattern it is
refused ([LTIM.2.6.2]).

*ratified*  —  *see also:* [LLOG.3.11.1](#LLOG-3-11-1), [LTIM.2.4](#LTIM-2-4), [LTIM.2.4.1](#LTIM-2-4-1), [LTIM.2.4.3](#LTIM-2-4-3), [LTIM.2.5.1](#LTIM-2-5-1), [LTIM.2.6.2](#LTIM-2-6-2), [LTIM.2.7](#LTIM-2-7)

(LSER-8-2)=
### With the `dwell` alias [LSER.8.2]

(LSER-8-2-1)=
[LSER.8.2.1] `t.dwell` is **not** a series query — it's a
compile-time alias for the time since the fact entered working
memory ([LEXP.9.5.1]) on `logical`-schema bindings. Works without any declared series; independent of
series maintenance. See [LFAC].

*see also:* [LEXP.9.5.1](#LEXP-9-5-1)

(LSER-8-3)=
### With the storage samples plane [LSER.8.3]

(LSER-8-3-1)=
[LSER.8.3.1] Adding `persist: <dur>` to a series declaration's
block-options forwards each sample to the samples plane (see
[LSTO]). Without `persist:`,
the series is live-only — state cold-starts after engine
restart. Rules that need historical continuity across restarts
use persisted series and rebuild stats via a hydration call on
startup.

*Deferred: not binding in this edition.*

(LSER-8-3-2)=
[LSER.8.3.2] In v1, `persist: <dur>` has **one** semantics for every
backing: it forwards each absorbed sample into the samples plane
([LSTO]). On restart, hydration
re-asserts those samples on the normal assert path ([LSER.9.2.3]) and
the backing — running stats, deque, or signal backing —
**rebuilds deterministically** by re-absorbing them in fact order. v1
does not checkpoint internal structure state, so rehydration does not
depend on any checkpoint cadence and reproduces the original state
exactly (given the pinned backing algorithms of [RDSC.5a]).

*Deferred: not binding in this edition.*

*see also:* [LSER.9.2.3](#LSER-9-2-3), [RDSC.5a](#RDSC-5a)

(LSER-8-3-3)=
[LSER.8.3.3] `persist:` forwarding costs one samples-plane write per
absorbed sample; for a high-rate slot that is the price of
restart-faithful, deterministic rehydration.

*Deferred: not binding in this edition.*

(LSER-8-3-4)=
[LSER.8.3.4] **In this edition a series is memory-only.** The samples plane
and `persist:` are deferred ([LSTO.3]), so a series' state lives in working
memory alone and starts empty after an engine restart ([LSER.9.2.1]). A series
declaration takes no `persist:` option ([LSER.13.9]).

*see also:* [LSTO.3](#LSTO-3), [LSER.9.2.1](#LSER-9-2-1), [LSER.13.9](#LSER-13-9)

(LSER-8-4)=
### With the engine tick [LSER.8.4]

(LSER-8-4-1)=
[LSER.8.4.1] The engine tick (see
[LLOG]) does not
cause extra sample-equivalent updates to a series backing — backing
state advances per absorbed sample, not per tick; the tick just forces
test-CE re-evaluation on time-dependent patterns.

(LSER-8-5)=
### With the no-op reassertion discipline [LSER.8.5]

(LSER-8-5-1)=
[LSER.8.5.1] A series takes one sample of its tracked slot per fact that
enters working memory. A meaningful change to any of a fact's slots is a new
fact ([LFAC.2.5.3]), so it adds a sample whether or not the tracked slot
changed. A no-op reassertion adds none, because the engine suppresses it
([LFAC.2.5.1]). An author who wants a sample only when the tracked value
changes declares that slot in a schema of its own.

*ratified*  —  *see also:* [LFAC.2.5.1](#LFAC-2-5-1), [LFAC.2.5.3](#LFAC-2-5-3)

(LSER-8-6)=
### Sample-vs-fire ordering [LSER.8.6]

**Sample absorption is a step of the pump, not a rule, and it runs once, after
the agenda has drained.** Within one pump the series are frozen:
every rule that fires reads the same snapshot, the one that held when the pump
began. Nothing an author writes can observe a partially-absorbed series.

The rule that reads: **within a pump the world is frozen except for working
memory.** Series state is pump-driven for the same reason the clock is
([LTIM.2.1.3]) — and one rule for both is the point.

*ratified*  —  *see also:* [LTIM.2.1.3](#LTIM-2-1-3)

(LSER-8-6-1)=
[LSER.8.6.1] When a fact assertion both updates series state
and triggers rule pattern re-evaluation, the where-clause
aggregation reads see the **pre-sample** series snapshot —
the state as of the start of the pump, before ANY sample
absorbed in it. RHS actions running in the same pump see the
same snapshot; the post-sample state is what the NEXT pump
reads.

The scope is the pump, not the assertion. Two facts asserted
before one pump both fire against the pre-sample snapshot, so
a rule firing for the second does not see the first's sample.

(LSER-8-6-2)=
[LSER.8.6.2] The ordering keeps anomaly-detection patterns
honest. A rule like `where t.state - t.mean > 2 * t.stdev`
reads `t.mean` and `t.stdev` against the historical
distribution, not against a distribution that already includes
the value being checked. Were absorption to happen before firing,
the new sample would contribute to its own threshold,
distorting comparisons — a small effect on heavy-state
backings with many samples, a large effect on small ring
buffers.

(LSER-8-6-3)=
[LSER.8.6.3] All rules that fire in one pump read the same
pre-sample snapshot, regardless of firing order and regardless
of which assertion activated them. Every sample due in that
pump absorbs once, after the agenda has drained.

(LSER-8-6-4)=
[LSER.8.6.4] Within a single pump, samples absorb in
fact-assert order. State at the end of the pump reflects this
order.

(LSER-8-6-5)=
[LSER.8.6.5] **A fact's sample is absorbed exactly once, for the life of that
fact.** Absorption is tracked per fact, not per pump and not per key, and three
cases follow that the pump-scoped rule above makes non-obvious:

- A **no-op reassertion** produces no second sample. The adapter returns the
  existing fact and the fact has already been absorbed ([LSER.8.5.1]).
- A **retract** ends the fact, and with it the record that it was absorbed. A
  later fact on the same key is a new fact and absorbs its own sample.
- A fact **superseded within a pump** still contributes. The absorption step
  runs after the agenda drains and by then the superseded fact is gone, so its
  sample must be resolved when it is superseded and held until the step runs —
  otherwise N asserts against one key before a pump would contribute one sample
  instead of N, against [LSER.8.5.1]'s "on every meaningful fact update".

The third is the one a second implementation gets wrong, because it is invisible
until a program updates the same key twice between pumps.

*see also:* [LSER.8.5.1](#LSER-8-5-1)

(LSER-8-7)=
### With multi-tier deployments [LSER.8.7]

(LSER-8-7-1)=
[LSER.8.7.1] Each engine instance maintains its own series
state; libds does not replicate state across tier boundaries.
A logical fact published from tier A to tier B (`publish X`)
reaches B's engine as an ordinary fact assertion
that absorbs into B's series state, independent of any series
state for the same identity in A.

(LSER-8-7-2)=
[LSER.8.7.2] The only cross-tier visibility for series data is
via `persist:` ([LSER.8.3]). The integrator's storage callback
wiring decides whether persisted samples are visible across
tiers — sharing a samples-plane backend across tiers makes
the data visible; per-tier storage keeps it local. libds
takes no position; the choice is integrator territory per
[LSTO].

*Deferred: not binding in this edition.*

*see also:* [LSER.8.3](#LSER-8-3)

(LSER-8-8)=
### Aggregation reads are pure [LSER.8.8]

(LSER-8-8-1)=
[LSER.8.8.1] Reading an aggregation is **read-only**: evaluating
`mean(t)`, `p95(t)`, `active_fraction(t)`, etc. computes the value
as of the query clock from stored backing state and never mutates
that state. The only state mutation is sample absorption, which
runs once per pump after the agenda drains ([LSER.8.6]);
eviction and compaction happen on assertion, never on a read.

*see also:* [LSER.8.6](#LSER-8-6)

(LSER-8-8-2)=
[LSER.8.8.2] This is required, not cosmetic: where-clause
aggregations re-evaluate on every test with no memoisation
([LEXP.9.2.2]). A read that lazily
evicted or compacted state would be
non-idempotent — the same `p95(t)` read twice at one instant could
differ, and the result would depend on how many rules reference it
(adding an unrelated reader would perturb everyone's value). The
runtime states the implementation rule for every backend at
[RDSC.5a.1a]; the signal backings carry it at [LSIG.2.5].

---

*see also:* [LEXP.9.2.2](#LEXP-9-2-2), [LSIG.2.5](#LSIG-2-5), [RDSC.5a.1a](#RDSC-5a-1a)

(LSER-19)=
## Warm-up [LSER.19]

(LSER-19-7)=
[LSER.19.7] **First-assertion timestamp (`t_first`).** The runtime records,
per series instance (per `by:` identity), the timestamp of the first sample
absorbed into a fresh backing allocation — `t_first`. It is internal backing
state, not an author-facing value. An aggregation whose windowed estimate is biased low until a
full window of history exists may divide by the elapsed-aware denominator
`min(W, now − t_first)` instead of the full window `W`, removing the warm-up
undercount at no extra state or accuracy cost. `t_first` is set on the first
absorbed sample. Its consumer is `onset_rate`'s ÷`min(W, elapsed)` denominator,
whose state is never evicted ([LSER.9.3.1]), so `t_first` persists for the
instance's life and the correction applies over the instance's first `W` only.

---

*see also:* [LSER.9.3.1](#LSER-9-3-1)

(LSER-19-8)=
[LSER.19.8] **A cold read yields `null`, at the grain of this partition.** An
aggregation read is **cold** when its backing holds no sample to aggregate for
that identity — before the first absorption, or once every absorbed sample has
left the window. `active_fraction` and `integral` are the exception to the
second: they aggregate a step function, in which each asserted value holds
until the next ([LSIG.1.3.1], [LSIG.3.2]), so the last absorbed value reaches
into every later window and their read is cold only before the first
absorption. The engine **must** answer a cold read with the value below,
not with an error and not with a placeholder. Reading a cold series is a normal
thing for a rule to do on the first pumps after start or restart.

**These keep a concrete return type**, because zero is the honest answer rather
than a stand-in for one:

| Aggregation | Cold value |
|---|---|
| `count`, `count_distinct`, `count_of` | `0` |
| `contains` | `false` |
| `sum` | `0` |
| `active_fraction`, `onset_rate`, `integral` | `0.0` |

Nothing has been observed, so the count **is** zero and the value **has not**
been seen. `[LSIG.8.1]` is retained unchanged by this clause, not overridden.

**Every other aggregation is genuinely undefined when cold and its declared
return type is therefore `T?` ([LSER.16]),** yielding `null` while cold. This
includes `bool_and` / `bool_or`: a universal over an empty series is not `true`
and an existential over one is not `false` — those are the *vacuous* answers,
and returning them would let a rule fire on a series that has told it nothing.
The descriptive, dispersion, quantile and temporal families are undefined for
the same reason — there is no mean of nothing.

**A cold read needs no guard in a `where` predicate.** A `null` propagates
through comparison and boolean operators and a `where` fires only on `true`
([LNUL.4.3]), so a rule reading a cold `T?` aggregation does not fire until the
backing holds a sample. At a concrete-value position the `T?` is rescued with
`??` or written to a `T?` slot ([LNUL.5.1]).

Whether a
read has a value is the read's own answer. An aggregation that needs more than
one sample says so in its own definition: `stdev`, `variance` and `direction`
are also `null` while one sample is held, and `rate` while no time separates
the first and last ([LSER.17.2]). This holds on every backing, a `sample n`
reservoir included: before its bag is full the bag holds every absorbed
sample ([LSMP.2.1]), and its aggregations are read over those.

*ratified*  —  *see also:* [LNUL.4.3](#LNUL-4-3), [LNUL.5.1](#LNUL-5-1), [LSER.16](#LSER-16), [LSER.17.2](#LSER-17-2), [LSIG.1.3.1](#LSIG-1-3-1), [LSIG.3.2](#LSIG-3-2), [LSIG.8.1](#LSIG-8-1), [LSMP.2.1](#LSMP-2-1)

(LSER-9)=
## Operational notes [LSER.9]

(LSER-9-1)=
### Memory accounting [LSER.9.1]

(LSER-9-1-1)=
[LSER.9.1.1] The engine tracks cumulative series state
(running stats, trailing tails, ring buffers, deques, reservoirs,
etc.) per entity per series. When total series memory
crosses an operator-set budget, the engine emits a warning and
a metric. No hard cap, no runtime rejection — the operator
decides how to respond (add memory, prune series, shorten
windows, retire rules that use rarely-referenced series).

(LSER-9-1-2)=
[LSER.9.1.2] Budget lives in engine config; no per-series or
per-site defaults baked into the language spec.

(LSER-9-2)=
### No serialisation across restarts [LSER.9.2]

(LSER-9-2-1)=
[LSER.9.2.1] Series state cold-starts after engine restart, and a read of
it is cold until its backing absorbs a sample ([LSER.19.8]).

*see also:* [LSER.19.8](#LSER-19-8)

(LSER-9-2-1a)=
[LSER.9.2.1a] **Replay.** Because series state cold-starts and is not
serialised, byte-for-byte replay of a rule that
reads an aggregation requires the recording to have begun at
engine-cold — then every sample re-absorbs from the event trace in
order and the backings rebuild identically. A recording started
against an already-warm engine diverges on series-derived facts. See
[LDET.2.2a].

*see also:* [LDET.2.2a](#LDET-2-2a)

(LSER-9-2-2)=
[LSER.9.2.2] Persistence across restarts is provided by
`persist:` on the series (forwards each sample to the samples
plane per [LSER.8.3.2]). Rebuilding the series
state from persisted data on startup is an adapter-mediated
operation, not automatic.

*Deferred: not binding in this edition.*

*see also:* [LSER.8.3.2](#LSER-8-3-2)

(LSER-9-2-3)=
[LSER.9.2.3] Series absorb a sample from a fact of a hydration target
([LHYD.4.1.7]) only when its `corr` slot is empty. Live asserts and the
persisted-sample re-asserts used for series rebuild carry an
empty `corr` and absorb normally. Facts loaded for
rule matching via `hydrate_*` carry a **non-empty**
`corr` and are **skipped** by the series absorber, so
a retrospective hydration does not pollute a live window. The
runtime enforces this with a `(corr "")` guard on the
absorber path for hydration targets (see [LHYD.10.4]
and the reference-runtime lowering RLOW.8.4). The engine does not
surface a separate "hydration done" signal.

*Deferred: not binding in this edition.*

*see also:* [LHYD.10.4](#LHYD-10-4), [LHYD.4.1.7](#LHYD-4-1-7), [RLOW.8.4](#RLOW-8-4)

(LSER-9-3)=
### Eviction [LSER.9.3]

(LSER-9-3-1)=
[LSER.9.3.1] Series state eviction policy is backing-specific.
All-time backings (running-stats, all-time distinct-set, etc.)
live until engine shutdown — eviction would destroy cumulative
semantics. Sliding and tumbling backings evict when no
sample for that identity has been absorbed for the declared
window — after window-of-silence the backing holds zero
in-window samples and the per-key allocation is pure overhead.

The state a signal aggregation ([LSIG.1.1]) reads is the exception: the engine
**must not** evict it after a window of silence. `active_fraction`, `onset_rate`
and `integral` read the slot as a step function, each absorbed value held until
the next ([LSIG.1.3.1], [LSIG.3.2]), so a silent window is not an empty one.
The last absorbed value, any open interval and `t_first` ([LSER.19.7]) persist
for the instance's life.

*see also:* [LSER.19.7](#LSER-19-7), [LSIG.1.1](#LSIG-1-1), [LSIG.1.3.1](#LSIG-1-3-1), [LSIG.3.2](#LSIG-3-2)

(LSER-9-3-1a)=
[LSER.9.3.1a] **Default vs `realtime` divergence (cross-mode replay).**
The eviction above is the *default* backend's behaviour. Under
`realtime` / `linear_scan: false` the row map is locked at `go_live` and
backings are pre-allocated, so a sliding/tumbling backing is **never
evicted** — its state persists across a silence gap instead of
cold-starting. The two modes therefore compute **different series
values from the same event trace** after any window of silence: the
default backend re-warms from empty (warm-up-biased), while
`realtime` carries the pre-gap state forward. This is permitted —
the dialect is part of the compiled rule set, so it is a different
input under [LDET.1.1] — but it is a cross-mode **replay trap**: a
`realtime` production recording replayed on a default-built engine
(or vice versa) diverges on series-derived facts, so replay on a
build of the same dialect. The three signal aggregations do not diverge:
no mode evicts their state ([LSER.9.3.1], [LSIG.5.4]).

*see also:* [LDET.1.1](#LDET-1-1), [LSER.9.3.1](#LSER-9-3-1), [LSIG.5.4](#LSIG-5-4)

(LSER-9-3-2)=
[LSER.9.3.2] The eviction sweep runs once per pump (engine cycle),
reading the engine clock once — the same `now_ns` and cadence as the
TTL fact sweep ([LFAC.1.3.3], [LFST.6.1]), **not** a real OS timer.
The engine clock is a recorded input in replay ([LDET.1.8.2]) and
every event-trace event carries its clock, so the sweep reads the
same `now_ns` at the same logical points on replay; eviction — and
the cold-start re-warm it triggers — is reproduced identically, as
part of the replay contract in [LDET.2.2a]. Evicted state means the
allocation is freed and the next sample for that identity cold-starts
a fresh allocation. Because eviction advances only when a pump reads
an advanced clock, a backing in a fully silent window is not freed
until the next assertion or `$ClockTick` ([LFST.6.2]) — the same
trigger dependency the signal aggregations carry ([LSIG.7]).

*see also:* [LDET.1.8.2](#LDET-1-8-2), [LDET.2.2a](#LDET-2-2a), [LFAC.1.3.3](#LFAC-1-3-3), [LFST.6.1](#LFST-6-1), [LFST.6.2](#LFST-6-2), [LSIG.7](#LSIG-7)

(LSER-9-3-3)=
[LSER.9.3.3] Each backing in the matrix declares its eviction
policy at definition time. The matrix is the source of truth
for backing-specific operational characteristics.

---

(LSER-10)=
## Series commitments [LSER.10]

(LSER-10-4)=
[LSER.10.4] **`t.dwell` is independent of series.** Compile-
time alias for the time since the fact entered working memory
([LEXP.9.5.1]) on `logical`-schema bindings, not a maintained
statistic. See [LFAC].
Restates [LSER.8.2.1].

`dwell` is a reserved word ([LLEX.9.5]) and carries a row on
[LLEX.9.6]. Being an alias rather than an aggregation changes
what it computes, not whether an author may name a slot after
it: the companion read is syntactically identical to a slot
read, so the two occupy one position and one must yield.

*see also:* [LEXP.9.5.1](#LEXP-9-5-1), [LLEX.9.5](#LLEX-9-5), [LLEX.9.6](#LLEX-9-6), [LSER.8.2.1](#LSER-8-2-1)

(LSER-10-5)=
[LSER.10.5] **No implicit declarations.** Every series is
declared at file scope. Referencing `t.mean` on a binding with
no declared series is a compile error.

*ratified*

(LSER-10-6)=
[LSER.10.6] **Series cursor and companion-slot sugar.** A
cursor (`binding`, `binding.label`, `binding.slot`, or
`binding.slot.label`) identifies the (slot, observation,
backing) triple to access. Companion-slot form
`cursor.<agg>` and expression form `<agg>(cursor)` are
fully equivalent. See [LSER.6].

*see also:* [LSER.6](#LSER-6)

(LSER-10-9)=
[LSER.10.9] **`direction` compares the two newest samples in the window.**
It returns an **`Int`** — `-1` falling, `0` steady, `+1` rising ([LSER.17.2]):

$\mathit{direction} = \operatorname{sgn}(x_{\mathit{new}} - x_{\mathit{prev}})$

where $x_{\mathit{new}}$ is the most recently absorbed sample still in the
window and $x_{\mathit{prev}}$ the one absorbed before it. The difference is the
exact one: the engine **must** decide the sign by comparing the two samples,
never from a wrapped `Int` or a rounded `Float` subtraction, and applies no
tolerance. $-0$ and $+0$ compare equal. With fewer than two samples in the
window there is no slope, and the read is `null`, as a cold read is
([LSER.19.8]).

An ordered integer keeps the comparison checkable: `d.direction > 0` is a type error away from being wrong, where a
string spelling would let a misspelt category compile and never match.

*ratified*  —  *see also:* [LSER.17.2](#LSER-17-2), [LSER.19.8](#LSER-19-8)

(LSER-10-10)=
[LSER.10.10] **Memory caps are advisory.** The engine
tracks cumulative state; crossing an operator-set budget
emits a metric and warning. No hard cap.

(LSER-10-11)=
[LSER.10.11] **Series state cold-starts** ([LSER.19.8]). A series lives in
working memory only: nothing in this edition carries its state across a
restart ([LSER.8.3.4]).

*see also:* [LSER.19.8](#LSER-19-8), [LSER.8.3.4](#LSER-8-3-4)

(LSER-10-13)=
[LSER.10.13] **Identity slot designation via `by:`.** Every
series binds to one identity slot, and that is a permanent
property of a series rather than a v1 limit. With `by:` omitted, a
`logical` schema takes its declared identity `key` slot when it has
exactly one ([LFAC.1.7], [LSER.7.6.1]); a composite key resolves to
nothing and must be narrowed with `by:`. A schema of any other lifecycle
declares no identity ([LFAC.1.7.6]) and must name `by:` explicitly.
Otherwise the declaration must qualify with `by: <slot>` or
opt into a single global allocation with `by: none`, and a
series with no resolvable identity is
`DS_VALIDATE_SERIES_NO_IDENTITY_SLOT`.
Which lifecycles a series may be declared on is [LSER.7.6.3].

*see also:* [LFAC.1.7](#LFAC-1-7), [LFAC.1.7.6](#LFAC-1-7-6), [LSER.7.6.1](#LSER-7-6-1), [LSER.7.6.3](#LSER-7-6-3)

(LSER-10-14)=
[LSER.10.14] **Fire-then-sample ordering.** A fact assertion's
where-clause aggregation reads see the pre-sample series
snapshot; sample absorption fires after the firing decision
lands; RHS actions read post-sample state. The ordering
preserves anomaly-detection threshold honesty.

(LSER-10-15)=
[LSER.10.15] **One series declaration per (slot path, file).**
Two declarations on the same slot path within one file are a
compile error. Declarations on the same slot path in
different files are independent per [LSER.13.6].

*ratified*  —  *see also:* [LSER.13.6](#LSER-13-6)

(LSER-10-17)=
[LSER.10.17] **Unique-required schema scoping.** An unqualified
`series <slot>` binds to the unique schema in scope with a
slot of that name. Zero matches and 2+ matches are compile
errors; the author qualifies as `<SchemaName>.<slot>` to
disambiguate. Adding a new schema with a same-named slot
makes the previously-unambiguous declaration ambiguous and
fails the build at the declaration site, not silently
elsewhere.
Restates [LSER.7.7].

*ratified*  —  *see also:* [LSER.7.7](#LSER-7-7)

(LSER-10-18)=
[LSER.10.18] **Observation-shaped surface, structure-agnostic
declarations.** Authors name aggregations × time models; the
compiler picks data structures from the matrix in
[LSER.18.1]. Authors never write structure names
(`monotonic_deque`, `ring_buffer`, etc.); the matrix grows
without changing the surface.

*see also:* [LSER.18.1](#LSER-18-1)

(LSER-10-19)=
[LSER.10.19] **Every aggregation is exact.** A declaration that
cannot be satisfied exactly is rejected rather than silently
approximated ([LSER.15]).

*ratified*  —  *see also:* [LSER.15](#LSER-15)

(LSER-10-20)=
[LSER.10.20] **Activation-scoped facts and supersedure on series.** Series
declarations are independent of the activation-scoped
mechanisms in
[LSCP] and
[LRST]. A series tracks slot history
across all activations; it is not bound to any single
activation's lifetime.
