ADR-0001: Canonical Typed Core
Status: accepted
Date: 2026-07-25
Context
The current surface AST interpreter is coupled to dynamic Rust Value, Rc,
RefCell, and host environments. Futamura specialization needs a smaller,
typed, stable semantics that is independent of both surface syntax and machine
lowering.
Options considered
| Option | Benefit | Cost |
|---|---|---|
| Surface AST as canonical | Reuses current interpreter | Large, dynamic, host-coupled |
| SSA as canonical | Optimizer-ready | Machine-oriented; difficult definitional semantics |
| Typed call-by-value ANF Core | Small, explicit, formalizable | Requires elaborator and new interpreter |
Decision
Adopt Core-N0, a typed call-by-value ANF language with explicit evaluation order, effects, logical regions, identity, and mutation.
Core-N0 has let, if, case, calls, tail recursion, perform, handle, and
return. It has no phi nodes, dominance, ABI, register, or physical address.
SSA remains a lower optimization representation.
Rationale
- The specializer handles a smaller language.
- Surface evolution cannot silently change canonical semantics.
- Translation validation has a precise source language.
- The Core interpreter can be formalized and generated against.
Trade-offs
- A second interpreter and elaboration path must be built.
- Existing AST/VM behavior requires explicit migration and parity tests.
- Some surface features remain outside early Core subsets.
Consequences
Positive: one semantic spine serves P1/P2, checking, proof, and lowering.
Negative: Stage 1 adds foundational work before new surface features.
Mitigation: implement one lighthouse subset and fail closed outside it.
Revisit trigger
Revisit only if Core-N0 cannot express a required observable semantic without importing machine concepts or if formalization exposes an inconsistency.