Skip to content

fix(javascript): omit self-referential import edges with disclosure - #1130

Merged
morluto merged 2 commits into
morluto:mainfrom
BaaRai:fix/javascript-self-import-edges
Oct 8, 2026
Merged

morluto merged 2 commits into
morluto:mainfrom
BaaRai:fix/javascript-self-import-edges

Conversation

@BaaRai

@BaaRai BaaRai commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

BaaRai and others added 2 commits October 9, 2026 07:09
A specifier that resolves back to the importing module itself produced an
imports edge from a module to itself, which the application graph schema
forbids; one such specifier failed result validation and lost the whole
analysis. Skip those edges at composition time and disclose the omission
count in the graph limitations.

Fixes morluto#1129
@morluto
morluto force-pushed the fix/javascript-self-import-edges branch from f33185b to 1cf4abf Compare October 8, 2026 23:09
@morluto
morluto merged commit 1d7115b into morluto:main Oct 8, 2026
3 checks passed
@morluto

morluto commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Thanks for the PR and contribution! The self-import fix addresses the graph-validation failure well.

I removed the unrelated Chinese README rewrite from this branch to keep this PR focused on #1129; that documentation change can be reviewed separately. I also strengthened the regressions into compiled CLI E2E tests and corrected the TypeScript extension-rewrite claim: ./util.js remains unresolved when only util.ts exists with the current resolver.

All 38 focused tests and static checks passed, and a real CLI/stdio MCP probe returned matching results. Your authorship on the original fix is preserved.

kaoru0822-kitauji added a commit that referenced this pull request Oct 9, 2026
The self-import (#1130), async-chunk (#1152) and static-reference
disclosures repeated one sentence template in three composers, and the
new test repeated the analyze-and-check sequence of its neighbour. That
put jscpd at its 2.5% threshold. Share the template through
selfReferenceOmissions with identical wording, and share one test helper
for the graph-wide self-reference invariants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
N0zoM1z0 pushed a commit that referenced this pull request Oct 9, 2026
…ure (#1157)

* fix(javascript): omit self-referential static references with disclosure

A bundled module that requires its own key (`r(50)` inside webpack
module 50) resolved, through the static-reference composer, to its own
module node. The resulting self-referential imports edge failed result
validation and lost the entire analysis ("Result schema rejected 1
issue ... (custom)"). This is the same invariant as #1146; #1152 fixed
the bundler async-chunk composer, and this is the remaining adjacent
composer.

Skip a reference whose resolved target is its own source, count it, and
disclose the omission the way #1152 discloses async-chunk references.
Sibling requires are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(javascript): share the self-reference omission disclosure

The self-import (#1130), async-chunk (#1152) and static-reference
disclosures repeated one sentence template in three composers, and the
new test repeated the analyze-and-check sequence of its neighbour. That
put jscpd at its 2.5% threshold. Share the template through
selfReferenceOmissions with identical wording, and share one test helper
for the graph-wide self-reference invariants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
…orluto#1130)

* fix(javascript): omit self-referential import edges with disclosure

A specifier that resolves back to the importing module itself produced an
imports edge from a module to itself, which the application graph schema
forbids; one such specifier failed result validation and lost the whole
analysis. Skip those edges at composition time and disclose the omission
count in the graph limitations.

Fixes morluto#1129

* test(javascript): verify self-import behavior through the compiled CLI

---------

Co-authored-by: BaaRai <baarai@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
…ure (morluto#1157)

* fix(javascript): omit self-referential static references with disclosure

A bundled module that requires its own key (`r(50)` inside webpack
module 50) resolved, through the static-reference composer, to its own
module node. The resulting self-referential imports edge failed result
validation and lost the entire analysis ("Result schema rejected 1
issue ... (custom)"). This is the same invariant as morluto#1146; morluto#1152 fixed
the bundler async-chunk composer, and this is the remaining adjacent
composer.

Skip a reference whose resolved target is its own source, count it, and
disclose the omission the way morluto#1152 discloses async-chunk references.
Sibling requires are kept.


* refactor(javascript): share the self-reference omission disclosure

The self-import (morluto#1130), async-chunk (morluto#1152) and static-reference
disclosures repeated one sentence template in three composers, and the
new test repeated the analyze-and-check sequence of its neighbour. That
put jscpd at its 2.5% threshold. Share the template through
selfReferenceOmissions with identical wording, and share one test helper
for the graph-wide self-reference invariants.


---------
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
Iyanuoluwa007 pushed a commit to Iyanuoluwa007/rea that referenced this pull request Oct 21, 2026
A webpack/Rspack chunk file that lazily requests one of its own chunk
ids (`__webpack_require__.e(<own id>)`, including merged multi-id
chunks) produced a bundler-async-chunk edge from the chunk to itself. A
bundled module that requires its own key (`r(50)` inside module 50) did
the same through the static-reference composer. The application graph
forbids self-referential edges, so one such edge failed result
validation and lost the entire analysis ("Result schema rejected ...
(custom)").

Apply the treatment morluto#1130 gave self-imports to both composers: skip the
edge, count it, and disclose the omission in the graph limitations. The
shared helper keeps the existing self-import wording.

Fixes morluto#1146
@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: evidence Evidence, artifacts, and reconstruction area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] analyze_javascript_application fails result validation when any module imports itself

2 participants