betterwithage Claude Opus 4.7 commited on
Commit
6ab77f4
·
verified ·
1 Parent(s): 4606670

deploy(hf): sync szl-holdings/a11oy@main derived COPY set

Browse files

Reusable Dockerfile-COPY-derived deploy from szl-holdings/a11oy main.
Files: 899 Pruned: 0
Derived from Dockerfile COPY sources (NO hand-maintained allowlist).

Signed-off-by: SZL Holdings <noreply@szlholdings.ai>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

static/3d/holographic.html CHANGED
@@ -162,6 +162,7 @@ const SURFACES = [
162
  { id: "brain", title: "Formula-Graph Brain", mod: "/static/3d/surfaces/brain.js" },
163
  { id: "zkinfer", title: "zkML Proof-of-Inference (Cryptographic Receipts)", mod: "/static/3d/surfaces/zkinfer.js" },
164
  { id: "flower", title: "Flower Brain", mod: "/static/3d/surfaces/flower.js" },
 
165
  ];
166
 
167
  const stageEl = document.getElementById("stage");
 
162
  { id: "brain", title: "Formula-Graph Brain", mod: "/static/3d/surfaces/brain.js" },
163
  { id: "zkinfer", title: "zkML Proof-of-Inference (Cryptographic Receipts)", mod: "/static/3d/surfaces/zkinfer.js" },
164
  { id: "flower", title: "Flower Brain", mod: "/static/3d/surfaces/flower.js" },
165
+ { id: "agentmem", title: "AgentMem · Λ-Governed Agent Memory (synthesis)", mod: "/static/3d/surfaces/agentmem.js" },
166
  ];
167
 
168
  const stageEl = document.getElementById("stage");
static/3d/surfaces/agentmem.js ADDED
@@ -0,0 +1,463 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11
3
+ //
4
+ // surfaces/agentmem.js — AGENTMEM: Λ-GOVERNED AGENT MEMORY (SZL synthesis) for
5
+ // the holographic frontier ring. Renders a persistent agent-memory store as a
6
+ // disc of memory nodes; a query recalls the top-k, which flow toward a central
7
+ // Λ-GATE. Each recall gets a Λ advisory (Conjecture 1 — gray, NEVER green):
8
+ // admitted recalls glow proof-teal, Λ-gated-out or inconsistent recalls stay
9
+ // grey. The gate core scales with the capped trust (<=0.97). A compact HUD shows
10
+ // the recall/consistency stats and the signed-receipt-per-recall DESIGN (nothing
11
+ // minted on a read). Live snapshot: /api/a11oy/v1/frontier/agentmem.
12
+ //
13
+ // This is an SZL CROSS-AXIS SYNTHESIS no published system ships together:
14
+ // agent memory (MemGPT / A-MEM / Mem0 / DSPy) + Λ-gating (SZL restraint
15
+ // advisory, Λ = Conjecture 1) + the signed receipt chain (receipt-per-recall).
16
+ //
17
+ // Surface export shape (mirrors titans.js / specdecode.js exactly):
18
+ // export default { id, title, endpoints, mount(ctx), unmount() }
19
+ // ctx = { stage, container, live, label, THREE, szl3d }
20
+ //
21
+ // LEADERS ADOPTED & CITED (clean-room; NOT claimed as SZL's own):
22
+ // MemGPT: Towards LLMs as Operating Systems — Packer et al. 2023,
23
+ // arXiv:2310.08560 https://arxiv.org/abs/2310.08560
24
+ // A-MEM: Agentic Memory for LLM Agents — Xu et al. 2025,
25
+ // arXiv:2502.12110 https://arxiv.org/abs/2502.12110
26
+ // Mem0: Production-Ready AI Agents w/ Scalable Long-Term Memory — Chhikara
27
+ // et al. 2025, arXiv:2504.19413 https://arxiv.org/abs/2504.19413
28
+ // DSPy: Compiling Declarative LM Calls into Self-Improving Pipelines —
29
+ // Khattab et al. 2023, arXiv:2310.03714 https://arxiv.org/abs/2310.03714
30
+ //
31
+ // HONESTY LABELS: MODELED (deterministic recall / consistency simulation; read
32
+ // VERBATIM from JSON, never upgraded). The SZL SYNTHESIS is CONJECTURE: Λ as a
33
+ // per-recall trust gate is Λ = Conjecture 1 (gray, never green), and the
34
+ // signed-receipt-per-recall chain is design-only (RECEIPT-ON-WRITE — nothing is
35
+ // minted or signed on this GET). Trust is capped at 0.97, never 1.0.
36
+ // COLOURS: lattice-blue 0x5b8dee (memory nodes / recall links), violet-blue
37
+ // 0x8a6bff (Λ-gate ring), proof-teal 0x3af4c8 (admitted recall / accent),
38
+ // greys (gated-out / inconsistent / degraded). Purple BANNED.
39
+ // 0 RUNTIME CDN. three.js via ctx.THREE (vendored by the page importmap).
40
+ // DOCTRINE v11: degrades gracefully (grey) on 404/error; honesty label still shown.
41
+ // Nothing here is in the locked-8 (adds 0). Λ stays Conjecture 1. Trust never 100%.
42
+
43
+ const ID = "agentmem";
44
+ const TITLE = "AgentMem · Λ-Governed Agent Memory (live)";
45
+
46
+ // Served SAME-ORIGIN by szl_agentmem.py — a deterministic governed-recall model.
47
+ const EP = "/api/a11oy/v1/frontier/agentmem?seed=42&n_memories=256&query_k=16&horizon=128";
48
+
49
+ // data-viz hues — purple BANNED
50
+ const C_MEM = 0x5b8dee; // lattice-blue (memory node / recall link)
51
+ const C_GATE = 0x8a6bff; // violet-blue (Λ-gate ring)
52
+ const C_ADMIT = 0x3af4c8; // proof-teal (admitted recall / accent)
53
+ const C_GATED = 0x5a6570; // grey (Λ-gated-out / inconsistent)
54
+ const C_DIM = 0x42505d; // grey (degraded / no-live-data)
55
+ const C_GRID = 0x1b3a44; // floor / link colour
56
+
57
+ // layout geometry
58
+ const DISC_R = 6.0; // radius of the memory-store disc
59
+ const MAX_MEM = 256; // cap on memory nodes rendered (perf)
60
+ const MAX_RECALL = 24; // cap on recall links rendered
61
+ const GATE_Y = 0.6; // height of the central Λ-gate core
62
+
63
+ let _stage = null, _THREE = null, _ctx = null, _group = null, _overlay = null;
64
+ let _frameReg = false, _polls = [], _el = {}, _badge = null;
65
+ let _collapsed = false;
66
+
67
+ // geometry handles
68
+ let _floor = null;
69
+ let _memMesh = []; // Array<THREE.Mesh> — memory nodes on the disc
70
+ let _gateRing = null; // THREE.LineLoop — Λ-gate ring
71
+ let _core = null; // THREE.Mesh — central gate core (scales with trust)
72
+ let _links = []; // Array<THREE.Line> — recall links to the gate
73
+
74
+ // live state
75
+ const S = {
76
+ label: null,
77
+ nMemories: null,
78
+ queryK: null,
79
+ horizon: null,
80
+ recalled: null, // recalled[]
81
+ checked: null,
82
+ consistent: null,
83
+ conflicts: null,
84
+ consistencyRate: null,
85
+ meanLambda: null,
86
+ admits: null,
87
+ gatedOut: null,
88
+ trust: null,
89
+ trustCap: null,
90
+ receiptSigned: null,
91
+ receiptDigest: null,
92
+ state: "init",
93
+ };
94
+
95
+ // =============================================================================
96
+ // mount(ctx)
97
+ // =============================================================================
98
+ export function mount(ctx) {
99
+ _ctx = ctx; _stage = ctx.stage; _THREE = ctx.THREE;
100
+ _group = new _THREE.Group();
101
+ _stage.scene.add(_group);
102
+ _stage.camera.position.set(0, 9, 20);
103
+ try { if (_stage.controls && _stage.controls.target) { _stage.controls.target.set(0, 1.2, 0); _stage.controls.update(); } } catch (_) {}
104
+ try { _stage.setBloom(true); } catch (_) {}
105
+
106
+ _buildFloor();
107
+ _buildMemoryDisc();
108
+ _buildGate();
109
+ _buildLinks();
110
+
111
+ if (!_frameReg) { _stage.onFrame(_onFrame); _frameReg = true; }
112
+
113
+ _badge = ctx.live.createBadge();
114
+ _polls.push(ctx.live.poll(EP, 5000, _onData, { badge: _badge, onState: (m) => { S.state = m.state; _paintOverlay(); } }));
115
+
116
+ _buildOverlay();
117
+ return { id: ID, started: true };
118
+ }
119
+
120
+ // =============================================================================
121
+ // builders
122
+ // =============================================================================
123
+ function _buildFloor() {
124
+ const THREE = _THREE;
125
+ const grid = new THREE.GridHelper(44, 44, C_GRID, 0x0f2027);
126
+ grid.material.opacity = 0.18; grid.material.transparent = true; grid.position.y = -0.01;
127
+ _group.add(grid);
128
+ _floor = grid;
129
+ }
130
+
131
+ // Memory store: a disc of nodes laid out on a deterministic spiral so recalled
132
+ // (high-relevance) items cluster toward the centre near the Λ-gate.
133
+ function _buildMemoryDisc() {
134
+ const THREE = _THREE;
135
+ const geo = new THREE.SphereGeometry(0.12, 8, 8);
136
+ const golden = Math.PI * (3 - Math.sqrt(5));
137
+ for (let i = 0; i < MAX_MEM; i++) {
138
+ const t = i / MAX_MEM;
139
+ const r = DISC_R * Math.sqrt(t);
140
+ const a = i * golden;
141
+ const mesh = new THREE.Mesh(
142
+ geo,
143
+ new THREE.MeshStandardMaterial({ color: C_MEM, emissive: C_MEM, emissiveIntensity: 0.15, transparent: true, opacity: 0.0 }),
144
+ );
145
+ mesh.position.set(Math.cos(a) * r, 0.15, Math.sin(a) * r);
146
+ mesh.visible = false;
147
+ _group.add(mesh);
148
+ _memMesh.push(mesh);
149
+ }
150
+ }
151
+
152
+ // Central Λ-gate: a ring (advisory boundary) + a core that scales with trust.
153
+ function _buildGate() {
154
+ const THREE = _THREE;
155
+ {
156
+ const pts = [];
157
+ for (let i = 0; i <= 64; i++) {
158
+ const a = (i / 64) * Math.PI * 2;
159
+ pts.push(new THREE.Vector3(Math.cos(a) * 1.7, GATE_Y, Math.sin(a) * 1.7));
160
+ }
161
+ const g = new THREE.BufferGeometry().setFromPoints(pts);
162
+ const m = new THREE.LineBasicMaterial({ color: C_GATE, transparent: true, opacity: 0.45 });
163
+ _gateRing = new THREE.LineLoop(g, m);
164
+ _group.add(_gateRing);
165
+ }
166
+ _core = new THREE.Mesh(
167
+ new THREE.IcosahedronGeometry(0.7, 1),
168
+ new THREE.MeshStandardMaterial({ color: C_GATE, emissive: C_GATE, emissiveIntensity: 0.4, wireframe: true, transparent: true, opacity: 0.85 }),
169
+ );
170
+ _core.position.set(0, GATE_Y, 0);
171
+ _group.add(_core);
172
+ }
173
+
174
+ // Recall links: pre-allocated lines from a memory node to the gate core.
175
+ function _buildLinks() {
176
+ const THREE = _THREE;
177
+ for (let i = 0; i < MAX_RECALL; i++) {
178
+ const g = new THREE.BufferGeometry().setFromPoints([
179
+ new THREE.Vector3(0, 0.15, 0), new THREE.Vector3(0, GATE_Y, 0),
180
+ ]);
181
+ const m = new THREE.LineBasicMaterial({ color: C_MEM, transparent: true, opacity: 0.0 });
182
+ const line = new THREE.Line(g, m);
183
+ line.visible = false;
184
+ _group.add(line);
185
+ _links.push(line);
186
+ }
187
+ }
188
+
189
+ // =============================================================================
190
+ // live data handler
191
+ // =============================================================================
192
+ function _onData(j) {
193
+ const p = (j && typeof j.payload === "object" && j.payload) ? j.payload : j;
194
+ const rawLabel = (j && j.label) || (p && p.label) || "MODELED";
195
+ S.label = String(rawLabel).toUpperCase();
196
+
197
+ S.nMemories = typeof p.n_memories === "number" ? p.n_memories : null;
198
+ S.queryK = typeof p.query_k === "number" ? p.query_k : null;
199
+ S.horizon = typeof p.horizon === "number" ? p.horizon : null;
200
+ S.recalled = Array.isArray(p.recalled) ? p.recalled : null;
201
+
202
+ const c = (p && typeof p.consistency === "object") ? p.consistency : {};
203
+ S.checked = typeof c.checked === "number" ? c.checked : null;
204
+ S.consistent = typeof c.consistent === "number" ? c.consistent : null;
205
+ S.conflicts = typeof c.conflicts === "number" ? c.conflicts : null;
206
+ S.consistencyRate = typeof c.consistency_rate === "number" ? c.consistency_rate : null;
207
+
208
+ const g = (p && typeof p.lambda_gate === "object") ? p.lambda_gate : {};
209
+ S.meanLambda = typeof g.mean_lambda_advisory === "number" ? g.mean_lambda_advisory : null;
210
+ S.admits = typeof g.admits === "number" ? g.admits : null;
211
+ S.gatedOut = typeof g.gated_out === "number" ? g.gated_out : null;
212
+ S.trust = typeof g.trust === "number" ? g.trust : null;
213
+ S.trustCap = typeof g.trust_cap === "number" ? g.trust_cap : null;
214
+
215
+ const rd = (p && typeof p.receipt_design === "object") ? p.receipt_design : {};
216
+ S.receiptSigned = typeof rd.signed === "boolean" ? rd.signed : null;
217
+ S.receiptDigest = typeof rd.receipt_preview_digest === "string" ? rd.receipt_preview_digest : null;
218
+
219
+ _updateScene();
220
+ _paintOverlay();
221
+ }
222
+
223
+ // =============================================================================
224
+ // geometry updater
225
+ // =============================================================================
226
+ function _updateScene() {
227
+ const live = S.state === "live";
228
+
229
+ // gate ring degrades to grey when not live
230
+ if (_gateRing) {
231
+ _gateRing.material.color.setHex(live ? C_GATE : C_DIM);
232
+ _gateRing.material.opacity = live ? 0.45 : 0.12;
233
+ }
234
+
235
+ // memory nodes: light up the store; recalled nodes get pulled brighter.
236
+ const nMem = live && S.nMemories ? Math.min(S.nMemories, MAX_MEM) : 0;
237
+ const recalledIds = new Set();
238
+ const admittedIds = new Set();
239
+ if (live && S.recalled) {
240
+ for (const r of S.recalled) {
241
+ if (typeof r.id === "number") {
242
+ recalledIds.add(r.id % MAX_MEM);
243
+ if (r.admitted) admittedIds.add(r.id % MAX_MEM);
244
+ }
245
+ }
246
+ }
247
+ for (let i = 0; i < MAX_MEM; i++) {
248
+ const mesh = _memMesh[i];
249
+ if (i >= nMem) { mesh.visible = false; continue; }
250
+ mesh.visible = true;
251
+ const recalled = recalledIds.has(i);
252
+ const admitted = admittedIds.has(i);
253
+ const color = admitted ? C_ADMIT : (recalled ? (live ? C_GATE : C_GATED) : (live ? C_MEM : C_DIM));
254
+ mesh.material.color.setHex(color);
255
+ mesh.material.emissive.setHex(color);
256
+ mesh.material.emissiveIntensity = admitted ? 0.6 : (recalled ? 0.4 : 0.12);
257
+ mesh.material.opacity = recalled ? 0.95 : (live ? 0.35 : 0.15);
258
+ mesh.scale.setScalar(admitted ? 1.5 : (recalled ? 1.2 : 0.8));
259
+ }
260
+
261
+ // recall links: draw from each recalled node to the gate; admitted proof-teal,
262
+ // Λ-gated-out grey (the advisory verdict is shown, never hidden).
263
+ const rec = live && S.recalled ? S.recalled.slice(0, MAX_RECALL) : [];
264
+ for (let i = 0; i < MAX_RECALL; i++) {
265
+ const line = _links[i];
266
+ const r = i < rec.length ? rec[i] : null;
267
+ if (!live || !r || typeof r.id !== "number") { line.visible = false; continue; }
268
+ const src = _memMesh[r.id % MAX_MEM];
269
+ if (!src) { line.visible = false; continue; }
270
+ line.visible = true;
271
+ const pos = line.geometry.attributes.position;
272
+ pos.setXYZ(0, src.position.x, src.position.y, src.position.z);
273
+ pos.setXYZ(1, 0, GATE_Y, 0);
274
+ pos.needsUpdate = true;
275
+ const color = r.admitted ? C_ADMIT : C_GATED;
276
+ line.material.color.setHex(color);
277
+ line.material.opacity = r.admitted ? 0.55 : 0.22;
278
+ }
279
+
280
+ // gate core: colour + size reflect the CAPPED trust (never green / never 1.0).
281
+ if (_core) {
282
+ if (live && S.trust != null) {
283
+ _core.material.color.setHex(C_ADMIT);
284
+ _core.material.emissive.setHex(C_ADMIT);
285
+ _core.material.opacity = 0.85;
286
+ _core.scale.setScalar(0.6 + S.trust * 1.0);
287
+ } else {
288
+ _core.material.color.setHex(C_DIM);
289
+ _core.material.emissive.setHex(C_DIM);
290
+ _core.material.opacity = 0.3;
291
+ _core.scale.setScalar(0.6);
292
+ }
293
+ }
294
+ }
295
+
296
+ // =============================================================================
297
+ // per-frame animation
298
+ // =============================================================================
299
+ function _onFrame() {
300
+ const t = performance.now();
301
+ if (_group) _group.rotation.y = Math.sin(t * 0.00008) * 0.12;
302
+ if (_gateRing) _gateRing.rotation.y += 0.0016;
303
+ if (_core) {
304
+ _core.rotation.y += 0.02;
305
+ _core.rotation.x += 0.008;
306
+ const pulse = 1.0 + 0.1 * Math.sin(t * 0.0035);
307
+ const base = (S.state === "live" && S.trust != null) ? (0.6 + S.trust * 1.0) : 0.6;
308
+ _core.scale.setScalar(base * pulse);
309
+ }
310
+ }
311
+
312
+ // =============================================================================
313
+ // overlay — COMPACT: title + badge + small legend + collapsible panel
314
+ // =============================================================================
315
+ function _buildOverlay() {
316
+ const ctx = _ctx;
317
+ _overlay = document.createElement("div");
318
+ Object.assign(_overlay.style, {
319
+ position: "absolute", left: "14px", top: "14px", zIndex: "6",
320
+ display: "flex", flexDirection: "column", gap: "7px",
321
+ maxWidth: "min(92vw,340px)", maxHeight: "calc(100dvh - 28px)", overflowY: "auto",
322
+ font: "12px ui-sans-serif,system-ui,Segoe UI,Roboto,Arial",
323
+ color: "#eef3f6",
324
+ });
325
+
326
+ const h = document.createElement("div");
327
+ h.style.cssText = "font:600 13px ui-sans-serif,system-ui;letter-spacing:.3px";
328
+ h.textContent = TITLE;
329
+ _overlay.appendChild(h);
330
+
331
+ const brow = document.createElement("div");
332
+ brow.style.cssText = "display:flex;gap:7px;align-items:center;flex-wrap:wrap";
333
+ if (_badge && _badge.el) brow.appendChild(_badge.el);
334
+ // honesty label pill (verbatim, never upgraded)
335
+ const pill = document.createElement("span");
336
+ pill.id = "am-pill";
337
+ pill.style.cssText = "font:600 10px ui-monospace,monospace;padding:2px 7px;border-radius:10px;border:1px solid #8a6bff;color:#c9bdff;background:#14102a";
338
+ pill.textContent = "MODELED · Λ=CONJECTURE 1";
339
+ brow.appendChild(pill);
340
+ _overlay.appendChild(brow);
341
+
342
+ // small legend (3 chips)
343
+ const lg = document.createElement("div");
344
+ lg.style.cssText = "display:flex;gap:9px;flex-wrap:wrap;font-size:10px;color:#9fb1bf";
345
+ lg.innerHTML =
346
+ '<span style="color:#3af4c8">● admitted</span>' +
347
+ '<span style="color:#8a6bff">● recalled</span>' +
348
+ '<span style="color:#5a6570">● Λ-gated/stale</span>';
349
+ _overlay.appendChild(lg);
350
+
351
+ // collapse toggle
352
+ const tog = document.createElement("button");
353
+ tog.textContent = "▾ details";
354
+ tog.style.cssText = "font:11px ui-monospace,monospace;padding:4px 10px;border-radius:7px;border:1px solid #3af4c8;background:#08140f;color:#3af4c8;cursor:pointer;width:fit-content";
355
+ tog.addEventListener("click", () => {
356
+ _collapsed = !_collapsed;
357
+ card.style.display = _collapsed ? "none" : "flex";
358
+ tog.textContent = _collapsed ? "▸ details" : "▾ details";
359
+ });
360
+ _overlay.appendChild(tog);
361
+
362
+ const card = document.createElement("div");
363
+ card.id = "am-card";
364
+ card.style.cssText = "background:#0a1117;border:1px solid #1d2a36;border-radius:9px;padding:9px 10px;display:flex;flex-direction:column;gap:5px";
365
+
366
+ const grid = document.createElement("div");
367
+ grid.style.cssText = "display:grid;grid-template-columns:1fr;gap:3px";
368
+
369
+ function kpiRow(id, label) {
370
+ const r = document.createElement("div");
371
+ r.style.cssText = "display:flex;justify-content:space-between;gap:10px;font-size:11px";
372
+ const l = document.createElement("span"); l.style.cssText = "color:#9fb1bf"; l.textContent = label;
373
+ const v = document.createElement("b");
374
+ v.id = id;
375
+ v.style.cssText = "font-variant-numeric:tabular-nums;color:#eef3f6;text-align:right;max-width:56%";
376
+ v.textContent = "—";
377
+ _el[id] = v;
378
+ r.appendChild(l); r.appendChild(v); return r;
379
+ }
380
+
381
+ grid.appendChild(kpiRow("am-store", "memory store / top-k"));
382
+ grid.appendChild(kpiRow("am-cons", "consistency_rate"));
383
+ grid.appendChild(kpiRow("am-conf", "conflicts (stale/contradict)"));
384
+ grid.appendChild(kpiRow("am-lambda", "mean Λ advisory (gray)"));
385
+ grid.appendChild(kpiRow("am-gate", "Λ-gate admits / gated-out"));
386
+ grid.appendChild(kpiRow("am-trust", "trust (capped ≤0.97)"));
387
+ grid.appendChild(kpiRow("am-receipt", "recall receipt"));
388
+ grid.appendChild(kpiRow("am-label", "honesty label"));
389
+ card.appendChild(grid);
390
+
391
+ const note = document.createElement("div");
392
+ note.style.cssText = "font-size:10px;color:#c9d6df;line-height:1.5;border-top:1px solid #1d2a36;padding-top:5px";
393
+ note.innerHTML =
394
+ "SZL synthesis: agent memory + <b>Λ trust gate</b> (Λ = Conjecture 1, gray) + " +
395
+ "<b>signed receipt per recall</b> (receipt-on-write — nothing minted on this read).";
396
+ card.appendChild(note);
397
+
398
+ const fn = document.createElement("div");
399
+ fn.style.cssText = "font-size:9px;color:#6b7a86;line-height:1.5";
400
+ fn.textContent = "MemGPT arXiv:2310.08560 · A-MEM 2502.12110 · Mem0 2504.19413 · DSPy 2310.03714. MODELED/CONJECTURE · not claimed-as.";
401
+ card.appendChild(fn);
402
+ _overlay.appendChild(card);
403
+
404
+ (ctx.container || document.body).appendChild(_overlay);
405
+ _paintOverlay();
406
+ }
407
+
408
+ function _tok(s) {
409
+ if (s === "live") return null;
410
+ if (s === "missing") return "NO-LIVE-DATA";
411
+ if (s === "degraded") return "DEGRADED";
412
+ if (s === "error") return "OFFLINE";
413
+ return "…";
414
+ }
415
+
416
+ function pct(v, d) { return typeof v === "number" ? (v * 100).toFixed(d) + "%" : "—"; }
417
+ function fx(v, d) { return typeof v === "number" ? v.toFixed(d) : "—"; }
418
+ function _set(id, v) { if (_el[id]) _el[id].textContent = v; }
419
+
420
+ function _paintOverlay() {
421
+ const t = _tok(S.state);
422
+ _set("am-store", t || (S.nMemories != null ? S.nMemories + " / " + (S.queryK != null ? S.queryK : "—") : "—"));
423
+ _set("am-cons", t || pct(S.consistencyRate, 1));
424
+ _set("am-conf", t || (S.conflicts != null ? String(S.conflicts) : "—"));
425
+ _set("am-lambda", t || fx(S.meanLambda, 3));
426
+ _set("am-gate", t || (S.admits != null || S.gatedOut != null ? (S.admits != null ? S.admits : "—") + " / " + (S.gatedOut != null ? S.gatedOut : "—") : "—"));
427
+ _set("am-trust", t || (S.trust != null ? fx(S.trust, 3) + (S.trustCap != null ? " (≤" + S.trustCap + ")" : "") : "—"));
428
+ _set("am-receipt", t || (S.receiptSigned === false
429
+ ? "unsigned preview" + (S.receiptDigest ? " " + S.receiptDigest.slice(0, 10) + "…" : "")
430
+ : (S.receiptDigest ? S.receiptDigest.slice(0, 10) + "…" : "—")));
431
+ _set("am-label", t || (S.label || "MODELED"));
432
+ }
433
+
434
+ // =============================================================================
435
+ // unmount — clean up everything; must not affect other organs
436
+ // =============================================================================
437
+ export function unmount() {
438
+ _polls.forEach((p) => { try { p.stop(); } catch (_) {} }); _polls = [];
439
+ try { if (_overlay && _overlay.parentNode) _overlay.parentNode.removeChild(_overlay); } catch (_) {}
440
+ try {
441
+ if (_group && _stage) {
442
+ _group.traverse((o) => {
443
+ if (o.geometry && o.geometry.dispose) o.geometry.dispose();
444
+ if (o.material) {
445
+ const ms = Array.isArray(o.material) ? o.material : [o.material];
446
+ ms.forEach((m) => { if (m.dispose) m.dispose(); });
447
+ }
448
+ });
449
+ _stage.scene.remove(_group);
450
+ }
451
+ } catch (_) {}
452
+ _group = _overlay = null;
453
+ _floor = null; _memMesh = []; _gateRing = null; _core = null; _links = [];
454
+ _el = {}; _badge = null; _collapsed = false; _frameReg = false;
455
+ _stage = _THREE = _ctx = null;
456
+ S.label = S.nMemories = S.queryK = S.horizon = S.recalled = null;
457
+ S.checked = S.consistent = S.conflicts = S.consistencyRate = null;
458
+ S.meanLambda = S.admits = S.gatedOut = S.trust = S.trustCap = null;
459
+ S.receiptSigned = S.receiptDigest = null;
460
+ S.state = "init";
461
+ }
462
+
463
+ export default { id: ID, title: TITLE, endpoints: [EP], mount, unmount };