# Compiler analysis report

**Not in this edition.** Every clause in this document is deferred or retired, so nothing here binds a 1.0 implementation. It is kept so that its ids and the references to them resolve.


The compiler-analysis artifact emitted at build time. The compiler makes non-trivial choices during
lowering — series backing selection, capture-fact lifetime,
scope-activation completion paths, supersedure-key resolution, cooldown expansion, empty-cell
rejections — and these choices materially affect runtime cost,
behaviour, or correctness. The analysis report is the
author-facing surface for inspecting them.

This doc commits to **what the report contains** at the
language-spec layer. The format, delivery channel, and CLI
surface are runtime concerns, outside this document.

Paired with:
- [LSER.13.3] — series backing selection.
- [LCCO.5] —
  capture-fact lifetime.
- [LSCP.3] —
  scope-activation completion paths.
- [LRST.1.2] — supersedure-key
  resolution.
- [LCDB]
  — cooldown expansion.
- [RDSC] — natural
  home for the build-artifact format.

## What this is not

- Not a format spec. Format (JSON schema, structured-text
  layout, etc.) is a runtime concern.
- Not a delivery-channel spec. Whether the report ships as a
  build artifact, a log channel, or a CLI tool output is a
  runtime concern.
- Not a profiler. The report is build-time analysis, not
  runtime measurement. Runtime profiling lives in
  [NMET].

---

(LCMP-1)=
## The analysis report [LCMP.1]

*Deferred: not binding in this edition.*

(LCMP-1-1)=
[LCMP.1.1] The compiler must emit one analysis report per
compilation. The report covers every rule, schema, and series
declaration in the compiled source.

(LCMP-1-2)=
[LCMP.1.2] The report's audience is the author and the
operator: authors inspect choices that affect cost or behaviour;
operators inspect the report to understand what the compiled
ruleset does at runtime.

(LCMP-1-3)=
[LCMP.1.3] The report is non-normative for runtime semantics —
the compiled output (the `.dsc` artefact) is what the runtime
executes. The report describes the compiler's choices for
human consumption; it does not feed back into runtime decision
making.

(LCMP-1-4)=
[LCMP.1.4] The report is per-compilation. A re-compilation
emits a fresh report; the runtime does not retain prior
reports.

---

(LCMP-2)=
## Required events [LCMP.2]

*Deferred: not binding in this edition.*

(LCMP-2-1)=
[LCMP.2.1] The compiler must emit an analysis event for each of
the following lowering decisions. Each event identifies the
source location, the input declaration, the lowered form, and
the choice rationale.

(LCMP-2-2)=
### Series backing selection [LCMP.2.2]

(LCMP-2-2-1)=
[LCMP.2.2.1] For each `(aggregation, time-model, accuracy)`
triple in a `series` declaration per [LSER.13], the compiler
must emit:

- The triple as the author wrote it.
- The chosen backing class (named per
  [LSER.18.1]).
- The state cost class (e.g. `O(1)`, `O(window-rate)`,
  `O((1/ε) log²(W))`).
- Whether this triple shares a backing with another triple in
  the same `series` block (coalescing per [LSER.13.3]).

*see also:* [LSER.13](#LSER-13), [LSER.13.3](#LSER-13-3), [LSER.18.1](#LSER-18-1)

(LCMP-2-2-2)=
[LCMP.2.2.2] Triples that fall in provably-empty cells per
[LSER.15.2] emit a compile error in the report rather than a
backing entry. The error names the unreachable cell and the
closest satisfiable forms.

*see also:* [LSER.15.2](#LSER-15-2)

(LCMP-2-3)=
### Capture-fact lifetime [LCMP.2.3]

(LCMP-2-3-1)=
[LCMP.2.3.1] For each `call` action with continuations per
[LCCO.5], the compiler must emit:

- The synthetic capture-fact name
  (`$CaptureBindings_<rule>_c<N>`).
- The captured LHS bindings the continuation bodies reference.
- The computed lifetime (`max(retain, largest timeout duration)`
  per [LCCO.5.3]).
- The supersedure correlation (the call's `as <expr>` value
  per [LRST.4]) if any.

*see also:* [LCCO.5](#LCCO-5), [LCCO.5.3](#LCCO-5-3), [LRST.4](#LRST-4)

(LCMP-2-4)=
### Scope-activation completion paths [LCMP.2.4]

(LCMP-2-4-1)=
[LCMP.2.4.1] For each rule whose RHS has scope-activation facts
(an `emit` of a `scope activation` schema per [LSCP.3], or
continuations per [LCCO]), the compiler must emit:

- The list of activation-scoped facts (capture facts and emitted
  `scope activation` facts).
- The enumerated completion paths (synchronous RHS end, each
  `after` timer fire, each `on response` match, each
  `timeout` fire, each `error` match).
- The retract action emitted at each completion path.

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

(LCMP-2-6)=
### Supersedure-key resolution [LCMP.2.6]

(LCMP-2-6-1)=
[LCMP.2.6.1] For each `call ... as <expr>` and each
`after <duration> as <expr>:` clause per [LRST.1.1], the
compiler must emit:

- The author-written expression.
- The expression's resolved type.
- The supersedure scope per [LRST.2.2]: `(rule, clause-position,
  evaluated-key)` for an `after`, `(service, evaluated-key)` for a
  `call` ([LCRS.6.2.1]).
- Compile errors if the type is `Json` per [LRST.1.4] or if
  the expression can be absent per [LRST.1.5].

*see also:* [LRST.1.1](#LRST-1-1), [LRST.1.4](#LRST-1-4), [LRST.1.5](#LRST-1-5), [LRST.2.2](#LRST-2-2), [LCRS.6.2.1](#LCRS-6-2-1)

(LCMP-2-7)=
### Cooldown expansion [LCMP.2.7]

(LCMP-2-7-1)=
[LCMP.2.7.1] For each `cooldown` clause per [LCDB], the compiler must emit:

- The declared duration.
- The resolved duration in microseconds.
- The cooldown scope (per-rule or per-entity).

(LCMP-2-9)=
### Unprefixed schema lifecycle forms [LCMP.2.9]

(LCMP-2-9-1)=
[LCMP.2.9.1] For each schema declaration using an unprefixed
lifecycle form (`schema X logical:` or `schema X ttl <dur>:`),
the compiler must emit the compile error [LSCP.1.6] requires,
including the `scope` spelling it suggests.

---

*see also:* [LSCP.1.6](#LSCP-1-6)

(LCMP-3)=
## Granularity [LCMP.3]

*Deferred: not binding in this edition.*

(LCMP-3-1)=
[LCMP.3.1] The report is structured per rule, with cross-
references to schema declarations and series declarations the
rule depends on.

(LCMP-3-2)=
[LCMP.3.2] Each rule entry contains the events listed in §2
that arose from lowering that rule. Schema declarations and
series declarations get their own entries (not duplicated per
referencing rule).

(LCMP-3-3)=
[LCMP.3.3] Cross-references between entries use the spec's
section IDs ([LSCP.3.1], [LRST.2.2], etc.) so authors reading
the report can trace each compiler decision back to the
governing spec paragraph.

---

*see also:* [LRST.2.2](#LRST-2-2), [LSCP.3.1](#LSCP-3-1)

(LCMP-4)=
## Format and delivery [LCMP.4]

*Deferred: not binding in this edition.*

(LCMP-4-1)=
[LCMP.4.1] The on-disk format and delivery channel are runtime
concerns and are not specified here. One runtime spec owns
those decisions; per-feature forks are forbidden.

(LCMP-4-2)=
[LCMP.4.2] The format must satisfy:

- **Machine-readable.** Tooling (linters, dashboards, dev-loop
  scripts) consumes the report programmatically.
- **Human-renderable.** A CLI tool or default editor view
  presents the report in readable form.
- **Versioned.** A schema-version field allows tooling to
  detect incompatibility.
- **Stable.** Breaking changes follow the standard deprecation
  path; per-feature additions are non-breaking.

(LCMP-4-3)=
[LCMP.4.3] The delivery channel must satisfy:

- **Reproducible.** A given compilation emits the same report
  bytes given the same source and toolchain version.
- **Independent of runtime.** The report is produced at
  compile time and does not depend on runtime state.

(LCMP-4-4)=
[LCMP.4.4] The language spec is silent on the delivery
mechanism; the runtime spec chooses it.

---

(LCMP-5)=
## Stability [LCMP.5]

*Deferred: not binding in this edition.*

(LCMP-5-1)=
[LCMP.5.1] The set of required events per [LCMP.2] is normative
and stable.

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

(LCMP-5-2)=
[LCMP.5.2] Adding a new event is non-breaking: tooling reading
older reports continues to work; tooling that needs the new
event checks for it.

(LCMP-5-3)=
[LCMP.5.3] Removing or renaming an event is breaking and
follows the standard deprecation path.

(LCMP-5-4)=
[LCMP.5.4] The data each event carries per [LCMP.2.2] through
[LCMP.2.9] is the contract. Adding fields to an event is
non-breaking; removing or renaming fields is breaking.

---

*see also:* [LCMP.2.2](#LCMP-2-2), [LCMP.2.9](#LCMP-2-9)

