fix(extract): preserve stub edges that would become self-loops - #2401
fix(extract): preserve stub edges that would become self-loops#2401zrh805 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify review — findings
This PR modifies the _rewire_unique_stub_nodes function in graphify/extract.py to prevent a stub node from being resolved onto a node it already shares an edge with, which would create a self-loop. To do this, it builds a stub_neighbors map tracking each stub's edge endpoints and adds that as an exclusion condition before remapping. The change is referenced as fixing issue #2374 (false self-loops). Three new tests are added covering the scenario directly at the function level, plus end-to-end cases for Kotlin anonymous object literals inheriting an external base and Python qualified decorators (@app.list_tools()).
No blocking issues surfaced.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 1421 functions depend on the 501 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract()— 360 callers, 29 callees - worse:
_rewire_unique_stub_nodes()— 7 callers, 6 callees
Verification — 1421 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 1293 function(s) in the blast radius were not formally verified this run
· 2 more finding(s) on lines outside this diff (see the check run).
9abdf59 to
e579f42
Compare
There was a problem hiding this comment.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify review — findings
This PR modifies _rewire_unique_stub_nodes in graphify/extract.py to prevent a stub node from being resolved onto a node it's already directly connected to via an edge. It builds a stub_neighbors mapping tracking each stub's edge endpoints and adds a guard so remapping is skipped when the unique candidate is a neighbor, with the stated intent of avoiding false self-loops (#2374). The rest of the diff adds test coverage across three test files, exercising this behavior for a Python qualified decorator case, a Kotlin anonymous object supertype case, and a direct unit test of the rewiring function.
No blocking issues surfaced.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 1421 functions depend on the 501 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract()— 360 callers, 29 callees - worse:
_rewire_unique_stub_nodes()— 7 callers, 6 callees
Verification — 1421 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 1293 function(s) in the blast radius were not formally verified this run
· 2 more finding(s) on lines outside this diff (see the check run).
Summary
Fixes #2374
Validation
uv run --frozen pytest tests/test_extract.py tests/test_python_decorators.py tests/test_kotlin_object_literal.py(180 passed, 1 skipped)uv run --frozen ruff check graphify testsuv run --frozen graphify update .The full suite completed with 3,898 passed / 36 skipped; its 12 unrelated failures are caused by an optional
openaidependency missing from this environment,example.comresolving to a blocked internal test address, and an existing batch-order assertion.