[PR #2829] [CLOSED] fix(source-maps): retain originals with partial source contents #5422

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2829
Author: @shoyann
Created: 10/13/2026
Status: ❌ Closed

Base: main ← Head: fix/source-map-partial-contents


📝 Commits (1)

  • 28d2ecb fix(source-maps): retain originals with partial source contents

📊 Changes

7 files changed (+200 additions, -28 deletions)

View changed files

📝 src/application/javascript/JavaScriptArtifactAnalysis.ts (+2 -2)
📝 src/domain/sourceMapContents.test.ts (+8 -6)
📝 src/domain/sourceMapContents.ts (+2 -6)
📝 src/javascript/sourceMaps/SourceMapFormat.ts (+0 -12)
📝 tests/acceptance/applications/sourceMapPrefixCli.test.ts (+81 -0)
📝 tests/boundary/browser/webSourceMapFetcher.test.ts (+103 -1)
📝 tests/boundary/filesystem/javascriptArtifactReconstruction.test.ts (+4 -1)

📄 Description

Summary

Fixes #2821.

Retain original source declarations and available embedded text when sourcesContent has a different length from sources, in local application reconstruction and browser source-map collection.

Problem and expected behavior

With sources: ["a.ts", "b.ts"] and sourcesContent: ["export const answer = 42;"], local CLI/MCP analysis discarded both originals; browser collection rejected the entire map. Padding the content array with null made the same declarations work.

ECMA-426 DecodeSourceMapSources reads content by source ordinal only when an entry exists. Missing content is unavailable, and excess entries do not introduce sources. This corrects the cardinality assumption retained by #2034; malformed field/element types remain invalid.

Change and scope

Remove source-count equality from the local content admission helper and its obsolete parameter/error wording. Remove the redundant browser-profile content check: the existing leaf schema already validates every supplied content entry, and raw content records are still budgeted before schema parsing. Both existing collectors continue iterating source declarations, preserving section-local and flattened ordinals without padding, compacting, or mutating raw map evidence.

Contract and boundary impact

  • Semantic owner and earliest changed stage: source-map content admission; local source collection and shared browser leaf validation.
  • Contribution scope fit and linked maintainer decision: ordinary read-only format correction within existing workflows; separate maintainer scope decision not applicable.
  • CLI and MCP/tool-catalog contract: unchanged request and result schemas; valid maps now retain originals previously discarded.
  • Provider, bridge, target-format, or platform compatibility: version-3 regular/indexed source maps; no provider or bridge changes.
  • Evidence, artifact, provenance, or reconstruction contract: preserve exact map bytes/digest and source ordinals; unavailable content stays null, empty strings stay present, excess content creates no source.
  • Target selection, authority, upstream behavior, and cleanup details: existing file selection and allowed-origin policies remain in force; regression HTTP listener is closed in finally.
  • Generated metadata, package, or installation impact: none.

Expected workflow effects:

  • 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 (existing opt-in source-map collection).
  • 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

  • Added compiled CLI and stdio MCP regressions for indexed leaves with short/empty/excess content arrays, explicit null and empty text, source ordinals and exact map/content digests.

  • Added real loopback HTTP collection coverage asserting retained raw map evidence, content availability and generated/source mapping ordinals across sections.

  • Kept scalar/non-string rejection and changed the obsolete empty-array rejection cases to malformed excess-element cases. Existing omitted/null content and resource-budget regressions pass.

  • Base reproduction: at 9680da76c84a6833635dc7a5df607806d899f804, all 3 new regression cases failed while the other 79 cases in the two files passed. CLI/MCP returned 0 instead of 5 originals; HTTP returned invalid instead of included.

  • Public CLI reproduction from #2821: short and padded arrays now both produce coverage: "complete", originals: 2 (short previously produced partial, 0).

  • Remaining proof gaps: no live CDP browser session was run; the production source-map HTTP fetch/parse boundary and public local CLI/MCP were exercised. No native engine is involved.

  • 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 ci --prefer-offline and npm run build:cached — passed with Node 24.18.0 / npm 11.16.0 on WSL Ubuntu x86_64.
  • npm run test:focused -- src/domain/sourceMapContents.test.ts src/javascript/sourceMaps/TraceSourceMap.test.ts src/application/javascript/JavaScriptArtifactAnalysis.sourceMaps.test.ts tests/acceptance/applications/sourceMapPrefixCli.test.ts tests/boundary/browser/webSourceMapFetcher.test.ts tests/boundary/filesystem/javascriptArtifactReconstruction.test.ts — 121 passed across 6 files.
  • npm run test:focused -- tests/boundary/browser/webSourceMapFetcher.test.ts — final test-scope cleanup verified, 74 passed.
  • npm run typecheck, npm run knip, npm run verify:module-boundaries, npm run verify:architecture-guards, npm run verify:test-discovery — passed; all 1078 test files discovered exactly once.
  • npx oxfmt --check and npx oxlint over all 7 changed files — passed (no lint errors); git diff --check passed.
  • npm run check — blocked by unrelated baseline formatting in tests/fixtures/javaClassFile.ts and existing max-lines-per-function errors in tests/boundary/providers/ghidra/ghidraLauncher.test.ts:431, src/ghidra/GhidraFunctionValues.test.ts:46, and src/domain/webBundleAnalyzer.test.ts:224. Those files are unchanged here; the individual checks above completed separately because Turbo cancels peer tasks after failure.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; valid previously rejected maps are accepted.
  • Real Hopper/Ghidra, browser, or OS coverage: no native engine changes; real HTTP boundary on WSL Ubuntu, no live CDP claim.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: malformed content types remain invalid; network response/structure/evidence budgets and origin admission are unchanged. Extra content remains only in retained raw map bytes, not invented source artifacts.

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

The same formatting failure and three lint errors were independently reproduced on a clean checkout of base 9680da7. The normal pre-push hook failed on those same lint errors; after the checks above, this branch was pushed with that local hook disabled for the push only.

Integration note

Related independent fix: #2831. Both PRs target main and fix separate issues. Their deletions touch adjacent validation blocks in SourceMapFormat.ts; a local three-way merge reports a textual conflict between them. Once either merges, the other needs a small rebase retaining both removals. There is no semantic dependency, and the regression additions merge cleanly.


🔄 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/2829 **Author:** [@shoyann](https://github.com/shoyann) **Created:** 10/13/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/source-map-partial-contents` --- ### 📝 Commits (1) - [`28d2ecb`](https://github.com/morluto/rea/commit/28d2ecb0f346ca44de29770447fcc6c4456fe8ef) fix(source-maps): retain originals with partial source contents ### 📊 Changes **7 files changed** (+200 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `src/application/javascript/JavaScriptArtifactAnalysis.ts` (+2 -2) 📝 `src/domain/sourceMapContents.test.ts` (+8 -6) 📝 `src/domain/sourceMapContents.ts` (+2 -6) 📝 `src/javascript/sourceMaps/SourceMapFormat.ts` (+0 -12) 📝 `tests/acceptance/applications/sourceMapPrefixCli.test.ts` (+81 -0) 📝 `tests/boundary/browser/webSourceMapFetcher.test.ts` (+103 -1) 📝 `tests/boundary/filesystem/javascriptArtifactReconstruction.test.ts` (+4 -1) </details> ### 📄 Description ## Summary Fixes #2821. Retain original source declarations and available embedded text when `sourcesContent` has a different length from `sources`, in local application reconstruction and browser source-map collection. ## Problem and expected behavior With `sources: ["a.ts", "b.ts"]` and `sourcesContent: ["export const answer = 42;"]`, local CLI/MCP analysis discarded both originals; browser collection rejected the entire map. Padding the content array with `null` made the same declarations work. [ECMA-426 DecodeSourceMapSources](https://tc39.es/ecma426/#sec-decodesourcemapsources) reads content by source ordinal only when an entry exists. Missing content is unavailable, and excess entries do not introduce sources. This corrects the cardinality assumption retained by #2034; malformed field/element types remain invalid. ## Change and scope Remove source-count equality from the local content admission helper and its obsolete parameter/error wording. Remove the redundant browser-profile content check: the existing leaf schema already validates every supplied content entry, and raw content records are still budgeted before schema parsing. Both existing collectors continue iterating source declarations, preserving section-local and flattened ordinals without padding, compacting, or mutating raw map evidence. ## Contract and boundary impact - Semantic owner and earliest changed stage: source-map content admission; local source collection and shared browser leaf validation. - Contribution scope fit and linked maintainer decision: ordinary read-only format correction within existing workflows; separate maintainer scope decision not applicable. - CLI and MCP/tool-catalog contract: unchanged request and result schemas; valid maps now retain originals previously discarded. - Provider, bridge, target-format, or platform compatibility: version-3 regular/indexed source maps; no provider or bridge changes. - Evidence, artifact, provenance, or reconstruction contract: preserve exact map bytes/digest and source ordinals; unavailable content stays null, empty strings stay present, excess content creates no source. - Target selection, authority, upstream behavior, and cleanup details: existing file selection and allowed-origin policies remain in force; regression HTTP listener is closed in `finally`. - Generated metadata, package, or installation impact: none. Expected workflow effects: - [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. - [x] Contact network services (existing opt-in source-map collection). - [ ] 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 - Added compiled CLI and stdio MCP regressions for indexed leaves with short/empty/excess content arrays, explicit null and empty text, source ordinals and exact map/content digests. - Added real loopback HTTP collection coverage asserting retained raw map evidence, content availability and generated/source mapping ordinals across sections. - Kept scalar/non-string rejection and changed the obsolete empty-array rejection cases to malformed excess-element cases. Existing omitted/null content and resource-budget regressions pass. - Base reproduction: at `9680da76c84a6833635dc7a5df607806d899f804`, all 3 new regression cases failed while the other 79 cases in the two files passed. CLI/MCP returned 0 instead of 5 originals; HTTP returned `invalid` instead of `included`. - Public CLI reproduction from #2821: short and padded arrays now both produce `coverage: "complete", originals: 2` (short previously produced `partial`, 0). - Remaining proof gaps: no live CDP browser session was run; the production source-map HTTP fetch/parse boundary and public local CLI/MCP were exercised. No native engine is involved. - [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 ci --prefer-offline` and `npm run build:cached` — passed with Node 24.18.0 / npm 11.16.0 on WSL Ubuntu x86_64. - `npm run test:focused -- src/domain/sourceMapContents.test.ts src/javascript/sourceMaps/TraceSourceMap.test.ts src/application/javascript/JavaScriptArtifactAnalysis.sourceMaps.test.ts tests/acceptance/applications/sourceMapPrefixCli.test.ts tests/boundary/browser/webSourceMapFetcher.test.ts tests/boundary/filesystem/javascriptArtifactReconstruction.test.ts` — 121 passed across 6 files. - `npm run test:focused -- tests/boundary/browser/webSourceMapFetcher.test.ts` — final test-scope cleanup verified, 74 passed. - `npm run typecheck`, `npm run knip`, `npm run verify:module-boundaries`, `npm run verify:architecture-guards`, `npm run verify:test-discovery` — passed; all 1078 test files discovered exactly once. - `npx oxfmt --check` and `npx oxlint` over all 7 changed files — passed (no lint errors); `git diff --check` passed. - `npm run check` — blocked by unrelated baseline formatting in `tests/fixtures/javaClassFile.ts` and existing `max-lines-per-function` errors in `tests/boundary/providers/ghidra/ghidraLauncher.test.ts:431`, `src/ghidra/GhidraFunctionValues.test.ts:46`, and `src/domain/webBundleAnalyzer.test.ts:224`. Those files are unchanged here; the individual checks above completed separately because Turbo cancels peer tasks after failure. ## Compatibility, safety, and release - Breaking changes or migration steps: none; valid previously rejected maps are accepted. - Real Hopper/Ghidra, browser, or OS coverage: no native engine changes; real HTTP boundary on WSL Ubuntu, no live CDP claim. - Package or release metadata impact: none. - Security, privacy, process, or containment review: malformed content types remain invalid; network response/structure/evidence budgets and origin admission are unchanged. Extra content remains only in retained raw map bytes, not invented source artifacts. ## 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. - [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 (no changes required). - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. The same formatting failure and three lint errors were independently reproduced on a clean checkout of base `9680da7`. The normal pre-push hook failed on those same lint errors; after the checks above, this branch was pushed with that local hook disabled for the push only. ## Integration note Related independent fix: #2831. Both PRs target `main` and fix separate issues. Their deletions touch adjacent validation blocks in `SourceMapFormat.ts`; a local three-way merge reports a textual conflict between them. Once either merges, the other needs a small rebase retaining both removals. There is no semantic dependency, and the regression additions merge cleanly. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:06:31 +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#5422
No description provided.