Skip to content

fix: suggest_questions bridge-node question restated hub's own name as a target - #2673

Open
cybersecurity-cell wants to merge 1 commit into
Graphify-Labs:v8from
cybersecurity-cell:fix/bridge-question-self-reference
Open

fix: suggest_questions bridge-node question restated hub's own name as a target#2673
cybersecurity-cell wants to merge 1 commit into
Graphify-Labs:v8from
cybersecurity-cell:fix/bridge-question-self-reference

Conversation

@cybersecurity-cell

Copy link
Copy Markdown

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}?"`.
  • An extreme hub (highest betweenness) is frequently isolated by Louvain into its own singleton community, auto-named after that same node. When that happens, comm_label collapses 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.
  • Found this on a real ~3,150-node project graph: 3 of the top-3 bridge-node questions all hit it, since the highest-degree nodes are exactly the ones most likely to end up alone in their own community.
  • Fix: when a normalized (lowercased, non-alphanumeric-stripped) comparison of comm_label and label matches, drop the "connect {comm_label} to" framing and use f"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

  • Added test_suggest_questions_bridge_node_no_self_referential_connect to tests/test_analyze.py, reproducing the bug on a minimal 3-node graph (fails without the fix, passes with it)
  • Full pytest tests/test_analyze.py — 50 passed
  • Manually re-verified against the real project graph that surfaced this: the three affected questions now read cleanly, and the one genuinely-distinct case is untouched

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

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

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

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.

1 participant