fix: multi-memory WASI import lowering and adapter type fixes#20
Merged
Conversation
Parser: handle Enum/Primitive/Flags in type definition conversion so pointer_pair_positions are computed correctly for functions using type aliases (e.g. list-typedef = string). Add ReturnAreaSlot struct that computes byte_offset/byte_size from canonical ABI layout instead of using flat i32 sizes, fixing retptr copy for variant types with f64/i64 payloads. Resolver: thread return_area_slots through AdapterRequirements. Adapter: rewrite Phase 3/4/5 retptr handling to iterate return_area_slots with correctly-sized load/store operations. Phase 1b/5b conditional copy uses discriminant checks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add hazards H-8 (P2 wrapping), H-9 (conditional pointer), H-10 (import dedup type safety), H-3.5 (start function remap), H-4.5 (retptr variant layout). Add CTRL-WRAPPER controller with UCAs UCA-W-1 through UCA-W-3. Add 11 new UCAs, 4 loss scenarios, 13 controller constraints, and safety requirements SR-21 through SR-26. Update traceability matrix with verification status and gaps GAP-4 through GAP-6. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Root cause: component_wrap.rs hardcoded CanonicalOption::Memory(0) for all WASI imports. In multi-memory mode, code from component N uses memory N but the lowered WASI function wrote to memory 0, causing "pointer out of bounds" traps. Merger: add import_memory_indices and import_realloc_indices metadata. Use component-aware dedup key (module, field, Option<comp_idx>) so multi-memory mode preserves separate import slots per component. Suffix field names with $N for duplicate imports. Export per-component cabi_realloc$N. Wrapper: multi-memory stubs module with all memories. Convert ALL memories to imports from meld:shim. Per-import Memory(N)/Realloc(N) in canon lower using merger metadata. Strip $N suffixes in import resolution. Fix core memory index calculation (per-kind index spaces, not global). Promote flavorful runtime test from graceful degradation to hard assertion — all 8 wit-bindgen fixture runtime tests now pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ReturnAreaSlotfor canonical ABI-correct byte-level retptr copy instead of fixed 4-byte i32 slots.component_wrap.rshardcodingCanonicalOption::Memory(0)for all WASI imports. In multi-memory mode, each component's WASI calls now use the correct memory andcabi_realloc. Merger tracks per-import metadata; wrapper uses per-componentMemory(N)/Realloc(N)in canon lower.All 8 wit-bindgen fixture runtime tests pass, including flavorful (promoted from graceful degradation to hard assertion).
Test plan
cargo test --package meld-core)cargo clippy --all-targetscleanNonecomponent dimension)🤖 Generated with Claude Code