---
title: "ruflo-agentdb"
url: "https://claudemods.dev/zh-tw/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: "zh-tw"
content_locale: "zh-tw"
---

# ruflo-agentdb

Ruflo 記憶系統的基底層外掛：AgentDB 控制器橋接（15 個 agentdb_* MCP 工具）、RuVector ONNX 嵌入（10 個 embeddings_* 工具，包含 RaBitQ 32x 量化）和 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 个工具）——包装成可发现的 skills 和指令。其他外掛（`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 内的修订版本升级应当是无操作的。
- **AgentDB：** CLI 內含 `agentdb@^3.0.0-alpha.11`。外掛**不會**固定 npm package——内部版本（alpha.11 → alpha.12 等）不属于外掛契约。
- **验证：** 内置 smoke script 是事實來源（`bash plugins/ruflo-agentdb/scripts/smoke.sh`）。如果它在你的 CLI 版本上透過，外掛契约就成立。

## 功能

- **控制器橋接：** 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` 联合类型（跨 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 跟踪）。其他第 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) 關閉了之前停用的 5 个 AgentDB 控制器：

| 控制器 | 作用 | 來源 |
|---|---|---|
| `gnnService` | 在 AgentDB 因果图上提供图神经網路嵌入和关系评分。无參數构造。 | `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` | 用 `mutationGuard` + `attestationLog` 包装现有的 `vectorBackend`。 | `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 自己的自动記憶橋接填入，而不是由使用者直接呼叫填入。有两种机制：

| 机制 | 触发器 | 寫入內容 |
|---|---|---|
| `memory_import_claude` MCP 工具 | 手動或 hook 驱动 | 讀取 `~/.claude/projects/*/memory/*.md`，解析 YAML frontmatter，拆分章節，并用 384 維嵌入儲存。`allProjects: true` 会从所有 Claude 專案导入。 |
| `.claude/helpers/auto-memory-hook.mjs` | `SessionStart`（导入）和 `SessionEnd`（同步）——接入 `.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`（`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` package，或者缺少 `controller-registry.ts`）时，每個 `agentdb_*` handler 都会回傳：

```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
