Repository navigation
Description
Summary
_find_node (and therefore graphify explain) cannot resolve any node ID that contains punctuation. In our graph this silently disabled lookup for 2,327 of 2,327 concept/overlay nodes (concept:domain:*, concept:class:*, entity:*, commit:*), while IDs without punctuation resolved 400/400.
The docstring states the intent clearly, so this looks like an oversight rather than a design decision:
Return node IDs whose label or ID matches the search term (diacritic-insensitive).
[...] Node-ID exact matches are grouped with label exact matches.
find_node_ambiguity's user-facing hint also assumes ID lookup works:
Retry with the repo-relative path or the full node id.
Version: graphifyy 0.9.32
Reproduction
import networkx as nx
from graphify.serve import _find_node
G = nx.DiGraph()
G.add_node("concept:domain:gosu", label="Gosu") # id contains ':'
G.add_node("plain_node_id", label="Plain") # id has no punctuation
print("colon id ->", _find_node(G, "concept:domain:gosu"))
print("plain id ->", _find_node(G, "plain_node_id"))
print("by label ->", _find_node(G, "Gosu"))Actual:
colon id -> []
plain id -> ['plain_node_id']
by label -> ['concept:domain:gosu']
Expected: the first line resolves to ['concept:domain:gosu'].
Same through the CLI:
$ graphify explain "concept:domain:gosu"
No node matching 'concept:domain:gosu' found. # node exists in the graph
Root cause
In graphify/serve.py, _find_node_tiers builds two normalizations of the query:
term = " ".join(_search_tokens(label)) # \w+ tokens -> punctuation becomes a space
norm_query = _strip_diacritics(str(label)).lower().strip() # punctuation preservedThe exact-match tier compares the node ID against term only:
elif (
term == norm_label or term == bare_label or term == label_tokens or term == nid_lower
or norm_query == norm_label or norm_query == bare_label
):For concept:domain:gosu:
| value | |
|---|---|
term |
concept domain gosu |
norm_query |
concept:domain:gosu |
nid_lower |
concept:domain:gosu |
term == nid_lower is always False once the ID contains punctuation. norm_query — which already holds the correct form and is even part of the trigram prefilter (_trigram_candidates(G, [term, norm_query])) — is never compared against nid_lower.
norm_query appears to have been introduced for punctuated labels (the comment references #1704); it just wasn't extended to node IDs.
Suggested fix
One additional clause in the exact tier:
elif (
term == norm_label or term == bare_label or term == label_tokens or term == nid_lower
or norm_query == norm_label or norm_query == bare_label or norm_query == nid_lower
):Why this is worse than a plain lookup failure
The natural workaround — calling explain with the node's label instead of its ID — resolves to the wrong node silently. Across our 35 concept nodes, only 4 resolved correctly; 31 landed on a same-named code node:
| query | resolves to | intended |
|---|---|---|
Repository |
data_repository_feedrepository_ts |
concept:class:Repository |
API |
api_apitypehelper_ts |
concept:class:API |
Gosu |
entity:Gosu |
concept:domain:gosu |
So users get a plausible-looking wrong answer rather than an error, which is hard to notice in downstream reasoning.
Activity
sean-soomgo commentedon Aug 5, 2026
Follow-up: the fix I suggested in the issue body is incomplete, and there is a second class of unresolvable IDs with the same root cause.
Non-ASCII IDs are also affected, without any punctuation
_strip_diacriticsNFD-decomposes the query, but the node ID is compared in its raw form. For any ID containing Hangul (and presumably any NFD-decomposable script), the two sides can never be equal:They print identically but differ byte-wise.
Measured on our graph (14.9k code nodes, Korean source filenames are common):
:So my original repro understated the scope — I first sampled only ASCII IDs and reported 400/400 passing.
Revised suggestion
Normalize both sides rather than adding
norm_query == nid_lower:Evaluated over the same graph, replicating the exact-tier predicate:
norm_query == nid_lowernorm_query == _strip_diacritics(nid).lower():(2,327)No regression: 400 label-based queries returned identical results before and after.
(The single colon ID the narrower fix misses is
artifact:story:공통— it is in both classes.)User-visible consequence
find_node_ambiguitytells users to disambiguate with the full node ID:For a repo with non-ASCII filenames that retry cannot succeed —
explain "<label>"returnsAmbiguous, and every ID it prints as the remedy fails to resolve.sean-soomgo commentedon Aug 5, 2026
Correction to my previous comment — the non-ASCII part of that table is wrong.
I measured the strengthened clause by replicating the exact-tier predicate over every node. That skipped
_trigram_candidates, which runs before the predicate. After actually applying the change to my local install and re-testing through_find_node:norm_query == _strip_diacritics(nid).lower():(300 sample)So the predicate change fixes the punctuation class, and does not fix the non-ASCII class. Sorry for the noise.
Why non-ASCII IDs fail earlier in the pipeline
_find_node_tiersprefilters with_trigram_candidates(G, [term, norm_query]). For a Hangul node ID the candidate set comes back empty, so the node is never scored by any predicate:The cause looks like a normalization mismatch between index build and query. The postings table holds both forms:
17 of the query's 19 trigrams exist in the index individually, but the per-trigram postings intersect to the empty set — consistent with the node's own text having been indexed under one normalization while the query is trigrammed under the other (
_strip_diacriticsNFD-decomposes, sonorm_queryis NFD;termgoes through the same path).Suggested split
These look like two independent defects with one shared theme (query and stored text normalized asymmetrically):
_strip_diacriticsconsistently on both sides at index build time).Happy to test a candidate patch for (2) against a graph with ~350 Hangul-named nodes if that helps.
sean-soomgo commentedon Aug 5, 2026
Found the prefilter half. Both classes are now fixed locally; measurements below.
Root cause of the non-ASCII class
_node_search_textindexes the node ID raw, while every query path folds through_strip_diacritics(which NFD-decomposes):So for a Hangul node ID the query's trigrams never match the indexed ones and
_trigram_candidatesreturns an empty candidate list — the node is dropped before any predicate runs.This is why the two classes need different fixes, and why the non-ASCII class needs both: the full-scan path is gated by the predicate, the index path by the prefilter.
Suggested fix (prefilter)
Index the folded form alongside the raw one:
Additive only — candidates stay a superset and the exact predicates still decide, so no new false positives.
_trigramsbuilds a set over the whole concatenated text, so ASCII IDs (where both forms are equal) add no duplicate postings.Measurements
Applied to a real graph (14.9k code nodes, Korean source filenames common), full population, not a sample:
:Regression check: 600 label-based queries compared before/after in the same process — all 600 identical. (My earlier comment compared
hash()across two processes, which is salted per process and therefore meaningless; that was my error, not a real difference.)End-to-end through the CLI:
One gotcha for whoever writes the regression test
A synthetic graph that is too small will pass even when the bug is present:
_trigram_candidates's guard (min(present) > int(n * 0.10)) bails out to a full scan, which the predicate fix alone can satisfy. I first wrote a 2-node probe and it reported success while the real graph still returned 0/300. A test for the non-ASCII class needs enough nodes (~10+) to actually exercise the index path.xg-gh-25 commentedon Aug 5, 2026
The root cause is colon-splitting during node ID resolution —
concept:domain:xgets parsed as["concept", "domain", "x"]instead of being treated as an opaque identifier.Why this breaks:
The fix: Node IDs should be content-addressed, not parsed. Colons are valid in URIs (
urn:isbn:,did:key:), and graphify's ID scheme shouldn't restrict that.Recommended approach:
concept\:domain\:x|or#), or store IDs as opaque strings with a separatenamespacefieldDomain-Driven Design lens: This is a bounded context leak. The ID format (colons as structure) is bleeding into the ID semantics (should be opaque). The explain/ API shouldn't care how IDs are constructed — it should just look them up.
Test case to add:
SwarmAI contribution from Domain-Driven Design. Built with the SwarmAI framework.
thomasrengot-hub commentedon Aug 8, 2026
Another affected class, in case it helps size the fix: every graph produced by
merge-graphsis 100% unresolvable by ID, not just concept/overlay nodes.merge-graphsnamespaces node IDs with a<source>::prefix, so the separator ispresent on every node — plain code nodes included. On the merged graph of my two
repos,
21596 / 21596nodes contain:::So on a merged graph the ID printed by
explainitself cannot be fed back intoexplain, andfind_node_ambiguity's hint ("Retry with [...] the full node id")is advice that cannot work — which is how I ran into it: I copied the ID out of
one command's output into the next.
Label lookup is the only route left, and that is exactly what namespacing exists
to disambiguate — the same short label often exists in both merged repos
(
SynthesesScreen,CortexScreen, and so on appear in my Kotlin app and in theTypeScript PWA).
Nothing to add on the root cause — your
norm_query == nid_loweranalysis coversthis case as-is. Just noting that the blast radius is larger than concept/overlay
nodes: for anyone using
merge-graphs, ID lookup is not degraded, it is entirelyunavailable.
Version:
graphifyy 0.9.36.sean-soomgo commentedon Aug 10, 2026
@xg-gh-25 I don't think this matches the code, flagging it so the diagnosis in this thread stays consistent.
There is no colon splitting in the resolution path. In
graphify/serve.py(v0.9.38, 2290 lines)split(":"),partition(":")andrsplit(":")each appear 0 times. Theparts = node_id.split(":")/lookup_key = parts[0]snippet quoted as "Current (broken)" is not in the repository. The package does split on::elsewhere —build.py:1880records alocal_idwhenmerge-graphsprefixes ids, and the Rust/Ruby/C++ extractors parse::namespaces — but none of that touches_find_node.The repro in the issue body already rules it out.
_find_node(G, "Gosu")returns['concept:domain:gosu']— the full punctuated ID comes back intact. If the ID were being decomposed and looked up under aconceptnamespace, a label query could not return it whole.IDs are already opaque here. What differs between the two sides of the comparison is normalization, not structure: the query is folded (
_search_tokensturns punctuation into spaces forterm;_strip_diacriticsNFD-decomposes fornorm_query) while the node ID is compared raw. That is the two-part root cause in #2467 (comment) — the exact-tier predicate for the punctuation class, the trigram prefilter for the non-ASCII class.On the suggested remedies: escaping colons at index time adds a third normalization form that has to stay in sync with the query rather than removing the mismatch, and changing the internal delimiter would break every existing graph as well as
merge-graphs'<source>::prefix, while leaving the failing comparison untouched. Neither reaches the line that actually fails.One small thing on the test case: the function is
graphify.serve._find_node(G, label), soexplain._find_node("concept:domain:x")would not run as written.For what it is worth I have put the actual fix up as #2583, with regression tests for both classes and a full-population before/after sweep.
[-]explain/_find_node cannot resolve node IDs containing punctuation (e.g. concept:domain:x)[/-][+]explain/_find_node cannot resolve node IDs containing punctuation or non-ASCII text (concept:*, merge-graphs ::, Hangul)[/+]fix(serve): resolve punctuated and non-ASCII node ids in _find_node (G…
fix(serve): resolve punctuated and non-ASCII node ids in _find_node (#…
chore: bump to 0.9.40
safishamsi commentedon Aug 11, 2026
Fixed in v0.9.40 (
graphifyy==0.9.40on PyPI).explain/_find_node(and the MCP serve equivalent) now resolve node ids containing punctuation or non-ASCII characters, without collapsing distinct ids. Thanks @sean-soomgo (PR #2583).Merge upstream/v8 (v0.9.40) into chore/sync-upstream-0940
fix(query): score the `rationale` attribute as its own tier (#2293)