[PR #657] [MERGED] fix(reference): retain dynamic import relationships #2142

Closed
opened 2026-10-16 21:14:49 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/657
Author: @kaoru0822-kitauji
Created: 10/6/2026
Status: ✅ Merged
Merged: 10/6/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/reference-dynamic-imports


📝 Commits (1)

  • b89de8f fix(reference): retain dynamic import relationships

📊 Changes

3 files changed (+166 additions, -9 deletions)

View changed files

➕ src/domain/referenceSourceImportParsing.test.ts (+81 -0)
📝 src/domain/referenceSourceImportParsing.ts (+28 -9)
➕ tests/boundary/filesystem/referenceSourceDynamicImports.test.ts (+57 -0)

📄 Description

Summary

Recognize Babel 8 ImportExpression nodes when importing historical source trees. Dynamic imports currently disappear from the graph without a parse failure.

No separate issue: this is a focused regression found with the locked parser and production import workflow.

Problem and expected behavior

On 19f8cdd, source containing await import("./lazy.js") produces no dependency relationship. The walker collects only CallExpression, but the locked Babel 8 parser represents dynamic imports as ImportExpression.

Literal targets should produce ordinary import relationships. Computed targets should remain explicitly unknown rather than disappearing or receiving a guessed path.

Change and scope

  • Collect import expressions alongside existing calls.
  • Retain string-literal targets for normal local/external resolution.
  • Represent computed targets as <dynamic-import>, with resolution: "unknown" and parse_state: "partial".
  • Preserve existing static import, re-export, CommonJS, and TypeScript handling.

Contract and boundary impact

  • Semantic owner: historical-source AST extraction, before existing path resolution and graph normalization.
  • CLI/MCP: import-reference-source now returns the missing relationships; no schema/tool changes.
  • Providers/platforms: no native-provider or platform support change.
  • Evidence/provenance: literal edges are retained; computed targets remain unknown/partial.
  • Process/authorization/cleanup: source remains read-only and is never executed.
  • Generated metadata/package: no dependencies, versions, or generated artifacts change.

Evidence and regression coverage

All 9 new domain/filesystem checks fail on the unchanged base and pass with the fix. Coverage includes literal local/external imports, assignment, nested async/await, import options, computed names/templates, and static/require parity.

A real compiled CLI comparison against the same source-owned directory confirms:

  • Base: exit 0, no parse failures, zero relationships.
  • Fixed: exit 0, an internal lazy.js edge plus an explicit unknown/partial computed import.

Validation performed

  • Focused parser, graph, source-reader, and filesystem import suites: 35 tests passed.
  • npm run check: passed (93 lint warnings, 0 errors).
  • npm run jscpd: passed.
  • npm run scan:todos: passed.
  • Boundary build and the public CLI before/after check: passed.
  • git diff --check: passed.
  • Independent review: no findings; additional AST and baseline-parity probes passed.

Node.js 24.19.0, npm 11.9.0. Hosted CI is tracked separately; no complete local suite pass is claimed.

Compatibility, safety, and release

No migration or source execution. This patch does not touch packaging or native providers, so package-install and real Hopper/Ghidra lanes were not rerun locally.

Prepared with AI 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/657 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/6/2026 **Status:** ✅ Merged **Merged:** 10/6/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/reference-dynamic-imports` --- ### 📝 Commits (1) - [`b89de8f`](https://github.com/morluto/rea/commit/b89de8feab389477a468f0b89b8dfa35d7ddc102) fix(reference): retain dynamic import relationships ### 📊 Changes **3 files changed** (+166 additions, -9 deletions) <details> <summary>View changed files</summary> ➕ `src/domain/referenceSourceImportParsing.test.ts` (+81 -0) 📝 `src/domain/referenceSourceImportParsing.ts` (+28 -9) ➕ `tests/boundary/filesystem/referenceSourceDynamicImports.test.ts` (+57 -0) </details> ### 📄 Description ## Summary Recognize Babel 8 `ImportExpression` nodes when importing historical source trees. Dynamic imports currently disappear from the graph without a parse failure. No separate issue: this is a focused regression found with the locked parser and production import workflow. ## Problem and expected behavior On `19f8cdd`, source containing `await import("./lazy.js")` produces no dependency relationship. The walker collects only `CallExpression`, but the locked Babel 8 parser represents dynamic imports as `ImportExpression`. Literal targets should produce ordinary import relationships. Computed targets should remain explicitly unknown rather than disappearing or receiving a guessed path. ## Change and scope - Collect import expressions alongside existing calls. - Retain string-literal targets for normal local/external resolution. - Represent computed targets as `<dynamic-import>`, with `resolution: "unknown"` and `parse_state: "partial"`. - Preserve existing static import, re-export, CommonJS, and TypeScript handling. ## Contract and boundary impact - Semantic owner: historical-source AST extraction, before existing path resolution and graph normalization. - CLI/MCP: `import-reference-source` now returns the missing relationships; no schema/tool changes. - Providers/platforms: no native-provider or platform support change. - Evidence/provenance: literal edges are retained; computed targets remain unknown/partial. - Process/authorization/cleanup: source remains read-only and is never executed. - Generated metadata/package: no dependencies, versions, or generated artifacts change. ## Evidence and regression coverage All 9 new domain/filesystem checks fail on the unchanged base and pass with the fix. Coverage includes literal local/external imports, assignment, nested async/await, import options, computed names/templates, and static/require parity. A real compiled CLI comparison against the same source-owned directory confirms: - Base: exit 0, no parse failures, zero relationships. - Fixed: exit 0, an internal `lazy.js` edge plus an explicit unknown/partial computed import. ## Validation performed - Focused parser, graph, source-reader, and filesystem import suites: 35 tests passed. - `npm run check`: passed (93 lint warnings, 0 errors). - `npm run jscpd`: passed. - `npm run scan:todos`: passed. - Boundary build and the public CLI before/after check: passed. - `git diff --check`: passed. - Independent review: no findings; additional AST and baseline-parity probes passed. Node.js 24.19.0, npm 11.9.0. Hosted CI is tracked separately; no complete local suite pass is claimed. ## Compatibility, safety, and release No migration or source execution. This patch does not touch packaging or native providers, so package-install and real Hopper/Ghidra lanes were not rerun locally. Prepared with AI assistance. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-16 21:14:49 +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#2142
No description provided.