enigma-memory 0.1.13 → 0.1.14
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 +36 -17
- package/apps/cli/bin/enigma.mjs +320 -42
- package/deploy/docker-compose.local-production-simulation.yml +10 -11
- package/docs/benchmark-attestation-network.md +487 -487
- package/docs/benchmark-reproducibility.md +10 -9
- package/docs/demo-proof-network.md +275 -275
- package/docs/developer-ecosystem.md +223 -223
- package/docs/developer-proof-quickstart.md +325 -325
- package/docs/enigma-memory-ready-conformance.md +376 -376
- package/docs/hosted-cloud-product.md +10 -0
- package/docs/install-anywhere.md +34 -17
- package/docs/installers-and-desktop.md +9 -7
- package/docs/proof-network-build-notes.md +240 -240
- package/docs/proof-network.md +257 -257
- package/docs/sdk-api.md +324 -324
- package/docs/solana-devnet-acceptance.md +48 -0
- package/docs/solana-proof-rail.md +453 -453
- package/examples/ci/github-actions.yml +6 -8
- package/package.json +8 -1
- package/packages/mcp-server/src/index.js +1 -1
- package/packages/passport/src/index.js +9 -5
- package/scripts/build-benchmark-proof-release.mjs +391 -0
- package/scripts/build-goal-completion-audit.mjs +11 -5
- package/scripts/build-hosted-api-key-lifecycle.mjs +1 -1
- package/scripts/build-hosted-customer-lifecycle.mjs +1 -1
- package/scripts/build-installer-assets.mjs +126 -10
- package/scripts/build-production-handoff-packet.mjs +7 -6
- package/scripts/build-production-unblocker.mjs +409 -0
- package/scripts/build-proof-network-packet.mjs +1 -1
- package/scripts/release-audit.mjs +71 -2
- package/scripts/run-standard-memory-benchmarks.mjs +1 -1
- package/scripts/wait-for-backend-ready.mjs +4 -2
package/docs/sdk-api.md
CHANGED
|
@@ -1,324 +1,324 @@
|
|
|
1
|
-
# SDK and API guide
|
|
2
|
-
|
|
3
|
-
This guide covers the public package imports for `enigma-memory`. The SDK runs locally by default: vaults, passports, context packs, receipts, relay/gateway demo state, storage contracts, metering artifacts, settlement artifacts, proof-network artifacts, and hosted-cloud contract packets are package-level developer surfaces. They are not evidence of hosted Enigma cloud, live customer API key issuance, provider-side deletion, provider model forgetting, token ROI, invoice savings, compliance certification, benchmark leadership, Solana transaction submission, or on-chain raw memory.
|
|
4
|
-
|
|
5
|
-
## Install and import style
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
npm install enigma-memory
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Requires Node.js `>=24`, matching the package `engines` field.
|
|
12
|
-
|
|
13
|
-
Use ESM imports and explicit subpaths when you know the surface you need:
|
|
14
|
-
|
|
15
|
-
```js
|
|
16
|
-
import { createVault, remember } from 'enigma-memory/vault';
|
|
17
|
-
import { createPassport, compileContextPack } from 'enigma-memory/passport';
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Package exports
|
|
21
|
-
|
|
22
|
-
### `enigma-memory`
|
|
23
|
-
|
|
24
|
-
The package root exports the core proof helpers. Use it for canonical JSON, hashes, signatures, receipt creation, receipt-chain verification, checkpoints, Merkle sets, and deterministic memory addresses.
|
|
25
|
-
|
|
26
|
-
```js
|
|
27
|
-
import { verifyReceiptChain, receiptHash, MerkleSet } from 'enigma-memory';
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### `enigma-memory/vault`
|
|
31
|
-
|
|
32
|
-
The vault module creates local encrypted vault state and proof-carrying exports. Memory text is local input. Full `exportBundle` output can include a local import keyring, so publish only reviewed public summaries, receipt reports, roots, commitments, or keyring-stripped artifacts; do not use vault exports to claim provider-side deletion or model forgetting.
|
|
33
|
-
|
|
34
|
-
```js
|
|
35
|
-
import { createVault, remember, exportBundle, importBundle } from 'enigma-memory/vault';
|
|
36
|
-
|
|
37
|
-
const vault = createVault({ subject_id: 'subject-ref-local-001' });
|
|
38
|
-
const localOnlyMemoryText = String(process.env.ENIGMA_LOCAL_MEMORY_TEXT ?? '');
|
|
39
|
-
const remembered = remember({ vault, text: localOnlyMemoryText });
|
|
40
|
-
const bundle = exportBundle({ vault });
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### `enigma-memory/passport`
|
|
44
|
-
|
|
45
|
-
The passport module describes vault ownership/scope and compiles receipt-backed context packs for authorized local retrieval.
|
|
46
|
-
|
|
47
|
-
```js
|
|
48
|
-
import { createPassport, compileContextPack, verifyContextPack } from 'enigma-memory/passport';
|
|
49
|
-
|
|
50
|
-
const localOnlyQueryText = String(process.env.ENIGMA_LOCAL_QUERY_TEXT ?? '');
|
|
51
|
-
const passport = createPassport({ vault, display_name: 'Public Demo Subject' });
|
|
52
|
-
const pack = compileContextPack({ vault, passport, query: localOnlyQueryText, limit: 1 });
|
|
53
|
-
const checked = verifyContextPack({ contextPack: pack, passport, vault, publicKey: bundle.keyring.publicKey });
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### `enigma-memory/optimizer`
|
|
57
|
-
|
|
58
|
-
The optimizer module builds deterministic, local memory-selection plans and plaintext-minimized access receipts. Token and cost helpers estimate from explicit inputs only; they do not prove ROI or provider invoice savings.
|
|
59
|
-
|
|
60
|
-
```js
|
|
61
|
-
import { createMemoryOptimizationPlan, createMemoryAccessReceipt, estimateTextTokens } from 'enigma-memory/optimizer';
|
|
62
|
-
|
|
63
|
-
const localOnlyCandidateText = String(process.env.ENIGMA_LOCAL_MEMORY_TEXT ?? '');
|
|
64
|
-
const localOnlyQueryText = String(process.env.ENIGMA_LOCAL_QUERY_TEXT ?? '');
|
|
65
|
-
const plan = createMemoryOptimizationPlan({
|
|
66
|
-
candidates: [{ address: 'memory-ref-public-001', content: localOnlyCandidateText }],
|
|
67
|
-
prompt_tokens: estimateTextTokens(localOnlyQueryText),
|
|
68
|
-
});
|
|
69
|
-
const receipt = createMemoryAccessReceipt({ item: plan.items[0], plan });
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### `enigma-memory/connectors`
|
|
73
|
-
|
|
74
|
-
The connectors module renders and manages local MCP client config for supported clients. It uses the `enigma-mcp` command and an `ENIGMA_BUNDLE` environment variable.
|
|
75
|
-
|
|
76
|
-
```js
|
|
77
|
-
import { supportedClients, renderMcpConfig, doctorConnectors } from 'enigma-memory/connectors';
|
|
78
|
-
|
|
79
|
-
const config = renderMcpConfig({ env: { ENIGMA_BUNDLE: './enigma-bundle.json' } });
|
|
80
|
-
const report = await doctorConnectors({ clientId: 'generic-mcp' });
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### `enigma-memory/mcp-server`
|
|
84
|
-
|
|
85
|
-
The MCP server module exposes descriptors, handlers, JSON-RPC handling, and a stdio server for local MCP clients.
|
|
86
|
-
|
|
87
|
-
```js
|
|
88
|
-
import { toolDescriptors, handlers, handleJsonRpcRequest, startStdioServer } from 'enigma-memory/mcp-server';
|
|
89
|
-
|
|
90
|
-
const initTool = toolDescriptors.find((tool) => tool.name === 'enigma_init');
|
|
91
|
-
const reply = await handleJsonRpcRequest({ jsonrpc: '2.0', id: 1, method: 'tools/list' });
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### `enigma-memory/relay`
|
|
95
|
-
|
|
96
|
-
The relay module exposes a local relay witness service API and demo state helpers. Local relay state is useful for development and review, but it is not hosted-cloud durability evidence.
|
|
97
|
-
|
|
98
|
-
```js
|
|
99
|
-
import { createRelayState, createRelayServer, runRelayDemo } from 'enigma-memory/relay';
|
|
100
|
-
|
|
101
|
-
const state = createRelayState({ role: 'relay_witness' });
|
|
102
|
-
const server = createRelayServer({ state });
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### `enigma-memory/gateway`
|
|
106
|
-
|
|
107
|
-
The gateway module exposes a local policy gateway service API and demo state helpers. Local gateway decisions are package/source evidence unless deployed and operated with production storage, monitoring, secrets, and incident-response controls.
|
|
108
|
-
|
|
109
|
-
```js
|
|
110
|
-
import { createGatewayState, handleGatewayRequest, runGatewayDemo } from 'enigma-memory/gateway';
|
|
111
|
-
|
|
112
|
-
const state = createGatewayState({ gateway_id: 'local-gateway' });
|
|
113
|
-
const demo = runGatewayDemo();
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### `enigma-memory/storage`
|
|
117
|
-
|
|
118
|
-
The storage module emits PostgreSQL migration and operation contracts for production storage. It is a contract/builder surface; applying migrations requires your own reviewed database environment.
|
|
119
|
-
|
|
120
|
-
```js
|
|
121
|
-
import { productionStorageContract, buildPostgresMigration, buildRelayRecordUpsert } from 'enigma-memory/storage';
|
|
122
|
-
|
|
123
|
-
const contract = productionStorageContract({ schema: 'enigma' });
|
|
124
|
-
const migration = buildPostgresMigration({ schema: 'enigma' });
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### `enigma-memory/metering`
|
|
128
|
-
|
|
129
|
-
The metering module creates content-minimized usage events and deterministic aggregates. Inputs are explicit counts and metadata; outputs do not prove provider discounts or ROI.
|
|
130
|
-
|
|
131
|
-
```js
|
|
132
|
-
import { createUsageEvent, aggregateUsageEvents } from 'enigma-memory/metering';
|
|
133
|
-
|
|
134
|
-
const event = createUsageEvent({
|
|
135
|
-
tenant_id: 'subject-ref-public-001',
|
|
136
|
-
provider: 'local',
|
|
137
|
-
model: 'demo-model',
|
|
138
|
-
prompt_tokens: 800,
|
|
139
|
-
completion_tokens: 120,
|
|
140
|
-
memory_baseline_tokens: 1200,
|
|
141
|
-
memory_optimized_tokens: 800,
|
|
142
|
-
});
|
|
143
|
-
const aggregate = aggregateUsageEvents({ events: [event] });
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### `enigma-memory/settlement`
|
|
147
|
-
|
|
148
|
-
The settlement module creates hash-only memory jobs, capacity profiles, quotes, service receipts, receipt verification, and batches for permissionless access/accountability boundaries. It does not decentralize raw memory storage or inference.
|
|
149
|
-
|
|
150
|
-
```js
|
|
151
|
-
import { createPermissionlessMemoryJob, createOperatorServiceQuote, createServiceSettlementReceipt, verifyServiceSettlementReceipt } from 'enigma-memory/settlement';
|
|
152
|
-
|
|
153
|
-
const job = createPermissionlessMemoryJob({
|
|
154
|
-
tenant_id: 'subject-ref-public-001',
|
|
155
|
-
job_type: 'context.pack',
|
|
156
|
-
memory_commitment_root: 'sha256:0000000000000000000000000000000000000000000000000000000000000000',
|
|
157
|
-
policy_hash: 'sha256:1111111111111111111111111111111111111111111111111111111111111111',
|
|
158
|
-
usage_event_hash: 'sha256:2222222222222222222222222222222222222222222222222222222222222222',
|
|
159
|
-
requested_at: '2026-01-01T00:00:00.000Z',
|
|
160
|
-
expires_at: '2026-01-02T00:00:00.000Z',
|
|
161
|
-
max_price_amount: 10,
|
|
162
|
-
payment_asset: 'CREDITS',
|
|
163
|
-
});
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### `enigma-memory/proof-network`
|
|
167
|
-
|
|
168
|
-
The proof-network module creates public-safe proof artifacts for AI-memory uniqueness: Solana-ready anchor batches, scoped capability grants/revocations, benchmark attestations, and proof packets. These functions are pure local builders and validators. They never submit transactions, write files, call Solana RPC, call external providers, or make raw memory public.
|
|
169
|
-
|
|
170
|
-
Proof-network artifacts must contain only hashes, roots, opaque refs, counts, timestamps, and signatures. Do not include raw memory, prompts, transcripts, completions, embeddings, ACL bodies, tenant names, private keys, API keys, seed phrases, provider responses, or dataset rows. Anchor batches should explicitly preserve the boundary that no transaction was submitted and no raw memory goes on-chain:
|
|
171
|
-
|
|
172
|
-
Claim boundaries:
|
|
173
|
-
|
|
174
|
-
- `transaction_submitted:false` means the artifact is a local Solana-ready plan, not a submitted or finalized transaction.
|
|
175
|
-
- `raw_memory_on_chain:false` means chain payloads carry only opaque hashes/roots/refs, never raw memory or private context.
|
|
176
|
-
- `provider_deletion_claim:false`, `model_forgetting_claim:false`, and `hosted_saas_claim:false` mean proof-network packets are SDK artifacts, not provider deletion evidence, model-forgetting evidence, hosted-service evidence, compliance certification, or benchmark leadership claims.
|
|
177
|
-
|
|
178
|
-
```js
|
|
179
|
-
import {
|
|
180
|
-
createProofNetworkAnchorBatch,
|
|
181
|
-
validateProofNetworkAnchorBatch,
|
|
182
|
-
} from 'enigma-memory/proof-network';
|
|
183
|
-
|
|
184
|
-
const anchorBatch = createProofNetworkAnchorBatch({
|
|
185
|
-
anchor_ref: 'anchor:local-plan-001',
|
|
186
|
-
commitments: [
|
|
187
|
-
{
|
|
188
|
-
kind: 'memory.root',
|
|
189
|
-
root: 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
|
190
|
-
ref: 'memory-root-ref-001',
|
|
191
|
-
count: 1,
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
kind: 'receipt.root',
|
|
195
|
-
root: 'sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
|
|
196
|
-
ref: 'receipt-root-ref-001',
|
|
197
|
-
count: 1,
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
kind: 'policy.root',
|
|
201
|
-
root: 'sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc',
|
|
202
|
-
ref: 'policy-root-ref-001',
|
|
203
|
-
count: 1,
|
|
204
|
-
},
|
|
205
|
-
],
|
|
206
|
-
transaction_submitted: false,
|
|
207
|
-
raw_memory_on_chain: false,
|
|
208
|
-
});
|
|
209
|
-
const anchorBatchValid = validateProofNetworkAnchorBatch(anchorBatch);
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
Capability grants are scoped permission artifacts. They are not live auth changes, account creation, delegated custody, provider access, or proof that a downstream system enforced the grant:
|
|
213
|
-
|
|
214
|
-
```js
|
|
215
|
-
import {
|
|
216
|
-
createCapabilityGrant,
|
|
217
|
-
validateCapabilityGrant,
|
|
218
|
-
} from 'enigma-memory/proof-network';
|
|
219
|
-
|
|
220
|
-
const grant = createCapabilityGrant({
|
|
221
|
-
issuer_ref: 'issuer-ref-public',
|
|
222
|
-
subject_ref: 'subject-ref-public',
|
|
223
|
-
capability: 'memory.read.receipt-summary',
|
|
224
|
-
resource_roots: ['sha256:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'],
|
|
225
|
-
max_uses: 1,
|
|
226
|
-
issued_at: '2026-01-01T00:00:00.000Z',
|
|
227
|
-
expires_at: '2026-01-02T00:00:00.000Z',
|
|
228
|
-
});
|
|
229
|
-
const grantValid = validateCapabilityGrant(grant);
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
Benchmark attestations bind public report hashes and reproducibility refs. They do not prove benchmark leadership, third-party certification, provider-side behavior, model forgetting, or private dataset contents:
|
|
233
|
-
|
|
234
|
-
```js
|
|
235
|
-
import {
|
|
236
|
-
createBenchmarkAttestation,
|
|
237
|
-
validateBenchmarkAttestation,
|
|
238
|
-
} from 'enigma-memory/proof-network';
|
|
239
|
-
|
|
240
|
-
const attestation = createBenchmarkAttestation({
|
|
241
|
-
report_hash: 'sha256:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
|
|
242
|
-
dataset_ref: 'dataset-ref-public',
|
|
243
|
-
runner_ref: 'runner-ref-public',
|
|
244
|
-
package_ref: 'npm:enigma-memory@0.1.
|
|
245
|
-
metric_roots: ['sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'],
|
|
246
|
-
sample_count: 120,
|
|
247
|
-
run_count: 1,
|
|
248
|
-
attested_at: '2026-01-01T00:00:00.000Z',
|
|
249
|
-
});
|
|
250
|
-
const attestationValid = validateBenchmarkAttestation(attestation);
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
Proof packets wrap one or more supported proof-network artifacts for local verification. Packet verification checks supported artifact structure and privacy boundaries; it is not chain finality, settlement, provider deletion evidence, customer deployment evidence, or a compliance certificate:
|
|
254
|
-
|
|
255
|
-
```js
|
|
256
|
-
import {
|
|
257
|
-
createProofNetworkAnchorBatch as createPacketAnchorBatch,
|
|
258
|
-
createProofNetworkPacket,
|
|
259
|
-
validateProofNetworkPacket,
|
|
260
|
-
} from 'enigma-memory/proof-network';
|
|
261
|
-
|
|
262
|
-
const anchorBatchForPacket = createPacketAnchorBatch({
|
|
263
|
-
anchor_ref: 'anchor:packet-demo',
|
|
264
|
-
commitments: [
|
|
265
|
-
{
|
|
266
|
-
kind: 'memory.root',
|
|
267
|
-
root: 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
|
268
|
-
ref: 'memory-root-ref-001',
|
|
269
|
-
count: 1,
|
|
270
|
-
},
|
|
271
|
-
],
|
|
272
|
-
transaction_submitted: false,
|
|
273
|
-
raw_memory_on_chain: false,
|
|
274
|
-
});
|
|
275
|
-
const packet = createProofNetworkPacket({
|
|
276
|
-
packet_ref: 'packet-ref-public',
|
|
277
|
-
artifacts: [anchorBatchForPacket],
|
|
278
|
-
});
|
|
279
|
-
const packetValid = validateProofNetworkPacket(packet);
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### `enigma-memory/hosted-cloud`
|
|
283
|
-
|
|
284
|
-
The hosted-cloud module emits public-safe contract/readiness evidence only. Customer API key lifecycle packets model issue, rotate, revoke, and audit readiness with evidence refs, opaque subject refs, fingerprints, missing-evidence refs, readiness status, and operator approval refs. They never contain raw key material, provider payloads, plaintext prompts, raw memory, credentials, ROI claims, provider deletion claims, or model forgetting claims.
|
|
285
|
-
|
|
286
|
-
```js
|
|
287
|
-
import {
|
|
288
|
-
buildApiKeyLifecyclePacket,
|
|
289
|
-
validateApiKeyLifecyclePacket,
|
|
290
|
-
} from 'enigma-memory/hosted-cloud';
|
|
291
|
-
|
|
292
|
-
const packet = buildApiKeyLifecyclePacket({
|
|
293
|
-
tenant_id: 'subject-ref-public-001',
|
|
294
|
-
subject_ref: 'subject-ref-alpha',
|
|
295
|
-
environment: 'production',
|
|
296
|
-
operation: 'audit',
|
|
297
|
-
});
|
|
298
|
-
const valid = validateApiKeyLifecyclePacket(packet);
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
`customer_api_keys_live` stays `false` unless the issue/rotate/revoke/audit evidence refs are complete and an operator approval ref is supplied. Even then, the packet is readiness evidence validation only; it does not issue a key, create a secret, call KMS or auth providers, rotate or revoke a provider credential, or prove provider-side deletion.
|
|
302
|
-
|
|
303
|
-
## Verifying exported proof
|
|
304
|
-
|
|
305
|
-
Package consumers should verify exported bundles through the CLI or MCP verifier rather than importing source-only verifier internals. Treat full bundles as private unless you have reviewed and removed local import key material before sharing:
|
|
306
|
-
|
|
307
|
-
```sh
|
|
308
|
-
enigma verify --bundle enigma-export.json
|
|
309
|
-
enigma-verify enigma-export.json
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
For in-process SDK checks, use exported public keys with core receipt verification:
|
|
313
|
-
|
|
314
|
-
```js
|
|
315
|
-
import { verifyReceiptChain } from 'enigma-memory';
|
|
316
|
-
|
|
317
|
-
const report = verifyReceiptChain({
|
|
318
|
-
receipts: bundle.receipts,
|
|
319
|
-
publicKey: bundle.keyring.publicKey,
|
|
320
|
-
expectedReceiptLogRoot: bundle.vault.receipt_log_root,
|
|
321
|
-
expectedActiveSetRoot: bundle.vault.active_set_root,
|
|
322
|
-
verifyEmbeddedReceiptLogRoot: true,
|
|
323
|
-
});
|
|
324
|
-
```
|
|
1
|
+
# SDK and API guide
|
|
2
|
+
|
|
3
|
+
This guide covers the public package imports for `enigma-memory`. The SDK runs locally by default: vaults, passports, context packs, receipts, relay/gateway demo state, storage contracts, metering artifacts, settlement artifacts, proof-network artifacts, and hosted-cloud contract packets are package-level developer surfaces. They are not evidence of hosted Enigma cloud, live customer API key issuance, provider-side deletion, provider model forgetting, token ROI, invoice savings, compliance certification, benchmark leadership, Solana transaction submission, or on-chain raw memory.
|
|
4
|
+
|
|
5
|
+
## Install and import style
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install enigma-memory
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requires Node.js `>=24`, matching the package `engines` field.
|
|
12
|
+
|
|
13
|
+
Use ESM imports and explicit subpaths when you know the surface you need:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { createVault, remember } from 'enigma-memory/vault';
|
|
17
|
+
import { createPassport, compileContextPack } from 'enigma-memory/passport';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Package exports
|
|
21
|
+
|
|
22
|
+
### `enigma-memory`
|
|
23
|
+
|
|
24
|
+
The package root exports the core proof helpers. Use it for canonical JSON, hashes, signatures, receipt creation, receipt-chain verification, checkpoints, Merkle sets, and deterministic memory addresses.
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import { verifyReceiptChain, receiptHash, MerkleSet } from 'enigma-memory';
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### `enigma-memory/vault`
|
|
31
|
+
|
|
32
|
+
The vault module creates local encrypted vault state and proof-carrying exports. Memory text is local input. Full `exportBundle` output can include a local import keyring, so publish only reviewed public summaries, receipt reports, roots, commitments, or keyring-stripped artifacts; do not use vault exports to claim provider-side deletion or model forgetting.
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
import { createVault, remember, exportBundle, importBundle } from 'enigma-memory/vault';
|
|
36
|
+
|
|
37
|
+
const vault = createVault({ subject_id: 'subject-ref-local-001' });
|
|
38
|
+
const localOnlyMemoryText = String(process.env.ENIGMA_LOCAL_MEMORY_TEXT ?? '');
|
|
39
|
+
const remembered = remember({ vault, text: localOnlyMemoryText });
|
|
40
|
+
const bundle = exportBundle({ vault });
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### `enigma-memory/passport`
|
|
44
|
+
|
|
45
|
+
The passport module describes vault ownership/scope and compiles receipt-backed context packs for authorized local retrieval.
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
import { createPassport, compileContextPack, verifyContextPack } from 'enigma-memory/passport';
|
|
49
|
+
|
|
50
|
+
const localOnlyQueryText = String(process.env.ENIGMA_LOCAL_QUERY_TEXT ?? '');
|
|
51
|
+
const passport = createPassport({ vault, display_name: 'Public Demo Subject' });
|
|
52
|
+
const pack = compileContextPack({ vault, passport, query: localOnlyQueryText, limit: 1 });
|
|
53
|
+
const checked = verifyContextPack({ contextPack: pack, passport, vault, publicKey: bundle.keyring.publicKey });
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### `enigma-memory/optimizer`
|
|
57
|
+
|
|
58
|
+
The optimizer module builds deterministic, local memory-selection plans and plaintext-minimized access receipts. Token and cost helpers estimate from explicit inputs only; they do not prove ROI or provider invoice savings.
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
import { createMemoryOptimizationPlan, createMemoryAccessReceipt, estimateTextTokens } from 'enigma-memory/optimizer';
|
|
62
|
+
|
|
63
|
+
const localOnlyCandidateText = String(process.env.ENIGMA_LOCAL_MEMORY_TEXT ?? '');
|
|
64
|
+
const localOnlyQueryText = String(process.env.ENIGMA_LOCAL_QUERY_TEXT ?? '');
|
|
65
|
+
const plan = createMemoryOptimizationPlan({
|
|
66
|
+
candidates: [{ address: 'memory-ref-public-001', content: localOnlyCandidateText }],
|
|
67
|
+
prompt_tokens: estimateTextTokens(localOnlyQueryText),
|
|
68
|
+
});
|
|
69
|
+
const receipt = createMemoryAccessReceipt({ item: plan.items[0], plan });
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### `enigma-memory/connectors`
|
|
73
|
+
|
|
74
|
+
The connectors module renders and manages local MCP client config for supported clients. It uses the `enigma-mcp` command and an `ENIGMA_BUNDLE` environment variable.
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
import { supportedClients, renderMcpConfig, doctorConnectors } from 'enigma-memory/connectors';
|
|
78
|
+
|
|
79
|
+
const config = renderMcpConfig({ env: { ENIGMA_BUNDLE: './enigma-bundle.json' } });
|
|
80
|
+
const report = await doctorConnectors({ clientId: 'generic-mcp' });
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### `enigma-memory/mcp-server`
|
|
84
|
+
|
|
85
|
+
The MCP server module exposes descriptors, handlers, JSON-RPC handling, and a stdio server for local MCP clients.
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
import { toolDescriptors, handlers, handleJsonRpcRequest, startStdioServer } from 'enigma-memory/mcp-server';
|
|
89
|
+
|
|
90
|
+
const initTool = toolDescriptors.find((tool) => tool.name === 'enigma_init');
|
|
91
|
+
const reply = await handleJsonRpcRequest({ jsonrpc: '2.0', id: 1, method: 'tools/list' });
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### `enigma-memory/relay`
|
|
95
|
+
|
|
96
|
+
The relay module exposes a local relay witness service API and demo state helpers. Local relay state is useful for development and review, but it is not hosted-cloud durability evidence.
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
import { createRelayState, createRelayServer, runRelayDemo } from 'enigma-memory/relay';
|
|
100
|
+
|
|
101
|
+
const state = createRelayState({ role: 'relay_witness' });
|
|
102
|
+
const server = createRelayServer({ state });
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### `enigma-memory/gateway`
|
|
106
|
+
|
|
107
|
+
The gateway module exposes a local policy gateway service API and demo state helpers. Local gateway decisions are package/source evidence unless deployed and operated with production storage, monitoring, secrets, and incident-response controls.
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
import { createGatewayState, handleGatewayRequest, runGatewayDemo } from 'enigma-memory/gateway';
|
|
111
|
+
|
|
112
|
+
const state = createGatewayState({ gateway_id: 'local-gateway' });
|
|
113
|
+
const demo = runGatewayDemo();
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### `enigma-memory/storage`
|
|
117
|
+
|
|
118
|
+
The storage module emits PostgreSQL migration and operation contracts for production storage. It is a contract/builder surface; applying migrations requires your own reviewed database environment.
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
import { productionStorageContract, buildPostgresMigration, buildRelayRecordUpsert } from 'enigma-memory/storage';
|
|
122
|
+
|
|
123
|
+
const contract = productionStorageContract({ schema: 'enigma' });
|
|
124
|
+
const migration = buildPostgresMigration({ schema: 'enigma' });
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### `enigma-memory/metering`
|
|
128
|
+
|
|
129
|
+
The metering module creates content-minimized usage events and deterministic aggregates. Inputs are explicit counts and metadata; outputs do not prove provider discounts or ROI.
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
import { createUsageEvent, aggregateUsageEvents } from 'enigma-memory/metering';
|
|
133
|
+
|
|
134
|
+
const event = createUsageEvent({
|
|
135
|
+
tenant_id: 'subject-ref-public-001',
|
|
136
|
+
provider: 'local',
|
|
137
|
+
model: 'demo-model',
|
|
138
|
+
prompt_tokens: 800,
|
|
139
|
+
completion_tokens: 120,
|
|
140
|
+
memory_baseline_tokens: 1200,
|
|
141
|
+
memory_optimized_tokens: 800,
|
|
142
|
+
});
|
|
143
|
+
const aggregate = aggregateUsageEvents({ events: [event] });
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### `enigma-memory/settlement`
|
|
147
|
+
|
|
148
|
+
The settlement module creates hash-only memory jobs, capacity profiles, quotes, service receipts, receipt verification, and batches for permissionless access/accountability boundaries. It does not decentralize raw memory storage or inference.
|
|
149
|
+
|
|
150
|
+
```js
|
|
151
|
+
import { createPermissionlessMemoryJob, createOperatorServiceQuote, createServiceSettlementReceipt, verifyServiceSettlementReceipt } from 'enigma-memory/settlement';
|
|
152
|
+
|
|
153
|
+
const job = createPermissionlessMemoryJob({
|
|
154
|
+
tenant_id: 'subject-ref-public-001',
|
|
155
|
+
job_type: 'context.pack',
|
|
156
|
+
memory_commitment_root: 'sha256:0000000000000000000000000000000000000000000000000000000000000000',
|
|
157
|
+
policy_hash: 'sha256:1111111111111111111111111111111111111111111111111111111111111111',
|
|
158
|
+
usage_event_hash: 'sha256:2222222222222222222222222222222222222222222222222222222222222222',
|
|
159
|
+
requested_at: '2026-01-01T00:00:00.000Z',
|
|
160
|
+
expires_at: '2026-01-02T00:00:00.000Z',
|
|
161
|
+
max_price_amount: 10,
|
|
162
|
+
payment_asset: 'CREDITS',
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### `enigma-memory/proof-network`
|
|
167
|
+
|
|
168
|
+
The proof-network module creates public-safe proof artifacts for AI-memory uniqueness: Solana-ready anchor batches, scoped capability grants/revocations, benchmark attestations, and proof packets. These functions are pure local builders and validators. They never submit transactions, write files, call Solana RPC, call external providers, or make raw memory public.
|
|
169
|
+
|
|
170
|
+
Proof-network artifacts must contain only hashes, roots, opaque refs, counts, timestamps, and signatures. Do not include raw memory, prompts, transcripts, completions, embeddings, ACL bodies, tenant names, private keys, API keys, seed phrases, provider responses, or dataset rows. Anchor batches should explicitly preserve the boundary that no transaction was submitted and no raw memory goes on-chain:
|
|
171
|
+
|
|
172
|
+
Claim boundaries:
|
|
173
|
+
|
|
174
|
+
- `transaction_submitted:false` means the artifact is a local Solana-ready plan, not a submitted or finalized transaction.
|
|
175
|
+
- `raw_memory_on_chain:false` means chain payloads carry only opaque hashes/roots/refs, never raw memory or private context.
|
|
176
|
+
- `provider_deletion_claim:false`, `model_forgetting_claim:false`, and `hosted_saas_claim:false` mean proof-network packets are SDK artifacts, not provider deletion evidence, model-forgetting evidence, hosted-service evidence, compliance certification, or benchmark leadership claims.
|
|
177
|
+
|
|
178
|
+
```js
|
|
179
|
+
import {
|
|
180
|
+
createProofNetworkAnchorBatch,
|
|
181
|
+
validateProofNetworkAnchorBatch,
|
|
182
|
+
} from 'enigma-memory/proof-network';
|
|
183
|
+
|
|
184
|
+
const anchorBatch = createProofNetworkAnchorBatch({
|
|
185
|
+
anchor_ref: 'anchor:local-plan-001',
|
|
186
|
+
commitments: [
|
|
187
|
+
{
|
|
188
|
+
kind: 'memory.root',
|
|
189
|
+
root: 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
|
190
|
+
ref: 'memory-root-ref-001',
|
|
191
|
+
count: 1,
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
kind: 'receipt.root',
|
|
195
|
+
root: 'sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
|
|
196
|
+
ref: 'receipt-root-ref-001',
|
|
197
|
+
count: 1,
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
kind: 'policy.root',
|
|
201
|
+
root: 'sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc',
|
|
202
|
+
ref: 'policy-root-ref-001',
|
|
203
|
+
count: 1,
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
transaction_submitted: false,
|
|
207
|
+
raw_memory_on_chain: false,
|
|
208
|
+
});
|
|
209
|
+
const anchorBatchValid = validateProofNetworkAnchorBatch(anchorBatch);
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Capability grants are scoped permission artifacts. They are not live auth changes, account creation, delegated custody, provider access, or proof that a downstream system enforced the grant:
|
|
213
|
+
|
|
214
|
+
```js
|
|
215
|
+
import {
|
|
216
|
+
createCapabilityGrant,
|
|
217
|
+
validateCapabilityGrant,
|
|
218
|
+
} from 'enigma-memory/proof-network';
|
|
219
|
+
|
|
220
|
+
const grant = createCapabilityGrant({
|
|
221
|
+
issuer_ref: 'issuer-ref-public',
|
|
222
|
+
subject_ref: 'subject-ref-public',
|
|
223
|
+
capability: 'memory.read.receipt-summary',
|
|
224
|
+
resource_roots: ['sha256:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'],
|
|
225
|
+
max_uses: 1,
|
|
226
|
+
issued_at: '2026-01-01T00:00:00.000Z',
|
|
227
|
+
expires_at: '2026-01-02T00:00:00.000Z',
|
|
228
|
+
});
|
|
229
|
+
const grantValid = validateCapabilityGrant(grant);
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Benchmark attestations bind public report hashes and reproducibility refs. They do not prove benchmark leadership, third-party certification, provider-side behavior, model forgetting, or private dataset contents:
|
|
233
|
+
|
|
234
|
+
```js
|
|
235
|
+
import {
|
|
236
|
+
createBenchmarkAttestation,
|
|
237
|
+
validateBenchmarkAttestation,
|
|
238
|
+
} from 'enigma-memory/proof-network';
|
|
239
|
+
|
|
240
|
+
const attestation = createBenchmarkAttestation({
|
|
241
|
+
report_hash: 'sha256:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
|
|
242
|
+
dataset_ref: 'dataset-ref-public',
|
|
243
|
+
runner_ref: 'runner-ref-public',
|
|
244
|
+
package_ref: 'npm:enigma-memory@0.1.14',
|
|
245
|
+
metric_roots: ['sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'],
|
|
246
|
+
sample_count: 120,
|
|
247
|
+
run_count: 1,
|
|
248
|
+
attested_at: '2026-01-01T00:00:00.000Z',
|
|
249
|
+
});
|
|
250
|
+
const attestationValid = validateBenchmarkAttestation(attestation);
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Proof packets wrap one or more supported proof-network artifacts for local verification. Packet verification checks supported artifact structure and privacy boundaries; it is not chain finality, settlement, provider deletion evidence, customer deployment evidence, or a compliance certificate:
|
|
254
|
+
|
|
255
|
+
```js
|
|
256
|
+
import {
|
|
257
|
+
createProofNetworkAnchorBatch as createPacketAnchorBatch,
|
|
258
|
+
createProofNetworkPacket,
|
|
259
|
+
validateProofNetworkPacket,
|
|
260
|
+
} from 'enigma-memory/proof-network';
|
|
261
|
+
|
|
262
|
+
const anchorBatchForPacket = createPacketAnchorBatch({
|
|
263
|
+
anchor_ref: 'anchor:packet-demo',
|
|
264
|
+
commitments: [
|
|
265
|
+
{
|
|
266
|
+
kind: 'memory.root',
|
|
267
|
+
root: 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
|
268
|
+
ref: 'memory-root-ref-001',
|
|
269
|
+
count: 1,
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
transaction_submitted: false,
|
|
273
|
+
raw_memory_on_chain: false,
|
|
274
|
+
});
|
|
275
|
+
const packet = createProofNetworkPacket({
|
|
276
|
+
packet_ref: 'packet-ref-public',
|
|
277
|
+
artifacts: [anchorBatchForPacket],
|
|
278
|
+
});
|
|
279
|
+
const packetValid = validateProofNetworkPacket(packet);
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### `enigma-memory/hosted-cloud`
|
|
283
|
+
|
|
284
|
+
The hosted-cloud module emits public-safe contract/readiness evidence only. Customer API key lifecycle packets model issue, rotate, revoke, and audit readiness with evidence refs, opaque subject refs, fingerprints, missing-evidence refs, readiness status, and operator approval refs. They never contain raw key material, provider payloads, plaintext prompts, raw memory, credentials, ROI claims, provider deletion claims, or model forgetting claims.
|
|
285
|
+
|
|
286
|
+
```js
|
|
287
|
+
import {
|
|
288
|
+
buildApiKeyLifecyclePacket,
|
|
289
|
+
validateApiKeyLifecyclePacket,
|
|
290
|
+
} from 'enigma-memory/hosted-cloud';
|
|
291
|
+
|
|
292
|
+
const packet = buildApiKeyLifecyclePacket({
|
|
293
|
+
tenant_id: 'subject-ref-public-001',
|
|
294
|
+
subject_ref: 'subject-ref-alpha',
|
|
295
|
+
environment: 'production',
|
|
296
|
+
operation: 'audit',
|
|
297
|
+
});
|
|
298
|
+
const valid = validateApiKeyLifecyclePacket(packet);
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
`customer_api_keys_live` stays `false` unless the issue/rotate/revoke/audit evidence refs are complete and an operator approval ref is supplied. Even then, the packet is readiness evidence validation only; it does not issue a key, create a secret, call KMS or auth providers, rotate or revoke a provider credential, or prove provider-side deletion.
|
|
302
|
+
|
|
303
|
+
## Verifying exported proof
|
|
304
|
+
|
|
305
|
+
Package consumers should verify exported bundles through the CLI or MCP verifier rather than importing source-only verifier internals. Treat full bundles as private unless you have reviewed and removed local import key material before sharing:
|
|
306
|
+
|
|
307
|
+
```sh
|
|
308
|
+
enigma verify --bundle enigma-export.json
|
|
309
|
+
enigma-verify enigma-export.json
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
For in-process SDK checks, use exported public keys with core receipt verification:
|
|
313
|
+
|
|
314
|
+
```js
|
|
315
|
+
import { verifyReceiptChain } from 'enigma-memory';
|
|
316
|
+
|
|
317
|
+
const report = verifyReceiptChain({
|
|
318
|
+
receipts: bundle.receipts,
|
|
319
|
+
publicKey: bundle.keyring.publicKey,
|
|
320
|
+
expectedReceiptLogRoot: bundle.vault.receipt_log_root,
|
|
321
|
+
expectedActiveSetRoot: bundle.vault.active_set_root,
|
|
322
|
+
verifyEmbeddedReceiptLogRoot: true,
|
|
323
|
+
});
|
|
324
|
+
```
|