Repository navigation
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. |
14a1f22 to
ef91773
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 14a1f22f34
ℹ️ 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".
| "Percent signs are not admitted in ES module package names.", | ||
| ]); | ||
| const self = commonJsSelfCandidate(input, declared); | ||
| const self = packageSelfCandidate(input, declared); |
There was a problem hiding this comment.
Preserve suffixes while matching ESM self-export keys
When an ESM self import contains a query or fragment (for example, import "pkg/feature?raw"), declared has already been passed through stripQueryAndFragment in contextualCandidate before this call. Node includes that suffix in the package subpath, so an exports map such as { "./feature": "./plain.js", "./feature?raw": "./raw.js" } loads raw.js; this path instead resolves plain.js (or reports the import unmatched if only the suffixed key exists), producing a wrong graph edge. Keep the original specifier for self-export key selection and strip only the selected target URL afterward.
AGENTS.md reference: AGENTS.md:L11-L11
Useful? React with 👍 / 👎.
| declared: string, | ||
| ): CandidateResolution | null => { | ||
| if (input.moduleKind !== "require" || !input.files.has(input.sourcePath)) | ||
| if (input.moduleKind === undefined || !input.files.has(input.sourcePath)) |
There was a problem hiding this comment.
Require an exact parsed package-name match for ESM self references
When the nearest package has a slash-bearing noncanonical name that merely prefixes the import (for example, metadata name: "@scope" and an import of @scope/pkg), admitting import here reuses the CommonJS prefix test below and incorrectly selects local exports["./pkg"]. The ESM resolver parses the requested package name as @scope/pkg and only self-resolves on exact equality, so with an inventoried node_modules/@scope/pkg dependency REA now records the wrong local target. Preserve the prefix behavior for require, but compare metadata.name with the parsed barePackageName(declared) for imports.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
|
Superseded by #1939, which retains your implementation commit, integrates it with #1888 and #1887 on current main, and adds the missing suffixed ESM self-reference interaction checked against real Node. The combined CLI/MCP and boundary checks passed; #1881 remains linked for closure when the integration merges. |
Summary
ESM package self-references were marked external even when the package's exact exported files were inventoried. Resolve them through the nearest package's
nameandexportsbefore dependency lookup, using the import loader's conditions. Fixes #1881.Problem and expected behavior
import { answer } from "rea-self-fixture/feature"loads successfully in Node, but previously producedresolved_path: nullandresolution_status: "external". It now resolves to the exported internal file and retains its binding relationship and source provenance.Change and scope
Reuse the existing self-reference scope walk and exports selector for both named loaders. Rename the former CommonJS-only helper to describe its shared responsibility. Keep the existing nearest-package, container-identity, blocked-export, and exact-target rules.
Contract and boundary impact
Evidence and regression coverage
New compiled CLI and stdio MCP acceptance coverage checks package-root/subpath self imports, different import/require targets, and original source digest/location.
A real Node subprocess independently loads the same source-owned fixture and prints
11 22.On base
fb94d9dde0ccda83ae520ac6fb22b1d283562cf3, both new surface tests failed because the expected internal imports were external. Both pass after the fix.Existing CommonJS self-reference, nearest-package-scope, foreign-container, blocked/missing exports, and package-subpath tests pass.
Review: self-review of the fixed base, complete patch, and new acceptance test; no actionable findings.
Remaining proof gaps: full deterministic coverage is left to upstream CI; real native engines and browser runtime are outside this static resolution change.
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
All local checks used Node 24.18.0 / npm 11.16.0 on macOS 27.0.1 arm64.
npm run test:focused -- tests/acceptance/applications/packageSelfReferencesCli.test.tsbefore the production fix — 2 expected regression failures.npm run test:focused -- tests/acceptance/applications/packageSelfReferencesCli.test.ts tests/acceptance/applications/packageSubpathsCli.test.ts tests/boundary/javascript/packageConditionalExports.test.ts src/application/javascript/JavaScriptArtifactPathResolution.test.ts— 152 tests passed across 4 files, including freshly built CLI/MCP workflows.npm run check— passed typecheck, lint, formatting, knip, metadata, module boundaries, and architecture guards; 758 lint warnings, zero errors.npm run verify:test-discovery— all 843 test files discovered exactly once.git diff --check— passed.action_required); no CI jobs have executed. This is not counted as a passing check.Compatibility, safety, and release
Review checklist