Native/JIT Shared-Input Contract
Goal
Specify — and do not yet freeze — the pure semantic data seam shared by VM tier-0 and the future ori_backend compiled/JIT tier, without requiring bytecode, BIR/MIR, frames, or encodings to be identical.
The seam is asymmetric today and one endpoint does not exist. ori_vm::compile::compile(&ExecutableProgram) takes the closed post-AIMS artifact as its sole input; the compiled tier’s declared seam ori_codegen::CodegenInput carries frontend inputs (CanonResult, TypeCheckResult, Pool) and its own module doc gates widening on types absent from the workspace. ori_backend and ori_engine are unbuilt. A neutrality contract authored against one live consumer is shaped by that consumer, so this section produces a specification with a deferred freeze; the freeze happens when a second consumer exists.
Sequencing — this section executes third, not first
s-ba8f2041(executable-program-contract) owns the artifact, the purity contract, the anti-fork test overori_llvmandori_vmalike, and the backend-neutral naming freeze. Cite it; never re-specify it.s-429b48fe(production-eval-architecture-contract) owns the name-freeze and statesVmLayoutPlan/CompiledLayoutPlan(TargetSpec)have zero definitions in tree. Its “name-freeze precedes every other item” applies transitively here.repr-opt#13ownsReprEvidence/VmLayoutPlan/CompiledLayoutPlancoinage. The adoption-vs-coinage decision across these three plans is a prerequisite of this section, not a detail inside it.s-c22d62a9creates the VM production entry point every parity claim here presupposes.s-4b00387eowns the parity harness, the leak gate, and the regression baseline.
Implementation Sketch
- Adopt the frozen naming; author no contract text against types absent from the workspace. Seven of the twelve contract names this section once wrote as extant resolve to zero definitions.
- Subtraction precedes addition: remove the
repr_plan: ReprPlanneutrality leak from the shared artifact before adding any compiled-tier field to it. LLVM reads it in production; the VM reads it zero times in production and fabricates a dummy in test fixtures only. A shared-carrier field one consumer must fabricate is the liveLEAK:backend-ownership-calculus-forkinstance. - Map onto
s-ba8f2041’s shippedExecutableProgramfamilies — identity/provenance, callable inventory, ownership/drop, runtime-call descriptors — rather than re-specifying the artifact it owns. - Do not route the seam through
realize_closed_program: it returnsArcPipelineBatchOutcomeand is not the artifact producer. The soleExecutableProgram::validateedge isoric::realization::program::realize_arc_program. - Keep VM
VmCallSigand compiledFunctionAbidistinct, and adopt the VM’s already-coined vocabulary rather than duplicating it:PhysicalVmPlanis the live VM layout plan;VmRetainPlan/VmCalleeOwnerDemandare the live VM ownership projection. Coining a second name for either is a naming fork, not a contract. - Each backend may lower differently; neither may add semantic discovery or reclassify AIMS ownership policy. The graph finds no convergence between the VM lowerer and the LLVM emitter, so the shared abstraction must be authored, not extracted.
- Name the oracle for disagreement: the evaluator is the representation-abstract behavioral oracle. A third executor entering a harness that already carries open two-way parity breaks will surface them as VM-vs-X mismatches; a three-way disagreement resolves to the evaluator.
- Coordinate with native-backend architecture/BIR work (
s-4fa1f7d2,s-4148408d) andnative-backend#s-3caa36e9(whereori_backendfirst becomes real) before freezing either side. - Any change altering
ExecutableProgram’s shape budgets theori_llvm::codegen::arc_emittermodule family andori_arc::irinto its change-set; that family is the historical co-change blast radius of the freeze/VM-compile surface.
Evidence caveats carried into this section’s claims
- The co-change blast radius above is directional, not a current count: those edges predate the current code import.
- “No convergence between the VM lowerer and the LLVM emitter” is a WEAK negative — the sibling-divergence nominations are pre-import. Read both endpoint sources before relying on it to justify authoring rather than extracting the shared abstraction.
- Module-boundary evidence for this seam is dark this run: the derived community bundle has not consumed the current import and returns no assignment for these symbols.
- Cross-repo semantic search cannot reach the ingested VM prior-art corpus (those repos are symbol-indexed but not embedded), so the prior-art path into them is symbol-name search only.
- Absence of a bug cluster for this terrain is absence of evidence — the code is new — never evidence of absence.
Ownership boundary — ori_engine
- Put the production coordinator in a narrow
ori_enginelayer above both executors; treat the name as a placeholder and preserve the boundary. - Give it tiering policy, immutable profile snapshots, code-memory lifetime, safepoint transitions, and tier counters — and split those responsibilities rather than landing one type that owns policy AND lifetime AND transitions AND counters.
- Enforce safepoint and tier-entry ordering in the type system, not by convention; convention-enforced ordering is temporal coupling.
- Make
ori_vmexpose typed hot-region/state snapshots and checked resume points. Makeori_backendcompile explicit artifacts purely into an ownedJitArtifact. - Forbid either backend depending on the other or on
ori_engine; pin the dependency direction that already holds, first and independently. - Let
oricselect interpreter-only versus tiered execution and construct the engine; keep hot-loop semantics outside the driver.
Observability substrate — absent, and a prerequisite
ori_vmcarries zeroORI_*seams: no tracing target, no dump flag, no ablation toggle. Tier-transition counters, deopt counts, and state-map rejections have nowhere to surface until one is created.diagnostics/bytecode-verify.shdoes not exist;dual-exec-verify.shis two-way (interpreter vs LLVM) with no VM leg.- Any tracing target this seam introduces is declared in the central tracing registry (
COMPILER:trace-target-central-registry); anyORI_DISABLE_*/ORI_FORCE_*tier toggle carries a test asserting its documented bisection effect (COMPILER:ablation-toggle-untested).
Prototype Tiering Matrix
- Compare static typed specialization/quickening, generated handlers, method JIT, region/loop JIT, trace JIT, and
ori_backendreuse as competing measured variants. - Run every variant against the same interpreter-only parent. Measure combinations independently; never presume additive gains.
- Record warmup, compilation latency, steady-state time, code size, memory, tier entries, bailouts/deopts, and parity.
- Tier input is explicit immutable data:
ExecutableProgram,VerifiedProgram/region identity, proved type/repr/ownership facts, profile snapshot, and the adopted target-spec / compiled-layout carriers. - Tier output is an owned artifact plus checked VM/compiled state maps.
- Forbid compiler databases, ambient runtime state, fallback callbacks, and process-global mutable profiles at the seam.
- Disable the seam in interpreter-only benchmarks; label every transition in tiered benchmarks.
- Materialize and validate a bijective OSR/deoptimization map for every live register, local aggregate/iterator/heap handle, ownership obligation, panic continuation, source location, and return continuation at each entry/exit.
- Reject tier entry on a missing or ambiguous mapping; never reconstruct semantics ad hoc. The accepted map is a refined type carrying its proof, not a
bool/Result<()>verdict handing the raw frame downstream, and no incomplete-mapping case falls through silently. - Allow LLVM JIT as a prototype comparator; keep retained production tier compilation in
ori_backend. - Forbid
ori_vmdependencies on compiled backends and hidden compiled fallback for unsupported VM execution.
Ori-Original Hypothesis: Verified Tracelets
- Treat verified tracelets as a prototype hypothesis, not an adopted design. Preserve ordinary verified bytecode as the complete semantic expansion and the deopt target; a failed optimization degrades to a no-op, never a crash.
- Let a pure optimizer describe
RegionPlanover post-AIMS logical identities — entry PC, covered expansion PCs/hash, live-ins/outs, normal/exceptional exits, source/effect order, runtime calls, ownership/RC delta, resource accounting, and exact state maps. - Accept the plan only when every fact mechanically corresponds to the baseline expansion.
- State the map over logical AIMS event identities rather than physical slots, so one map validates against the VM’s physical projection and the compiled layout plan independently. The ownership-restoration term is what makes this stronger than the external prior art, which restores interpreter stack slots and explicitly excludes ownership/GC integration from its theorems.
Three constraints the prototype carries as falsifiable kill-criteria:
- A region may not span an unresolved sharing observation. Restoring an in-flight COW mutation requires knowing which branch the physical projection took — an outcome a logical-only map cannot express. This narrows tracelet coverage, and the perf case must survive the narrowing.
- Map preservation is a mechanically checked post-condition of every region rewrite, not an authoring convention. Snapshot maintenance under optimizer passes is where deopt bugs live in every surveyed system.
- The contract is specified now and frozen only when a second consumer exists; neutrality is unfalsifiable while
ori_backendis absent.
Measure three interchangeable implementations behind the same accepted plan:
- a portable Rust tracelet that removes per-op dispatch while retaining checked semantic operations;
- an AIMS-guided quickened tracelet that consumes frozen quickening-eligibility and ownership facts, guards only their declared runtime preconditions at entry, and removes redundant COW/RC checks within the region; guard failure dequickens to baseline and never reclassifies AIMS policy;
- a native region body produced by a JIT candidate and entered/exited through the identical state maps.
- Hypothesize one proof-carrying region contract can unify superinstructions, quickening, OSR/deoptimization, and JIT without separate semantic engines.
- Exploit Ori facts dynamic VMs reconstruct: closed call targets, static types/reprs, post-AIMS ownership, and effects. Do not import the compensation machinery other systems built for static facts they lack.
- Prove any ownership-restoration claim in the compiled Lean before implementing it; the ownership-on-deopt obligation is the one thing the external literature does not cover.
- Reject the hypothesis when proof/metadata cost, optimizer fragility, parity surface, portability, or macro performance loses to separate mechanisms.
- Include numeric loops, list transform/update, reductions, calls, panic edges, and RC/COW aliasing. Execute each retained expansion as the optimized cell’s oracle.
- Benchmark combined tracelet/quickening/JIT variants against every individual parent. Require multi-program wins with absolute parity before changing production architecture.
- Land no
RegionPlan/ state-map / adapter machinery in production before a measured variant earns it; this work is prototype-gated and must never bind production.
Layer Coverage
Backend-layer dispositions are stated against the terrain rather than assumed. ori_vm is a [dev-dependencies] entry of oric and CodegenBackendChoice has one variant, so the VM has no production entry point; an LLVM-only parity run never covers a VM-affecting change.
| Layer | Disposition |
|---|---|
| L1 | N/A: no grammar changes. |
| L2 | N/A: no typechecking changes. |
| L3 | N/A: no canonicalization changes. |
| L4 | Covered by the shared artifact/ownership-provenance criterion. |
| L5 | Covered by the VM shared-input conformance criterion, with the evaluator as the oracle a three-way disagreement resolves to. |
| L6 | Covered for the LLVM leg by the debug shared-input conformance criterion. The VM leg is harness-only until s-c22d62a9 lands ori run --backend=vm; it is not claimed as production-path coverage here. |
| L7 | Covered for the LLVM leg by the release shared-input conformance criterion. Same VM-leg limitation as L6. |
| L8 | Covered for LLVM AOT. The ori_backend leg is unclaimable until native-backend#s-3caa36e9 creates the crate. |
| L9 | Requires a VM leg in the parity harness. No such leg exists: dual-exec-verify.sh is interpreter-vs-LLVM only and diagnostics/bytecode-verify.sh is absent. Citing an LLVM-only run as L9 evidence for a VM-affecting change is the LAYER_GAP:L9-cross-executor-parity this section must not commit; the criterion is owned with s-4b00387e and creates the missing leg. |
| L10 | Requires the same VM leg; leak-freedom is asserted per affected executor, not inferred from the LLVM leg. Owned with s-4b00387e. |
| L11 | Covered by cross-backend seam fixtures riding the real realize_arc_program output, never a hand-built ExecutableProgramParts the production producer never emits. |
| L12 | N/A: this section defines an internal future-tier contract and adds no user-facing JIT entry point. The VM half additionally has no production entry point today, so no production-path claim is made. |
Unpinned surfaces the conformance work must close
bind_executable_program— the compiled tier’s entire consumption of the shared artifact — has zero direct test callers, and it is the consumer that reads the leakedrepr_plan. The first pin here is negative: an artifact whose compiled-layout carrier is absent or neutral must still bind on the LLVM side.- The VM’s physical-plan validator family has zero direct test callers.
- The hottest symbol in the terrain (
program_freeze::validate) has zero direct test callers while its public wrapper carries the pins; the pins sit on the facade and the churn sits on the implementation.
Work Items
- Adopt (never invent) the
TargetSpec/CompiledLayoutPlan/VmLayoutPlan/ReprEvidencenaming frozen bys-429b48fe’s architecture decision record andrepr-opt#13’s coinage; do not author these names independently. Before adding any compiled-tier field to the sharedExecutableProgram, remove the existingrepr_plan: ReprPlanneutrality leak (source-verified: LLVM-only consumer, 19 production reads inori_llvm/src, zero inori_vmproduction code) by scoping it to the compiled-layout carrier those owners define — subtraction precedes addition. Then document canonical executable-program identity/provenance, operation correspondence, ownership trace, representation facts, callable inventory, and runtime-call contracts as a mapping ontos-ba8f2041’s already-shippedExecutableProgramfamilies (identity/provenance, callable inventory, ownership/drop, runtime-call descriptors), never re-specifying the artifacts-ba8f2041owns. Sequence this work afters-ba8f2041closes the artifact ands-429b48fe/repr-opt#13land the naming freeze; do not author contract text against types absent from the workspace. - Cite (never re-declare)
s-ba8f2041’s anti-fork test ands-4b00387e’s absolute-parity / leak-freedom criteria rather than re-authoring them. Add pure-seam conformance tests provingori_vmconsumes the sharedExecutableProgramfaithfully today; extend the same conformance-test class to the compiledori_backendlowerer only oncenative-backend#s-3caa36e9lands that crate — sequence theori_backendleg on that landing rather than asserting it against a nonexistent consumer now. Freeze theori_engineproduction-coordinator ownership boundary (tiering policy, immutable profile snapshots, code-memory lifetime, safepoint transitions, tier counters) as a narrow layer above both executors, with an explicit dependency-direction test forbidding either backend from depending on the other or onori_engine. Coordinate the boundary’s shape with native-backend architecture/BIR sections (s-4fa1f7d2,s-4148408d) before freezing it. - Prototype the Verified-Tracelets hypothesis as its own tracked deliverable (currently described only in section prose with no owning work item): define a proof-carrying
RegionPlanover post-AIMSArcVarIdidentities (entry PC, covered PCs, live-ins/outs, normal/exceptional exits, ownership/RC delta, exact state maps), owned by neither the VM nor the compiled tier; measure three interchangeable implementations (portable-Rust tracelet, AIMS-guided quickened tracelet, native JIT region) against the same interpreter-only parent and against each other. Carry the three constraints external prior-art triangulation (OSR-Distilled PLDI’18, sourir/POPL’21, the deopt-maintenance critique) established as load-bearing and that the section’s current prose omits: (i) a region may not span an unresolved sharing observation, (ii) map-preservation is a mechanically checked post-condition of every region rewrite, not an authoring convention, (iii) bijective OSR/deoptimization state maps reject tier entry on any missing or ambiguous mapping rather than reconstructing semantics ad hoc. Promote no mechanism without multi-program wins and absolute evaluator/VM/LLVM/AOT parity; this work is prototype-gated per the plan’s own north-star gate 7 and must never bind production.
Intel dossier — pointer and tier disposition
Dossier: jit-handoff-contract--s-1fd9d2db.intel.md (this section’s content/intel/ sidecar)
Read that dossier from line 1 through EOF before acting on this section. This block is a pointer and an audit record, never a substitute: not the BLUF, not a summary, not selected tiers.
| Dossier tier | Title | Lines | Disposition | Where / why |
|---|---|---|---|---|
| 0 | 0. Bottom line up front | 39 | integrated | ## Goal (asymmetric seam, absent endpoint, specify-not-freeze) + ## Sequencing — this section executes third, not first |
| 1 | 1. The target, verbatim | 29 | integrated | ## Goal + ## Layer Coverage (L12 disposition retained with its reason, plus the VM no-production-entry-point qualifier) |
| 2 | 2. Terrain — what the section names, and whether it exists | 63 | integrated | ## Implementation Sketch (adopt the frozen naming; author no text against absent types; adopt the VM’s already-coined PhysicalVmPlan / VmRetainPlan vocabulary rather than duplicating it) |
| 3 | 3. Code-graph recon | 145 | integrated | ## Goal (VM-in-artifact vs LLVM-in-frontend asymmetry) + ## Implementation Sketch (repr_plan subtraction-first; realize_closed_program is not the producer; arc_emitter co-change budget) + ## Unpinned surfaces the conformance work must close |
| 3D | 3D. Diagnostic / observability surface | 24 | integrated | ## Observability substrate — absent, and a prerequisite (new heading: zero ORI_* seams in ori_vm, absent bytecode-verify.sh, two-way-only dual-exec-verify, tracing-registry and ablation-toggle obligations) |
| 3H | 3H. Hygiene constraints the recommended design inherits | 26 | integrated | ## Ownership boundary — ori_engine (responsibility split + type-system-enforced ordering) + ## Prototype Tiering Matrix (refined-type state map, no silent fallthrough) + ## Layer Coverage (L6/L7/L8/L9/L10 corrected) + L11 (real realize_arc_program output, not hand-built parts) |
| 4 | 4. Cluster — the plan family this section sits in | 47 | integrated | ## Sequencing — this section executes third, not first (s-ba8f2041, s-429b48fe, repr-opt#13, s-c22d62a9, s-4b00387e) + ## Implementation Sketch (evaluator as the three-way disagreement oracle) |
| 5 | 5. Conformance audit — MISSING_ABSTRACTION / SIBLING_DIVERGENCE | 24 | integrated | ## Implementation Sketch (no convergence between the lowerers, so the shared abstraction is authored not extracted) + ## Evidence caveats carried into this section’s claims (weak-negative qualifier) |
| 6 | 6. Plan ownership + the dedup verdict | 25 | integrated | ## Sequencing — this section executes third, not first (cite s-ba8f2041’s purity contract / anti-fork test / naming freeze and s-4b00387e’s parity+leak criteria rather than re-owning them) + ## Implementation Sketch (map onto shipped families, never re-specify the artifact) |
| 7 | 7. Prior art | 81 | integrated | ## Ori-Original Hypothesis: Verified Tracelets (baseline as oracle and failed-optimization-is-a-no-op; map over logical AIMS identities; the three falsifiable kill-criteria — no region spanning an unresolved sharing observation, mechanically checked map-preservation, specify-now-freeze-later; prove ownership-restoration in the compiled Lean first; do not import compensation machinery for static facts Ori already has) |
| 8 | 8. Sentiment | 7 | not_applicable | The sentiment tier is structurally unavailable rather than empty: the ingested VM prior-art repos carry no issue corpus (issues: 0 for all six) and the issue-bearing repos have no tiered-execution terrain to sample. It yields no constraint, verdict, or finding that could change any of this section’s contracts, ownership boundaries, layer dispositions, or prototype gates. |
| 9 | 9. Declared coverage gaps | 21 | integrated | ## Evidence caveats carried into this section’s claims (new heading: co-change directional-not-current, weak sibling-divergence negative, dark community bundle, prior-art corpus unreachable by semantic search, absence-of-bug-cluster is absence of evidence) |
| 10 | 10. Recon entry points — the ordered read path | 25 | not_applicable | Tier 10 prescribes the ORDER a worker reads existing artifacts (sibling sections, then source files, then external prior art, then the Lean corpus). Its substantive content is already integrated through the tiers it points at — sequencing into ## Sequencing (tier 4/6), the repr_plan and producer facts into ## Implementation Sketch (tier 3), the prior-art constraints into ## Ori-Original Hypothesis (tier 7). It imposes no additional contract, constraint, or disposition on the section’s own headings; duplicating a read path into the section body would restate the dossier rather than answer to it. |