[PR #691] [MERGED] fix(javascript): count all source line terminators #2172

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

📋 Pull Request Information

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

Base: main ← Head: fix/javascript-line-terminators


📝 Commits (1)

  • 03bc6d3 fix(javascript): count all source line terminators

📊 Changes

3 files changed (+111 additions, -1 deletions)

View changed files

📝 src/domain/javascriptStaticAnalysisHelpers.ts (+2 -1)
➕ src/domain/javascriptStaticAnalysisLocations.test.ts (+65 -0)
➕ tests/boundary/filesystem/javascriptSourceMapLocations.test.ts (+44 -0)

📄 Description

Summary

Correct source-map directive coordinates after all JavaScript line terminators.

No separate issue: this is a reproduced source-location defect identified while checking source-map evidence.

Problem and expected behavior

After a lone CR, U+2028, or U+2029, Babel locates a trailing directive on line 2, but REA reports line 1 and a column that includes the preceding statement. The incorrect range is then copied into the public reconstruction graph's source-map evidence.

JavaScript recognizes LF, CR, U+2028 and U+2029, with CRLF counted as one line break (ECMAScript line terminators). Offset-derived locations should agree with the AST's line/UTF-16-column convention.

Change and scope

Replace the LF-only split in the JavaScript offset-to-location helper with the language's line-terminator sequences. Preserve UTF-16 column lengths and existing source-map match spans.

This is independent of #672's comment-recognition fix. Both patches were also tested together in a separate tree.

Contract and boundary impact

  • Semantic owner: JavaScript static source-coordinate conversion.
  • CLI/MCP: correct existing source-map evidence ranges; no schema or tool changes.
  • Provider/platform: unchanged.
  • Evidence/provenance: declared URLs, artifact hashes, unresolved locations and inferred relationship status remain intact. Evidence identifiers incorporating the corrected ranges may change.
  • Process/authorization/cleanup: source remains inert; no new execution or network behavior.
  • Generated metadata/package: unchanged.

Evidence and regression coverage

Nine new expectations failed on unchanged main b6c21b1: six domain cases and three filesystem reconstruction cases. LF/CRLF and same-line controls passed.

Coverage includes Babel-oracle coordinates for all line terminators and mixed sequences, astral-character UTF-16 columns, VT/FF whitespace controls, multiline block directives, first-occurrence deduplication, and actual graph evidence from owned files.

Validation performed

  • Exact current lock installed with npm ci; build passed.
  • Focused location, existing source-map and public reconstruction suites: 23 tests passed.
  • npm run check: all five tasks passed (93 existing lint warnings, no errors).
  • npm run jscpd, npm run scan:todos, and git diff --check: passed.
  • Combined #672 + this patch: 39 focused tests passed in a separate tree.
  • Independent review: completed before publication; no blocking findings.

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

Compatibility, safety, and release

No packaging, provider or execution-authority changes. Package-install and real Hopper/Ghidra lanes were not rerun for this coordinate-only fix. This does not change source-map directive recognition.

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/691 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/6/2026 **Status:** ✅ Merged **Merged:** 10/6/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/javascript-line-terminators` --- ### 📝 Commits (1) - [`03bc6d3`](https://github.com/morluto/rea/commit/03bc6d36db94e70c709557cb7302d40af9e99e6b) fix(javascript): count all source line terminators ### 📊 Changes **3 files changed** (+111 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/javascriptStaticAnalysisHelpers.ts` (+2 -1) ➕ `src/domain/javascriptStaticAnalysisLocations.test.ts` (+65 -0) ➕ `tests/boundary/filesystem/javascriptSourceMapLocations.test.ts` (+44 -0) </details> ### 📄 Description ## Summary Correct source-map directive coordinates after all JavaScript line terminators. No separate issue: this is a reproduced source-location defect identified while checking source-map evidence. ## Problem and expected behavior After a lone CR, U+2028, or U+2029, Babel locates a trailing directive on line 2, but REA reports line 1 and a column that includes the preceding statement. The incorrect range is then copied into the public reconstruction graph's source-map evidence. JavaScript recognizes LF, CR, U+2028 and U+2029, with CRLF counted as one line break ([ECMAScript line terminators](https://tc39.es/ecma262/multipage/ecmascript-language-lexical-grammar.html#sec-line-terminators)). Offset-derived locations should agree with the AST's line/UTF-16-column convention. ## Change and scope Replace the LF-only split in the JavaScript offset-to-location helper with the language's line-terminator sequences. Preserve UTF-16 column lengths and existing source-map match spans. This is independent of #672's comment-recognition fix. Both patches were also tested together in a separate tree. ## Contract and boundary impact - Semantic owner: JavaScript static source-coordinate conversion. - CLI/MCP: correct existing source-map evidence ranges; no schema or tool changes. - Provider/platform: unchanged. - Evidence/provenance: declared URLs, artifact hashes, unresolved locations and inferred relationship status remain intact. Evidence identifiers incorporating the corrected ranges may change. - Process/authorization/cleanup: source remains inert; no new execution or network behavior. - Generated metadata/package: unchanged. ## Evidence and regression coverage Nine new expectations failed on unchanged main `b6c21b1`: six domain cases and three filesystem reconstruction cases. LF/CRLF and same-line controls passed. Coverage includes Babel-oracle coordinates for all line terminators and mixed sequences, astral-character UTF-16 columns, VT/FF whitespace controls, multiline block directives, first-occurrence deduplication, and actual graph evidence from owned files. ## Validation performed - Exact current lock installed with `npm ci`; build passed. - Focused location, existing source-map and public reconstruction suites: 23 tests passed. - `npm run check`: all five tasks passed (93 existing lint warnings, no errors). - `npm run jscpd`, `npm run scan:todos`, and `git diff --check`: passed. - Combined #672 + this patch: 39 focused tests passed in a separate tree. - Independent review: completed before publication; no blocking findings. Node.js 24.19.0, npm 11.9.0. Hosted CI is tracked separately; no full local suite pass is claimed. ## Compatibility, safety, and release No packaging, provider or execution-authority changes. Package-install and real Hopper/Ghidra lanes were not rerun for this coordinate-only fix. This does not change source-map directive recognition. 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:12 +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#2172
No description provided.