Skip to content

fix(javascript): resolve root package exports arrays - #1046

Merged
N0zoM1z0 merged 2 commits into
morluto:mainfrom
ac1982:fix/package-exports-arrays
Oct 8, 2026
Merged

N0zoM1z0 merged 2 commits into
morluto:mainfrom
ac1982:fix/package-exports-arrays

Conversation

@ac1982

@ac1982 ac1982 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

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.

@N0zoM1z0 N0zoM1z0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the complete patch and traced root exports selection through the existing ordered target walker and artifact resolver. The two removed array rejections fix #1041; the existing array semantics correctly retain declaration order and target refusal.

Independent verification at final head c239c04cf31b7b622c2bf81f3aa767e0f711a7e9:

  • Fresh locked install and production build with Node 24.18.0/npm 11.16.0 on Linux x64.
  • Three focused files: 54 tests passed, including the package filesystem/Node oracle cases, URI/path resolution, and the complete post-SDK input compatibility guard from merged #919.
  • Full standalone typecheck, lint/module-boundary checks, and generated-document checks passed.
  • Eight actual CLI/MCP analyses produced identical results and matched Node: top-level/root/nested arrays, invalid and unmatched entries, empty/blocked arrays, target order, and first-target absence. Empty or blocked arrays did not use index fallback; a missing first target did not select a later target.

The only follow-up was synchronizing merged main and retaining both documentation paragraphs in the conflict. The final diff remains the original three files; no generated MCP catalog is tracked. #1040 target validation remains a separate issue.

The original head's complete CI passed. Fresh CI is now running for this final follow-up head; merge will wait for those exact results.

@N0zoM1z0
N0zoM1z0 merged commit 53409ab into morluto:main Oct 8, 2026
23 checks passed
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
@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.

[Bug] Top-level package exports arrays are rejected as invalid JSON

3 participants