Skip to main content

Module codegen

Module codegen 

Source
Expand description

Code generation for WASM invariant modules from Gherkin predicates.

Converts parsed Gherkin predicates and scenario metadata into Rust source code for WASM modules conforming to the Converge WASM ABI v1.

§Pipeline

ScenarioMeta + JTBDMetadata + Vec<Predicate>
    │
    ▼
ManifestBuilder.build() → manifest JSON string
    │
    ▼
generate_invariant_module() → Rust source code string
    │
    ▼
[Task #5: compilation] → .wasm bytes

§Manifest Builder

ManifestBuilder assembles a WasmManifest-compatible JSON string from Gherkin scenario tags (ScenarioMeta), JTBD metadata, and parsed predicates. The JSON conforms to the converge-runtime WasmManifest schema without requiring a direct crate dependency.

§Code Generator

generate_invariant_module produces a complete Rust source file that exports the WASM ABI v1 functions (converge_abi_version, converge_manifest, alloc, dealloc, check_invariant). Each Predicate is compiled to a Rust check expression inside the generated check() function.

Structs§

CodegenConfig
Configuration for code generation.
ManifestBuilder
Builder for constructing a WasmManifest-compatible JSON string.

Enums§

ManifestError
Error during manifest construction.

Functions§

generate_invariant_module
Generate a complete Rust source file for a WASM invariant module.