Skip to content

fix(javascript): normalize package URLs before array selection - #1916

Merged
morluto merged 1 commit into
mainfrom
codex/package-target-url-fallback
Oct 11, 2026
Merged

morluto merged 1 commit into
mainfrom
codex/package-target-url-fallback

Conversation

@morluto

@morluto morluto commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Summary

Package imports and exports now normalize each relative target as a URL before deciding whether an array entry escapes the package root. A target such as ["./.\t./outside.cjs", "./fallback.cjs"] selects fallback.cjs, matching Node, instead of losing the edge as not-found.

Follow-up to #1862 for its final review finding, posted after that PR merged.

Problem and expected behavior

The selector checked raw path segments, then committed to a string before URL normalization. Node removes tabs and newlines while constructing the URL, validates package-root containment, and skips an invalid target while array fallback is still available. Decoding and file lookup failures happen after selection and must retain the first selected target's failure.

Change and scope

The shared application selector retains the original target and its normalized URL. Imports and exports use that URL for containment and lookup, with inventory path segments encoded when constructing the package base. This also preserves package filenames containing spaces, Unicode, and URL punctuation. Failed lookups retain the original target and metadata path in their limitations.

CommonJS validates encoded separators across the selected serialized URL; ESM validates its pathname. Those errors and missing files do not select a later array entry. Wildcard expansion, recursive aliases, and external-package import targets keep their existing scope.

Contract and boundary impact

  • Semantic owner and earliest changed stage: JavaScriptArtifactPathResolution target selection, before array fallback is decided.
  • CLI and MCP/tool-catalog contract: existing graph and Evidence fields; no schema or tool-name changes.
  • Provider, bridge, target-format, or platform compatibility: static JavaScript artifact analysis; no provider or bridge changes.
  • Evidence, artifact, provenance, or reconstruction contract: retain the original declaration, target text, metadata path, importing source range, and digest; normalize only the derived lookup URL.
  • Process execution, authorization, cleanup, or containment impact: no new runtime execution; package-root containment is checked before selection and artifact/container confinement remains enforced.
  • Generated metadata, package, or installation impact: none; generated catalogs and build outputs remain uncommitted.

Evidence and regression coverage

  • Tests added or updated: Node 24.18 require/import comparisons for tab/CR/LF escapes, normalized filenames, trailing whitespace, query/fragment suffixes, package-path punctuation, and targets that normalize back inside their package. Refusal cases cover encoded separators, missing files, and retained raw target diagnostics.
  • Base reproduction or other evidence: added regressions failed before the fix on the feat(javascript): resolve exact package import aliases #1862 branch; Node selected a fallback or normalized file where REA returned not-found.
  • User-visible CLI/MCP output: both compiled surfaces retain #tab-escape and #newline-escape edges to config.cjs; missing normalized targets retain not-found and their original target text.
  • Remaining proof gaps: native Windows execution was not run locally. Provider-engine verification does not apply to this static resolver.

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

  • npm ci — passed with the pinned Node 24.18.0/npm 11.16.0 toolchain.
  • npm run test:focused -- src/domain/javascript/javascriptPackageImportAliases.test.ts src/application/javascript/JavaScriptArtifactPathResolution.test.ts tests/boundary/javascript/packageImportAliases.test.ts tests/boundary/javascript/packageConditionalExports.test.ts tests/acceptance/applications/packageImportAliasesCli.test.ts tests/acceptance/applications/packageSubpathsCli.test.ts tests/acceptance/applications/packageJsonImports.test.ts — 225 tests passed across seven files on current main plus this commit, including compiled CLI/stdio MCP journeys.
  • npm run check — passed, including architecture guards; zero lint errors.
  • npm run docs:check — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; previously missed valid package targets now resolve with Node's URL normalization and fallback order.
  • Real Hopper/Ghidra, browser, or OS coverage: Node resolver oracles and public CLI/MCP workflows ran on macOS arm64. No real-provider behavior changes are claimed.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no network access, installation, or target execution is added to analysis; selected targets remain confined to the owning package and inventoried container.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T17:36:16.338596Z 04c9a59 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@morluto
morluto merged commit 369cd3d into main Oct 11, 2026
28 of 29 checks passed
@morluto
morluto deleted the codex/package-target-url-fallback branch October 11, 2026 17:36
@github-actions github-actions Bot mentioned this pull request Oct 11, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: build Build, CI, packaging, and publishing labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: build Build, CI, packaging, and publishing bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant