Skip to content

MCP server's graph-context cache keys on graph.json only — a graphify reflect run (sidecar-only write) leaves a running server serving stale lesson annotations #3041

Open

Description

@Azeem1985

The defect

_GraphContextCache.load (graphify/serve.py) keys each cached context on graph.json's (st_mtime_ns, st_size) alone. But the .graphify_learning.json sidecar is baked into the cached graph object at load time — _load_graph attaches it as G.graph["_learning_overlay"], which becomes the learning= NODE annotations in query_graph output.

graphify reflect deliberately writes only the sidecar, never graph.json (CHANGELOG 0.9.3: "structural truth stays separate ... no rebuild churn"). That design decision is exactly why graph.json's stat can never witness a reflect run: the multi-project cache's documented "mtime+size hot-reload" contract (CHANGELOG 0.9.5, #1594) was written for a one-file read surface that has since become two files.

Consequence, measured on a live long-running deployment: after a reflect run refreshed the sidecar, the running MCP server kept serving the pre-reflect lesson annotations (or none, when the sidecar was new) until graph.json itself happened to change. Restarting the server "fixed" it — the classic stale-cache signature.

Expected

A sidecar-only change misses the cache exactly like a graph change. Concretely: append the sidecar's (st_mtime_ns, st_size) to the key, with (0, 0) standing in when no sidecar exists — so a sidecar appearing, changing, or vanishing each invalidates, while an unchanged pair still hits the cache. Applies to both the pinned default graph and project_path LRU contexts (they share load()).

A ready patch exists

Implemented and tested (end-to-end on a running HTTP server with a counting loader: sidecar appears → reload + annotations; unchanged → cache hit; rewritten → new verdicts; deleted → annotations gone; also via a project_path context; serve families green) on our production fork: TelB-io/graphify@d0e44d9 (branch upstream/mcp-sidecar-cache-key, based on v8 @ 0.9.49). Companion PR opened from that branch.

Searched existing issues/PRs for "cache sidecar", "stale cache reflect", "server stale", "cache key" before filing — no prior report.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions