# DS fact model: lifecycle and no-op reassertion discipline

This document covers:

1. The two fact lifecycle categories (`logical` / `ttl`)
   declared on every schema, and what the choice commits an
   adapter (or rule) to at runtime.
2. The **no-op reassertion discipline** — the engine-side
   contract that `logical` fact semantics depend on.

Paired with [LGRA],
which specifies the syntax for the lifecycle modifier; this
doc specifies the runtime semantics the modifier implies.

## What this is not

- Not a schema-declaration grammar reference — that's
  [LGRA].
- Not a cross-tier fact-flow specification — see
  [LTIE] for the language-side contract
  and [RARC] for the
  runtime-side mechanism.
- Not an implementation guide for adapter authors —
  adapter-specific docs own the per-system details of
  meaningful-change filtering.

---

(LFAC-1)=
## The two fact lifecycle categories [LFAC.1]

(LFAC-1-1)=
[LFAC.1.1] Every schema picks a lifecycle via the optional
`scope` clause on its header. Four values are admitted per
[LSCP.1.5]: `explicit`, `logical`, `ttl <duration>` and
`activation`, and `logical` and `ttl` may carry the `ambient`
modifier. When `scope` is omitted, the schema
defaults to `scope explicit` per [LSCP.1.4].

This section covers `logical` and `ttl`; `explicit`,
`activation`, and `ambient` live at [LSCP.2].

*ratified*  —  *checks:* `k`  —  *see also:* [LSCP.1.4](#LSCP-1-4), [LSCP.1.5](#LSCP-1-5), [LSCP.2](#LSCP-2)

(LFAC-1-2)=
### `logical` facts [LFAC.1.2]

(LFAC-1-2-1)=
- [LFAC.1.2.1] **Asserted** by adapters that bridge
  external entity-oriented state (Home Assistant entities,
  MQTT retained topics, weather current-conditions,
  author-declared state facts) or by rules using
  `emit X logical`.

(LFAC-1-2-2)=
- [LFAC.1.2.2] **Retract-and-replace** on each meaningful
  change. Exactly one live fact per identity key — the
  slots the `logical` schema declares `key` per [LFAC.1.7].
  (This is the key-subset case of the declared-key model.)

*checks:* `k` `idris×23`  —  *see also:* [LFAC.1.7](#LFAC-1-7)

(LFAC-1-2-3)=
- [LFAC.1.2.3] **Persist** in working memory until the
  next meaningful change retracts them.

(LFAC-1-2-4)=
- [LFAC.1.2.4] **`t.dwell`** (time since last meaningful
  change) is well-defined.

(LFAC-1-2-5)=
- [LFAC.1.2.5] **`emit X logical`** compiles only when `X`
  is declared `logical`. The engine maintains truth
  correspondence between the emit rule's LHS and the
  emitted fact: the fact lives while the LHS matches,
  retracts when it stops matching, and survives cycles
  where the LHS continues to match.

*ratified*

(LFAC-1-2-6)=
[LFAC.1.2.6] Examples of `logical` schemas:

- Adapter-emitted: HA entity state, MQTT retained-topic
  state, weather current-conditions.
- Rule-emitted: derived state like `Occupied`,
  `InQuietHours`, `OnCall` — things that are either "true
  right now" or "not true right now."

(LFAC-1-7)=
### Identity keys [LFAC.1.7]

*checks:* `alloy×2` `idris×2`

(LFAC-1-7-1)=
[LFAC.1.7.1] A `logical` fact's **identity** is the declared
subset of its slots marked `key`; the remaining slots, marked
`mutable`, are payload. The author declares the role of every
slot with the per-slot `key` / `mutable` markers (the
`field_decl` production is [LGRA.5.1]; the marker tokens are
reserved words per [LLEX.9.5]). Identity
comparison is **exact**: a `tolerance` is admissible only on a
`mutable` slot, never a `key` slot ([LGRA.5.9.10]). Two `Float` keys are
exactly equal when they compare equal under IEEE 754 `==`, so `-0.0` and
`0.0` are one identity ([LDET.3.2.7]). A NaN never reaches a key, because a
NaN `Float` is refused before it enters working memory ([LEXP.4.2]).

*ratified*  —  *checks:* `idris`  —  *see also:* [LDET.3.2.7](#LDET-3-2-7), [LEXP.4.2](#LEXP-4-2), [LGRA.5.1](#LGRA-5-1), [LGRA.5.9.10](#LGRA-5-9-10), [LLEX.9.5](#LLEX-9-5)

(LFAC-1-7-2)=
[LFAC.1.7.2] One rule covers the whole range: **two assertions
with the same key values are the same fact — the later one
supersedes the earlier, its payload replacing the prior.** The
width of the key selects the behaviour:

- key = ∅ (every slot `mutable`) — a **singleton**: one live
  fact, latest payload wins.
- key = one slot — **entity-state**: one live fact per entity.
- key = several slots — a **composite key**.
- key = all slots (every slot `key`, no payload) — a
  **relation**: distinct tuples coexist and identical tuples
  coalesce. This is the key-all case of [LLOG.2.7].

A schema of one slot, marked `key`, is both the second case and the last. They
are one behaviour there: one live fact per key value, which a reassertion
coalesces.

*ratified*  —  *checks:* `k` `souffle` `idris×8`  —  *see also:* [LLOG.2.7](#LLOG-2-7)

(LFAC-1-7-3)=
[LFAC.1.7.3] Relation, entity-state, and singleton are not
separate fact modes — they fall out of which slots are the
key.

(LFAC-1-7-4)=
[LFAC.1.7.4] **Require-all.** Every slot of a `logical`
schema must be marked `key` or `mutable`. The compiler rejects
an unmarked slot on a `logical` schema. Require-all is the
forcing function: no slot is unmarked, so there is no
default-direction question and no silent guess. The one slot it
does not reach is `ts`, which is the engine's and carries no marker
([LFAC.9.1]).

*ratified*  —  *checks:* `alloy×2`  —  *see also:* [LFAC.9.1](#LFAC-9-1)

(LFAC-1-7-5)=
[LFAC.1.7.5] The identity key is the single answer every
identity consumer reads: retract-and-replace dedup
([LFAC.1.2.2]), cooldown keying ([LCDB.3.3.1]),
no-linear-scan join anchors ([LNLS.3.3]), series grouping
([LSER.7.6.1]), and debug display names ([RDSC.6.8.4]). No
consumer resolves identity independently.

*see also:* [LCDB.3.3.1](#LCDB-3-3-1), [LFAC.1.2.2](#LFAC-1-2-2), [LNLS.3.3](#LNLS-3-3), [LSER.7.6.1](#LSER-7-6-1), [RDSC.6.8.4](#RDSC-6-8-4)

(LFAC-1-7-6)=
[LFAC.1.7.6] **`ttl` / event facts carry no markers.** A
`mutable` payload presupposes supersedure, the defining
property of `logical`; `ttl` facts have no per-identity
uniqueness ([LFAC.1.3.2]) — they accumulate and expire — so
`key` / `mutable` are a category error on them. The compiler
rejects a marker on a non-`logical` slot. A `ttl` schema's
grouping needs (cooldown-per-entity, series `by:`) are separate
per-consumer concepts, unchanged by this model.

*see also:* [LFAC.1.3.2](#LFAC-1-3-2)

(LFAC-1-7-7)=
[LFAC.1.7.7] The declared-key identity model applies to a `logical`
base whether or not the `ambient` modifier is layered ([LSCP.2.5]):
`scope logical ambient` is `scope logical` for identity — same
require-all markers, same `key = all` ⇒ relation ([LFAC.1.7.2]).
`ambient` changes *who may write*, never *how the fact is keyed*.

*ratified*  —  *see also:* [LFAC.1.7.2](#LFAC-1-7-2), [LSCP.2.5](#LSCP-2-5)

(LFAC-1-3)=
### `ttl` facts [LFAC.1.3]

(LFAC-1-3-1)=
- [LFAC.1.3.1] **Asserted** by event-oriented adapters (HA
  events from the event bus, camera detections, MQTT
  non-retained messages, response facts and `CallError` from
  service calls) or by rules using plain `emit` (no
  `logical`).

(LFAC-1-3-2)=
- [LFAC.1.3.2] **Accumulate** in working memory — multiple
  in-flight facts of the same schema coexist; there's no
  per-identity uniqueness.

*ratified*  —  *checks:* `k`

(LFAC-1-3-3)=
- [LFAC.1.3.3] **Expire** via per-schema or per-emit TTL.
  A fact received from another tier takes the receiving
  schema's lifecycle ([LTIE.9.4]).

*ratified*  —  *checks:* `k`  —  *see also:* [LTIE.9.4](#LTIE-9-4)

(LFAC-1-3-4)=
- [LFAC.1.3.4] **`t.dwell`** is a compile error ([LFAC.4.5]) — the
  fact's entry stamp ([LTIM.2.8.6]) is the moment it was
  asserted, not the moment something changed.

*see also:* [LFAC.4.5](#LFAC-4-5), [LTIM.2.8.6](#LTIM-2-8-6)

(LFAC-1-3-5)=
- [LFAC.1.3.5] `emit X logical` is a **compile error**
  when `X` is declared `ttl`.

*ratified*  —  *checks:* `idris`

(LFAC-1-3-6)=
[LFAC.1.3.6] Examples of `ttl` schemas:

- Adapter-emitted: HA event-bus events, camera detections,
  MQTT non-retained messages, call response facts and
  `CallError` ([LCRS.4.3.2]).
- Rule-emitted: alerts, transient intermediate events,
  anything that represents "something just happened."

*see also:* [LCRS.4.3.2](#LCRS-4-3-2)

(LFAC-1-4)=
### Why the choice is load-bearing [LFAC.1.4]

(LFAC-1-4-1)=
[LFAC.1.4.1] The lifecycle category decides whether
several load-bearing language primitives work against a
schema:

(LFAC-1-4-2)=
- [LFAC.1.4.2] **`t.dwell`** — only well-defined on
  `logical`-schema bindings. On `ttl` schemas it is a compile error
  ([LFAC.4.5]).

*ratified*  —  *see also:* [LFAC.4.5](#LFAC-4-5)

(LFAC-1-4-3)=
- [LFAC.1.4.3] **`logical` emit** — targets must be
  `logical` schemas. A rule using `emit X logical` with a
  `ttl`-declared X is a compile error.

(LFAC-1-4-4)=
- [LFAC.1.4.4] **No-op reassertion discipline** — applies
  to `logical`-schema emitters only (see
  [LFAC.2]). `ttl` schemas don't need the discipline
  because each emit is independently timestamped and
  meaningful.

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

(LFAC-1-4-5)=
- [LFAC.1.4.5] **Cross-tier emit semantics** — `logical`
  facts crossing a tier boundary need retract-replace on
  the wire; `ttl` facts don't. See
  [LTIE].

(LFAC-1-4-6)=
[LFAC.1.4.6] Making the choice implicit would hide all of
these consequences behind a default. The mandatory header
is a one-time decision per schema that reaches into every
rule touching the schema.

(LFAC-1-5)=
### Mapping from source to category [LFAC.1.5]

(LFAC-1-5-1)=
[LFAC.1.5.1] Typical adapter-side mapping:

(LFAC-1-5-2)=
- [LFAC.1.5.2] **HA entity → `logical`.** Retract +
  reassert on `state_changed` with meaningful-change
  suppression.

(LFAC-1-5-3)=
- [LFAC.1.5.3] **HA event-bus event → `ttl`.** Emits once
  per event, TTL-based.

(LFAC-1-5-4)=
- [LFAC.1.5.4] **Camera detection → `ttl`.** Each
  detection is an event.

(LFAC-1-5-5)=
- [LFAC.1.5.5] **MQTT retained topic → `logical`.**
  Retained = "current state."

(LFAC-1-5-6)=
- [LFAC.1.5.6] **MQTT non-retained → `ttl`.** Published
  events.

(LFAC-1-5-7)=
- [LFAC.1.5.7] **Weather current-conditions →
  `logical`.** One fact per location at a time;
  retract-replace on refresh.

(LFAC-1-5-8)=
- [LFAC.1.5.8] **Weather forecast → `ttl`.** Many
  forecast slots simultaneously; refresh retracts all and
  reasserts the new set.

(LFAC-1-5-9)=
- [LFAC.1.5.9] **Rule `emit X` (no `logical`) → `ttl`**
  by default.

(LFAC-1-5-10)=
- [LFAC.1.5.10] **Rule `emit X logical` → `logical`**
  (and X must be declared so).

(LFAC-1-5-11)=
[LFAC.1.5.11] If a concept legitimately needs both forms
— e.g., `Occupied` as both a transient entry event and a
maintained state — split into two schemas
(`OccupiedEvent ttl` + `Occupied logical`). Forces the two
intents to be visible at authoring time.

(LFAC-1-6)=
### Mixing categories in one rule [LFAC.1.6]

(LFAC-1-6-1)=
[LFAC.1.6.1] A rule's LHS can pattern-match both
categories without any special syntax.

*ratified*

(LFAC-1-6-2)=
[LFAC.1.6.2] The category difference is a property of
each fact, not the rule. The rule fires when a matching
`Person` arrives while the lux sensor is in the "low"
state.

---

(LFAC-2)=
## No-op reassertion discipline [LFAC.2]

*checks:* `alloy×2`

(LFAC-2-1)=
[LFAC.2.1] `logical`-fact semantics depend on this
discipline. When an incoming reassertion of a live fact
carries the same slot values, the engine must not
retract-and-reassert. Doing so would:

(LFAC-2-2)=
- [LFAC.2.2] Reset `dwell` (since
  `dwell` measures from the fact's entry stamp and a
  reassertion would re-enter the fact, [LTIM.2.8.6]),
  making dwell-based rules wrong.

*see also:* [LTIM.2.8.6](#LTIM-2-8-6)

(LFAC-2-3)=
- [LFAC.2.3] Briefly end `logical` emit activations whose
  LHS depended on the fact, causing derived facts to
  flicker retract → reassert.

(LFAC-2-4)=
- [LFAC.2.4] Generate meaningless series samples,
  polluting statistics over the slot.

*ratified*

(LFAC-2-5)=
### Enforcement [LFAC.2.5]

(LFAC-2-5-1)=
- [LFAC.2.5.1] **Engine-side (primary):** the engine
  de-duplicates no-op reassertions as the correctness
  contract. For `String`, `Bool`, `TYPE_NAME`, and default
  `Int` / `Float` slots the comparison is exact equality; for a `Float` that
  is IEEE 754 `==`, so a reassertion that turns `0.0` into `-0.0` is a no-op
  ([LFAC.1.7.1]).
  For `Json` slots the comparison is deep structural
  equality: two values are equal iff they are the same kind and

  - two objects have the same set of keys and, under each key, equal
    values; member order carries no meaning;
  - two arrays have the same length and equal elements, position by
    position;
  - two strings have the same bytes, two booleans the same value, and two
    nulls are equal;
  - two integers have the same value, and two floats compare by IEEE 754
    `==`, so `0.0` equals `-0.0`.

  An integer and a float are different kinds, so `1` and `1.0` are not
  equal: a leaf keeps the kind it was written with ([LEXP.7.12.1]).

  For a slot with a declared `tolerance` ([LGRA.5.9]; on a unit-typed slot,
  in its base unit, [LUNI.7.4]), values within
  the tolerance are treated as equal. **The bound is INCLUSIVE**:
  the values are equal iff they are exactly equal or `|delta| <= tolerance`,
  so a change of exactly `tolerance` IS suppressed. Two equal infinities are therefore equal under any tolerance,
  though their `delta` is NaN. This matters in ordinary use rather than at a float
  edge — `tolerance` is declared on `Int` slots too, where a delta
  landing exactly on the bound is commonplace.

  When a reassertion is suppressed, `dwell` does not reset, no series sample is
  generated, and derived `logical` facts do not flicker.

  The comparison is over the author's slots. `ts` is not compared
  ([LFAC.9.1]): a reassertion that differs from the live fact only in `ts` is
  a no-op, and the live fact keeps its `ts`.

*ratified*  —  *checks:* `alloy×3` `tla` `k` `idris×33`  —  *see also:* [LEXP.7.12.1](#LEXP-7-12-1), [LFAC.1.7.1](#LFAC-1-7-1), [LFAC.9.1](#LFAC-9-1), [LGRA.5.9](#LGRA-5-9), [LUNI.7.4](#LUNI-7-4)

(LFAC-2-5-2)=
- [LFAC.2.5.2] **Adapter-side (optional efficiency):**
  adapters may additionally suppress no-op updates at the
  source-system boundary to reduce wire traffic and
  engine load. Not required for correctness — the
  engine's dedup is the contract. Adapters that suppress
  aggressively emit less (entity adapters comparing against
  last-emitted state; message-bus adapters dropping identical
  republishes; polling adapters dropping unchanged
  refreshes); adapters that pass everything through let
  the engine do the work. Adapter-specific documentation
  describes what each adapter chooses to do.

*ratified*

(LFAC-2-5-3)=
- [LFAC.2.5.3] **The complement: a meaningful change
  is a replace, never a second fact, and is never
  silent.** A reassertion that is *not* a no-op under
  [LFAC.2.5.1] — a `tolerance`-bearing slot whose value
  moves outside the tolerance, or any exactly-compared
  slot that changes — is a **meaningful change**. The
  engine must apply it as a retract-and-replace per
  [LFAC.1.2.2]: the prior fact for that identity key
  ([LFAC.1.7]) is retracted and the new one asserted, so
  **exactly one live fact per key remains** (the live
  count is unchanged), the new fact is a fresh wrapper
  with a new `fact_id` ([IDAT.4.4]), and `ts` advances.
  The engine must surface this on the stream as
  `FACT_ASSERT(new)` followed by `FACT_RETRACT(old)`,
  whether a host assert or a rule's emit produced the
  new fact: the successor is recorded before the
  withdrawal it causes ([RFCS.6.7], [RFCS.6a.4]). `FACT_MODIFY` is reserved and not
  emitted ([NCBK.2.4]). An
  in-place same-wrapper mutation that emits no stream
  event, and any path that leaves a second live fact for
  the same key, are both non-conforming.

*ratified*  —  *checks:* `alloy×3` `tla×2` `k` `idris×30`  —  *see also:* [IDAT.4.4](#IDAT-4-4), [LFAC.1.2.2](#LFAC-1-2-2), [LFAC.1.7](#LFAC-1-7), [LFAC.2.5.1](#LFAC-2-5-1), [NCBK.2.4](#NCBK-2-4), [RFCS.6.7](#RFCS-6-7), [RFCS.6a.4](#RFCS-6a-4)

(LFAC-2-5-4)=
- [LFAC.2.5.4] **Equality basis: `String` / `Bytes` by
  content, not pointer.** The no-op vs meaningful-change
  decision on `String` and `Bytes` slots — and the
  identity-key match ([LFAC.1.7]) — is by **byte content**,
  never by interned-pointer identity. Interning is a
  non-observable runtime optimization ([IRET.1.4] /
  [IDAT.4.7]): a conforming implementation MUST NOT depend
  on two equal strings sharing a pointer, nor expose
  interned-pointer identity across the wire or any
  observable surface. Two facts with byte-equal
  `String`/`Bytes` slots are equal regardless of how the
  runtime stores those bytes (interned engine-lifetime,
  refcounted, arena-copied, or duplicated), so the
  intern-leak seal's refcount + arena machinery is invisible
  to conforming programs.

*ratified*  —  *checks:* `idris×5`  —  *see also:* [IDAT.4.7](#IDAT-4-7), [IRET.1.4](#IRET-1-4), [LFAC.1.7](#LFAC-1-7)

(LFAC-2-6)=
### Scope [LFAC.2.6]

(LFAC-2-6-1)=
[LFAC.2.6.1] The discipline applies to `logical`-schema
emitters:

(LFAC-2-6-2)=
- [LFAC.2.6.2] All adapters emitting `logical`-declared
  schemas.

(LFAC-2-6-3)=
- [LFAC.2.6.3] All rules using `emit X logical`.

(LFAC-2-6-4)=
[LFAC.2.6.4] `tolerance` is legal on **`logical`** schemas only.
It drives the no-op dedup above — a within-tolerance reassertion
of the same identity ([LFAC.1.7]) is suppressed — so it
presupposes identity dedup. A `ttl` / event fact carries no
identity markers ([LFAC.1.7.6]) and does not dedup; such facts
accumulate and expire on their deadline, so `tolerance` has
nothing to suppress there. `tolerance` on a `ttl`-scoped schema
is therefore a compile error (`DS_VALIDATE_TOLERANCE_TTL_SCHEMA`;
grammar rule [LGRA.5.9.5]). The rule is **`logical`-only**, not
merely `ttl`-specific: the compiler rejects `tolerance` on every
non-`logical` lifecycle (`ttl`, `explicit`, `ambient`), matching
the runtime, which rejects it on any non-`logical` schema at
load. The `ttl` case (the common one) reports
`DS_VALIDATE_TOLERANCE_TTL_SCHEMA`.

*ratified*  —  *checks:* `idris`  —  *see also:* [LFAC.1.7](#LFAC-1-7), [LFAC.1.7.6](#LFAC-1-7-6), [LGRA.5.9.5](#LGRA-5-9-5)

(LFAC-2-7)=
### Why it's load-bearing [LFAC.2.7]

(LFAC-2-7-1)=
[LFAC.2.7.1] Spec language throughout DS assumes the
discipline holds:

(LFAC-2-7-2)=
- [LFAC.2.7.2] Series aliases (`t.mean`, `t.stdev`,
  `t.direction`, `t.dwell`) are well-defined only when
  the fact re-enters working memory — and its entry
  stamp advances ([LTIM.2.8.6]) — on meaningful change
  alone. See
  [LSER].

*see also:* [LTIM.2.8.6](#LTIM-2-8-6)

(LFAC-2-7-3)=
- [LFAC.2.7.3] `logical` emit's truth-maintenance
  correspondence depends on stable LHS bindings; no-op
  reassertions destroy stability. See
  [LLOG].

(LFAC-2-7-4)=
- [LFAC.2.7.4] `within <dur>` on `logical` patterns
  means "a live fact whose last meaningful change was
  within the last dur" — only coherent under the
  discipline.

(LFAC-2-7-5)=
[LFAC.2.7.5] The engine's dedup discipline holds
regardless of adapter behaviour. Rule authors can read
`t.dwell > 5_min` and rely on `dwell` advancing only on
meaningful change.

(LFAC-2-7-6)=
[LFAC.2.7.6] For noisy-sensor slots where "meaningful
change" means something other than exact equality, the
`tolerance` modifier on the schema declaration (see
[LGRA]) is the visible,
engine-enforced way to set the threshold — no reliance on
adapter-specific configuration living outside the rule
file.

---

(LFAC-3)=
## Implications for rule authors [LFAC.3]

(LFAC-3-1)=
[LFAC.3.1] Concrete patterns that fall out of the
two-category distinction:

(LFAC-3-2)=
- [LFAC.3.2] **When authoring a rule, first ask: is this
  a per-event decision or a state decision?** Event
  decision → `ttl` facts on the LHS. State decision →
  `logical` facts on the LHS.

(LFAC-3-3)=
- [LFAC.3.3] **`no X within 30_s` on `ttl` facts** —
  checks for absence of any matching event fact within
  the last 30 seconds.

(LFAC-3-4)=
- [LFAC.3.4] **`no X` on `logical` facts** — checks for
  absence of a live fact with the identity key. No
  `within` — a `logical` fact either exists or doesn't
  at a given instant.

(LFAC-3-5)=
- [LFAC.3.5] **`t.dwell > 5_min` on `logical` facts** —
  checks time since last meaningful change. Relies on the
  no-op discipline.

(LFAC-3-6)=
- [LFAC.3.6] **`emit X logical` produces `logical`-style
  derived facts** (X must be declared `logical`, [LLOG.1.3]); plain
  `emit X` produces a fact of X's own lifecycle: `ttl`, or `explicit`
  ([LSCP.2.1.1]).

*see also:* [LLOG.1.3](#LLOG-1-3), [LSCP.2.1.1](#LSCP-2-1-1)

(LFAC-4)=
## Fact-model commitments [LFAC.4]

(LFAC-4-1)=
- [LFAC.4.1] **Two lifecycle categories**, declared on
  the schema header. An omitted `scope` is `scope explicit` ([LSCP.1.4]); the
  choice is load-bearing.

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

(LFAC-4-2)=
- [LFAC.4.2] **Keywords are `logical` and `ttl`.** The
  schema-header word matches the emit-modifier word
  (`emit X logical`). See [LGRA].

*ratified*

(LFAC-4-3)=
- [LFAC.4.3] **Engine-primary no-op dedup.** The engine
  de-duplicates reassertions as the correctness contract.
  Adapters may suppress at the source as an efficiency
  optimisation. See [LFAC.2.5].

*ratified*  —  *see also:* [LFAC.2.5](#LFAC-2-5)

(LFAC-4-4)=
- [LFAC.4.4] **Slot-declared tolerance.** Numeric slots
  with per-slot tolerance drive the engine's
  tolerance-aware comparison. Author-visible at the
  schema; no hidden per-adapter epsilon.

(LFAC-4-5)=
- [LFAC.4.5] **Compile-time enforcement.** `emit X
  logical` requires X's schema lifecycle to be `logical`.
  `t.dwell` on `ttl`-schema bindings is a compile error.

*ratified*

(LFAC-4-6)=
- [LFAC.4.6] **Splitting categories for dual-intent
  concepts.** If a concept has both event and state
  aspects, split into two schemas (`FooEvent ttl` +
  `Foo logical`) rather than conflating.

(LFAC-8)=
## Cross-boundary representation [LFAC.8]

(LFAC-8-1)=
[LFAC.8.1] Schemas are declared in DS source using DS's
declarative schema syntax. The author does not write
protobuf.

(LFAC-8-2)=
[LFAC.8.2] The compiler generates a canonical `.proto`
definition for each schema declaration. The generated
`.proto` is the structural shape of fact instances of
that schema for any cross-boundary use: persistence to
disk by storage adapters, recording in event-trace
artefacts per [LFST.8.10], hypothetical wire transport,
debug inspection, code generation for integrator type
stubs.

*see also:* [LFST.8.10](#LFST-8-10)

(LFAC-8-3)=
[LFAC.8.3] The compiler ships every schema's generated
`.proto` inside the compiled rule artefact (`.dsc`), per
[LFST.11.9] and [RDSC.5.8]. Tooling that needs
schema-typed access fetches the `.proto` from the
artefact rather than from a separate distribution.

*see also:* [LFST.11.9](#LFST-11-9), [RDSC.5.8](#RDSC-5-8)

(LFAC-8-4)=
[LFAC.8.4] The in-process callback surface delivers fact
instances as typed in-memory values per [LFST.2.1];
protobuf is the cross-boundary serialisation form. A
callback receiver may itself encode to protobuf (using
the schema's `.proto` from the artefact) when forwarding
cross-boundary, but the runtime does not protobuf-encode
for in-process delivery.

*see also:* [LFST.2.1](#LFST-2-1)

(LFAC-8-5)=
[LFAC.8.5] The compiler must keep a schema's generated
`.proto` consistent with the schema's slots: one field per slot,
of the type the slot's kind takes ([RDSC.5.8.7]), `optional` exactly when
the slot is nullable ([RDSC.5.8.3]). The `.proto` describes an
instance's slots and nothing else: the schema's lifecycle, slot
tolerance and hydration are carried by their own atoms. Drift between the `.proto` and the slot-typed
metadata is a compiler bug.

*ratified*  —  *see also:* [RDSC.5.8.3](#RDSC-5-8-3), [RDSC.5.8.7](#RDSC-5-8-7)

(LFAC-8-6)=
[LFAC.8.6] **`SchemaDef`↔metadata round trip.** A conforming compiler must be
exercised by a fixture that compiles each schema kind in the slot-
type matrix [RDSC.5.8.6] states, loads the resulting `.dsc`
artefact, and asserts that the `SchemaDef` atom's
`proto_source` agrees with the `Slot` atoms field-by-field
([LFAC.8.5]: the `.proto` describes slots only): every slot in the `.proto`
appears as a `Slot` atom whose kind takes the field's type
([RDSC.5.8.7]), and vice versa. The test fails on
any unidirectional entry (`Slot` without `.proto`
field, or `.proto` field without `Slot`). This makes
the [LFAC.8.5] invariant mechanically checkable
rather than asserted by inspection. Runtime-side
fixture lives at
[RDSC.5.8.6].

*ratified*  —  *see also:* [LFAC.8.5](#LFAC-8-5), [RDSC.5.8.6](#RDSC-5-8-6), [RDSC.5.8.7](#RDSC-5-8-7)

(LFAC-9)=
## The `ts` slot [LFAC.9]

(LFAC-9-1)=
[LFAC.9.1] **A slot named `ts` is a `Time`.** A schema may declare a slot named
`ts` and need not. If it does, the slot's type must be `Time`, not nullable. The
compiler must refuse a `ts` slot of any other type, `Time?` included, with
`DS_VALIDATE_TS_NOT_TIME`.

A construct that needs `ts` requires it of the schemas it reads: every adapter
schema declares it ([LADP.4.2.1]), and so does every schema in a `then` sequence,
the anchor `latest` pins among them ([LTHE.4.5]). Any other schema may declare it,
and there it is the slot this clause describes and nothing more.

**`ts` is the engine's slot, outside identity and outside the no-op test.** It
carries no `key` or `mutable` marker on any schema; on a `logical` schema it is
the one slot [LFAC.1.7.4]'s require-all does not reach, and the compiler must
refuse a marker on it with `DS_VALIDATE_TS_MARKED`. It takes no part in the
schema's identity key ([LFAC.1.7]) and no part in the no-op comparison
([LFAC.2.5.1]): a reassertion that differs from the live fact only in `ts` is
a no-op, and the live fact keeps the `ts` it was given when it entered
([LFAC.9.2]). In the artefact, on a `logical` schema, it carries the identity role
`ENGINE` ([RDSC.5.5.7]). Only a `logical` schema has a no-op test or an identity
key; on any other schema `ts` is a slot like the rest wherever two facts are
compared ([RFCS.23.7]), since it is what tells two events of one schema apart.

*ratified*  —  *checks:* `alloy×4`  —  *see also:* [LADP.4.2.1](#LADP-4-2-1), [LFAC.1.7](#LFAC-1-7), [LFAC.1.7.4](#LFAC-1-7-4), [LFAC.2.5.1](#LFAC-2-5-1), [LFAC.9.2](#LFAC-9-2), [LTHE.4.5](#LTHE-4-5), [RDSC.5.5.7](#RDSC-5-5-7), [RFCS.23.7](#RFCS-23-7)

(LFAC-9-2)=
[LFAC.9.2] **Where `ts` comes from.** When a fact of a schema that declares
`ts` enters working memory, its `ts` is set by where the fact comes from:

- for a fact a rule asserts (`emit`), and for a fact a rule publishes, which
  enters no working memory here ([LTIE.4.3]), the engine must set it to the
  wall clock's current sample, as a UTC `Time` (RLOW.7.1.2). The engine **must**
  fill `ts` before it evaluates any of the action's slot values. Where the wall clock has no value ([LTIM.2.8.3]), the
  fault it records is the `ts` fill's, whatever a slot value would have
  raised;
- for a fact an `initial` block places ([LGRA.24.3]), which supplies no `ts`,
  the engine must set it to the wall clock's sample of the step that consumes
  it ([LTIM.2.8.4]);
- for a host input, the host must supply it ([NFCT.2.10]), and it is source
  time ([LADP.4.2.1]). The engine must not fill a host input's `ts`.

A test input writes no `ts` ([LFAC.9.3]). The test runner must supply it, as a
host supplies source time: the test clock's wall sample at the input's `at`
coordinate, which is the coordinate's instant in absolute mode ([LTSL.3.2]) and
its offset from the Unix epoch in relative mode ([LTSL.3.1]).

*ratified*  —  *checks:* `alloy×5`  —  *see also:* [LADP.4.2.1](#LADP-4-2-1), [LFAC.9.3](#LFAC-9-3), [LGRA.24.3](#LGRA-24-3), [LTIE.4.3](#LTIE-4-3), [LTIM.2.8.3](#LTIM-2-8-3), [LTIM.2.8.4](#LTIM-2-8-4), [LTSL.3.1](#LTSL-3-1), [LTSL.3.2](#LTSL-3-2), [NFCT.2.10](#NFCT-2-10), [RLOW.7.1.2](#RLOW-7-1-2)

(LFAC-9-3)=
[LFAC.9.3] **`ts` is read-only to authors.** An author may read `ts` wherever a
slot may be read, in patterns, expressions and test assertions, and must not
write it. The compiler must refuse a `ts` value supplied by a rule's `emit` or
`publish`, or by a test's constructed fact in `inputs`, `initial` or a response
reply ([LTSL.4.1]), with `DS_VALIDATE_TS_READ_ONLY`.

*ratified*  —  *see also:* [LTSL.4.1](#LTSL-4-1)

(LFAC-10)=
## Slot values [LFAC.10]

(LFAC-10-1)=
[LFAC.10.1] **A slot holds a value, and the value is its fact's own.** A fact
asserted or emitted with a value read from another fact holds that value
itself, not a reference to the other fact's slot. The engine **must** leave it
unchanged when the fact it was read from is retracted, superseded
([LFAC.2.5.3]) or expires, whatever the value's type, `Json` and `Bytes`
included.

A schema-typed slot is the one exception by design: its value is a fact
reference ([LGRA.5.7a.2]), and what a read of it answers is [LEXP.7.20]'s.

*ratified*  —  *see also:* [LEXP.7.20](#LEXP-7-20), [LFAC.2.5.3](#LFAC-2-5-3), [LGRA.5.7a.2](#LGRA-5-7a-2)

(LFAC-11)=
## Terms [LFAC.11]

A **fact** is one instance of a schema: a value for each of its slots.
**Working memory** is the set of facts an engine holds live ([RARC.5.2.1]). An
**activation** is a rule together with the particular facts that matched it: a
firing owed until it fires, which stays, fired, while its match lasts ([LDET.5.3]).

*see also:* [LDET.5.3](#LDET-5-3), [RARC.5.2.1](#RARC-5-2-1)

