Skip to content

Fix collapsed import self-loops#2038

Draft
Endogen wants to merge 1 commit into
Graphify-Labs:v8from
Endogen:fix/import-self-loops
Draft

Fix collapsed import self-loops#2038
Endogen wants to merge 1 commit into
Graphify-Labs:v8from
Endogen:fix/import-self-loops

Conversation

@Endogen

@Endogen Endogen commented Jul 19, 2026

Copy link
Copy Markdown

Summary

  • drop file-level imports, imports_from, and re_exports edges when endpoint resolution collapses them into self-loops
  • cover Python stdlib/package basename collisions and Rust parent/external module cases
  • verify that meaningful recursive calls self-loops remain intact

Fixes #2037.

Root cause

AST extraction can emit unresolved bare import targets such as builtins, contracting, or poseidon. The legacy-ID alias index in build_from_json() may then resolve that bare target to the importing file's own canonical node. Materializing the resolved edge creates a file-level self-loop that carries no connectivity and is flagged by graphify diagnose multigraph.

The filter is intentionally relation-specific. It removes only collapsed import/re-export edges and preserves other self-edges, including recursive calls.

Impact

Rebuilt graphs no longer contain false import self-loops caused by basename/legacy-alias resolution. This eliminates diagnostic noise without changing application code or hiding real recursive program structure.

Validation

  • uv run pytest tests/ -q — 3,478 passed, 3 skipped
  • uv run ruff check . — passed
  • focused build/extraction suite — 148 passed
  • rebuilt two affected real-world graphs — zero self-loops, dangling endpoints, missing endpoints, or endpoint-collapse groups

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bare import aliases can collapse into file-level self-loops

1 participant