Skip to content

fix(extract): preserve stub edges that would become self-loops - #2401

Open
zrh805 wants to merge 1 commit into
Graphify-Labs:v8from
zrh805:codex/fix-stub-rewire-self-loops
Open

fix(extract): preserve stub edges that would become self-loops#2401
zrh805 wants to merge 1 commit into
Graphify-Labs:v8from
zrh805:codex/fix-stub-rewire-self-loops

Conversation

@zrh805

@zrh805 zrh805 commented Aug 2, 2026

Copy link
Copy Markdown

Summary

  • keep a unique stub unresolved when rewiring it onto an existing edge neighbor would produce a false self-loop
  • cover the generic rewire guard plus Python qualified decorators and Kotlin anonymous-object supertypes

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 tests
  • uv run --frozen graphify update .

The full suite completed with 3,898 passed / 36 skipped; its 12 unrelated failures are caused by an optional openai dependency missing from this environment, example.com resolving to a blocked internal test address, and an existing batch-order assertion.

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@zrh805
zrh805 force-pushed the codex/fix-stub-rewire-self-loops branch from 9abdf59 to e579f42 Compare August 3, 2026 01:42

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

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.

_rewire_unique_stub_nodes creates false self-loops for qualified decorators and Kotlin anonymous objects

1 participant