[PR #1788] [MERGED] fix(javascript): preserve and resolve complete source-map URLs #4816

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

📋 Pull Request Information

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

Base: main ← Head: fix/source-map-url-resolution


📝 Commits (2)

  • 5b7065c fix(javascript): preserve and resolve complete source-map URLs
  • 521ffac Merge remote-tracking branch 'origin/main' into fix/source-map-url-resolution

📊 Changes

4 files changed (+207 additions, -1 deletions)

View changed files

📝 src/application/javascript/JavaScriptArtifactPathResolution.test.ts (+27 -0)
📝 src/application/javascript/JavaScriptArtifactPathResolution.ts (+8 -0)
📝 src/domain/javascript/javascriptStaticAnalysisCalls.ts (+3 -1)
📝 tests/acceptance/applications/applicationWorkflowCli.test.ts (+169 -0)

📄 Description

Summary

Keep complete source-map URL evidence and resolve percent-encoded local paths to the selected map. Fixes #1781. Fixes #1782.

Problem and expected behavior

//# sourceMappingURL=app.js.map?variant=a*modern was truncated at *, collapsing distinct declarations and shortening source ranges. space%20part.js.map remained encoded during local lookup, reporting an unavailable map despite inventory containing space part.js.map.

The original declaration, SHA-256 and source span must stay intact, while local URL lookup removes query/fragment and percent-decodes the path exactly once.

Change and scope

Line-comment directives terminate at whitespace; the existing block-comment terminator stays unchanged. The owning url-reference path boundary reuses percentDecodeUrlPath, preserving literal invalid percent escapes and rejecting decoded NUL/invalid UTF-8. ESM, CommonJS, HTML and filesystem-expression policies are unchanged. These related producer corrections share public CLI/MCP regression coverage.

Contract and boundary impact

  • Semantic owner and earliest changed stage: comment-token extraction in the JavaScript domain and contextual URL lookup in the application path resolver.
  • CLI and MCP/tool-catalog contract: no schema change; both return complete declarations and correctly linked local source maps.
  • Provider, bridge, target-format, or platform compatibility: static JavaScript/URL handling. New fixtures use portable filenames; literal * is in URL query/fragment.
  • Evidence, artifact, provenance, or reconstruction contract: hash raw declarations, preserve exact ranges and distinct observations; link to the existing inventoried map identity.
  • Process execution, authorization, cleanup, or containment impact: none; no URL fetch, execution or additional filesystem authority.
  • Generated metadata, package, or installation impact: none; no generated outputs committed.

Evidence and regression coverage

  • Tests added or updated: two compiled CLI + real stdio MCP scenarios for modern/legacy line comments, distinct URLs, SHA-256/ranges/target edges, encoded spaces/percent/Unicode, one-pass decoding, suffixes and literal %ZZ. The same URL resolver's Worker/service-worker callers preserve encoded specifiers and link literal-space files. Resolver cases preserve rejected outcomes for NUL, invalid UTF-8, encoded separators/dots and traversal. Existing block-comment and 9M/9.5M-character regressions remain.

  • Base reproduction: both new public tests fail on unchanged production at aaeadf2d4: three star-containing declarations yielded only two reference observations, and the encoded-space reference did not link to its inventoried map.

  • User-visible output: declared_url/declared_url_sha256 remain original; resolved_path names the local decoded path, available: true, and maps_to targets the inventoried map node.

  • Remaining proof gaps: static relationships do not prove target JavaScript executes or debugger/provider behavior. Native Windows execution is not locally available.

  • 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/domain/javascript/javascriptStaticAnalysisSourceMaps.test.ts src/application/javascript/JavaScriptArtifactPathResolution.test.ts tests/acceptance/applications/applicationWorkflowCli.test.ts — 133/133 passed, including the unchanged capacity regressions.
  • Compiled runtime, targeted public tests after adding Worker/service-worker controls: node node_modules/vitest/vitest.mjs run tests/acceptance/applications/applicationWorkflowCli.test.ts -t 'source-map URL' — 2/2 passed (31 unrelated tests intentionally filtered).
  • Four additional actual Linux CLI probes passed: ordinary URL, literal-star filenames with modern/legacy line directives, and an encoded star; verified exact declarations, SHA-256, resolved paths and graph links.
  • npm run check — typecheck, lint/module boundaries, formatting, Knip, metadata and architecture guards passed.
  • After merging current main into the branch: npm run build:cached passed; targeted compiled CLI/MCP source-map scenarios plus the merged Mach-O regression passed 3/3 (40 unrelated tests filtered).

Compatibility, safety, and release

  • Breaking changes or migration steps: none; valid URLs now resolve as intended.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux compiled CLI and SDK stdio MCP; no native provider/browser execution claim.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: decode only local URL paths, once, after existing external/syntax guards; preserve lexical artifact-root confinement and selected-file lookup.

Review checklist

  • This PR addresses concrete bugs.
  • One focused outcome; Conventional Commit title.
  • Related issues are linked.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs/contracts/generated metadata require no changes.
  • Representative CLI/MCP output is described above.
  • Final diff checked 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/1788 **Author:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/11/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `fix/source-map-url-resolution` --- ### 📝 Commits (2) - [`5b7065c`](https://github.com/morluto/rea/commit/5b7065c5b1d2222e012165a08374ae6df8727783) fix(javascript): preserve and resolve complete source-map URLs - [`521ffac`](https://github.com/morluto/rea/commit/521ffacbd739e15cffaef855fea7d98a699c7405) Merge remote-tracking branch 'origin/main' into fix/source-map-url-resolution ### 📊 Changes **4 files changed** (+207 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/application/javascript/JavaScriptArtifactPathResolution.test.ts` (+27 -0) 📝 `src/application/javascript/JavaScriptArtifactPathResolution.ts` (+8 -0) 📝 `src/domain/javascript/javascriptStaticAnalysisCalls.ts` (+3 -1) 📝 `tests/acceptance/applications/applicationWorkflowCli.test.ts` (+169 -0) </details> ### 📄 Description ## Summary Keep complete source-map URL evidence and resolve percent-encoded local paths to the selected map. Fixes #1781. Fixes #1782. ## Problem and expected behavior `//# sourceMappingURL=app.js.map?variant=a*modern` was truncated at `*`, collapsing distinct declarations and shortening source ranges. `space%20part.js.map` remained encoded during local lookup, reporting an unavailable map despite inventory containing `space part.js.map`. The original declaration, SHA-256 and source span must stay intact, while local URL lookup removes query/fragment and percent-decodes the path exactly once. ## Change and scope Line-comment directives terminate at whitespace; the existing block-comment terminator stays unchanged. The owning `url-reference` path boundary reuses `percentDecodeUrlPath`, preserving literal invalid percent escapes and rejecting decoded NUL/invalid UTF-8. ESM, CommonJS, HTML and filesystem-expression policies are unchanged. These related producer corrections share public CLI/MCP regression coverage. ## Contract and boundary impact - Semantic owner and earliest changed stage: comment-token extraction in the JavaScript domain and contextual URL lookup in the application path resolver. - CLI and MCP/tool-catalog contract: no schema change; both return complete declarations and correctly linked local source maps. - Provider, bridge, target-format, or platform compatibility: static JavaScript/URL handling. New fixtures use portable filenames; literal `*` is in URL query/fragment. - Evidence, artifact, provenance, or reconstruction contract: hash raw declarations, preserve exact ranges and distinct observations; link to the existing inventoried map identity. - Process execution, authorization, cleanup, or containment impact: none; no URL fetch, execution or additional filesystem authority. - Generated metadata, package, or installation impact: none; no generated outputs committed. ## Evidence and regression coverage - Tests added or updated: two compiled CLI + real stdio MCP scenarios for modern/legacy line comments, distinct URLs, SHA-256/ranges/target edges, encoded spaces/percent/Unicode, one-pass decoding, suffixes and literal `%ZZ`. The same URL resolver's Worker/service-worker callers preserve encoded specifiers and link literal-space files. Resolver cases preserve rejected outcomes for NUL, invalid UTF-8, encoded separators/dots and traversal. Existing block-comment and 9M/9.5M-character regressions remain. - Base reproduction: both new public tests fail on unchanged production at `aaeadf2d4`: three star-containing declarations yielded only two reference observations, and the encoded-space reference did not link to its inventoried map. - User-visible output: `declared_url`/`declared_url_sha256` remain original; `resolved_path` names the local decoded path, `available: true`, and `maps_to` targets the inventoried map node. - Remaining proof gaps: static relationships do not prove target JavaScript executes or debugger/provider behavior. Native Windows execution is not locally available. - [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/domain/javascript/javascriptStaticAnalysisSourceMaps.test.ts src/application/javascript/JavaScriptArtifactPathResolution.test.ts tests/acceptance/applications/applicationWorkflowCli.test.ts` — 133/133 passed, including the unchanged capacity regressions. - Compiled runtime, targeted public tests after adding Worker/service-worker controls: `node node_modules/vitest/vitest.mjs run tests/acceptance/applications/applicationWorkflowCli.test.ts -t 'source-map URL'` — 2/2 passed (31 unrelated tests intentionally filtered). - Four additional actual Linux CLI probes passed: ordinary URL, literal-star filenames with modern/legacy line directives, and an encoded star; verified exact declarations, SHA-256, resolved paths and graph links. - `npm run check` — typecheck, lint/module boundaries, formatting, Knip, metadata and architecture guards passed. - After merging current main into the branch: `npm run build:cached` passed; targeted compiled CLI/MCP source-map scenarios plus the merged Mach-O regression passed 3/3 (40 unrelated tests filtered). ## Compatibility, safety, and release - Breaking changes or migration steps: none; valid URLs now resolve as intended. - Real Hopper/Ghidra, browser, or OS coverage: Linux compiled CLI and SDK stdio MCP; no native provider/browser execution claim. - Package or release metadata impact: none. - Security, privacy, process, or containment review: decode only local URL paths, once, after existing external/syntax guards; preserve lexical artifact-root confinement and selected-file lookup. ## Review checklist - [x] This PR addresses concrete bugs. - [x] One focused outcome; Conventional Commit title. - [x] Related issues are linked. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs/contracts/generated metadata require no changes. - [x] Representative CLI/MCP output is described above. - [x] Final diff checked 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:55:21 +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#4816
No description provided.