Compiler IR Pipeline
The Vox compiler features a structured Intermediate Representation (IR) pipeline that enables machine-verifiable introspection of programs. This pipeline is critical for high-fidelity agentic workflows, such as the "Doubt" loop and automated resolution agents.
IR emission
The primary way to obtain a full VoxIrModule JSON bundle is:
vox check main.vox --emit-ir
This runs the full compiler frontend (lex, parse, typecheck) and writes main.vox-ir.json next to the source file.
vox build … --emit-ir writes web-ir.v1.json under the output directory containing WebIR only (frontend projection), not the full Vox bundle. See IR emission SSOT for the authoritative table.
Validation and quality gates
- Structural JSON Schema: Emitted
VoxIrModuleJSON is validated in CI againstvox-ir.schema.json(required top-level andmodulekeys; HIR bodies remain loosely typed in the schema by design). Seecrates/vox-compiler/tests/ir_emission_test.rs. - Semantic smoke: That test asserts representative
functions/server_fnsentries round-trip from a small fixture after the full frontend. - Golden
.vox: Everyexamples/golden/**/*.voxfile is parsed, lowered, WebIR-validated, and checked forlegacy_ast_nodesincrates/vox-compiler/tests/golden_vox_examples.rs(runs under the default workspacenextestCI job). Example layout + mdBook include policy is centralized inexamples/examples.ssot.v1.yamland enforced bycrates/vox-compiler/tests/examples_ssot.rs. - WebIR gates: With
VOX_WEBIR_VALIDATE=1,web_ir_lower_emitandprojection_paritytests guard the TS/TSX pipeline (see.github/workflows/ci.yml).
TOESTUB / completion-policy applies to Rust product code, not to emitted IR JSON. Do not conflate skeleton detection on crates/ with IR file validation.
Role in the AI ecosystem
The IR pipeline provides a structured target for AI agents:
- Auditing: Resolution agents can analyze the IR without re-parsing
.voxsource. - Code generation: Emitters consume HIR and/or WebIR depending on the target.
- Documentation: Prefer
{{#include}}fromexamples/golden/so snippets stay parser-verified.