[PR #1967] [MERGED] fix(wasm): preserve debug module names in WABT output #4939

Closed
opened 2026-10-31 00:57:10 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1967
Author: @bugstan
Created: 10/11/2026
Status: ✅ Merged
Merged: 10/11/2026
Merged by: @morluto

Base: main ← Head: fix/wasm-debug-module-names


📝 Commits (3)

  • 3abba74 fix(wasm): preserve debug module names in WABT output
  • c96980f chore: merge upstream main for WASM verification
  • 2f101dc fix(native): accept otool dylib-use options

📊 Changes

13 files changed (+262 additions, -56 deletions)

View changed files

📝 docs/testing.md (+3 -1)
📝 docs/wasm-artifacts.md (+2 -1)
📝 scripts/verify-wasm-artifact.mjs (+27 -3)
📝 scripts/verify/apple/native-provenance.mjs (+13 -0)
📝 src/native/parsers/otool.ts (+43 -30)
📝 src/wasm/WabtArtifactProvider.ts (+3 -3)
📝 src/wasm/WabtOutput.test.ts (+24 -0)
📝 src/wasm/WabtOutput.ts (+14 -5)
📝 src/wasm/WabtWat.ts (+62 -12)
📝 tests/boundary/providers/native/nativeLoadKinds.golden.test.ts (+63 -0)
📝 tests/fixtures/native-macos/otool-high-address.md (+1 -1)
📝 tests/fixtures/native-macos/otool-high-address.txt (+3 -0)
➕ tests/fixtures/wasm/module-names.wat (+4 -0)

📄 Description

Summary

Valid WASM modules carrying a debug module name fail inspect_wasm_artifact / inspect-wasm-artifact after successful WABT validation: the adapter rejects the additional module name: <...> preamble. Accept and preserve this producer output without changing the public schema or section-range checks.

This is a newly reproduced bug, so there is no existing issue to close. It is separate from the unpadded DataCount row in #1956 / merged #1963; this PR does not change that row pattern.

Problem and expected behavior

Compile the following with WABT 1.0.42 wat2wasm --debug-names, then inspect it through the CLI or MCP:

(module $named
  (func (export "answer") (result i32) i32.const 42))

Both interfaces currently return unreadable_output, reason Unsupported WABT section header format. They should return the valid artifact Evidence, including the exact module-name preamble in headers and details.

Change and scope

WABT prints raw module names, which can contain newlines and apparent section delimiters. Its WAT identifier also replaces invalid identifier bytes, so that identifier cannot reconstruct the raw name. Reuse the existing WAT string decoder and read only module-name metadata from WABT's preserved @custom "name" payloads. Use those ordered names to frame the exact objdump preamble, including its NUL-terminated display behavior. No raw WASM parser or target mutation is introduced.

Preserve the preamble in both header and detail views. Add real CLI/MCP fixtures for compiler-generated names and custom metadata with empty, multiline, Unicode, long and NUL-containing names. Keep malformed-output and metadata-boundary refusals in the parser tests.

Contract and boundary impact

  • Semantic owner and earliest changed stage: WABT output decoding, after producer validation.
  • CLI and MCP/tool-catalog contract: unchanged inputs and schemas; formerly rejected named modules return Evidence.
  • Provider, bridge, target-format, or platform compatibility: existing WABT 1.0.42 profile; real verification on WSL/Linux x64.
  • Evidence, artifact, provenance, or reconstruction contract: preserve exact WAT, header/detail text, artifact/tool digests, section ranges and retained records.
  • Process execution, authorization, cleanup, or containment impact: none; existing owned-process and workspace lifecycle reused.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: exact-name preamble mismatches and truncated name metadata; real-WABT workflow and source-owned WAT fixture.

  • Base reproduction: on unmodified upstream 39418ea1, actual compiled CLI and fresh stdio MCP both returned unreadable_output for the source above. A following MCP ping succeeded. Official WABT validation succeeded.

  • User-visible output after the fix: valid inline Evidence; CLI/MCP values and Evidence IDs match, as do independent wasm-objdump -h / -x output and decoded WAT.

  • Remaining proof gaps: Windows/macOS WABT hosts, packaged-install verification and the full deterministic suite were not run. No native engine or target execution is involved.

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

Pinned Node 24.18.0 / npm 11.16.0; official WABT 1.0.42 Linux x64 archive SHA-256 84895407a6bbb80e918f33b16b2fb2206021c150b6bc9ff6f761263a745ab131, checked against release metadata.

  • npm run test:focused -- src/wasm/WabtOutput.test.ts src/wasm/WabtArtifactProvider.test.ts tests/boundary/mcp/wasmArtifactMcp.test.ts — 20 tests passed after integrating upstream 9eee709f.
  • npm run verify:wasm:artifact -- --require-tools with explicit WABT directory — 42 cases passed after integrating upstream 9eee709f, including its DataCount control. Inputs remained unchanged, provider workspaces were cleaned up and verified process lineage had no remaining descendants.
  • npm run check — all six tasks and architecture guards passed. Existing lint warnings remain; zero lint errors.
  • npm run docs:check — all six tasks passed.
  • git diff --check — passed.
  • Independent review of name metadata against the pinned WABT producer found no actionable medium/high issue.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: real WABT on WSL/Linux x64 only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no added authority or executable changes; raw names cannot substitute for parser delimiters, and existing malformed-output/range checks remain.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1967 **Author:** [@bugstan](https://github.com/bugstan) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/11/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/wasm-debug-module-names` --- ### 📝 Commits (3) - [`3abba74`](https://github.com/morluto/rea/commit/3abba74f030d5bf9e8c29519ce8da9fcc9cfd720) fix(wasm): preserve debug module names in WABT output - [`c96980f`](https://github.com/morluto/rea/commit/c96980f93baf6dd4227959c8d97419ab3a461fa5) chore: merge upstream main for WASM verification - [`2f101dc`](https://github.com/morluto/rea/commit/2f101dc665548fae9c57dc30255875d9133200df) fix(native): accept otool dylib-use options ### 📊 Changes **13 files changed** (+262 additions, -56 deletions) <details> <summary>View changed files</summary> 📝 `docs/testing.md` (+3 -1) 📝 `docs/wasm-artifacts.md` (+2 -1) 📝 `scripts/verify-wasm-artifact.mjs` (+27 -3) 📝 `scripts/verify/apple/native-provenance.mjs` (+13 -0) 📝 `src/native/parsers/otool.ts` (+43 -30) 📝 `src/wasm/WabtArtifactProvider.ts` (+3 -3) 📝 `src/wasm/WabtOutput.test.ts` (+24 -0) 📝 `src/wasm/WabtOutput.ts` (+14 -5) 📝 `src/wasm/WabtWat.ts` (+62 -12) 📝 `tests/boundary/providers/native/nativeLoadKinds.golden.test.ts` (+63 -0) 📝 `tests/fixtures/native-macos/otool-high-address.md` (+1 -1) 📝 `tests/fixtures/native-macos/otool-high-address.txt` (+3 -0) ➕ `tests/fixtures/wasm/module-names.wat` (+4 -0) </details> ### 📄 Description ## Summary Valid WASM modules carrying a debug module name fail `inspect_wasm_artifact` / `inspect-wasm-artifact` after successful WABT validation: the adapter rejects the additional `module name: <...>` preamble. Accept and preserve this producer output without changing the public schema or section-range checks. This is a newly reproduced bug, so there is no existing issue to close. It is separate from the unpadded DataCount row in #1956 / merged #1963; this PR does not change that row pattern. ## Problem and expected behavior Compile the following with WABT 1.0.42 `wat2wasm --debug-names`, then inspect it through the CLI or MCP: ```wat (module $named (func (export "answer") (result i32) i32.const 42)) ``` Both interfaces currently return `unreadable_output`, reason `Unsupported WABT section header format.` They should return the valid artifact Evidence, including the exact module-name preamble in headers and details. ## Change and scope WABT prints raw module names, which can contain newlines and apparent section delimiters. Its WAT identifier also replaces invalid identifier bytes, so that identifier cannot reconstruct the raw name. Reuse the existing WAT string decoder and read only module-name metadata from WABT's preserved `@custom "name"` payloads. Use those ordered names to frame the exact objdump preamble, including its NUL-terminated display behavior. No raw WASM parser or target mutation is introduced. Preserve the preamble in both header and detail views. Add real CLI/MCP fixtures for compiler-generated names and custom metadata with empty, multiline, Unicode, long and NUL-containing names. Keep malformed-output and metadata-boundary refusals in the parser tests. ## Contract and boundary impact - Semantic owner and earliest changed stage: WABT output decoding, after producer validation. - CLI and MCP/tool-catalog contract: unchanged inputs and schemas; formerly rejected named modules return Evidence. - Provider, bridge, target-format, or platform compatibility: existing WABT 1.0.42 profile; real verification on WSL/Linux x64. - Evidence, artifact, provenance, or reconstruction contract: preserve exact WAT, header/detail text, artifact/tool digests, section ranges and retained records. - Process execution, authorization, cleanup, or containment impact: none; existing owned-process and workspace lifecycle reused. - Generated metadata, package, or installation impact: none. ## Evidence and regression coverage - Tests added or updated: exact-name preamble mismatches and truncated name metadata; real-WABT workflow and source-owned WAT fixture. - Base reproduction: on unmodified upstream `39418ea1`, actual compiled CLI and fresh stdio MCP both returned `unreadable_output` for the source above. A following MCP ping succeeded. Official WABT validation succeeded. - User-visible output after the fix: valid inline Evidence; CLI/MCP values and Evidence IDs match, as do independent `wasm-objdump -h` / `-x` output and decoded WAT. - Remaining proof gaps: Windows/macOS WABT hosts, packaged-install verification and the full deterministic suite were not run. No native engine or target execution is involved. - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed Pinned Node 24.18.0 / npm 11.16.0; official WABT 1.0.42 Linux x64 archive SHA-256 `84895407a6bbb80e918f33b16b2fb2206021c150b6bc9ff6f761263a745ab131`, checked against release metadata. - `npm run test:focused -- src/wasm/WabtOutput.test.ts src/wasm/WabtArtifactProvider.test.ts tests/boundary/mcp/wasmArtifactMcp.test.ts` — 20 tests passed after integrating upstream `9eee709f`. - `npm run verify:wasm:artifact -- --require-tools` with explicit WABT directory — 42 cases passed after integrating upstream `9eee709f`, including its DataCount control. Inputs remained unchanged, provider workspaces were cleaned up and verified process lineage had no remaining descendants. - `npm run check` — all six tasks and architecture guards passed. Existing lint warnings remain; zero lint errors. - `npm run docs:check` — all six tasks passed. - `git diff --check` — passed. - Independent review of name metadata against the pinned WABT producer found no actionable medium/high issue. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: real WABT on WSL/Linux x64 only. - Package or release metadata impact: none. - Security, privacy, process, or containment review: no added authority or executable changes; raw names cannot substitute for parser delimiters, and existing malformed-output/range checks remain. ## Review checklist - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:57:10 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#4939
No description provided.