# Language surface — feature inventory

An inventory of every feature the DS language exposes to
rule authors, organised by category.

**This is not the gating catalog.** Most features here are
grammar-level and not dialect-gateable; the BNF parses them
identically regardless of which dialect a rule file
declares. The narrow subset that *is* gateable — action-
level forms that correspond to runtime capabilities a tier
might lack — lives at [LFCA].

This doc earns its place as a **cross-check for the BNF**:
it ensures [LGRA] covers everything
authors can type.

## What this is not

- **Not the gating catalog.** See
  [LFCA] for the narrow set
  of forms dialect registration calls reference.
- Not a grammar. [LGRA] owns the BNF;
  this doc is an informal feature inventory.
- Not a spec for any feature's semantics. Those live in
  per-topic spec docs; this doc points at them.
- Not a source of truth for capabilities. [LCAP.1] is the
  registry, and a program sets them in its `use` block.

### Why most of these aren't gateable

A tier integrator's dialect is an **action-and-capability
allowlist**, not a grammar subset. The BNF does not change
between dialects. Expression grammar, pattern matching,
schema declarations, truth maintenance,
interpolation, and all the grammar primitives are always
available and always parsed identically. Tier authors
cannot invent a different DS; they can only restrict which
actions their tier's rules can invoke and which runtime
capabilities those rules may depend on.

---

(LLSU-1)=
## Conventions [LLSU.1]

(LLSU-1-1)=
- [LLSU.1.1] **Stable name.** Lowercase snake case. Dialects reference
  forms by stable name; these names never change
  semantically across catalog versions. A form can be
  deprecated and retired, but not renamed while present.

(LLSU-1-2)=
- [LLSU.1.2] **Dependencies.** Forms required by this form. A dialect
  enabling this form must also enable its dependencies.

(LLSU-1-3)=
- [LLSU.1.3] **Refactor hint.** What a rule author does when their
  dialect disables this form. Surfaces in compile-error
  messages. "not generally avoidable" is a valid answer for
  foundational forms; the compiler repeats that text.

---

(LLSU-2)=
## `core` — always on [LLSU.2]

(LLSU-2-1)=
[LLSU.2.1] These are available to every program under every setting;
none is a capability ([LDIA.4.2]). A dialect definition naming one fails
to load with `DS_VALIDATE_DIALECT_UNKNOWN_CAPABILITY` ([NDLC.2.2]).

| Name | Explanation | Refactor hint |
|---|---|---|
| `schema_decl` | `schema <Name> [<qualifier>]:` declaration over an indented slot block | not generally avoidable |
| `schema_lifecycle` | `logical` / `ttl` lifecycle on a schema declaration | not generally avoidable |
| `rule_decl` | `rule <name> <lhs> -> <rhs>` declaration | not generally avoidable |
| `pattern_match` | LHS pattern matching on schema constructor | not generally avoidable |
| `pattern_binding` | `<Schema> <binding>` explicit pattern binding | not generally avoidable |
| `where_clause` | `where <expression>` on patterns | not generally avoidable |
| `pattern_not` | `not <…>` logical connector — a logic shape, sibling to `or` and `and`, and unrelated to absence. Distinct from `no <pattern>`, which is a pattern shape ([LGRA.2.11.5]) | not generally avoidable |
| `pattern_or` | `(<pattern> or <pattern>)` disjunction | not generally avoidable |
| `expression` | the expression grammar (arithmetic, comparison, bool ops) per EXPRESSIONS | not generally avoidable |
| `emit_intratier` | `emit <Schema>` — assert a fact into the current tier's working memory | not generally avoidable |
| `log_action` | `log <level> "<msg>"` action | rewrite using the integrator-provided logging adapter if available |

*see also:* [LDIA.4.2](#LDIA-4-2), [LGRA.2.11.5](#LGRA-2-11-5), [NDLC.2.2](#NDLC-2-2)

(LLSU-2-2)=
[LLSU.2.2] Semantic specs: [LFAC],
[LEXP], [LGRA].

---

(LLSU-3)=
## `expressions` — the expression grammar [LLSU.3]

(LLSU-3-1)=
[LLSU.3.1] The full expression surface from [LEXP]. Dialects
can narrow this (disabling bitwise, disabling regex) without
breaking anything else.

| Name | Explanation | Refactor hint |
|---|---|---|
| `expr_arithmetic` | `+ - * / // % **` | not generally avoidable |
| `expr_comparison` | `= != < <= > >=` | not generally avoidable |
| `expr_comparison_chain` | `a < b < c` comparison chains | rewrite as `a < b and b < c` |
| `expr_logical` | `and or not` | not generally avoidable |
| `expr_bitwise` | `& \| ^ ~ << >>` | use an integrator call target for bit-twiddling |
| `expr_unary` | unary `- + ~` | not generally avoidable |
| `expr_parens` | `( <expression> )` grouping | not generally avoidable |
| `expr_cast` | postfix `::` conversion cast — `x::Int`, `s::Float?`, `f::Json` ([LCST.4]) | not generally avoidable |
| `expr_constants` | `inf` `nan` | use literal numeric values if inexact is OK |
| `expr_math_rounding` | `abs` `round` | inline with comparison + arithmetic |
| `expr_math` | the `math` module and its import ([LIMP.3.3.4]): `pi` `e` `tau`, `floor` `ceil` `trunc` `sign`, `fma`, `sqrt` `exp` `ln` `log2` `log10` `pow`, `sin` `cos` `tan` `asin` `acos` `atan` `atan2`, `sinh` `cosh` `tanh`, `degrees` `radians` | use an integrator call target |
| `expr_bit_utility` | the `Int` members ([LEXP.3.7.1]) `.bit_count` `.bit_length` `.leading_zeros` `.trailing_zeros` `.bits` `.sign_extend` `.swap_bytes` | use an integrator call target |
| `expr_aggregation_atom` | series aggregations (`mean(s)` etc.) usable as expression atoms | requires `series` category; fold into the enclosing condition |
| `expr_distance` | the `distance` module and its import ([LIMP.3.3.4]): `euclidean` `manhattan` `chebyshev` `hypotenuse` `cosine` at 2D and 3D arities, `great_circle` | use an integrator call target |

*see also:* [LCST.4](#LCST-4), [LEXP.3.7.1](#LEXP-3-7-1), [LIMP.3.3.4](#LIMP-3-3-4)

(LLSU-3-2)=
[LLSU.3.2] Semantic spec: [LEXP].

---

(LLSU-4)=
## `logical` — truth maintenance [LLSU.4]

(LLSU-4-1)=
[LLSU.4.1] The `logical` modifier on emit, the tick-fact infrastructure
that drives time-bound re-evaluation, and the operator-log
entries for retract causes.

| Name | Explanation | Dependencies | Refactor hint |
|---|---|---|---|
| `logical_emit` | `emit <Schema> logical` — truth-maintained fact | `emit_intratier` | use `emit` with an explicit TTL via `retain` and pair with an explicit-retract rule |
| `time_tick` | engine tick-fact plumbing for time-bound LHS tests | `logical_emit` | disable only if the tier has a natural high-frequency clock source |
| `logical_retract_observability` | operator-log entries for logical-retract cause (`justifier_end` / `hydration_ttl` / `explicit_retract`) | `logical_emit` | not generally avoidable for debuggability |

(LLSU-4-2)=
[LLSU.4.2] Semantic spec: [LLOG].

---

(LLSU-5)=
## `temporal` — time-axis primitives on patterns [LLSU.5]

(LLSU-5-1)=
[LLSU.5.1] Temporal predicates in LHS patterns. Timer-based RHS
continuations (`after <dur>:` and `after <dur> as <expr>:`)
are normative in v1 per [LTAC]
and [LRST], which itemise them.

| Name | Explanation | Refactor hint |
|---|---|---|
| `within_predicate` | `within <dur>` on a pattern — fact entered in the last N | compare `t.dwell` against N |
| `not_within_predicate` | `not <pattern> within <dur>` — no matching fact entered in last N | not generally avoidable for absence-based rules |
| `dwell_alias` | `t.dwell` compile-time alias for the time since the fact entered working memory | none: the entry stamp has no other author syntax ([LEXP.9.5.2]) |

*see also:* [LEXP.9.5.2](#LEXP-9-5-2)

(LLSU-5-2)=
[LLSU.5.2] Semantic spec: [LGRA],
[LFAC], [LSER]
(for the dwell/no-op relationship).

---

(LLSU-6)=
## `adapter` — dotted-syntax sugar for adapter-managed facts [LLSU.6]

(LLSU-6-1)=
[LLSU.6.1] Per [LADP]. A dialect for a tier that
doesn't connect to adapters can disable the category
entirely.

| Name | Explanation | Refactor hint |
|---|---|---|
| `adapter_dotted_sugar` | `domain.entity t where ...` lowers to `Constructor t where t.entity_id == "domain.entity"` | spell out the constructor form: `Sensor s where s.entity_id == "..."` |
| `adapter_wildcard_glob` | `*` in dotted patterns lowers to regex on the key slot | enumerate specific entities if the glob size is small |
| `adapter_discovery_schemas` | schemas a discovery-driven adapter declares ([RARC.9.4.2]) | use author-declared or fixed schemas |
| `adapter_json_fallback` | `Json` slot type for adapter payloads whose shape can't be statically committed to | stringify at the adapter and require rule-side parsing; or emit multiple narrow schemas per observed type |
| `adapter_retained_slot` | `retained` common slot on author-declared adapter schemas | drop live/snapshot filtering, or query a separate schema |
| `adapter_context_id_slot` | `context_id` common slot on discovery-driven adapter schemas | ignore own-action feedback avoidance |

*see also:* [RARC.9.4.2](#RARC-9-4-2)

(LLSU-6-2)=
[LLSU.6.2] Semantic spec: [LADP].

---

(LLSU-7)=
## `call` — async call/response [LLSU.7]

(LLSU-7-1)=
[LLSU.7.1] Service invocation via the (domain, method) dispatch table.
A response arrives as a fact of the service's response schema
([LCRS.4.3.1]) the rule can match in a sibling rule.

| Name | Explanation | Dependencies | Refactor hint |
|---|---|---|---|
| `call` | `call <domain>.<method> args ...` action | | not generally avoidable; this is the fundamental external-effect primitive |
| `service_response_decl` | `response T` or `no response` as a service declaration's last line | `call` | not avoidable; every service declares its response |
| `call_response_fact` | the response fact, a `ttl` fact of the service's response schema matched on `corr` in a sibling rule | `service_response_decl` | requires re-designing around cache-based polling; usually a sign the tier is wrong |
| `call_error_fact` | `CallError e where e.corr == "<id>"` matchable in a sibling rule | `call` | silently swallow errors (usually wrong) |
| `call_correlation_explicit` | `as "<id>"` on `call` to set correlation id | `call` | accept compiler-generated corr ids (harder to grep in logs) |
| `call_cooldown_required` | `cooldown: <dur>` mandatory on every `call` (compile error if omitted) | `call` | not generally avoidable; this is the rate-limit safety |
| `nocooldown` | the bare `nocooldown` flag, the explicit opt-out for naturally-bounded calls | `call` | use a minimum cooldown value the tier's rate budget tolerates |
| `call_retain` | `retain: <dur>` on a call — refused on every call in this edition ([LCRS.6.3.3]) | `call` | none: a response's lifetime is its schema's TTL ([LCRS.6.6.1]) |
| `call_batch_coalescing` | adapter-side opportunistic batching of multi-entity calls | `call` | write per-entity calls; adapter coalescing is transparent, so disabling here just disables the optimisation |

*see also:* [LCRS.4.3.1](#LCRS-4-3-1), [LCRS.6.3.3](#LCRS-6-3-3), [LCRS.6.6.1](#LCRS-6-6-1)

(LLSU-7-2)=
[LLSU.7.2] Semantic spec: [LCRS].

---

(LLSU-8)=
## `publish` — cross-tier fact flow [LLSU.8]

(LLSU-8-1)=
[LLSU.8.1] Upward fact flow to a higher tier (integrator-defined).
Distinct from intra-tier `emit` (in `core`) because it
crosses a tier boundary with TTL and overflow semantics.

| Name | Explanation | Refactor hint |
|---|---|---|
| `publish` | `publish <Schema>` — cross-tier upward assertion | reach the other tier through a `call` |
| `publish_overflow_policy` | `overflow <policy>` per-schema on cross-tier wire (drop-oldest / persist-through-storage / drop-newest) | accept the runtime's default policy |

(LLSU-8-2)=
[LLSU.8.2] Semantic spec: [LTIE],
[LFAC],
[RARC].

---

(LLSU-9)=
## `storage` — the three storage planes [LLSU.9]

(LLSU-9-1)=
[LLSU.9.1] The cache plane, per [LSTO]. The facts and
samples planes, and hydration, are deferred ([LSTO.2], [LSTO.3], [LHYD.1]).

| Name | Explanation | Dependencies | Refactor hint |
|---|---|---|---|
| `cached` | `let v = cached("k")` — sync-intent read (let-RHS expression per LGRA.9.8.2) | | not generally avoidable as a sync-read primitive |
| `cache` | `cache key: k value: v` — async write | | keep the state in a `logical` fact |
| `cache_delete` | `cache_delete key: k` | | let TTL expire the key (may be too slow) |
| `cache_ttl` | `ttl: <dur>` on `cache` | `cache` | manage invalidation via explicit delete |

*see also:* [LGRA.9.8.2](#LGRA-9-8-2), [LSTO.2](#LSTO-2), [LSTO.3](#LSTO-3), [LHYD.1](#LHYD-1)

(LLSU-9-2)=
[LLSU.9.2] Semantic spec: [LSTO].

---

(LLSU-10)=
## `series` — observation-shaped series declarations [LLSU.10]

(LLSU-10-1)=
[LLSU.10.1] Declared series naming the observations an author wants
on a slot's history (aggregation × time-model × accuracy);
the compiler picks backing structures from the matrix at
[LSER.18.1].
Aggregations are accessible as expression atoms (via
`expr_aggregation_atom` in the expressions category) and as
companion slots on bindings.

| Name | Explanation | Dependencies | Refactor hint |
|---|---|---|---|
| `series` | top-level declaration: `series <slot-ref> [block-opts]:` + block of observation lines (`<aggs> <time-model>`) | | not generally avoidable if any aggregation is used |
| `series_block_options` | parenthesised block options on the declaration line: `(by: <slot>\|none)` | `series` | omit (on `logical`, `by:` defaults to the schema's declared `key` slots per LSER.7.6.1; required on `ttl`) |
| `series_time_model_all_time` | `all_time` time-model phrase | `series` | use `sliding <dur>` with a long window |
| `series_time_model_sliding` | `sliding <dur>` true-window time-model phrase | `series` | not generally avoidable for windowed questions |
| `series_time_model_tumbling` | `tumbling <dur>` non-overlapping bucketed time-model phrase | `series` | approximate with `sliding <dur>` (different read semantics) |
| `series_time_model_sample` | `sample <n>` uniform-random reservoir time-model phrase ([LSMP]) | `series` | use `sliding` over a sized window |
| `series_agg_descriptive` | `mean` `median` `min` `max` `sum` `count` | `series` | manually maintain via rule-based state |
| `series_agg_dispersion` | `stdev` `pstdev` `variance` `pvariance` | `series` | manually compute via call target |
| `series_agg_percentile` | `p1`..`p99` (excluding `p0`/`p100` — use `min`/`max`) | `series` | exact on a bounded window (`sliding` / `sample`); `all_time` / `tumbling` percentiles have no exact backing |
| `series_agg_cardinality` | `count_distinct` | `series` | manually maintain set state per identity |
| `series_agg_per_value_freq` | `count_of(s, value)` | `series` | manually maintain a frequency table per identity |
| `series_agg_set_membership` | `contains(s, value)` | `series` | manually maintain a set per identity |
| `series_agg_boolean` | `bool_and` `bool_or` (`Bool`-typed slots only) | `series` | use explicit `not` absence patterns |
| `series_agg_temporal` | `first` `last` `rate` `direction` | `series` | inline via pattern-match on two timestamps |
| `series_label` | `as <label>` namespacing on an observation line; produces `t.<label>.<agg>` companion slots | `series` | unique-aggregation triples per slot, drop `as` |
| `series_companion_slot` | `t.<agg>` / `t.<label>.<agg>` companion-slot aliases on bindings | `series` | write the explicit `<agg>(t)` / `<agg>(t.<label>)` expression form |

A `tolerance` / `confidence` / `delta` /
`bound deterministic` phrase on an observation line is refused ([LSER.15.1]).

`confidence`, `delta`, `bound` and `deterministic` are **ordinary identifiers**,
not reserved words.
`tolerance` is reserved: it is the slot-level within-tolerance clause
([LFAC.2]). See [LSER.15].

*see also:* [LFAC.2](#LFAC-2), [LSER.15](#LSER-15), [LSER.15.1](#LSER-15-1), [LSER.18.1](#LSER-18-1), [LSER.7.6.1](#LSER-7-6-1)

(LLSU-10-2)=
[LLSU.10.2] Semantic spec: [LSER].

---

(LLSU-12)=
## `interpolation` — string interpolation in action arguments [LLSU.12]

(LLSU-12-1)=
[LLSU.12.1] Typed string interpolation per [LGRA].

| Name | Explanation | Refactor hint |
|---|---|---|
| `interp_basic` | `"{binding.slot}"` substitution | manual string-concatenation call target |
| `interp_format_spec` | format specifiers: `:.2f`, `:04d`, `:>10`, `:+.1f`, etc. | pre-format the value via an integrator call target |
| `interp_time_format` | `{t.ts:%H:%M:%S}` strftime-style time formatting | pre-format the value via an integrator call target |
| `interp_path_access` | `{response.forecast[0].max}` path access into structured slots | bind intermediate value via an earlier rule |
| `interp_literal_braces` | `{{` and `}}` for literal `{` and `}` | not generally avoidable once `interp_basic` is on |

(LLSU-12-2)=
[LLSU.12.2] Semantic spec: [LGRA].

---

(LLSU-13)=
## `fact_category` — fact lifecycle discipline [LLSU.13]

(LLSU-13-1)=
[LLSU.13.1] Schema-level declarations that shape fact lifetime.

| Name | Explanation | Refactor hint |
|---|---|---|
| `schema_logical` | `logical` lifecycle on schema — truth-maintained, retract-and-replace on change, one live fact per identity | use `ttl` with explicit retract rules (loses dwell correctness, breaks `emit ... logical`) |
| `schema_ttl` | `ttl` lifecycle on schema — TTL-bound, accumulates | not generally avoidable for event-like facts |
| `noop_reassert_suppression` | engine-level no-op reassertion suppression | live with dwell flicker and logical-fact flicker (breaks too many other things) |

(LLSU-13-2)=
[LLSU.13.2] Noop-suppression is an engine-level discipline invisible
to rule authors but exposable as a catalog form so
dialects that care about this invariant can ensure it's
on.

(LLSU-13-3)=
[LLSU.13.3] Semantic spec: [LFAC].

---

(LLSU-14)=
## `synthetic` — compiler-generated identifiers [LLSU.14]

(LLSU-14-1)=
[LLSU.14.1] Synthetic names, the `$`-prefixed names the compiler and engine
make for themselves ([LLEX.10.6.1]). Author code can't produce these; dialects that disable this
category reject rule files containing any feature that
would require synthetic identifiers (essentially:
everything with any desugaring).

| Name | Explanation | Refactor hint |
|---|---|---|
| `synthetic_identifiers` | compiler-generated `$`-prefixed names (for desugaring and internal machinery) | disabling effectively disables most of the language; not meaningfully avoidable |

*see also:* [LLEX.10.6.1](#LLEX-10-6-1)

(LLSU-14-2)=
[LLSU.14.2] Semantic spec: [LLEX.10.6.1] — a synthetic name is `$` followed
by the name, and `$` is not a `NAME` character, so no author name collides with
one. [LGRA.15.2] states the same as a property of the `NAME` terminal.

---

*see also:* [LGRA.15.2](#LGRA-15-2), [LLEX.10.6.1](#LLEX-10-6-1)

(LLSU-15)=
## The extension boundary [LLSU.15]

(LLSU-15-3)=
### What ships in v1 without an extension [LLSU.15.3]

(LLSU-15-4)=
- [LLSU.15.4] Test-mode **runtime machinery** (deterministic clock,
  adapter-mock contract, event-trace primitive, introspection
  queries) ships in v1 because it's how the runtime works
  under test — see [LTES]. This is not an extension;
  authors don't write test-only constructs in rule files.
  User rule tests in v1 are harness-side code that drives
  the runtime in test mode; rule files themselves use only
  base-language forms.

(LLSU-15-5)=
- [LLSU.15.5] Activation-linked timer behaviour is part of the base
  language: [LSCP] (the `scope activation`
  lifecycle) and [LRST] (the `after <dur> as <expr>:`
  per-fact supersedure form).

*ratified*

(LLSU-16)=
## Inventory scope [LLSU.16]

(LLSU-16-1)=
- [LLSU.16.1] **v1 language inventory.** This inventory covers the
  features the language has. Material held under `future/` is out
  of scope.

(LLSU-16-2)=
- [LLSU.16.2] **Author-visible axis.** Features here are things a rule
  author can type. Lowering details and engine-internal
  mechanisms that have no syntactic surface don't appear.

(LLSU-16-3)=
- [LLSU.16.3] **Not the gating surface.** Most entries here are
  grammar-level — parsed identically regardless of dialect.
  The gating subset (action-level forms corresponding to
  runtime capabilities) is extracted to
  [LFCA]; only that subset
  has stable names dialect registration calls reference.

(LLSU-16-4)=
- [LLSU.16.4] **Capabilities.** [LCAP.1] registers every capability a
  program's `use` block may set; a name outside that registry is a compile
  error ([LDIA.3.3.2]). Testing is not among them — `.dstest` is a separate file type,
  not a capability ([LTES.7.6], [LTSL]). The imperative-shaped surface (activation
  timers, per-fact supersedure) sits in the base language per [LLSU.15.5].

*ratified*  —  *see also:* [LCAP.1](#LCAP-1), [LDIA.3.3.2](#LDIA-3-3-2), [LTES.7.6](#LTES-7-6), [LLSU.15.5](#LLSU-15-5)

(LLSU-16-5)=
- [LLSU.16.5] **Role as BNF cross-check.** Every feature in this
  inventory is covered by the BNF in
  [LGRA]; conformance for each feature
  lives under that feature's own clause.

