[PR #4323] [MERGED] fix(javascript): resolve relative ESM backslash paths #6172

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4323
Author: @6eanut
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @morluto

Base: main ← Head: fix/esm-reference-path-4269


📝 Commits (1)

  • 361ef67 fix(javascript): resolve relative ESM backslash paths

📊 Changes

3 files changed (+75 additions, -11 deletions)

View changed files

📝 src/application/javascript/JavaScriptArtifactPathResolution.test.ts (+35 -0)
📝 src/application/javascript/JavaScriptArtifactPathResolution.ts (+5 -1)
📝 tests/boundary/filesystem/javascript-applications/javascriptModuleSpecifierPaths.test.ts (+35 -10)

📄 Description

Summary

Narrows this PR to the remaining relative ESM backslash case requested in the maintainer follow-up. Main already resolves #4269 via f2e5fd148; this revision keeps that implementation and drops the superseded source-import changes.

Problem and expected behavior

Node loads a relative import such as ./nested\direct.mjs as nested/direct.mjs, and historical reference lookup already finds it. Artifact analysis rejected the same request before URL parsing, leaving its graph edge unresolved. Both consumers should select the file loaded by Node while preserving the authored specifier.

Change and scope

Normalize raw backslashes inside the existing artifact ESM URL owner, only after the original request satisfies ./ or ../ relative-module admission. Existing URL parsing, encoded-separator/NUL checks and root confinement still own validity. Production changes are confined to one function; there is no replacement source parser or new helper layer.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: contextualCandidate() in JavaScriptArtifactPathResolution, before canonical-path admission and URL/root checks. Historical import already uses its own URL parser and remains on main's implementation; its distinct inventory-decoding policy is retained.
  • Contribution scope fit and linked maintainer decision: ordinary static-analysis fix; a new capability scope decision is not applicable. The requested focus is linked in Summary.
  • CLI and MCP/tool-catalog contract: no command/schema change; application graph imports gain the correct resolved_path for valid relative module URLs.
  • Provider, bridge, target-format, or platform compatibility: no new provider/bridge behavior. Verified on Linux with Node 24.22.1; Windows execution was not performed.
  • Evidence, artifact, provenance, or reconstruction contract: authored declared_path/graph specifiers and existing inventory identities are preserved. Historical source_specifier, literal-backslash filenames and decoding remain governed by main's existing contract.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): no new product execution or cleanup authority. Loader controls execute only self-authored temporary modules.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): no authored metadata, dependency or installation change.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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.
  • 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

  • Tests added or updated: eight resolver cases covering valid relative separators, parent traversal, preserved declarations and invalid inputs. The existing Node-backed matrix now includes static/dynamic raw-backslash controls, literal-name decoys and historical/application graph comparisons.
  • Base reproduction or other evidence: before the fix, resolver tests had 3 failures / 298 passes, and the boundary file had 1 failure / 26 passes: Node loaded the target while artifact analysis returned no resolved path. The changed production file is identical between the original tested base 9c9c64ed and final base 25b69bb8.
  • User-visible CLI/MCP output (if applicable): no output schema change. Node-backed application graph checks assert both the original specifier and resolved target; compiled historical CLI controls verify retained source semantics.
  • Remaining proof gaps: full suite and Windows execution were not run. Full npm run check is blocked by the pre-existing Knip findings listed below.

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

Covered: format assumptions and raw identity/normalization, including malformed encodings and confinement. Product resource lifecycle is unchanged; fixture cleanup uses the existing scoped helpers and subprocess timeouts.

For evidence-bearing changes:

  • 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

Toolchain: Node 24.22.1, npm 11.16.0; base 25b69bb803.

  • npm run test:focused -- src/application/javascript/JavaScriptArtifactPathResolution.test.ts tests/boundary/filesystem/javascript-applications/javascriptModuleSpecifierPaths.test.ts tests/boundary/cli/referenceSourceModuleSemantics.test.ts tests/boundary/cli/referenceSourceUtf8.test.ts — 336 passed, 4 files; includes actual Node static/dynamic loading.
  • npm run check:fast — typecheck and lint passed, 2/2 tasks.
  • node scripts/run-turbo.mjs run format:check metadata:check — 2/2 tasks passed.
  • npm run verify:architecture-guards — passed across 2,152 source files.
  • npm run lint:typed — zero errors; 3,762 warnings reported.
  • npm run verify:test-discovery — all 2,634 test files discovered exactly once.
  • Targeted V8 coverage of the resolver test file — 301 passed; resolver statement coverage 669/761 (87.91%), including execution of the new normalization statements.
  • npm run check — failed in Knip: unused staticFileUrlPath and exported type ObjcClassImportBindingCoverage. The same unused declarations are reproducible on an unmodified base; those files are outside this diff. Full check is not claimed as passed.
  • npm audit --json — one existing moderate fast-uri entry, zero high/critical; dependency files unchanged.
  • git diff --check — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux Node loader, application workflow and historical CLI controls executed. No real provider/browser/Windows workflow was exercised.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: relative module admission precedes separator conversion; encoded separators, NUL and above-root requests remain rejected by the artifact owner. CommonJS/compiler-dependent paths retain their existing handling.

Author readiness

Human owner: @6eanut

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

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.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff 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/4323 **Author:** [@6eanut](https://github.com/6eanut) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/esm-reference-path-4269` --- ### 📝 Commits (1) - [`361ef67`](https://github.com/morluto/rea/commit/361ef67cc2b45a698011dc7f5e6b840d2d433ed0) fix(javascript): resolve relative ESM backslash paths ### 📊 Changes **3 files changed** (+75 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `src/application/javascript/JavaScriptArtifactPathResolution.test.ts` (+35 -0) 📝 `src/application/javascript/JavaScriptArtifactPathResolution.ts` (+5 -1) 📝 `tests/boundary/filesystem/javascript-applications/javascriptModuleSpecifierPaths.test.ts` (+35 -10) </details> ### 📄 Description <!-- PR title: type(optional-scope): imperative outcome The title becomes the squash-merge commit subject and generated changelog entry. --> ## Summary Narrows this PR to the remaining relative ESM backslash case requested in the [maintainer follow-up](https://github.com/morluto/rea/pull/4323#issuecomment-6427983034). Main already resolves #4269 via f2e5fd148; this revision keeps that implementation and drops the superseded source-import changes. <!-- What user, agent, or maintainer problem does this solve? Link the issue with "Fixes #123" when applicable. Keep the prior behavior, expected contract, and new behavior understandable without private context. --> ## Problem and expected behavior Node loads a relative import such as `./nested\direct.mjs` as `nested/direct.mjs`, and historical reference lookup already finds it. Artifact analysis rejected the same request before URL parsing, leaving its graph edge unresolved. Both consumers should select the file loaded by Node while preserving the authored specifier. <!-- For fixes, give the smallest trigger and violated invariant. For features, describe the use case and observable outcome. --> ## Change and scope Normalize raw backslashes inside the existing artifact ESM URL owner, only after the original request satisfies `./` or `../` relative-module admission. Existing URL parsing, encoded-separator/NUL checks and root confinement still own validity. Production changes are confined to one function; there is no replacement source parser or new helper layer. <!-- Explain the chosen approach, why it fits REA's architecture, and what is intentionally not included. If adding complexity for a speculative or vanishingly unlikely race or security edge case, record the concrete failure mode, likelihood, complexity cost, and the user's buy-in obtained before implementation. Do not silently expand scope for theoretical robustness. --> Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). Unresolved scope, authority, side effects, or required verification block integration. Link the required maintainer scope decision for new providers or capabilities involving target execution, injection, mutation, or protection recovery; ordinary fixes within existing boundaries may state "not applicable". Draft PRs may leave the scope decision pending and the readiness and merge checklists unchecked. Maintainers can help resolve open questions. ## Contract and boundary impact <!-- Short answers are welcome. Complete applicable lines; mark unresolved facts as "unknown". Use "none" or "not applicable" only when established. --> - Semantic owner and earliest changed stage: `contextualCandidate()` in `JavaScriptArtifactPathResolution`, before canonical-path admission and URL/root checks. Historical import already uses its own URL parser and remains on main's implementation; its distinct inventory-decoding policy is retained. <!-- Name the producer of parsed facts or resources and its affected consumers. Summarize superseded paths removed and any distinct policy, lifecycle, lazy-loading, or compatibility responsibility retained. --> - Contribution scope fit and linked maintainer decision: ordinary static-analysis fix; a new capability scope decision is not applicable. The requested focus is linked in Summary. - CLI and MCP/tool-catalog contract: no command/schema change; application graph imports gain the correct `resolved_path` for valid relative module URLs. - Provider, bridge, target-format, or platform compatibility: no new provider/bridge behavior. Verified on Linux with Node 24.22.1; Windows execution was not performed. - Evidence, artifact, provenance, or reconstruction contract: authored `declared_path`/graph specifiers and existing inventory identities are preserved. Historical `source_specifier`, literal-backslash filenames and decoding remain governed by main's existing contract. - Target selection, authority, upstream behavior, and cleanup details (if applicable): no new product execution or cleanup authority. Loader controls execute only self-authored temporary modules. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact (CI generates and validates ignored catalogs and `skills/`; edit authored instructions in `.agents/skills/reverse-engineer-anything/` and never commit build outputs): no authored metadata, dependency or installation change. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [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. - [ ] Contact network services. - [ ] 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 <!-- State whether evidence is executed, source-derived, or proposed. For fixes, show the original failure and explain how the regression would fail on the affected base revision when practical. Include the most useful proof inline; link long logs or artifacts, or put them in optional details. Documentation-only changes can use source, link, or rendered-document checks. --> - Tests added or updated: eight resolver cases covering valid relative separators, parent traversal, preserved declarations and invalid inputs. The existing Node-backed matrix now includes static/dynamic raw-backslash controls, literal-name decoys and historical/application graph comparisons. - Base reproduction or other evidence: before the fix, resolver tests had 3 failures / 298 passes, and the boundary file had 1 failure / 26 passes: Node loaded the target while artifact analysis returned no resolved path. The changed production file is identical between the original tested base 9c9c64ed and final base 25b69bb8. - User-visible CLI/MCP output (if applicable): no output schema change. Node-backed application graph checks assert both the original specifier and resolved target; compiled historical CLI controls verify retained source semantics. - Remaining proof gaps: full suite and Windows execution were not run. Full `npm run check` is blocked by the pre-existing Knip findings listed below. For boundary fixes, identify the applicable [boundary regressions](https://github.com/morluto/rea/blob/main/docs/testing.md#boundary-regressions) and [lifecycle regressions](https://github.com/morluto/rea/blob/main/docs/testing.md#lifecycle-regressions) covered by the evidence above, and explain relevant gaps. Covered: format assumptions and raw identity/normalization, including malformed encodings and confinement. Product resource lifecycle is unchanged; fixture cleanup uses the existing scoped helpers and subprocess timeouts. For evidence-bearing changes: - [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 <!-- List only commands that actually ran, with observed results. Include the relevant real-provider or platform workflow, or explain why it was unavailable. Keep these results current after changes; a command without its result is incomplete. --> Toolchain: Node 24.22.1, npm 11.16.0; base 25b69bb803ffe337cca705629ec88cd220ca09a7. - `npm run test:focused -- src/application/javascript/JavaScriptArtifactPathResolution.test.ts tests/boundary/filesystem/javascript-applications/javascriptModuleSpecifierPaths.test.ts tests/boundary/cli/referenceSourceModuleSemantics.test.ts tests/boundary/cli/referenceSourceUtf8.test.ts` — **336 passed**, 4 files; includes actual Node static/dynamic loading. - `npm run check:fast` — typecheck and lint passed, 2/2 tasks. - `node scripts/run-turbo.mjs run format:check metadata:check` — 2/2 tasks passed. - `npm run verify:architecture-guards` — passed across 2,152 source files. - `npm run lint:typed` — zero errors; 3,762 warnings reported. - `npm run verify:test-discovery` — all 2,634 test files discovered exactly once. - Targeted V8 coverage of the resolver test file — 301 passed; resolver statement coverage **669/761 (87.91%)**, including execution of the new normalization statements. - `npm run check` — failed in Knip: unused `staticFileUrlPath` and exported type `ObjcClassImportBindingCoverage`. The same unused declarations are reproducible on an unmodified base; those files are outside this diff. Full check is **not** claimed as passed. - `npm audit --json` — one existing moderate `fast-uri` entry, zero high/critical; dependency files unchanged. - `git diff --check` — passed. ## Compatibility, safety, and release <!-- Call out breaking changes, migrations, package effects, platform/provider limits, security/privacy/containment implications, and meaningful proof gaps. --> - Breaking changes or migration steps: none. <!-- For ! / BREAKING CHANGE: show a previously valid call/configuration, its new behavior and migration, and why compatibility/deprecation cannot preserve it. Every release increments minor, including breaking changes; keep breaking markers and migration notes so callers can assess compatibility. See docs/releasing.md. --> - Real Hopper/Ghidra, browser, or OS coverage: Linux Node loader, application workflow and historical CLI controls executed. No real provider/browser/Windows workflow was exercised. - Package or release metadata impact: none. - Security, privacy, process, or containment review: relative module admission precedes separator conversion; encoded separators, NUL and above-root requests remain rejected by the artifact owner. CommonJS/compiler-dependent paths retain their existing handling. ## Author readiness <!-- The human owner completes these declarations before requesting review. The PR author is the owner by default. A different owner must explicitly accept ownership on this PR. AI agents must leave these declarations to a human to dictate to them or there could be catastrophic consequences for many users of REA. Draft PRs may leave them unchecked. These declarations record initial readiness when opening the PR for review; later pushes do not require a new human sign-off. Keep the description and validation evidence current as the work changes. See CONTRIBUTING.md#pull-request-ownership-and-readiness. --> Human owner: @6eanut - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge <!-- Draft PRs may leave pending items unchecked. Resolve material scope and authority questions before integration. --> - [ ] 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. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff 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 01:12:25 +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#6172
No description provided.