fix(wrap): route lift lookup via export name + propagate string encoding (LS-A-16)#159
Merged
Merged
Conversation
Mythos delta-pass requiredThis PR modifies one or more Tier-5 source files (per Before merge, run the Mythos discover protocol on the
Why this gate exists: LS-A-10 The gate check on this PR will pass once the label is |
dd24c2c to
258c689
Compare
…ing (LS-A-16)
`find_lift_type_for_interface_func` took (iface, func) parameters but
never compared them — `let _ = target_export_name` suppressed the unused
warning. For a multi-export component, every export silently received
the first lift's type and canonical options (including string_encoding).
A guest compiled with `--string-encoding=utf16` had every export
downgraded to UTF-8 because the encoding was also hardcoded in emission
paths. Wasm validator accepts the output; downstream wasmtime transcodes
against the wrong encoding, producing mojibake / truncated strings with
no trap. Same family as the wasmtime 2026-04-09 CM-transcoding CVE wave.
Fix:
- find_lift_type_for_interface_func matches export names against the
wit-bindgen `{iface}#{func}` convention; resolves through
component_func_defs to the right canon Lift entry.
- New `source_string_encoding_option` helper maps the source
CanonStringEncoding to the wasm_encoder::CanonicalOption.
- Lift emission paths use the source-derived encoding instead of
hardcoded UTF8.
- Single-lift fallback retained for simple-fixture compatibility but
only when exactly one lift exists; multi-lift without matching
export now returns None instead of guessing.
Tests (4 new):
- ls_a_16_find_lift_distinguishes_between_two_exports
- ls_a_16_find_lift_single_lift_fallback_still_works
- ls_a_16_find_lift_two_lifts_without_matching_export_returns_none
- ls_a_16_source_string_encoding_option_round_trips
Deferred to a follow-up under the same UCA-W-2:
- Lower-side encoding propagation (canon.lower options threaded from
source canon.lower entries)
- Lift-side Memory(0) hardcoding in multi-memory mode (uncertain
reachability since assemble_component is called with a single source)
LS-A-16 added to safety/stpa/loss-scenarios.yaml. Discovered by the
post-v0.8.0 Mythos delta-pass on component_wrap.rs.
Refs: LS-A-16 (UCA-W-2, H-1, H-4)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
258c689 to
2f60989
Compare
avrabe
added a commit
that referenced
this pull request
May 16, 2026
Cuts v0.8.1 carrying the post-v0.8.0 Mythos delta-pass sweep on the 8 Tier-5 files unscanned at v0.8.0 cut time (per #151 gate scope). Ten loss scenarios closed across 6 fix PRs, all of them silent (no host trap, no validator rejection — wrong-by-construction outputs): - LS-A-11 (#152) — extended-const init/offset truncation in segments and global initializers. Folds (i32.const x)(i32.const y) i32.add instead of dropping operands after the first. - LS-A-12/13/14 (#153) — p3-async detection bugs: mixed-mode stackful mis-classification, stream-write over-count silently classified as Complete, future<stream<...>> mis-routed to stream_types via substring match. - LS-A-15 (#154) — HashMap.iter().find non-determinism at three sites; realloc and resource-rep/-new fallbacks now sort candidate keys. - LS-A-16 (#159) — wrapper dropped source canonical options for lifts; every export silently received the first lift's string encoding. - LS-A-17/18/19 (#156) — resource_graph definer purge and terminal- exporter pass ignored the iface dimension; merger dedup used ends_with(rn) where exact match was required (float / bigfloat suffix collision). - LS-A-20 (#157) — flags<N> canonical ABI silently modeled as Record<N x Bool>; new ComponentValType::Flags variant with explicit arms in every canonical-ABI helper. Also under Added: the Mythos delta-pass CI gate workflow (#151) that made this sweep observable at PR time, and the stackful async-lift cross-memory (ptr, len) return path that v0.8.0 had errored out on. Co-authored-by: Claude Opus 4.7 <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.
Third try at LS-A-16 — the prior branches (
fix/component-wrap-option-dropsfrom PRs #155 and #158) got stuck behind a GitHub-Actions glitch where workflow_runs never triggered on synchronize events. Cherry-picked the fix onto this fresh branch name; same code.Summary
Two defects in
meld-core/src/component_wrap.rssurfaced by the post-v0.8.0 Mythos sweep:find_lift_type_for_interface_functook (iface, func) parameters but never compared them. Multi-export components got every export's lift mapped to the first lift's type+options.string_encoding— UTF-16 lifts silently downgraded.Fix
{iface}#{func}export-name convention to find the right lift.source_string_encoding_optionhelper maps source CanonStringEncoding to the corresponding CanonicalOption.log::warn— preservesfuzz_fusion_roundtripsafety for malformed inputs.Tests (4 new)
ls_a_16_find_lift_distinguishes_between_two_exportsls_a_16_find_lift_single_lift_fallback_still_worksls_a_16_find_lift_two_lifts_without_matching_export_fuzz_safe_fallbackls_a_16_source_string_encoding_option_round_tripsRefs
🤖 Generated with Claude Code