rag-memory-epf-mcp 6.4.0 → 6.4.1

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,48 @@ storeDocument(id, content, metadata)
154
154
 
155
155
  ## Changelog
156
156
 
157
+ ### v6.4.1 (2026-10-16)
158
+
159
+ - **Changed — new opt-in manager method `generateRelationEvidenceChunks(items, { formatVersion: 'evidence-v1' })`.**
160
+ `items` is the whole set of relationships that should have a relationship chunk: on success every relationship KG
161
+ chunk is replaced by evidence-backed chunks for that set, built from verified quotes (document chunk codepoint
162
+ ranges) and current active observations; relationships outside the set get no chunk, and entity chunks and
163
+ relationship rows are untouched. Caps: 1–8 evidence entries per item, ≤ 4,000 codepoints per quote, ≤ 8,000
164
+ codepoints of final body — over-cap input rejects the whole call without writes, never truncated. Not exposed over
165
+ MCP and does not change search defaults. The no-argument generator `generateKnowledgeGraphChunks()` keeps the
166
+ previous entity/triplet bodies, IDs, metadata and counts (the lifecycle and atomicity fixes below still apply);
167
+ calling it replaces existing evidence relationship chunks with triplet chunks. "Evidence-backed" means
168
+ caller-selected evidence whose references the engine verified exist verbatim, not an independent proof.
169
+ - **Changed — stale KG chunks leave search immediately.** Deleting a relationship, or changing or removing a cited
170
+ observation or document, removes the KG chunk (vector, FTS row) in the same transaction. No automatic evidence
171
+ regeneration is scheduled; the chunk stays absent until the caller explicitly generates again. A confidence-only
172
+ update refreshes the copied metadata without re-embedding.
173
+ - **Changed — `getDetailedContext` resolves KG chunks.** Entity chunks return the entity and its active observations;
174
+ relationship chunks return the relationship plus `evidence_status` (`claim_only` / `refs_available` /
175
+ `refs_unavailable`) and per-reference `available` / `missing` / `mismatch`, with `document_id: null` and
176
+ `document_title: null` in this branch only. Document detail and all `hybridSearch` fields are unchanged, except that
177
+ `full_context_available` is now `false` for a KG chunk whose entity or relationship row is gone.
178
+ - **Changed — a failed KG replacement leaves the previous snapshot intact; no partial replacement is published. A KG
179
+ embedding computed for an input that changed meanwhile (text, evidence fingerprint or profile) is dropped,** on the
180
+ dedicated path and in background backfill. A profile change before inference starts embeds under the new profile.
181
+ An evidence row whose reference list is empty or malformed is never written back.
182
+ - **Changed — `importGraph` requires string ids for documents and observation sources.** A `documents[i].id` or an
183
+ `observation_sources[i].observation_id` that is not a string (a number, `null`, or missing) rejects the whole import
184
+ before anything is written. Previously such a value was bound as-is: a number such as `7.5` could replace the
185
+ document whose TEXT id is `'7.5'` while the evidence chunks citing it stayed in search.
186
+ - **Fixed — `deleteEntities` refreshes cached coverage** after at least one entity was deleted, so the coverage figures
187
+ and `search_mode` reported by `hybridSearch` and stats reflect the deletion without waiting for another write.
188
+ - **Changed — oversize blocks split faster.** An oversize block that reaches the fallback split is split using a
189
+ verified token-window estimate, with the previous linear scan kept when no candidate verifies (C6 numbers: framework
190
+ receipts `raw/measurements/2026-10-16-kg-relation-evidence/C6-BENCH.md`, one synthetic input per size on one Mac,
191
+ Node 24.12.0 — not a guarantee for every input). Inputs that never reach this fallback keep their previous
192
+ boundaries. The chunking signature now says `fallback=cp-window-N`; documents stamped `cp-exact-N` stay current
193
+ format. A signature change alone does not re-chunk an unchanged document that still has chunk metadata (missing
194
+ vectors are re-queued without re-chunking; if no chunks remain, the normal path runs).
195
+ - **Documented — `limit` sets both the maximum result count and the retrieval depth** (each query variant requests up
196
+ to `limit × 3` vector and up to `limit × 3` FTS candidates, then merged), so results for different limits can
197
+ differ. No algorithm change.
198
+
157
199
  ### v6.4.0 (2026-10-03)
158
200
 
159
201
  - (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';
@@ -40,7 +41,7 @@ interface EnhancedSearchResult {
40
41
  source_id?: string;
41
42
  search_mode?: 'hybrid' | 'fts-only';
42
43
  }
43
- interface DetailedContext {
44
+ interface DocumentDetailedContext {
44
45
  chunk_id: string;
45
46
  document_id: string;
46
47
  full_text: string;
@@ -53,11 +54,49 @@ interface DetailedContext {
53
54
  entities: string[];
54
55
  metadata: Record<string, any>;
55
56
  }
57
+ interface KgDetailedContextBase {
58
+ chunk_id: string;
59
+ document_id: null;
60
+ document_title: null;
61
+ source_kind: 'entity' | 'relationship';
62
+ source_id: string;
63
+ full_text: string;
64
+ entities: string[];
65
+ metadata: Record<string, any>;
66
+ }
67
+ interface EntityDetailedContext extends KgDetailedContextBase {
68
+ source_kind: 'entity';
69
+ entity: {
70
+ name: string;
71
+ entityType: string;
72
+ observations: Array<{
73
+ observation_id: string;
74
+ revision_no: number;
75
+ content: string;
76
+ }>;
77
+ };
78
+ }
79
+ interface RelationshipDetailedContext extends KgDetailedContextBase {
80
+ source_kind: 'relationship';
81
+ relationship: {
82
+ id: string;
83
+ source: string;
84
+ target: string;
85
+ relationType: string;
86
+ confidence: number;
87
+ };
88
+ evidence_status: EvidenceStatus;
89
+ evidence_refs: EvidenceRefStatus[];
90
+ support: EvidenceChunkMetadataV1['support'] | null;
91
+ }
92
+ type KgDetailedContext = EntityDetailedContext | RelationshipDetailedContext;
93
+ type DetailedContext = DocumentDetailedContext | KgDetailedContext;
56
94
  export declare class SyncCasConflictError extends Error {
57
95
  constructor(documentId: string);
58
96
  }
59
97
  export declare function isIoError(e: unknown): boolean;
60
98
  export declare function setSyncFaultPoint(point: string | null, fn: (() => void) | null): void;
99
+ export declare function setKgFaultPoint(point: string | null, fn: (() => void) | null): void;
61
100
  export interface ReuseCandidate {
62
101
  rowid: number;
63
102
  text: string;
@@ -98,6 +137,7 @@ export declare class RAGKnowledgeGraphManager {
98
137
  private mutateEntityAndInvalidate;
99
138
  private invalidateDerivedForEntity;
100
139
  invalidateEntityVector(entityId: string): void;
140
+ private writeKgVectorIfCurrent;
101
141
  reembedChunkByRowid(rowid: number): Promise<boolean>;
102
142
  shutdownAll(): Promise<void>;
103
143
  runMigrations(): Promise<{
@@ -244,11 +284,19 @@ export declare class RAGKnowledgeGraphManager {
244
284
  embedKnowledgeGraphChunks(): Promise<{
245
285
  embeddedChunks: number;
246
286
  totalChunks: number;
287
+ discardedChunks?: number;
247
288
  errors?: string[];
248
289
  }>;
290
+ generateRelationEvidenceChunks(items: EvidenceItemInput[], options: {
291
+ formatVersion: typeof EVIDENCE_FORMAT;
292
+ }): Promise<{
293
+ relationshipChunks: number;
294
+ removedRelationshipChunks: number;
295
+ formatVersion: typeof EVIDENCE_FORMAT;
296
+ }>;
249
297
  private generateEntityChunkText;
250
298
  private generateRelationshipChunkText;
251
- private cleanupKnowledgeGraphChunks;
299
+ private deleteAllKgChunks;
252
300
  private loadDictionary;
253
301
  private hasKorean;
254
302
  private isLikelyEnglish;
@@ -462,6 +510,7 @@ export declare class RAGKnowledgeGraphManager {
462
510
  }>;
463
511
  degradationReason(): 'disabled' | 'model_not_ready' | 'reconciling' | 'reconciliation_failed' | undefined;
464
512
  getDetailedContext(chunkId: string, includeSurrounding?: boolean): Promise<DetailedContext>;
513
+ private getKgDetailedContext;
465
514
  getKnowledgeGraphStats(): Promise<any>;
466
515
  private _buildGraphologyGraph;
467
516
  getGraphMetrics(entityNames?: string[], metrics?: string[], limit?: number): Promise<any>;