fix: suggest_questions bridge-node question restated hub's own name as a target - #2673
Conversation
…s a target
An extreme hub node is often isolated by Louvain into its own singleton
community, auto-named after that same node. The bridge-node question
template named that community right after the node itself, producing
"Why does `useLang()` connect `useLang` to `Settings`, `Chart`?" - the
node's own name shows up twice, once as a distinct "target" it supposedly
connects to.
Drop the redundant "connect `{comm_label}` to" framing when the bridge
node's own community label normalizes to the same string as the node's
own label, and use "Why does `{label}` bridge {other_labels}?" instead.
Leaves the phrasing unchanged when the two labels genuinely differ.
Found while tracing a suggested question on a real 3000+ node graph,
where 3 of the top-3 bridge questions all hit this (the highest-degree
nodes are exactly the ones most likely to end up in their own
singleton community).
There was a problem hiding this comment.
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 suggest_questions function in graphify/analyze.py to change how bridge-node questions are phrased when a node's own community label matches the node's own label (e.g., a hub isolated into its own singleton community). In that case it now generates a "Why does X bridge ...?" phrasing instead of the "Why does X connect X to ...?" phrasing, using a normalized comparison of the labels. A corresponding test is added to tests/test_analyze.py covering this self-referential scenario.
No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 526 functions depend on the 110 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
suggest_questions()— 12 callers, 4 callees
Verification — 526 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: 365 function(s) in the blast radius were not formally verified this run
· 1 more finding(s) on lines outside this diff (see the check run).
Summary
suggest_questions()'s bridge-node template names the bridge node's own community label right after the node's name:f"Why does \{label}` connect `{comm_label}` to {other_labels}?"`.comm_labelcollapses to (approximately)label, and the generated question reads:Why does \useLang()` connect `useLang` to `Settings`, `Chart`?` — the node's own name appears twice, the second time framed as if it were a distinct thing it connects to.comm_labelandlabelmatches, drop the "connect{comm_label}to" framing and usef"Why does \{label}` bridge {other_labels}?"` instead. Left unchanged when the two labels genuinely differ (verified against a case in the same report where they do).Test plan
test_suggest_questions_bridge_node_no_self_referential_connecttotests/test_analyze.py, reproducing the bug on a minimal 3-node graph (fails without the fix, passes with it)pytest tests/test_analyze.py— 50 passed