CodeGen
CodeGen is the ENC instance's emit layer: it turns the protocol's checked Lean spec into every implementation that ships — byte-deterministically, with each artifact's hash pinned. The software you run is provably the design that was verified, because it was generated from it rather than written against it.
How it works
-
One source. The canonical form is
Enc.DSL— a protocol DSL induced from prose, Lean definitions, implementation observations, and witness failures by SpecGen. Humans never hand-author it. -
Fan-out emit. From that Lean, CodeGen emits multiple targets:
Target What it is Lean reference the executable referee — the spec that runs JS core / client / dataview SDK @enc-protocol/{core, client, dataview}JS node the pure-JS node implementation Rust / WASM kernel the enc-core.wasmkernel + Rust hostCloudflare Worker the production Worker source -
Byte-determinism. Re-running the emit produces zero diff; a codegen manifest pins each artifact's
sha256. Today the manifest tracks 55 generated artifacts (47 protocol / 7 platform / 1 operational). -
Idempotence gate. Any drift between the committed artifact and a fresh emit fails CI — handwritten protocol residue is a release problem unless it is explicitly classified and accepted.
What makes it sound
Because all targets are emitted from the same Lean, they are byte-identical where it counts: the JS node, the WASM kernel, and the Lean reference answer the same wire request the same way (cross-implementation parity is asserted byte-equally — see Run a Node). There is no spec↔implementation gap to drift, because there is only one source and the rest is a checked projection of it.
Spec layers
ENC's spec is layered so each layer depends only on the ones below it:
kernel → node → app → deployment, with appgen depending on kernel + node + app. Changing the
kernel changes which histories, states, and proofs are valid; everything above is generated to
match.
See also
- SpecGen — the framework CodeGen is an instance of
- Its outputs: Protocol Spec · SDK Reference · Plugin SDKs
- Pipeline overview