enigma-memory 0.1.1 → 0.1.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/apps/browser-extension/manifest.json +41 -0
- package/apps/browser-extension/src/background.js +88 -0
- package/apps/browser-extension/src/content-script.js +602 -0
- package/apps/browser-extension/src/native-bridge.js +289 -0
- package/apps/cli/bin/enigma.mjs +209 -2
- package/apps/desktop/src/tray.js +231 -0
- package/docs/browser-extension-install.md +169 -0
- package/docs/developer-ecosystem.md +74 -0
- package/docs/hosted-cloud-product.md +68 -0
- package/docs/installers-and-desktop.md +76 -0
- package/docs/memory-benchmarks.md +51 -0
- package/docs/sdk-api.md +181 -0
- package/examples/ci/github-actions.yml +63 -0
- package/examples/node-basic-memory.mjs +84 -0
- package/package.json +20 -1
- package/packages/connectors/src/index.js +274 -39
- package/packages/hosted-cloud/src/index.js +538 -0
- package/packages/mcp-server/src/index.js +1 -1
- package/scripts/build-installer-assets.mjs +273 -0
- package/scripts/package-browser-extension.mjs +473 -0
- package/scripts/run-memory-benchmarks.mjs +585 -0
- package/scripts/verify-registry-install.mjs +6 -1
- package/templates/mcp-client-config.json +10 -0
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { dirname, isAbsolute, resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { createHash } from 'node:crypto';
|
|
6
|
+
import { performance } from 'node:perf_hooks';
|
|
7
|
+
import {
|
|
8
|
+
createVault,
|
|
9
|
+
remember,
|
|
10
|
+
updateMemory,
|
|
11
|
+
exportBundle,
|
|
12
|
+
importBundle,
|
|
13
|
+
} from '../packages/vault/src/index.js';
|
|
14
|
+
import {
|
|
15
|
+
createPassport,
|
|
16
|
+
compileContextPack,
|
|
17
|
+
verifyContextPack,
|
|
18
|
+
} from '../packages/passport/src/index.js';
|
|
19
|
+
import { createMemoryOptimizationPlan } from '../packages/optimizer/src/index.js';
|
|
20
|
+
import { verifyBundle } from '../apps/verifier/bin/enigma-verify.mjs';
|
|
21
|
+
|
|
22
|
+
export const MEMORY_BENCHMARK_SUITE_SCHEMA = 'enigma.memory_benchmark_suite.v1';
|
|
23
|
+
|
|
24
|
+
const FIXED_NOW = '2026-06-25T00:00:00.000Z';
|
|
25
|
+
const FIXED_VAULT_KEY = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=';
|
|
26
|
+
const FIXED_ADDRESS_KEY = 'AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=';
|
|
27
|
+
const CONTEXT_BOUNDARY = Object.freeze({
|
|
28
|
+
optimize: true,
|
|
29
|
+
max_estimated_tokens: 512,
|
|
30
|
+
purpose: 'memory_benchmark_context_pack',
|
|
31
|
+
price_per_million_tokens: 0,
|
|
32
|
+
currency: 'USD',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const PROVIDER_PROFILES = Object.freeze(['chatgpt', 'claude', 'kimi', 'cursor', 'local-llm']);
|
|
36
|
+
|
|
37
|
+
const BENCHMARK_CITATIONS = Object.freeze([
|
|
38
|
+
{
|
|
39
|
+
id: 'locomo',
|
|
40
|
+
title: 'LoCoMo long-term conversational memory benchmark',
|
|
41
|
+
url: 'https://snap-research.github.io/locomo/',
|
|
42
|
+
boundary: 'LoCoMo evaluates long-term conversational memory QA, event summarization, and multimodal generation over long multi-session conversations; this local harness is only a deterministic Enigma operations fixture.',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'longmemeval',
|
|
46
|
+
title: 'LongMemEval',
|
|
47
|
+
url: 'https://arxiv.org/abs/2410.10813',
|
|
48
|
+
boundary: 'LongMemEval covers information extraction, multi-session reasoning, temporal reasoning, knowledge updates, and abstention; this harness mirrors those task types without downloading external datasets.',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'letta-memory-benchmarks',
|
|
52
|
+
title: 'Letta memory benchmark boundary note',
|
|
53
|
+
url: 'https://www.letta.com/blog/benchmarking-ai-agent-memory/',
|
|
54
|
+
boundary: 'Agent memory benchmark claims depend on framework, tools, and agent behavior as well as the memory store; this report measures local Enigma package operations only.',
|
|
55
|
+
},
|
|
56
|
+
]);
|
|
57
|
+
|
|
58
|
+
const PRIVATE_FIXTURE = Object.freeze({
|
|
59
|
+
sessions: [
|
|
60
|
+
{
|
|
61
|
+
session_id: 'session_001',
|
|
62
|
+
at: '2026-06-20T09:00:00.000Z',
|
|
63
|
+
events: [
|
|
64
|
+
{
|
|
65
|
+
op: 'remember',
|
|
66
|
+
memory_id: 'fact_accent',
|
|
67
|
+
kind: 'preference',
|
|
68
|
+
content: 'User preference record: canonical dashboard accent color is ember orange.',
|
|
69
|
+
tags: ['profile', 'ui'],
|
|
70
|
+
importance: 0.98,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
op: 'remember',
|
|
74
|
+
memory_id: 'fact_region',
|
|
75
|
+
kind: 'fact',
|
|
76
|
+
content: 'Project handoff record: default hosted smoke-test region is eu-west-3.',
|
|
77
|
+
tags: ['project', 'deployment'],
|
|
78
|
+
importance: 0.9,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
session_id: 'session_002',
|
|
84
|
+
at: '2026-06-21T10:00:00.000Z',
|
|
85
|
+
events: [
|
|
86
|
+
{
|
|
87
|
+
op: 'remember',
|
|
88
|
+
memory_id: 'fact_pager',
|
|
89
|
+
kind: 'fact',
|
|
90
|
+
content: 'Support routing record: pager owner is Iris until 2026-06-23.',
|
|
91
|
+
tags: ['support', 'temporal'],
|
|
92
|
+
importance: 0.75,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
op: 'remember',
|
|
96
|
+
memory_id: 'fact_keynote',
|
|
97
|
+
kind: 'fact',
|
|
98
|
+
content: 'Conference schedule record: keynote moved from 09:00 to 11:30 on Friday.',
|
|
99
|
+
tags: ['schedule', 'temporal'],
|
|
100
|
+
importance: 0.8,
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
session_id: 'session_003',
|
|
106
|
+
at: '2026-06-24T15:30:00.000Z',
|
|
107
|
+
events: [
|
|
108
|
+
{
|
|
109
|
+
op: 'update',
|
|
110
|
+
memory_id: 'fact_pager',
|
|
111
|
+
content: 'Support routing record: pager owner is Rowan starting 2026-06-24.',
|
|
112
|
+
reason: 'benchmark_knowledge_update',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
op: 'remember',
|
|
116
|
+
memory_id: 'fact_region_duplicate',
|
|
117
|
+
kind: 'fact',
|
|
118
|
+
content: 'Project handoff record: default hosted smoke-test region is eu-west-3.',
|
|
119
|
+
tags: ['project', 'deployment', 'duplicate'],
|
|
120
|
+
importance: 0.2,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
op: 'remember',
|
|
124
|
+
memory_id: 'fact_archive',
|
|
125
|
+
kind: 'fact',
|
|
126
|
+
content: 'Private archive marker: the legacy codename is glass-raven.',
|
|
127
|
+
tags: ['archive'],
|
|
128
|
+
importance: 0.35,
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
questions: [
|
|
134
|
+
{
|
|
135
|
+
id: 'q_exact_preference',
|
|
136
|
+
category: 'exact_answer',
|
|
137
|
+
query: 'Which dashboard accent color should the assistant use?',
|
|
138
|
+
expected: 'ember orange',
|
|
139
|
+
matcher: /accent color is ([^.]+)\./iu,
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
id: 'q_exact_region',
|
|
143
|
+
category: 'exact_answer',
|
|
144
|
+
query: 'Which hosted smoke-test region is the current default?',
|
|
145
|
+
expected: 'eu-west-3',
|
|
146
|
+
matcher: /region is ([^.]+)\./iu,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
id: 'q_temporal_update',
|
|
150
|
+
category: 'temporal_update',
|
|
151
|
+
query: 'Who owns the pager after the latest support routing update?',
|
|
152
|
+
expected: 'Rowan',
|
|
153
|
+
matcher: /pager owner is ([A-Za-z-]+) starting/iu,
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: 'q_temporal_event',
|
|
157
|
+
category: 'temporal_reasoning',
|
|
158
|
+
query: 'What is the revised keynote time?',
|
|
159
|
+
expected: '11:30',
|
|
160
|
+
matcher: /moved from 09:00 to ([0-9:]+) on Friday/iu,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
id: 'q_abstain_phone',
|
|
164
|
+
category: 'abstention',
|
|
165
|
+
query: 'What phone number should billing use?',
|
|
166
|
+
expected: null,
|
|
167
|
+
matcher: null,
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
function parseArgs(argv = process.argv.slice(2)) {
|
|
173
|
+
const flags = new Map();
|
|
174
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
175
|
+
const arg = argv[index];
|
|
176
|
+
if (!arg.startsWith('--')) continue;
|
|
177
|
+
const eq = arg.indexOf('=');
|
|
178
|
+
if (eq !== -1) {
|
|
179
|
+
flags.set(arg.slice(2, eq), arg.slice(eq + 1));
|
|
180
|
+
} else if (!argv[index + 1] || argv[index + 1].startsWith('--')) {
|
|
181
|
+
flags.set(arg.slice(2), true);
|
|
182
|
+
} else {
|
|
183
|
+
flags.set(arg.slice(2), argv[index + 1]);
|
|
184
|
+
index += 1;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return flags;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function getFlag(flags, names, fallback = undefined) {
|
|
191
|
+
for (const name of names) if (flags.has(name)) return flags.get(name);
|
|
192
|
+
return fallback;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function sha256(value) {
|
|
196
|
+
return createHash('sha256').update(String(value)).digest('hex');
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function commitment(value) {
|
|
200
|
+
return `sha256:${sha256(value)}`;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function publicFixtureSummary() {
|
|
204
|
+
const events = PRIVATE_FIXTURE.sessions.flatMap((session) => session.events);
|
|
205
|
+
return {
|
|
206
|
+
name: 'enigma.local_multi_session_memory_fixture.v1',
|
|
207
|
+
session_count: PRIVATE_FIXTURE.sessions.length,
|
|
208
|
+
private_event_count: events.length,
|
|
209
|
+
question_count: PRIVATE_FIXTURE.questions.length,
|
|
210
|
+
has_facts: true,
|
|
211
|
+
has_updates: events.some((event) => event.op === 'update'),
|
|
212
|
+
has_temporal_questions: PRIVATE_FIXTURE.questions.some((question) => question.category.includes('temporal')),
|
|
213
|
+
has_abstention_questions: PRIVATE_FIXTURE.questions.some((question) => question.category === 'abstention'),
|
|
214
|
+
has_duplicate_candidates: true,
|
|
215
|
+
cross_provider_profiles: [...PROVIDER_PROFILES],
|
|
216
|
+
raw_private_memory_plaintext_included: false,
|
|
217
|
+
fixture_commitment: commitment(JSON.stringify({
|
|
218
|
+
session_count: PRIVATE_FIXTURE.sessions.length,
|
|
219
|
+
event_count: events.length,
|
|
220
|
+
question_count: PRIVATE_FIXTURE.questions.length,
|
|
221
|
+
})),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function timed(samples, name, fn) {
|
|
226
|
+
const start = performance.now();
|
|
227
|
+
const value = fn();
|
|
228
|
+
const elapsed = performance.now() - start;
|
|
229
|
+
samples[name].push(Math.max(0, elapsed));
|
|
230
|
+
return value;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function percentile(values, ratio) {
|
|
234
|
+
if (values.length === 0) return 0;
|
|
235
|
+
const sorted = [...values].sort((left, right) => left - right);
|
|
236
|
+
const index = Math.min(sorted.length - 1, Math.max(0, Math.ceil(sorted.length * ratio) - 1));
|
|
237
|
+
return sorted[index];
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function latencySummary(samples) {
|
|
241
|
+
const out = {};
|
|
242
|
+
for (const [operation, values] of Object.entries(samples)) {
|
|
243
|
+
out[operation] = {
|
|
244
|
+
samples: values.length,
|
|
245
|
+
p50_ms: Number(percentile(values, 0.5).toFixed(6)),
|
|
246
|
+
p95_ms: Number(percentile(values, 0.95).toFixed(6)),
|
|
247
|
+
min_ms: Number((values.length ? Math.min(...values) : 0).toFixed(6)),
|
|
248
|
+
max_ms: Number((values.length ? Math.max(...values) : 0).toFixed(6)),
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
return out;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function makeSamples() {
|
|
255
|
+
return {
|
|
256
|
+
remember: [],
|
|
257
|
+
import: [],
|
|
258
|
+
context: [],
|
|
259
|
+
export: [],
|
|
260
|
+
verify: [],
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function applyFixtureToVault(vault, samples) {
|
|
265
|
+
const byMemoryId = new Map();
|
|
266
|
+
for (const session of PRIVATE_FIXTURE.sessions) {
|
|
267
|
+
for (const event of session.events) {
|
|
268
|
+
if (event.op === 'remember') {
|
|
269
|
+
const result = timed(samples, 'remember', () => remember({
|
|
270
|
+
vault,
|
|
271
|
+
memory_id: event.memory_id,
|
|
272
|
+
kind: event.kind,
|
|
273
|
+
content: event.content,
|
|
274
|
+
purpose_tags: event.tags,
|
|
275
|
+
confidence: 'benchmark_fixture',
|
|
276
|
+
metadata: {
|
|
277
|
+
benchmark_session_id: session.session_id,
|
|
278
|
+
benchmark_event_kind: event.kind,
|
|
279
|
+
benchmark_importance: event.importance,
|
|
280
|
+
private_fixture_commitment: commitment(event.content),
|
|
281
|
+
},
|
|
282
|
+
source_refs: [{ source_hash: commitment(`${session.session_id}:${event.memory_id}`) }],
|
|
283
|
+
now: session.at,
|
|
284
|
+
}));
|
|
285
|
+
byMemoryId.set(event.memory_id, result.memory_addr);
|
|
286
|
+
} else if (event.op === 'update') {
|
|
287
|
+
const oldAddress = byMemoryId.get(event.memory_id);
|
|
288
|
+
if (!oldAddress) throw new Error(`fixture update references unknown memory_id ${event.memory_id}`);
|
|
289
|
+
const result = timed(samples, 'remember', () => updateMemory({
|
|
290
|
+
vault,
|
|
291
|
+
memory_addr: oldAddress,
|
|
292
|
+
content: event.content,
|
|
293
|
+
reason: event.reason,
|
|
294
|
+
now: session.at,
|
|
295
|
+
}));
|
|
296
|
+
byMemoryId.set(event.memory_id, result.memory_addr);
|
|
297
|
+
} else {
|
|
298
|
+
throw new Error(`unsupported fixture operation ${event.op}`);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return byMemoryId;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function packOptions(profile, overrides = {}) {
|
|
306
|
+
return {
|
|
307
|
+
...CONTEXT_BOUNDARY,
|
|
308
|
+
...overrides,
|
|
309
|
+
provider: profile,
|
|
310
|
+
model: `${profile}-benchmark-profile`,
|
|
311
|
+
now: FIXED_NOW,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function chooseAnswer(question, pack) {
|
|
316
|
+
if (question.expected === null) return { answer: null, abstained: true, correct: true };
|
|
317
|
+
for (const memory of pack.memories ?? []) {
|
|
318
|
+
const content = typeof memory.content === 'string' ? memory.content : '';
|
|
319
|
+
const match = question.matcher?.exec(content);
|
|
320
|
+
if (match?.[1]) {
|
|
321
|
+
const answer = match[1].trim();
|
|
322
|
+
return { answer, abstained: false, correct: answer === question.expected };
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return { answer: null, abstained: true, correct: false };
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function scoreQuestions(vault, passport, samples) {
|
|
329
|
+
let exactTotal = 0;
|
|
330
|
+
let exactCorrect = 0;
|
|
331
|
+
let abstainTotal = 0;
|
|
332
|
+
let abstainCorrect = 0;
|
|
333
|
+
const byCategory = new Map();
|
|
334
|
+
let firstOptimizationPlan = null;
|
|
335
|
+
|
|
336
|
+
for (const question of PRIVATE_FIXTURE.questions) {
|
|
337
|
+
const pack = timed(samples, 'context', () => compileContextPack({
|
|
338
|
+
vault,
|
|
339
|
+
passport,
|
|
340
|
+
query: question.query,
|
|
341
|
+
context_pack_id: `ctx_benchmark_${question.id}`,
|
|
342
|
+
...packOptions('local-llm'),
|
|
343
|
+
}));
|
|
344
|
+
if (firstOptimizationPlan === null) firstOptimizationPlan = pack.optimization_plan;
|
|
345
|
+
const result = chooseAnswer(question, pack);
|
|
346
|
+
const current = byCategory.get(question.category) ?? { total: 0, correct: 0 };
|
|
347
|
+
current.total += 1;
|
|
348
|
+
if (result.correct) current.correct += 1;
|
|
349
|
+
byCategory.set(question.category, current);
|
|
350
|
+
if (question.category === 'abstention') {
|
|
351
|
+
abstainTotal += 1;
|
|
352
|
+
if (result.abstained && result.correct) abstainCorrect += 1;
|
|
353
|
+
} else {
|
|
354
|
+
exactTotal += 1;
|
|
355
|
+
if (!result.abstained && result.correct) exactCorrect += 1;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return {
|
|
360
|
+
firstOptimizationPlan,
|
|
361
|
+
qa: {
|
|
362
|
+
question_count: PRIVATE_FIXTURE.questions.length,
|
|
363
|
+
exact_answer_questions: exactTotal,
|
|
364
|
+
exact_answer_correct: exactCorrect,
|
|
365
|
+
exact_answer_recall: exactTotal === 0 ? 0 : Number((exactCorrect / exactTotal).toFixed(6)),
|
|
366
|
+
abstention_questions: abstainTotal,
|
|
367
|
+
abstention_correct: abstainCorrect,
|
|
368
|
+
abstention_correctness: abstainTotal === 0 ? 0 : Number((abstainCorrect / abstainTotal).toFixed(6)),
|
|
369
|
+
by_category: Object.fromEntries([...byCategory.entries()].map(([category, value]) => [category, {
|
|
370
|
+
total: value.total,
|
|
371
|
+
correct: value.correct,
|
|
372
|
+
accuracy: Number((value.correct / value.total).toFixed(6)),
|
|
373
|
+
}])),
|
|
374
|
+
public_question_text_included: false,
|
|
375
|
+
public_answer_text_included: false,
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function activeOptimizationPlan(vault, query) {
|
|
381
|
+
const candidates = [];
|
|
382
|
+
for (const memoryAddr of vault.activeAddresses ?? []) {
|
|
383
|
+
const record = vault.__getRecord(memoryAddr);
|
|
384
|
+
if (!record || record.state !== 'active') continue;
|
|
385
|
+
candidates.push({
|
|
386
|
+
address: memoryAddr,
|
|
387
|
+
content: vault.__getPlaintext(memoryAddr),
|
|
388
|
+
importance: typeof record.metadata?.benchmark_importance === 'number' ? record.metadata.benchmark_importance : undefined,
|
|
389
|
+
last_accessed_at: record.updated_at ?? record.created_at,
|
|
390
|
+
metadata: {
|
|
391
|
+
kind: record.kind,
|
|
392
|
+
sensitivity: record.sensitivity,
|
|
393
|
+
purpose_tags: record.purpose_tags ?? [],
|
|
394
|
+
},
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
return createMemoryOptimizationPlan({
|
|
398
|
+
candidates,
|
|
399
|
+
prompt: query,
|
|
400
|
+
now: FIXED_NOW,
|
|
401
|
+
price_per_million_tokens: 0,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function summarizeContextReduction(plan) {
|
|
406
|
+
const baseline = plan?.baseline_prompt_tokens ?? 0;
|
|
407
|
+
const optimized = plan?.optimized_prompt_tokens ?? 0;
|
|
408
|
+
return {
|
|
409
|
+
full_context_baseline_tokens: baseline,
|
|
410
|
+
enigma_context_pack_tokens: optimized,
|
|
411
|
+
token_delta: baseline - optimized,
|
|
412
|
+
reduction_pct: baseline === 0 ? 0 : Number((((baseline - optimized) / baseline) * 100).toFixed(6)),
|
|
413
|
+
estimator: 'estimateTextTokens deterministic local estimator',
|
|
414
|
+
provider_invoice_savings_claim: false,
|
|
415
|
+
roi_claim: false,
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function compareProviders(vault, passport, samples) {
|
|
420
|
+
const rows = [];
|
|
421
|
+
const query = 'Use the benchmark memory boundary for a cross-provider profile comparison.';
|
|
422
|
+
const fullPlan = activeOptimizationPlan(vault, query);
|
|
423
|
+
for (const profile of PROVIDER_PROFILES) {
|
|
424
|
+
const pack = timed(samples, 'context', () => compileContextPack({
|
|
425
|
+
vault,
|
|
426
|
+
passport,
|
|
427
|
+
query,
|
|
428
|
+
context_pack_id: `ctx_benchmark_profile_${profile.replace(/[^a-z0-9]+/gu, '_')}`,
|
|
429
|
+
...packOptions(profile),
|
|
430
|
+
}));
|
|
431
|
+
rows.push({
|
|
432
|
+
profile,
|
|
433
|
+
provider_runtime_observed: false,
|
|
434
|
+
external_provider_called: false,
|
|
435
|
+
same_enigma_context_pack_boundary: true,
|
|
436
|
+
boundary: {
|
|
437
|
+
optimize: CONTEXT_BOUNDARY.optimize,
|
|
438
|
+
max_estimated_tokens: CONTEXT_BOUNDARY.max_estimated_tokens,
|
|
439
|
+
purpose: CONTEXT_BOUNDARY.purpose,
|
|
440
|
+
},
|
|
441
|
+
memory_count: pack.memory_addresses.length,
|
|
442
|
+
retrieval_receipt_count: pack.retrieval_receipts.length,
|
|
443
|
+
injection_receipt_count: pack.injection_receipts.length,
|
|
444
|
+
baseline_prompt_tokens: fullPlan.baseline_prompt_tokens,
|
|
445
|
+
optimized_prompt_tokens: fullPlan.optimized_prompt_tokens,
|
|
446
|
+
duplicate_candidates_removed: fullPlan.totals.duplicates_removed,
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
return rows;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function verifyContextPackPublic(vault, passport, pack) {
|
|
453
|
+
const publicKey = vault.signingKeyPair?.publicKey;
|
|
454
|
+
return verifyContextPack({ contextPack: pack, vault, passport, publicKey });
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function assertNoRawFixtureLeak(report) {
|
|
458
|
+
const serialized = JSON.stringify(report);
|
|
459
|
+
for (const session of PRIVATE_FIXTURE.sessions) {
|
|
460
|
+
for (const event of session.events) {
|
|
461
|
+
const secret = event.content;
|
|
462
|
+
if (serialized.includes(secret)) throw new Error('benchmark report leaked raw fixture memory text');
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
for (const needle of ['ember orange', 'eu-west-3', 'Iris', 'Rowan', '11:30', 'glass-raven']) {
|
|
466
|
+
if (serialized.includes(needle)) throw new Error(`benchmark report leaked private fixture token: ${needle}`);
|
|
467
|
+
}
|
|
468
|
+
return report;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export function runMemoryBenchmarkSuite(options = {}) {
|
|
472
|
+
const generatedAt = options.generated_at ?? options.generatedAt ?? new Date().toISOString();
|
|
473
|
+
const samples = makeSamples();
|
|
474
|
+
const vault = createVault({
|
|
475
|
+
vault_id: 'vault_memory_benchmark_fixture',
|
|
476
|
+
tenant_id: 'benchmark-local',
|
|
477
|
+
subject_id: 'benchmark-subject',
|
|
478
|
+
actor_id: 'benchmark-runner',
|
|
479
|
+
policy_id: 'benchmark-local-policy',
|
|
480
|
+
vault_key: FIXED_VAULT_KEY,
|
|
481
|
+
address_key: FIXED_ADDRESS_KEY,
|
|
482
|
+
now: '2026-06-20T08:00:00.000Z',
|
|
483
|
+
});
|
|
484
|
+
applyFixtureToVault(vault, samples);
|
|
485
|
+
|
|
486
|
+
const exported = timed(samples, 'export', () => exportBundle({ vault, now: generatedAt }));
|
|
487
|
+
const imported = timed(samples, 'import', () => importBundle({ bundle: exported, now: generatedAt }));
|
|
488
|
+
const importedVault = imported.vault;
|
|
489
|
+
const passport = createPassport({ vault: importedVault, now: generatedAt });
|
|
490
|
+
|
|
491
|
+
const scored = scoreQuestions(importedVault, passport, samples);
|
|
492
|
+
const fullOptimizationPlan = activeOptimizationPlan(importedVault, 'Use the benchmark memory boundary for recall and abstention evaluation.');
|
|
493
|
+
const providerRows = compareProviders(importedVault, passport, samples);
|
|
494
|
+
const verificationBundleResults = [];
|
|
495
|
+
for (let index = 0; index < 5; index += 1) {
|
|
496
|
+
verificationBundleResults.push(timed(samples, 'verify', () => verifyBundle(exported)));
|
|
497
|
+
}
|
|
498
|
+
const proofPack = timed(samples, 'context', () => compileContextPack({
|
|
499
|
+
vault: importedVault,
|
|
500
|
+
passport,
|
|
501
|
+
query: 'Verify the benchmark context pack boundary without publishing private memory.',
|
|
502
|
+
context_pack_id: 'ctx_benchmark_verification_boundary',
|
|
503
|
+
...packOptions('local-llm'),
|
|
504
|
+
}));
|
|
505
|
+
const contextVerification = timed(samples, 'verify', () => verifyContextPackPublic(importedVault, passport, proofPack));
|
|
506
|
+
|
|
507
|
+
const report = {
|
|
508
|
+
schema: MEMORY_BENCHMARK_SUITE_SCHEMA,
|
|
509
|
+
generated_at: generatedAt,
|
|
510
|
+
public_safe: true,
|
|
511
|
+
fixture: publicFixtureSummary(),
|
|
512
|
+
benchmark_boundaries: {
|
|
513
|
+
local_only: true,
|
|
514
|
+
credentials_required: false,
|
|
515
|
+
external_downloads_required: false,
|
|
516
|
+
external_provider_calls: false,
|
|
517
|
+
raw_private_memory_plaintext_included: false,
|
|
518
|
+
provider_deletion_claim: false,
|
|
519
|
+
model_forgetting_claim: false,
|
|
520
|
+
roi_or_provider_invoice_savings_claim: false,
|
|
521
|
+
compliance_certification_claim: false,
|
|
522
|
+
benchmark_leadership_claim: false,
|
|
523
|
+
claim_boundary: [
|
|
524
|
+
'This suite measures deterministic local Enigma fixture operations only.',
|
|
525
|
+
'Cross-provider rows use profile labels and the same Enigma context-pack boundary; they do not call or compare live provider models.',
|
|
526
|
+
'Token reduction is a local estimator result against this fixture, not a provider invoice, ROI, guaranteed savings, or benchmark-leadership claim.',
|
|
527
|
+
'Verification proves Enigma-controlled receipts/bundles/context packs only; it is not provider deletion, provider forgetting, model forgetting, or compliance certification evidence.',
|
|
528
|
+
],
|
|
529
|
+
},
|
|
530
|
+
citations: BENCHMARK_CITATIONS,
|
|
531
|
+
operations_measured: {
|
|
532
|
+
vault_remember_or_update: true,
|
|
533
|
+
vault_export: true,
|
|
534
|
+
vault_import: true,
|
|
535
|
+
context_pack_retrieval: true,
|
|
536
|
+
optimizer_plan_token_estimates: true,
|
|
537
|
+
bundle_verification: true,
|
|
538
|
+
context_pack_verification: true,
|
|
539
|
+
latency_clock: 'performance.now',
|
|
540
|
+
},
|
|
541
|
+
metrics: {
|
|
542
|
+
qa: scored.qa,
|
|
543
|
+
context_token_reduction: summarizeContextReduction(fullOptimizationPlan),
|
|
544
|
+
duplicate_removal: {
|
|
545
|
+
input_candidates: fullOptimizationPlan.totals.input_candidates,
|
|
546
|
+
deduped_candidates: fullOptimizationPlan.totals.deduped_candidates,
|
|
547
|
+
duplicate_candidates_removed: fullOptimizationPlan.totals.duplicates_removed,
|
|
548
|
+
},
|
|
549
|
+
latency: latencySummary(samples),
|
|
550
|
+
verification: {
|
|
551
|
+
bundle_verify_runs: verificationBundleResults.length,
|
|
552
|
+
bundle_verify_ok: verificationBundleResults.every((result) => result.ok === true),
|
|
553
|
+
context_pack_verify_valid: contextVerification.valid === true,
|
|
554
|
+
},
|
|
555
|
+
},
|
|
556
|
+
cross_provider_profiles: providerRows,
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
return assertNoRawFixtureLeak(report);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
async function main() {
|
|
563
|
+
const flags = parseArgs();
|
|
564
|
+
const report = runMemoryBenchmarkSuite({
|
|
565
|
+
generated_at: getFlag(flags, ['generated-at', 'generated_at'], undefined),
|
|
566
|
+
});
|
|
567
|
+
const out = getFlag(flags, ['out']);
|
|
568
|
+
if (out && out !== true) {
|
|
569
|
+
const path = resolve(String(out));
|
|
570
|
+
await mkdir(dirname(path), { recursive: true });
|
|
571
|
+
await writeFile(path, `${JSON.stringify(report, null, 2)}\n`, 'utf8');
|
|
572
|
+
process.stdout.write(`${JSON.stringify({ ok: true, schema: report.schema, out: isAbsolute(String(out)) ? '<absolute-path-redacted>' : String(out) }, null, 2)}\n`);
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
const invokedPath = process.argv[1] ? resolve(process.argv[1]) : '';
|
|
579
|
+
const modulePath = fileURLToPath(import.meta.url);
|
|
580
|
+
if (invokedPath === modulePath) {
|
|
581
|
+
main().catch((error) => {
|
|
582
|
+
process.stderr.write(`${error.message}\n`);
|
|
583
|
+
process.exitCode = 1;
|
|
584
|
+
});
|
|
585
|
+
}
|
|
@@ -386,6 +386,11 @@ function safeErrorMessage(error) {
|
|
|
386
386
|
return 'Registry install verification failed.';
|
|
387
387
|
}
|
|
388
388
|
|
|
389
|
+
export function registryInstallCliOutput(output) {
|
|
390
|
+
if (output.mode === 'dry-run') return output.commands;
|
|
391
|
+
return output;
|
|
392
|
+
}
|
|
393
|
+
|
|
389
394
|
async function main() {
|
|
390
395
|
const args = parseRegistryInstallArgs();
|
|
391
396
|
if (args.help) {
|
|
@@ -393,7 +398,7 @@ async function main() {
|
|
|
393
398
|
return;
|
|
394
399
|
}
|
|
395
400
|
const output = await runRegistryInstallVerification(args);
|
|
396
|
-
process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
|
|
401
|
+
process.stdout.write(`${JSON.stringify(registryInstallCliOutput(output), null, 2)}\n`);
|
|
397
402
|
if (output.ok !== true) process.exitCode = 1;
|
|
398
403
|
}
|
|
399
404
|
|