memory-fabric
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMemory Fabric - Graph Orchestration
Memory Fabric - 图编排
Knowledge graph orchestration via mcp__memory__* for entity extraction, query parsing, deduplication, and cross-reference boosting.
通过mcp__memory__*实现知识图谱编排,支持实体提取、查询解析、去重和交叉引用增强。
Overview
概述
- Comprehensive memory retrieval from the knowledge graph
- Cross-referencing entities within graph storage
- Ensuring no relevant memories are missed
- Building unified context from graph queries
- 从知识图谱中全面检索内存
- 在图存储中交叉引用实体
- 确保不遗漏任何相关内存
- 基于图查询构建统一上下文
Architecture Overview
架构概述
┌─────────────────────────────────────────────────────────────┐
│ Memory Fabric Layer │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ │
│ │ Query │ │ Query │ │
│ │ Parser │ │ Executor │ │
│ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌──────────────────────────────────────────────┐ │
│ │ Graph Query Dispatch │ │
│ └──────────────────────┬───────────────────────┘ │
│ │ │
│ ┌─────────▼──────────┐ │
│ │ mcp__memory__* │ │
│ │ (Knowledge Graph) │ │
│ └─────────┬──────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────┐ │
│ │ Result Normalizer │ │
│ └─────────────────────┬───────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────┐ │
│ │ Deduplication Engine (>85% sim) │ │
│ └─────────────────────┬───────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────┐ │
│ │ Cross-Reference Booster │ │
│ └─────────────────────┬───────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────┐ │
│ │ Final Ranking: recency × relevance │ │
│ │ × source_authority │ │
│ └─────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘┌─────────────────────────────────────────────────────────────┐
│ Memory Fabric Layer │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ │
│ │ Query │ │ Query │ │
│ │ Parser │ │ Executor │ │
│ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌──────────────────────────────────────────────┐ │
│ │ Graph Query Dispatch │ │
│ └──────────────────────┬───────────────────────┘ │
│ │ │
│ ┌─────────▼──────────┐ │
│ │ mcp__memory__* │ │
│ │ (Knowledge Graph) │ │
│ └─────────┬──────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────┐ │
│ │ Result Normalizer │ │
│ └─────────────────────┬───────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────┐ │
│ │ Deduplication Engine (>85% sim) │ │
│ └─────────────────────┬───────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────┐ │
│ │ Cross-Reference Booster │ │
│ └─────────────────────┬───────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────┐ │
│ │ Final Ranking: recency × relevance │ │
│ │ × source_authority │ │
│ └─────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘Unified Search Workflow
统一搜索工作流
Step 1: Parse Query
步骤1:解析查询
Extract search intent and entity hints from natural language:
Input: "What pagination approach did database-engineer recommend?"
Parsed:
- query: "pagination approach recommend"
- entity_hints: ["database-engineer", "pagination"]
- intent: "decision" or "pattern"从自然语言中提取搜索意图和实体提示:
Input: "What pagination approach did database-engineer recommend?"
Parsed:
- query: "pagination approach recommend"
- entity_hints: ["database-engineer", "pagination"]
- intent: "decision" or "pattern"Step 2: Execute Graph Query
步骤2:执行图查询
Query Graph (entity search):
javascript
mcp__memory__search_nodes({
query: "pagination database-engineer"
})图查询(实体搜索):
javascript
mcp__memory__search_nodes({
query: "pagination database-engineer"
})Step 3: Normalize Results
步骤3:标准化结果
Transform results to common format:
json
{
"id": "graph:original_id",
"text": "content text",
"source": "graph",
"timestamp": "ISO8601",
"relevance": 0.0-1.0,
"entities": ["entity1", "entity2"],
"metadata": {}
}将结果转换为通用格式:
json
{
"id": "graph:original_id",
"text": "content text",
"source": "graph",
"timestamp": "ISO8601",
"relevance": 0.0-1.0,
"entities": ["entity1", "entity2"],
"metadata": {}
}Step 4: Deduplicate (>85% Similarity)
步骤4:去重(相似度>85%)
When two results have >85% text similarity:
- Keep the one with higher relevance score
- Merge metadata
- Mark as "cross-validated" for authority boost
当两个结果的文本相似度超过85%时:
- 保留相关性分数更高的结果
- 合并元数据
- 标记为"交叉验证"以提升权威性
Step 5: Cross-Reference Boost
步骤5:交叉引用增强
If a result mentions an entity that exists elsewhere in the graph:
- Boost relevance score by 1.2x
- Add graph relationships to result metadata
如果某个结果提到的实体在图中的其他位置存在:
- 将相关性分数提升1.2倍
- 在结果元数据中添加图关系
Step 6: Final Ranking
步骤6:最终排序
Score =
recency_factor × relevance × source_authority| Factor | Weight | Description |
|---|---|---|
| recency | 0.3 | Newer memories rank higher |
| relevance | 0.5 | Semantic match quality |
| source_authority | 0.2 | Graph entities boost, cross-validated boost |
分数 =
recency_factor × relevance × source_authority| 因子 | 权重 | 描述 |
|---|---|---|
| recency(时效性) | 0.3 | 较新的内存排名更高 |
| relevance(相关性) | 0.5 | 语义匹配质量 |
| source_authority(来源权威性) | 0.2 | 图实体增强、交叉验证增强 |
Result Format
结果格式
json
{
"query": "original query",
"total_results": 4,
"sources": {
"graph": 4
},
"results": [
{
"id": "graph:cursor-pagination",
"text": "Use cursor-based pagination for scalability",
"score": 0.92,
"source": "graph",
"timestamp": "2026-01-15T10:00:00Z",
"entities": ["cursor-pagination", "database-engineer"],
"graph_relations": [
{ "from": "database-engineer", "relation": "recommends", "to": "cursor-pagination" }
]
}
]
}json
{
"query": "original query",
"total_results": 4,
"sources": {
"graph": 4
},
"results": [
{
"id": "graph:cursor-pagination",
"text": "Use cursor-based pagination for scalability",
"score": 0.92,
"source": "graph",
"timestamp": "2026-01-15T10:00:00Z",
"entities": ["cursor-pagination", "database-engineer"],
"graph_relations": [
{ "from": "database-engineer", "relation": "recommends", "to": "cursor-pagination" }
]
}
]
}Entity Extraction
实体提取
Memory Fabric extracts entities from natural language for graph storage:
Input: "database-engineer uses pgvector for RAG applications"
Extracted:
- Entities:
- { name: "database-engineer", type: "agent" }
- { name: "pgvector", type: "technology" }
- { name: "RAG", type: "pattern" }
- Relations:
- { from: "database-engineer", relation: "uses", to: "pgvector" }
- { from: "pgvector", relation: "used_for", to: "RAG" }See for detailed extraction patterns.
references/entity-extraction.mdMemory Fabric从自然语言中提取实体用于图存储:
Input: "database-engineer uses pgvector for RAG applications"
Extracted:
- Entities:
- { name: "database-engineer", type: "agent" }
- { name: "pgvector", type: "technology" }
- { name: "RAG", type: "pattern" }
- Relations:
- { from: "database-engineer", relation: "uses", to: "pgvector" }
- { from: "pgvector", relation: "used_for", to: "RAG" }详情请参考中的提取模式。
references/entity-extraction.mdGraph Relationship Traversal
图关系遍历
Memory Fabric supports multi-hop graph traversal for complex relationship queries.
Memory Fabric支持多跳图遍历,用于复杂关系查询。
Example: Multi-Hop Query
示例:多跳查询
Query: "What did database-engineer recommend about pagination?"
1. Search for "database-engineer pagination"
→ Find entity: "database-engineer recommends cursor-pagination"
2. Traverse related entities (depth 2)
→ Traverse: database-engineer → recommends → cursor-pagination
→ Find: "cursor-pagination uses offset-based approach"
3. Return results with relationship contextQuery: "What did database-engineer recommend about pagination?"
1. 搜索"database-engineer pagination"
→ 找到实体:"database-engineer recommends cursor-pagination"
2. 遍历相关实体(深度2)
→ 遍历:database-engineer → recommends → cursor-pagination
→ 找到:"cursor-pagination uses offset-based approach"
3. 返回包含关系上下文的结果Integration with Graph Memory
与图内存的集成
Memory Fabric uses the knowledge graph for entity relationships:
- Graph search via finds matching entities
mcp__memory__search_nodes - Graph traversal expands context via entity relationships
- Cross-reference boosts relevance when entities match
Memory Fabric利用知识图谱处理实体关系:
- 通过进行图搜索,找到匹配的实体
mcp__memory__search_nodes - 图遍历通过实体关系扩展上下文
- 当实体匹配时,交叉引用提升相关性
Integration Points
集成点
With memory Skill
与memory Skill集成
When memory search runs, it can optionally use Memory Fabric for unified results.
当执行内存搜索时,可选择使用Memory Fabric获取统一结果。
With Hooks
与Hooks集成
- - Inject unified context at session start
prompt/memory-fabric-context.sh - - Sync entities to graph at session end
stop/memory-fabric-sync.sh
- - 在会话开始时注入统一上下文
prompt/memory-fabric-context.sh - - 在会话结束时将实体同步到图中
stop/memory-fabric-sync.sh
Configuration
配置
bash
undefinedbash
undefinedEnvironment variables
环境变量
MEMORY_FABRIC_DEDUP_THRESHOLD=0.85 # Similarity threshold for merging
MEMORY_FABRIC_BOOST_FACTOR=1.2 # Cross-reference boost multiplier
MEMORY_FABRIC_MAX_RESULTS=20 # Max results per source
undefinedMEMORY_FABRIC_DEDUP_THRESHOLD=0.85 # 合并的相似度阈值
MEMORY_FABRIC_BOOST_FACTOR=1.2 # 交叉引用增强乘数
MEMORY_FABRIC_MAX_RESULTS=20 # 每个来源的最大结果数
undefinedMCP Requirements
MCP要求
Required: Knowledge graph MCP server:
json
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@anthropic/memory-mcp-server"]
}
}
}必需: 知识图谱MCP服务器:
json
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@anthropic/memory-mcp-server"]
}
}
}Error Handling
错误处理
| Scenario | Behavior |
|---|---|
| graph unavailable | Error - graph is required |
| Query empty | Return recent memories from graph |
| 场景 | 行为 |
|---|---|
| 图不可用 | 报错 - 图是必需组件 |
| 查询为空 | 返回图中的最新内存 |
Related Skills
相关技能
- - User-facing memory operations (search, load, sync, viz)
memory - - User-facing memory storage
remember - - Caching layer that can use fabric
caching
- - 面向用户的内存操作(搜索、加载、同步、可视化)
memory - - 面向用户的内存存储
remember - - 可使用fabric的缓存层
caching
Key Decisions
关键决策
| Decision | Choice | Rationale |
|---|---|---|
| Dedup threshold | 85% | Balances catching duplicates vs. preserving nuance |
| Parallel queries | Always | Reduces latency, both sources are independent |
| Cross-ref boost | 1.2x | Validated info more trustworthy but not dominant |
| Ranking weights | 0.3/0.5/0.2 | Relevance most important, recency secondary |
| 决策 | 选择 | 理由 |
|---|---|---|
| 去重阈值 | 85% | 在捕获重复内容与保留细节之间取得平衡 |
| 并行查询 | 始终启用 | 降低延迟,各来源相互独立 |
| 交叉引用增强系数 | 1.2倍 | 验证过的信息更可信,但不会成为主导因素 |
| 排序权重 | 0.3/0.5/0.2 | 相关性最重要,时效性次之 |