Repository navigation
Description
graphify version: 0.7.15 (also reproduces on 0.5.2 — unchanged)
Symptom
In some codebases with prefix-style class names (Tab, TabbedActivity, TabUI, …), graphify path "Foo" "FooBar" almost always returns 0 hops. The source and target labels both match the same substring candidate node, so src == tgt.
Reproducer
In any codebase with classes like Foo and FooBar indexed:
graphify path "Foo" "FooBar"
→ 0 hops ("Foo" is a prefix of FooBar → both src and tgt match the FooBar node, src == tgt)
Suspected root cause
serve.py:235 — _find_node is a single-stage substring match:
def _find_node(G: nx.Graph, label: str) -> list[str]:
term = _strip_diacritics(label).lower()
return [nid for nid, d in G.nodes(data=True)
if term in (d.get("norm_label") or ...) or term == nid.lower()]Only term in label — no precedence for exact / prefix matches, and no ambiguity signal back to the caller when multiple nodes match.
_score_nodes (serve.py:54), used by _tool_query_graph and _tool_shortest_path for src/tgt scoring, is also substring-based (plus matching against source_file, plus lexicographic tie-breaking), so the path/query endpoint selection has the same fuzziness.
Environment
- Production Android browser fork (Chromium-derived), Java + Kotlin
- 19,668 nodes / 50,881 edges (after
graphify update .) - Many prefix-style class names (
Tab*,UrlBar*,Toolbar*)
For context, the 0.5.2 → 0.7.15 cross-file resolver fix (is_member_call skip + ambiguous skip) reduced top boilerplate INFERRED target counts in this codebase by ~69% (.get() 736 → 208, .getInstance() 478 → 84, .getContext() 475 → 141). That fix lands cleanly; the _find_node substring issue is independent and unchanged.
Possible directions
(Up to the maintainer; happy to send a PR. One possible direction:)
- Try exact match first → fall back to substring
- If substring has ≥ 2 candidates, signal ambiguity to the caller (or return empty)
- Apply the same staging to
_score_nodes
Impact
In some codebases with prefix-style naming, graphify path returns 0 hops on most calls. query and explain may also start BFS from an incorrect node.
Companion issues
Two more issues found in the same measurement run (filed separately so they can be triaged independently):
- BFS direction:
build.pysupportsdirected=Truebut the option is not exposed via CLI;serve.pyBFS usesG.neighbors() - BFS god-node transit: degree-p99+ hubs are freely traversed
Activity
[-][BUG] `_find_node` substring match collapses `src == tgt`, making `graphify path` return 0 hops[/-][+]`_find_node` substring match collapses `src == tgt`, making `graphify path` return 0 hops[/+]fix #832 #831 #828 #826 #827: encoding, uv fallback, path scoring, ca…
safishamsi commentedon May 12, 2026
Fixed in v0.7.16 —
_score_nodesnow uses three-tier precedence (exact 1000 / prefix 100 / substring 1).graphify pathand the MCP tool now emit a clear error when source and target resolve to the same node instead of silently returning 0 hops.serve: lap-29 cherry-pick Graphify-Labs#828 — path scoring tiers + am…
fix Graphify-Labs#832 Graphify-Labs#831 Graphify-Labs#828 Graphify-La…
fix Graphify-Labs#832 Graphify-Labs#831 Graphify-Labs#828 Graphify-La…