ruvnet/ruflo/tree/main/plugins/ruflo-rag-memory
ruflo-rag-memory
HNSW 검색, AgentDB, 시맨틱 검색을 갖춘 RuVector 메모리입니다. 플러그인(ADR-445)으로서 시크릿을 메모리에 저장하지 않는 쓰기 가드, /rag-mod, 콘솔에 표시되는 상태 파일을 제공합니다.
이 mod 소개
ruflo-rag-memory
HNSW 벡터 검색, AgentDB 영속화, Claude Code 메모리 브리지를 제공하는 Retrieval-Augmented Generation 메모리입니다.
개요
AgentDB에서 의미 기반 저장, 검색, 회상을 제공하며 HNSW 인덱스 벡터 검색을 사용합니다(N=20k에서 무차별 대입 검색보다 약 1.9배, N=5k에서 약 3.2x–4.7x 빠르게 측정되었고 recall@10은 약 0.99입니다. 인덱스 크기의 교차점을 넘으면 ANN이 유리합니다). Claude Code의 네이티브 자동 메모리를 384차원 ONNX 임베딩과 함께 AgentDB로 연결해 세션을 넘나드는 통합 시맨틱 검색을 제공합니다.
빠른 시작
세션 간에 지식을 저장하고 가져옵니다.
# Store a pattern you want to remember
npx ruflo memory store --key "oauth-flow" --value "OAuth2 with pkce for SPAs, use refresh tokens" --namespace patterns
# Search for it later (even across projects!)
npx ruflo recall "oauth single page app"
# Retrieve exact entry
npx ruflo memory retrieve --key "oauth-flow" --namespace patterns
에이전트와 함께 사용합니다.
# In your Claude Code agent prompt:
const context = await memory_search({ query: "authentication patterns", limit: 3 });
// Returns top 3 semantic matches from all sessions
설치
claude --plugin-dir plugins/ruflo-rag-memory
필요 사항
ruflo-core플러그인(MCP 서버 제공)
에이전트
| 에이전트 | 모델 | 역할 |
|-------|-------|------|
| memory-specialist | sonnet | AgentDB 관리, HNSW 최적화, 메모리 브리지, 통합 |
스킬
| 스킬 | 사용법 | 설명 |
|-------|-------|------|
| memory-search | /memory-search <query> | 모든 네임스페이스의 시맨틱 벡터 검색 |
| memory-bridge | /memory-bridge [--all-projects] | Claude Code 자동 메모리를 AgentDB로 가져오기 |
명령
# Store a memory entry
memory store --key "pattern-auth" --value "JWT with refresh tokens" --namespace patterns
# Semantic search (HNSW-indexed)
memory search --query "authentication patterns" --namespace patterns --limit 5
# Retrieve by key
memory retrieve --key "pattern-auth" --namespace patterns
# List entries
memory list --namespace patterns --limit 10
# Delete
memory delete --key "old-entry" --namespace patterns
# Quick semantic recall across all namespaces
recall "how did we handle rate limiting?"
아키텍처
Claude Code Auto-Memory (~/.claude/projects/*/memory/*.md)
│
▼ (ONNX all-MiniLM-L6-v2, 384-dim)
Memory Bridge
│
▼
AgentDB (SQLite + vector_indexes)
│
├── patterns namespace
├── tasks namespace
├── solutions namespace
├── feedback namespace
├── security namespace
└── claude-memories namespace
│
▼ (HNSW ANN index)
Semantic Search (HNSW ANN — measured ~1.9x at N=20k vs brute force; see docs/reviews/intelligence-system-audit-2026-05-29.md)
저장 암호화(ruflo 3.6.25+)
이 플러그인이 작성하는 AgentDB SQLite 블롭(.swarm/memory.db)은 ADR-096에 따라 AES-256-GCM 저장 암호화를 선택적으로 지원합니다. CLAUDE_FLOW_ENCRYPT_AT_REST=1 및 CLAUDE_FLOW_ENCRYPTION_KEY 를 설정하면 다음과 같이 동작합니다.
.swarm/memory.db를 쓸 때마다 새 12바이트 IV로 암호화합니다(writeFileRestricted({encrypt:true})).readFileMaybeEncrypted(path, null)로 읽으며 매직 바이트(RFE1)를 감지하므로 마이그레이션 기간의 기존 평문 memory.db도 그대로 작동합니다.- 임베딩은 SQLite 블롭의 나머지 부분과 함께 암호화되므로 Phase 1에서 별도 열 수준 암호화가 필요하지 않습니다.
- 바이트 하나가 뒤집히면 GCM 인증이 실패해 조용한 손상 대신 복호화 오류가 납니다.
ruflo doctor -c encryption으로 게이트 상태를 확인합니다. 기본값은 꺼짐이며 켜는 데 마이그레이션 단계가 필요하지 않습니다(읽을 때 기존 평문 바이트를 감지하고 처음 쓸 때 암호화된 DB로 다시 씁니다).
메모리 네임스페이스
| 네임스페이스 | 목적 | 예시 키 |
|-----------|------|--------|
| patterns | 성공한 코드/설계 패턴 | pattern-auth-jwt |
| tasks | 작업 컨텍스트와 결과 | task-refactor-api |
| solutions | 버그 수정과 해결책 | fix-race-condition |
| feedback | 사용자 피드백과 수정 | feedback-style-test |
| security | 취약점 패턴 | vuln-sql-injection |
| claude-memories | 연결된 Claude Code 메모리 | auto-imported |
Claude 메모리 브리지
AgentDB 세션이 시작되면 Claude Code의 네이티브 ~/.claude/projects/*/memory/*.md 파일을 ONNX 벡터 임베딩과 함께 자동으로 가져옵니다.
# Manual import (current project)
/memory-bridge
# Import all projects
/memory-bridge --all-projects
# Check bridge health
# Via MCP: memory_bridge_status({})
결과에는 claude-code, auto-memory 또는 agentdb의 출처 정보가 포함됩니다.
SmartRetrieval(ADR-090)
세션을 넘나드는 검색 품질을 높이는 5단계 파이프라인입니다.
- 쿼리 확장 ——템플릿으로 변형 생성(LLM 없음)
- 다중 쿼리 팬아웃 + RRF ——변형별 역순위 융합
- 최신성 가중치 ——메타데이터 타임스탬프의 지수 감쇠
- MMR 다양성 ——token-Jaccard 최대 주변 관련성으로 재정렬
- 세션 라운드 로빈 ——서로 다른 세션의 결과를 번갈아 반환
# CLI
npx @claude-flow/cli@latest memory search --query "auth patterns" --smart --limit 10
# MCP
mcp__plugin_ruflo-core_ruflo__memory_search({ query: "auth patterns", smart: true, limit: 10 })
다중 세션 검색, 시간 질문(“지난주 속도 제한을 어떻게 처리했지?”), 다양한 결과가 필요할 때 적합합니다.
통합 검색
모든 네임스페이스를 동시에 조회하고 MMR 다양성 재정렬을 적용합니다.
# Via MCP: memory_search_unified({ query: "auth security", limit: 5 })
# Via CLI:
npx @claude-flow/cli@latest memory search --query "auth security" --limit 5
HNSW 성능
실측값은 docs/reviews/intelligence-system-audit-2026-05-29.md와 scripts/benchmark-intelligence.mjs에서 가져왔습니다.
| 작업 | 무차별 대입 검색 대비 | 비고 | |-----------|----------------|-------| | N=5k 벡터 검색 | 약 3.2x–4.7x 빠름 | ruvector NAPI, recall@10 약 0.99 | | N=20k 벡터 검색 | 약 1.9x 빠름 | 교차점 이상에서는 ANN이 유리 | | 교차점 미만 벡터 검색 | 비슷하거나 느림 | 작은 규모에는 무차별 대입 검색 우선 |
이전에 공개된 “150x–12,500x” 수치는 무차별 대입 폴백의 산물이며 감사 하니스에서는 재현되지 않습니다.
ruvector 통합
ruflo-ruvector도 로드되어 있으면 rag-memory가 백엔드를 ruvector에 위임해 고급 기능을 사용합니다.
- FlashAttention-3를 이용한 O(N) 메모리 어텐션
- 다중 홉 검색을 위한 Graph RAG
- RRF 융합 하이브리드 검색(희소 + 밀집)
- 대규모 영속 인덱스를 위한 DiskANN
호환성
- CLI:
@claude-flow/cliv3.6 메이저+마이너로 고정됩니다. - 검증:
bash plugins/ruflo-rag-memory/scripts/smoke.sh가 계약입니다.
네임스페이스 조정 — claude-memories 소비자
이 플러그인은 ruflo-agentdb ADR-0001 “Namespace convention”에 정의된 claude-memories 예약 네임스페이스의 표준 사용자 측 소비자입니다. 자동 가져오기 흐름은 다음과 같습니다.
Claude Code SessionStart hook
→ memory_import_claude (MCP)
→ claude-memories namespace (reserved, ruflo-agentdb owned)
→ exposed by this plugin's memory-bridge skill + memory_search_unified
이 플러그인은 claude-memories를 소유하지 않고 소비합니다. 예약 네임스페이스(pattern, claude-memories, default)를 가로채면 안 됩니다.
다른 네임스페이스(patterns, tasks, solutions, feedback, security)는 네임스페이스 라우팅된 memory_*로 접근합니다. 플러그인은 올바른 라우팅만 사용하며 네임스페이스 인수가 붙은 agentdb_hierarchical-* 또는 agentdb_pattern-store는 사용하지 않습니다.
검증
bash plugins/ruflo-rag-memory/scripts/smoke.sh
# Expected: "10 passed, 0 failed"
아키텍처 결정
- ADR-0001 — ruflo-rag-memory plugin contract (claude-memories reserved-namespace consumer, smoke as contract) (./docs/adrs/0001-rag-memory-contract.md)
관련 플러그인
ruflo-agentdb— 전체 AgentDB 컨트롤러 브리지(15개의agentdb_*MCP 도구); 네임스페이스 규칙 소유자이며claude-memories예약 네임스페이스를 소유ruflo-ruvector— 고급 벡터 연산(FlashAttention-3, Graph RAG, 하이브리드 검색)ruflo-rvf— 머신 간 내보내기/가져오기를 위한 이식 가능한 RVF 메모리 형식ruflo-knowledge-graph— 메모리에서 엔터티를 추출하고 그래프를 순회
라이선스
MIT
플러그인으로 사용
함수 훅 플러그인(ADR-445, ruflo-agentdb 패턴)입니다. hooks/hooks.json → hooks/register.ts에서 로드됩니다.
메모리 쓰기 가드인 memory_store, agentdb_hierarchical-store, agentdb_pattern-store는 시크릿을 거부하므로 자격 증명이 벡터 저장소에 들어가지 않습니다.
- 명령:
/rag-mod는 모델을 호출하지 않고 로컬에서 응답합니다. 동사는status,scan <text>(가드가 이 텍스트를 거부할까?),tools(연결된 메모리 도구)입니다. - 상태 파일:
.claude-flow/rag-mod/status.json({version, updatedMs, ...counters})을 세션 시작과 카운터 변경 때 씁니다. - 안전: 네트워크에 접근하거나 프로세스를 생성하지 않고 이미 연결된 도구만 사용합니다.
- 옵션
guard(기본on,off로 끌 수 있음): 강화만 수행하는tool.call가드입니다. 위 도구 중 하나의 입력에 키, 토큰, 개인 키 또는 비밀번호가 들어 있으면 호출을 거부합니다. 거부 이유에 시크릿을 다시 쓰지 않습니다. - 테스트:
claude plugin validate plugins/ruflo-rag-memory,claude plugin test plugins/ruflo-rag-memory,bash plugins/ruflo-rag-memory/scripts/smoke.sh。
설치
먼저 작성자의 README에서 marketplace와 플러그인 이름을 확인하세요. 저장소 구조에 따라 명령어가 달라질 수 있습니다.
claude plugin marketplace add ruvnet/ruflo claude plugin install ruflo-rag-memory
원문 / README
ruflo-rag-memory
Retrieval-Augmented Generation memory with HNSW vector search, AgentDB persistence, and Claude Code memory bridge.
Overview
Provides semantic store/search/recall over AgentDB with HNSW-indexed vector search (measured ~1.9x at N=20k, ~3.2x–4.7x at N=5k vs brute force, recall@10 ~0.99; ANN wins above the index-size crossover). Bridges Claude Code's native auto-memory into AgentDB with 384-dim ONNX embeddings for unified cross-session semantic retrieval.
Quick Start
Store and retrieve knowledge across sessions:
# Store a pattern you want to remember
npx ruflo memory store --key "oauth-flow" --value "OAuth2 with pkce for SPAs, use refresh tokens" --namespace patterns
# Search for it later (even across projects!)
npx ruflo recall "oauth single page app"
# Retrieve exact entry
npx ruflo memory retrieve --key "oauth-flow" --namespace patterns
Use with agents:
# In your Claude Code agent prompt:
const context = await memory_search({ query: "authentication patterns", limit: 3 });
// Returns top 3 semantic matches from all sessions
Installation
claude --plugin-dir plugins/ruflo-rag-memory
Requires
ruflo-coreplugin (provides MCP server)
Agents
| Agent | Model | Role |
|-------|-------|------|
| memory-specialist | sonnet | AgentDB management, HNSW optimization, memory bridge, consolidation |
Skills
| Skill | Usage | Description |
|-------|-------|-------------|
| memory-search | /memory-search <query> | Semantic vector search across all namespaces |
| memory-bridge | /memory-bridge [--all-projects] | Import Claude Code auto-memory into AgentDB |
Commands
# Store a memory entry
memory store --key "pattern-auth" --value "JWT with refresh tokens" --namespace patterns
# Semantic search (HNSW-indexed)
memory search --query "authentication patterns" --namespace patterns --limit 5
# Retrieve by key
memory retrieve --key "pattern-auth" --namespace patterns
# List entries
memory list --namespace patterns --limit 10
# Delete
memory delete --key "old-entry" --namespace patterns
# Quick semantic recall across all namespaces
recall "how did we handle rate limiting?"
Architecture
Claude Code Auto-Memory (~/.claude/projects/*/memory/*.md)
│
▼ (ONNX all-MiniLM-L6-v2, 384-dim)
Memory Bridge
│
▼
AgentDB (SQLite + vector_indexes)
│
├── patterns namespace
├── tasks namespace
├── solutions namespace
├── feedback namespace
├── security namespace
└── claude-memories namespace
│
▼ (HNSW ANN index)
Semantic Search (HNSW ANN — measured ~1.9x at N=20k vs brute force; see docs/reviews/intelligence-system-audit-2026-05-29.md)
Encryption at rest (ruflo 3.6.25+)
The AgentDB SQLite blob written by this plugin (.swarm/memory.db) supports opt-in AES-256-GCM encryption at rest per ADR-096. When CLAUDE_FLOW_ENCRYPT_AT_REST=1 and CLAUDE_FLOW_ENCRYPTION_KEY is set:
- Each write of
.swarm/memory.dbis encrypted with a fresh 12-byte IV (writeFileRestricted({encrypt:true})). - Reads use
readFileMaybeEncrypted(path, null)— magic-byte sniff (RFE1) so legacy plaintext memory.db files keep working unchanged during the migration window. - Embeddings are encrypted along with the rest of the SQLite blob — no separate column-level encryption needed for Phase 1.
- A flipped byte fails GCM auth and produces a decrypt error rather than silent corruption.
Verify gate state with ruflo doctor -c encryption. Off by default; flipping it on doesn't require a migration step (legacy plaintext bytes are sniffed on read; first write after enable rewrites the DB encrypted).
Memory Namespaces
| Namespace | Purpose | Example Key |
|-----------|---------|-------------|
| patterns | Successful code/design patterns | pattern-auth-jwt |
| tasks | Task context and outcomes | task-refactor-api |
| solutions | Bug fixes and solutions | fix-race-condition |
| feedback | User feedback and corrections | feedback-test-style |
| security | Vulnerability patterns | vuln-sql-injection |
| claude-memories | Bridged Claude Code memories | auto-imported |
Claude Memory Bridge
Auto-imports Claude Code's native ~/.claude/projects/*/memory/*.md files into AgentDB on session start with ONNX vector embeddings.
# Manual import (current project)
/memory-bridge
# Import all projects
/memory-bridge --all-projects
# Check bridge health
# Via MCP: memory_bridge_status({})
Results include source attribution: claude-code, auto-memory, or agentdb.
SmartRetrieval (ADR-090)
5-phase retrieval pipeline for higher-quality recall across sessions:
- Query expansion -- template-based variant generation (no LLM)
- Multi-query fan-out + RRF -- Reciprocal Rank Fusion across variants
- Recency boost -- exponential decay from metadata timestamps
- MMR diversity -- token-Jaccard Maximal Marginal Relevance re-ranking
- Session round-robin -- interleaved results from distinct sessions
# CLI
npx @claude-flow/cli@latest memory search --query "auth patterns" --smart --limit 10
# MCP
mcp__plugin_ruflo-core_ruflo__memory_search({ query: "auth patterns", smart: true, limit: 10 })
Best for multi-session recall, temporal queries ("what did we decide last week?"), and diverse result sets.
Unified Search
Queries across all namespaces simultaneously with MMR diversity reranking:
# Via MCP: memory_search_unified({ query: "auth security", limit: 5 })
# Via CLI:
npx @claude-flow/cli@latest memory search --query "auth security" --limit 5
HNSW Performance
Measured numbers from docs/reviews/intelligence-system-audit-2026-05-29.md + scripts/benchmark-intelligence.mjs:
| Operation | vs Brute Force | Notes | |-----------|----------------|-------| | Vector search (N=5k) | ~3.2x–4.7x faster | ruvector NAPI, recall@10 ~0.99 | | Vector search (N=20k) | ~1.9x faster | ANN wins above crossover | | Vector search (below crossover) | ties/loses | brute force preferred for small N |
The previously published "150x–12,500x" figures were brute-force fallback artifacts and are not reproduced under the audit harness.
Integration with ruvector
When ruflo-ruvector is also loaded, rag-memory delegates to ruvector's backend for advanced features:
- FlashAttention-3 for O(N) memory attention
- Graph RAG for multi-hop knowledge retrieval
- Hybrid search (sparse + dense) with RRF fusion
- DiskANN for large-scale persistent indexes
Compatibility
- CLI: pinned to
@claude-flow/cliv3.6 major+minor. - Verification:
bash plugins/ruflo-rag-memory/scripts/smoke.shis the contract.
Namespace coordination — claude-memories consumer
This plugin is the canonical user-facing consumer of the claude-memories reserved namespace defined in ruflo-agentdb ADR-0001 §"Namespace convention". The auto-import flow:
Claude Code SessionStart hook
→ memory_import_claude (MCP)
→ claude-memories namespace (reserved, ruflo-agentdb owned)
→ exposed by this plugin's memory-bridge skill + memory_search_unified
This plugin does not own claude-memories — it consumes it. Reserved namespaces (pattern, claude-memories, default) MUST NOT be shadowed.
Other namespaces (patterns, tasks, solutions, feedback, security) are accessed via memory_* (namespace-routed). The plugin uses correct routing throughout — no agentdb_hierarchical-* or agentdb_pattern-store with namespace arguments.
Verification
bash plugins/ruflo-rag-memory/scripts/smoke.sh
# Expected: "10 passed, 0 failed"
Architecture Decisions
Related Plugins
ruflo-agentdb— Full AgentDB controller bridge (15agentdb_*MCP tools); namespace convention owner; owns theclaude-memoriesreserved namespaceruflo-ruvector— Advanced vector operations (FlashAttention-3, Graph RAG, hybrid search)ruflo-rvf— Portable RVF memory format for cross-machine export/importruflo-knowledge-graph— Entity extraction and graph traversal over memory
License
MIT
As a mod
Function-hook mod (ADR-445, pattern of ruflo-agentdb). It loads from hooks/hooks.json → hooks/register.ts.
A write guard for memory: memory_store, agentdb_hierarchical-store and agentdb_pattern-store refuse secrets, so credentials never land in the vector store.
- Command:
/rag-modanswers locally with no model call. Verbs:status,scan <text>(would the guard refuse this?),tools(which memory tools are connected). - Status file:
.claude-flow/rag-mod/status.json({version, updatedMs, ...counters}), written at session start and as counters change. - Safety: no network, no process spawning; it only uses tools already connected.
- Option
guard(onby default,offto disable): a tighten-onlytool.callguard. A call to one of the tools above whose input holds a key, token, private key or password is denied. The reason never repeats the secret. - Test:
claude plugin validate plugins/ruflo-rag-memory,claude plugin test plugins/ruflo-rag-memory,bash plugins/ruflo-rag-memory/scripts/smoke.sh.

