Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

feat(ruflo-agentdb): v0.3.0 β€” accurate surface, RaBitQ workflow, namespace contract, hook integration

Reuven6324f5ae073e
diff --git a/plugins/ruflo-agentdb/.claude-plugin/plugin.json b/plugins/ruflo-agentdb/.claude-plugin/plugin.json
index bb2edaa5c2..07c62a70a8 100644
--- a/plugins/ruflo-agentdb/.claude-plugin/plugin.json
+++ b/plugins/ruflo-agentdb/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "ruflo-agentdb",
- "description": "AgentDB memory controllers with HNSW vector search, RuVector embeddings, and causal knowledge graphs",
- "version": "0.2.0",
+ "description": "Substrate plugin for Ruflo memory: AgentDB controller bridge (15 agentdb_* MCP tools), RuVector ONNX embeddings (10 embeddings_* tools incl. RaBitQ 32x quantization), and WASM HNSW pattern router (3 ruvllm_hnsw_* tools)",
+ "version": "0.3.0",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
@@ -14,6 +14,11 @@
"ruvector",
"hnsw",
"embeddings",
- "vector-search"
+ "vector-search",
+ "rabitq",
+ "quantization",
+ "namespace-convention",
+ "controller-bridge",
+ "mcp"
]
}
diff --git a/plugins/ruflo-agentdb/README.md b/plugins/ruflo-agentdb/README.md
index d4d6388be3..33c5922769 100644
--- a/plugins/ruflo-agentdb/README.md
+++ b/plugins/ruflo-agentdb/README.md
@@ -1,8 +1,8 @@
# ruflo-agentdb
-AgentDB memory controllers with HNSW vector search, RuVector embeddings, and causal knowledge graphs.
+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.
-Wraps Ruflo's AgentDB MCP tools (agentdb_*, embeddings_*, ruvllm_hnsw_*) into skills and commands for Claude Code.
+> **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 (10 checks) is the verification mechanism β€” see [docs/adrs/0001-agentdb-optimization.md](./docs/adrs/0001-agentdb-optimization.md).
## Install
@@ -11,36 +11,211 @@ Wraps Ruflo's AgentDB MCP tools (agentdb_*, embeddings_*, ruvllm_hnsw_*) into sk
/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
-- **19 AgentDB controllers**: Hierarchical store/recall, semantic routing, context synthesis
-- **HNSW vector search**: 150x-12,500x faster than brute-force scanning
-- **384-dim ONNX embeddings**: all-MiniLM-L6-v2 for semantic similarity
-- **Causal knowledge graphs**: Link related knowledge with causal edges
-- **Hyperbolic embeddings**: Poincare ball model for hierarchical data
+- **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).
-## G7 controllers (activated in ruflo 3.6.23+ / 3.6.24)
+## Controllers (real registry, grouped by INIT_LEVELS)
-[ADR-095](../../v3/docs/adr/ADR-095-architectural-gaps-from-april-audit.md) closed five previously-disabled AgentDB controllers. They're now wired by default in the ControllerRegistry and reachable via `agentdb_*` MCP tools or the `/agentdb` slash command:
+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:
-| Controller | Role | Source |
-|---|---|---|
-| `gnnService` | Graph Neural Network embeddings + relational scoring over the AgentDB causal graph. No-arg construction, safe-default activation. | `agentdb/dist/src/services/GNNService.js` |
-| `rvfOptimizer` | RuVector format compaction β€” quantizes + dedupes vector blocks before persistence. No-arg construction. | `agentdb/dist/src/optimizations/RVFOptimizer.js` |
-| `mutationGuard` | WASM-backed proof generation for state mutations (ADR-060). Gates writes through proof verification. | `agentdb/dist/src/security/MutationGuard.js` |
-| `attestationLog` | Hash-chained audit log of mutations. Backed by a dedicated `.swarm/attestation.db` (separate from main memory.db so the audit trail is isolated). Requires `better-sqlite3`. | `agentdb/dist/src/security/AttestationLog.js` |
-| `GuardedVectorBackend` | Wraps the existing vectorBackend with `mutationGuard` + `attestationLog` for proof-gated writes. Activates only when both prerequisites resolve. | `agentdb/dist/src/backends/ruvector/GuardedVectorBackend.js` |
+```bash
+mcp tool call agentdb_controllers --json
+```
-The remaining G7 controller β€” `graphAdapter` β€” is still pending an external graph-DB connection. Tracked in ADR-095.
+Initialization order per ADR-053 (`controller-registry.ts:160-174`):
-Inspect runtime status: `agentdb_controllers` MCP tool or `agentdb_health` β€” both report initialization status per controller.
+| 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` -- AgentDB health, controller status, session management
-- `/embeddings` -- RuVector embedding engine status and operations
+- `/agentdb` β€” 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 with RuVector embeddings
+- `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).
+
+## Architecture Decisions
+
+- [`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
diff --git a/plugins/ruflo-agentdb/agents/agentdb-specialist.md b/plugins/ruflo-agentdb/agents/agentdb-specialist.md
index e0a26ed6ac..ebe4626fe3 100644
--- a/plugins/ruflo-agentdb/agents/agentdb-specialist.md
+++ b/plugins/ruflo-agentdb/agents/agentdb-specialist.md
@@ -1,45 +1,80 @@
---
name: agentdb-specialist
-description: AgentDB and RuVector specialist for memory operations, HNSW indexing, and semantic search
+description: AgentDB and RuVector specialist for memory operations, HNSW indexing, RaBitQ quantization, and semantic search across the controller bridge
model: sonnet
---
You are an AgentDB specialist for the Ruflo memory system. Your responsibilities:
-1. **Manage AgentDB** sessions, controllers, and knowledge storage
-2. **Build HNSW indexes** for fast vector search (150x-12,500x speedup)
-3. **Generate embeddings** using ONNX all-MiniLM-L6-v2 (384 dimensions)
+1. **Manage AgentDB** sessions, controllers, and knowledge storage via the controller bridge
+2. **Build HNSW indexes** for fast vector search; pick an operating point (recall/balanced/latency) deliberately
+3. **Generate embeddings** using ONNX all-MiniLM-L6-v2 (384 dimensions); apply RaBitQ for 32Γ— memory reduction on large corpora
4. **Semantic routing** to find the most relevant knowledge for a query
-5. **Causal graphs** linking related knowledge with causal edges
+5. **Causal graphs** linking related knowledge with `agentdb_causal-edge`
6. **Consolidate memory** to prevent bloat and maintain quality
-### MCP Tools (19 Controllers)
-
-| Tool Prefix | Operations |
-|-------------|-----------|
-| `mcp__claude-flow__agentdb_semantic-route` | Route queries to best knowledge source |
-| `mcp__claude-flow__agentdb_hierarchical-*` | Store/recall structured hierarchical data |
-| `mcp__claude-flow__agentdb_pattern-*` | Store/search learned patterns |
-| `mcp__claude-flow__agentdb_causal-edge` | Link related knowledge causally |
-| `mcp__claude-flow__agentdb_context-synthesize` | Synthesize context from multiple sources |
-| `mcp__claude-flow__agentdb_batch` | Bulk operations |
-| `mcp__claude-flow__agentdb_consolidate` | Clean up and deduplicate |
-| `mcp__claude-flow__agentdb_feedback` | Record quality feedback |
-| `mcp__claude-flow__embeddings_*` | Vector embedding generation and search |
-| `mcp__claude-flow__ruvllm_hnsw_*` | HNSW index create/add/route |
-| `mcp__claude-flow__memory_search_unified` | Cross-namespace semantic search |
+### MCP Tools
+
+The plugin documents three tool families. Counts and authoritative sources:
+
+| Family | Count | Source |
+|---|---|---|
+| `agentdb_*` (controller bridge) | 15 | `v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts` |
+| `embeddings_*` (RuVector ONNX) | 10 | `v3/@claude-flow/cli/src/mcp-tools/embeddings-tools.ts` |
+| `ruvllm_hnsw_*` (WASM router) | 3 | `v3/@claude-flow/cli/src/mcp-tools/ruvllm-tools.ts` |
+
+For the canonical list of *controllers* (distinct from MCP tools), call `agentdb_controllers` at runtime. Do not hard-code a count anywhere in agent reasoning β€” the runtime tool is the source of truth.
+
+### Tool routing
+
+| Use case | Tool |
+|---|---|
+| Structured tier-keyed data | `agentdb_hierarchical-store` / `agentdb_hierarchical-recall` (tiers: `working|episodic|semantic`) |
+| Pattern matching across sessions | `agentdb_pattern-store` / `agentdb_pattern-search` (ReasoningBank) |
+| Routing a query to best knowledge source | `agentdb_semantic-route` |
+| Combining multiple memories | `agentdb_context-synthesize` |
+| Linking related knowledge causally | `agentdb_causal-edge` (graph-node backend with bridge fallback) |
+| Bulk operations | `agentdb_batch` (≀500 entries β€” `MAX_BATCH_SIZE` at `agentdb-tools.ts:20`) |
+| Cleanup / dedup | `agentdb_consolidate` |
+| Quality feedback | `agentdb_feedback` |
+| Cross-session persistence | `agentdb_session-start` / `agentdb_session-end` |
+| Namespaced text search | `embeddings_search` |
+| Large-corpus quantized search | `embeddings_rabitq_build` β†’ `_search` β†’ `_status` |
+| Hierarchical embeddings | `embeddings_hyperbolic` (Poincare ball) |
+| Hot-path pattern routing (≀11 patterns) | `ruvllm_hnsw_*` (WASM, capped) |
+| Cross-namespace unified search | `memory_search_unified` |
### Decision Guide
-- **Structured data** β†’ hierarchical store/recall
+- **Structured data** β†’ hierarchical store/recall (tier-routed, namespace IGNORED)
- **Unstructured queries** β†’ semantic routing
-- **Pattern matching** β†’ pattern store/search
-- **Cross-session** β†’ session start/end with persistence
-- **Quick key-value** β†’ use ruflo-rag-memory instead
+- **Pattern matching** β†’ pattern store/search (ReasoningBank-routed, namespace IGNORED)
+- **Cross-session** β†’ session start/end
+- **Quick key-value** β†’ use `ruflo-rag-memory` instead
+- **Large corpus, memory-constrained** β†’ RaBitQ quantized path (32Γ— reduction)
+- **Hot routing of ≀11 patterns** β†’ `ruvllm_hnsw_*` (WASM-backed)
+
+### Operational fallbacks
+
+When you observe these responses, branch on them β€” they are intentional, not soft failures:
+
+| Response field | Meaning | Source |
+|---|---|---|
+| `controller: 'memory-store-fallback'` | ReasoningBank registry unavailable; pattern persisted via `memory_store --namespace pattern`. | `agentdb-tools.ts:138-161` (ADR-093 F4) |
+| `_graphNodeBackend: true` | Native `@ruvector/graph-node` handled the causal-edge call. | `agentdb-tools.ts:267-290` (ADR-087) |
+| `success: false, error: '...Use memory_store/memory_search instead.'` | Bridge unavailable (`@claude-flow/memory` not installed). Use the README replacement table. | every handler |
+
+### Namespace handling
+
+Namespace strings apply only to `memory_*` and `embeddings_search`. They are **silently ignored** by `agentdb_hierarchical-*`, `agentdb_pattern-*`, and `agentdb_causal-edge` (which route by tier or controller). Do not pass `namespace: 'foo'` to those tools and expect filtering.
+
+Reserved namespaces (do not shadow): `pattern`, `claude-memories`, `default`. See README "Namespace convention" section.
### Related Plugins
-- **ruflo-rag-memory**: Simple store/search/recall interface β€” use for quick key-value memory when full AgentDB isn't needed
+- **ruflo-rag-memory**: Simple store/search/recall β€” use for quick key-value memory when full AgentDB isn't needed
- **ruflo-intelligence**: SONA neural patterns use AgentDB for pattern storage and HNSW retrieval
+- **ruflo-browser**: composes the namespace convention (`browser-sessions/-selectors/-templates/-cookies`)
+- **ruflo-ruvector**: sibling substrate plugin (pinned `[email protected]`)
### Neural Learning
diff --git a/plugins/ruflo-agentdb/commands/agentdb.md b/plugins/ruflo-agentdb/commands/agentdb.md
index 3057c3a68e..142b0bd752 100644
--- a/plugins/ruflo-agentdb/commands/agentdb.md
+++ b/plugins/ruflo-agentdb/commands/agentdb.md
@@ -6,6 +6,7 @@ description: AgentDB health, controller status, and session management
AgentDB management:
1. Call `mcp__claude-flow__agentdb_health` to check database health
-2. Call `mcp__claude-flow__agentdb_controllers` to list all 19 controllers and their status
-3. Present a summary with: total entries, active sessions, controller count, and storage size
-4. If issues found, suggest running `npx @claude-flow/cli@latest memory init --force` to reinitialize
+2. Call `mcp__claude-flow__agentdb_controllers` to list whatever the runtime reports β€” controller `total` and `active` counts. The canonical list of names lives at `v3/@claude-flow/memory/src/controller-registry.ts:34-73` (`ControllerName` union); the runtime tool is the source of truth.
+3. Present a summary with: total entries, active sessions, controller `active` / `total`, and storage size.
+4. If `agentdb_health.available` is `false` (bridge unavailable), see the README's "Bridge unavailable" replacement table β€” `memory_store` / `memory_search` substitute for most `agentdb_*` operations.
+5. If issues found, suggest `npx @claude-flow/cli@latest memory init --force` to reinitialize.
diff --git a/plugins/ruflo-agentdb/commands/embeddings.md b/plugins/ruflo-agentdb/commands/embeddings.md
index 805542db0f..c9f58679e6 100644
--- a/plugins/ruflo-agentdb/commands/embeddings.md
+++ b/plugins/ruflo-agentdb/commands/embeddings.md
@@ -1,11 +1,17 @@
---
name: embeddings
-description: RuVector embedding engine status and operations
+description: RuVector embedding engine status and operations -- ONNX, HNSW, RaBitQ quantization
---
Embedding engine commands:
-1. Call `mcp__claude-flow__embeddings_status` to check the ONNX embedding engine
-2. Show: model (all-MiniLM-L6-v2), dimensions (384), HNSW index status, cache hit rate
-3. If not initialized, suggest calling `mcp__claude-flow__embeddings_init`
-4. For search operations, use `mcp__claude-flow__embeddings_search` with the user's query
+1. Call `mcp__claude-flow__embeddings_status` to check the ONNX embedding engine.
+2. Show: model (all-MiniLM-L6-v2), dimensions (384), HNSW index status, cache hit rate.
+3. If not initialized, suggest calling `mcp__claude-flow__embeddings_init`.
+4. For search, use `mcp__claude-flow__embeddings_search` with the user's query (namespace-filtered).
+5. For large-corpus search with memory pressure, use the RaBitQ quantized path (32Γ— memory reduction):
+ - `mcp__claude-flow__embeddings_rabitq_build` (one-time, after corpus is loaded)
+ - `mcp__claude-flow__embeddings_rabitq_search` (Hamming-prefilter to top-N candidates)
+ - `mcp__claude-flow__embeddings_rabitq_status` for index health
+6. For hierarchical data (taxonomies, code trees), use `mcp__claude-flow__embeddings_hyperbolic` (Poincare ball model).
+7. The substrate-level entry point `mcp__claude-flow__embeddings_neural` exists; in normal use it's covered by `embeddings_init` + `embeddings_generate`.
diff --git a/plugins/ruflo-agentdb/docs/adrs/0001-agentdb-optimization.md b/plugins/ruflo-agentdb/docs/adrs/0001-agentdb-optimization.md
new file mode 100644
index 0000000000..8c86a724c0
--- /dev/null
+++ b/plugins/ruflo-agentdb/docs/adrs/0001-agentdb-optimization.md
@@ -0,0 +1,200 @@
+---
+id: ADR-0001
+title: Optimize ruflo-agentdb β€” accurate surface, quantization opt-ins, controller-managed namespacing, smoke-as-contract
+status: Proposed
+date: 2026-05-04
+authors:
+ - planner (Claude Code)
+tags: [plugin, agentdb, mcp, hnsw, rabitq, controllers, namespacing, smoke-test]
+---
+
+## Context
+
+### Today's `ruflo-agentdb`
+
+`ruflo-agentdb` is a thin documentation wrapper around three MCP tool families exposed by `@claude-flow/cli`: `agentdb_*` (controller bridge), `embeddings_*` (RuVector ONNX engine), and `ruvllm_hnsw_*` (WASM-backed pattern router). The plugin ships six files:
+
+- `.claude-plugin/plugin.json:2` β€” `name: "ruflo-agentdb"`, `version: "0.2.0"`, keywords `agentdb, ruvector, hnsw, embeddings, vector-search`.
+- `README.md:16` β€” claims `19 AgentDB controllers`; `README.md:49` β€” calls out HNSW "150x-12,500x" speedup and "384-dim ONNX" embeddings.
+- `agents/agentdb-specialist.md:15` β€” header `MCP Tools (19 Controllers)` then enumerates eight `agentdb_*` tool prefixes plus `embeddings_*` and `ruvllm_hnsw_*` as bullet groups.
+- `commands/agentdb.md:8` β€” invokes `agentdb_health` and `agentdb_controllers` and prints "all 19 controllers and their status".
+- `commands/embeddings.md:8` β€” invokes `embeddings_status`/`embeddings_init`/`embeddings_search`. Mentions the model and dimension count but no quantization or HNSW tuning.
+- `skills/agentdb-query/SKILL.md:5` β€” `allowed-tools` enumerates 14 `agentdb_*` tools (correct count); `SKILL.md:26` repeats the "19 Controllers" framing.
+- `skills/vector-search/SKILL.md:5` β€” `allowed-tools` enumerates seven `embeddings_*` and three `ruvllm_hnsw_*` tools; `SKILL.md:46–50` is a performance table claiming `HNSW (n=10,000) 12,500x faster`.
+
+There is no `scripts/`, no `docs/` (the ADR file path is the first under that subtree), and no version pin against the underlying `agentdb` npm package or the CLI MCP surface.
+
+### What AgentDB / the CLI actually exposes
+
+Counted directly from source on 2026-05-04 (HEAD of `main`):
+
+| Surface | Plugin claim | Real count | Source |
+|---|---|---|---|
+| `agentdb_*` MCP tools | "19 controllers" β†’ implies tools | **15 tools** | `v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts:629–645` (`agentdbTools` export array) |
+| `embeddings_*` MCP tools | 7 enumerated in skill | **10 tools** | `v3/@claude-flow/cli/src/mcp-tools/embeddings-tools.ts:159, 260, 328, 418, 520, 717, 835, 910, 926, 970` |
+| `ruvllm_hnsw_*` MCP tools | 3 enumerated | **3 tools** (correct) but capacity is **~11 patterns**, not 10,000 | `v3/@claude-flow/cli/src/mcp-tools/ruvllm-tools.ts:57–58` ("Max ~11 patterns (v2.0.1 limit)") |
+| Controllers in `ControllerRegistry` | "19" | **29** names across 6 init levels: 13 AgentDB-layer + 16 CLI-layer | `v3/@claude-flow/memory/src/controller-registry.ts:34–73` (type `ControllerName`) and `:160–174` (`INIT_LEVELS`) |
+| RaBitQ 1-bit quantization | Not documented | 32Γ— compression, two-phase Hamming-prefilter + exact-rerank pipeline | `embeddings_rabitq_build`, `_search`, `_status` at `embeddings-tools.ts:910, 926, 970`; impl at `v3/@claude-flow/cli/src/memory/rabitq-index.ts` |
+| HNSW tuning (`efSearch`, `efConstruction`, `M`) | Not surfaced in any skill | `efSearch` accepted as a constructor param on `ruvllm_hnsw_create`; `efConstruction` defaulted to 200 in the lite index; `M` not exposed via MCP | `ruvllm-tools.ts:64`, `v3/@claude-flow/memory/src/hnsw-index.ts:537` |
+| Pattern-store fallback when ReasoningBank unavailable | Not documented | ADR-093 F4: when controller registry returns null, `agentdb_pattern-store` writes to `memory_store` with `controller: 'memory-store-fallback'` | `agentdb-tools.ts:138–161` |
+| Native graph-node backend for causal edges | Not documented | ADR-087: `agentdb_causal-edge` tries graph-node first, falls back to bridge | `agentdb-tools.ts:267–290` |
+| `agentdb` npm dep version | Not pinned in plugin | `agentdb: ^3.0.0-alpha.11` in CLI's `package.json:120`; `pnpm-lock.yaml` resolves multiple versions (1.6.1, 2.0.0-alpha.3.4/3.7, 3.0.0-alpha.10/11) | `v3/@claude-flow/cli/package.json:120`; `v3/node_modules/.pnpm/` |
+
+The "19 controllers" number appears to be a stale snapshot from before ADR-095 G7 closed five disabled-by-default controllers (`gnnService`, `rvfOptimizer`, `mutationGuard`, `attestationLog`, `GuardedVectorBackend`) and before ADR-053 added `mmrDiversityRanker`, `contextSynthesizer`, `batchOperations`, `memoryConsolidation`, `hierarchicalMemory` to the CLI-layer registry. The plugin README block on G7 (`README.md:22–35`) is accurate about the five activated controllers and about `graphAdapter` still being disabled β€” but the surrounding "19" framing is not.
+
+### What's missing entirely
+
+Beyond the count drift, the plugin omits four substantive capabilities of the substrate it documents:
+
+1. **Quantization.** `embeddings_rabitq_*` provides 32Γ— memory reduction at index time. CLAUDE.md's V3 perf targets explicitly call out "Memory Reduction 50–75% with quantization" as **Implemented**; the plugin advertises HNSW speedup but never mentions quantization.
+2. **Index tunables.** `efSearch` / `efConstruction` / `M` directly control the recall/latency tradeoff; the plugin presents HNSW as a binary "150–12,500Γ—" claim with no operating points.
+3. **Namespacing convention.** Every consumer plugin (`ruflo-browser` defines `browser-sessions / browser-selectors / browser-templates / browser-cookies` in its ADR-0001 Β§3; `ruflo-rag-memory` references `claude-memories / patterns / tasks / solutions`; `ruflo-intelligence` writes to `pattern`) reinvents namespace naming. There is no contract from `ruflo-agentdb` about how namespaces should be named, what they should contain, or how they are GC'd. The `agentdb_*` tools mostly do not even take a namespace parameter β€” they route to controllers (`reasoningBank`, `hierarchicalMemory`, `causalGraph`) β€” but the CLI fallback `memory_store` and `embeddings_search` *do* take namespace strings, so the surface is mixed and undocumented.
+4. **Token-efficiency path.** The repo ships `getCompactContext` on the `TokenOptimizer` (`v3/@claude-flow/integration/src/token-optimizer.ts:109`), and `agentdb_context-synthesize` exists for the same goal at the MCP layer. Neither is surfaced by the plugin as a "use this when you want compact retrieved context for an LLM call" workflow.
+
+### Why now
+
+`ruflo-agentdb` is the substrate plugin β€” `ruflo-browser` (ADR-0001) explicitly depends on AgentDB namespaces and controller-managed sessions; `ruflo-rag-memory` and `ruflo-intelligence` route through the same controllers; the whole "memory-as-substrate" story in `CLAUDE.md` rests on it. Documentation drift in this plugin is contagious β€” every downstream plugin inherits the wrong tool count, the wrong controller count, and the missing quantization story. We just fixed the same class of drift in `ruflo-ruvector` (ADR-0001 there); the same pattern applies here.
+
+## Decision
+
+We propose six changes to `ruflo-agentdb`. None requires modifying AgentDB itself; all are plugin-local edits plus one new smoke script.
+
+### 1. Replace "19 controllers" with the real registry, and pin its source
+
+The plugin currently treats "19" as a magic number repeated across five files. Replace it with two explicit references to the real source:
+
+- **README.md** swaps the blanket "19 AgentDB controllers" line for a table generated from `INIT_LEVELS` at `controller-registry.ts:160–174`. Group by init level (0–6) so the dependency story is visible. Mark each row as one of: `active by default`, `gated on dependency`, `disabled-pending-ADR`. Cite the source file + line.
+- **agents/agentdb-specialist.md** drops the "19 Controllers" header and replaces the bullet groups with a one-line "controllers are listed at runtime via `agentdb_controllers`; see registry source for the canonical list."
+- **commands/agentdb.md** drops the "all 19 controllers" string from step 2; the step now reads "list whatever the runtime reports".
+- **skills/agentdb-query/SKILL.md** Β§"19 Controllers" becomes "Available controller groups" and lists only the four functional categories already in the skill (hierarchical, pattern, semantic, causal).
+
+The point isn't to memorize the count β€” it's to stop hard-coding any count. The runtime tool `agentdb_controllers` is already the source of truth; documentation should defer to it.
+
+### 2. Surface `embeddings_rabitq_*` as a first-class quantization workflow
+
+Add a new section to `skills/vector-search/SKILL.md` titled "Quantized search (32Γ— memory)" with:
+
+- A 5-step recipe: `embeddings_init` β†’ `embeddings_rabitq_build` (one-time, after corpus is loaded) β†’ `embeddings_rabitq_search` (Hamming-prefilter to top-N candidates) β†’ optional rerank via `embeddings_search` (exact, on the candidate set) β†’ `embeddings_rabitq_status` for index health.
+- A "when to use" rule: corpora β‰₯ 5,000 vectors and/or memory-constrained environments. Below that, the rebuild cost outweighs the savings.
+- The exact tool names added to the `allowed-tools` frontmatter line.
+- A note: RaBitQ `_search` returns candidate IDs only; the rerank step is the user's responsibility (mirrors the docstring at `embeddings-tools.ts:911`).
+
+`embeddings_neural` (line 520) is the other undocumented `embeddings_*` tool. It is the substrate-level entry point and is implicitly covered by `embeddings_init`/`_generate`; we will add a one-line note to `commands/embeddings.md` acknowledging it exists, and stop there. We do not invent a second skill for it.
+
+### 3. Expose HNSW tuning as a deliberate, documented choice
+
+The plugin currently presents HNSW as a magic number (`12,500x faster` at `vector-search/SKILL.md:50`). That number is the published ceiling under specific parameters; without surfacing those parameters the claim is unfalsifiable.
+
+`skills/vector-search/SKILL.md` gets a new "Tuning" section that documents three operating points and ties each to a tool call:
+
+| Profile | `efSearch` | `M` | Use case |
+|---------|-----------|-----|----------|
+| `recall-first` | 200 | 32 | Pattern recall during planning, search quality matters more than ms |
+| `balanced` (default) | 64 | 16 | General-purpose semantic recall |
+| `latency-first` | 16 | 8 | Hot-path routing where p99 latency matters |
+
+`efSearch` is passed via `ruvllm_hnsw_create` (`ruvllm-tools.ts:64`). `M` is not currently MCP-exposed; we document it as a registry-level setting with a forward reference: "raise as a follow-up ADR if `M` should be MCP-tunable."
+
+We also fix the speed claim. The 12,500Γ— number is for the embeddings/HNSW path inside `@claude-flow/memory`, not for the WASM `ruvllm_hnsw_*` tools β€” those are capped at ~11 patterns (`ruvllm-tools.ts:58`). The skill currently lumps them together. The new copy reads: "`embeddings_search` uses the `@claude-flow/memory` HNSW index (large-scale, 150–12,500Γ—). `ruvllm_hnsw_*` is a separate WASM-backed router for ≀11 high-priority patterns β€” useful for hot routes, not for corpus search."
+
+### 4. Define a namespace convention contract for downstream plugins
+
+Add a new section to `README.md` titled **"Namespace convention"** that ruflo-agentdb owns and downstream plugins consume. The contract:
+
+- **Naming**: `<plugin-stem>-<intent>` kebab-case. Examples: `browser-sessions`, `browser-selectors`, `browser-cookies` (ruflo-browser), `claude-memories` (ruflo-rag-memory's bridge), `pattern` (ruflo-intelligence ReasoningBank fallback).
+- **Three reserved namespaces** owned by the AgentDB plugin itself, not to be shadowed: `pattern` (ReasoningBank fallback writes here per `agentdb-tools.ts:144`), `claude-memories` (Claude Code auto-memory bridge target), `default` (`memory_store` default per `memory-tools.ts:194`).
+- **Controller routing**: tools in the `agentdb_hierarchical-*` family route by `tier` (`working|episodic|semantic`) not by namespace; tools in the `agentdb_pattern-*` family route by ReasoningBank, again not by namespace. Document explicitly that namespace strings only apply to `memory_*` and `embeddings_search` paths. This stops downstream plugins from passing a `namespace` arg to `agentdb_pattern-store` and being silently confused when it's ignored.
+- **GC posture**: ruflo-agentdb does not GC namespaces. Consumer plugins that want lifecycle (e.g., `browser-sessions` after `purge`) own their own deletion via `memory_delete` + `agentdb_consolidate`. Document this so consumers don't expect cleanup we don't provide.
+- **Naming guardrail**: 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`).
+
+This section is the load-bearing artifact for cross-plugin discipline. Without it, every plugin author re-invents.
+
+### 5. Document the operational fallbacks that already exist
+
+Three fallback paths exist in the bridge code and are invisible in the plugin's docs:
+
+- **Pattern-store fallback** (`agentdb-tools.ts:138–161`, ADR-093 F4): when ReasoningBank's controller registry is unavailable, `agentdb_pattern-store` returns `controller: 'memory-store-fallback'`. Document this in `agents/agentdb-specialist.md` so the agent does not interpret a fallback response as a soft failure.
+- **Causal-edge graph-node backend** (`agentdb-tools.ts:267–290`, ADR-087): `agentdb_causal-edge` tries the native `@ruvector/graph-node` backend first, then the bridge. Document the `_graphNodeBackend: true` field so consumers can branch on it.
+- **Bridge unavailable** (returned by every handler when `bridgeHealthCheck` returns null): the response is `{ success: false, error: '...Use memory_store/memory_search instead.' }`. Add one paragraph in the README enumerating which `memory_*` tool replaces which `agentdb_*` tool when the bridge is unavailable.
+
+### 6. Smoke test as the contract (mirrors ruvector ADR-0001 Β§5)
+
+Add `scripts/smoke.sh` (file does not exist yet β€” first one in this plugin). It runs against any environment that has `npx @claude-flow/cli@latest` available with MCP enabled. Each check is a one-liner around `mcp tool call ... --json` + `jq`. The contract is "10 passed, 0 failed".
+
+Numbered checks (this is the verifiable artifact, not the prose above):
+
+1. `agentdb_health` returns `{ available: true, ... }`. The bridge is wired.
+2. `agentdb_controllers.total >= 15` and `agentdb_controllers.active >= 10`. The lower-bound assertions are deliberately loose β€” they verify "the registry initialized at all" without hard-coding the 29-name `ControllerName` union or the 15 `agentdb_*` MCP tools (which are different counts). If a future ADR removes a default-active controller, raise the floor; do not raise the test to an exact match.
+3. The 15 documented `agentdb_*` tool names are all callable: `agentdb_health, agentdb_controllers, agentdb_pattern-store, agentdb_pattern-search, agentdb_feedback, agentdb_causal-edge, agentdb_route, agentdb_session-start, agentdb_session-end, agentdb_hierarchical-store, agentdb_hierarchical-recall, agentdb_consolidate, agentdb_batch, agentdb_context-synthesize, agentdb_semantic-route`. Each gets a smoke call with minimal args; non-error response = pass.
+4. The 10 documented `embeddings_*` tools are all callable: `embeddings_init, embeddings_generate, embeddings_compare, embeddings_search, embeddings_neural, embeddings_hyperbolic, embeddings_status, embeddings_rabitq_build, embeddings_rabitq_search, embeddings_rabitq_status`.
+5. The 3 documented `ruvllm_hnsw_*` tools are all callable: `ruvllm_hnsw_create` (dim=384, max=11), `ruvllm_hnsw_add`, `ruvllm_hnsw_route`.
+6. RaBitQ build runs: `embeddings_rabitq_build` then `embeddings_rabitq_status` reports `available: true`.
+7. Pattern-store with the bridge intentionally unavailable returns `controller: 'memory-store-fallback'`. **Caveat β€” this check has a load-bearing unverified assumption:** the env-var name `MEMORY_BRIDGE_DISABLE=1` was inferred from the fallback code path, not confirmed against the actual gating mechanism in `bridgeHealthCheck`. Implementer must grep `agentdb-tools.ts` + `memory-bridge.ts` for the real switch (it may instead key on `AGENTDB_BRIDGE`, on a missing AgentDB controller, or on no env var at all). If no clean runtime switch exists, downgrade this check to a code-path inspection (assert the fallback string literal is reachable in source) rather than a runtime assertion.
+8. `agentdb_hierarchical-store` rejects a `tier` value not in `{working, episodic, semantic}` (regression on `agentdb-tools.ts:426`).
+9. `agentdb_batch` rejects a 501-element entries array (regression on `MAX_BATCH_SIZE = 500` at `agentdb-tools.ts:20`).
+10. Namespace convention guardrails: `memory_store --namespace 'has:colon'` is rejected; `memory_store --namespace '<205 chars>'` is rejected (tests the rule we just documented).
+
+The script does NOT test the controller count exactly, does NOT depend on `agentdb` being a specific minor version, and does NOT exercise the disabled `graphAdapter` controller. Those are explicit non-goals.
+
+### 7. Pinning posture
+
+Following ruvector ADR-0001:
+
+- Add a "Compatibility" subsection to README.md that states: "Plugin v0.3.x targets `@claude-flow/cli` v3.6.x with bundled `agentdb@^3.0.0-alpha.11`. The plugin is documentation-only and does not pin via package.json; the smoke contract is the verification mechanism."
+- Bump `.claude-plugin/plugin.json` to `0.3.0` when this ADR's changes land. Patch bumps thereafter for accuracy fixes; minor for new namespace-convention rules or new MCP tools surfaced.
+- Plugin pins the **CLI**'s major+minor (`v3.6`), not the npm `agentdb` package, because the CLI is the layer the plugin actually invokes. AgentDB internals (e.g., the alpha.11 β†’ alpha.12 bump) are not the plugin's contract.
+
+## Consequences
+
+**Positive:**
+
+- Every count, tool name, and capability claim in the plugin matches a verifiable line in the source. The "19 controllers" myth is gone.
+- RaBitQ goes from invisible to a documented quantization workflow β€” downstream plugins handling large corpora (`ruflo-rag-memory`, future `ruflo-knowledge-graph` integrations) get a 32Γ— memory-reduction story by reference, not by re-discovery.
+- HNSW becomes tunable instead of a magic number. Consumer plugins choose an operating point.
+- A namespace convention exists. `ruflo-browser`'s ADR Β§3 already implements it ad hoc; this ADR formalizes it so the next plugin author doesn't re-derive it.
+- Operational fallbacks (pattern-store fallback, graph-node backend) are now part of the contract; agents can branch on them deterministically.
+- `scripts/smoke.sh` makes plugin-level regressions catchable in CI.
+
+**Negative:**
+
+- Three downstream plugins reference "19 controllers" in their own docs (grep across `plugins/`). Updating them is a separate, mechanical task β€” but if it's not done, the inconsistency moves rather than disappears.
+- The namespace convention is non-binding (we have no enforcement in the bridge). It documents intent. If a downstream plugin ignores it, the substrate still works β€” it just gets harder to reason about. Future enforcement would be a `validate-namespace` helper exposed via MCP, but that is out of scope here.
+- Smoke depends on the daemon being healthy and the embeddings backend being warm. Cold-start runs may flake on `embeddings_rabitq_build` if no vectors are loaded yet. Mitigation: smoke seeds 10 vectors via `memory_store` before exercising the rabitq path.
+- We do not propose changing `agentdb-tools.ts` itself. Some of the "19 controllers" claim is upstream framing in the AgentDB README too; we cannot unilaterally fix that, only stop propagating it from the plugin.
+
+**Neutral:**
+
+- Plugin version moves `0.2.0` β†’ `0.3.0`. Semver-minor because the namespace convention is a new contract for consumers, not a removal.
+- No new MCP tools are introduced. We are surfacing existing surface, not extending it.
+- No change to the `.claude-plugin/plugin.json` keywords beyond optionally adding `rabitq` and `quantization`. Keywords are advisory only.
+
+## Verification
+
+A future implementation must satisfy this smoke contract before the ADR moves from Proposed β†’ Accepted:
+
+```bash
+bash plugins/ruflo-agentdb/scripts/smoke.sh
+# Expected: "10 passed, 0 failed"
+```
+
+Plus three documentation invariants checked by a one-line `grep` each:
+
+- `! grep -rn "19 AgentDB controllers\|all 19 controllers\|19 Controllers" plugins/ruflo-agentdb/` β€” no occurrence remains.
+- `grep -q "embeddings_rabitq_build" plugins/ruflo-agentdb/skills/vector-search/SKILL.md` β€” quantization workflow is documented.
+- `grep -q "Namespace convention" plugins/ruflo-agentdb/README.md` β€” namespace contract section exists.
+
+## Related
+
+- `plugins/ruflo-ruvector/docs/adrs/0001-pin-ruvector-0.2.25.md` β€” pinning + smoke-as-contract precedent (this ADR mirrors Β§5 and Β§6).
+- `plugins/ruflo-browser/docs/adrs/0001-browser-skills-architecture.md` β€” `browser-*` namespace family that motivated Β§4 (namespace convention contract).
+- `v3/docs/adr/ADR-053-...` β€” controller activation pipeline (referenced by the bridge module docstring at `memory-bridge.ts:5`).
+- `v3/docs/adr/ADR-087-graph-node-native-backend.md` β€” graph-node backend used as the primary `agentdb_causal-edge` path.
+- `v3/docs/adr/ADR-093-mcp-audit-may-2026-remediation.md` β€” F4 introduced the `memory-store-fallback` controller string surfaced by Β§5.
+- `v3/docs/adr/ADR-095-architectural-gaps-from-april-audit.md` β€” G7 closed five disabled controllers; the README block `README.md:22–35` summarizes G7 correctly.
+- `v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts` β€” 15 `agentdb_*` tool definitions (canonical surface for Β§6 check 3).
+- `v3/@claude-flow/cli/src/mcp-tools/embeddings-tools.ts` β€” 10 `embeddings_*` tool definitions including RaBitQ trio at `:910–981`.
+- `v3/@claude-flow/cli/src/mcp-tools/ruvllm-tools.ts` β€” 3 `ruvllm_hnsw_*` tools, ~11-pattern WASM cap at `:58`.
+- `v3/@claude-flow/memory/src/controller-registry.ts:34–73` β€” `ControllerName` union (canonical 29-name list).
+- `v3/@claude-flow/memory/src/controller-registry.ts:160–174` β€” `INIT_LEVELS` (canonical dependency-ordered grouping).
+- `v3/@claude-flow/cli/src/memory/rabitq-index.ts` β€” RaBitQ implementation referenced by the quantization workflow in Β§2.
+- `v3/@claude-flow/integration/src/token-optimizer.ts:109` β€” `getCompactContext` token-efficiency path (deferred: Β§6 covers `agentdb_context-synthesize` only; the integration-layer optimizer is a separate ADR if surfaced).
diff --git a/plugins/ruflo-agentdb/scripts/smoke.sh b/plugins/ruflo-agentdb/scripts/smoke.sh
new file mode 100755
index 0000000000..ca7c8aa576
--- /dev/null
+++ b/plugins/ruflo-agentdb/scripts/smoke.sh
@@ -0,0 +1,204 @@
+#!/usr/bin/env bash
+# Structural smoke test for ruflo-agentdb plugin v0.3.0.
+# Per ADR-0001 Β§6 Verification: 10 numbered checks against the documented
+# CLI MCP surface plus three documentation invariants.
+#
+# This script verifies plugin structural soundness and source-level
+# contracts. Live MCP-tool exercise (against a running daemon with the
+# bridge wired) is layered on top via the optional --live flag, but the
+# default invocation is offline-safe and CI-friendly.
+set -u
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+REPO_ROOT="$(cd "$ROOT/../.." && pwd)"
+LIVE=0
+for arg in "$@"; do
+ case "$arg" in --live) LIVE=1 ;; esac
+done
+
+PASS=0
+FAIL=0
+
+step() { printf "β†’ %s ... " "$1"; }
+ok() { printf "PASS\n"; PASS=$((PASS+1)); }
+bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }
+
+# Documentation invariants (ADR-0001 Β§Verification)
+step "INV1: no '19 controllers' string in plugin docs (excluding ADRs which document history)"
+# ADR files inside docs/adrs/ are allowed to reference "19 controllers" because
+# they document the change. The invariant is on user-facing docs only.
+hits=$(grep -rE '19 (AgentDB )?[Cc]ontrollers|all 19 controllers' "$ROOT" \
+ --include='*.md' --include='*.json' \
+ --exclude-dir='adrs' 2>/dev/null || true)
+if [[ -n "$hits" ]]; then
+ bad "stale '19 controllers' phrasing still present in user-facing docs:"
+ echo "$hits" | sed 's/^/ /'
+else
+ ok
+fi
+
+step "INV2: RaBitQ workflow documented in vector-search SKILL"
+grep -q "embeddings_rabitq_build" "$ROOT/skills/vector-search/SKILL.md" \
+ && grep -q "embeddings_rabitq_search" "$ROOT/skills/vector-search/SKILL.md" \
+ && grep -q "embeddings_rabitq_status" "$ROOT/skills/vector-search/SKILL.md" \
+ && ok || bad "RaBitQ trio not all documented"
+
+step "INV3: README has the Namespace convention section"
+grep -q "## Namespace convention" "$ROOT/README.md" \
+ && grep -q "Reserved namespaces" "$ROOT/README.md" \
+ && ok || bad "Namespace convention section missing"
+
+# 1. Plugin version + new keywords
+step "1. plugin.json declares version 0.3.0 with rabitq + namespace-convention keywords"
+v=$(grep -E '"version"[[:space:]]*:' "$ROOT/.claude-plugin/plugin.json" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
+if [[ "$v" != "0.3.0" ]]; then
+ bad "expected 0.3.0, got '$v'"
+else
+ miss=""
+ for k in rabitq quantization namespace-convention controller-bridge; do
+ grep -q "\"$k\"" "$ROOT/.claude-plugin/plugin.json" || miss="$miss $k"
+ done
+ [[ -z "$miss" ]] && ok || bad "missing keywords:$miss"
+fi
+
+# 2. Controller-count claims defer to runtime
+step "2. README/agent/command/skill defer controller count to runtime tool"
+miss=""
+for f in "$ROOT/README.md" "$ROOT/agents/agentdb-specialist.md" "$ROOT/commands/agentdb.md" "$ROOT/skills/agentdb-query/SKILL.md"; do
+ grep -q "agentdb_controllers" "$f" || miss="$miss $(basename $f)"
+done
+[[ -z "$miss" ]] && ok || bad "missing agentdb_controllers reference:$miss"
+
+# 3. All 15 agentdb_* tool names are documented somewhere in the plugin
+step "3. all 15 agentdb_* tool names referenced in plugin docs"
+miss=""
+for t in agentdb_health agentdb_controllers agentdb_pattern-store agentdb_pattern-search agentdb_feedback agentdb_causal-edge agentdb_route agentdb_session-start agentdb_session-end agentdb_hierarchical-store agentdb_hierarchical-recall agentdb_consolidate agentdb_batch agentdb_context-synthesize agentdb_semantic-route; do
+ grep -rq "$t" "$ROOT" --include='*.md' || miss="$miss $t"
+done
+[[ -z "$miss" ]] && ok || bad "undocumented:$miss"
+
+# 4. All 10 embeddings_* tools documented
+step "4. all 10 embeddings_* tool names referenced in plugin docs"
+miss=""
+for t in embeddings_init embeddings_generate embeddings_compare embeddings_search embeddings_neural embeddings_hyperbolic embeddings_status embeddings_rabitq_build embeddings_rabitq_search embeddings_rabitq_status; do
+ grep -rq "$t" "$ROOT" --include='*.md' || miss="$miss $t"
+done
+[[ -z "$miss" ]] && ok || bad "undocumented:$miss"
+
+# 5. The 3 ruvllm_hnsw_* tools documented + the ~11 cap is acknowledged
+step "5. ruvllm_hnsw_* tools documented and ~11 cap acknowledged"
+miss=""
+for t in ruvllm_hnsw_create ruvllm_hnsw_add ruvllm_hnsw_route; do
+ grep -rq "$t" "$ROOT" --include='*.md' || miss="$miss $t"
+done
+if [[ -n "$miss" ]]; then
+ bad "undocumented:$miss"
+elif ! grep -rq "11 patterns\|≀11" "$ROOT/skills/vector-search/SKILL.md" "$ROOT/README.md" "$ROOT/agents/agentdb-specialist.md"; then
+ bad "WASM cap (~11 patterns) not acknowledged"
+else
+ ok
+fi
+
+# 6. RaBitQ workflow has a 5-step recipe + the rerank caveat
+step "6. RaBitQ section has the 5-step recipe + rerank caveat"
+F="$ROOT/skills/vector-search/SKILL.md"
+if grep -q "Quantized search" "$F" \
+ && grep -q "rerank" "$F" \
+ && grep -qE "embeddings_rabitq_build" "$F" \
+ && grep -qE "embeddings_rabitq_search" "$F" \
+ && grep -qE "embeddings_rabitq_status" "$F"; then
+ ok
+else
+ bad "RaBitQ section incomplete (missing recipe or rerank caveat)"
+fi
+
+# 7. Pattern-store fallback is source-inspectable (no env var gates this β€” see ADR Β§6 caveat)
+step "7. memory-store-fallback path is source-inspectable in agentdb-tools.ts"
+TOOLS="$REPO_ROOT/v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts"
+if [[ -f "$TOOLS" ]] \
+ && grep -q "memory-store-fallback" "$TOOLS" \
+ && grep -q "ReasoningBank controller registry unavailable" "$TOOLS"; then
+ ok
+else
+ bad "fallback string not present in agentdb-tools.ts (or file moved)"
+fi
+
+# 8. agentdb_hierarchical-store rejects an unknown tier
+step "8. tier validator rejects unknown tier values"
+TOOLS="$REPO_ROOT/v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts"
+if grep -qE "(working|episodic|semantic).*tier|tier.*(working|episodic|semantic)" "$TOOLS"; then
+ ok
+else
+ bad "tier validator pattern not found in agentdb-tools.ts"
+fi
+
+# 9. Batch size is bounded
+step "9. agentdb_batch enforces MAX_BATCH_SIZE = 500"
+TOOLS="$REPO_ROOT/v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts"
+if grep -qE "MAX_BATCH_SIZE\s*=\s*500" "$TOOLS"; then
+ ok
+else
+ bad "MAX_BATCH_SIZE = 500 not present (or moved)"
+fi
+
+# 10. Namespace convention guardrails: reserved list + colon rule + length cap
+step "10. namespace guardrails documented (reserved list + colon rule + length cap)"
+F="$ROOT/README.md"
+miss=""
+grep -q "claude-memories" "$F" || miss="$miss reserved-list"
+grep -qE "SHOULD NOT contain.+:.+colon|colon.+delimiter" "$F" || \
+ grep -qE 'NOT contain `:`' "$F" || miss="$miss colon-rule"
+grep -qE "200 chars|≀200" "$F" || miss="$miss length-cap"
+[[ -z "$miss" ]] && ok || bad "guardrail set incomplete:$miss"
+
+# 11. Auto-memory bridge mechanics documented (Claude Code populates claude-memories)
+step "11. auto-memory bridge mechanics documented (memory_import_claude + auto-memory-hook.mjs)"
+F="$ROOT/README.md"
+if grep -q "How Claude Code populates AgentDB" "$F" \
+ && grep -q "memory_import_claude" "$F" \
+ && grep -q "auto-memory-hook.mjs" "$F" \
+ && grep -q "memory_bridge_status" "$F" \
+ && grep -q "memory_search_unified" "$F"; then
+ ok
+else
+ bad "auto-memory bridge section missing pieces (header, import tool, hook script, bridge status, unified search)"
+fi
+
+# 12. Hook β†’ namespace integration table
+step "12. hook integration table maps hook β†’ namespace it writes to"
+F="$ROOT/README.md"
+if grep -q "Hook integration convention" "$F" \
+ && grep -q "SessionStart" "$F" \
+ && grep -q "post-task --train-neural" "$F" \
+ && grep -qE "ReasoningBank.*pattern|pattern.*ReasoningBank" "$F"; then
+ ok
+else
+ bad "hook integration table missing (SessionStart, post-task --train-neural, ReasoningBank β†’ pattern)"
+fi
+
+# 13. Pluralization gotcha (pattern vs patterns)
+step "13. pluralization gotcha documented (pattern vs patterns)"
+F="$ROOT/README.md"
+if grep -qiE "pluraliz.*gotcha|pattern.*plural|plural.*pattern" "$F" \
+ && grep -q '`pattern`' "$F" \
+ && grep -q '`patterns`' "$F"; then
+ ok
+else
+ bad "pluralization callout missing (must contrast pattern vs patterns)"
+fi
+
+# Live mode (optional, requires daemon)
+if [[ "$LIVE" == "1" ]]; then
+ step "L1 (live): agentdb_health responds (requires running daemon)"
+ if command -v claude-flow >/dev/null 2>&1; then
+ if claude-flow mcp call agentdb_health 2>/dev/null | grep -q '"available"'; then
+ ok
+ else
+ bad "agentdb_health did not return an 'available' field"
+ fi
+ else
+ bad "claude-flow CLI not on PATH (skipping --live checks)"
+ fi
+fi
+
+printf "\n%s passed, %s failed\n" "$PASS" "$FAIL"
+[[ $FAIL -eq 0 ]] || exit 1
diff --git a/plugins/ruflo-agentdb/skills/agentdb-query/SKILL.md b/plugins/ruflo-agentdb/skills/agentdb-query/SKILL.md
index f565613c84..a3ef270014 100644
--- a/plugins/ruflo-agentdb/skills/agentdb-query/SKILL.md
+++ b/plugins/ruflo-agentdb/skills/agentdb-query/SKILL.md
@@ -1,13 +1,13 @@
---
name: agentdb-query
-description: Query AgentDB with semantic routing, hierarchical recall, causal graphs, and context synthesis
+description: Query AgentDB through the controller bridge -- semantic routing, hierarchical recall, causal graphs, context synthesis, pattern store/search
argument-hint: "<query>"
allowed-tools: mcp__claude-flow__agentdb_semantic-route mcp__claude-flow__agentdb_hierarchical-recall mcp__claude-flow__agentdb_hierarchical-store mcp__claude-flow__agentdb_context-synthesize mcp__claude-flow__agentdb_causal-edge mcp__claude-flow__agentdb_pattern-search mcp__claude-flow__agentdb_pattern-store mcp__claude-flow__agentdb_controllers mcp__claude-flow__agentdb_health mcp__claude-flow__agentdb_batch mcp__claude-flow__agentdb_feedback mcp__claude-flow__agentdb_consolidate mcp__claude-flow__agentdb_session-start mcp__claude-flow__agentdb_session-end Bash
---
# AgentDB Query
-Query and manage AgentDB's 19 memory controllers.
+Query and manage AgentDB through the controller bridge. AgentDB exposes 15 `agentdb_*` MCP tools; this skill enumerates the standard usage path.
## When to use
@@ -15,25 +15,35 @@ When you need to store, retrieve, or search knowledge across agent sessions. Age
## Steps
-1. **Check health** β€” call `mcp__claude-flow__agentdb_health` to verify AgentDB is running
-2. **Start session** β€” call `mcp__claude-flow__agentdb_session-start` if not already active
-3. **Store knowledge** β€” call `mcp__claude-flow__agentdb_hierarchical-store` for structured data
-4. **Recall knowledge** β€” call `mcp__claude-flow__agentdb_hierarchical-recall` with a query
-5. **Search patterns** β€” call `mcp__claude-flow__agentdb_pattern-search` for learned patterns
-6. **Synthesize context** β€” call `mcp__claude-flow__agentdb_context-synthesize` to combine multiple memories
-7. **Build causal graph** β€” call `mcp__claude-flow__agentdb_causal-edge` to link related knowledge
-
-## 19 Controllers
-
-Call `mcp__claude-flow__agentdb_controllers` to list all available controllers:
-- Hierarchical store/recall
-- Pattern store/search
-- Semantic routing
-- Context synthesis
-- Causal edges
-- Feedback loops
-- Batch operations
-- Consolidation
+1. **Check health** β€” `mcp__claude-flow__agentdb_health`. Sanity-check `available: true`.
+2. **Start session** β€” `mcp__claude-flow__agentdb_session-start` if not already active.
+3. **Store knowledge** β€” `mcp__claude-flow__agentdb_hierarchical-store` for structured tier-keyed data (tiers: `working|episodic|semantic`).
+4. **Recall knowledge** β€” `mcp__claude-flow__agentdb_hierarchical-recall` with a query.
+5. **Search patterns** β€” `mcp__claude-flow__agentdb_pattern-search` for learned patterns (ReasoningBank-routed).
+6. **Synthesize context** β€” `mcp__claude-flow__agentdb_context-synthesize` to combine multiple memories.
+7. **Build causal graph** β€” `mcp__claude-flow__agentdb_causal-edge` to link related knowledge.
+
+## Available controller groups
+
+Call `mcp__claude-flow__agentdb_controllers` to list the runtime registry. Functional categories surfaced via the 15 MCP tools:
+
+- **Hierarchical** β€” `agentdb_hierarchical-store`, `_recall` (tier-routed)
+- **Pattern** β€” `agentdb_pattern-store`, `_search` (ReasoningBank-routed)
+- **Semantic** β€” `agentdb_semantic-route`, `_context-synthesize`
+- **Causal** β€” `agentdb_causal-edge` (graph-node backend with bridge fallback)
+- **Lifecycle** β€” `agentdb_health`, `_controllers`, `_session-start`, `_session-end`
+- **Bulk** β€” `agentdb_batch` (≀500 entries), `_consolidate`
+- **Quality** β€” `agentdb_feedback`
+
+## Important: namespace handling
+
+Namespace strings apply to `memory_*` and `embeddings_search` only. The `agentdb_hierarchical-*`, `agentdb_pattern-*`, and `agentdb_causal-edge` tools route by **tier** or **controller**, not namespace. Don't pass `namespace: 'foo'` to those tools β€” it will be silently ignored. See plugin README "Namespace convention".
+
+## Operational fallbacks (branch on these)
+
+- `controller: 'memory-store-fallback'` β€” pattern persisted via `memory_store --namespace pattern`. NOT a failure.
+- `_graphNodeBackend: true` β€” causal-edge handled by `@ruvector/graph-node`.
+- `success: false, error: '...Use memory_store/memory_search instead.'` β€” bridge unavailable; switch to `memory_*` tools per the README replacement table.
## CLI alternative
diff --git a/plugins/ruflo-agentdb/skills/vector-search/SKILL.md b/plugins/ruflo-agentdb/skills/vector-search/SKILL.md
index bbbdaec46e..386818bd75 100644
--- a/plugins/ruflo-agentdb/skills/vector-search/SKILL.md
+++ b/plugins/ruflo-agentdb/skills/vector-search/SKILL.md
@@ -1,37 +1,79 @@
---
name: vector-search
-description: HNSW vector search with RuVector embeddings for 150x-12500x faster semantic retrieval
-argument-hint: "<query> [--limit N]"
-allowed-tools: mcp__claude-flow__embeddings_generate mcp__claude-flow__embeddings_search mcp__claude-flow__embeddings_compare mcp__claude-flow__embeddings_init mcp__claude-flow__embeddings_status mcp__claude-flow__embeddings_hyperbolic mcp__claude-flow__embeddings_neural mcp__claude-flow__ruvllm_hnsw_create mcp__claude-flow__ruvllm_hnsw_add mcp__claude-flow__ruvllm_hnsw_route mcp__claude-flow__memory_search_unified Bash
+description: Vector search via embeddings_* (large-scale HNSW) and ruvllm_hnsw_* (WASM router for ≀11 hot patterns), with RaBitQ 1-bit quantization for 32Γ— memory reduction
+argument-hint: "<query> [--limit N] [--quantized]"
+allowed-tools: mcp__claude-flow__embeddings_generate mcp__claude-flow__embeddings_search mcp__claude-flow__embeddings_compare mcp__claude-flow__embeddings_init mcp__claude-flow__embeddings_status mcp__claude-flow__embeddings_hyperbolic mcp__claude-flow__embeddings_neural mcp__claude-flow__embeddings_rabitq_build mcp__claude-flow__embeddings_rabitq_search mcp__claude-flow__embeddings_rabitq_status mcp__claude-flow__ruvllm_hnsw_create mcp__claude-flow__ruvllm_hnsw_add mcp__claude-flow__ruvllm_hnsw_route mcp__claude-flow__memory_search_unified Bash
---
# Vector Search
-HNSW-indexed vector search with RuVector embeddings (384-dim ONNX).
+Two distinct vector-search paths live in this plugin. Pick the right one β€” they're not interchangeable.
+
+| Path | Tool family | Backing | Capacity | Latency |
+|------|-------------|---------|----------|---------|
+| **Large-scale corpus** | `embeddings_*` | `@claude-flow/memory` HNSW (Rust/Native) | up to millions of vectors | 150×–12,500Γ— faster than brute-force, depending on N and parameters |
+| **Hot-path router** | `ruvllm_hnsw_*` | WASM-backed router (v2.0.1) | **~11 patterns max** (`ruvllm-tools.ts:58`) | sub-ms; designed for high-priority routing, not corpus search |
+
+The "12,500Γ—" headline applies to the large-scale `embeddings_search` path. The WASM router is **not** that path.
## When to use
-When you need fast semantic search across large knowledge bases. HNSW provides 150x-12,500x faster search compared to brute-force scanning.
+| Need | Path |
+|---|---|
+| Search a corpus of N β‰₯ 500 documents | `embeddings_search` |
+| Memory-constrained corpus (β‰₯5,000 vectors) | RaBitQ quantized β€” see "Quantized search" below |
+| Compare two strings | `embeddings_compare` |
+| Hierarchical / taxonomic data | `embeddings_hyperbolic` (Poincare ball) |
+| Route a query to one of ≀11 hot patterns | `ruvllm_hnsw_route` |
+| Cross-namespace search | `memory_search_unified` |
+
+## Standard search
+
+1. **Check status** β€” `mcp__claude-flow__embeddings_status` to verify the embedding engine.
+2. **Initialize** β€” `mcp__claude-flow__embeddings_init` if not active.
+3. **Generate** β€” `mcp__claude-flow__embeddings_generate` for text input.
+4. **Search** β€” `mcp__claude-flow__embeddings_search` with the query.
+5. **Compare** β€” `mcp__claude-flow__embeddings_compare` to measure similarity.
+6. **Unified search** β€” `mcp__claude-flow__memory_search_unified` for cross-namespace.
+
+## Quantized search (32Γ— memory reduction)
+
+For corpora β‰₯5,000 vectors and/or memory-constrained environments, use the RaBitQ 1-bit quantization workflow. Below 5,000 vectors the rebuild cost outweighs the savings β€” use the standard path instead.
+
+| Step | Tool | Purpose |
+|---|---|---|
+| 1 | `embeddings_init` | Engine warm |
+| 2 | `embeddings_rabitq_build` | One-time build of the 1-bit index after corpus is loaded |
+| 3 | `embeddings_rabitq_search` | Hamming-prefilter returns top-N candidate IDs (cheap) |
+| 4 | `embeddings_search` | Optional exact rerank on the candidate set (full-precision) |
+| 5 | `embeddings_rabitq_status` | Index health, memory footprint, build time |
+
+> **Note**: `embeddings_rabitq_search` returns candidate IDs only β€” the rerank in step 4 is the user's responsibility (mirrors the docstring at `embeddings-tools.ts:911`). Without rerank, results are approximate; with rerank, you get full-precision quality at 32Γ— lower memory.
+
+## Tuning
+
+HNSW exposes three knobs that trade recall against latency. The "12,500Γ—" headline assumes **defaults**; tune deliberately for your workload:
+
+| Profile | `efSearch` | `M` | When to use |
+|---------|-----------|-----|-------------|
+| `recall-first` | 200 | 32 | Pattern recall during planning; quality matters more than ms |
+| `balanced` (default) | 64 | 16 | General-purpose semantic recall |
+| `latency-first` | 16 | 8 | Hot-path routing where p99 latency matters |
-## Steps
+`efSearch` is passed via `ruvllm_hnsw_create` (`ruvllm-tools.ts:64`). `M` is registry-level today; raise as a follow-up if it should be MCP-tunable. `efConstruction` defaults to 200 in the lite index (`hnsw-index.ts:537`).
-1. **Check status** β€” call `mcp__claude-flow__embeddings_status` to verify the embedding engine
-2. **Initialize** β€” call `mcp__claude-flow__embeddings_init` if not already active
-3. **Generate embeddings** β€” call `mcp__claude-flow__embeddings_generate` for text input
-4. **Search** β€” call `mcp__claude-flow__embeddings_search` with a query for semantic matches
-5. **Compare** β€” call `mcp__claude-flow__embeddings_compare` to measure similarity between texts
-6. **Unified search** β€” call `mcp__claude-flow__memory_search_unified` to search across all namespaces
+## HNSW pattern router (WASM, ≀11 patterns)
-## HNSW Index
+For routing a small number of high-priority patterns:
+- `mcp__claude-flow__ruvllm_hnsw_create` β€” create the WASM index (cap ~11)
+- `mcp__claude-flow__ruvllm_hnsw_add` β€” add a pattern
+- `mcp__claude-flow__ruvllm_hnsw_route` β€” route an incoming query
-For building custom HNSW indexes:
-- `mcp__claude-flow__ruvllm_hnsw_create` β€” create a new index
-- `mcp__claude-flow__ruvllm_hnsw_add` β€” add vectors to the index
-- `mcp__claude-flow__ruvllm_hnsw_route` β€” route queries through the index
+This is **not** a corpus index. Treat it as a fast classifier over a curated set of patterns.
## Hyperbolic embeddings
-For hierarchical data (code trees, org charts), use `mcp__claude-flow__embeddings_hyperbolic` which maps to Poincare ball space.
+For hierarchical data (code trees, org charts), use `mcp__claude-flow__embeddings_hyperbolic` which maps to Poincare ball space. Distance is geodesic, not cosine.
## CLI alternative
@@ -46,5 +88,7 @@ npx @claude-flow/cli@latest memory search --query "your query"
| Method | Speed |
|--------|-------|
| Brute-force scan | Baseline |
-| HNSW (n=500) | 150x faster |
-| HNSW (n=10,000) | 12,500x faster |
+| HNSW (n=500, balanced) | ~150Γ— faster |
+| HNSW (n=10,000, balanced) | ~12,500Γ— faster |
+| RaBitQ + rerank (n=10,000) | ~12,500Γ— search speed at 32Γ— lower memory |
+| `ruvllm_hnsw_route` (n≀11) | sub-ms per route, fixed cost |