Repository navigation
fix(serve): MCP orientation refreshes the strict hook's freshness stamp - #12
Merged
Merged
Conversation
The strict read guard admits an agent only while the 'recently oriented' stamp (graphify-out/cache/last_query_stamp) is fresh. The CLI's query / path / explain each touch it (cli._touch_query_stamp), but their MCP twins never did — an agent that oriented through the server via query_graph was still treated as blind and had its first raw read denied. call_tool now touches the stamp after every successful call to one of the four orientation tools: query_graph (= query), shortest_path (= path), get_node + get_neighbors (the MCP split of explain). The stamp lands next to the graph that answered, so a project_path call stamps THAT project's graphify-out/cache — the graph whose reads the guard gates. Browsing tools (graph_stats, god_nodes, get_community) and the PR tools don't stamp on the CLI and still don't over MCP; a failed call stamps nothing. Co-Authored-By: Claude Fable 5 <[email protected]>
Azeem1985
pushed a commit
that referenced
this pull request
Aug 25, 2026
…query ledger The strict read guard admits an agent only while the "recently oriented" stamp (graphify-out/cache/last_query_stamp) is fresh, and the query ledger is the audit trail of graph consults. query/path/explain each stamp + log, and PR #12 extended the stamp to the MCP orientation tools — but the CLI affected and god-nodes verbs did neither: an agent orienting through them stayed blind to the guard (next raw read denied) and invisible to the audit trail. Orientation is orientation regardless of door (PR #12): both verbs now mirror the query verb's calls after a successful run — kind="affected" with the impacted-node count, kind="god_nodes" with the returned-hub count — followed by _touch_query_stamp. Both are fail-silent; the ledger stays opt-in behind the GRAPHIFY_QUERY_LOG* gates. The MCP god_nodes tool still does not stamp; widening that set is a deliberate follow-up. Co-Authored-By: Claude Fable 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defect
The strict read guard (vendor
hook-guard read --strictand our deny-hook) admits an agent only while the "recently oriented" stamp —graphify-out/cache/last_query_stamp— is fresh. The CLI commandsgraphify query/path/explaineach touch it (cli.py_touch_query_stampcalls at the end of each handler), but the MCP server's tools never did:_tool_query_graphruns_query_graph_text+ query-logging and returns. Verified in tonight's audit on the live deployment: an agent that oriented exclusively through MCPquery_graphstayed "blind" to the strict guard and had its first raw read denied — after it had already consulted the graph.Maker-docs check
Upstream CHANGELOG 0.9.19 defines the contract: "Running any
graphify query/explain/pathrefreshes a short-lived 'recently oriented' stamp that suppresses the block." The spirit is "the agent consulted the graph"; nothing in the docs, README, or code comments says MCP consultation shouldn't count —serve.pyupstream simply contains zero mentions of the stamp. No existing config or intended solution found.Community check
gh search issues/prson Graphify-Labs/graphify for "stamp mcp", "query stamp", "strict hook mcp", "orient": zero reports of this defect (nearest neighbors are Graphify-Labs#2202 — strict-hook phrasing — and Graphify-Labs#1624 — a different, generated_at stamp).Which MCP tools count as orientation — the reasoning
Parity with the CLI's stamping commands, tool by tool:
graphify queryquery_graphgraphify pathshortest_pathgraphify explainget_node+get_neighbors(explain's output = node detail + connections, split into two tools)graphify god-nodes(does NOT stamp)god_nodesgraph_stats,get_communitylist_prs,get_pr_impact,triage_prsTwo deliberate choices beyond the table:
sys.exit(0)s before reaching it — an accident of control flow, not a contract. A no-match answer IS a graph consult: the agent learned the graph lacks the symbol, after which reading raw files is exactly right. The guard's premise ("asked the graph first") holds.project_path, the stamp lands in that project'sgraphify-out/cache— the project whose reads the guard gates. A failed call (missing/corrupt project graph) stamps nothing.Tests
query_graphcreates the stamp; each of the four orientation tools refreshes an aged stamp (parametrized, mtime advances)graph_stats/god_nodes/get_communityleave an aged stamp untouchedproject_pathcall stamps the project's cache dir, not the default graph's🤖 Generated with Claude Code