feat(memorygraph): add persistent memory graph package and MCP tools#142
feat(memorygraph): add persistent memory graph package and MCP tools#142greynewell merged 1 commit intomainfrom
Conversation
Introduces internal/memorygraph — a typed, weighted knowledge graph for agent memory, persisted at .supermodel/memory-graph.json. Nodes are classified as fact/concept/entity/event/procedure/context; edges carry relation types and weights. Provides BFS traversal, scored full-text search, similarity-based auto-linking, and stale-link pruning. Six new MCP tools exposed via server.go: upsert_memory_node, create_relation, search_memory_graph, retrieve_with_traversal, prune_stale_links, add_interlinked_context Also adds peek.go (node inspection layer) with full test coverage. Closes #136 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review WalkthroughIntroduces a persistent in-memory graph system for the Go MCP server. Adds core graph operations (upsert nodes, create typed relations, search, traversal, pruning) with JSON file persistence, read-only inspection tools, and MCP tool wrappers to expose graph functionality. Changes
Sequence DiagramsequenceDiagram
actor Client
participant MCP Server
participant Tool Wrapper
participant Memory Graph
participant Storage
Client->>MCP Server: Request (e.g., SearchGraph)
activate MCP Server
MCP Server->>Tool Wrapper: Dispatch with parsed args
activate Tool Wrapper
Tool Wrapper->>Memory Graph: SearchGraph(query, maxDepth, topK)
activate Memory Graph
Memory Graph->>Storage: Load graph from JSON
activate Storage
Storage-->>Memory Graph: Graph data
deactivate Storage
Memory Graph->>Memory Graph: Score & rank nodes<br/>(substring + token overlap)
Memory Graph->>Memory Graph: Expand 1-hop neighbors<br/>(adjacency + weight filter)
Memory Graph->>Memory Graph: Async bump access counts
Memory Graph-->>Tool Wrapper: SearchResult{Direct, Neighbors}
deactivate Memory Graph
Tool Wrapper->>Tool Wrapper: Format results<br/>(truncate content,<br/>include stats)
Tool Wrapper-->>MCP Server: Human-readable string
deactivate Tool Wrapper
MCP Server-->>Client: Response with results
deactivate MCP Server
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes The PR introduces substantial new functionality across five files with dense, multi-algorithm logic (graph traversal, relevance scoring, similarity computation, JSON persistence, concurrency). While relatively self-contained, the changes demand understanding of graph data structures, BFS traversal, token-set similarity, and MCP integration patterns. Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
…142) Introduces internal/memorygraph — a typed, weighted knowledge graph for agent memory, persisted at .supermodel/memory-graph.json. Nodes are classified as fact/concept/entity/event/procedure/context; edges carry relation types and weights. Provides BFS traversal, scored full-text search, similarity-based auto-linking, and stale-link pruning. Six new MCP tools exposed via server.go: upsert_memory_node, create_relation, search_memory_graph, retrieve_with_traversal, prune_stale_links, add_interlinked_context Also adds peek.go (node inspection layer) with full test coverage. Closes #136 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-Authored-By: Dr. Q and Company <213266729+drQedwards@users.noreply.github.com>
Summary
Squash-merge of the fixed version of #136 onto current main (the original branch history was too messy to rebase cleanly — 33 commits with renames/deletes/capitalisation changes).
internal/memorygraph: typed, weighted knowledge graph persisted at.supermodel/memory-graph.jsonfact,concept,entity,event,procedure,contextrelated_to,causes,part_of, etc.)peek.go: node inspection layer (by ID or label) with formatted terminal outputserver.go:upsert_memory_node,create_relation,search_memory_graph,retrieve_with_traversal,prune_stale_links,add_interlinked_contextpeek.goCloses #136
Test plan
make lint— 0 issuesgo test ./internal/memorygraph/...— all 15 tests passgo build ./...— compiles cleanly🤖 Generated with Claude Code
Summary by CodeRabbit