---
title: "ruflo-agentdb"
url: "https://claudemods.dev/ko/builds/ruflo-agentdb-4e8c67"
source: "https://github.com/ruvnet/ruflo/tree/main/plugins/ruflo-agentdb"
source_type: "github"
repo: "https://github.com/ruvnet/ruflo/tree/main/plugins/ruflo-agentdb"
author: "ruvnet"
author_handle: "ruvnet"
stars: 82617
category: "기타"
categories: ["other"]
tags: []
permission_level: 2
scan_complete: true
install: "claude plugin marketplace add ruvnet/ruflo\nclaude plugin install ruflo-agentdb@ruflo"
added: "2026-10-05T15:42:11.297Z"
updated: "2026-11-28T23:39:59Z"
locale: "ko"
content_locale: "ko"
---

# ruflo-agentdb

Ruflo 메모리 기반용 플러그인입니다. AgentDB 컨트롤러 브리지（15개 agentdb_* MCP 도구）, RuVector ONNX 임베딩（RaBitQ 32x 양자화를 포함한 10개 embeddings_* 도구）, WASM HNSW 패턴 라우터（3개 ruvllm_hnsw_* 도구）를 제공합니다. mod（ADR-445）로서 프롬프트에 안전한 선택적 회수를 넣고, 비밀이 메모리에 들어가지 않도록 쓰기 가드를 두며, /agentdb와 콘솔이 보여 주는 상태 파일을 제공합니다.

## Description

# ruflo-agentdb

Ruflo 메모리 기반을 위한 플러그인입니다. 세 가지 CLI MCP 제품군인 `agentdb_*`（컨트롤러 브리지, 도구 15개）, `embeddings_*`（RuVector ONNX 엔진, 도구 10개）, `ruvllm_hnsw_*`（WASM 기반 패턴 라우터, 도구 3개）를 검색 가능한 skill과 명령으로 묶습니다. 다른 플러그인（`ruflo-browser`, `ruflo-rag-memory`, `ruflo-intelligence`）이 이 기반을 조합해 사용하며, 이 플러그인은 전체 기반의 네임스페이스 규칙과 smoke contract를 소유합니다.

> **상태:** ADR-0001이 구현되었습니다. 플러그인 v0.3.0은 `@claude-flow/cli` v3.6.x를 대상으로 하며 `agentdb@^3.0.0-alpha.11`을 포함합니다. smoke contract（번호가 붙은 검사 13개 + 문서 불변 조건 3개）가 검증 수단입니다. [docs/adrs/0001-agentdb-optimization.md](./docs/adrs/0001-agentdb-optimization.md)를 참조하세요.

## 설치

```
/plugin marketplace add ruvnet/ruflo
/plugin install ruflo-agentdb@ruflo
```

## 호환성

- **CLI:** `@claude-flow/cli` v3.6의 주 버전과 부 버전에 고정됩니다. v3.6 안의 패치 업데이트는 no-op가 될 예정입니다.
- **AgentDB:** CLI는 `agentdb@^3.0.0-alpha.11`을 포함합니다. 플러그인은 npm 패키지를 **고정하지 않습니다**. 내부 버전（alpha.11 → alpha.12 등）은 플러그인의 계약이 아닙니다.
- **검증:** 포함된 smoke script가 기준입니다（`bash plugins/ruflo-agentdb/scripts/smoke.sh`）. 사용하는 CLI 버전에서 smoke가 통과하면 플러그인의 계약이 유지됩니다.

## 기능

- **컨트롤러 브리지:** 15개의 `agentdb_*` MCP 도구（계층형 저장/회수, 의미 라우팅, 패턴 저장/검색, 인과 엣지, 컨텍스트 합성, 배치 작업, 통합, 피드백, 세션）입니다.
- **RuVector 임베딩:** 10개의 `embeddings_*` MCP 도구입니다. 384차원 ONNX（all-MiniLM-L6-v2）, HNSW 검색, 쌍곡선（Poincare）, 신경 기반, **RaBitQ 1-bit 양자화（메모리 32× 절감）**를 제공합니다.
- **HNSW 패턴 라우터:** 3개의 `ruvllm_hnsw_*` 도구（WASM 기반, 우선순위가 높은 패턴 최대 11개）입니다. 대규모 임베딩 HNSW 경로와는 다릅니다.
- **인과 지식 그래프:** `agentdb_causal-edge`（graph-node 백엔드, ADR-087에 따른 브리지 폴백）입니다.

## 컨트롤러（실제 레지스트리, INIT_LEVELS별 그룹）

이 플러그인 어디에서든 보고되는 “컨트롤러 수”는 **런타임 도구가 실제로 보고하는 값**입니다. 이름의 표준 목록은 `v3/@claude-flow/memory/src/controller-registry.ts:34-73`의 `ControllerName` union이며, 6개 초기화 레벨에 걸쳐 29개 이름이 있습니다. 런타임에서는 다음으로 확인합니다.

```bash
mcp tool call agentdb_controllers --json
```

ADR-053（`controller-registry.ts:160-174`）에 따른 초기화 순서입니다.

| 레벨 | 컨트롤러 | 역할 |
|------:|-------------|------|
| 0 | _(foundation, pre-existing)_ | 부트스트랩 |
| 1 | `reasoningBank`, `hierarchicalMemory`, `learningBridge`, `hybridSearch`, `tieredCache` | 핵심 인텔리전스 |
| 2 | `memoryGraph`, `agentMemoryScope`, `vectorBackend`, `mutationGuard`, `gnnService` | 그래프 + 보안 |
| 3 | `skills`, `explainableRecall`, `reflexion`, `attestationLog`, `batchOperations`, `memoryConsolidation` | 전문화 |
| 4 | `causalGraph`, `nightlyLearner`, `learningSystem`, `semanticRouter` | 인과 + 라우팅 |
| 5 | `graphTransformer`, `sonaTrajectory`, `contextSynthesizer`, `rvfOptimizer`, `mmrDiversityRanker`, `guardedVectorBackend` | 고급 서비스 |
| 6 | `federatedSession`, `graphAdapter` | 세션 관리 |

`graphAdapter`는 외부 graph-DB 연결을 기다리는 동안 현재 비활성화되어 있습니다（ADR-095에서 추적）. 다른 Level-2/3 보안 컨트롤러（`mutationGuard`, `attestationLog`, `gnnService`, `rvfOptimizer`, `guardedVectorBackend`）는 ruflo 3.6.23+의 ADR-095 G7에서 활성화되었습니다.

## G7 컨트롤러（ADR-095에서 활성화）

[ADR-095](../../v3/docs/adr/ADR-095-architectural-gaps-from-april-audit.md)는 이전에 비활성화된 AgentDB 컨트롤러 5개를 활성화했습니다.

| 컨트롤러 | 역할 | 소스 |
|---|---|---|
| `gnnService` | AgentDB 인과 그래프에서 Graph Neural Network 임베딩과 관계 점수를 제공합니다. 인자 없이 생성합니다. | `agentdb/dist/src/services/GNNService.js` |
| `rvfOptimizer` | RuVector 형식 압축입니다. 영속화 전에 벡터 블록을 양자화하고 중복을 제거합니다. | `agentdb/dist/src/optimizations/RVFOptimizer.js` |
| `mutationGuard` | 상태 변경을 위한 WASM 기반 증명 생성（ADR-060）입니다. | `agentdb/dist/src/security/MutationGuard.js` |
| `attestationLog` | 변경 사항의 해시 체인 감사 로그입니다. 전용 `.swarm/attestation.db`에 저장됩니다. | `agentdb/dist/src/security/AttestationLog.js` |
| `GuardedVectorBackend` | 기존 `vectorBackend`를 `mutationGuard` + `attestationLog`로 감쌉니다. | `agentdb/dist/src/backends/ruvector/GuardedVectorBackend.js` |

## 명령

- `/agentdb-mod` — AgentDB 상태, 컨트롤러 상태, 세션 관리
- `/embeddings` — RuVector 임베딩 엔진 상태와 작업

## Skills

- `agentdb-query` — 의미 라우팅과 계층형 회수로 AgentDB 조회
- `vector-search` — HNSW 벡터 검색 + RaBitQ 양자화 + 3개 튜닝 프로필

## 네임스페이스 규칙

이 플러그인은 하위 플러그인이 사용하는 네임스페이스 규칙을 담당합니다. 이 규칙을 따르면 플러그인 간 검색이 가능하고 브리지에서 우발적인 키 충돌을 피할 수 있습니다.

### 이름 지정

kebab-case 형식의 `<plugin-stem>-<intent>`를 사용합니다. 이미 사용 중인 예시는 다음과 같습니다.

| 플러그인 | 네임스페이스 |
|---|---|
| `ruflo-browser` | `browser-sessions`, `browser-selectors`, `browser-templates`, `browser-cookies` |
| `ruflo-rag-memory` |（브리지 대상 `claude-memories` 사용） |
| `ruflo-intelligence` |（폴백 대상 `pattern` 사용） |

### 예약된 네임스페이스（덮어쓰지 말 것）

| 네임스페이스 | 소유자 | 소스 |
|---|---|---|
| `pattern` | ReasoningBank 폴백 쓰기 위치 | `agentdb-tools.ts:144` |
| `claude-memories` | Claude Code 자동 메모리 브리지 대상 | bridge |
| `default` | `memory_store` 기본값 | `memory-tools.ts` |

### 네임스페이스 문자열이 실제로 적용되는 위치

네임스페이스는 **모든 곳에서 쓰는 매개변수가 아닙니다**. 라우팅을 주의해서 읽으세요.

- `memory_*` 및 `embeddings_search`는 네임스페이스로 라우팅되므로 값을 전달합니다.
- `agentdb_hierarchical-*`는 `tier`（`working|episodic|semantic`）로 라우팅되며 네임스페이스 인수는 무시됩니다.
- `agentdb_pattern-*`는 ReasoningBank 컨트롤러를 거쳐 라우팅되며 네임스페이스 인수는 무시됩니다.
- `agentdb_causal-edge`는 인과 그래프를 거쳐 라우팅되며 네임스페이스 인수는 무시됩니다.

`namespace: 'browser-cookies'`를 `agentdb_pattern-store`에 전달한다고 필터링되는 것은 아닙니다. 조용히 버려집니다.

### GC 방침

이 플러그인은 네임스페이스를 GC하지 **않습니다**. 수명 주기가 필요한 소비자 플러그인（예: `purge` 후의 `browser-sessions`）이 `memory_delete` + `agentdb_consolidate`를 사용해 직접 삭제합니다. 정리가 필요하면 예약하세요.

### 이름 지정 가드레일

네임스페이스에 `:`를 넣지 마세요（브리지의 키 내부 구분자와 충돌합니다）. 200자 이하여야 하며 `validateIdentifier`（`agentdb-tools.ts:122`에서 이미 사용하는 동일한 검증기）를 통과해야 합니다.

## Claude Code가 AgentDB를 채우는 방법

예약된 `claude-memories` 네임스페이스는 사용자가 직접 호출해서 채우는 것이 아니라 Claude Code 자체의 자동 메모리 브리지가 채웁니다. 메커니즘은 2가지입니다.

| 메커니즘 | 트리거 | 기록하는 내용 |
|---|---|---|
| `memory_import_claude` MCP 도구 | 수동 또는 hook 기반 | `~/.claude/projects/*/memory/*.md`를 읽고 YAML frontmatter를 파싱해 섹션으로 나눈 뒤 384차원 임베딩과 함께 저장합니다. `allProjects: true`는 모든 Claude 프로젝트에서 가져옵니다. |
| `.claude/helpers/auto-memory-hook.mjs` | `SessionStart`（import） 및 `SessionEnd`（sync）— `.claude/settings.json`에 연결됨 | `import` → 현재 프로젝트 브리지 호출, `sync` → AgentDB 인사이트를 `~/.claude/projects/*/memory/MEMORY.md`로 되돌림 |

검사하거나 새로 고치려면 다음을 실행합니다.

```
# What's in the bridge right now?
mcp tool call memory_bridge_status --json

# Force a re-import from Claude Code's project memory
mcp tool call memory_import_claude --json -- '{"allProjects": true}'

# Cross-namespace search across claude-memories + auto-memory + patterns + tasks + feedback
mcp tool call memory_search_unified --json -- '{"query": "your query"}'
```

`memory_search_unified`는 기본적으로 `['default', 'claude-memories', 'auto-memory', 'patterns', 'tasks', 'feedback']`를 검색합니다. 이는 브리지가 실제로 채우는 네임스페이스입니다. `default`는 포괄적인 공간이고, `auto-memory`는 `claude-memories`와 다릅니다（전자는 브리지 내부 캐시, 후자는 파싱된 `*.md` 섹션을 보관）.

> **복수형 함정:** ReasoningBank 폴백은 `pattern`（단수）에 씁니다. 다른 hooks（`pretrain`, 신경망 학습 경로）는 `patterns`（복수）에 씁니다. 서로 다른 네임스페이스입니다. 확실하지 않으면 `memory_list --namespace pattern`과 `memory_list --namespace patterns`를 각각 실행해 데이터가 어느 쪽에 있는지 확인하세요. 실제 쓰기 위치를 확인하기 전에는 복수형을 “수정”하려고 하위 코드를 리팩터링하지 마세요.

## Hook 통합 규칙

여러 Claude Code hook이 AgentDB에 기록합니다. 소비자 플러그인은 어떤 네임스페이스가 자동으로 상태를 쌓고 어떤 네임스페이스가 명시적 호출을 필요로 하는지 알아야 합니다. 그래야 hook 시스템이 이미 제공하는 기능을 다시 만들지 않습니다.

| Hook | 호출 도구 | 대상 네임스페이스 | 비고 |
|------|--------------|----------|-------|
| `SessionStart` | `memory_import_claude`（`auto-memory-hook.mjs` 경유） | `claude-memories` | 매 세션 시작마다 `~/.claude/projects/*/memory/*.md`를 AgentDB로 가져옴 |
| `SessionEnd` | `auto-memory-hook.mjs sync` | bridge → `MEMORY.md` | AgentDB 인사이트를 Claude Code의 MEMORY.md로 돌려보냄 |
| `post-task --train-neural` | `agentdb_pattern-store`（ReasoningBank） | `pattern`（레지스트리가 없으면 `memory-store-fallback`） | SONA 증류용 작업 완료 패턴 저장 |
| `pretrain`（one-shot） | `memory_store` | `patterns`（복수） | 학습 코퍼스 부트스트랩 |
| `trajectory-begin/step/end`（ruvector hooks） | ruvector 기반（별도 플러그인） | `ruflo-ruvector`가 처리하는 sona/agentdb 네임스페이스 | `plugins/ruflo-ruvector/docs/adrs/0001-pin-ruvector-0.2.25.md` 참조 |

소비자 플러그인에 대한 의미는 다음과 같습니다.

- **두 번 쓰지 마세요.** 이미 `hooks post-task --train-neural`를 호출한다면 `memory_store --namespace pattern`을 수동으로 호출할 필요가 없습니다. 한 경로를 선택하세요.
- **`claude-memories`를 직접 새로 고치지 마세요.** 매 `SessionStart`마다 자동으로 가져옵니다. 수동 `memory_import_claude`는 강제 갱신용이지 정상 운영용이 아닙니다.
- **폴백 응답을 드러내세요.** `agentdb_pattern-store`에서 `controller: 'memory-store-fallback'`이 돌아오면 데이터는 이미 저장된 것입니다. 아래의 “Pattern-store fallback”을 참조하세요.

## 운영 폴백

브리지 코드에는 3가지 폴백이 있습니다. 소비자는 이를 소프트 실패로 취급하지 말고 분기해야 합니다.

### Pattern-store fallback（ADR-093 F4）

ReasoningBank 컨트롤러 레지스트리가 null을 반환하면 `agentdb_pattern-store`가 `memory_store`를 통해 기록하고 다음을 반환합니다.

```json
{
  "success": true,
  "patternId": "pattern-...",
  "controller": "memory-store-fallback",
  "note": "ReasoningBank controller registry unavailable. Pattern persisted via memory_store."
}
```

`controller: 'memory-store-fallback'` 응답은 패턴이 **저장되었다**는 뜻이지 오류가 아닙니다. 소스: `agentdb-tools.ts:138-161`.

### Causal-edge graph-node 백엔드（ADR-087）

`agentdb_causal-edge`는 먼저 네이티브 `@ruvector/graph-node` 백엔드를 시도하고, 실패하면 브리지로 폴백합니다. 네이티브 백엔드가 처리했을 때 응답에는 `_graphNodeBackend: true`가 포함됩니다. 소스: `agentdb-tools.ts:267-290`.

### 브리지를 사용할 수 없을 때

`bridgeHealthCheck()`가 null을 반환하면（`@claude-flow/memory` 패키지가 설치되지 않았거나 `controller-registry.ts`가 없는 경우）모든 `agentdb_*` 핸들러가 다음을 반환합니다.

```json
{
  "success": false,
  "error": "AgentDB bridge not available — @claude-flow/memory not installed... Use memory_store/memory_search tools instead."
}
```

브리지 사용 불가 모드의 대체 표입니다.

| 사용할 수 없는 `agentdb_*` | 대신 사용 |
|---|---|
| `agentdb_hierarchical-store` / `_recall` | `memory_store` / `memory_search` |
| `agentdb_pattern-store` / `_search` | `memory_store --namespace pattern` / `memory_search --namespace pattern` |

## Install

```
claude plugin marketplace add ruvnet/ruflo
claude plugin install ruflo-agentdb@ruflo
```

## Original README

# ruflo-agentdb

The substrate plugin for Ruflo memory. Wraps three CLI MCP families — `agentdb_*` (controller bridge, 15 tools), `embeddings_*` (RuVector ONNX engine, 10 tools), and `ruvllm_hnsw_*` (WASM-backed pattern router, 3 tools) — into discoverable skills and commands. Other plugins (`ruflo-browser`, `ruflo-rag-memory`, `ruflo-intelligence`) compose this substrate; this plugin owns the namespace convention and the smoke contract for the substrate as a whole.

> **Status:** ADR-0001 implemented. Plugin v0.3.0 targets `@claude-flow/cli` v3.6.x with bundled `agentdb@^3.0.0-alpha.11`. The smoke contract (13 numbered checks + 3 documentation invariants) is the verification mechanism — see [docs/adrs/0001-agentdb-optimization.md](./docs/adrs/0001-agentdb-optimization.md).

## Install

```
/plugin marketplace add ruvnet/ruflo
/plugin install ruflo-agentdb@ruflo
```

## Compatibility

- **CLI:** pinned to `@claude-flow/cli` v3.6 major+minor. Patch bumps within v3.6 are expected to be no-op.
- **AgentDB:** the CLI bundles `agentdb@^3.0.0-alpha.11`. The plugin does **not** pin the npm package — internals (alpha.11 → alpha.12 etc.) are not the plugin's contract.
- **Verification:** the bundled smoke script is the source of truth (`bash plugins/ruflo-agentdb/scripts/smoke.sh`). If smoke passes against your CLI version, the plugin's contract holds.

## Features

- **Controller bridge**: 15 `agentdb_*` MCP tools (hierarchical store/recall, semantic routing, pattern store/search, causal edges, context synthesis, batch ops, consolidation, feedback, sessions).
- **RuVector embeddings**: 10 `embeddings_*` MCP tools — 384-dim ONNX (all-MiniLM-L6-v2), HNSW search, hyperbolic (Poincare), neural substrate, and **RaBitQ 1-bit quantization (32× memory reduction)**.
- **HNSW pattern router**: 3 `ruvllm_hnsw_*` tools (WASM-backed, ≤11 high-priority patterns — distinct from the large-scale embeddings HNSW path).
- **Causal knowledge graphs**: `agentdb_causal-edge` (graph-node backend with bridge fallback per ADR-087).

## Controllers (real registry, grouped by INIT_LEVELS)

The "controller count" reported anywhere in this plugin is **whatever the runtime tool reports**. The canonical list of names is the `ControllerName` union at `v3/@claude-flow/memory/src/controller-registry.ts:34-73` (29 names across 6 init levels). Inspect at runtime:

```bash
mcp tool call agentdb_controllers --json
```

Initialization order per ADR-053 (`controller-registry.ts:160-174`):

| Level | Controllers | Role |
|------:|-------------|------|
| 0 | _(foundation, pre-existing)_ | Bootstrap |
| 1 | `reasoningBank`, `hierarchicalMemory`, `learningBridge`, `hybridSearch`, `tieredCache` | Core intelligence |
| 2 | `memoryGraph`, `agentMemoryScope`, `vectorBackend`, `mutationGuard`, `gnnService` | Graph + security |
| 3 | `skills`, `explainableRecall`, `reflexion`, `attestationLog`, `batchOperations`, `memoryConsolidation` | Specialization |
| 4 | `causalGraph`, `nightlyLearner`, `learningSystem`, `semanticRouter` | Causal + routing |
| 5 | `graphTransformer`, `sonaTrajectory`, `contextSynthesizer`, `rvfOptimizer`, `mmrDiversityRanker`, `guardedVectorBackend` | Advanced services |
| 6 | `federatedSession`, `graphAdapter` | Session management |

`graphAdapter` is currently disabled pending an external graph-DB connection (tracked in ADR-095). Other Level-2/3 security controllers (`mutationGuard`, `attestationLog`, `gnnService`, `rvfOptimizer`, `guardedVectorBackend`) were activated by ADR-095 G7 in ruflo 3.6.23+.

## G7 controllers (activated by ADR-095)

[ADR-095](../../v3/docs/adr/ADR-095-architectural-gaps-from-april-audit.md) closed five previously-disabled AgentDB controllers:

| Controller | Role | Source |
|---|---|---|
| `gnnService` | Graph Neural Network embeddings + relational scoring over the AgentDB causal graph. No-arg construction. | `agentdb/dist/src/services/GNNService.js` |
| `rvfOptimizer` | RuVector format compaction — quantizes + dedupes vector blocks before persistence. | `agentdb/dist/src/optimizations/RVFOptimizer.js` |
| `mutationGuard` | WASM-backed proof generation for state mutations (ADR-060). | `agentdb/dist/src/security/MutationGuard.js` |
| `attestationLog` | Hash-chained audit log of mutations. Backed by a dedicated `.swarm/attestation.db`. | `agentdb/dist/src/security/AttestationLog.js` |
| `GuardedVectorBackend` | Wraps the existing vectorBackend with `mutationGuard` + `attestationLog`. | `agentdb/dist/src/backends/ruvector/GuardedVectorBackend.js` |

## Commands

- `/agentdb-mod` — AgentDB health, controller status, session management
- `/embeddings` — RuVector embedding engine status and operations

## Skills

- `agentdb-query` — Query AgentDB with semantic routing and hierarchical recall
- `vector-search` — HNSW vector search + RaBitQ quantization + 3 tuning profiles

## Namespace convention

This plugin owns the namespace convention that downstream plugins consume. Following it keeps cross-plugin search discoverable and avoids accidental key collisions in the bridge.

### Naming

`<plugin-stem>-<intent>` in kebab-case. Examples already in the wild:

| Plugin | Namespaces |
|---|---|
| `ruflo-browser` | `browser-sessions`, `browser-selectors`, `browser-templates`, `browser-cookies` |
| `ruflo-rag-memory` | (uses bridge target `claude-memories`) |
| `ruflo-intelligence` | (uses fallback target `pattern`) |

### Reserved namespaces (do NOT shadow)

| Namespace | Owned by | Source |
|---|---|---|
| `pattern` | ReasoningBank fallback writes here | `agentdb-tools.ts:144` |
| `claude-memories` | Claude Code auto-memory bridge target | bridge |
| `default` | `memory_store` default | `memory-tools.ts` |

### Where namespace strings actually apply

Namespace is **not** a universal parameter. Read the routing carefully:

- `memory_*` and `embeddings_search` route by namespace — pass it.
- `agentdb_hierarchical-*` routes by `tier` (`working|episodic|semantic`) — namespace argument is ignored.
- `agentdb_pattern-*` routes through the ReasoningBank controller — namespace argument is ignored.
- `agentdb_causal-edge` routes through the causal graph — namespace argument is ignored.

Don't pass `namespace: 'browser-cookies'` to `agentdb_pattern-store` and expect filtering. It will be silently dropped.

### GC posture

This plugin **does not** GC namespaces. Consumer plugins that want lifecycle (e.g., `browser-sessions` after a `purge`) own their own deletion via `memory_delete` + `agentdb_consolidate`. If you need cleanup, schedule it.

### Naming guardrails

A namespace SHOULD NOT contain `:` (collides with key-internal delimiters used in the bridge), MUST be ≤200 chars, and MUST pass `validateIdentifier` (the same validator already used in `agentdb-tools.ts:122`).

## How Claude Code populates AgentDB

The `claude-memories` reserved namespace is filled by Claude Code's own auto-memory bridge, not by direct user calls. Two mechanisms:

| Mechanism | Trigger | What it writes |
|---|---|---|
| `memory_import_claude` MCP tool | Manual or hook-driven | Reads `~/.claude/projects/*/memory/*.md`, parses YAML frontmatter, splits sections, stores with 384-dim embeddings. `allProjects: true` imports from ALL Claude projects. |
| `.claude/helpers/auto-memory-hook.mjs` | `SessionStart` (import) and `SessionEnd` (sync) — wired in `.claude/settings.json` | `import` → calls into the bridge for the current project; `sync` → flows AgentDB insights back to `~/.claude/projects/*/memory/MEMORY.md` |

To inspect or refresh:

```bash
# What's in the bridge right now?
mcp tool call memory_bridge_status --json

# Force a re-import from Claude Code's project memory
mcp tool call memory_import_claude --json -- '{"allProjects": true}'

# Cross-namespace search across claude-memories + auto-memory + patterns + tasks + feedback
mcp tool call memory_search_unified --json -- '{"query": "your query"}'
```

`memory_search_unified` defaults to searching `['default', 'claude-memories', 'auto-memory', 'patterns', 'tasks', 'feedback']` — these are the namespaces the bridge actually populates. The `default` namespace is the catch-all; `auto-memory` is distinct from `claude-memories` (auto-memory holds bridge-internal cache, claude-memories holds parsed `*.md` sections).

> **Pluralization gotcha:** the ReasoningBank fallback writes to `pattern` (singular). Other hooks (`hooks pretrain`, neural training paths) write to `patterns` (plural). They are different namespaces. When in doubt, `memory_list --namespace pattern` and `memory_list --namespace patterns` will tell you which one your data is in. Don't refactor your downstream code to "fix" the pluralization until you've confirmed which namespace was actually written.

## Hook integration convention

Several Claude Code hooks fire writes into AgentDB. Consumer plugins should know which namespaces accumulate state automatically vs. by explicit call, so they don't rebuild what the hook system already provides.

| Hook | Tool invoked | Target namespace | Notes |
|------|--------------|------------------|-------|
| `SessionStart` | `memory_import_claude` (via auto-memory-hook.mjs) | `claude-memories` | Imports `~/.claude/projects/*/memory/*.md` into AgentDB on every session start |
| `SessionEnd` | `auto-memory-hook.mjs sync` | bridge → `MEMORY.md` | Flows AgentDB insights back to Claude Code's MEMORY.md |
| `post-task --train-neural` | `agentdb_pattern-store` (ReasoningBank) | `pattern` (with `memory-store-fallback` if registry unavailable) | Stores task-completion patterns for SONA distillation |
| `pretrain` (one-shot) | `memory_store` | `patterns` (plural) | Bootstrap learning corpus |
| `trajectory-begin/step/end` (ruvector hooks) | ruvector substrate (separate plugin) | sona/agentdb namespaces handled by `ruflo-ruvector` | See `plugins/ruflo-ruvector/docs/adrs/0001-pin-ruvector-0.2.25.md` |

Implication for consumer plugins:

- **Don't double-write.** If you're already calling `hooks post-task --train-neural`, you don't also need to manually `memory_store --namespace pattern`. Pick one path.
- **Don't refresh `claude-memories` yourself.** It auto-imports on every SessionStart. Manual `memory_import_claude` is for force-refresh, not steady-state.
- **Surface fallback responses.** When `controller: 'memory-store-fallback'` comes back from `agentdb_pattern-store`, the data still landed — see "Pattern-store fallback" below.

## Operational fallbacks

Three fallbacks exist in the bridge code; consumers should branch on them rather than treat them as soft failures.

### Pattern-store fallback (ADR-093 F4)

When the ReasoningBank controller registry returns null, `agentdb_pattern-store` writes through to `memory_store` and returns:

```json
{
  "success": true,
  "patternId": "pattern-...",
  "controller": "memory-store-fallback",
  "note": "ReasoningBank controller registry unavailable. Pattern persisted via memory_store."
}
```

A `controller: 'memory-store-fallback'` response is a pattern that **was persisted** — not an error. Source: `agentdb-tools.ts:138-161`.

### Causal-edge graph-node backend (ADR-087)

`agentdb_causal-edge` tries the native `@ruvector/graph-node` backend first; on failure, falls back to the bridge. The response includes `_graphNodeBackend: true` when the native backend handled the call. Source: `agentdb-tools.ts:267-290`.

### Bridge unavailable

When `bridgeHealthCheck()` returns null (the `@claude-flow/memory` package is not installed or `controller-registry.ts` is missing), every `agentdb_*` handler returns:

```json
{
  "success": false,
  "error": "AgentDB bridge not available — @claude-flow/memory not installed... Use memory_store/memory_search tools instead."
}
```

Replacement table for bridge-unavailable mode:

| Unavailable `agentdb_*` | Use instead |
|---|---|
| `agentdb_hierarchical-store` / `_recall` | `memory_store` / `memory_search` |
| `agentdb_pattern-store` / `_search` | `memory_store --namespace pattern` / `memory_search --namespace pattern` |
| `agentdb_semantic-route` | `embeddings_search` |
| `agentdb_context-synthesize` | `memory_search_unified` |

## Verification

```bash
bash plugins/ruflo-agentdb/scripts/smoke.sh
# Expected: "10 passed, 0 failed"
```

The smoke script is the contract. It calls each documented MCP tool, exercises the RaBitQ workflow, and source-inspects the fallback path (no env-var gate exists to force the fallback live).

## As a mod (0.4.6, ADR-445)

A function-hook mod ships beside the skills. Needs a Claude Code with mods (2.1.287+); older builds ignore it.

| Piece | Default | What it does |
|---|---|---|
| **Secret guard** | on | Refuses a memory write (`agentdb_hierarchical-store`, `agentdb_pattern-store`, `agentdb_batch`, `agentdb_causal-edge`, `memory_store`, `hooks_remember`, `hooks_intelligence_pattern-store`, `agentdb_feedback`, `agentdb_session-end`, `hive-mind_memory`, `session_save`) that holds a private key, cloud/GitHub/Slack token, bearer token, JWT or key-like assignment. The secret is never echoed. The shared screen (`hooks/screen.ts`, copied to every mod by `scripts/sync-mod-screen.mjs`) judges an assignment by its value: calls, env references, identifier paths, placeholders, UUIDs, secret-manager paths and hyphenated names are not secrets; a literal needs two character classes (one a digit or symbol) and at least 2.5 bits of entropy per character. Vendor keys (Stripe, npm, HuggingFace, SendGrid, Twilio, Slack webhooks) and `scheme://user:pass@host` URLs are matched by shape; input is scanned in one pass up to 200 KB (head and tail beyond that). |
| **Import file screen** | on (with the guard) | `memory_import` takes only a path, so the guard also reads the file at `inputPath` and refuses the import when it holds a secret (same message, never echoing it). Best effort, not a gate, and it **fails open**: a file over 1 MB, a directory, a missing or unreadable file, a path outside the project root and your home, a path with `..`, a backslash or a null byte, a non-string path, or a stat/read error all let the import proceed unread. Symlinks are not resolved. `rvf_ingest` is still unguarded. |
| **Recall into prompts** | **off** | Attaches the best 1–5 memories to each prompt as framed, per-prompt context (the prompt cache is not disturbed). Read through the already-connected tools, in order: `memory_search` (semantic: the only reader that finds a paraphrase; its 60-character cut is completed with `memory_retrieve`), `agentdb_hierarchical-recall` and `agentdb_pattern-search` (substring matches, so also asked with the prompt's salient words), ruvector `hooks_recall`. A result scoring under 0.25 is noise and skipped. No CLI, no network. Skipped for slash commands, `!` lines and short prompts; gives up after `recallDeadlineMs` (800; the first recall of a fresh session takes 0.5–1.5 s, so consider 1500); cached 10 minutes. |
| **Untrusted memory** | always | A retrieved memory with a secret or an instruction-to-the-model phrase is dropped; the rest are control-character-stripped, capped (5 items, 400 chars each, 1500 total) and framed as data. |
| **`/agentdb-mod`** | — | `status`, `recall <text>`, `scan <text>`, `recent`; answered locally, no model call. |
| **Status file** | — | `.claude-flow/agentdb-mod/status.json` (counts and short snippets); the ruflo console's Memory page shows it. |

**Permissions:** the mod's reads go through Claude Code's permission rules, and a headless (`-p`) or fresh session refuses a tool nobody allowed. Allow the readers you use, e.g. `mcp__<server>__memory_search`, `memory_retrieve`, `agentdb_hierarchical-recall`, `agentdb_pattern-search`. A refusal is counted in `errors` and named in `lastError` in the status file; before 0.4.1 it read as "nothing relevant".

Options (`userConfig`): `recall` off|on, `recallLimit` 1–5, `recallDeadlineMs` 200–3000, `guard` on|off, `source` auto|agentdb|ruvector|none.

```bash
claude plugin test plugins/ruflo-agentdb      # 109 tests: screening, recall, reader fallback, guard, /agentdb-mod, deadline, cache, live-run findings
scripts/live-agentdb-recall.sh                 # live harness against a real AgentDB (haiku, about $1); results in v3/docs/validation/agentdb-recall-live-2026-10.md
node plugins/ruflo-agentdb/scripts/bench.mjs  # per-call cost of the pure paths (tens of µs)
```

## Architecture Decisions

- [`ADR-445` — AgentDB as a mod](../../v3/docs/adr/ADR-445-agentdb-as-a-mod.md)
- [`ADR-0001` — Optimize ruflo-agentdb (accurate surface, RaBitQ, namespacing, smoke contract)](./docs/adrs/0001-agentdb-optimization.md)

## Related Plugins

- `ruflo-rag-memory` — simple store/search/recall interface; consumes the `claude-memories` reserved namespace
- `ruflo-intelligence` — SONA neural patterns; consumes the `pattern` reserved namespace via ReasoningBank
- `ruflo-browser` — composes the namespace convention for `browser-sessions/-selectors/-templates/-cookies` (ADR-0001 §3 there)
- `ruflo-ruvector` — pinned ruvector CLI; sibling substrate plugin

## License

MIT
