Skip to content

fix(javascript): preserve namespace re-export relationships - #1833

Merged
morluto merged 2 commits into
morluto:mainfrom
shoyann:fix/javascript-namespace-reexports
Oct 11, 2026
Merged

morluto merged 2 commits into
morluto:mainfrom
shoyann:fix/javascript-namespace-reexports

Conversation

@shoyann

@shoyann shoyann commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #1831.

JavaScript namespace re-exports such as export * as ns from "./dependency.mjs" were absent from semantic module links and exported-name inventories even when coverage reported complete. Retain the namespace binding and its dependency relationship through the shared producer, CLI, and MCP graph.

Problem and expected behavior

Node exposes ns, but REA previously reported zero export relationships and no export names for that declaration. Static file dependencies were already present. The semantic graph should preserve the imported namespace (*), declared exported name, source specifier, and original source evidence.

Change and scope

Extend collectNamedExports to handle value ExportNamespaceSpecifier declarations using the existing re-export representation. Namespace re-exports have no local binding; TypeScript export type * as Types declarations are excluded because they are erased at runtime. Named exports and ordinary star re-exports continue through their existing paths; no schema or resolution policy changes are needed.

Contract and boundary impact

  • Semantic owner and earliest changed stage: JavaScript semantic module-link projection.
  • CLI and MCP/tool-catalog contract: unchanged schemas; both surfaces now report the omitted namespace export and resolved relationship.
  • Provider, bridge, target-format, or platform compatibility: ordinary ESM source syntax, including string-literal namespace export names; no provider or platform changes.
  • Evidence, artifact, provenance, or reconstruction contract: preserve source digest and specifier range on the export observation and exposing edge.
  • Process execution, authorization, cleanup, or containment impact: none; production analysis remains static, and Node executes only test-owned fixtures as an oracle.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Added real Node/stdio MCP/CLI regressions covering identifier and string-literal namespace export names alongside named and ordinary star controls, plus a mixed .mts barrel with erased type-only and retained value namespace exports. Its type-only dependency throws if executed; Node confirms it is not loaded.

  • On base 76e4153, the public workflow test failed because the barrel exposed only two of its four declared export relationships; the standalone minimal CLI fixture reported export_names: [], export_relationships: 0, and complete coverage.

  • Corrected representative module fields: {"export_names":["ns"],"export_relationships":1}. The namespace relationship has imported_name: "*", exported_name: "ns", and local_name: null.

  • Assertions cover resolved dependency edges, artifact digests, exact source ranges, and complete coverage.

  • Remaining proof gaps: executed under Node 24.18.0 / npm 11.16.0 on WSL Ubuntu x64; no native Windows/macOS run claimed.

  • 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 run test:focused -- tests/acceptance/applications/exportedFunctionBindingsCli.test.ts src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts src/domain/javascript/javascriptSemanticAnalysis.require_links.test.ts tests/composition/javascript-applications/javascriptModuleRelationships.test.ts — 111/111 passed.
  • npm run check — passed, including typecheck, formatting, lint, module boundaries, and architecture guards (lint warnings, zero errors).
  • git diff --check — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: WSL Ubuntu, actual Node evaluation, compiled CLI and stdio MCP; optional providers are not involved.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new production execution or filesystem authority.

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 (existing contract unchanged).
  • 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-11T14:18:23.218771Z 9812dcd New commits
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 429e7392c4

ℹ️ 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".

if (t.isExportSpecifier(specifier))
if (
t.isExportSpecifier(specifier) ||
t.isExportNamespaceSpecifier(specifier)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exclude erased namespace type exports

When a .ts/.mts file contains export type * as Types from "./types.js", Babel represents the specifier as an ExportNamespaceSpecifier while node.exportKind is "type", so this new arm emits the same value-level re-export link as export * as Types. addJavaScriptSourceModules then counts Types in export_relationships and export_names and marks the graph complete, although TypeScript/Node type stripping produces no such export; gate this arm on the non-type export kind (or retain the type kind explicitly rather than treating it as a value export).

AGENTS.md reference: AGENTS.md:L17-L17

Useful? React with 👍 / 👎.

@morluto
morluto merged commit 37a9eb9 into morluto:main Oct 11, 2026
28 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 11, 2026
3 tasks done
@morluto

morluto commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Thanks for filling in the namespace re-export path, @shoyann. export * as ns from ... now contributes the * import and ns exported name to the module graph, with source range and digest provenance intact. The CLI/MCP fixture also checks that erased type-only namespace exports stay out.

@morluto morluto added bug Something isn't working area: domain Domain logic, errors, and pure functions labels Oct 14, 2026
@morluto morluto added the area: evidence Evidence, artifacts, and reconstruction label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions area: evidence Evidence, artifacts, and reconstruction bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] JavaScript namespace re-exports are omitted from complete semantic graphs

2 participants