[PR #4485] [MERGED] fix(wasm): pass glue filenames to the JavaScript parser #6270

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4485
Author: @jayinvers
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @morluto

Base: main ← Head: fix/wasm-glue-filename-parser


📝 Commits (1)

  • c890dc7 fix(wasm): pass glue filenames to the JavaScript parser

📊 Changes

2 files changed (+37 additions, -0 deletions)

View changed files

📝 src/wasm/WabtOutput.test.ts (+34 -0)
📝 src/wasm/WasmGlueAdapter.ts (+3 -0)

📄 Description

Summary

inspect-wasm-artifact glue association parsed selected .js glue files without their filename, so the parser's unnamed-source fallback kept the TypeScript-capable grammar active. TypeScript reads valid JavaScript like n===0?H=>({start:H.startY}):H=>({start:H.startX}) as a return type, the whole glue file got parse_status: "failed", and every .wasm literal reference in it was lost. The adapter now passes its existing path argument to parseJavaScriptSource, so .js glue parses with the JavaScript grammar. Fixes #4474 (follow-up to #3780/#3782's remaining affected flow).

Problem and expected behavior

Smallest trigger: a selected glue file containing a conditional-arrow statement followed by a fetch:

const pick=n===0?H=>({start:H.startY}):H=>({start:H.startX});
fetch("./module.wasm");

Violated invariant: WasmGlueAdapter already receives the selected glue filename but dropped it at the parser boundary, defeating the filename-aware grammar selection owned by javascriptSourceParser.ts (#3782). Expected: the fixture parses completely and retains the ./module.wasm reference at line 2, column 6 with association: "local-path-candidate" and evidence_kind: "static-literal"; the fetch-only control is unaffected.

Change and scope

One-line fix at the owning boundary: src/wasm/WasmGlueAdapter.ts passes path into parseJavaScriptSource. The unnamed-source fallback policy in src/domain/javascript/javascriptSourceParser.ts is intentionally unchanged (preserved by #3782). Not included: directive-prologue literal handling (#4001/#4149) and candidate-path equivalence (#3402/#3455). Regression test added next to the existing glue association tests in src/wasm/WabtOutput.test.ts. Contribution scope: not applicable (ordinary fix within existing read-only boundaries).

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/wasm/WasmGlueAdapter.ts glue association; earliest stage is inert glue parsing, before literal collection.
  • Contribution scope fit and linked maintainer decision: not applicable — ordinary fix, no new capability.
  • CLI and MCP/tool-catalog contract: none; the existing glue[].parse_status/references schema is unchanged, now with correct values for previously mis-parsed valid JavaScript.
  • Provider, bridge, target-format, or platform compatibility: none; grammar selection is filename-based.
  • Evidence, artifact, provenance, or reconstruction contract: provenance unchanged; previously lost references (failed parse) are now retained with correct source locations.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable (inert parsing of already-selected files).
  • Generated metadata, package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/wasm/WabtOutput.test.ts — "retains .wasm references in glue whose conditional arrows only parse as JavaScript" (issue fixture + fetch-only control).
  • Base reproduction (executed): a tsx probe importing associateWasmGlue from source, run against base revision fe2a398dd and with this change:
Glue input (path /app/glue.js, candidate /app/module.wasm) Base fe2a398dd This change
conditional arrow + fetch("./module.wasm"); parse_status: "failed", references: [] parse_status: "complete", one reference: value ./module.wasm, line 2, column 6, local-path-candidate, static-literal, candidate /app/module.wasm
fetch("./module.wasm"); (control) parse_status: "complete", reference line 1 column 6 unchanged
  • Red-green: temporarily reverting the one-line fix makes the new test fail (expected 'failed' to be 'complete') while the 14 existing tests in the file pass; restored, all 15 pass. The regression test therefore catches the base-revision failure.
  • User-visible CLI/MCP output (if applicable): not re-run locally; the issue reports the public CLI fields (glue: [{ "parse_status": "failed", "references": [] }] vs. the control's complete parse) with real WABT 1.0.42, which the probe's adapter-level results match.
  • Remaining proof gaps: real WABT was NOT run locally (not installed on this host); the public CLI/MCP path and non-Windows platforms are covered only by CI's lanes, not by local execution. The probe is executed against source modules, not the published package.

For evidence-bearing changes:

  • 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 test:focused -- src/wasm/WabtOutput.test.ts — 15 passed (14 existing + 1 new); red-green verified by temporarily reverting the fix (new test failed, 14 passed).
  • npm run check:fast — typecheck + lint: 2 successful.
  • npx oxfmt --check src/wasm/WasmGlueAdapter.ts src/wasm/WabtOutput.test.ts — all files correctly formatted.
  • npm run verify:test-discovery — all 1417 test files discovered exactly once.
  • Fork CI (jayinvers/rea, branch fix/wasm-glue-filename-parser): CI run 38907748779 — success (pull_request event, full workflow).

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not run locally (no real WABT/Hopper/Ghidra on this host); deterministic suite plus the repo's CI lanes cover this change.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none needed — inert parsing of already-selected local files; no execution, network, or mutation.

Author readiness

Human owner: @jayinvers

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. (Not applicable — ordinary fix within existing boundaries.)
  • 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. (None required.)
  • User-visible CLI/MCP changes include representative output. (Not executed locally; see remaining proof gaps — the issue contains the reporter-executed CLI 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/4485 **Author:** [@jayinvers](https://github.com/jayinvers) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/wasm-glue-filename-parser` --- ### 📝 Commits (1) - [`c890dc7`](https://github.com/morluto/rea/commit/c890dc72c4d9faea625557a462a6bafb98247e9e) fix(wasm): pass glue filenames to the JavaScript parser ### 📊 Changes **2 files changed** (+37 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/wasm/WabtOutput.test.ts` (+34 -0) 📝 `src/wasm/WasmGlueAdapter.ts` (+3 -0) </details> ### 📄 Description ## Summary `inspect-wasm-artifact` glue association parsed selected `.js` glue files without their filename, so the parser's unnamed-source fallback kept the TypeScript-capable grammar active. TypeScript reads valid JavaScript like `n===0?H=>({start:H.startY}):H=>({start:H.startX})` as a return type, the whole glue file got `parse_status: "failed"`, and every `.wasm` literal reference in it was lost. The adapter now passes its existing `path` argument to `parseJavaScriptSource`, so `.js` glue parses with the JavaScript grammar. Fixes #4474 (follow-up to #3780/#3782's remaining affected flow). ## Problem and expected behavior Smallest trigger: a selected glue file containing a conditional-arrow statement followed by a fetch: ```js const pick=n===0?H=>({start:H.startY}):H=>({start:H.startX}); fetch("./module.wasm"); ``` Violated invariant: `WasmGlueAdapter` already receives the selected glue filename but dropped it at the parser boundary, defeating the filename-aware grammar selection owned by `javascriptSourceParser.ts` (#3782). Expected: the fixture parses completely and retains the `./module.wasm` reference at line 2, column 6 with `association: "local-path-candidate"` and `evidence_kind: "static-literal"`; the fetch-only control is unaffected. ## Change and scope One-line fix at the owning boundary: `src/wasm/WasmGlueAdapter.ts` passes `path` into `parseJavaScriptSource`. The unnamed-source fallback policy in `src/domain/javascript/javascriptSourceParser.ts` is intentionally unchanged (preserved by #3782). Not included: directive-prologue literal handling (#4001/#4149) and candidate-path equivalence (#3402/#3455). Regression test added next to the existing glue association tests in `src/wasm/WabtOutput.test.ts`. Contribution scope: not applicable (ordinary fix within existing read-only boundaries). ## Contract and boundary impact - Semantic owner and earliest changed stage: `src/wasm/WasmGlueAdapter.ts` glue association; earliest stage is inert glue parsing, before literal collection. - Contribution scope fit and linked maintainer decision: not applicable — ordinary fix, no new capability. - CLI and MCP/tool-catalog contract: none; the existing `glue[].parse_status`/`references` schema is unchanged, now with correct values for previously mis-parsed valid JavaScript. - Provider, bridge, target-format, or platform compatibility: none; grammar selection is filename-based. - Evidence, artifact, provenance, or reconstruction contract: provenance unchanged; previously lost references (failed parse) are now retained with correct source locations. - Target selection, authority, upstream behavior, and cleanup details: not applicable (inert parsing of already-selected files). - Generated metadata, package, or installation impact: none. Expected effects (check known effects; use documentation-only on its own). - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `src/wasm/WabtOutput.test.ts` — "retains .wasm references in glue whose conditional arrows only parse as JavaScript" (issue fixture + fetch-only control). - Base reproduction (executed): a tsx probe importing `associateWasmGlue` from source, run against base revision `fe2a398dd` and with this change: | Glue input (path `/app/glue.js`, candidate `/app/module.wasm`) | Base `fe2a398dd` | This change | | --- | --- | --- | | conditional arrow + `fetch("./module.wasm");` | `parse_status: "failed"`, `references: []` | `parse_status: "complete"`, one reference: value `./module.wasm`, line 2, column 6, `local-path-candidate`, `static-literal`, candidate `/app/module.wasm` | | `fetch("./module.wasm");` (control) | `parse_status: "complete"`, reference line 1 column 6 | unchanged | - Red-green: temporarily reverting the one-line fix makes the new test fail (`expected 'failed' to be 'complete'`) while the 14 existing tests in the file pass; restored, all 15 pass. The regression test therefore catches the base-revision failure. - User-visible CLI/MCP output (if applicable): not re-run locally; the issue reports the public CLI fields (`glue: [{ "parse_status": "failed", "references": [] }]` vs. the control's complete parse) with real WABT 1.0.42, which the probe's adapter-level results match. - Remaining proof gaps: real WABT was NOT run locally (not installed on this host); the public CLI/MCP path and non-Windows platforms are covered only by CI's lanes, not by local execution. The probe is executed against source modules, not the published package. For evidence-bearing changes: - [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 - `npm run test:focused -- src/wasm/WabtOutput.test.ts` — 15 passed (14 existing + 1 new); red-green verified by temporarily reverting the fix (new test failed, 14 passed). - `npm run check:fast` — typecheck + lint: 2 successful. - `npx oxfmt --check src/wasm/WasmGlueAdapter.ts src/wasm/WabtOutput.test.ts` — all files correctly formatted. - `npm run verify:test-discovery` — all 1417 test files discovered exactly once. - Fork CI (jayinvers/rea, branch `fix/wasm-glue-filename-parser`): [CI run 38907748779](https://github.com/jayinvers/rea/actions/runs/38907748779) — success (pull_request event, full workflow). ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: not run locally (no real WABT/Hopper/Ghidra on this host); deterministic suite plus the repo's CI lanes cover this change. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none needed — inert parsing of already-selected local files; no execution, network, or mutation. ## Author readiness Human owner: @jayinvers - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. (Not applicable — ordinary fix within existing boundaries.) - [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. (None required.) - [ ] User-visible CLI/MCP changes include representative output. (Not executed locally; see remaining proof gaps — the issue contains the reporter-executed CLI 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 01:13: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#6270
No description provided.