Skip to content

fix(javascript): preserve import-equals declaration and export evidence - #2062

Merged
baron merged 6 commits into
morluto:mainfrom
xu91102:fix/typescript-import-equals-dependencies
Oct 12, 2026
Merged

baron merged 6 commits into
morluto:mainfrom
xu91102:fix/typescript-import-equals-dependencies

Conversation

@xu91102

@xu91102 xu91102 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Recognize the import-equals alias as a declaration, retain its legacy require reference, and preserve the require branch on both direct exported values and exported local aliases in CTS/MTS. Keep the original source evidence and exported value.

Fixes #2058

Problem and expected behavior

An import-equals declaration incorrectly produced a read at its identifier, while the legacy reference producer omitted the dependency. For export import typed = require("typed-package") in MTS, the direct require link chose the require branch but its exported-binding association could fall back to the import branch. The same failure occurred for import raw = require("typed-package"); const alias = raw; export { alias }; when only the direct binding retained the mode.

Change and scope

Main integrated the original import-equals lookup and fixed CTS/MTS module formats in e4532b5. Retain those shared implementations. Recognize import-equals identifiers as declarations, retain require provenance through aliases/member/destructure propagation, and finalize local exports from already computed immutable binding provenance. Normalize implicit CTS static-import origins before deduplication so a static import and import-equals of the same package retain their shared exported association. Preserve MTS ambiguity when import and require select different targets. Synchronize the shared strict private module-link vocabulary for compatibility with #2060; this branch does not add an inline-type producer.

CI baseline: the prior failures were independently reproduced on c22111e. Upstream commit 621cee1 (PR #2137) now fixes the same warm-only completion fixture expectations. Merge that commit and retain its exact test/verifier implementation. The final contribution contains no completion-fixture or package-verifier changes relative to pinned main 621cee1.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Domain identifier classification, legacy dependency production, and exported-binding finalization; the artifact resolver consumes the retained loader.
  • CLI and MCP/tool-catalog contract: public schemas and operations unchanged. Retained resolution_mode is visible on relationship properties; fix(javascript): preserve TypeScript resolution modes and native type erasure #2060 also distinguishes inline type-import associations from runtime imports.
  • Provider, bridge, target-format, or platform compatibility: local source analysis; no provider or bridge changes.
  • Evidence, artifact, provenance, or reconstruction contract: original source bytes, SHA, declarations and ranges preserved. Private worker schemas remain strict.
  • Process execution, authorization, cleanup, or containment impact: none in production. Native controls use owned fixtures and repository temporary-directory cleanup.
  • Generated metadata, package, or installation impact: none; no generated artifacts committed.

Evidence and regression coverage

  • Tests updated: Extend the existing unboundRequires CLI/MCP workflow and domain binding/reference regression. Actual TypeScript NodeNext emission and external Node consumers of both CTS and MTS direct exports and local aliases print "42 42"; the same package import branch contains 99. Check require and exported-binding associations, exports/exposes, fixed formats, source SHA/ranges and type-only erasure. The domain regression retains exactly the real alias read; internal aliases and type-only declarations do not create external runtime dependencies.

  • Executed evidence: The domain false-read assertion failed before the declaration fix. Both public workflows failed before legacy retention and again before export-mode propagation, then passed after the respective corrections. The exported local-alias scenario additionally produced two valid RED failures after TypeScript/Node controls passed, and is now GREEN through both public workflows. Native compiler/Node controls ran before graph assertions. The original issue fixture was replayed twice with source-digest checks.

  • User-visible CLI/MCP output: The require relationship and exported typed and alias associations all resolve to node_modules/typed-package/actual.cjs; typed stays exported. CTS reports commonjs and MTS reports esm. Type-only imports produce no runtime dependency.

  • Additional review acceptance: native CTS prints 42/42/42 for the static, require and mixed exported choices; MTS prints 99/42/99. Both public workflows preserve the CTS mixed association and leave the distinct MTS mixed origins ambiguous. No parallel workflow was added.

  • Remaining proof gaps: Actual execution covers Node 24.18.0 / TypeScript 7.0.2 on macOS arm64, compiled CLI and real stdio MCP. Native binary providers/live browsers are outside this source-analysis 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

  • npm run test:focused with 35 selected files — 686 tests passed. Includes the existing public CLI/MCP workflow, resolver/provider/cancellation/worker boundaries, and readiness checks. All 23 semantic-domain suites were included after extending origin metadata.
  • npm run check — typecheck, lint, format, knip, metadata and architecture guards passed; 0 lint errors. Existing lint warnings remain.
  • npm run verify:test-discovery — all 915 test files discovered exactly once.
  • Original issue fixture — two compiled-CLI replays and real Node/TypeScript controls passed, preserving original source SHA.
  • Independent frozen-contribution review — Standards and Spec passed.
  • Joint integration of all three final contributions — automatic source merge, 42 selected files / 821 tests, npm run check and test discovery passed. The disposable integration checkout was restored clean.
  • Upstream CI: PENDING (queued) for 5490c6203a38b47d174f1cdc89c000573f2c1acb. Earlier successful runs are not substituted for this head.

Compatibility, safety, and release

  • Breaking changes or migrations: none.
  • Real Hopper/Ghidra, browser, or OS coverage: Node/TypeScript source workflows executed on macOS; binary-provider/live-browser execution not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment impact: no new authorization, host access, target execution or containment behavior in production.

Review checklist

  • Concrete problem, one focused outcome and conventional title.
  • Related issue linked above.
  • Observable behavior and meaningful failure paths covered.
  • Owning contracts and metadata checked; no public schema or metadata update required.
  • Representative CLI/MCP outcomes included.
  • Final diff checked for secrets, unrelated cleanup and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 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-12T11:54:29.590030Z 5490c62 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: 19b93435c9

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

@NIU-123370 NIU-123370 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Local review completed. The shared import-equals classifier preserves the type-only and internal-alias boundaries, and the MTS format guard matches NodeNext output. Build plus focused domain/CLI/MCP suites passed: 23 tests.

@xu91102 xu91102 changed the title fix(javascript): retain TypeScript import-equals dependencies fix(javascript): preserve import-equals declaration and export evidence Oct 12, 2026

@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: e6d513b2d5

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

@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

node.importKind !== "type" &&
t.isTSExternalModuleReference(node.moduleReference) &&
t.isStringLiteral(node.moduleReference.expression)
? node.moduleReference.expression.value

P2 Badge Exclude ambient import-equals declarations

When a selected .d.ts, .d.mts, or .d.cts contains import X = require("pkg") without the optional type keyword, Babel leaves importKind as a value even though declaration files are ambient and emit no JavaScript. Those files are admitted by relevantKind, and both new collectors call this path-blind predicate, so application analysis now emits require/imports edges for a dependency that never exists at runtime; carry the source-path/declaration context into this classification and skip ambient declarations.

AGENTS.md reference: AGENTS.md:L21-L21

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

@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: a4fdf57f4f

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

@baron baron 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 exact head 5490c62 and current-main integration. No confirmed source blocker or justified additional refactor.

Declaration/export loader mode is retained by the immutable provenance owner, normalized once before origin deduplication, and consumed consistently by both resolution paths. Unknown/ambiguous mode and exact lexical callable ownership are preserved. Pinned validation: 47 semantic tests, check:fast and both compiled public CLI/MCP import-equals cases passed on isolated current-main integration. Distinct malformed, identity and scope cases remain; no gratuitous test pruning or provider claims. Current exact-head CI is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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] TypeScript import-equals declarations lose their module dependency during analysis

4 participants