Repository navigation
Description
Version: 0.9.42
Affects: MCP query_graph / get_node, and graphify query / explain — any corpus with a semantic layer.
Summary
semantic_cleanup promotes sentence-like rationale nodes into a rationale attribute on the target node (_append_rationale_attr, semantic_cleanup.py:324), exactly as references/extraction-spec.md prescribes. Nothing ever reads it back.
On a 3-document markdown corpus this captured 50 of 75 nodes (67%) carrying ~8,900 characters of prose. None of it is reachable through any read surface.
This is not #2293. That issue is about scoring: a "why" question cannot reach the node, because _score_query never matches against rationale. This one is about rendering: the node is reached — it is the top seed — and its rationale still does not appear in the output. The two are complementary halves of the same attribute being write-only, and fixing #2293 alone would surface more nodes whose answers are still invisible.
Where it stops
_subgraph_to_text(serve.py:1028) emits onlylabel,source_file,source_location,community(plus an optionallearning=suffix). This is the single renderer behind both MCPquery_graphand the CLI, which imports_query_graph_textfromserve(cli.py:947)._tool_get_node(serve.py:1698) emitslabel / ID / Source / Type / Community / Degreeonly.- No flag, env var or MCP parameter includes it.
Reproduction
graphify extract ./docs --backend <b>
graphify query "<question whose answer node has a rationale>" --budget 6000
The node is listed. Its rationale is not, at any budget.
Measurement
Four questions, budget 6000, on a corpus where the seed node was correct every time:
| seed correct | rationale shown | exact fact recovered | |
|---|---|---|---|
| all 4 questions | yes | no | 0 / 4 |
Concretely — the graph contains, and never shows:
- node
Clustering per deposito→ rationale: "cannot work on ORIGINALS_NORMALIZED as it stands, because timestamps and coordinates are missing" - node
DIFETTO — la normalizzazione distrugge l'EXIF→ rationale: "probable cause: Pillowimg.save()does not preserve EXIF by default and OpenCV always loses it"
A caller asking why clustering is blocked gets the label of the node that answers, and nothing else.
Cost, and why opt-in
I simulated the rendering non-invasively (same query, rationale appended from graph.json) to size it before proposing anything:
| output tokens | |
|---|---|
| current | 10,994 |
| with rationale rendered | 15,901 |
| +45% |
That is a real cost on a token-budgeted surface, so unconditional rendering seems wrong.
Suggested fix
An opt-in:
include_rationale: boolon thequery_graphandget_nodeMCP tools;--rationaleon the CLI;- truncated per node (a
rationale_charscap, or charged against the existing token budget) so a few long rationales cannot crowd out the traversal.
Ordering it after the NODE line, as a WHY … continuation, keeps the existing line format stable for anything parsing it.
Happy to send a PR if this shape is agreeable — and to rebase it on the #2293 scorer change if that lands first, since the two are complementary rather than overlapping.
Activity
yotamleo commentedon Oct 17, 2026
Still reproducible on 0.9.91, and we have two data points to add.
Where it stops, 0.9.91 line numbers (the numbers in the issue body are from 0.9.42):
serve.py_subgraph_to_text(def at 1112). TheNODEline (1193 to 1200) is built fromlabel,source_file,source_location,communityplus the optionallearning=andattrs=suffixes.rationaleis read in this file only by the scorer (_node_rationale_text, 402; the bonus, 701 to 704), never by the renderer.cli.pyexplain(theDegree:/Connectionsblock, about 2100 to 2178) prints node fields,Lesson:lines and connections.grep -n rationale cli.pyhas no hits.Repro (the node carries
rationaleingraph.json, sographify query/graphify explainshould be able to print it):On a graph holding this node:
{"id": "retask_halt", "label": "Halt/narrowing needs no token (fail-safe asymmetry)", "source_file": "docs/internals/retask-channel.md", "_origin": "semantic", "rationale": "An attacker who can only make the child do less has a mild DoS, not a compromise; a stood-down worker must not reason a halt away as 'not genuine user input'."}Today
queryprints the node as label only:and
explainprints the label, source, type, community, degree and connections, with no rationale.Desired, one bounded line right under the
NODEline and underexplain's node header:Real-corpus size, since #2821 flagged cost: on our repo graph, 825 of 2170 nodes (38 %) carry a
rationale. It is the only place the why of a design decision is stored, so a "why" question returns the right node and no answer.Sanitization is required, not optional.
rationaleis LLM-extracted free text from the corpus, so it is untrusted and flows into an agent's context. Render it throughsanitize_label-style handling at minimum:NODE/EDGEline);sanitize_labelcaps at 256 (security.py,_MAX_LABEL_LEN); we use 400 and it keeps the sentence intact in our corpus. Add a visible...on truncation.Without this, a rationale that contains
\nEDGE ...would inject fake graph lines into the output that agents parse.Workaround we carry (so you know the shape that works): a stdin filter that matches each
NODEline to a graph node by label plus source file and appends the rationale, control characters stripped, 400-character cap. It exists only because the renderer drops the field. If #2821 lands we delete it.Happy to test a fix against our graph.
yotamleo commentedon Oct 20, 2026
A rebased fix for this is up as #4576 (supersedes #2830, which has conflicted with
v8since 2026-08-20). It adds an opt-in--rationaleflag toqueryandexplain, andinclude_rationaletoquery_graphandget_node. The text goes through a sanitizer and is capped.On our own repo graph 825 of 2170 semantic nodes carry a
rationaleand none is printed today, so every "why" question returns the right node without the reason. We use it from the rebased branch; upstream CI is green. Review welcome.fix: [HIMMEL-6056] render rationale in query, explain and get_node (#14)
chore(graphify): [HIMMEL-6056] pin the fork with rationale rendering …
fix(security): [HIMMEL-7187] sync to upstream 0.9.94 and floor the pa…
fix: [HIMMEL-6056] render rationale in query, explain and get_node (#14)
fix: [HIMMEL-6056] render rationale in query, explain and get_node (#14)