0%

ori run / ori test Backend Integration

Goal

Integrate the VM through the existing production backend boundary and CLI while preserving the pure architecture seams, one realization path, deterministic cache semantics, absolute evaluator/VM/LLVM/AOT behavior parity, and test isolation.

Implementation Sketch

  • Preserve the compiled boundary from plans/backend-boundary: CodegenBackendChoice { Llvm, Native } remains build/codegen-only. Add ExecutionBackend { Vm, Compiled(CodegenBackendChoice) } for ori run/ori test, flattened to the existing user-facing --backend=vm|llvm|native values. Do not make the VM implement CodegenBackend and do not create another identically named BackendChoice.
  • The CLI performs frontend analysis and shared executable-program realization once, then calls VmBackend. A thin adapter may route typed inputs/results only; it cannot initiate ARC/impl/derive discovery, reach backward into the compiler database, perform hidden I/O, or own VM semantics.
  • Keep const evaluation on ori_eval. Treat WASM as a compiled TargetSpec accepted only by a compiled backend; plans/native-backend owns direct module emission and its runtime/host adapter. Make the command/mode/backend/target matrix explicit and reject unsupported combinations with actionable diagnostics.
  • Start with a session-local chunk cache keyed by stable function identity plus realization/version provenance. Add Salsa persistence only after neutral ReprEvidence, the selected physical plan, and every transitive input have deterministic equality, hashing, encoding version, and invalidation tests.
  • Add ori test --backend=vm sequentially first. Enable parallel execution only after proving per-test VM stacks, runtime state, panic state, output capture, and leak accounting are isolated; include a race/stress regression.
  • Production VM selection is fail-closed: it either executes wholly in VM or returns a typed diagnostic. It never silently falls back to the evaluator or a compiled backend; const evaluation and compiled WASM are separate explicit routes.
  • Keep --dual an explicit diagnostic mode that runs the evaluator from the same frontend snapshot and VM/native backends from the same executable-program identity. Require absolute behavior parity under the frozen normalizer; --dual is never implicit production fallback.

Layer Coverage

LayerDisposition
L1N/A: backend selection adds no grammar.
L2N/A: backend selection changes no typechecking semantics.
L3N/A: backend selection changes no canonicalization semantics.
L4N/A: this section consumes the shared post-AIMS artifact without changing ARC.
L5Covered by the production VM run/test criterion.
L6Covered by the LLVM-debug selector regression criterion.
L7Covered by the LLVM-release selector regression criterion.
L8Covered by the AOT selector regression criterion.
L9Covered by the section cross-executor criterion.
L10Covered by the section leak-freedom criterion.
L11Covered by the VM spec-corpus criterion.
L12Covered by real ori run and ori test CLI criteria.

Work Items

  • Add ExecutionBackend::Vm around the existing compiled-backend selector and production --backend=vm routing over one shared realization; use a versioned session cache first, keep const evaluation on ori_eval, and route WASM only through direct compiled target selection.
  • Add sequential then isolation-proven parallel ori test --backend=vm, diagnostic --dual, selector precedence/error tests, zero-fallback routing assertions, absolute parity, and real spec-corpus CLI coverage.