Repository navigation
fix(javascript): match source-map originals that name parent directories - #1215
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50642d0282
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Pushed b48702a for maps in a nested directory: a source-map entry starting with |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b48702a4ee
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75f0c9d314
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 819579cc9f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0118c44461
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2a9dde0cc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 89fd82dd12
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| mapPath?: string, | ||
| ): SourceMapPath | null => { | ||
| const portable = source.replaceAll("\\", "/"); | ||
| const windowsPath = /^[a-z]:\//iu.test(portable) || source.startsWith("\\\\"); |
There was a problem hiding this comment.
Preserve relative Windows source-map filename syntax
When a supported relative Windows declaration contains literal URL punctuation (for example, a map at pkg/maps/main.map names ..\src\a%23b.js), windowsPath is false because this detector accepts only drive-qualified and UNC paths. The declaration then goes through URL path processing, which decodes %23 (and would treat # as a fragment), projecting pkg/src/a#b.js instead of the real pkg/src/a%23b.js; with changed or absent sourcesContent, the high path signal can select that decoy and the actual file can be reported removed under complete coverage. The newly added ..\src\a.js boundary case establishes that relative backslash declarations are supported, so retain their raw Windows filename semantics while resolving them against the map directory.
AGENTS.md reference: AGENTS.md:L59-L59
Useful? React with 👍 / 👎.
N0zoM1z0
left a comment
There was a problem hiding this comment.
Reviewed 89fd82d integrated with main and #1216. All 64 focused tests pass, covering nested/merged maps, URI and Windows/UNC declarations, literal filesystem punctuation and rejected path projections. The sourceRoot case matches the pinned TraceMap resolver.
Actual CLI and stdio MCP agree: changed source → modified, equal digest → unchanged, missing digest → unknown, two current sources → split; the same-basename decoy gets no strong path signal. Raw declarations remain preserved. All 23 CI checks pass.
|
Thank you for fixing parent directory source map matching. I went through how normalizeCurrentPath now collapses dot dot segments lexically and resolves leading parent entries against the map file directory, so Rollup style ../src/a.js maps correctly for path signals only. The nested directory boundary test that fails without the change shows the care here. Really appreciate it. |
…ies (morluto#1215) * fix(javascript): match source-map originals that name parent directories * fix(javascript): resolve parent segments against the source map's directory * fix(javascript): resolve source originals against their map location * fix(javascript): preserve URI and empty source map path semantics * fix(javascript): separate source URL paths from opaque URI payloads * fix(javascript): preserve filesystem names during URI classification * style(javascript): format source URI presence guard * fix(javascript): resolve source map references with URL semantics * fix(javascript): preserve literal UNC source map paths --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Summary
compare-source-to-bundlenever matches a historical source file to a source-map original when the map names it relative to the map's own directory, such as../src/a.js. Rollup, Vite, esbuild and rolldown writesourcesthis way by default, so for their bundles every source file loses its path evidence.Problem and expected behavior
Trigger:
dist/main.jswithdist/main.js.mapwhosesourcesis["../src/a.js"], compared with a reference tree containingsrc/a.js.Before:
normalizeCurrentPathreturnsnullfor any path that contains a..segment (src/domain/javascript/sourceToBundleSignals.ts:287), so thesource-modulenode gets no path, suffix or basename entries. An editedsrc/a.jsis reported asunknownwith "No candidate was observed, but incomplete input or graph coverage prevents a removal claim." An unedited file is still found, but only through its digest.Expected:
../src/a.jsis the same location assrc/a.jsfor matching, so the node gets asource-map-original-pathsignal forsrc/a.js.Change and scope
normalizeCurrentPathnow collapses..segments lexically instead of discarding the whole path; entries starting with../are resolved against the map file's directory first. The value is used only for path matching and for the signal'scurrent_values, never to read a file. Scoring, weights and classification are unchanged.Contract and boundary impact
sourceToBundleSignals.ts)...segments now produce path signals;current_valuesshow the collapsed path.docs/public/product-catalog.json), package, or installation impact: none.Evidence and regression coverage
matches source-map originals named relative to the mapintests/boundary/filesystem/sourceToBundlePaths.test.ts(real analyzer on adist/main.js+ map withsources: ["../src/a.js"]). It fails on current main and passes with this change. The existing test there now shares a small helper.sources: ["../src/a.js","../src/main.js"]) andsrc/a.jsedited in the reference tree, on main and on rea-agents 6.0.0:src/a.js unknown unknown ['No candidate was observed, ...']. With this change thesource-modulecandidate carriessource-map-original-pathandcurrent-path-exactforsrc/a.js(score 155, confidence high).unknown("comparable source digests are unavailable"); that classification is a separate bug inclassifyMapping, fixed in a separate PR. With both changes the edited file is reportedmodified.Validation performed
npm run test:focused -- tests/boundary/filesystem/sourceToBundlePaths.test.ts— 3 passed; the new test fails with the fix reverted.npx vitest run src/domain/javascript/— 512 passed.npm run check:fast— passed.npx vitest run(afternpm run build:cached) — 5316 passed; the 10 failures are firmware (local Binwalk is not 3.1.x) and two ASAR reconstruction tests, which fail the same way on untouched main here.src/a.jsnow has thesource-map-original-pathcandidate;src/main.jsstaysunchanged.Compatibility, safety, and release