[PR #1130] [MERGED] fix(javascript): omit self-referential import edges with disclosure #2668

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1130
Author: @BaaRai
Created: 10/8/2026
Status: ✅ Merged
Merged: 10/8/2026
Merged by: @morluto

Base: main ← Head: fix/javascript-self-import-edges


📝 Commits (2)

  • e94310f fix(javascript): omit self-referential import edges with disclosure
  • 1cf4abf test(javascript): verify self-import behavior through the compiled CLI

📊 Changes

3 files changed (+180 additions, -7 deletions)

View changed files

📝 src/application/javascript/JavaScriptArtifactGraphBuilder.ts (+13 -2)
📝 src/application/javascript/JavaScriptModuleRelationships.ts (+28 -5)
➕ tests/boundary/cli/javascriptSelfImportRelationships.test.ts (+139 -0)

📄 Description

Summary

analyze_javascript_application previously lost the whole result when an import resolved to its own source module: composition emitted a self-referential module edge, which the graph schema rejects. Skip those edges and disclose their count in graph and result limitations. Import observations and their source evidence remain available; sibling imports and export-binding relationships are preserved.

Fixes #1129.

Changes

  • Count invalid self-import edges during module relationship composition and pass the count explicitly into graph limitations.
  • Replace the two reconstruction-only regressions with compiled CLI E2E tests covering literal imports, CommonJS self-require, direct TypeScript self-import, sibling imports, valid self-re-export edges, retained source locations, and exact omission counts.
  • Preserve unresolved ./util.js when only util.ts exists. The resolver currently does not perform this extension rewrite, so it is not counted as a self-import omission.
  • Rebase the fix onto current main and remove the unrelated Chinese README rewrite. Preserve the original fix author's attribution.

CLI/MCP schemas and resolver behavior are unchanged.

Validation

  • 38 tests passed across the new CLI regression file, existing CLI JSON output tests, module relationship composition, TypeScript dialect, and application workflow tests.
  • npm run check:fast passed.
  • A real compiled CLI/stdio MCP probe returned identical results for a fixture containing literal and extensionless self-imports, CommonJS self-require, direct TypeScript self-import, dynamic import, self-re-export, and unresolved package/extension/missing-file imports. Four invalid module edges were disclosed; unresolved references remained visible.

Local verification was performed on macOS. The contributor's larger monorepo example was not rerun in this review.


🔄 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/1130 **Author:** [@BaaRai](https://github.com/BaaRai) **Created:** 10/8/2026 **Status:** ✅ Merged **Merged:** 10/8/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/javascript-self-import-edges` --- ### 📝 Commits (2) - [`e94310f`](https://github.com/morluto/rea/commit/e94310f19252f1b3de49a3350e9fc5c8f20adefc) fix(javascript): omit self-referential import edges with disclosure - [`1cf4abf`](https://github.com/morluto/rea/commit/1cf4abff32c9aa350f0e46abd7eff4d0b1a3e180) test(javascript): verify self-import behavior through the compiled CLI ### 📊 Changes **3 files changed** (+180 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `src/application/javascript/JavaScriptArtifactGraphBuilder.ts` (+13 -2) 📝 `src/application/javascript/JavaScriptModuleRelationships.ts` (+28 -5) ➕ `tests/boundary/cli/javascriptSelfImportRelationships.test.ts` (+139 -0) </details> ### 📄 Description ## Summary `analyze_javascript_application` previously lost the whole result when an import resolved to its own source module: composition emitted a self-referential module edge, which the graph schema rejects. Skip those edges and disclose their count in graph and result limitations. Import observations and their source evidence remain available; sibling imports and export-binding relationships are preserved. Fixes #1129. ## Changes - Count invalid self-import edges during module relationship composition and pass the count explicitly into graph limitations. - Replace the two reconstruction-only regressions with compiled CLI E2E tests covering literal imports, CommonJS self-require, direct TypeScript self-import, sibling imports, valid self-re-export edges, retained source locations, and exact omission counts. - Preserve unresolved `./util.js` when only `util.ts` exists. The resolver currently does not perform this extension rewrite, so it is not counted as a self-import omission. - Rebase the fix onto current main and remove the unrelated Chinese README rewrite. Preserve the original fix author's attribution. CLI/MCP schemas and resolver behavior are unchanged. ## Validation - 38 tests passed across the new CLI regression file, existing CLI JSON output tests, module relationship composition, TypeScript dialect, and application workflow tests. - `npm run check:fast` passed. - A real compiled CLI/stdio MCP probe returned identical results for a fixture containing literal and extensionless self-imports, CommonJS self-require, direct TypeScript self-import, dynamic import, self-re-export, and unresolved package/extension/missing-file imports. Four invalid module edges were disclosed; unresolved references remained visible. Local verification was performed on macOS. The contributor's larger monorepo example was not rerun in this review. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:08: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#2668
No description provided.