Background
vera/codegen/api.py has grown to 2,228 lines and now mixes three distinct concerns: memory layout utilities, the public compile/execute API, and the host runtime setup. It follows the same growth pattern as codegen.py before it was split in #155.
Proposed split
vera/codegen/memory.py (~150 lines)
Extract the ADT memory layout utilities that are needed by both the compiler and the runtime:
ConstructorLayout dataclass
_wasm_type_size()
_wasm_type_align()
_align_up()
These are pure data/math utilities with no runtime dependency and are already imported by multiple codegen modules.
vera/codegen/runtime.py (~800 lines)
Extract the wasmtime execution layer:
ExecuteResult dataclass
_VeraExit exception
execute() — sets up the wasmtime Store, linker, memory, all host imports (IO, Http, Inference, Map, Set, Regex, Markdown, …)
- All
host_* functions (currently ~1,400 lines of the file)
Keep in vera/codegen/api.py (~300 lines)
CompileResult dataclass
compile() — the public compilation entry point
Acceptance criteria
- All 3,157 tests pass
mypy vera/ clean
- Public API (
from vera.codegen.api import compile, execute, CompileResult, ExecuteResult) unchanged
api.py under 400 lines after the split
Background
vera/codegen/api.pyhas grown to 2,228 lines and now mixes three distinct concerns: memory layout utilities, the public compile/execute API, and the host runtime setup. It follows the same growth pattern ascodegen.pybefore it was split in #155.Proposed split
vera/codegen/memory.py(~150 lines)Extract the ADT memory layout utilities that are needed by both the compiler and the runtime:
ConstructorLayoutdataclass_wasm_type_size()_wasm_type_align()_align_up()These are pure data/math utilities with no runtime dependency and are already imported by multiple codegen modules.
vera/codegen/runtime.py(~800 lines)Extract the wasmtime execution layer:
ExecuteResultdataclass_VeraExitexceptionexecute()— sets up the wasmtimeStore, linker, memory, all host imports (IO, Http, Inference, Map, Set, Regex, Markdown, …)host_*functions (currently ~1,400 lines of the file)Keep in
vera/codegen/api.py(~300 lines)CompileResultdataclasscompile()— the public compilation entry pointAcceptance criteria
mypy vera/cleanfrom vera.codegen.api import compile, execute, CompileResult, ExecuteResult) unchangedapi.pyunder 400 lines after the split