rag-memory-epf-mcp 3.5.2 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/index.d.ts +50 -6
- package/dist/index.js +782 -188
- package/dist/src/backfillCoordinator.d.ts +59 -0
- package/dist/src/backfillCoordinator.js +552 -0
- package/dist/src/embeddingGate.d.ts +68 -0
- package/dist/src/embeddingGate.js +227 -0
- package/dist/src/migrations/migrations.js +71 -0
- package/dist/src/modelCache.d.ts +33 -0
- package/dist/src/modelCache.js +235 -0
- package/docs/UPDATING.md +121 -0
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -134,9 +134,19 @@ storeDocument(id, content, metadata)
|
|
|
134
134
|
|----------|---------|-------------|
|
|
135
135
|
| `DB_FILE_PATH` | `rag-memory.db` (server dir) | Path to project-local SQLite database |
|
|
136
136
|
| `EMBEDDING_MODEL` | `Xenova/bge-m3` | HuggingFace model ID for embeddings |
|
|
137
|
+
| `RAG_MEMORY_EMBEDDINGS` | `lazy` | Boot mode: `lazy` (connect instantly, model loads in background), `eager` (wait for model + reconciliation, pre-3.6 behavior), `off` (never load the model — FTS5-only, zero download) |
|
|
138
|
+
| `RAG_MEMORY_MODEL_CACHE_DIR` | OS user cache | Version-independent model cache location (see `docs/UPDATING.md`) |
|
|
139
|
+
| `RAG_MEMORY_TRUST_LEGACY_VECTORS` | unset | Set `1` to grandfather pre-existing vectors under a **custom** `EMBEDDING_MODEL` (default model configs grandfather automatically) |
|
|
137
140
|
|
|
138
141
|
## Changelog
|
|
139
142
|
|
|
143
|
+
### v3.6.0
|
|
144
|
+
- **Lite install / lazy boot**: the MCP server connects immediately — FTS5 search, knowledge graph and CRUD work from the first second, while the bge-m3 model (~1.2GB) loads or downloads in the background. Hybrid search switches on automatically. Requires Node **>= 24**.
|
|
145
|
+
- **Version-independent model cache** with a cross-process download lock: engine version bumps no longer re-download the model, and concurrent servers on one machine never corrupt a download. Cleaning the npx cache no longer deletes the model.
|
|
146
|
+
- **Embedding provenance + automatic backfill**: every vector records its input hash and model profile; anything missing or stale (including rows written while the model was unavailable) is re-embedded automatically with a per-target retry cap. Fixes a long-standing defect where `deleteObservations` left stale entity vectors behind.
|
|
147
|
+
- **Search state transparency**: responses report `search_mode` (`hybrid` / `hybrid-partial` / `fts-only`), model state, provenance coverage and a `degradation_reason`; `searchNodes` gains a lexical FTS fallback so entities never disappear from search while embeddings catch up. `getKnowledgeGraphStats` gains a `server` block (version, node, states, coverage) for update-reliability checks.
|
|
148
|
+
- **⚠️ BREAKING**: (1) `hybridSearch` now returns an envelope `{results, search_mode, model_state, coverage, degradation_reason?}` instead of a bare array (per-item `search_mode` removed). (2) `deleteObservations` returns `{results: [{entityName, deleted, embedding_status}], total_deleted}` instead of a success string. Error responses now set `isError: true`. Migration/rollback and fleet-rollout guidance: `docs/UPDATING.md`.
|
|
149
|
+
|
|
140
150
|
### v3.5.0
|
|
141
151
|
- **Atomic `syncDocumentFromFile`**: embeddings are computed before any DB write, then applied in a single synchronous transaction, so a failed embedding (e.g. model still loading) leaves the existing document fully intact instead of a half-deleted or partially-embedded state.
|
|
142
152
|
- **`content_hash` dedup**: unchanged files short-circuit the delete/chunk/embed pipeline (`skipped: true`), with a completeness gate that still re-processes a partially-embedded document.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { EmbeddingGate } from './src/embeddingGate.js';
|
|
3
|
+
import type { EmbedPriority } from './src/embeddingGate.js';
|
|
4
|
+
import { BackfillCoordinator } from './src/backfillCoordinator.js';
|
|
5
|
+
export declare function compileFtsLiteralQuery(q: string): string | null;
|
|
2
6
|
interface Entity {
|
|
3
7
|
name: string;
|
|
4
8
|
entityType: string;
|
|
@@ -44,15 +48,28 @@ interface DetailedContext {
|
|
|
44
48
|
export declare class RAGKnowledgeGraphManager {
|
|
45
49
|
private db;
|
|
46
50
|
private encoding;
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
gate: EmbeddingGate;
|
|
52
|
+
embeddingsMode: 'lazy' | 'eager' | 'off';
|
|
53
|
+
currentProfileId: number;
|
|
54
|
+
grandfatherAllowed: boolean;
|
|
55
|
+
coordinator: BackfillCoordinator | null;
|
|
49
56
|
private embeddingCache;
|
|
50
57
|
private readonly EMBEDDING_CACHE_MAX;
|
|
51
58
|
private dictionaryCache;
|
|
52
59
|
initialize(opts?: {
|
|
53
60
|
skipModel?: boolean;
|
|
61
|
+
gate?: EmbeddingGate;
|
|
54
62
|
}): Promise<void>;
|
|
55
|
-
private
|
|
63
|
+
private ensureCurrentProfile;
|
|
64
|
+
private buildRealLoader;
|
|
65
|
+
startReconciliation(): Promise<void>;
|
|
66
|
+
hashWithBuilderVersion(text: string): string;
|
|
67
|
+
entityInputHash(entityId: string): string | null;
|
|
68
|
+
tryEmbedEntity(entityId: string, priority?: EmbedPriority): Promise<'embedded' | 'queued' | 'disabled'>;
|
|
69
|
+
private mutateEntityAndInvalidate;
|
|
70
|
+
invalidateEntityVector(entityId: string): void;
|
|
71
|
+
reembedChunkByRowid(rowid: number): Promise<boolean>;
|
|
72
|
+
shutdownAll(): Promise<void>;
|
|
56
73
|
runMigrations(): Promise<{
|
|
57
74
|
applied: number;
|
|
58
75
|
currentVersion: number;
|
|
@@ -76,7 +93,14 @@ export declare class RAGKnowledgeGraphManager {
|
|
|
76
93
|
deleteObservations(deletions: {
|
|
77
94
|
entityName: string;
|
|
78
95
|
observations: string[];
|
|
79
|
-
}[]): Promise<
|
|
96
|
+
}[]): Promise<{
|
|
97
|
+
results: Array<{
|
|
98
|
+
entityName: string;
|
|
99
|
+
deleted: number;
|
|
100
|
+
embedding_status: 'embedded' | 'queued' | 'disabled' | 'n/a';
|
|
101
|
+
}>;
|
|
102
|
+
total_deleted: number;
|
|
103
|
+
}>;
|
|
80
104
|
deleteRelations(relations: Relation[]): Promise<void>;
|
|
81
105
|
updateRelations(updates: {
|
|
82
106
|
from: string;
|
|
@@ -108,7 +132,17 @@ export declare class RAGKnowledgeGraphManager {
|
|
|
108
132
|
path: string[];
|
|
109
133
|
}>;
|
|
110
134
|
}>;
|
|
111
|
-
searchNodes(query: string, limit?: number, since?: string, until?: string): Promise<KnowledgeGraph
|
|
135
|
+
searchNodes(query: string, limit?: number, since?: string, until?: string): Promise<KnowledgeGraph & {
|
|
136
|
+
search_mode?: string;
|
|
137
|
+
model_state?: string;
|
|
138
|
+
coverage?: {
|
|
139
|
+
entity_pct: number;
|
|
140
|
+
};
|
|
141
|
+
degradation_reason?: string;
|
|
142
|
+
warning?: string;
|
|
143
|
+
}>;
|
|
144
|
+
private searchNodesFts;
|
|
145
|
+
private relationsAmong;
|
|
112
146
|
openNodes(names: string[]): Promise<KnowledgeGraph>;
|
|
113
147
|
private generateEntityEmbeddingText;
|
|
114
148
|
private buildEntityEmbeddingText;
|
|
@@ -267,7 +301,17 @@ export declare class RAGKnowledgeGraphManager {
|
|
|
267
301
|
documents: number;
|
|
268
302
|
};
|
|
269
303
|
}>;
|
|
270
|
-
hybridSearch(query: string, limit?: number, useGraph?: boolean): Promise<
|
|
304
|
+
hybridSearch(query: string, limit?: number, useGraph?: boolean): Promise<{
|
|
305
|
+
results: EnhancedSearchResult[];
|
|
306
|
+
search_mode: 'hybrid' | 'hybrid-partial' | 'fts-only';
|
|
307
|
+
model_state: string;
|
|
308
|
+
coverage: {
|
|
309
|
+
chunk_pct: number;
|
|
310
|
+
graph_coverage_pct: number;
|
|
311
|
+
};
|
|
312
|
+
degradation_reason?: string;
|
|
313
|
+
}>;
|
|
314
|
+
degradationReason(): 'disabled' | 'model_not_ready' | 'reconciling' | 'reconciliation_failed' | undefined;
|
|
271
315
|
getDetailedContext(chunkId: string, includeSurrounding?: boolean): Promise<DetailedContext>;
|
|
272
316
|
getKnowledgeGraphStats(): Promise<any>;
|
|
273
317
|
private _buildGraphologyGraph;
|