Repository navigation
fix(serve): include the learning sidecar in the graph-context cache key - #14
Merged
Merged
Conversation
The context cache keyed on graph.json's (mtime_ns, size) alone, but the .graphify_learning.json sidecar is baked into the cached graph object at load time (_load_graph attaches it as the learning= annotation overlay). graphify reflect rewrites only the sidecar, never graph.json — so a long-running MCP server kept serving stale lesson annotations (or none) until the graph itself happened to change. The key now appends the sidecar's (mtime_ns, size), with (0, 0) standing in when no sidecar exists: appearing, changing, and vanishing each invalidate exactly like a graph change, on both the pinned default graph and project_path LRU contexts; an unchanged pair still hits the cache. 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
_GraphContextCache.loadkeys each context on graph.json's(st_mtime_ns, st_size)only. But the.graphify_learning.jsonsidecar is baked into the cached graph object at load time —serve._load_graphattaches it asG.graph["_learning_overlay"], which becomes thelearning=NODE annotations.graphify reflectrewrites only the sidecar, never graph.json. Verified in tonight's audit on the live deployment: a long-running MCP server kept serving the pre-reflect lesson annotations (or none at all) until graph.json itself happened to change.Maker-docs check
The multi-project cache feature (upstream CHANGELOG 0.9.5, Graphify-Labs#1594) documents the invalidation contract as "its own mtime+size hot-reload" — written for graph.json before the two-file read surface existed. The overlay feature (CHANGELOG 0.9.3) deliberately keeps the sidecar out of graph.json ("structural truth stays separate ... no rebuild churn") — which is exactly why graph.json's stat can never witness a reflect run. No config or intended handling for sidecar-driven invalidation exists in docs, CHANGELOG, or code comments: zero hits.
Community check
gh search issues/prson Graphify-Labs/graphify for "cache sidecar", "stale cache reflect", "server stale", "cache key sidecar": zero reports.Fix
The cache key now appends the sidecar's
(st_mtime_ns, st_size), with(0, 0)standing in when no sidecar exists:(0,0)→ real stat) → reload, annotations appear(0,0)→ reload, annotations goneApplies to both the pinned default graph and
project_pathLRU contexts (they shareload(); the docstring's "sole owner of file statting and cache-key construction" contract is preserved — the stat moved nowhere).Tests
_load_graph: no sidecar → un-annotated + 1 load; sidecar appears (graph.json untouched) →learning=preferred+ reload; unchanged → cache hit (load count flat); rewritten →learning=contested+ reload; deleted → un-annotated + reloadproject_pathcontext🤖 Generated with Claude Code