fix(wrap): route lift lookup via export name + propagate string encoding (LS-A-16)#155
fix(wrap): route lift lookup via export name + propagate string encoding (LS-A-16)#155avrabe wants to merge 1 commit into
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 |
|
Mythos delta-pass evidence Tier-5 file touched: Fresh agent ran |
7c2c4ca to
c4509ba
Compare
|
Fuzz failure investigation + fix (amend)
The fuzz target catches exactly this: feed random bytes, if Fix amended into this PR ( Updated test 218 lib tests pass; clippy clean. |
317c291 to
0ea2736
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>
0ea2736 to
92fdf71
Compare
Fourth fix from the post-v0.8.0 Mythos delta-pass sweep.
component_wrap.rs::find_lift_type_for_interface_functook(iface, func)parameters but never compared them;let _ = target_export_nameat the bottom suppressed the unused warning. Every export got the first lift's type and options.The bugs
find_lift_type_for_interface_funclines 2479-2530string_encodinghardcoded UTF-8 regardless of source declarationWasm validator accepts the wrapper output because the lift still type-checks against the wrapper interface. Downstream wasmtime transcodes against the wrong encoding → mojibake / truncated strings with no trap. Same family as the wasmtime 2026-04-09 CM-transcoding CVE wave.
Fix
find_lift_type_for_interface_funcmatches export names against the wit-bindgen{iface}#{func}convention; resolves throughcomponent_func_defsto the right canon Lift entry.source_string_encoding_optionhelper maps the sourceCanonStringEncodingto the correspondingCanonicalOption.Noneinstead of guessing.Tests (4 new)
ls_a_16_find_lift_distinguishes_between_two_exports— multi-lift correctnessls_a_16_find_lift_single_lift_fallback_still_works— regression for simple fixturesls_a_16_find_lift_two_lifts_without_matching_export_returns_none— the dangerous "first lift wins" guess is gonels_a_16_source_string_encoding_option_round_trips— encoding mappingDeferred to follow-up (same UCA-W-2)
Memory(0)hardcoding in multi-memory mode (uncertain reachability sinceassemble_componentis called with a singlesource)Test plan
cargo test -p meld-core --lib— 212 pass (208 prior + 4 new)cargo clippy --all-targets -- -D warnings— cleancargo fmt --check— cleanRefs