[PR #672] [MERGED] fix(javascript): read source-map directives only from comments #2155

Closed
opened 2026-10-16 21:15:00 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/672
Author: @kaoru0822-kitauji
Created: 10/6/2026
Status: ✅ Merged
Merged: 10/6/2026
Merged by: @morluto

Base: main ← Head: fix/comment-source-maps


📝 Commits (1)

  • 94688bb fix(javascript): read source-map directives only from comments

📊 Changes

5 files changed (+149 additions, -9 deletions)

View changed files

📝 src/domain/javascriptSourceParser.ts (+1 -1)
📝 src/domain/javascriptStaticAnalysis.ts (+1 -1)
📝 src/domain/javascriptStaticAnalysisCalls.ts (+17 -7)
📝 src/domain/javascriptStaticAnalysisSourceMaps.test.ts (+87 -0)
➕ tests/boundary/filesystem/javascriptSourceMapComments.test.ts (+43 -0)

📄 Description

Summary

Stop ordinary strings, templates, regular expressions, and JSX text from inventing source-map declarations and graph relationships.

No separate issue: this is a reproduced static-evidence correctness defect.

Problem and expected behavior

For const documentation = "//# sourceMappingURL=ghost.map ";, Babel reports no comments, but REA currently extracts ghost.map and creates a source-map node and maps_to edge. The extractor scans the entire raw source rather than comment tokens.

Source-map annotations are comment content, as described by ECMA-426. Quoted examples should not become declarations.

Change and scope

Use the existing parsed AST's comment ranges and match at each actual comment opener. This also excludes nested-looking examples inside documentation comments.

Keep current/legacy line syntax, minifier block syntax, all-directive reporting, URL deduplication, and existing source-span conventions. Parsing remains inert.

Contract and boundary impact

  • Semantic owner: JavaScript static source-map directive extraction.
  • CLI/MCP: false source-map observations and graph edges disappear; no schemas or tools change.
  • Providers/platforms: no change.
  • Evidence/provenance: declarations are bound to actual comments, preserving original URLs and locations.
  • Process/authorization/cleanup: source is parsed as data and never executed; no new file/network effects.
  • Generated metadata/package: none.

Evidence and regression coverage

On the unchanged base, nine new cases fail while 14 controls pass. Coverage includes strings, templates, regex literals, JSX/TypeScript, documentation-comment examples, authentic trailing/nested/legacy comments, LF/CRLF locations, URL deduplication, and recovered/failed parsing.

A directory reconstruction regression proves quoted text creates no phantom source-map node/edge, then verifies that a real trailing directive still creates its relationship.

Validation performed

After updating to main 39db9fe:

  • Focused source-map, full-collection, directory-graph, and bundler suites: 27 tests passed.
  • Build and npm run check: passed (93 lint warnings, 0 errors).
  • npm run jscpd, npm run scan:todos, and git diff --check: passed.
  • Independent review: no introduced issue; committed tests and additional lexical/compatibility probes passed.

The separate pre-existing coordinate limitation after lone CR/U+2028/U+2029 is addressed by merged #691. This comment-boundary patch remains independent; both changes passed 39 focused tests together in a separate current-main tree.

Node.js 24.19.0, npm 11.9.0. Hosted CI is tracked separately; no complete local suite pass is claimed.

Compatibility, safety, and release

No schema, packaging, or native-provider change. Package-install and real Hopper/Ghidra verification were not rerun locally.

Prepared with AI assistance.


🔄 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/672 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/6/2026 **Status:** ✅ Merged **Merged:** 10/6/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/comment-source-maps` --- ### 📝 Commits (1) - [`94688bb`](https://github.com/morluto/rea/commit/94688bb2216ba714b11f9640c22f11972e7151cd) fix(javascript): read source-map directives only from comments ### 📊 Changes **5 files changed** (+149 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/javascriptSourceParser.ts` (+1 -1) 📝 `src/domain/javascriptStaticAnalysis.ts` (+1 -1) 📝 `src/domain/javascriptStaticAnalysisCalls.ts` (+17 -7) 📝 `src/domain/javascriptStaticAnalysisSourceMaps.test.ts` (+87 -0) ➕ `tests/boundary/filesystem/javascriptSourceMapComments.test.ts` (+43 -0) </details> ### 📄 Description ## Summary Stop ordinary strings, templates, regular expressions, and JSX text from inventing source-map declarations and graph relationships. No separate issue: this is a reproduced static-evidence correctness defect. ## Problem and expected behavior For `const documentation = "//# sourceMappingURL=ghost.map ";`, Babel reports no comments, but REA currently extracts `ghost.map` and creates a source-map node and `maps_to` edge. The extractor scans the entire raw source rather than comment tokens. Source-map annotations are comment content, as described by [ECMA-426](https://tc39.es/ecma426/#sec-JavaScriptExtractSourceMapURL). Quoted examples should not become declarations. ## Change and scope Use the existing parsed AST's comment ranges and match at each actual comment opener. This also excludes nested-looking examples inside documentation comments. Keep current/legacy line syntax, minifier block syntax, all-directive reporting, URL deduplication, and existing source-span conventions. Parsing remains inert. ## Contract and boundary impact - Semantic owner: JavaScript static source-map directive extraction. - CLI/MCP: false source-map observations and graph edges disappear; no schemas or tools change. - Providers/platforms: no change. - Evidence/provenance: declarations are bound to actual comments, preserving original URLs and locations. - Process/authorization/cleanup: source is parsed as data and never executed; no new file/network effects. - Generated metadata/package: none. ## Evidence and regression coverage On the unchanged base, nine new cases fail while 14 controls pass. Coverage includes strings, templates, regex literals, JSX/TypeScript, documentation-comment examples, authentic trailing/nested/legacy comments, LF/CRLF locations, URL deduplication, and recovered/failed parsing. A directory reconstruction regression proves quoted text creates no phantom source-map node/edge, then verifies that a real trailing directive still creates its relationship. ## Validation performed After updating to main `39db9fe`: - Focused source-map, full-collection, directory-graph, and bundler suites: 27 tests passed. - Build and `npm run check`: passed (93 lint warnings, 0 errors). - `npm run jscpd`, `npm run scan:todos`, and `git diff --check`: passed. - Independent review: no introduced issue; committed tests and additional lexical/compatibility probes passed. The separate pre-existing coordinate limitation after lone CR/U+2028/U+2029 is addressed by merged #691. This comment-boundary patch remains independent; both changes passed 39 focused tests together in a separate current-main tree. Node.js 24.19.0, npm 11.9.0. Hosted CI is tracked separately; no complete local suite pass is claimed. ## Compatibility, safety, and release No schema, packaging, or native-provider change. Package-install and real Hopper/Ghidra verification were not rerun locally. Prepared with AI assistance. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-16 21:15:00 +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#2155
No description provided.