Repository navigation
Description
Version: 0.9.29
Affects: graphify query (and the MCP query tool) on any corpus whose semantic layer follows the extraction spec.
Summary
_score_query matches a question against norm_label, label_tokens, source_file and the node id. It never reads rationale.
But references/extraction-spec.md deliberately stores the WHY as an attribute, not a node:
For rationale (WHY decisions were made, trade-offs, design intent): store as a
rationaleattribute on the relevant concept node — do NOT create a separate rationale node or fragment node.
So for a "why does X …" question, the rationale prose is frequently the only place the question's wording occurs. The node holding the answer is reachable only by someone who already knows the label it hangs on — which is precisely what the asker does not know.
The same text is also absent from _node_search_text, so those nodes are not even trigram candidates.
Measurement
A 5,524-node corpus (TypeScript/Next.js app + 200 design docs), semantic layer built per the spec. Five natural-language "why" questions, each with one ground-truth answer node carrying a rationale that states the answer in plain words:
| question | answer node's rank | picked as seed | reached at depth 2 |
|---|---|---|---|
| why is the npm version pinned in CI | 4 / 19 | no | no |
| why is Instagram sharing copy-only instead of a prefilled link | 126 / 156 | no | no |
| why does the sheet drag only start when the list is scrolled to the top | 278 / 405 | no | no |
| why do callers not branch on the payment provider | 5 / 492 | no | no |
| why is the directions button hidden when the geolocation popover opens | 37 / 142 | no | no |
0 / 5 answers reached, although all five nodes exist, are connected, and literally contain the answer.
Two of them, to show this is not a corpus problem:
showDirections visibility rule→ rationale: "Hidden when the mini card is dismissed and while the geolocation popover is open, because that popover opens upward into the DirectionsFAB's space." The question "why is the directions button hidden when the geolocation popover opens" is almost a quotation of it. The label shares only "visibility".PaymentProvider Adapter Seam→ rationale: "Adapter, not branching: callers never switch on the payment provider…" against the question "why do callers not branch on the payment provider".
Reproduction
- Build any graph whose docs went through semantic extraction.
- Pick a node with a
rationale; phrase a question from the rationale text using words absent from its label. graphify query "<question>"— the node is not among the seeds and usually not in the traversal.
Suggested fix
Score rationale as its own tier, below the label substring tier and above the source-path tier, and add the same text to _node_search_text so the trigram prefilter stays a complete candidate generator. Like the source tier it should not count toward term coverage, so it adds recall without letting a long rationale win back an exact-label tier it did not earn.
PR: nuboxworld-byte:fix/query-scores-rationale — 6 tests, 3 of which fail on the current scorer; no new failures in the suite.
With that change, same corpus and questions:
| before | after | |
|---|---|---|
| rank of the answer | 126, 278, 37, 5, 4 | 2, 14, 3, 4, 4 |
| answer reached | 0 / 5 | 2 / 5 |
The remaining gate is _pick_seeds, not scoring
Worth flagging separately: after the fix the answer ranks 2nd–4th for four of the five questions, yet _pick_seeds' gap-based cutoff still drops it in three of them. Scoring was one of two gates. I did not touch seed selection — it is a more opinionated change and probably deserves its own issue, but a fix to scoring alone will look disappointing without it.
Aside
_node_search_text's docstring states it concatenates "every field _score_nodes / _find_node match a query against". That contract is what makes the two-part fix safe — and it is also what made the omission easy to miss, since the docstring was accurate about the fields the scorer did read.
Activity
fix(query): score the `rationale` attribute as its own tier (#2293)
safishamsi commentedon Sep 5, 2026
Fixed in v0.9.54 by #3288 (thanks @andytsai821201-spec) — the query scorer now ranks a rationale match as its own tier, between exact-label and source-path. Release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.54