enigma-memory 0.1.14 → 0.1.16

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.
Files changed (40) hide show
  1. package/README.md +64 -84
  2. package/apps/cli/bin/enigma.mjs +3151 -3126
  3. package/apps/native-host/README.md +20 -0
  4. package/deploy/SIMULATION.md +34 -38
  5. package/deploy/docker-compose.local-production-simulation.yml +5 -2
  6. package/docs/benchmark-attestation-network.md +2 -2
  7. package/docs/benchmark-reproducibility.md +240 -228
  8. package/docs/browser-extension-install.md +9 -6
  9. package/docs/client-connectors.md +22 -52
  10. package/docs/demo-proof-network.md +3 -3
  11. package/docs/developer-ecosystem.md +205 -223
  12. package/docs/developer-proof-quickstart.md +3 -3
  13. package/docs/enigma-memory-ready-conformance.md +1 -1
  14. package/docs/hosted-cloud-product.md +2 -0
  15. package/docs/install-anywhere.md +61 -66
  16. package/docs/memory-benchmarks.md +6 -3
  17. package/docs/proof-network-build-notes.md +2 -2
  18. package/docs/proof-network.md +32 -7
  19. package/docs/sdk-api.md +1 -1
  20. package/docs/solana-devnet-acceptance.md +1 -1
  21. package/docs/solana-proof-rail.md +1 -1
  22. package/package.json +278 -272
  23. package/packages/connectors/src/index.js +13 -0
  24. package/packages/mcp-server/README.md +22 -0
  25. package/packages/mcp-server/src/index.js +1185 -1185
  26. package/scripts/build-benchmark-proof-release.mjs +106 -5
  27. package/scripts/build-cloudflare-token-policy.mjs +6 -2
  28. package/scripts/build-hosted-api-key-lifecycle.mjs +274 -274
  29. package/scripts/build-hosted-customer-lifecycle.mjs +456 -456
  30. package/scripts/build-installer-assets.mjs +389 -389
  31. package/scripts/build-production-handoff-packet.mjs +1 -1
  32. package/scripts/build-production-unblocker.mjs +409 -409
  33. package/scripts/build-production-workplan.mjs +3 -1
  34. package/scripts/build-proof-network-packet.mjs +213 -213
  35. package/scripts/check.mjs +3 -1
  36. package/scripts/cloudflare-ops.mjs +35 -0
  37. package/scripts/collect-hosted-backend-live-evidence.mjs +44 -2
  38. package/scripts/run-memory-benchmarks.mjs +5 -0
  39. package/scripts/run-standard-memory-benchmarks.mjs +1194 -1070
  40. package/scripts/stage-cloudflare-pages-artifact.mjs +145 -0
@@ -37,6 +37,7 @@ const ALLOWED_FALSE_REPORT_KEYS = new Set([
37
37
  'benchmark_leadership_claim',
38
38
  'external_provider_calls',
39
39
  'llm_answer_accuracy_scored',
40
+ 'credentials_required',
40
41
  'raw_benchmark_body_included',
41
42
  'report_body_copied',
42
43
  'raw_memory_included',
@@ -50,9 +51,41 @@ const ALLOWED_FALSE_REPORT_KEYS = new Set([
50
51
  'provider_invoice_savings_claim',
51
52
  'hosted_saas_claim',
52
53
  ]);
54
+ const ALLOWED_PUBLIC_REPORT_KEYS = new Set([
55
+ 'estimated_prompt_tokens',
56
+ 'baseline_prompt_tokens',
57
+ 'optimized_prompt_tokens',
58
+ ]);
53
59
  const SECRET_VALUE_RE = /(?:Bearer\s+[A-Za-z0-9._~+/=-]{12,}|Basic\s+[A-Za-z0-9+/=-]{12,}|-----BEGIN [A-Z ]*PRIVATE KEY-----|https?:\/\/[^\s/@]+:[^\s/@]+@|sk-[A-Za-z0-9_-]{16,}|AKIA[0-9A-Z]{16}|(?:seed phrase|mnemonic phrase|raw memory|private prompt|full transcript|provider response|embedding vector))/iu;
54
60
  const ABSOLUTE_LOCAL_PATH_RE = /^(?:[A-Za-z]:[\\/]|\\\\|\/(?:Users|home|tmp|var|etc|mnt|Volumes)\b)/u;
55
61
  const CLAIM_SCORE_KEY_RE = /(?:provider|competitor|roi|profit|savings|solana|transaction|answer_accuracy|leaderboard)/iu;
62
+ const PROOF_COMPATIBLE_REPORT_SCHEMAS = new Set([
63
+ 'enigma.memory_benchmark_suite.v1',
64
+ 'enigma.standard_memory_benchmark_suite.v1',
65
+ ]);
66
+ const REQUIRED_FALSE_BOUNDARY_KEYS = Object.freeze([
67
+ 'external_provider_calls',
68
+ 'llm_answer_accuracy_scored',
69
+ 'provider_deletion_claim',
70
+ 'model_forgetting_claim',
71
+ 'roi_or_provider_invoice_savings_claim',
72
+ 'compliance_certification_claim',
73
+ 'benchmark_leadership_claim',
74
+ ]);
75
+ const OPTIONAL_FALSE_BOUNDARY_KEYS = Object.freeze([
76
+ 'provider_answer_accuracy_claim',
77
+ 'competitor_performance_claim',
78
+ 'solana_submission_claim',
79
+ 'transaction_submitted',
80
+ 'roi_or_profit_claim',
81
+ 'provider_invoice_savings_claim',
82
+ 'hosted_saas_claim',
83
+ 'api_calls_made',
84
+ 'provider_api_calls_made',
85
+ 'network_calls_made',
86
+ 'mem0_adapter_run',
87
+ 'external_competitor_adapters_run',
88
+ ]);
56
89
 
57
90
  class UsageError extends Error {
58
91
  constructor(message) {
@@ -139,7 +172,7 @@ export function parseArgs(argv = process.argv.slice(2)) {
139
172
  export function usage() {
140
173
  return `Usage: node scripts/build-benchmark-proof-release.mjs --report <path> --dataset-ref <ref> --runner-ref <ref> --package-ref <ref> [--score key=value ...] [--out-dir <dir>]
141
174
 
142
- Builds a dependency-free, local benchmark proof release from an existing public-safe benchmark report. The report file is parsed for public-safety checks and hashed, but its body and local path are never copied into the attestation or proof packet. The generated artifacts are local benchmark attestation/proof only: no API calls, provider answer-accuracy claims, competitor performance claims, Solana submissions, hosted SaaS claims, ROI/profit/savings claims, raw memory, prompts, transcripts, embeddings, credentials, account ids, private keys, or provider responses are written.
175
+ Builds a dependency-free, local benchmark proof release from an existing public-safe benchmark report. The report must use a compatible benchmark schema and explicit offline benchmark boundaries. The report file is parsed for public-safety checks and hashed, but its body and local path are never copied into the attestation or proof packet. The generated artifacts are local benchmark attestation/proof only: no API calls, provider answer-accuracy claims, Mem0 or competitor performance claims, Solana submissions, hosted SaaS claims, ROI/profit/savings claims, raw memory, prompts, transcripts, embeddings, credentials, account ids, private keys, or provider responses are written.
143
176
  `;
144
177
  }
145
178
 
@@ -172,7 +205,7 @@ function assertPublicReportPayload(value, path = 'report') {
172
205
  }
173
206
  if (!isPlainObject(value)) return;
174
207
  for (const [key, child] of Object.entries(value)) {
175
- if (PRIVATE_REPORT_KEY_RE.test(key)) {
208
+ if (PRIVATE_REPORT_KEY_RE.test(key) && !ALLOWED_PUBLIC_REPORT_KEYS.has(key)) {
176
209
  if (!ALLOWED_FALSE_REPORT_KEYS.has(key) || child !== false) throw new UsageError(`${path}.${key} is not allowed in public benchmark proof artifacts`);
177
210
  }
178
211
  assertPublicReportPayload(child, `${path}.${key}`);
@@ -190,11 +223,62 @@ function parseJsonReport(bytes) {
190
223
  function reportSchema(report) {
191
224
  if (!isPlainObject(report)) throw new UsageError('report must be a JSON object');
192
225
  if (typeof report.schema !== 'string' || report.schema.trim() === '') throw new UsageError('report.schema must be a non-empty string');
226
+ if (!PROOF_COMPATIBLE_REPORT_SCHEMAS.has(report.schema)) throw new UsageError(`report.schema is not proof-release compatible: ${report.schema}`);
193
227
  if (report.public_safe !== true) throw new UsageError('report.public_safe must be true');
194
228
  assertPublicReportPayload(report);
229
+ assertProofCompatibleBenchmarkBoundaries(report);
195
230
  return report.schema;
196
231
  }
197
232
 
233
+ function requireFalseField(row, key, path) {
234
+ if (row[key] !== false) throw new UsageError(`${path}.${key} must be false for a public benchmark proof release`);
235
+ }
236
+
237
+ function assertBoundaryObject(report) {
238
+ if (!isPlainObject(report.benchmark_boundaries)) throw new UsageError('report.benchmark_boundaries must be present for a public benchmark proof release');
239
+ return report.benchmark_boundaries;
240
+ }
241
+
242
+ function assertCommandBoundaries(report) {
243
+ if (report.command_boundaries === undefined) return;
244
+ if (!isPlainObject(report.command_boundaries)) throw new UsageError('report.command_boundaries must be an object when present');
245
+ for (const key of OPTIONAL_FALSE_BOUNDARY_KEYS) {
246
+ if (report.command_boundaries[key] !== undefined && report.command_boundaries[key] !== false) {
247
+ throw new UsageError(`report.command_boundaries.${key} must be false for a public benchmark proof release`);
248
+ }
249
+ }
250
+ if (report.command_boundaries.api_spend_possible !== undefined && report.command_boundaries.api_spend_possible !== false) {
251
+ throw new UsageError('report.command_boundaries.api_spend_possible must be false for a public benchmark proof release');
252
+ }
253
+ }
254
+
255
+ function assertExternalAdaptersUnscored(report) {
256
+ if (!Array.isArray(report.external_competitor_adapters)) return;
257
+ report.external_competitor_adapters.forEach((row, index) => {
258
+ if (!isPlainObject(row)) throw new UsageError(`report.external_competitor_adapters[${index}] must be an object`);
259
+ if (row.scores_included !== false) throw new UsageError(`report.external_competitor_adapters[${index}].scores_included must be false`);
260
+ for (const key of ['recall', 'answer_accuracy', 'latency', 'cost', 'ranking']) {
261
+ if (row[key] !== undefined) throw new UsageError(`report.external_competitor_adapters[${index}].${key} is not allowed without a reviewed adapter run`);
262
+ }
263
+ });
264
+ }
265
+
266
+ function assertProofCompatibleBenchmarkBoundaries(report) {
267
+ const boundaries = assertBoundaryObject(report);
268
+ for (const key of REQUIRED_FALSE_BOUNDARY_KEYS) requireFalseField(boundaries, key, 'report.benchmark_boundaries');
269
+ for (const key of OPTIONAL_FALSE_BOUNDARY_KEYS) {
270
+ if (boundaries[key] !== undefined) requireFalseField(boundaries, key, 'report.benchmark_boundaries');
271
+ }
272
+ if (report.schema === 'enigma.standard_memory_benchmark_suite.v1') {
273
+ if (boundaries.retrieval_evidence_proxy_scored !== true) throw new UsageError('standard benchmark report must set benchmark_boundaries.retrieval_evidence_proxy_scored true');
274
+ }
275
+ if (report.schema === 'enigma.memory_benchmark_suite.v1') {
276
+ if (boundaries.local_only !== true) throw new UsageError('local memory benchmark report must set benchmark_boundaries.local_only true');
277
+ }
278
+ assertCommandBoundaries(report);
279
+ assertExternalAdaptersUnscored(report);
280
+ }
281
+
198
282
  function nonNegativeInteger(value) {
199
283
  return Number.isInteger(value) && value >= 0 ? value : undefined;
200
284
  }
@@ -242,7 +326,7 @@ function assertValidation(validation, label) {
242
326
  if (validation?.ok !== true) throw new Error(`${label} validation failed: ${(validation?.errors ?? ['unknown error']).join('; ')}`);
243
327
  }
244
328
 
245
- function releaseManifest({ generatedAt, reportHash, schema, args, commitments, attestation, packet }) {
329
+ function releaseManifest({ generatedAt, reportHash, schema, sampleCount, datasetCount, args, commitments, attestation, packet }) {
246
330
  const manifest = {
247
331
  schema: BENCHMARK_PROOF_RELEASE_SCHEMA,
248
332
  generated_at: generatedAt,
@@ -254,6 +338,8 @@ function releaseManifest({ generatedAt, reportHash, schema, args, commitments, a
254
338
  report_public_safe: true,
255
339
  report_body_copied: false,
256
340
  report_path_copied: false,
341
+ sample_count: sampleCount,
342
+ dataset_count: datasetCount,
257
343
  },
258
344
  refs: {
259
345
  dataset_ref: args.datasetRef,
@@ -261,6 +347,16 @@ function releaseManifest({ generatedAt, reportHash, schema, args, commitments, a
261
347
  package_ref: args.packageRef,
262
348
  },
263
349
  score_commitments: commitments,
350
+ command_boundaries: {
351
+ deterministic_offline_proof_builder: true,
352
+ report_file_hashed_from_local_disk: true,
353
+ network_calls_made: false,
354
+ provider_api_calls_made: false,
355
+ api_spend_possible: false,
356
+ solana_transaction_submitted: false,
357
+ benchmark_scores_generated: false,
358
+ report_body_copied: false,
359
+ },
264
360
  claim_boundaries: {
265
361
  provider_answer_accuracy_claim: false,
266
362
  competitor_performance_claim: false,
@@ -306,6 +402,8 @@ export async function buildBenchmarkProofRelease(args, options = {}) {
306
402
  const reportHash = sha256Buffer(bytes);
307
403
  const report = parseJsonReport(bytes);
308
404
  const schema = reportSchema(report);
405
+ const sampleCount = sampleCountFromReport(report);
406
+ const datasetCount = Array.isArray(report.datasets) ? report.datasets.length : 0;
309
407
  const commitments = scoreCommitments(args.scores, reportHash);
310
408
  const metricRoots = commitments.map((score) => score.score_hash);
311
409
 
@@ -317,7 +415,7 @@ export async function buildBenchmarkProofRelease(args, options = {}) {
317
415
  package_ref: args.packageRef,
318
416
  report_hash: reportHash,
319
417
  metric_roots: metricRoots,
320
- sample_count: sampleCountFromReport(report),
418
+ sample_count: sampleCount,
321
419
  run_count: 1,
322
420
  });
323
421
  assertValidation(validateBenchmarkAttestation(attestation), 'benchmark attestation');
@@ -329,7 +427,7 @@ export async function buildBenchmarkProofRelease(args, options = {}) {
329
427
  });
330
428
  assertValidation(validateProofNetworkPacket(packet), 'proof packet');
331
429
 
332
- const manifest = releaseManifest({ generatedAt, reportHash, schema, args, commitments, attestation, packet });
430
+ const manifest = releaseManifest({ generatedAt, reportHash, schema, sampleCount, datasetCount, args, commitments, attestation, packet });
333
431
  assertPublicReportPayload(manifest, 'manifest');
334
432
 
335
433
  return Object.freeze({
@@ -377,6 +475,9 @@ export async function main(argv = process.argv.slice(2)) {
377
475
  out_dir: outputLabel(args.outDir),
378
476
  ...files,
379
477
  report_hash: release.report_hash,
478
+ report_schema: release.report_schema,
479
+ sample_count: release.manifest.report.sample_count,
480
+ dataset_count: release.manifest.report.dataset_count,
380
481
  report_body_copied: false,
381
482
  api_calls_made: false,
382
483
  }, null, 2)}\n`);
@@ -167,8 +167,12 @@ export function buildCloudflareTokenPolicy(input = {}) {
167
167
  const domain = optionalText(input.domain, 'enigmamemory.com');
168
168
  const verificationCommands = [
169
169
  'npm run cloudflare:ops -- token verify --account-id <account-id>',
170
- 'npm run cloudflare:pages:packet -- --site ../github-upload/enigma-memory-site/_public_site --project-name enigma-memory --domain enigmamemory.com --live-url https://enigmamemory.com/ --expect-title Enigma',
171
- 'npm run production:handoff -- --site ../github-upload/enigma-memory-site/_public_site --project-name enigma-memory --domain enigmamemory.com --live-url https://enigmamemory.com/ --expect-title Enigma',
170
+ 'npm run cloudflare:pages:stage',
171
+ 'npm run cloudflare:pages:packet -- --site .enigma/cloudflare-pages/enigmamemory.com --project-name enigma-memory --domain enigmamemory.com --live-url https://enigmamemory.com/ --expect-title "Enigma"',
172
+ 'npm run cloudflare:pages:dry-run',
173
+ 'npm run cloudflare:pages:deploy',
174
+ 'npm run cloudflare:ops -- --cloudflare-env-file <local-secret-file> pages verify --url https://enigmamemory.com/ --project-name enigma-memory --domain enigmamemory.com --cloudflare-live required',
175
+ 'npm run production:handoff -- --site .enigma/cloudflare-pages/enigmamemory.com --project-name enigma-memory --domain enigmamemory.com --live-url https://enigmamemory.com/ --expect-title "Enigma"',
172
176
  ];
173
177
  if (includeMode(mode, 'hosted-probe')) {
174
178
  verificationCommands.splice(1, 0, 'npm run cloudflare:ops -- workers inspect-probe --name enigma-hosted-probe');