fix(serve): resolve node ids containing punctuation in _find_node (#2467) - #2499
fix(serve): resolve node ids containing punctuation in _find_node (#2467)#2499ousamabenyounes wants to merge 1 commit into
Conversation
…aphify-Labs#2467) term tokenizes punctuation into spaces, so it never equaled the punctuation-preserving node id (concept:domain:x resolved to nothing). Compare norm_query against nid_lower too, mirroring the norm_query == norm_label label path from Graphify-Labs#1704. Exact-tier only, purely additive: punctuation-free ids and label lookups are unchanged.
There was a problem hiding this comment.
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 node-matching logic in _find_node_tiers within graphify/serve.py to add a comparison between the punctuation-preserving norm_query and nid_lower, so that exactly-typed node IDs containing punctuation (e.g. concept:domain:x) can resolve by id. It updates the accompanying code comment and adds a changelog entry describing the intended fix (#2467). A new test (test_find_node_resolves_id_with_punctuation) is added covering punctuated-id lookup along with regression checks for plain ids and label lookups.
No blocking issues surfaced.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 663 functions depend on the 470 functions this change touches.
Health — grade A; 10 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):
dispatch_command()— 2 callers, 118 callees (high)_query_graph_text()— 14 callers, 8 callees (high)_score_query()— 14 callers, 5 callees (high)run_benchmark()— 16 callers, 3 callees (high)_query_terms()— 16 callers, 3 callees (high)_build_server()— 2 callers, 20 callees (high)_load_graph()— 9 callers, 3 callees (medium)_shortest_path_text()— 5 callers, 4 callees (medium)- …and 2 more
Verification — 663 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: 523 function(s) in the blast radius were not formally verified this run
Why
graphify explain(and_find_node) cannot resolve any node ID that contains punctuation — e.g.concept:domain:gosu,entity:*,commit:*. The reporter measured 2,327 of 2,327 concept/overlay nodes silently unresolvable by id, while punctuation-free ids resolved. The docstring promises id lookup ("Return node IDs whose label or ID matches …"), andfind_node_ambiguity's own hint tells users to "retry with the full node id" — so this is an oversight, not a design choice.Root cause
In
graphify/serve.py_find_node_tiers, the query is normalized two ways:The exact-match tier compared the node id (
nid_lower, which keeps punctuation) only againstterm(which replaces punctuation with spaces). Forconcept:domain:gosu,termis"concept domain gosu"— it can never equalnid_lower"concept:domain:gosu". The punctuation-preservingnorm_querywas already compared againstnorm_label/bare_label, but not againstnid_lower.What changed
Add the symmetric comparison
norm_query == nid_lowerto the exact-match tier — the exact counterpart of thenorm_query == norm_labelclause that was added for punctuated labels in #1704. One production line, plus a clarifying comment and a CHANGELOG entry.Why it's safe
exacttier only when the whole diacritic-stripped, lowercased query byte-equals that node's id — the definition of an exact id match. It can only promote a currently-unresolvable id intoexact; it cannot pull in a different node or reorder resolution for any existing query.term == nid_lowerclause already lives inexact.shortest_path/_score_nodesuse a separate scoring path and are not affected;explainandfind_node_ambiguityroute through_find_node_tiersand only benefit.prefixtier) is intentionally left as a separate concern to avoid speculative false-prefix matches.Test verification (RED → GREEN)
New test
tests/test_serve.py::test_find_node_resolves_id_with_punctuation.RED — on unmodified
v8, with only the new test applied:GREEN — with the fix:
The test also guards the regressions (punctuation-free ids and label lookups still resolve).
Full suite:
4044 passedon cleanv8→4045 passed, 3 skippedon this branch (the one added test).ruff check graphify testsclean;python -m tools.skillgen --checkOK;graphify --helpinstall smoke OK.