memory-fabric

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Memory 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:
  1. Keep the one with higher relevance score
  2. Merge metadata
  3. Mark as "cross-validated" for authority boost
当两个结果的文本相似度超过85%时:
  1. 保留相关性分数更高的结果
  2. 合并元数据
  3. 标记为"交叉验证"以提升权威性

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
FactorWeightDescription
recency0.3Newer memories rank higher
relevance0.5Semantic match quality
source_authority0.2Graph 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
references/entity-extraction.md
for detailed extraction patterns.
Memory 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.md
中的提取模式。

Graph 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 context
Query: "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:
  1. Graph search via
    mcp__memory__search_nodes
    finds matching entities
  2. Graph traversal expands context via entity relationships
  3. Cross-reference boosts relevance when entities match
Memory Fabric利用知识图谱处理实体关系:
  1. 通过
    mcp__memory__search_nodes
    进行图搜索,找到匹配的实体
  2. 图遍历通过实体关系扩展上下文
  3. 当实体匹配时,交叉引用提升相关性

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集成

  • prompt/memory-fabric-context.sh
    - Inject unified context at session start
  • stop/memory-fabric-sync.sh
    - Sync entities to graph at session end
  • prompt/memory-fabric-context.sh
    - 在会话开始时注入统一上下文
  • stop/memory-fabric-sync.sh
    - 在会话结束时将实体同步到图中

Configuration

配置

bash
undefined
bash
undefined

Environment 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
undefined
MEMORY_FABRIC_DEDUP_THRESHOLD=0.85 # 合并的相似度阈值 MEMORY_FABRIC_BOOST_FACTOR=1.2 # 交叉引用增强乘数 MEMORY_FABRIC_MAX_RESULTS=20 # 每个来源的最大结果数
undefined

MCP 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

错误处理

ScenarioBehavior
graph unavailableError - graph is required
Query emptyReturn recent memories from graph
场景行为
图不可用报错 - 图是必需组件
查询为空返回图中的最新内存

Related Skills

相关技能

  • memory
    - User-facing memory operations (search, load, sync, viz)
  • remember
    - User-facing memory storage
  • caching
    - Caching layer that can use fabric
  • memory
    - 面向用户的内存操作(搜索、加载、同步、可视化)
  • remember
    - 面向用户的内存存储
  • caching
    - 可使用fabric的缓存层

Key Decisions

关键决策

DecisionChoiceRationale
Dedup threshold85%Balances catching duplicates vs. preserving nuance
Parallel queriesAlwaysReduces latency, both sources are independent
Cross-ref boost1.2xValidated info more trustworthy but not dominant
Ranking weights0.3/0.5/0.2Relevance most important, recency secondary
决策选择理由
去重阈值85%在捕获重复内容与保留细节之间取得平衡
并行查询始终启用降低延迟,各来源相互独立
交叉引用增强系数1.2倍验证过的信息更可信,但不会成为主导因素
排序权重0.3/0.5/0.2相关性最重要,时效性次之