Skip to content

ADR-0203 stage 4: elided artifacts serialize + load soundly — closes D-515(1) - #140

Merged
chaploud merged 1 commit into
mainfrom
develop/aot-stage4-elision
Jul 9, 2026
Merged

ADR-0203 stage 4: elided artifacts serialize + load soundly — closes D-515(1)#140
chaploud merged 1 commit into
mainfrom
develop/aot-stage4-elision

Conversation

@chaploud

@chaploud chaploud commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

AOT-full-fidelity campaign, Phase IV stage 4 (ADR-0203 D4 / ADR-0202 D5). Guard-page-elided codegen — the default .auto mode — is now AOT-serializable end-to-end, closing D-515(1). zwasm compile's default output is now the SAME elided machine code the fresh JIT runs.

The soundness chain (each link verified + critique-proven cross-process)

  1. Producer stamps flag_bounds_elided (v0.5 header bit 2) iff the compile elided; the ElidedBoundsNotAotSerializable refusal and compileWasmForAot's forced .explicit are gone.
  2. Loader re-link re-registers per-func oob-stub trap entries against the LOADED block — linkWithThunks does this unconditionally, and oob_stub_off has ridden func_extras since stage 2.
  3. Setup binds the guarded reservation with no plain-heap fallback for a qualifying memory (allocBacking fails loudly), and qualifies() is a pure function of the module declaration — identical verdicts at compile- and load-time.
  4. Host gate: the loader explicitly REJECTS an elided artifact on a non-guarded host (ElidedArtifactNeedsGuardedHost — the ADR-0202 D5 "non-D1-host reject" clause; vacuous today since every jit_mem platform is guarded-capable, but enforced rather than left to set-inclusion coincidence).

Verification

  • New unit: an elided module serializes → deserializes → its page-straddling load guard-faults to a clean Error.Trap through the re-registered entries (expect(bounds_elided) pre-serialize proves no inline check exists, so a Trap can only arrive via the registry redirect).
  • test/aot/corpus gains oob_guard_boundary — the cross-process differential now pins artifact-OOB → clean trap on every CI run: 63/63 MATCH with elided artifacts as the default output.
  • zig build test green · fuzz-diff 0 mismatch · Rosetta x86_64-macos suite green.
  • Independent Devil's-Advocate critique (check Add first-class Windows support #8, 17/20): the invariant chain "could not be broken on any reachable host"; all three findings (missing host-reject; unpinned artifact-OOB coverage + a misattributed evidence claim; ADR overselling) fixed in-commit. The critique independently reproduced: elided .cwasm → fresh process → trap kind=oob_memory.

Bookkeeping

D-515 row: item (1) struck — item (2) (spec-assert corpus under elision) remains. ADR-0202 status note: AOT elision ENABLED, all five D5 clauses realized.

Next

Stage 5 = --cache transparent compilation cache (D-508, ADR-0203 D5) → stage V retrospective → v2.2.0 release (user-directed).

…ly (closes D-515(1))

Elided-bounds codegen is now AOT-serializable end-to-end:
- format v0.5 gains `flag_bounds_elided` (header flags bit 2; in the
  header round-trip test).
- produce: the ElidedBoundsNotAotSerializable refusal is GONE — the
  loader upholds the ADR-0202 "elided ⇒ guarded binding" invariant: the
  re-link re-registers per-func oob-stub trap entries against the LOADED
  block (linkWithThunks does this unconditionally; oob_stub_off rides
  func_extras since stage 2), setup's allocBacking binds the guarded
  reservation with NO plain-heap fallback for a qualifying memory, and
  the loader explicitly REJECTS an elided artifact on a non-guarded host
  (ElidedArtifactNeedsGuardedHost — ADR-0202 D5's "non-D1-host reject";
  vacuous today, enforced rather than left to set-inclusion coincidence).
- compileWasmForAot no longer forces `.explicit` — the default
  `zwasm compile` output is now ELIDED on qualifying memories (verified:
  header flags 0x05), the same codegen the fresh JIT runs.
- deserializer restores `bounds_elided` from the header flag.
- Unit (produce.zig): an elided module serializes, deserializes, and its
  page-straddling load GUARD-FAULTS to a clean Error.Trap through the
  re-registered entries; `expect(bounds_elided)` pre-serialize proves the
  code has no inline check, so Trap can only arrive via the registry.
- test/aot/corpus gains oob_guard_boundary ({wat,wasm}) so the
  cross-process differential pins artifact-OOB → clean trap on every run
  (63/63 MATCH).
- D-515 row: item (1) struck ((2) spec-assert corpus remains); ADR-0202
  status note updated (all five D5 clauses realized, host-reject named).

DA-critique check #8 (17/20) findings folded in: the missing non-D1-host
reject implemented; artifact-OOB coverage added to the aot corpus (the
prior evidence claim misattributed the fuzz-corpus fixture); format
round-trip test extended with the new flag; ADR wording corrected;
stale runner_test comment re-pointed. The critique independently proved
the soundness chain cross-process (elided .cwasm → fresh process →
trap kind=oob_memory).

Verified: zig build test green · test-aot-diff 63/63 MATCH with elided
artifacts as the default output · fuzz-diff 0 mismatch · Rosetta
x86_64-macos suite green.
@chaploud
chaploud merged commit 3721e3e into main Jul 9, 2026
5 checks passed
@chaploud
chaploud deleted the develop/aot-stage4-elision branch July 9, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant