Skip to content

fix(wasm): preserve original glue source locations - #2114

Merged
morluto merged 13 commits into
morluto:mainfrom
1052326311:fix/wasm-glue-source-locations
Oct 13, 2026
Merged

morluto merged 13 commits into
morluto:mainfrom
1052326311:fix/wasm-glue-source-locations

Conversation

@1052326311

@1052326311 1052326311 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Preserve original JavaScript source locations when inspecting BOM-prefixed WASM glue files. inspect-wasm-artifact / inspect_wasm_artifact previously reported first-line literal columns one character too early, even though their artifact hash and byte count described the original file.

Problem and expected behavior

For \uFEFFfetch("./module.wasm");, the string literal starts at zero-based column 7. The provider's default UTF-8 decoder removed U+FEFF before Babel parsed the source, so Evidence reported column 6. Locations must refer to the same original source whose digest is recorded. Newlines must reset columns normally; adding a downstream offset would incorrectly move later lines.

This was found by tracing source decoding into glue reference evidence; no existing issue is linked. This is distinct from #2102, which handles WABT binary custom-section names: this change fixes JavaScript file decoding and source coordinates, with no changes to WAT/binary name parsing.

Change and scope

Preserve U+FEFF in the existing fatal UTF-8 decoder at WabtArtifactProvider.inspect. Babel already accepts it as JavaScript whitespace and computes the original positions. For BOM-prefixed hashbangs, associateWasmGlue removes only the BOM before parsing so Babel can recognize the interpreter directive; reference line/column coordinates remain unchanged because executable source follows the hashbang line. No generic offset adjustment is introduced.

Extend the existing real-WABT verifier with plain, BOM-prefixed, BOM-plus-newline, plain hashbang, and BOM-prefixed hashbang source controls. Both local and URL literals are checked against positions derived from original source text; each glue file's path, hash, byte count, unchanged contents and candidate associations are verified.

Contract and boundary impact

  • Semantic owner and earliest changed stage: glue-file UTF-8 decoding in WabtArtifactProvider.inspect, before associateWasmGlue parses source.
  • CLI and MCP/tool-catalog contract: unchanged schemas; corrected source coordinates in both adapters.
  • Provider, bridge, target-format, or platform compatibility: same WABT 1.0.42 profile and fatal UTF-8 validation; no engine/bridge changes.
  • Evidence, artifact, provenance, or reconstruction contract: positions now agree with the hashed original artifact; CLI/MCP Evidence equality is verified.
  • Process execution, authorization, cleanup, or containment impact: none.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Base c22111eca2c4bc84a084f12711f405b3e7422a40, running the extended verifier against its built runtime: failed with first-line columns 6/32 instead of 7/33.

  • Candidate with real WABT: all 42 verifier cases pass, including public CLI and stdio MCP, schema validation, equal Evidence, original artifact identity and cleanup.

  • Representative corrected output: glue[].references[0] has line: 1, column: 7 for the BOM-prefixed source; plain source has line: 1, column: 6, and BOM-plus-newline source has line: 2, column: 6.

  • Review regression: the expanded verifier fails on initial head 9bf8140788 with parse_status: failed for BOM-plus-hashbang source; the follow-up preserves references and exact later-line positions.

  • Remaining proof gaps: executed on macOS with WABT 1.0.42; no claim of Linux/Windows execution or runtime execution of the glue/module.

  • 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

  • npm run build:cached — passed.
  • REA_WABT_BIN_DIRECTORY=<local WABT 1.0.42 bin> node scripts/verify-wasm-artifact.mjs --require-tools — 42 cases passed; the extended verifier fails on the unchanged base runtime.
  • npm run test:focused -- src/wasm/WabtArtifactProvider.test.ts src/wasm/WabtOutput.test.ts src/application/wasm/WasmArtifactService.test.ts tests/boundary/mcp/wasmArtifactMcp.test.ts — 33 tests passed.
  • npm run check — all six tasks and architecture guards passed.
  • git diff --check — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; coordinates are corrected to match the original source.
  • Real Hopper/Ghidra, browser, or OS coverage: real WABT CLI/MCP on macOS; no native-engine or browser changes.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no added execution or permissions; original input remains unchanged.

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 (no schema or metadata change).
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Hosted CI baseline

Initial-head test shard 1 failed in promptCompletion.test.ts ([] versus ['App', 'AppTests']), matching exact base main. Both Darwin package jobs failed with packaged MCP prompt completion lifecycle failed, matching base arm64 and base x64. These remain CI failures, not passes. Follow-up-head CI results are tracked separately.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9bf8140788

ℹ️ 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".

Comment thread src/wasm/WabtArtifactProvider.ts Resolved
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T18:43:11.720355Z a614721 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defect was found.

Summary

Preserves original source columns for BOM-prefixed JavaScript glue files without changing artifact identity or public schemas.

  • WASM glue references now keep their original source locations.

Reviews (7) · Last reviewed commit: "Merge branch 'main' into fix/wasm-glue-s..." · Reviewed by Greptile

Comment thread scripts/verify-wasm-artifact.mjs Resolved
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior area: providers Provider and capability discovery, including provider proposal triage area: build Build, CI, packaging, and publishing P2: medium Medium priority issue labels Oct 13, 2026
morluto and others added 8 commits October 13, 2026 23:01
* fix(comparison): preserve incomplete function call evidence

Keep missing, unknown, partial and unresolved call relationships unknown in function comparisons and reconstruction claims. Aggregate IDA caller and callee coverage without overwriting uncertainty.

Validate with 144 focused tests, typecheck/lint, docs checks and test discovery. Real providers were not verified; the full headless IDA session suite requires unavailable Windows native controls.

* fix(comparison): recheck historical calls-only changes

---------

Co-authored-by: morluto <[email protected]>
(cherry picked from commit 688defc)
…2895)

* fix: repair the static-check failures on the default branch

The default branch fails its own required `Static checks` job three ways, so
every pull request reports that job as failed regardless of its own change.

- `npm run format:check` reports `src/domain/functionComparison.test.ts` and
  `src/ida/IdaOperationRunner.ts`.
- `npm run lint` reports a duplicate `import { join } from "node:path"` in
  `tests/boundary/mcp/ghidraInventoryMcp.test.ts` (lines 4 and 17).
- `npm run typecheck` reports `format: "devin"` missing from the client format
  union in `src/application/SupportedClients.ts`, and an unchecked index in
  `tests/boundary/cli/clientProfileLifecycle.test.ts`, whose pair array is
  inferred as `string[][]`.

Apply the pinned formatter, drop the duplicate import, list the `"devin"` format
that its own definition already uses, and mark the pair array `as const`.

Validation: `npm run check:fast` and `npm run format:check` pass.

* fix(setup): keep Devin on the JSON configuration dialect

---------

Co-authored-by: 吴佳浩 <[email protected]>
Co-authored-by: morluto <[email protected]>
(cherry picked from commit df3d96d)
@morluto
morluto merged commit cddf31d into morluto:main Oct 13, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: build Build, CI, packaging, and publishing area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior area: providers Provider and capability discovery, including provider proposal triage bug Something isn't working P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants