1 / 10
← → step · Esc exit
Executing spec.html
Formalization's time has come
James M Snell · Dan Carney · TC39 #117
Architecture
The pipeline
Why now?
LLMs!
Immediate value
Tools for champions, reviewers & editors — usable right now
Static & Structural
Mechanical merge
Merges a proposal into spec.html · checks grammar SDOs, slots & types
Caught across #117
- Missing
BoundNamesrow onimport defer *undefined*vs.~empty~/~unused~inImmutable ArrayBuffers- Missing
[[DeferredNamespace]]inParseModule& JSON modules - Stale clause IDs, untyped built-ins & dangling intrinsics
Interactive Wasm64
Spec debugger
Step forward & back through spec.html · inspect Slots & Realm
Examples
Adding a proposal · Step 1
Write the algorithms
spec.html
§22.1.3.32 String.prototype.trim — proposal-trim-chars
<emu-clause id="sec-string.prototype.trim" type="built-in function"> <h1>String.prototype.trim ( <ins>[ _characters_ ]</ins> )</h1> <emu-alg> 1. Let _thisValue_ be the *this* value. 1. Return ? TrimString(_thisValue_, ~start+end~<ins>, _characters_</ins>). </emu-alg> </emu-clause>
Adding a proposal · Step 2
Generate the spec
lean/Ecma/Gen/S22_1_part2.lean
Before (ECMA-262)
def «String.prototype.trim» : Alg := { id := ⟨1454, 0⟩ name := "String.prototype.trim" header := { kind := .builtin, params := [], ret := none, recv := none, desc := [] } vars := #["this value", "NewTarget", "thisValue"] body := [ (.mk [] (.let_ 2 (.thisValue false))), (.mk [] (.ret (some (.q (.call (.alg ⟨1455, 0⟩) [(.var 2), (.enum 88)])))))] }
lean/Ecma/Gen/S22_1_part2.lean
After generate.py · 0 proof lines needed
def «String.prototype.trim» : Alg := { id := ⟨1454, 0⟩ name := "String.prototype.trim" header := { kind := .builtin, params := [{ x := 2, ty := none, optional := true, rest := false }], … } vars := #["this value", "NewTarget", "characters", "thisValue"] body := [ (.mk [] (.let_ 3 (.thisValue false))), (.mk [] (.ret (some (.q (.call (.alg ⟨1455, 0⟩) [(.var 3), (.enum 88), (.var 2)])))))] }
Adding a proposal · Step 3
Debug!
proposal_trim_chars.js
● Breakpoint: sec-string.prototype.trim · step 2
const path = "/__ecma-262__/".trim("/_");
// → "ecma-262"
Adding a proposal · Step 4
All 14 ECMA-262 proposals on the TC39 #117 agenda
| Stage | Proposal (TC39 #117) | spec.html | Generated Lean | Model / Host | Proofs | |
|---|---|---|---|---|---|---|
| 3 | import defer (with PR #97 cycle/TLA fix) | +723 / −109 | +283 / −122 | 0 | 0 | Debug → |
| 3 | Import Text (for Stage 4) | +39 / −4 | +26 / −15 | +4 | 0 | Debug → |
| 3 | Thenable Curtailment (PRs #22 & #26) | +157 / −23 | +80 / −25 | +2 / −1 | +1 / −1 | Debug → |
| 2.7 | Deferred Re-exports (export defer) | +2,154 / −186 | +1,330 / −289 | 0 | 0 | Debug → |
| 2.7 | JSON.parse Options (PR #27 nullPrototypeObjects) | +96 / −7 | +71 / −32 | 0 | 0 | Debug → |
| 2.7 | ESM Phase Imports (PR #65) | +1,083 / −89 | +430 / −258 | +11 / −4 | +1 / −1 | Debug → |
| 2.7 | Immutable ArrayBuffers (for Stage 3) | +366 / −206 | +223 / −151 | 0 | 0 | Debug → |
| 2 | Error code property (to Stage 2.7) | +32 / −4 | +24 / −13 | 0 | 0 | Debug → |
| 2 | Math.fusedMultiplyAdd (to Stage 2.7) | +63 | +23 / −1 | 0 | 0 | Debug → |
| 2 | Composites | +268 / −2 | +114 / −3 | 0 | 0 | Debug → |
| 1 | Cancellation: AbortController & AbortSignal (PR #35) | +790 / −14 | +281 / −33 | +4 / −1 | +2 / −1 | Debug → |
| 0 | Iterator.prototype.transfer | +83 | +40 / −18 | 0 | 0 | Debug → |
| 0 | Trim Specific Characters | +21 / −15 | +12 / −12 | 0 | 0 | Debug → |
| 0 | Bitwise counting (Math.popcount32 / Math.ctz32) | +23 | +23 / −1 | 0 | 0 | Debug → |
Where this goes
What this can deliver
-
Invariants
Module graph
[[Status]]monotonicity · §6.1.7.3 essential object invariants · immutableArrayBufferbytes never mutate -
Soundness (eventually)
Every engine fast path or shortcut produces the exact same observable result as stepping
spec.htmlline by line (Engine.implements) -
Proofs about JS libraries (eventually)
Tractable where intrinsics are frozen (
SES/ hardened realms), primordials are captured at module init, or values are immutable (Composite)