Skip to content

fix(serve): MCP orientation refreshes the strict hook's freshness stamp - #12

Merged
Azeem1985 merged 1 commit into
v8from
fix/mcp-stamp-touch
Aug 25, 2026
Merged

Azeem1985 merged 1 commit into
v8from
fix/mcp-stamp-touch

Conversation

@Azeem1985

Copy link
Copy Markdown

Defect

The strict read guard (vendor hook-guard read --strict and our deny-hook) admits an agent only while the "recently oriented" stamp — graphify-out/cache/last_query_stamp — is fresh. The CLI commands graphify query / path / explain each touch it (cli.py _touch_query_stamp calls at the end of each handler), but the MCP server's tools never did: _tool_query_graph runs _query_graph_text + query-logging and returns. Verified in tonight's audit on the live deployment: an agent that oriented exclusively through MCP query_graph stayed "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/path refreshes 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.py upstream simply contains zero mentions of the stamp. No existing config or intended solution found.

Community check

gh search issues/prs on 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:

CLI (stamps) MCP twin stamps now
graphify query query_graph yes
graphify path shortest_path yes
graphify explain get_node + get_neighbors (explain's output = node detail + connections, split into two tools) yes
graphify god-nodes (does NOT stamp) god_nodes no
— graph_stats, get_community no (graph-level browsing; no CLI stamp precedent)
— list_prs, get_pr_impact, triage_prs no (PR triage, not codebase orientation)

Two deliberate choices beyond the table:

  • Stamp on any successful call, including "No node matching" answers. The CLI's explain skips the stamp on a no-match only because it 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.
  • Stamp next to the graph that answered. With project_path, the stamp lands in that project's graphify-out/cache — the project whose reads the guard gates. A failed call (missing/corrupt project graph) stamps nothing.

Tests

  • query_graph creates the stamp; each of the four orientation tools refreshes an aged stamp (parametrized, mtime advances)
  • graph_stats / god_nodes / get_community leave an aged stamp untouched
  • project_path call stamps the project's cache dir, not the default graph's
  • failed call (missing project graph) stamps nothing
  • full serve/serve_http/hook_strict families: 201 passed; ruff + py_compile clean

🤖 Generated with Claude Code

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
Azeem1985 merged commit 218e02c into v8 Aug 25, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant