Description
graph_stats is the only tool that answers "what am I querying?", and it cannot answer "how old is it?". An agent working over MCP has no other way to find out: it can read the graph but it cannot stat graph.json, so it will answer questions about today's code from a graph built last month exactly as confidently as from one built ten minutes ago.
Reproduced on 0.9.54 (v8 @ 937e59a, stock, no local modifications).
Reproduction
Build a graph inside a git repo and ask the MCP server for its stats:
G = nx.DiGraph()
G.add_node("a_foo", label="foo", type="function")
G.add_node("a_py", label="a.py", type="file")
G.add_edge("a_py", "a_foo", type="contains", confidence="EXTRACTED")
export.to_json(G, {0: ["a_foo", "a_py"]}, str(repo / "graphify-out" / "graph.json"))graph.json records where the graph came from:
graph.json top-level keys: ['built_at_commit', 'directed', 'graph', 'hyperedges', 'multigraph']
built_at_commit in file : d787419075b674426a0cb3017c2416d4950232c2
git HEAD : d787419075b674426a0cb3017c2416d4950232c2
Load it the way the MCP server does, and the provenance is gone:
G.graph after _load_graph : {'_logical_directed': True, '_learning_overlay': {}}
So graph_stats over MCP answers:
Nodes: 2
Edges: 1
Communities: 1
EXTRACTED: 100%
INFERRED: 0%
AMBIGUOUS: 0%
Nothing in that output — or in any other MCP tool — says which revision the graph describes, or when it was written.
Root cause
Two separate gaps, one per field.
1. The commit is written but dropped on load. export.to_json writes it at the top level:
graphify/export.py:407—data["built_at_commit"] = commit
networkx.readwrite.json_graph.node_link_graph copies only data["graph"] onto G.graph and silently discards every other top-level key, so serve.py never sees it:
graphify/serve.py:64—G = json_graph.node_link_graph(data, edges="links")graphify/serve.py:67—G.graph["_logical_directed"] = _logical_directed— the one top-level value that is rescued, stashed by hand one line after the load, exactly because of this
The data reaches every other consumer that reads the raw JSON — graphify/callflow_html.py:299, graphify/cli.py:2278, graphify/report.py:172 all use built_at_commit. Only the MCP surface, which loads through node_link_graph, loses it. grep -n built_at_commit graphify/serve.py returns nothing on 0.9.54.
2. There is no build timestamp at all. built_at_commit answers which revision, not when written, and the two diverge in exactly the case that matters: a graph built from a commit that is now three weeks behind still reports that commit, and a --no-cluster rewrite (graphify/cli.py:2278) deliberately carries the old commit forward onto a newly written file. A consumer that cannot stat the file has nothing to fall back on.
Expected
Nodes: 2
Edges: 1
Communities: 1
EXTRACTED: 100%
INFERRED: 0%
AMBIGUOUS: 0%
Built at: 2026-08-25T09:15:42Z
Built from commit: d6ff04064219c45e6cb1aeda8e66c292b6650307
Appended, never prepended, and omitted line-by-line when absent, so a graph written by an older version renders byte-identically to what it renders today.
Notes on a fix
Three constraints worth stating up front, since each one is a way to get this wrong:
- The stamp must be injectable. The round-trip tests assert
graph.jsonis byte-identical across two writes; no wall-clock field can satisfy that unless the caller can pin it, the waybuilt_at_commitalready can. - The stamp must be excluded from the graph comparators.
_canonical_graph_for_compare/_canonical_topology_for_compare(graphify/watch.py:1036,:1060) already dropbuilt_at_commit. A field that changes on every write would otherwise make "did the graph change?" answer yes forever, rewritinggraph.jsonandGRAPH_REPORT.mdon every incremental run and destroying the no-op skip those helpers exist for. - The stamp should not be preserved across a cluster-only rewrite the way Four silent failures with success exit codes: cluster-only ignores --backend, label prompt collides with the
Community {cid}sentinel,tree --root <abs>flattens the hierarchy, built_at_commit stamped from cwd #2534 preserves the commit. The commit describes the extraction, which--no-clusterdoes not redo; the stamp describes the file, which it does rewrite.
I have a patch against 0.9.54 and will open it alongside this issue.
Activity
winesoft-namjin-yun commentedon Oct 6, 2026
Status update, so this is easy to pick up:
v8, not a review decision against the approach. The branch is still there if anyone wants to reuse the_load_graphstash +graph_statsoutput part.graph_statsover MCP returns only node/edge/community counts and the confidence split; nothing says which commit the graph was built from or when.--updatedropping cross-file edges, fixed in 0.9.68 via fix: preserve cross-file edges during incremental updates #3812) cited this issue for the same reason: without build provenance ingraph.json, a drifted graph is indistinguishable from a current one.Leaving this open since the underlying gap is unchanged.
fix(serve): show the graph's build commit in graph_stats