rag-memory-epf-mcp 6.4.0 → 6.4.2

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 CHANGED
@@ -154,6 +154,61 @@ storeDocument(id, content, metadata)
154
154
 
155
155
  ## Changelog
156
156
 
157
+ ### v6.4.2 (2026-10-31)
158
+
159
+ - **Fixed — the engine no longer keeps the peak memory of its largest embedding.** The ONNX session is opened with
160
+ the CPU memory arena off. With it on, one long input (12,000 characters, 5,774 tokens) left the process at about
161
+ 8 GB until it exited (1.4 GB after model load), and every MCP client runs its own engine. With it off the same
162
+ input left 1.5-2.4 GB in a probe and 2.7-3.2 GB in the full engine (one Mac, one run each). Vectors are
163
+ byte-identical with the arena on and off. The transient peak while a long input is being embedded is not lowered.
164
+ - **Changed — `@huggingface/transformers` 4.3.2** (was `^3.5.1`; onnxruntime-node 1.30.0). The model cache layout is
165
+ unchanged and an existing cache loads without a re-download. Vectors differ from 3.x only in the last bits (cosine
166
+ 0.9999995 or higher on 5 inputs); the embedding profile is unchanged, so nothing is re-embedded. Measured on one
167
+ Mac: a 30-character query 128 ms -> 33 ms, a 484-token chunk 739 ms -> 639 ms (3.8.1 with the arena on vs 4.3.2
168
+ with it off). Not measured: fixed-query ranking of existing document vectors against new query vectors, Windows.
169
+
170
+ ### v6.4.1 (2026-10-16)
171
+
172
+ - **Changed — new opt-in manager method `generateRelationEvidenceChunks(items, { formatVersion: 'evidence-v1' })`.**
173
+ `items` is the whole set of relationships that should have a relationship chunk: on success every relationship KG
174
+ chunk is replaced by evidence-backed chunks for that set, built from verified quotes (document chunk codepoint
175
+ ranges) and current active observations; relationships outside the set get no chunk, and entity chunks and
176
+ relationship rows are untouched. Caps: 1–8 evidence entries per item, ≤ 4,000 codepoints per quote, ≤ 8,000
177
+ codepoints of final body — over-cap input rejects the whole call without writes, never truncated. Not exposed over
178
+ MCP and does not change search defaults. The no-argument generator `generateKnowledgeGraphChunks()` keeps the
179
+ previous entity/triplet bodies, IDs, metadata and counts (the lifecycle and atomicity fixes below still apply);
180
+ calling it replaces existing evidence relationship chunks with triplet chunks. "Evidence-backed" means
181
+ caller-selected evidence whose references the engine verified exist verbatim, not an independent proof.
182
+ - **Changed — stale KG chunks leave search immediately.** Deleting a relationship, or changing or removing a cited
183
+ observation or document, removes the KG chunk (vector, FTS row) in the same transaction. No automatic evidence
184
+ regeneration is scheduled; the chunk stays absent until the caller explicitly generates again. A confidence-only
185
+ update refreshes the copied metadata without re-embedding.
186
+ - **Changed — `getDetailedContext` resolves KG chunks.** Entity chunks return the entity and its active observations;
187
+ relationship chunks return the relationship plus `evidence_status` (`claim_only` / `refs_available` /
188
+ `refs_unavailable`) and per-reference `available` / `missing` / `mismatch`, with `document_id: null` and
189
+ `document_title: null` in this branch only. Document detail and all `hybridSearch` fields are unchanged, except that
190
+ `full_context_available` is now `false` for a KG chunk whose entity or relationship row is gone.
191
+ - **Changed — a failed KG replacement leaves the previous snapshot intact; no partial replacement is published. A KG
192
+ embedding computed for an input that changed meanwhile (text, evidence fingerprint or profile) is dropped,** on the
193
+ dedicated path and in background backfill. A profile change before inference starts embeds under the new profile.
194
+ An evidence row whose reference list is empty or malformed is never written back.
195
+ - **Changed — `importGraph` requires string ids for documents and observation sources.** A `documents[i].id` or an
196
+ `observation_sources[i].observation_id` that is not a string (a number, `null`, or missing) rejects the whole import
197
+ before anything is written. Previously such a value was bound as-is: a number such as `7.5` could replace the
198
+ document whose TEXT id is `'7.5'` while the evidence chunks citing it stayed in search.
199
+ - **Fixed — `deleteEntities` refreshes cached coverage** after at least one entity was deleted, so the coverage figures
200
+ and `search_mode` reported by `hybridSearch` and stats reflect the deletion without waiting for another write.
201
+ - **Changed — oversize blocks split faster.** An oversize block that reaches the fallback split is split using a
202
+ verified token-window estimate, with the previous linear scan kept when no candidate verifies (C6 numbers: framework
203
+ receipts `raw/measurements/2026-10-16-kg-relation-evidence/C6-BENCH.md`, one synthetic input per size on one Mac,
204
+ Node 24.12.0 — not a guarantee for every input). Inputs that never reach this fallback keep their previous
205
+ boundaries. The chunking signature now says `fallback=cp-window-N`; documents stamped `cp-exact-N` stay current
206
+ format. A signature change alone does not re-chunk an unchanged document that still has chunk metadata (missing
207
+ vectors are re-queued without re-chunking; if no chunks remain, the normal path runs).
208
+ - **Documented — `limit` sets both the maximum result count and the retrieval depth** (each query variant requests up
209
+ to `limit × 3` vector and up to `limit × 3` FTS candidates, then merged), so results for different limits can
210
+ differ. No algorithm change.
211
+
157
212
  ### v6.4.0 (2026-10-03)
158
213
 
159
214
  - (Published first as `6.4.0-rc.1` on the `next` dist-tag; promoted to `latest` after a canary of the published
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { type SourceInput } from './src/observations/lifecycle.js';
3
+ import { EVIDENCE_FORMAT, type EvidenceItemInput, type EvidenceStatus, type EvidenceRefStatus, type EvidenceChunkMetadataV1 } from './src/kg/relation-evidence.js';
3
4
  import { EmbeddingGate } from './src/embeddingGate.js';
4
5
  import type { EmbedPriority } from './src/embeddingGate.js';
5
6
  import { BackfillCoordinator } from './src/backfillCoordinator.js';
@@ -9,8 +10,12 @@ export declare function makeEmbedFn(model: (input: string, opts: any) => Promise
9
10
  data: any;
10
11
  }>, defaultModel: boolean): (text: string, dims: number, isQuery: boolean) => Promise<Float32Array<ArrayBuffer>>;
11
12
  export declare function compileFtsLiteralQuery(q: string): string | null;
13
+ export declare function setPipelineImpl(fn: ((...args: any[]) => Promise<any>) | null): void;
12
14
  export declare function resolveDbFilePath(envValue: string | undefined, cwd: string, serverDir: string): string;
13
15
  export declare function parseMmapSize(raw: string | undefined): number;
16
+ export declare const MODEL_SESSION_OPTIONS: Readonly<{
17
+ enableCpuMemArena: false;
18
+ }>;
14
19
  interface Entity {
15
20
  name: string;
16
21
  entityType: string;
@@ -40,7 +45,7 @@ interface EnhancedSearchResult {
40
45
  source_id?: string;
41
46
  search_mode?: 'hybrid' | 'fts-only';
42
47
  }
43
- interface DetailedContext {
48
+ interface DocumentDetailedContext {
44
49
  chunk_id: string;
45
50
  document_id: string;
46
51
  full_text: string;
@@ -53,11 +58,49 @@ interface DetailedContext {
53
58
  entities: string[];
54
59
  metadata: Record<string, any>;
55
60
  }
61
+ interface KgDetailedContextBase {
62
+ chunk_id: string;
63
+ document_id: null;
64
+ document_title: null;
65
+ source_kind: 'entity' | 'relationship';
66
+ source_id: string;
67
+ full_text: string;
68
+ entities: string[];
69
+ metadata: Record<string, any>;
70
+ }
71
+ interface EntityDetailedContext extends KgDetailedContextBase {
72
+ source_kind: 'entity';
73
+ entity: {
74
+ name: string;
75
+ entityType: string;
76
+ observations: Array<{
77
+ observation_id: string;
78
+ revision_no: number;
79
+ content: string;
80
+ }>;
81
+ };
82
+ }
83
+ interface RelationshipDetailedContext extends KgDetailedContextBase {
84
+ source_kind: 'relationship';
85
+ relationship: {
86
+ id: string;
87
+ source: string;
88
+ target: string;
89
+ relationType: string;
90
+ confidence: number;
91
+ };
92
+ evidence_status: EvidenceStatus;
93
+ evidence_refs: EvidenceRefStatus[];
94
+ support: EvidenceChunkMetadataV1['support'] | null;
95
+ }
96
+ type KgDetailedContext = EntityDetailedContext | RelationshipDetailedContext;
97
+ type DetailedContext = DocumentDetailedContext | KgDetailedContext;
56
98
  export declare class SyncCasConflictError extends Error {
57
99
  constructor(documentId: string);
58
100
  }
59
101
  export declare function isIoError(e: unknown): boolean;
60
102
  export declare function setSyncFaultPoint(point: string | null, fn: (() => void) | null): void;
103
+ export declare function setKgFaultPoint(point: string | null, fn: (() => void) | null): void;
61
104
  export interface ReuseCandidate {
62
105
  rowid: number;
63
106
  text: string;
@@ -98,6 +141,7 @@ export declare class RAGKnowledgeGraphManager {
98
141
  private mutateEntityAndInvalidate;
99
142
  private invalidateDerivedForEntity;
100
143
  invalidateEntityVector(entityId: string): void;
144
+ private writeKgVectorIfCurrent;
101
145
  reembedChunkByRowid(rowid: number): Promise<boolean>;
102
146
  shutdownAll(): Promise<void>;
103
147
  runMigrations(): Promise<{
@@ -244,11 +288,19 @@ export declare class RAGKnowledgeGraphManager {
244
288
  embedKnowledgeGraphChunks(): Promise<{
245
289
  embeddedChunks: number;
246
290
  totalChunks: number;
291
+ discardedChunks?: number;
247
292
  errors?: string[];
248
293
  }>;
294
+ generateRelationEvidenceChunks(items: EvidenceItemInput[], options: {
295
+ formatVersion: typeof EVIDENCE_FORMAT;
296
+ }): Promise<{
297
+ relationshipChunks: number;
298
+ removedRelationshipChunks: number;
299
+ formatVersion: typeof EVIDENCE_FORMAT;
300
+ }>;
249
301
  private generateEntityChunkText;
250
302
  private generateRelationshipChunkText;
251
- private cleanupKnowledgeGraphChunks;
303
+ private deleteAllKgChunks;
252
304
  private loadDictionary;
253
305
  private hasKorean;
254
306
  private isLikelyEnglish;
@@ -462,6 +514,7 @@ export declare class RAGKnowledgeGraphManager {
462
514
  }>;
463
515
  degradationReason(): 'disabled' | 'model_not_ready' | 'reconciling' | 'reconciliation_failed' | undefined;
464
516
  getDetailedContext(chunkId: string, includeSurrounding?: boolean): Promise<DetailedContext>;
517
+ private getKgDetailedContext;
465
518
  getKnowledgeGraphStats(): Promise<any>;
466
519
  private _buildGraphologyGraph;
467
520
  getGraphMetrics(entityNames?: string[], metrics?: string[], limit?: number): Promise<any>;