Tools
Memory Lancedb Pro V4
Capability-first LanceDB memory plugin for OpenClaw โ hybrid retrieval (FTS+Vector+Lexical), Wiki knowledge graph + vector search, 17 tools, dreaming engine, incremental build
Install
npm install
#
Configuration Example
{
"plugins": {
"entries": {
"memory-lancedb-pro": {
"config": {
"dbPath": "path/to/lancedb",
"tableName": "memories",
"embeddingDimension": 2560,
"connectionMode": "embedded",
"retrieval": {
"hybrid": true,
"rerank": false
},
"vault": {
"path": "path/to/wiki"
},
"context": {
"includeCompiledDigestPrompt": false // default: false
},
"hostInterop": {
"enableArtifacts": true,
"enableEvents": true
},
"dreaming": {
"enabled": false // default: false
}
}
}
}
}
}
README
# Memory LanceDB Pro v4
Capability-first LanceDB memory plugin for OpenClaw โ hybrid retrieval, Wiki knowledge graph with vector search, dreaming engine, and incremental build.
**Production-proven**: 767+ memories, 142 wiki pages vector-indexed, 4350 graph nodes / 5435 edges, 218/218 vitest passing.
## Quick Facts
| Item | Detail |
|------|--------|
| Version | 4.0.0 |
| OpenClaw | >=2026.5.6 |
| Tools | 18 (10 memory + 8 wiki) |
| Tests | 218 (9 test files) |
| DB | LanceDB 0.33 embedded |
| Embedding | 2560-dim (DashScope tongyi-embedding-vision-flash) |
| Tables | `memories` + `wiki_pages` (fully isolated) |
| Retrieval | Hybrid: FTS (BM25) + Vector (cosine) + Lexical |
| Wiki | Graph + Vector Search + Incremental Build |
---
## Architecture
```
dist/
index.js โ Plugin entry (definePluginEntry)
config/ โ Config resolve + schema + backend config
store/
lancedb-store.js โ LanceDB 0.33 store (BITMAP + FTS indexes)
asset-store.js โ Multimodal asset indexing
migrations.js โ Schema migration manager
scope-manager.js โ Memory scope normalization
retrieval/
embedder.js โ DashScope multimodal embedding (2560-dim)
hybrid-retriever.js โ FTS + Vector + Lexical three-way fusion
search-manager.js โ Public search interface (MemorySearchResult)
rerank.js โ External rerank provider (optional)
tools/
register.js โ Tool registration + context init
store.js โ memory_store
recall.js โ memory_recall
list.js โ memory_list
promote.js โ memory_promote
update.js โ memory_update
archive.js โ memory_archive
diagnostics.js โ memory_stats + memory_debug
wiki-tools.js โ 8 wiki tools registration
wiki/
wiki-store.js โ Wiki vault CRUD
wiki-graph.js โ Graph build (full + incremental) + query
wiki-extractor.js โ Markdown content extractor
wiki-index.js โ Category index builder
wiki-doctor.js โ Vault health checker
wiki-sync-links.js โ Backlink synchronizer
wiki-supplement.js โ Corpus + prompt supplements (3-way fusion)
digest-compiler.js โ Compiled digest generator
wiki-vector-index.js โ P1: Vector index for wiki pages
build-manifest.js โ P2: File fingerprint tracking
obsidian-cli.js โ Obsidian CLI probe (optional)
capture/
sanitization.js โ Envelope sludge detection
policy.js โ Recall query normalization
prompt-defense.js โ Prompt injection detection + escape
dreaming/
engine.js โ Dreaming 3-phase sweep engine
config.js โ Dreaming config + source aliases
hooks/
auto-memory.js โ Auto-recall hooks (agent_end)
interop/
memory-capability.js โ Memory capability runtime
public-artifacts.js โ Public artifacts provider
host-events.js โ Host events manager
doctor/
cli.js โ Doctor CLI (schema validation + cleanup)
state/
plugin-state.js โ openKeyedStore persistence
migration/
index.js โ Legacy v0โv2 migration
```
---
## Tools (18)
### Memory Tools (10)
| Tool | Description |
|------|-------------|
| `memory_store` | Store a memory with embedding |
| `memory_recall` | Hybrid search (FTS + Vector + Lexical) |
| `memory_list` | List memories with filters |
| `memory_update` | Update an existing memory |
| `memory_archive` | Archive (soft-delete) a memory |
| `memory_promote` | Promote memory to durable/core |
| `memory_stats` | Memory statistics |
| `memory_debug` | Retrieval pipeline debug trace |
| `memory_migrate_legacy` | Migrate from legacy database |
| `memory_forget` | Permanently delete a memory |
### Wiki Tools (8)
| Tool | Description |
|------|-------------|
| `wiki_status` | Vault mode, health, Obsidian CLI availability |
| `wiki_new` | Create new wiki entry with front matter |
| `wiki_get` | Read wiki entry by path or lookup term |
| `wiki_query` | Query knowledge graph by keyword |
| `wiki_build` | Build graph (incremental by default, `force:true` for full) |
| `wiki_doctor` | Lint vault: broken links, stale graph, health |
| `wiki_index` | Rebuild category indexes + main INDEX.md |
| `wiki_sync_links` | Synchronize backlinks across all entries |
---
## Feature Matrix
### Enabled by Default
| Feature | Description |
|---------|-------------|
| **Hybrid Retrieval** | Three-way fusion: FTS (BM25, icu tokenizer) + Vector (cosine, native LanceDB) + Lexical (fallback). Sigmoid normalization for BM25 scores. |
| **Wiki Vector Search** | Independent `wiki_pages` table with full-page embedding. Three-way fusion: vector x0.5 + keyword x0.3 + graph x0.2. Graceful degradation when embedding unavailable. |
| **Wiki Incremental Build** | File fingerprint tracking (`build-manifest.json`, mtime + contentHash). Only re-extracts changed files. Dangling edge cleanup. No-change detection skips rebuild. |
| **Wiki Corpus Supplement** | Wiki search integrated into `memory_recall` pipeline via corpus supplement interface. |
| **autoRecall** | Automatic memory recall on agent turn end, with prompt injection defense and envelope sludge filtering. |
| **access_count** | Recall access tracking with write-back. Feeds dreaming deep promotion quality scoring. |
| **Dreaming Sweep** | 3-phase: light archive + deep promote + REM create. Scheduled via cron. |
| **Doctor CLI** | Schema validation + contamination cleanup (`openclaw doctor`). |
| **Host Interop** | Public artifacts provider + host events manager. |
| **Plugin State** | openKeyedStore persistence (fire-and-forget, honest degradation). |
| **Legacy Migration** | Automatic v0โv2 schema upgrade with skip-existing idempotency. |
### Disabled by Default
| Feature | Description | Reason |
|---------|-------------|--------|
| **includeCompiledDigestPrompt** | Compiled wiki digest injected into prompt | Offline assessment pending. Enable via config `context.includeCompiledDigestPrompt: true`. |
| **Semantic Edge Inference** | LLM-powered semantic edges in wiki graph | Not implemented in TypeScript (graceful degradation). Use Python wiki_ops.py for semantic builds. |
| **Dreaming Engine** | Background dreaming process | Engine created but not started. Enable via config `dreaming.enabled: true`. |
| **Rerank** | External rerank provider | Requires additional config (`retrieval.rerankProvider`, `retrieval.rerankModel`, `retrieval.rerankBaseUrl`). |
| **Obsidian CLI** | Obsidian vault integration | Probe available but Obsidian not installed on this host. Auto-detects if installed. |
### Removed in v4
| Feature | Reason |
|---------|--------|
| **autoCapture / customTriggers** | Permanently removed per user decision. Redundant with agent-initiated `memory_store` / `/remember`. Capture library modules retained for recall path (policy/sanitization/prompt-defense). |
---
## Retrieval Pipeline
```
memory_recall("query")
โโโ FTS Search (BM25, icu tokenizer, sigmoid normalization)
โโโ Vector Search (cosine, native LanceDB vectorSearch)
โโโ Lexical Search (fallback, term frequency + exact match bonus)
โโโ Three-way Fusion (configurable weights)
โโโ Rerank (optional, external provider)
โโโ Wiki Corpus Supplement
โโโ Vector Search (wiki_pages table, cosine)
โโโ Keyword Match (title + body)
โโโ Graph Query (graph.json node matching)
โโโ Fusion: vectorร0.5 + keywordร0.3 + graphร0.2
```
## Wiki Build Pipeline
```
wiki_build() โ Incremental by default
โโโ Load build-manifest.json
โโโ Scan vault fingerprints (mtime + contentHash)
โโโ Detect changes (added / modified / deleted / unchanged)
โโโ If no changes โ skip rebuild
โโโ If changes:
โ โโโ Re-extract changed files only
โ โโโ Remove deleted/modified file nodes/edges
โ โโโ Merge with unchanged graph
โ โโโ Clean dangling edges
โ โโโ Deduplicate nodes
โ โโโ Detect communities
โ โโโ Export graph.json + GRAPH_REPORT.md + graph.html
โ โโโ Update digest
โ โโโ Update vector index (wiki_pages)
โโโ Save manifest
wiki_build({ force: true }) โ Full rebuild
โโโ Extract all files
โโโ Build graph from scratch
โโโ Clean dangling edges
โโโ Detect communities
โโโ Export all outputs
โโโ Compile digest
โโโ Rebuild vector index
โโโ Save manifest
```
## Storage
| Table | Purpose | Schema |
|-------|---------|--------|
| `memories` | User memories | id, scope, content, embedding[2560], category, importance, createdAt, updatedAt, metadata |
| `wiki_pages` | Wiki vector index | id, path, title, content, embedding[2560], category, tags, updatedAt, metadata |
| `memory_assets` | Multimodal assets | id, memoryId, modality, mimeType, storagePath, ... |
**Indexes**: BITMAP on `scope`/`category` (memories), BITMAP on `category` (wiki_pages), FTS on `content` (memories, icu tokenizer).
## Development
```bash
# Install
npm install
# Type check
npm run typecheck
# Test (218 tests)
npm test
# Integration tests
node scripts/test-wiki-vector-index.mjs
node scripts/test-wiki-incremental-build.mjs
```
## Configuration
```jsonc
{
"plugins": {
"entries": {
"memory-lancedb-pro": {
"config": {
"dbPath": "path/to/lancedb",
"tableName": "memories",
"embeddingDimension": 2560,
"connectionMode": "embedded",
"retrieval": {
"hybrid": true,
"rerank": false
},
"vault": {
"path": "path/to/wiki"
},
"context": {
"includeCompiledDigestPrompt": false // default: false
},
"hostInterop": {
"enableArtifacts": true,
"enableEvents": true
},
"dreami
... (truncated)
tools
Comments
Sign in to leave a comment