Repository navigation
fix(wasm): preserve debug module names in WABT output - #1967
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Preserve modern dylib options while requiring one encoding metadata row and retaining duplicate and multiline-output checks. Share field parsing between preservation and validation. Verify delayed dylibs through real macOS CLI/MCP workflows and refresh the high-address golden with the provider's -h -l capture. Validated 85 focused native tests, npm run check, and verify:macos-bundle on macOS arm64.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f101dc665
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const requireUniqueField = (block: string, key: string): void => { | ||
| const escaped = key.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"); | ||
| const pattern = new RegExp(`^\\s*${escaped}\\s+`, "mu"); | ||
| const pattern = new RegExp(`^\\s*${escaped}(?:\\s|$)`, "mu"); |
There was a problem hiding this comment.
Restrict bare-field matching to empty options
When otool output is malformed or truncated immediately after a required field label such as entryoff, uuid, or vmaddr, the new end-of-line alternative makes requireUniqueField count that bare label even though parseField drops it. parseOtoolLoadCommands therefore accepts the command and emits an empty entrypoint or null UUID/address rather than surfacing unreadable producer output; allow an end-of-line value only for the deliberately empty options row.
AGENTS.md reference: AGENTS.md:L23-L23
Useful? React with 👍 / 👎.
| ); | ||
| customSectionNames.push(name); | ||
| if (name === "name") { | ||
| const payloadPrefix = /^\s+"/u.exec(form.slice(nameString.end)); |
There was a problem hiding this comment.
Handle placement before decoding name payloads
For a valid module whose name custom section is not in the default trailing position, WABT can preserve that position in decoded WAT as (@custom "name" (after code) "..."). This regex only accepts whitespace followed immediately by the payload quote, so parseWabtWat throws after successful validation and inspection returns unreadable_output; consume the optional placement annotation before decoding the payload.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
#1995) * fix(native): reject required otool fields truncated before their value #1967 let requireUniqueField count a label at end of line so an empty dylib-use options row is present. That applied to every required field, so truncated output such as a bare vmaddr, vmsize, uuid or entryoff line passed the presence check while parseField dropped it, and the value silently became null. Let parseField decide which labeled line carries a value: the single matching line must parse as that field. The empty options row remains the only valueless field parseField admits. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(native): admit the empty segname of Mach-O object files MH_OBJECT files put their sections in one segment whose name is empty, and otool -l prints it as a bare segname label. Requiring a value for every scalar field rejected valid object-file output as unreadable. Let parseField admit an empty segname like the empty dylib-use options row, and keep projecting an empty or absent segment name as "unknown", as main did. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(native): admit all-NUL Mach-O section names An all-NUL section_64.sectname prints as a bare sectname label, like an empty segname. Admit it in parseField and keep projecting the empty name as "unknown", as main did. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Valid WASM modules carrying a debug module name fail
inspect_wasm_artifact/inspect-wasm-artifactafter successful WABT validation: the adapter rejects the additionalmodule 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:Both interfaces currently return
unreadable_output, reasonUnsupported 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
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 returnedunreadable_outputfor 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/-xoutput 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 upstream9eee709f.npm run verify:wasm:artifact -- --require-toolswith explicit WABT directory — 42 cases passed after integrating upstream9eee709f, 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.Compatibility, safety, and release
Review checklist
type(scope): outcome.