gnomonlearn
Docs/RFC-0021/Reference catalog

RFC-0021 · Reference catalog

Versioned draft snapshot

RFCs, reference catalogs, and evidence reflect Spec 3b2e3e7a114fb826b1445d39a48756b8fff629cd. Counts and pending/status notes belong to that snapshot. Read the dated project update for later progress.

Source repositories are private during staging. Links marked “repository access required” need access to the linked repository.

← Read the authored RFC

Generated reference catalog. This page renders structured Lean data for RFC-0021: defined terms, diagnostics, dependencies, and invariants. It does not establish proof coverage or runtime conformance. The authored narrative lives in RFC-0021.

This page is generated from the lean/Gnomon/Spec/ module for RFC-0021. Edit that source and regenerate this catalog.


Title: Transform Expression Language
Status: draft
Owners: Compiler
Diagnostic range: M21100-M21199

Proof citations in source: 15 / 15. Standalone proof verification is pending.


Definitions

TermMeaning
TotalA transform expression is total if it is guaranteed to produce a non-error value of the declared output type for every possible input value.
Transform Expression Language (TEL)The pure, total, terminating sublanguage used to express field-level data transformations in migration declarations (RFC-0016).
inputThe sole implicit binding in a transform expression; it refers to the current value of the field being transformed (the old value in the migration context).

Diagnostics

CodeSeverityDescription
M21101ErrorExternal function call in transform expression; only built-in operations are permitted.
M21102ErrorReference to a declaration other than input in transform expression; purity violation.
M21103ErrorMutation operator in transform expression; transforms must be pure.
M21104ErrorRecursive reference detected in transform expression; recursion is not permitted.
M21105ErrorLoop construct in transform expression; loops are not permitted.
M21106ErrorLambda or closure expression in transform; not part of the TEL sublanguage.
M21107ErrorNullable input used in operation without null guard; may produce null propagation.
M21108ErrorCollection operation in transform expression; collection transforms are deferred.
M21110ErrorConditional expression is missing the else branch; both branches are required for totality.
M21111ErrorInferred LUB type of conditional branches is wider than the output field type.
M21112ErrorInvalid coercion path: no coercion exists from source type to target type.
M21113ErrorInferred expression type is not assignable to the new field’s declared type.
M21114WarningDivision by a denominator that is not statically proved non-zero.

Invariants

  1. Any nullable input that is not statically guarded produces a compile error (M21107) rather than a runtime null-pointer error. (enforced by: compile-time)
  2. Every transform expression that compiles successfully is provably total: it terminates and produces a value for every possible non-error input. (enforced by: compile-time)
  3. Once RFC-0021 is ratified, M21101–M21114 replace M01603 for all transform-specific violations; M01603 is retained only for version-indeterminate malformed transforms. (enforced by: compile-time)
  4. The TEL grammar is a strict syntactic subset of RFC-0008 §11; every valid TEL expression is a valid RFC-0008 expression but not vice versa. (enforced by: compile-time)
  5. The output type of a compiled transform is statically guaranteed to satisfy the new field’s declared type, so no type error can occur at transform execution time. (enforced by: compile-time)
  6. Transform expressions have no observable side effects and are referentially transparent given the same input. (enforced by: compile-time)

Normative Statements

Statements are structured source data. Proof citations, where present, have not passed a standalone Gnomon proof gate.

Allowed and Prohibited Operations

  1. MUST — Arithmetic operands MUST be numeric types. (proof citation: rfc0021_b13_grounded; verification pending)
  2. MUST — Conditional expressions MUST include both then and else branches. (proof citation: rfc0021_b9_grounded; verification pending)

Goals

  1. MUST — Every valid transform expression MUST be provably total — the compiler MUST statically prove termination and that the output satisfies the declared output type for every input. (proof citation: rfc0021_b2_grounded; verification pending)
  2. MUST — The TEL grammar MUST be a strict subset of the RFC-0008 §11 expression syntax. (proof citation: rfc0021_b5_grounded; verification pending)
  3. MUST — The compiler MUST emit specific M21xxx diagnostic codes for each class of violation, replacing the catch-all M01603. (proof citation: rfc0021_b7_grounded; verification pending)
  4. MUST — Transform expressions MUST be pure and MUST NOT cause I/O, mutation, or observable side effects. (proof citation: rfc0021_b29_grounded; verification pending)
  5. MUST — Type inference MUST be flow-sensitive within a single expression; conditional branch types MAY be narrower than the declared field type if both branches together cover it. (proof citation: rfc0021_b23_grounded; verification pending)

Integration with RFC-0016

  1. MUST — The RFC-0016 compiler MUST recognise M21xxx codes and incorporate them into migration validation output. (proof citation: rfc0021_b19_grounded; verification pending)
  2. MUST_NOT — The deprecated (v) => expr lambda form from RFC-0016 §2.4.1 MUST NOT be used in new declarations. (proof citation: rfc0021_b21_grounded; verification pending)
  3. MUST — Tooling displaying M01603 MUST also display the deprecation notice and the superseding M21xxx code.

Totality-Checking Algorithm

  1. MUST — If input has a nullable type, the expression MUST handle the null case (e.g., via isNull guard). (proof citation: rfc0021_b25_grounded; verification pending)

Type Inference Rules

  1. MUST — Both arithmetic operands MUST be numeric (Int or Float); modulo requires both Int. (proof citation: rfc0021_b27_grounded; verification pending)
  2. MUST — Both conditional branches MUST be present; a missing else produces M21110. (proof citation: rfc0021_b15_grounded; verification pending)
  3. MUST — The compiler MUST verify a valid coercion path exists from the source type to the target type per RFC-0006. (proof citation: rfc0021_b17_grounded; verification pending)
  4. MUST — The compiler MUST verify the inferred expression type is assignable to the new field type. (proof citation: rfc0021_b0_grounded; verification pending)
  5. MUST — The conditional inferred LUB type MUST be a subtype of (or equal to) the new field type, else emit M21111. (proof citation: rfc0021_b11_grounded; verification pending)

Linked References

(no cross-RFC dependencies)