[PR #2062] [MERGED] fix(javascript): preserve import-equals declaration and export evidence #4997

Closed
opened 2026-10-31 00:57:50 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2062
Author: @xu91102
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/12/2026
Merged by: @baron

Base: main ← Head: fix/typescript-import-equals-dependencies


📝 Commits (6)

  • 19b9343 fix(javascript): retain TypeScript import-equals dependencies
  • e6d513b fix(javascript): preserve import-equals declaration and export evidence
  • 40510c4 test(mcp): align completion checks with warm provider state
  • c341940 fix(javascript): propagate require origins through exported aliases
  • a4fdf57 chore: merge upstream completion fixture fixes
  • 5490c62 fix(javascript): normalize equivalent CTS binding origins

📊 Changes

16 files changed (+498 additions, -48 deletions)

View changed files

📝 src/application/javascript/JavaScriptArtifactAnalysis.ts (+6 -1)
📝 src/application/javascript/JavaScriptArtifactPathResolution.ts (+10 -2)
📝 src/application/javascript/JavaScriptModuleRelationships.ts (+3 -0)
📝 src/composition/javascriptAnalysisWorkerProcess.ts (+5 -1)
📝 src/domain/javascript/javascriptSemanticAnalysis.require_links.test.ts (+34 -1)
📝 src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts (+3 -0)
📝 src/domain/javascript/javascriptSemanticAnalysis.ts (+24 -6)
📝 src/domain/javascript/javascriptSemanticIr.ts (+3 -0)
📝 src/domain/javascript/javascriptSemanticProjection.ts (+20 -13)
📝 src/domain/javascript/javascriptSemanticProvenance.ts (+5 -1)
📝 src/domain/javascript/javascriptSemanticRequireOrigin.ts (+5 -1)
📝 src/domain/javascript/javascriptSemanticReturns.ts (+17 -1)
📝 src/domain/javascript/javascriptSemanticState.ts (+2 -0)
📝 src/domain/javascript/javascriptStaticAnalysis.ts (+6 -1)
📝 src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.ts (+32 -10)
📝 tests/acceptance/applications/unboundRequires.test.ts (+323 -10)

📄 Description

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 e4532b5376. 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 621cee192d (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; #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.

🔄 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/2062 **Author:** [@xu91102](https://github.com/xu91102) **Created:** 10/12/2026 **Status:** ✅ Merged **Merged:** 10/12/2026 **Merged by:** [@baron](https://github.com/baron) **Base:** `main` ← **Head:** `fix/typescript-import-equals-dependencies` --- ### 📝 Commits (6) - [`19b9343`](https://github.com/morluto/rea/commit/19b93435c913351ec59435b817620c9aeabbe0fd) fix(javascript): retain TypeScript import-equals dependencies - [`e6d513b`](https://github.com/morluto/rea/commit/e6d513b2d5962b20c30993e0616f4b17d79234a1) fix(javascript): preserve import-equals declaration and export evidence - [`40510c4`](https://github.com/morluto/rea/commit/40510c450070b5dd577931414eaf80bc6039a856) test(mcp): align completion checks with warm provider state - [`c341940`](https://github.com/morluto/rea/commit/c3419407631bb60f80014507fd87d39fca3bb945) fix(javascript): propagate require origins through exported aliases - [`a4fdf57`](https://github.com/morluto/rea/commit/a4fdf57f4fe11464418ece01e98361820dfcfe84) chore: merge upstream completion fixture fixes - [`5490c62`](https://github.com/morluto/rea/commit/5490c6203a38b47d174f1cdc89c000573f2c1acb) fix(javascript): normalize equivalent CTS binding origins ### 📊 Changes **16 files changed** (+498 additions, -48 deletions) <details> <summary>View changed files</summary> 📝 `src/application/javascript/JavaScriptArtifactAnalysis.ts` (+6 -1) 📝 `src/application/javascript/JavaScriptArtifactPathResolution.ts` (+10 -2) 📝 `src/application/javascript/JavaScriptModuleRelationships.ts` (+3 -0) 📝 `src/composition/javascriptAnalysisWorkerProcess.ts` (+5 -1) 📝 `src/domain/javascript/javascriptSemanticAnalysis.require_links.test.ts` (+34 -1) 📝 `src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts` (+3 -0) 📝 `src/domain/javascript/javascriptSemanticAnalysis.ts` (+24 -6) 📝 `src/domain/javascript/javascriptSemanticIr.ts` (+3 -0) 📝 `src/domain/javascript/javascriptSemanticProjection.ts` (+20 -13) 📝 `src/domain/javascript/javascriptSemanticProvenance.ts` (+5 -1) 📝 `src/domain/javascript/javascriptSemanticRequireOrigin.ts` (+5 -1) 📝 `src/domain/javascript/javascriptSemanticReturns.ts` (+17 -1) 📝 `src/domain/javascript/javascriptSemanticState.ts` (+2 -0) 📝 `src/domain/javascript/javascriptStaticAnalysis.ts` (+6 -1) 📝 `src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.ts` (+32 -10) 📝 `tests/acceptance/applications/unboundRequires.test.ts` (+323 -10) </details> ### 📄 Description ## 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 e4532b537663026c3e5b784380eecd009c959a36. 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 621cee192d582c87ca3d254d4cb22c9d209d3aea (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; #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. - [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 - `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)](https://github.com/morluto/rea/actions/runs/38244841234) 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 - [x] Concrete problem, one focused outcome and conventional title. - [x] Related issue linked above. - [x] Observable behavior and meaningful failure paths covered. - [x] Owning contracts and metadata checked; no public schema or metadata update required. - [x] Representative CLI/MCP outcomes included. - [x] Final diff checked for secrets, unrelated cleanup and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:57:50 +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#4997
No description provided.