[PR #1046] [MERGED] fix(javascript): resolve root package exports arrays #2605

Closed
opened 2026-10-17 21:08:08 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1046
Author: @ac1982
Created: 10/8/2026
Status: ✅ Merged
Merged: 10/8/2026
Merged by: @N0zoM1z0

Base: main ← Head: fix/package-exports-arrays


📝 Commits (2)

  • 8ca5f2b fix(javascript): resolve root package exports arrays
  • c239c04 chore: synchronize exports array fix with merged main

📊 Changes

3 files changed (+26 additions, -4 deletions)

View changed files

📝 docs/javascript-artifact-reconstruction.md (+4 -0)
📝 src/application/javascript/JavaScriptArtifactPathResolution.ts (+2 -4)
📝 tests/boundary/filesystem/javascriptPackagePrecedence.test.ts (+20 -0)

📄 Description

Summary

Fixes #1041. Resolve package exports arrays at the top level and under the root "." subpath using the existing exports-target walker.

Problem and expected behavior

A package with exports: ["./actual.cjs"] resolves in Node but REA reports unavailable/invalid package metadata. The same happens for { ".": ["./actual.cjs"] }. Valid arrays should select the same target as Node rather than falling back to legacy index files.

Change and scope

Remove the two premature array rejections from packageExport. The existing recursive exportTargets implementation already handles ordered arrays, invalid entries, unmatched conditions, and nested arrays. Add four filesystem regressions that compare production reconstruction directly with createRequire(...).resolve(...), retaining the existing legacy-resolution cases.

Contract and boundary impact

  • Semantic owner and earliest changed stage: application package-exports target selection.
  • CLI and MCP/tool-catalog contract: unchanged schemas/tools; corrected graph resolutions.
  • Provider, bridge, target-format, or platform compatibility: static JavaScript package metadata only.
  • Evidence, artifact, provenance, or reconstruction contract: preserve actual selected artifact and provenance; valid exports arrays no longer produce invalid-JSON diagnostics.
  • Process execution, authorization, cleanup, or containment impact: none.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Tests: top-level array, root-subpath array, invalid/unmatched entries before a valid target, nested array with a require condition.

  • Base reproduction: four new cases failed while 13 existing cases passed; each Node oracle selected the actual target successfully.

  • Built CLI: analyze-javascript-application <temporary-directory> --json for require("fixture") with exports ["./actual.cjs"] emitted resolution_status: "resolved", resolved_path: "node_modules/fixture/actual.cjs" even with an index fallback present.

  • Remaining proof gaps: no live binary providers or non-Linux execution; static package resolution only.

  • 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

Node 24.18.0 / npm 11.16.0, Linux arm64.

  • npm run test:focused -- tests/boundary/filesystem/javascriptPackagePrecedence.test.ts src/application/javascript/JavaScriptArtifactPathResolution.test.ts — 46 passed; includes production build prerequisite.
  • npm run check — all six tasks passed.
  • Built CLI reproduction above — passed.

Compatibility, safety, and release

No breaking schema changes, migrations, package metadata, authentication, or process changes. Real Hopper/Ghidra and browser workflows were not run because provider behavior is unchanged. Target traversal semantics remain owned by the existing walker.

Review checklist

  • One focused outcome; conventional title.
  • Related issue linked.
  • Tests cover changed observable behavior against Node.
  • Owning documentation updated; generated metadata unchanged.
  • Representative CLI output reported above.
  • Final diff checked for secrets, unrelated cleanup, and unsupported claims.

Prepared with OpenAI Codex assistance.


🔄 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/1046 **Author:** [@ac1982](https://github.com/ac1982) **Created:** 10/8/2026 **Status:** ✅ Merged **Merged:** 10/8/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `fix/package-exports-arrays` --- ### 📝 Commits (2) - [`8ca5f2b`](https://github.com/morluto/rea/commit/8ca5f2b02dd75aac8bc9aa4f52d6f03bc6e6cda4) fix(javascript): resolve root package exports arrays - [`c239c04`](https://github.com/morluto/rea/commit/c239c04cf31b7b622c2bf81f3aa767e0f711a7e9) chore: synchronize exports array fix with merged main ### 📊 Changes **3 files changed** (+26 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `docs/javascript-artifact-reconstruction.md` (+4 -0) 📝 `src/application/javascript/JavaScriptArtifactPathResolution.ts` (+2 -4) 📝 `tests/boundary/filesystem/javascriptPackagePrecedence.test.ts` (+20 -0) </details> ### 📄 Description ## Summary Fixes #1041. Resolve package `exports` arrays at the top level and under the root `"."` subpath using the existing exports-target walker. ## Problem and expected behavior A package with `exports: ["./actual.cjs"]` resolves in Node but REA reports unavailable/invalid package metadata. The same happens for `{ ".": ["./actual.cjs"] }`. Valid arrays should select the same target as Node rather than falling back to legacy index files. ## Change and scope Remove the two premature array rejections from `packageExport`. The existing recursive `exportTargets` implementation already handles ordered arrays, invalid entries, unmatched conditions, and nested arrays. Add four filesystem regressions that compare production reconstruction directly with `createRequire(...).resolve(...)`, retaining the existing legacy-resolution cases. ## Contract and boundary impact - Semantic owner and earliest changed stage: application package-exports target selection. - CLI and MCP/tool-catalog contract: unchanged schemas/tools; corrected graph resolutions. - Provider, bridge, target-format, or platform compatibility: static JavaScript package metadata only. - Evidence, artifact, provenance, or reconstruction contract: preserve actual selected artifact and provenance; valid exports arrays no longer produce invalid-JSON diagnostics. - Process execution, authorization, cleanup, or containment impact: none. - Generated metadata, package, or installation impact: none. ## Evidence and regression coverage - Tests: top-level array, root-subpath array, invalid/unmatched entries before a valid target, nested array with a require condition. - Base reproduction: four new cases failed while 13 existing cases passed; each Node oracle selected the actual target successfully. - Built CLI: `analyze-javascript-application <temporary-directory> --json` for `require("fixture")` with exports `["./actual.cjs"]` emitted `resolution_status: "resolved"`, `resolved_path: "node_modules/fixture/actual.cjs"` even with an index fallback present. - Remaining proof gaps: no live binary providers or non-Linux execution; static package resolution only. - [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 Node 24.18.0 / npm 11.16.0, Linux arm64. - `npm run test:focused -- tests/boundary/filesystem/javascriptPackagePrecedence.test.ts src/application/javascript/JavaScriptArtifactPathResolution.test.ts` — 46 passed; includes production build prerequisite. - `npm run check` — all six tasks passed. - Built CLI reproduction above — passed. ## Compatibility, safety, and release No breaking schema changes, migrations, package metadata, authentication, or process changes. Real Hopper/Ghidra and browser workflows were not run because provider behavior is unchanged. Target traversal semantics remain owned by the existing walker. ## Review checklist - [x] One focused outcome; conventional title. - [x] Related issue linked. - [x] Tests cover changed observable behavior against Node. - [x] Owning documentation updated; generated metadata unchanged. - [x] Representative CLI output reported above. - [x] Final diff checked for secrets, unrelated cleanup, and unsupported claims. Prepared with OpenAI Codex assistance. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:08:08 +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#2605
No description provided.