# Signal-processing series aggregations

Three series aggregations that characterise the
*temporal structure* of event-driven boolean and rate signals —
`active_fraction`, `onset_rate`, and `integral` — together with the two
backing atoms they require (`SeriesBackendIntervalPulse`, `SeriesBackendNumericIntegral`; `onset_rate` reuses `SeriesBackendRingBuffer`).
Registered in [RDSC.7.1]. Prefix `LSIG`.

**Paired with:**
- [LSER] — the observation-triple framework these extend:
  aggregation vocabulary [LSER.16], per-type and agg×time-model matrices
  [LSER.17]–[LSER.18], warm-up and `t_first` [LSER.19], eviction [LSER.9.3].
- [LGRA.7] and [LSER.13.5] —
  the `gap-policy` series-line production.
- [LDET.3.6.1] — the correctly-rounded-op bar
  these backings hold to.
- [LNLS.3.5] — bounded-memory availability.

**What this is.** Point-process statistics — time-in-state and event rate
on boolean slots — and a time-weighted integral on rate slots. These
answer questions about *when and how long* events occur, which the
value-statistics vocabulary in [LSER.16] cannot express.

**What this is not.** Not spectral or amplitude DSP. DS carries no Fourier
or wavelet content, no RMS/energy, no filtering: those need a uniform
sample stream that DS's event-driven facts do not carry, and belong in an
at-the-ADC adapter (§[LSIG.9]). Nor the inter-onset *rhythm* statistics
(`mean_interval` / `interval_var` / `interval_stdev`).

---

(LSIG-1)=
## Aggregation vocabulary [LSIG.1]

(LSIG-1-1)=
[LSIG.1.1] The v1 signal aggregations. Each is callable in any expression
position as `<agg>(cursor)` per [LSER.16.1], and readable through the
companion-slot form per [LSER.6]. The time model and accuracy come from the
series declaration.

| Aggregation | Semantics | Element type | Time model | Returns | Backing | At capacity |
|---|---|---|---|---|---|---|
| `active_fraction` | time-weighted fraction of the window the slot was `true` | `Bool` | `sliding` | `Float` | `SeriesBackendIntervalPulse` | refuse |
| `onset_rate` | rising edges per second | `Bool` | `sliding` | `Float` | `SeriesBackendRingBuffer` | drop |
| `integral` | time-weighted ∫x dt | `Float`, `Int` | `sliding`, `all_time` | `Float` | `SeriesBackendNumericIntegral` | refuse |


**At capacity** is what a declared `capacity` ([LSER.13.14]) does when an
identity's backing is full. `active_fraction` and `integral` hold a step
function over the window: a dropped sample would leave part of the window
unaccounted for and the value silently wrong, so each **refuses**, as a bounds
refusal, and the fact is not asserted. Each has a backing of its own, so no
atom carries both policies. `onset_rate` counts edges in the ring buffer it
shares with the sample-weighted aggregations of [LSER.18.1] and **drops** with
them: the oldest sample goes, and with it at most the edge the buffer started
on.

**`Returns` is the representation, not the dimension.** `integral` changes
dimension, and over a slot that carries a unit [LUNI.9.2] requires the author to
strip it in a `let`. A unit-typed value is an `Int`
or a `Float` carrying a compile-time dimension ([LNUL.4.9]), so this column and
that requirement describe different axes of one value.

*ratified*  —  *see also:* [LNUL.4.9](#LNUL-4-9), [LSER.13.14](#LSER-13-14), [LSER.16.1](#LSER-16-1), [LSER.18.1](#LSER-18-1), [LSER.6](#LSER-6), [LUNI.9.2](#LUNI-9-2)

(LSIG-1-2)=
[LSIG.1.2] The compiler must reject a declaration whose element type or time
model is outside the row above, with the closest-form hint shape of
[LSER.15.2]. Element-type and time-model applicability are orthogonal axes
([LSER.17.7]); the compiler reports the first failing axis.

*ratified*  —  *see also:* [LSER.15.2](#LSER-15-2), [LSER.17.7](#LSER-17-7)

(LSIG-1-3)=
### `active_fraction` [LSIG.1.3]

(LSIG-1-3-1)=
[LSIG.1.3.1] `active_fraction` computes the time-weighted fraction of the
sliding window during which the slot held `true`:

$\mathit{active\_fraction}([t-W, t]) = \frac{1}{W}\int_{t-W}^{t} b(\tau)\,d\tau,\qquad b(\tau) \in \{0, 1\}$

where `b(τ)` is the slot's value as a piecewise-constant step function
(each asserted value held until the next assertion). Before the slot's first
absorption `b(τ)` is `0`: the integral counts that time as not `true`, and the
slot holds no `false` then ([LSIG.1.4.1]).

*ratified*  —  *see also:* [LSIG.1.4.1](#LSIG-1-4-1)

(LSIG-1-3-2)=
[LSIG.1.3.2] `active_fraction` must be backed by `SeriesBackendIntervalPulse` (§[LSIG.2.2]), not by
the `mean` backing. On a boolean slot under DS's meaningful-change
discipline, `mean` computes the fraction of *assertions* that were `true`,
not the fraction of *time*; the two diverge whenever reporting is
non-uniform, which is the normal case for event-driven sensors. The
compiler must not satisfy an `active_fraction` declaration with a `mean`
backing.

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

(LSIG-1-3-3)=
[LSIG.1.3.3] `active_fraction` is admitted only under the `sliding` time
model. The compiler must reject `active_fraction` under `all_time`,
`tumbling`, and `sample`.

*ratified*

(LSIG-1-4)=
### `onset_rate` [LSIG.1.4]

(LSIG-1-4-1)=
[LSIG.1.4.1] `onset_rate` is the number of rising edges per second within
the sliding window:

$\mathit{onset\_rate} = \dfrac{N_{+}(t, W)}{\min(W, \mathit{elapsed})}$

where `N₊(t, W)` is the count of rising edges whose instant lies in the
half-open window `(t−W, t]` and `elapsed = t − t_first` ([LSER.19.7]).

The runtime **must** count as a rising edge exactly the absorption of a `true`
while the slot holds `false`. The slot holds the value it last absorbed, through
any silence and whatever the window or capacity has discarded ([LSER.9.3.1]).
Before its first absorption it holds nothing, which is not `false`. An edge's
instant is that sample's.

*ratified*  —  *checks:* `tla×5`  —  *see also:* [LSER.19.7](#LSER-19-7), [LSER.9.3.1](#LSER-9-3-1)

(LSIG-1-4-2)=
[LSIG.1.4.2] The denominator is `min(W, elapsed)`, never the full window `W`.
During the first `W` of an instance's life less than `W` of history exists, so
dividing by `W` would under-report; `min(W, elapsed)` removes that warm-up
bias. While `elapsed` is `0`, `onset_rate` is `0`.

*ratified*  —  *checks:* `tla×4`

(LSIG-1-4-3)=
[LSIG.1.4.3] `onset_rate` is admitted only on `Bool` slots under `sliding`.
The compiler must reject a wrong element type with
`DS_VALIDATE_SERIES_AGG_TYPE_MISMATCH` and a wrong time model with
`DS_VALIDATE_SERIES_AGG_TIME_MODEL_MISMATCH` — the applicability diagnostics
for every signal aggregation (`active_fraction`, `onset_rate`, `integral`).

*ratified*

(LSIG-1-4-4)=
[LSIG.1.4.4] `onset_rate` doubles as a liveness companion for
`active_fraction`: a stuck-`true` sensor (§[LSIG.6]) has `onset_rate ≈ 0`.
A rule that must distinguish "genuinely active" from "dropout stuck true"
should pair the two.

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

(LSIG-1-5)=
### `integral` [LSIG.1.5]

(LSIG-1-5-1)=
[LSIG.1.5.1] `integral` is the time-weighted integral of a rate slot, using
the rectangle rule over the piecewise-constant fact model:

$\mathit{integral}(\mathit{window}) = \int x(\tau)\,d\tau \approx \sum_i x_i \, (t_{i+1} - t_i)$

The most recent sample is held to the query time `t`, contributing
`xₙ × (t − tₙ)`. If slot `x` has units `U` and time is in seconds,
`integral` has units `U·s` (a flow rate in L/s integrated over 1_h yields
litres).

*ratified*

(LSIG-1-5-2)=
[LSIG.1.5.2] `integral` is the dimensionally-correct counterpart of `sum`
for a rate sensor: `sum` over L/s readings yields `(L/s)·count`, which is
meaningless; `integral` yields litres. The compiler must back `integral`
with `SeriesBackendNumericIntegral` (§[LSIG.2.3]), distinct from any `sum` backing.

*see also:* [LSIG.2.3](#LSIG-2-3)

(LSIG-1-5-3)=
[LSIG.1.5.3] The rectangle rule is exact for the piecewise-constant fact
model. It is not exact for a continuously-varying physical signal: the
absolute error is at most `granularity × W`, where `granularity` is the
slot's meaningful-change tolerance τ where declared ([LFAC.2.5.1]) or the
sensor quantisation step otherwise. An author integrating a fast-varying
rate who needs second-order accuracy on the closed history may apply the
trapezoid rule in the adapter; the open right-boundary interval has no
successor sample and reduces to the rectangle rule regardless.

*see also:* [LFAC.2.5.1](#LFAC-2-5-1)

(LSIG-1-5-4)=
[LSIG.1.5.4] `integral` is admitted on `Float` and `Int` slots, under
`sliding` and `all_time`. It is not admitted on `Bool` (use
`active_fraction`) nor under `sample`. The compiler must reject those. Its
`tumbling` form is refused in this edition with every other `tumbling` line
([LSER.14.4.5]).

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

(LSIG-1-5-5)=
[LSIG.1.5.5] `integral all_time` always returns `Float64` regardless of the
slot's declared element type. The accumulator begins at `0.0` on the first
assertion. `integral all_time` is rejected under `realtime` per
§[LSIG.5.3].

---

*see also:* [LSIG.5.3](#LSIG-5-3)

(LSIG-2)=
## Backings [LSIG.2]

(LSIG-2-1)=
[LSIG.2.1] Backings are not author-visible ([LSER.13.3]); the compiler picks
them from the declaration. The three v1 backings are pinned below: conforming
runtimes must agree on the computed value and on its determinism.

*see also:* [LSER.13.3](#LSER-13-3)

(LSIG-2-2)=
### `SeriesBackendIntervalPulse` — interval pulse [LSIG.2.2]

(LSIG-2-2-1)=
[LSIG.2.2.1] `SeriesBackendIntervalPulse` backs `active_fraction`. Its state,
in integer nanoseconds of the monotonic clock:

- the closed intervals $(s_i, e_i)$ in which the slot held `true`, each from
  the `true` that opened it to its falling edge, oldest first, not yet evicted;
- $s_{\mathrm{open}}$, the start of the interval still open, present only while
  the slot holds `true`;
- $T = \sum_i (e_i - s_i)$, the on-time of those closed intervals;
- $W$, the window, from the series declaration.

(LSIG-2-2-2)=
[LSIG.2.2.2] The runtime updates `SeriesBackendIntervalPulse`'s state
([LSIG.2.2.1]) on each absorbed sample, at time $c$:

- on `true` while $s_{\mathrm{open}}$ is absent: it sets
  $s_{\mathrm{open}} = c$, then evicts;
- on `false` (a falling edge) while $s_{\mathrm{open}}$ is present: it appends
  $(s_{\mathrm{open}}, c)$ to the intervals, adds $c - s_{\mathrm{open}}$ to $T$,
  clears $s_{\mathrm{open}}$, then evicts;
- on any other sample: nothing.

To evict is to remove every closed interval with $e_i \le c - W$, subtracting
its $e_i - s_i$ from $T$.

*see also:* [LSIG.2.2.1](#LSIG-2-2-1)

(LSIG-2-2-3)=
[LSIG.2.2.3] At query time $t$ the runtime must compute `active_fraction`
from the state of [LSIG.2.2.1] read-only: it must not change the state or
evict (eviction occurs on the next assertion, [LSIG.2.5]).

$\mathit{active\_fraction}(t) = \frac{1}{W}\Big(T - \sum_{i\,:\,s_i \le t-W} \big(\min(e_i,\ t-W) - s_i\big) + o(t)\Big)$

where $o(t) = t - \max(s_{\mathrm{open}},\ t-W)$ while $s_{\mathrm{open}}$ is
present and $0$ otherwise. The sum discounts the on-time before the window that
is not yet evicted; $o(t)$ clips the open interval to the window and holds it to
$t$. The numerator is integer arithmetic, and the division is the one rounding
([LSIG.4.1]).

*ratified*  —  *see also:* [LSIG.2.2.1](#LSIG-2-2-1), [LSIG.2.5](#LSIG-2-5), [LSIG.4.1](#LSIG-4-1)

(LSIG-2-2-4)=
[LSIG.2.2.4] **Window convention.** The window is the half-open interval
`(t−W, t]`: the left boundary `t−W` is exclusive and the right boundary `t`
is inclusive. The runtime must apply this convention consistently across
every `SeriesBackendIntervalPulse` query path and every conformance fixture. The same convention
governs `onset_rate`'s edge count (§[LSIG.1.4]) so that the two compose over
identical bounds.

*ratified*  —  *checks:* `tla×6`  —  *see also:* [LSIG.1.4](#LSIG-1-4)

(LSIG-2-2-5)=
[LSIG.2.2.5] Query cost is O(K) in the count of not-yet-evicted out-of-window
intervals — O(1) under continuous assertion. `active_fraction` is exact with
respect to the observed transition stream in every mode; `SeriesBackendIntervalPulse` has no
approximate form (§[LSIG.5.2]).

*see also:* [LSIG.5.2](#LSIG-5-2)

(LSIG-2-3)=
### `SeriesBackendNumericIntegral` — numeric integral [LSIG.2.3]

(LSIG-2-3-1)=
[LSIG.2.3.1] `SeriesBackendNumericIntegral` backs `integral`. Its state:

- a ring of entries $(t_i, x_i)$, oldest first, each the start and the value of
  a closed interval in the window;
- $x_{\mathrm{open}}$, the held value, and $t_{\mathrm{open}}$, its assertion time;
- $S = \sum_i x_i\,(t_{i+1} - t_i)$, the running sum over the closed
  intervals, where $t_{i+1}$ is the next entry's start, or $t_{\mathrm{open}}$
  for the newest entry.

(LSIG-2-3-2)=
[LSIG.2.3.2] On a new assertion $(t_{\mathrm{new}}, x_{\mathrm{new}})$ the
runtime, in this order:

1. closes the open interval: $S \leftarrow S + x_{\mathrm{open}}\,(t_{\mathrm{new}} - t_{\mathrm{open}})$;
2. evicts the expired entries from the ring and subtracts their contribution
   from $S$, clipping a partial interval at the window boundary;
3. pushes $(t_{\mathrm{open}}, x_{\mathrm{open}})$, the just-closed interval's
   **start**, as [LSIG.2.3.1] stores entries and [LSIG.2.3.3] reads them;
4. sets $x_{\mathrm{open}} = x_{\mathrm{new}}$ and $t_{\mathrm{open}} = t_{\mathrm{new}}$.

*see also:* [LSIG.2.3.1](#LSIG-2-3-1), [LSIG.2.3.3](#LSIG-2-3-3)

(LSIG-2-3-3)=
[LSIG.2.3.3] At query time $t$ the runtime must compute `integral` from the
state of [LSIG.2.3.1] read-only, as [LSIG.2.2.3] does `active_fraction`:

$\mathit{integral}(t) = \Big(S - \sum_{i\,:\,t_i \le t-W} x_i\,\big(\min(t_{i+1},\ t-W) - t_i\big)\Big) + x_{\mathrm{open}}\,\big(t - \max(t_{\mathrm{open}},\ t-W)\big)$

with $t_{i+1}$ as [LSIG.2.3.1] defines it. The value is evaluated in the order
written ([LSIG.4.1]): the sum accumulated oldest entry first, subtracted from
$S$, then the open interval's term added, clipped to the window and held to $t$.

Query cost is O(K), the bounded-staleness property shared with
`SeriesBackendIntervalPulse` ([LSIG.2.2.5]).

*ratified*  —  *see also:* [LSIG.2.2.3](#LSIG-2-2-3), [LSIG.2.2.5](#LSIG-2-2-5), [LSIG.2.3.1](#LSIG-2-3-1), [LSIG.4.1](#LSIG-4-1)

(LSIG-2-3-4)=
[LSIG.2.3.4] **Recompute.** The eviction subtract is subject to subtractive
cancellation over long windows with slowly-varying signals. The runtime must
fully recompute $S$ ([LSIG.2.3.1]) from the live ring intervals every `K = 128`
evictions (`K` is a runtime constant, not stored in the atom). This is the
canonical running-sum recompute policy for DS series backings.

*see also:* [LSIG.2.3.1](#LSIG-2-3-1)

(LSIG-2-3-5)=
[LSIG.2.3.5] **Tumbling.** For `integral tumbling W`, at each bucket boundary
(deterministic epoch per [LSER.14.4.1]) the runtime closes the open interval
against the bucket end, snapshots `running_sum` as the completed-bucket
readable value, then resets: clears the ring, sets `running_sum = 0` and
`open_start = bucket_end`. `open_value` is not reset — the slot's current
value carries over as the initial hold for the new bucket. The in-progress
bucket is not queryable ([LSER.14.4.2]); queries return the most-recently
completed snapshot, and `0.0` before the first bucket closes.

*Deferred: not binding in this edition.*

*see also:* [LSER.14.4.1](#LSER-14-4-1), [LSER.14.4.2](#LSER-14-4-2)

(LSIG-2-3-6)=
[LSIG.2.3.6] The `SeriesBackendNumericIntegral` atom records `gap_policy` and `time_model` explicitly;
both are load-bearing at runtime (gap policy changes the result on every
gap, §[LSIG.3]; time model selects eviction/reset behaviour) and neither can
be inferred from the other fields.

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

(LSIG-2-4)=
### `onset_rate` state [LSIG.2.4]

(LSIG-2-4-1)=
[LSIG.2.4.1] `onset_rate` reuses the existing `SeriesBackendRingBuffer` ring of rising-edge
timestamps; no new atom is required. On a rising edge the runtime pushes the
timestamp and evicts those older than `current_time − W`. At query time the
count is read-only: the runtime walks the leading entries that have crossed
`t − W` since the last assertion, excludes them, and divides the in-window
count by `min(W, elapsed)` (§[LSIG.1.4]).

*see also:* [LSIG.1.4](#LSIG-1-4)

(LSIG-2-4-2)=
[LSIG.2.4.2] The runtime must record a per-instance `t_first` on the `SeriesBackendRingBuffer`
allocation, per [LSER.19.7], to supply the `elapsed` denominator.

*see also:* [LSER.19.7](#LSER-19-7)

(LSIG-2-5)=
### Bounded staleness [LSIG.2.5]

(LSIG-2-5-1)=
[LSIG.2.5.1] **A query answers as of the clock, whatever the backing
stores.** The engine must answer every query as of the monotonic clock's sample
`t` ([LTIM.2.8.2]), over the samples inside the window as of `t` ([LSER.14.1]),
and must discount any sample outside that window the backing still stores.
`active_fraction`, `onset_rate`, and `integral` therefore all evaluate as of the
same instant `t` and may be combined in one rule without a freshness mismatch.
Worst-case query cost is O(K), bounded by the declared `.dsrt` capacity under
`realtime` (§[LSIG.5]).

An eviction as of `t` must remove only samples outside the window as of `t`, and
never what a backing keeps past its window: a step backing's carry
([LSER.13.14]), and the state [LSER.9.3.1] keeps after a window of silence. The
engine may evict as of the clock's current sample when it absorbs a sample, at
the pump's eviction sweep ([LSER.9.3.2]), and at a query before it answers it.
The monotonic clock does not go backward, so a sample evicted as of `t` lies
outside the window of every later query and every later capacity count
([LSER.13.14]). Where the engine evicts therefore changes no answer and no
refusal, and an eviction at a watch's query ([LDEB.7.4.1]) changes nothing a
later read observes.

*ratified*  —  *checks:* `tla×6`  —  *see also:* [LDEB.7.4.1](#LDEB-7-4-1), [LSER.13.14](#LSER-13-14), [LSER.14.1](#LSER-14-1), [LSER.9.3.1](#LSER-9-3-1), [LSER.9.3.2](#LSER-9-3-2), [LSIG.5](#LSIG-5), [LTIM.2.8.2](#LTIM-2-8-2)

(LSIG-3)=
## Gap policy [LSIG.3]

(LSIG-3-1)=
[LSIG.3.1] `integral` advances across intervals in which no new sample is
asserted according to a `gap-policy` phrase on the observation line
([LSER.13.5], [LGRA.7.1]): `gap hold`, `gap zero`, or `gap skip`. The phrase
is optional; omitting it selects `gap hold`.

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

(LSIG-3-2)=
[LSIG.3.2] The policies:

- `gap hold` — carry the last asserted value across the gap. The default;
  correct for held quantities (temperature, pressure, state-of-charge).
- `gap zero` — treat absence of a report as zero. Correct for rate sensors
  where no report means no flow, and dropout-safe by construction.
- `gap skip` — exclude dead-sensor intervals from the integral entirely.

(LSIG-3-3)=
[LSIG.3.3] `gap` applies only to `integral`. The compiler must reject a
`gap-policy` phrase on any other aggregation with
`DS_VALIDATE_SERIES_GAP_ON_NON_INTEGRAL`. Applicability is a compile-time
contract on the same axis as [LSER.16]–[LSER.17], not a grammar constraint
([LSER.13.5.1]).

*ratified*  —  *see also:* [LSER.13.5.1](#LSER-13-5-1), [LSER.16](#LSER-16), [LSER.17](#LSER-17)

(LSIG-3-4)=
[LSIG.3.4] `gap skip` requires a schema with bounded scope (`scope ttl N` or
`scope explicit`) so that a fact can go dead between assertions. On a
`scope logical` schema no fact can go dead, so there is nothing for `gap skip`
to exclude; the compiler must reject
`gap skip` on `scope logical` with `DS_VALIDATE_SERIES_GAP_SKIP_LOGICAL`
(error — reject).

*ratified*

(LSIG-3-5)=
[LSIG.3.5] Most of the rate use cases for `integral` (flow, power, speed,
current) are dropout-safe only under `gap zero`; an author should specify
`gap zero` explicitly on a rate integral and rely on the `gap hold` default
only for genuinely held quantities. `gap hold` over a dead sensor accrues
without bound (§[LSIG.6]).

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

(LSIG-3-6)=
[LSIG.3.6] Under `realtime`, `gap hold` advances the integral between pump
cycles using the monotonic clock's sample at query time ([LTIM.2.8.2]). The re-evaluation is driven by
giving the rule a time-dependent condition, a positive pattern's `within` window
([LTIM.2.7.1]) or a `where` that reads a clock ([LTIM.2.4.1]), which head-inserts the
internal `$ClockTick` re-driver ([LFST.6.2]). A `then … within` window reads no
clock and drives none; `$ClockTick` is
engine-internal and not an author construct. The compiler warns
`DS_VALIDATE_SERIES_GAP_HOLD_NO_CLOCK` when a `gap hold` integral under
`realtime` has no such tick-driving window. `gap zero` and `gap skip` advance
only on assertion and need no clock.

---

*Deferred: not binding in this edition.*

*see also:* [LTIM.2.8.2](#LTIM-2-8-2), [LFST.6.2](#LFST-6-2), [LTIM.2.4.1](#LTIM-2-4-1), [LTIM.2.7.1](#LTIM-2-7-1)

(LSIG-4)=
## Determinism [LSIG.4]

(LSIG-4-1)=
[LSIG.4.1] DS guarantees strict replay determinism in all modes, `realtime`
included ([LDET]). A series backing's output enters the operator log, so each
backing must use only correctly-rounded operations, in a fixed fact order:
IEEE-754's add, subtract, multiply, divide, `sqrt` and `fma`, and the
correctly rounded transcendentals the author-facing surface admits
([LDET.3.4.4]). That is the bar the author-facing surface is held to, so
there is no guard band anywhere to reason about ([LDET.3.4.1]).

*see also:* [LDET.3.4.1](#LDET-3-4-1), [LDET.3.4.4](#LDET-3-4-4)

(LSIG-4-2)=
[LSIG.4.2] All v1 aggregations meet this bar and are bit-reproducible on any
IEEE-754 platform, in every mode:

- `active_fraction` — integer (int64-ns) accumulation via the running sum,
  one correctly-rounded divide.
- `onset_rate` — running-sum count divided by the window.
- `integral` — fixed-order `Float64` accumulation, including the `K = 128`
  recompute.

(LSIG-4-3)=
[LSIG.4.3] `integral … gap hold` reads `clock_ns` at query time
(§[LSIG.3.6]). This stays deterministic on replay because `$ClockTick` /
`clock_ns` is part of the recorded input stream ([LDET]), so query times are
themselves replayed.

*see also:* [LSIG.3.6](#LSIG-3-6)

(LSIG-4-4)=
[LSIG.4.4] Every v1 aggregation may assert exact equality in conformance
fixtures, on every platform and in every mode. The golden vectors — the
integer-exact `active_fraction` path, the `integral` rectangle sum and
`K = 128` recompute, `onset_rate`'s `min(W, elapsed)` warm-up denominator,
and the default↔`realtime` divergence of §[LSIG.5] — are authored in
`specs/conformance/SERIES_SIGNAL_VECTORS.md`.

---

*see also:* [LSIG.5](#LSIG-5)

(LSIG-5)=
## Realtime and bounded-memory dialects [LSIG.5]

(LSIG-5-1)=
[LSIG.5.1] Under `realtime` and `linear_scan: false`, `SeriesBackendIntervalPulse`, `SeriesBackendNumericIntegral`, and the
`SeriesBackendRingBuffer`-backed `onset_rate` each require a `series[i].capacity` entry in the
`.dsrt` — the maximum number of transitions (`SeriesBackendIntervalPulse`, `SeriesBackendRingBuffer`) or samples (`SeriesBackendNumericIntegral`)
expected in the window. The runtime sizes the backing from it at load time;
the running sums are O(1) regardless. This is the capacity discipline already
governing `SeriesBackendRingBuffer` ([LNLS.3.5]).

*see also:* [LNLS.3.5](#LNLS-3-5)

(LSIG-5-2)=
[LSIG.5.2] `SeriesBackendIntervalPulse` has a single exact form and is available under `realtime`
and `linear_scan: false` with no approximate substitute: its state is bounded by the
declared capacity and its query is O(K)-bounded for WCET. A boolean slot
whose worst-case transition count would overflow a practical capacity is
almost always un-debounced chatter and must be debounced at the adapter.

(LSIG-5-3)=
[LSIG.5.3] `integral` is available under `realtime` for `sliding` and
`tumbling` only. The compiler must reject `integral all_time` under
`realtime` with `DS_VALIDATE_SERIES_REALTIME_UNBOUNDED_BACKING` (error — reject): the ring grows without
bound when no window limits it. The error should suggest `integral sliding W`
with a sufficiently large `W`, or a host-side build for true cumulative
totals.

*Deferred: not binding in this edition.*

(LSIG-5-4)=
[LSIG.5.4] The state of the three signal aggregations is not evicted after a
window of silence, in any mode ([LSER.9.3.1]). A boolean slot idle between
bursts holds its last value through the gap. A stuck `true` reads as `true`:
`active_fraction` reads `1.0` once its open interval spans the window, and a
`true` asserted after a held `true` is no rising edge. `t_first` does not reset
([LSER.19.7]), so `onset_rate`'s warm-up correction applies over the instance's
first `W` only. Silence is not an observation that the signal changed: an author
who needs a dead sensor to read differently from a steady one should pair these
aggregations with an explicit liveness check ([LSIG.6.1]).

---

*ratified*  —  *see also:* [LSER.19.7](#LSER-19-7), [LSER.9.3.1](#LSER-9-3-1), [LSIG.6.1](#LSIG-6-1)

(LSIG-6)=
## Reliability contract [LSIG.6]

(LSIG-6-1)=
[LSIG.6.1] The v1 aggregations are exact over the *observed* event stream,
but their fidelity to the *physical* process depends on assumptions the
substrate does not guarantee. The recurring rule: these primitives are
trustworthy paired with a liveness check, not alone. Over a lossy transport,
an author should pair them with an independent rate or heartbeat signal.

| Aggregation | Exact w.r.t. | Key assumption | Failure mode if it breaks | Pair with |
|---|---|---|---|---|
| `active_fraction` | observed transition stream | every transition observed; adapter asserts initial `true` on connect | a lost falling edge biases it high without self-correcting; an already-on sensor under-reports for ≤ W after connect | `onset_rate` and/or a `scope ttl` heartbeat |
| `onset_rate` | observed rising edges | edges are genuine onsets, not chatter | un-debounced chatter inflates it | debounce upstream |
| `integral` | piecewise-constant fact model | every value change observed; correct `gap` policy | `gap hold` over a dead sensor accrues without bound; rectangle error ≤ granularity × W vs the true signal | `gap zero` for rates; liveness for held quantities |

(LSIG-6-2)=
[LSIG.6.2] Two assumptions cut across all three:

- **Monotone timestamps.** DS series do not reorder. An assertion whose
  timestamp precedes the backing's most recent recorded timestamp is silently
  discarded; the adapter owns ordering and buffering. An adapter connecting to
  a boolean sensor already in the `true` state must assert `true` at connect
  time, before any subsequent change, or `SeriesBackendIntervalPulse` returns `active_fraction = 0`
  until the first observed rising edge.
- **Periodic re-evaluation.** See §[LSIG.7].

---

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

(LSIG-7)=
## Truth maintenance and re-evaluation [LSIG.7]

(LSIG-7-1)=
[LSIG.7.1] Signal aggregations are first-class series values in rule `where`
clauses and participate in truth maintenance: a logical fact emitted when
`active_fraction > threshold` retracts when `active_fraction` falls back
below it, with no explicit retraction rule.

(LSIG-7-2)=
[LSIG.7.2] A threshold crossing driven by a **new assertion** is reflected
immediately, on that assertion's evaluation. A crossing driven purely by the
**passage of time** — a quiet window sliding the value across the threshold —
is not self-triggering: the query returns a fresh value when evaluated, and
the engine evaluates at every pump ([LSER.8.1.1]). With no pump, the derived
fact does not change state, so the retraction latency of a fact whose source
can fall quiet is bounded by the host's pump interval. This is the same clock dependency
that `integral … gap hold` carries (§[LSIG.3.6]).

*see also:* [LSER.8.1.1](#LSER-8-1-1), [LSIG.3.6](#LSIG-3-6)

(LSIG-7-3)=
[LSIG.7.3] `active_fraction < ε` as an idle / cycle-done signal is therefore
intrinsically lagged by up to `W` and is tick-driven. An author who needs a
prompt idle signal should use `onset_rate ≈ 0` or the source fact's own
retraction; `active_fraction < ε` carries "has been idle for most of the
window" semantics where the ~`W` lag is intended.

---

(LSIG-8)=
## Cold-start and warm-up [LSIG.8]

(LSIG-8-1)=
[LSIG.8.1] The v1 aggregations accumulate activity and return `0.0` before
their first data — absence of signal is genuinely zero — and never return
`null`. No null-guard is required.

| Aggregation | Before first assertion | First valid result |
|---|---|---|
| `active_fraction` | `0.0` (assumed off; biased low for ≤ W if connected while already `true`) | first `true` assertion |
| `onset_rate` | `0.0` | unbiased once instance age ≥ W (÷`min(W, elapsed)` corrects the warm-up undercount) |
| `integral` | `0.0` | first assertion |

