About

Codegen architecture

The component turns an already typed frontend model into verified in-memory JVM classfiles. Its boundary is intentionally narrow: frontend owns syntax and semantic analysis, codegen owns lowering and artifact verification, and runtime owns the methods that generated bytecode calls.

required by generated classes Typed Program plus TypeInfo VaryCodegen facade Compatibility, identity, and resource preflight Session-local bytecode lowering Collision-safe artifact store Whole-result ASM verification Immutable success or diagnostic failure Published runtime ABI
required by generated classes Typed Program plus TypeInfo VaryCodegen facade Compatibility, identity, and resource preflight Session-local bytecode lowering Collision-safe artifact store Whole-result ASM verification Immutable success or diagnostic failure Published runtime ABI

Ownership boundaries

compiler-frontend publishes parser nodes, source locations, API specifications, and type metadata. codegen depends on that model and ASM only. It does not depend on the compiler CLI, Via, SQLite, Javalin, mutation tooling, or the runtime implementation. runtime remains separate so an embedding tool can generate without initializing application services while still declaring the matching runtime when it loads or executes generated classes.

Each facade call creates one private session. Writers, declarations, local-slot state, control-flow stacks, pending synthetic methods, counters, and diagnostics never cross request boundaries. The facade is reusable; the internal session is not.

Generation passes

The generator indexes persistence and API declarations before emitting classes. It then creates declared data, repository, interface, enum, service, and JSON artifacts, materializes synthetic API shapes, emits the module class, and adds tests, lambdas, task helpers, HTTP resources, lifecycle resources, and service clients. Artifact names are checked centrally before they enter the result map.

There is no public independent codegen IR in this release candidate. The supported input is Program + TypeInfo; internal emitters and lowering models remain implementation details. Consumers must not import package-internal classes or use reflection to bypass visibility.

Verification and determinism

Preflight validates model/runtime versions, logical source identity, module identity, AST complexity, and configured budgets. After lowering, codegen checks generated byte budgets and verifies every class as one graph with ASM analysis. Only a fully verified, deterministically sorted map becomes CodegenResult.Success. Any error yields diagnostics without partial artifacts.

Build archives remove file timestamps and use reproducible entry ordering. The release gate builds and stages the component twice from clean component build directories, compares every final byte, and records the exact source revision, JDK, Gradle version, dependency locks, build task, timestamp policy, and hashes.

Generated ABI

Generated class names, runtime owners, descriptors, and HTTP or persistence boundary calls form a separate ABI from the Kotlin facade. The compatibility policy versions the frontend model and runtime ABI explicitly. API and binary snapshots protect the Kotlin facade, while canonical verifier, runtime ABI, and external-consumer tests protect generated output.

← Varyonic scripting
Codegen security →