rag-memory-epf-mcp 6.4.1 → 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,19 @@ 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
+
157
170
  ### v6.4.1 (2026-10-16)
158
171
 
159
172
  - **Changed — new opt-in manager method `generateRelationEvidenceChunks(items, { formatVersion: 'evidence-v1' })`.**
package/dist/index.d.ts CHANGED
@@ -10,8 +10,12 @@ export declare function makeEmbedFn(model: (input: string, opts: any) => Promise
10
10
  data: any;
11
11
  }>, defaultModel: boolean): (text: string, dims: number, isQuery: boolean) => Promise<Float32Array<ArrayBuffer>>;
12
12
  export declare function compileFtsLiteralQuery(q: string): string | null;
13
+ export declare function setPipelineImpl(fn: ((...args: any[]) => Promise<any>) | null): void;
13
14
  export declare function resolveDbFilePath(envValue: string | undefined, cwd: string, serverDir: string): string;
14
15
  export declare function parseMmapSize(raw: string | undefined): number;
16
+ export declare const MODEL_SESSION_OPTIONS: Readonly<{
17
+ enableCpuMemArena: false;
18
+ }>;
15
19
  interface Entity {
16
20
  name: string;
17
21
  entityType: string;
package/dist/index.js CHANGED
@@ -95,6 +95,12 @@ export function compileFtsLiteralQuery(q) {
95
95
  return null;
96
96
  return terms.map(t => `"${t}"`).join(' OR ');
97
97
  }
98
+ // Test-only seam for the real model loader: replaces `pipeline` so a test can see the exact
99
+ // arguments buildRealLoader passes (same rule as setSyncFaultPoint: an argument, never an env var).
100
+ let __pipelineImpl = pipeline;
101
+ export function setPipelineImpl(fn) {
102
+ __pipelineImpl = (fn ?? pipeline);
103
+ }
98
104
  // Configure Hugging Face transformers for better compatibility
99
105
  if (env.backends?.onnx?.wasm) {
100
106
  env.backends.onnx.wasm.wasmPaths = './node_modules/@huggingface/transformers/dist/';
@@ -142,6 +148,12 @@ const IS_DEFAULT_MODEL_CONFIG = !process.env.EMBEDDING_MODEL || process.env.EMBE
142
148
  // on 'main' (their vectors are never auto-grandfathered anyway).
143
149
  const MODEL_REVISION = IS_DEFAULT_MODEL_CONFIG ? '4de13258303883538bd53b696b452bf8099f0858' : 'main';
144
150
  const MODEL_DTYPE = 'fp16';
151
+ // ONNX session options for the embedding model. The CPU memory arena is off: with it on, one long
152
+ // input (12,000 chars = 5,774 tokens) left the process holding its peak (footprint 1.4 → 8.0 GB,
153
+ // measured 2026-10-31 on transformers 3.8.1 and 4.3.2) and every MCP client runs its own engine.
154
+ // Arena off returned to 1.5-2.4 GB with byte-identical vectors; the cost is per-call allocation
155
+ // (query 29 → 33 ms, 484-token chunk 574 → 639 ms on 4.3.2). Not part of the cache artifact key.
156
+ export const MODEL_SESSION_OPTIONS = Object.freeze({ enableCpuMemArena: false });
145
157
  // Entity embedding text builder version — mixed into entity input hashes so a
146
158
  // builder change re-backfills entities without touching chunk vectors (spec §6c).
147
159
  const TEXT_BUILDER_VERSION = 'tb1';
@@ -387,7 +399,8 @@ export class RAGKnowledgeGraphManager {
387
399
  env.allowRemoteModels = true;
388
400
  env.allowLocalModels = true;
389
401
  console.error(`🤖 Loading embedding model: ${EMBEDDING_MODEL} (1024-dim, cache=${cacheDir})...`);
390
- const model = await pipeline('feature-extraction', EMBEDDING_MODEL, { revision: MODEL_REVISION, dtype: MODEL_DTYPE, cache_dir: cacheDir });
402
+ const model = await __pipelineImpl('feature-extraction', EMBEDDING_MODEL, { revision: MODEL_REVISION, dtype: MODEL_DTYPE, cache_dir: cacheDir,
403
+ session_options: { ...MODEL_SESSION_OPTIONS } });
391
404
  // dims fail-fast (spec §2 / beta B8): probe the ACTUAL output length — a
392
405
  // 384/768-dim custom model must fail here with a clear message, not at
393
406
  // every subsequent vector write.
package/docs/UPDATING.md CHANGED
@@ -108,6 +108,13 @@ path and holder pid (e.g. `.download-<key>.lock`). Verify the holder process
108
108
  is genuinely gone or hung (`ps -p <pid>`), then remove the lock file manually;
109
109
  the next start becomes a clean download owner.
110
110
 
111
+ ## v6.4.2 (schema v14, unchanged): CPU memory arena off, transformers 4.3.2
112
+
113
+ **What changes for an existing database.** Nothing is migrated and nothing is re-embedded (the embedding profile —
114
+ model, revision, dtype, dimensions, pooling, normalize — is unchanged). The model cache is reused as is. What changes
115
+ is the engine process: after a long embedding it returns to about 2-3 GB instead of holding about 8 GB. An engine that
116
+ is already running keeps the old behaviour until it is restarted on 6.4.2. Details: README changelog.
117
+
111
118
  ## v6.4.1 (schema v14, unchanged): evidence-backed relationship chunks (opt-in), KG lifecycle fixes, faster oversize split
112
119
 
113
120
  **What changes for an existing database.** Nothing is migrated and search defaults are unchanged (the 113-query
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rag-memory-epf-mcp",
3
- "version": "6.4.1",
3
+ "version": "6.4.2",
4
4
  "engines": {
5
5
  "node": ">=24"
6
6
  },
@@ -45,12 +45,12 @@
45
45
  "prepare": "npm run build",
46
46
  "watch": "tsc --watch",
47
47
  "verify:invariants": "node test/chunk-invariants.test.mjs",
48
- "verify:engine": "node test/engine-smoke.test.mjs && node test/launch-smoke.test.mjs && node test/sync-atomicity.test.mjs && node test/dedup.test.mjs && node test/search-degradation.test.mjs && node test/entity-embed-cap.test.mjs && node test/migration12.test.mjs && node test/model-cache.test.mjs && node test/embedding-gate.test.mjs && node test/lazy-boot.test.mjs && node test/reconciliation.test.mjs && node test/backfill.test.mjs && node test/fts-query.test.mjs && node test/search-contracts.test.mjs && node test/tool-contracts.test.mjs && node test/bounded-exit.test.mjs && node test/observation-schema.test.mjs && node test/search-graph-default.test.mjs && node test/observation-migration.test.mjs && node test/observation-lifecycle.test.mjs && node test/observation-contracts.test.mjs && node test/observation-search.test.mjs && node test/observation-cascade.test.mjs && node test/observation-realdata.test.mjs && node --no-concurrent-sparkplug test/chunker-c.test.mjs && node test/migration14.test.mjs && node test/chunk-params-validation.test.mjs && node test/vector-reuse.test.mjs && node test/entity-range-linking.test.mjs && node test/alias-link-gate.test.mjs && node test/entity-name-boundary.test.mjs && node test/stats-chunking.test.mjs && node test/migration14-realdata.test.mjs && node test/migration14-realdata-sync.test.mjs && node test/search-summaries-off.test.mjs && node test/search-fusion-rrf.test.mjs && node test/query-input.test.mjs && node test/document-return-contracts.test.mjs && node test/observation-date-prefix.test.mjs && node test/delete-entities-cascade.test.mjs && node test/delete-entities-kg-hygiene.test.mjs && node test/backup-publish-portable.test.mjs && node test/graph-context-explain.test.mjs && node test/eval-graph-role-libs.test.mjs && node test/eval-graph-role-t5b.test.mjs && node --test test/eval-graph-role-t8-fix.test.mjs && node --test test/eval-graph-role-t7-upstream.test.mjs && node --test test/eval-graph-role-t11-decision.test.mjs && node --test test/eval-graph-role-prereq-fix.test.mjs && node test/db-path.test.mjs && node test/mmap-option.test.mjs && node test/wal-exit.test.mjs && node test/wal-sidecar-guard.test.mjs && node test/kg-evidence-core.test.mjs && node test/kg-delete-relation.test.mjs && node test/kg-confidence-copy.test.mjs && node test/kg-embed-cas.test.mjs && node test/kg-relation-evidence.test.mjs && node test/kg-detail-context.test.mjs && node test/kg-evidence-invalidation.test.mjs && node test/kg-evidence-cas.test.mjs && node test/kg-defaults.test.mjs && node test/chunker-oversize-cost.test.mjs && node test/chunker-structure-parity.test.mjs && node test/search-limit-depth.test.mjs && node test/kg-import-id-contract.test.mjs && node test/kg-evidence-guards.test.mjs",
48
+ "verify:engine": "node test/engine-smoke.test.mjs && node test/launch-smoke.test.mjs && node test/sync-atomicity.test.mjs && node test/dedup.test.mjs && node test/search-degradation.test.mjs && node test/entity-embed-cap.test.mjs && node test/migration12.test.mjs && node test/model-cache.test.mjs && node test/embedding-gate.test.mjs && node test/lazy-boot.test.mjs && node test/reconciliation.test.mjs && node test/backfill.test.mjs && node test/fts-query.test.mjs && node test/search-contracts.test.mjs && node test/tool-contracts.test.mjs && node test/bounded-exit.test.mjs && node test/observation-schema.test.mjs && node test/search-graph-default.test.mjs && node test/observation-migration.test.mjs && node test/observation-lifecycle.test.mjs && node test/observation-contracts.test.mjs && node test/observation-search.test.mjs && node test/observation-cascade.test.mjs && node test/observation-realdata.test.mjs && node --no-concurrent-sparkplug test/chunker-c.test.mjs && node test/migration14.test.mjs && node test/chunk-params-validation.test.mjs && node test/vector-reuse.test.mjs && node test/entity-range-linking.test.mjs && node test/alias-link-gate.test.mjs && node test/entity-name-boundary.test.mjs && node test/stats-chunking.test.mjs && node test/migration14-realdata.test.mjs && node test/migration14-realdata-sync.test.mjs && node test/search-summaries-off.test.mjs && node test/search-fusion-rrf.test.mjs && node test/query-input.test.mjs && node test/document-return-contracts.test.mjs && node test/observation-date-prefix.test.mjs && node test/delete-entities-cascade.test.mjs && node test/delete-entities-kg-hygiene.test.mjs && node test/backup-publish-portable.test.mjs && node test/graph-context-explain.test.mjs && node test/eval-graph-role-libs.test.mjs && node test/eval-graph-role-t5b.test.mjs && node --test test/eval-graph-role-t8-fix.test.mjs && node --test test/eval-graph-role-t7-upstream.test.mjs && node --test test/eval-graph-role-t11-decision.test.mjs && node --test test/eval-graph-role-prereq-fix.test.mjs && node test/db-path.test.mjs && node test/mmap-option.test.mjs && node test/wal-exit.test.mjs && node test/wal-sidecar-guard.test.mjs && node test/kg-evidence-core.test.mjs && node test/kg-delete-relation.test.mjs && node test/kg-confidence-copy.test.mjs && node test/kg-embed-cas.test.mjs && node test/kg-relation-evidence.test.mjs && node test/kg-detail-context.test.mjs && node test/kg-evidence-invalidation.test.mjs && node test/kg-evidence-cas.test.mjs && node test/kg-defaults.test.mjs && node test/chunker-oversize-cost.test.mjs && node test/chunker-structure-parity.test.mjs && node test/search-limit-depth.test.mjs && node test/kg-import-id-contract.test.mjs && node test/kg-evidence-guards.test.mjs && node test/model-session-options.test.mjs",
49
49
  "test": "npm run build && npm run verify:invariants && npm run verify:engine",
50
50
  "prepublishOnly": "npm run build && npm run verify:invariants && npm run verify:engine"
51
51
  },
52
52
  "dependencies": {
53
- "@huggingface/transformers": "^3.5.1",
53
+ "@huggingface/transformers": "^4.3.2",
54
54
  "@modelcontextprotocol/sdk": "^1.27.1",
55
55
  "better-sqlite3": "^12.8.0",
56
56
  "graphology": "^0.26.0",