betterwithage Claude Opus 4.7 commited on
Commit
e345f85
·
verified ·
1 Parent(s): b8f152d

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

Browse files

Reusable Dockerfile-COPY-derived deploy from szl-holdings/a11oy main.
Files: 859 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
@@ -95,6 +95,10 @@ const SURFACES = [
95
  { id: "mor", title: "Mixture-of-Recursions (adaptive depth)", mod: "/static/3d/surfaces/mor.js" },
96
  { id: "goat", title: "GOAT Optimal-Transport Attention", mod: "/static/3d/surfaces/goat.js" },
97
  { id: "kla", title: "Kaczmarz Linear Attention", mod: "/static/3d/surfaces/kla.js" },
 
 
 
 
98
  { id: "energy", title: "Energy", mod: "/static/3d/surfaces/energy.js" },
99
  { id: "fabric", title: "Fabric", mod: "/static/3d/surfaces/fabric.js" },
100
  { id: "pnt", title: "PNT", mod: "/static/3d/surfaces/pnt.js" },
 
95
  { id: "mor", title: "Mixture-of-Recursions (adaptive depth)", mod: "/static/3d/surfaces/mor.js" },
96
  { id: "goat", title: "GOAT Optimal-Transport Attention", mod: "/static/3d/surfaces/goat.js" },
97
  { id: "kla", title: "Kaczmarz Linear Attention", mod: "/static/3d/surfaces/kla.js" },
98
+ { id: "hrm", title: "Hierarchical Reasoning Model", mod: "/static/3d/surfaces/hrm.js" },
99
+ { id: "pfield", title: "Pressure-Field Coordination", mod: "/static/3d/surfaces/pfield.js" },
100
+ { id: "qhall", title: "Quantum-Inspired Hallucination UQ", mod: "/static/3d/surfaces/qhall.js" },
101
+ { id: "aimc", title: "Analog In-Memory Attention", mod: "/static/3d/surfaces/aimc.js" },
102
  { id: "energy", title: "Energy", mod: "/static/3d/surfaces/energy.js" },
103
  { id: "fabric", title: "Fabric", mod: "/static/3d/surfaces/fabric.js" },
104
  { id: "pnt", title: "PNT", mod: "/static/3d/surfaces/pnt.js" },
static/3d/surfaces/aimc.js ADDED
@@ -0,0 +1,508 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11
3
+ //
4
+ // surfaces/aimc.js — ANALOG IN-MEMORY COMPUTING ATTENTION organ for the
5
+ // holographic frontier ring (charge-domain gain-cell crossbar attention,
6
+ // Leroux et al. 2025-style). Renders an idealized analog crossbar as a lattice
7
+ // of nodes: the query drives charge along columns to compute query·key
8
+ // dot-products IN MEMORY. Three score bars per column visualize the exact
9
+ // DIGITAL baseline (lattice-blue), the raw NOISY ANALOG pathway (violet-blue),
10
+ // and the CALIBRATED analog pathway (proof-teal) that recovers accuracy. A HUD
11
+ // shows analog_mse vs calibrated_mse + the operations-avoided energy tally read
12
+ // live from /api/killinchu/v1/aimc/attend. Honesty label "MODELED" is read
13
+ // VERBATIM from the JSON and displayed as-is; it is never upgraded.
14
+ //
15
+ // Surface export shape (mirrors mla.js / kvcache.js / specdecode.js exactly):
16
+ // export default { id, title, endpoints, mount(ctx), unmount() }
17
+ // ctx = { stage, container, live, label, THREE, szl3d }
18
+ //
19
+ // DATA SHOWN (all from live endpoint):
20
+ // seq_len, dim, noise_sigma, analog_mse, calibrated_mse, calibration_gain,
21
+ // accuracy_recovered_pct, adc_dac_ops_avoided, memory_move_reads_avoided,
22
+ // total_ops_avoided, paper_energy_reduction_claim, paper_latency_reduction_claim,
23
+ // sample_digital_scores[], sample_analog_scores[], sample_calibrated_scores[]
24
+ //
25
+ // LEADERS ADOPTED & CITED (clean-room; NOT claimed as SZL's own; VERIFY real):
26
+ // AIMC attention — analog in-memory gain-cell crossbar attention (mechanism
27
+ // simulated here):
28
+ // Leroux et al. 2025, Nature Computational Science
29
+ // https://www.nature.com/articles/s43588-025-00854-1
30
+ // IBM Research plain-language summary (reference):
31
+ // https://research.ibm.com/blog/how-can-analog-in-memory-computing-power-transformer-models
32
+ //
33
+ // HONESTY LABELS: MODELED (deterministic simulation of the charge-domain crossbar
34
+ // attention arithmetic on ordinary CPU floats; NOT a run on real analog gain-cell
35
+ // hardware; NEVER-CLAIMED-AS the Leroux et al. chip). Read verbatim from JSON;
36
+ // never upgraded here. CRITICAL HONESTY: the energy/latency advantage figures are
37
+ // the PAPER's published CLAIM reproduced at toy scale via an operations-avoided
38
+ // accounting model — NOT measured on real analog hardware, NOT a measured SZL
39
+ // result. Doctrine v11: never claim more than is real.
40
+ // COLOURS: lattice-blue 0x5b8dee (exact digital baseline / crossbar rows), violet-
41
+ // blue 0x8a6bff (raw noisy analog pathway), proof-teal 0x3af4c8 (calibrated
42
+ // pathway / HUD accent), greys (device-noise / degraded state). Purple BANNED as
43
+ // UI/background.
44
+ // 0 RUNTIME CDN. Vendored three.js r170 via page importmap.
45
+ // DOCTRINE v11: degrades gracefully (grey) on 404/error; honesty label still shown.
46
+ // Nothing here is in the locked-8. Λ stays Conjecture 1. Trust never 100%.
47
+
48
+ const ID = "aimc";
49
+ const TITLE = "Analog In-Memory Computing Attention · Gain-Cell Crossbar (live)";
50
+
51
+ // Endpoint is hosted on the dedicated killinchu Space (isolated compute), reached
52
+ // cross-origin (killinchu returns access-control-allow-origin: https://a-11-oy.com).
53
+ // This keeps the AIMC organ's rebuilds/faults isolated from the flagship.
54
+ const EP = "https://szlholdings-killinchu.hf.space/api/killinchu/v1/aimc/attend?seed=42&seq_len=128&dim=64&noise_sigma=0.05";
55
+
56
+ // data-viz hues — purple BANNED
57
+ const C_DIGITAL = 0x5b8dee; // lattice-blue (exact digital baseline / crossbar rows)
58
+ const C_ANALOG = 0x8a6bff; // violet-blue (raw noisy analog pathway)
59
+ const C_CALIB = 0x3af4c8; // proof-teal (calibrated pathway / HUD accent)
60
+ const C_NOISE = 0x6b7a86; // grey (device-noise cue)
61
+ const C_DIM = 0x42505d; // grey (degraded / no-live-data)
62
+ const C_GRID = 0x1b3a44; // floor / link colour
63
+
64
+ // crossbar + score-bar layout geometry
65
+ const GRID_N = 8; // crossbar rendered as GRID_N x GRID_N node lattice
66
+ const NODE_GAP = 0.5; // world-units between crossbar nodes
67
+ const BAR_GAP = 0.5; // world-units between score-bar columns along X
68
+ const MAX_BARS = 24; // cap on score-bar columns rendered (perf)
69
+ const MAX_BAR_H = 5.0; // world-units — score bar height at unit score
70
+ const MIN_BAR_H = 0.04; // floor height so a bar never fully vanishes
71
+
72
+ let _stage = null, _THREE = null, _ctx = null, _group = null, _overlay = null;
73
+ let _frameReg = false, _polls = [], _el = {}, _badge = null;
74
+ let _plain = false;
75
+
76
+ // geometry handles
77
+ let _floor = null;
78
+ let _crossbar = []; // Array<THREE.Mesh> — crossbar lattice nodes
79
+ let _crossLines = []; // Array<THREE.Line> — crossbar row/column wires
80
+ let _barsDig = []; // Array<THREE.Mesh> — digital baseline score bars
81
+ let _barsAna = []; // Array<THREE.Mesh> — raw analog score bars
82
+ let _barsCal = []; // Array<THREE.Mesh> — calibrated score bars
83
+ let _query = null; // THREE.Mesh — pulsing query-drive marker
84
+
85
+ // live state
86
+ const S = {
87
+ label: null,
88
+ seqLen: null, // seq_len
89
+ dim: null, // dim
90
+ noiseSigma: null, // noise_sigma
91
+ analogMse: null, // analog_mse
92
+ calibMse: null, // calibrated_mse
93
+ calibGain: null, // calibration_gain
94
+ accRecovered: null, // accuracy_recovered_pct
95
+ adcDacOps: null, // adc_dac_ops_avoided
96
+ memMoveOps: null, // memory_move_reads_avoided
97
+ totalOps: null, // total_ops_avoided
98
+ energyClaim: null, // paper_energy_reduction_claim (PAPER's claim, not measured)
99
+ latencyClaim: null, // paper_latency_reduction_claim (PAPER's claim, not measured)
100
+ digScores: null, // sample_digital_scores[]
101
+ anaScores: null, // sample_analog_scores[]
102
+ calScores: null, // sample_calibrated_scores[]
103
+ state: "init",
104
+ };
105
+
106
+ // =============================================================================
107
+ // mount(ctx)
108
+ // =============================================================================
109
+ export function mount(ctx) {
110
+ _ctx = ctx; _stage = ctx.stage; _THREE = ctx.THREE;
111
+ _group = new _THREE.Group();
112
+ _stage.scene.add(_group);
113
+ _stage.camera.position.set(6, 6, 16);
114
+ try { if (_stage.controls && _stage.controls.target) { _stage.controls.target.set(3, 2, 0); _stage.controls.update(); } } catch (_) {}
115
+ try { _stage.setBloom(true); } catch (_) {}
116
+
117
+ _buildFloor();
118
+ _buildCrossbar();
119
+ _buildScoreBars();
120
+ _buildQuery();
121
+
122
+ if (!_frameReg) { _stage.onFrame(_onFrame); _frameReg = true; }
123
+
124
+ _badge = ctx.live.createBadge();
125
+ _polls.push(ctx.live.poll(EP, 5000, _onAimc, { badge: _badge, onState: (m) => { S.state = m.state; _paintOverlay(); } }));
126
+
127
+ _buildOverlay();
128
+ return { id: ID, started: true };
129
+ }
130
+
131
+ // =============================================================================
132
+ // builders
133
+ // =============================================================================
134
+ function _buildFloor() {
135
+ const THREE = _THREE;
136
+ const grid = new THREE.GridHelper(40, 40, C_GRID, 0x0f2027);
137
+ grid.material.opacity = 0.18; grid.material.transparent = true; grid.position.y = -0.01;
138
+ _group.add(grid);
139
+ _floor = grid;
140
+ }
141
+
142
+ // Idealized analog gain-cell crossbar: a GRID_N x GRID_N lattice of nodes with
143
+ // row + column wires. Each node stores a Key element; the query drives charge
144
+ // down the columns to accumulate the dot-product IN MEMORY.
145
+ function _buildCrossbar() {
146
+ const THREE = _THREE;
147
+ const nodeGeo = new THREE.OctahedronGeometry(0.09, 0);
148
+ const originX = -5.0, baseY = 0.6, baseZ = -1.8;
149
+
150
+ for (let r = 0; r < GRID_N; r++) {
151
+ for (let c = 0; c < GRID_N; c++) {
152
+ const mesh = new THREE.Mesh(
153
+ nodeGeo,
154
+ new THREE.MeshStandardMaterial({ color: C_NOISE, emissive: C_NOISE, emissiveIntensity: 0.2, transparent: true, opacity: 0.75 }),
155
+ );
156
+ mesh.position.set(originX + c * NODE_GAP, baseY + r * NODE_GAP, baseZ);
157
+ _group.add(mesh);
158
+ _crossbar.push(mesh);
159
+ }
160
+ }
161
+ // row wires (lattice-blue) + column wires (proof-teal charge paths)
162
+ for (let r = 0; r < GRID_N; r++) {
163
+ const pts = [
164
+ new THREE.Vector3(originX, baseY + r * NODE_GAP, baseZ),
165
+ new THREE.Vector3(originX + (GRID_N - 1) * NODE_GAP, baseY + r * NODE_GAP, baseZ),
166
+ ];
167
+ const geo = new THREE.BufferGeometry().setFromPoints(pts);
168
+ const line = new THREE.Line(geo, new THREE.LineBasicMaterial({ color: C_DIGITAL, transparent: true, opacity: 0.3 }));
169
+ _group.add(line); _crossLines.push(line);
170
+ }
171
+ for (let c = 0; c < GRID_N; c++) {
172
+ const pts = [
173
+ new THREE.Vector3(originX + c * NODE_GAP, baseY, baseZ),
174
+ new THREE.Vector3(originX + c * NODE_GAP, baseY + (GRID_N - 1) * NODE_GAP, baseZ),
175
+ ];
176
+ const geo = new THREE.BufferGeometry().setFromPoints(pts);
177
+ const line = new THREE.Line(geo, new THREE.LineBasicMaterial({ color: C_CALIB, transparent: true, opacity: 0.25 }));
178
+ _group.add(line); _crossLines.push(line);
179
+ }
180
+ }
181
+
182
+ // Three interleaved score-bar columns per position: exact digital baseline
183
+ // (lattice-blue), raw noisy analog (violet-blue), calibrated (proof-teal).
184
+ // We scale each bar's Y in-place as live data arrives (no per-poll churn),
185
+ // base centered at y=0 via geometry translation so scaling grows upward.
186
+ function _buildScoreBars() {
187
+ const THREE = _THREE;
188
+ const barGeo = new THREE.BoxGeometry(0.12, 1, 0.12);
189
+ barGeo.translate(0, 0.5, 0); // base at y=0; scaling Y grows upward
190
+
191
+ function mkBar(color, emis) {
192
+ const m = new THREE.Mesh(
193
+ barGeo,
194
+ new THREE.MeshStandardMaterial({ color, emissive: color, emissiveIntensity: emis, transparent: true, opacity: 0.9 }),
195
+ );
196
+ m.scale.set(1, MIN_BAR_H, 1);
197
+ m.visible = false;
198
+ _group.add(m);
199
+ return m;
200
+ }
201
+ for (let i = 0; i < MAX_BARS; i++) {
202
+ const x = i * BAR_GAP;
203
+ const bd = mkBar(C_DIGITAL, 0.3); bd.position.set(x - 0.14, 0, 0.4);
204
+ const ba = mkBar(C_ANALOG, 0.34); ba.position.set(x, 0, 0.4);
205
+ const bc = mkBar(C_CALIB, 0.42); bc.position.set(x + 0.14, 0, 0.4);
206
+ _barsDig.push(bd); _barsAna.push(ba); _barsCal.push(bc);
207
+ }
208
+ }
209
+
210
+ function _buildQuery() {
211
+ const THREE = _THREE;
212
+ _query = new THREE.Mesh(
213
+ new THREE.IcosahedronGeometry(0.28, 1),
214
+ new THREE.MeshStandardMaterial({ color: C_CALIB, emissive: C_CALIB, emissiveIntensity: 0.5, wireframe: true, transparent: true, opacity: 0.85 }),
215
+ );
216
+ _query.position.set(-5.7, 2.4, -1.8);
217
+ _group.add(_query);
218
+ }
219
+
220
+ // =============================================================================
221
+ // live data handler
222
+ // =============================================================================
223
+ function _onAimc(j) {
224
+ // read honesty label VERBATIM — never upgrade. handle top-level 'label' OR
225
+ // nested 'payload.label' to match our own module's shape.
226
+ const lbl = (j && j.label != null) ? j.label
227
+ : (j && j.payload && j.payload.label != null) ? j.payload.label
228
+ : "MODELED";
229
+ const src = (j && j.payload && typeof j.payload === "object") ? j.payload : j;
230
+
231
+ S.label = String(lbl).toUpperCase();
232
+ S.seqLen = typeof src.seq_len === "number" ? src.seq_len : null;
233
+ S.dim = typeof src.dim === "number" ? src.dim : null;
234
+ S.noiseSigma = typeof src.noise_sigma === "number" ? src.noise_sigma : null;
235
+ S.analogMse = typeof src.analog_mse === "number" ? src.analog_mse : null;
236
+ S.calibMse = typeof src.calibrated_mse === "number" ? src.calibrated_mse : null;
237
+ S.calibGain = typeof src.calibration_gain === "number" ? src.calibration_gain : null;
238
+ S.accRecovered = typeof src.accuracy_recovered_pct === "number" ? src.accuracy_recovered_pct : null;
239
+ S.adcDacOps = typeof src.adc_dac_ops_avoided === "number" ? src.adc_dac_ops_avoided : null;
240
+ S.memMoveOps = typeof src.memory_move_reads_avoided === "number" ? src.memory_move_reads_avoided : null;
241
+ S.totalOps = typeof src.total_ops_avoided === "number" ? src.total_ops_avoided : null;
242
+ S.energyClaim = typeof src.paper_energy_reduction_claim === "string" ? src.paper_energy_reduction_claim : null;
243
+ S.latencyClaim = typeof src.paper_latency_reduction_claim === "string" ? src.paper_latency_reduction_claim : null;
244
+ S.digScores = Array.isArray(src.sample_digital_scores) ? src.sample_digital_scores : null;
245
+ S.anaScores = Array.isArray(src.sample_analog_scores) ? src.sample_analog_scores : null;
246
+ S.calScores = Array.isArray(src.sample_calibrated_scores) ? src.sample_calibrated_scores : null;
247
+
248
+ _updateBars();
249
+ _paintOverlay();
250
+ }
251
+
252
+ // =============================================================================
253
+ // geometry updater — drives the score bars + crossbar tint from live data
254
+ // =============================================================================
255
+ function _updateBars() {
256
+ const live = S.state === "live";
257
+ const dig = live && S.digScores ? S.digScores : [];
258
+ const ana = live && S.anaScores ? S.anaScores : [];
259
+ const cal = live && S.calScores ? S.calScores : [];
260
+
261
+ // normalize bar heights against the max absolute digital score so the trio
262
+ // is comparable per column.
263
+ let maxAbs = 0.0;
264
+ for (let i = 0; i < dig.length; i++) { const a = Math.abs(dig[i]); if (a > maxAbs) maxAbs = a; }
265
+ if (maxAbs <= 1e-9) maxAbs = 1.0;
266
+
267
+ for (let i = 0; i < MAX_BARS; i++) {
268
+ const has = live && i < dig.length;
269
+ _barsDig[i].visible = has;
270
+ _barsAna[i].visible = has;
271
+ _barsCal[i].visible = has;
272
+ if (!has) continue;
273
+ const hd = Math.max(MIN_BAR_H, (Math.abs(dig[i]) / maxAbs) * MAX_BAR_H);
274
+ const ha = Math.max(MIN_BAR_H, (Math.abs(ana[i] != null ? ana[i] : dig[i]) / maxAbs) * MAX_BAR_H);
275
+ const hc = Math.max(MIN_BAR_H, (Math.abs(cal[i] != null ? cal[i] : dig[i]) / maxAbs) * MAX_BAR_H);
276
+ _barsDig[i].scale.y = hd;
277
+ _barsAna[i].scale.y = ha;
278
+ _barsCal[i].scale.y = hc;
279
+ }
280
+
281
+ // crossbar node tint: violet-blue when live (charge flowing), grey degraded.
282
+ const nodeColor = live ? C_ANALOG : C_DIM;
283
+ for (let n = 0; n < _crossbar.length; n++) {
284
+ _crossbar[n].material.color.setHex(nodeColor);
285
+ _crossbar[n].material.emissive.setHex(nodeColor);
286
+ _crossbar[n].material.opacity = live ? 0.75 : 0.2;
287
+ }
288
+ for (let l = 0; l < _crossLines.length; l++) {
289
+ _crossLines[l].material.opacity = live ? 0.28 : 0.08;
290
+ }
291
+ if (_query) {
292
+ const qc = live ? C_CALIB : C_DIM;
293
+ _query.material.color.setHex(qc);
294
+ _query.material.emissive.setHex(qc);
295
+ _query.material.opacity = live ? 0.85 : 0.3;
296
+ }
297
+ }
298
+
299
+ // =============================================================================
300
+ // per-frame animation
301
+ // =============================================================================
302
+ function _onFrame() {
303
+ const t = performance.now();
304
+ if (_group) _group.rotation.y = Math.sin(t * 0.00008) * 0.11;
305
+ if (_query) {
306
+ _query.rotation.y += 0.02;
307
+ _query.rotation.x += 0.011;
308
+ const pulse = 1.0 + 0.14 * Math.sin(t * 0.004);
309
+ _query.scale.setScalar(pulse);
310
+ }
311
+ // gentle shimmer along crossbar nodes to suggest charge accumulation
312
+ for (let n = 0; n < _crossbar.length; n++) {
313
+ const m = _crossbar[n];
314
+ m.material.emissiveIntensity = 0.2 + 0.12 * (0.5 + 0.5 * Math.sin(t * 0.003 + n * 0.4));
315
+ }
316
+ }
317
+
318
+ // =============================================================================
319
+ // overlay
320
+ // =============================================================================
321
+ function _buildOverlay() {
322
+ const ctx = _ctx;
323
+ _overlay = document.createElement("div");
324
+ Object.assign(_overlay.style, {
325
+ position: "absolute", left: "14px", top: "14px", zIndex: "6",
326
+ display: "flex", flexDirection: "column", gap: "8px",
327
+ maxWidth: "min(94%,460px)",
328
+ font: "12px ui-sans-serif,system-ui,Segoe UI,Roboto,Arial",
329
+ color: "#eef3f6",
330
+ });
331
+
332
+ const h = document.createElement("div");
333
+ h.style.cssText = "font:600 13px ui-sans-serif,system-ui;letter-spacing:.4px";
334
+ h.textContent = TITLE;
335
+ _overlay.appendChild(h);
336
+
337
+ const sub = document.createElement("div");
338
+ sub.style.cssText = "color:#9fb1bf;font-size:11px;line-height:1.55";
339
+ sub.innerHTML =
340
+ 'Instead of moving the KV cache out of memory and through ADC/DAC converters, an analog ' +
341
+ '<b>gain-cell crossbar</b> stores the Keys and computes query\u00b7key dot-products as a ' +
342
+ 'physical <b>charge-domain multiply-accumulate</b> in place. Bars per column compare the ' +
343
+ 'exact <b>digital</b> baseline (lattice-blue), the raw <b>analog</b> pathway with device ' +
344
+ 'noise (violet-blue), and the <b>calibrated</b> pathway (proof-teal) that recovers accuracy. ' +
345
+ 'Honesty label <b>MODELED</b> \u2014 a deterministic simulation on ordinary CPU floats, NOT ' +
346
+ 'real analog hardware. Energy/latency wins shown are the <b>paper\u2019s claim, not a measured ' +
347
+ 'SZL result</b>. 0 runtime CDN.';
348
+ _overlay.appendChild(sub);
349
+
350
+ const brow = document.createElement("div");
351
+ brow.style.cssText = "display:flex;gap:8px;align-items:center;flex-wrap:wrap";
352
+ if (_badge && _badge.el) brow.appendChild(_badge.el);
353
+ _overlay.appendChild(brow);
354
+
355
+ const card = document.createElement("div");
356
+ card.style.cssText = "background:#0a1117;border:1px solid #1d2a36;border-radius:9px;padding:9px 10px;display:flex;flex-direction:column;gap:6px";
357
+
358
+ const chead = document.createElement("div");
359
+ chead.style.cssText = "display:flex;align-items:center;gap:8px;flex-wrap:wrap";
360
+ const dot = document.createElement("span");
361
+ dot.style.cssText = "width:9px;height:9px;border-radius:50%;background:#3af4c8;box-shadow:0 0 7px #3af4c8";
362
+ const nm = document.createElement("b");
363
+ nm.style.cssText = "font-size:12px;color:#3af4c8;letter-spacing:.3px";
364
+ nm.textContent = "analog in-memory computing attention";
365
+ chead.appendChild(dot); chead.appendChild(nm);
366
+ card.appendChild(chead);
367
+
368
+ const grid = document.createElement("div");
369
+ grid.style.cssText = "display:grid;grid-template-columns:1fr;gap:4px";
370
+
371
+ function kpiRow(id, label) {
372
+ const r = document.createElement("div");
373
+ r.style.cssText = "display:flex;justify-content:space-between;gap:10px;font-size:11px";
374
+ const l = document.createElement("span"); l.style.cssText = "color:#9fb1bf"; l.textContent = label;
375
+ const v = document.createElement("b");
376
+ v.id = id;
377
+ v.style.cssText = "font-variant-numeric:tabular-nums;color:#eef3f6;text-align:right;max-width:58%";
378
+ v.textContent = "\u2014";
379
+ _el[id] = v;
380
+ r.appendChild(l); r.appendChild(v); return r;
381
+ }
382
+
383
+ grid.appendChild(kpiRow("ai-seqlen", "seq_len (crossbar columns)"));
384
+ grid.appendChild(kpiRow("ai-dim", "dim (crossbar rows)"));
385
+ grid.appendChild(kpiRow("ai-noise", "noise_sigma (device imprecision)"));
386
+ grid.appendChild(kpiRow("ai-anamse", "analog_mse (raw, vs digital)"));
387
+ grid.appendChild(kpiRow("ai-calmse", "calibrated_mse (vs digital) \u2014 MODELED"));
388
+ grid.appendChild(kpiRow("ai-acc", "accuracy_recovered_pct"));
389
+ grid.appendChild(kpiRow("ai-ops", "total_ops_avoided (ADC/DAC + moves)"));
390
+ grid.appendChild(kpiRow("ai-energy", "energy reduction (paper\u2019s claim)"));
391
+ grid.appendChild(kpiRow("ai-latency", "latency reduction (paper\u2019s claim)"));
392
+ grid.appendChild(kpiRow("ai-label", "honesty label"));
393
+ card.appendChild(grid);
394
+
395
+ const fn = document.createElement("div");
396
+ fn.style.cssText = "font-size:9.5px;color:#6b7a86;line-height:1.5";
397
+ fn.innerHTML = "AIMC attention \u2014 Leroux et al. 2025, Nature Computational Science " +
398
+ "(nature.com/articles/s43588-025-00854-1) \u00b7 IBM Research summary. MODELED \u00b7 not " +
399
+ "claimed-as. Energy/latency = paper\u2019s claim, NOT a measured SZL figure.";
400
+ card.appendChild(fn);
401
+ _overlay.appendChild(card);
402
+
403
+ const pl = document.createElement("button");
404
+ pl.textContent = "\u25d1 what this means";
405
+ pl.title = "Toggle plain-language explanation for investors & consumers.";
406
+ pl.style.cssText = "font:11px ui-monospace,monospace;padding:5px 11px;border-radius:7px;border:1px solid #3af4c8;background:#08140f;color:#3af4c8;cursor:pointer;width:fit-content";
407
+ pl.addEventListener("click", () => {
408
+ _plain = !_plain;
409
+ pl.style.background = _plain ? "#0f2a20" : "#08140f";
410
+ _applyPlain();
411
+ });
412
+ _overlay.appendChild(pl);
413
+
414
+ const pd = document.createElement("div");
415
+ pd.id = "ai-plain";
416
+ pd.style.cssText = "font-size:10.5px;color:#c9d6df;line-height:1.55;border:1px dashed #26333f;border-radius:7px;padding:7px 9px;display:none";
417
+ _el["plain"] = pd;
418
+ _overlay.appendChild(pd);
419
+
420
+ (ctx.container || document.body).appendChild(_overlay);
421
+ _paintOverlay();
422
+ }
423
+
424
+ function _applyPlain() {
425
+ const pd = _el["plain"];
426
+ if (!pd) return;
427
+ pd.style.display = _plain ? "block" : "none";
428
+ if (!_plain) return;
429
+ const acc = S.accRecovered != null ? S.accRecovered.toFixed(1) + "%" : "loading\u2026";
430
+ const ops = S.totalOps != null ? S.totalOps.toLocaleString() : "loading\u2026";
431
+ const nz = S.noiseSigma != null ? S.noiseSigma.toFixed(3) : "loading\u2026";
432
+ pd.innerHTML =
433
+ "<b>What this means:</b> Today a chip has to haul the model\u2019s attention \u201cmemory\u201d " +
434
+ "(the KV cache) out of storage and convert it back and forth through analog\u2194digital " +
435
+ "converters just to do the math \u2014 that shuttling is where most of the energy and time " +
436
+ "goes. <b>Analog in-memory computing</b> stores those numbers as tiny electrical charges " +
437
+ "and lets the math happen <i>inside the memory itself</i>: the query flows in as a voltage " +
438
+ "and the answer literally adds itself up along each wire. Because the storage is analog it " +
439
+ "is slightly imprecise (device noise, here <b>" + nz + "</b>), but a one-time <b>calibration</b> " +
440
+ "step rescales the results and recovers about <b>" + acc + "</b> of the lost accuracy. Skipping " +
441
+ "the conversions and the memory shuttling avoids roughly <b>" + ops + "</b> operations at this " +
442
+ "toy scale. <b>Important honesty note:</b> the huge energy (up to ~100,000\u00d7) and latency " +
443
+ "(up to ~100\u00d7) savings are the <b>research paper\u2019s published claim</b> for real analog " +
444
+ "hardware \u2014 they are <b>NOT measured on real hardware here and NOT a measured SZL result</b>. " +
445
+ "This view is a <b>MODELED</b> deterministic simulation running on an ordinary digital CPU, " +
446
+ "not a run of the actual analog chip.";
447
+ }
448
+
449
+ function _tok(s) {
450
+ if (s === "live") return null;
451
+ if (s === "missing") return "NO-LIVE-DATA";
452
+ if (s === "degraded") return "DEGRADED";
453
+ if (s === "error") return "OFFLINE";
454
+ return "\u2026";
455
+ }
456
+
457
+ function fx(v, d) { return typeof v === "number" ? v.toFixed(d) : "\u2014"; }
458
+ function _set(id, v) { if (_el[id]) _el[id].textContent = v; }
459
+
460
+ function _paintOverlay() {
461
+ const t = _tok(S.state);
462
+ _set("ai-seqlen", t || (S.seqLen != null ? S.seqLen.toLocaleString() : "\u2014"));
463
+ _set("ai-dim", t || (S.dim != null ? String(S.dim) : "\u2014"));
464
+ _set("ai-noise", t || fx(S.noiseSigma, 3));
465
+ _set("ai-anamse", t || fx(S.analogMse, 6));
466
+ _set("ai-calmse", t || fx(S.calibMse, 6));
467
+ _set("ai-acc", t || (S.accRecovered != null ? S.accRecovered.toFixed(2) + "%" : "\u2014"));
468
+ _set("ai-ops", t || (S.totalOps != null ? S.totalOps.toLocaleString() : "\u2014"));
469
+ // energy/latency figures are the PAPER's claim, NOT a measured SZL result.
470
+ _set("ai-energy", t || (S.energyClaim != null ? S.energyClaim : "paper\u2019s claim, not measured SZL"));
471
+ _set("ai-latency", t || (S.latencyClaim != null ? S.latencyClaim : "paper\u2019s claim, not measured SZL"));
472
+ // honesty label verbatim — never upgraded
473
+ _set("ai-label", t || (S.label || "MODELED"));
474
+ if (_plain) _applyPlain();
475
+ }
476
+
477
+ // =============================================================================
478
+ // unmount — clean up everything; must not affect other organs
479
+ // =============================================================================
480
+ export function unmount() {
481
+ _polls.forEach((p) => { try { p.stop(); } catch (_) {} }); _polls = [];
482
+ try { if (_overlay && _overlay.parentNode) _overlay.parentNode.removeChild(_overlay); } catch (_) {}
483
+ try {
484
+ if (_group && _stage) {
485
+ _group.traverse((o) => {
486
+ if (o.geometry && o.geometry.dispose) o.geometry.dispose();
487
+ if (o.material) {
488
+ const ms = Array.isArray(o.material) ? o.material : [o.material];
489
+ ms.forEach((m) => { if (m.dispose) m.dispose(); });
490
+ }
491
+ });
492
+ _stage.scene.remove(_group);
493
+ }
494
+ } catch (_) {}
495
+ _group = _overlay = null;
496
+ _floor = null; _crossbar = []; _crossLines = [];
497
+ _barsDig = []; _barsAna = []; _barsCal = []; _query = null;
498
+ _el = {}; _badge = null; _plain = false; _frameReg = false;
499
+ _stage = _THREE = _ctx = null;
500
+ S.label = S.seqLen = S.dim = S.noiseSigma = null;
501
+ S.analogMse = S.calibMse = S.calibGain = S.accRecovered = null;
502
+ S.adcDacOps = S.memMoveOps = S.totalOps = null;
503
+ S.energyClaim = S.latencyClaim = null;
504
+ S.digScores = S.anaScores = S.calScores = null;
505
+ S.state = "init";
506
+ }
507
+
508
+ export default { id: ID, title: TITLE, endpoints: [EP], mount, unmount };
static/3d/surfaces/hrm.js ADDED
@@ -0,0 +1,497 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11
3
+ //
4
+ // surfaces/hrm.js — HIERARCHICAL REASONING MODEL (HRM) organ for the
5
+ // holographic frontier ring. Renders the two-timescale H-slow / L-fast control
6
+ // loop solving a toy mini-Sudoku Latin-square grid: a live 3D grid whose cells
7
+ // fill in as the FAST low-level executor (L) propagates local constraints and
8
+ // the SLOW high-level planner (H) advances an abstract-plan bar once per tick.
9
+ // Live snapshot comes from /api/killinchu/v1/hrm/solve.
10
+ //
11
+ // >>> HONESTY IS THE POINT OF THIS ORGAN <<<
12
+ // Per the ARC Prize independent analysis (arcprize.org/blog/hrm-analysis),
13
+ // the H/L hierarchy is NOT the dominant driver of HRM's headline results — a
14
+ // parameter-matched single-module Transformer came within ~5pp. So this
15
+ // surface renders the H/L result BESIDE a size-matched FLAT single-module
16
+ // baseline (same total update budget) and states the caveat plainly in the
17
+ // "what this means" copy. It does NOT repeat the paper's stronger framing.
18
+ //
19
+ // Surface export shape (mirrors mor.js / specdecode.js exactly):
20
+ // export default { id, title, endpoints, mount(ctx), unmount() }
21
+ // ctx = { stage, container, live, label, THREE, szl3d }
22
+ //
23
+ // DATA SHOWN (all from live endpoint):
24
+ // n, h_ticks, l_steps, clues, empty_start, hierarchical{solved,h_ticks_used,
25
+ // l_updates_total,guided_placements,h_plan_trace[],filled_trace[]},
26
+ // flat_baseline{solved,refine_rounds,l_updates_total,guided_placements},
27
+ // hierarchy_edge{both_solved,hier_updates_total,flat_updates_total,
28
+ // l_updates_delta,updates_ratio,verdict}, final_grid[][], solution_grid[][],
29
+ // caveat
30
+ //
31
+ // LEADERS ADOPTED & CITED (clean-room; NOT claimed as SZL's own):
32
+ // Hierarchical Reasoning Model (two-timescale H/L architecture modeled here):
33
+ // Wang et al. 2025, arXiv:2506.21734 https://arxiv.org/abs/2506.21734
34
+ // Official HRM code (reference only): github.com/sapientinc/HRM
35
+ // ARC Prize independent analysis (the honesty caveat source):
36
+ // https://arcprize.org/blog/hrm-analysis
37
+ // ARC Prize analysis code (reference only):
38
+ // github.com/arcprize/hierarchical-reasoning-model-analysis
39
+ //
40
+ // HONESTY LABELS: MODELED (deterministic re-implementation of the H/L control
41
+ // loop on a toy grid; NOT the HRM network; NEVER-CLAIMED-AS production). Read
42
+ // verbatim from JSON; never upgraded here. The endpoint puts the label at the
43
+ // TOP LEVEL of its JSON response (j.label); we read that (with a defensive
44
+ // nested payload.label fallback) and display it as-is.
45
+ // COLOURS: lattice-blue 0x5b8dee (empty / shallow), violet-blue 0x8a6bff
46
+ // (guided / H-planner accent), proof-teal 0x3af4c8 (solved cell / HUD
47
+ // accent), greys (degraded / no-live-data). Purple BANNED as UI/background.
48
+ // 0 RUNTIME CDN. Vendored three.js via ctx.THREE (page importmap).
49
+ // DOCTRINE v11: degrades gracefully (grey) on 404/error; honesty label still
50
+ // shown. Nothing here is in the locked-8. Λ stays Conjecture 1. Trust never 100%.
51
+
52
+ const ID = "hrm";
53
+ const TITLE = "Hierarchical Reasoning Model · H-slow / L-fast (live)";
54
+
55
+ // Endpoint is hosted on the dedicated killinchu Space (isolated compute), reached
56
+ // cross-origin (killinchu returns access-control-allow-origin: https://a-11-oy.com).
57
+ // This keeps the HRM organ's rebuilds/faults isolated from the flagship.
58
+ const EP = "https://szlholdings-killinchu.hf.space/api/killinchu/v1/hrm/solve?seed=42&n=4&h_ticks=12&l_steps=8";
59
+
60
+ // data-viz hues — purple BANNED.
61
+ const C_EMPTY = 0x5b8dee; // lattice-blue (empty / freshly-considered cell)
62
+ const C_GUIDED = 0x8a6bff; // violet-blue (H-planner top-down guided placement)
63
+ const C_SOLVED = 0x3af4c8; // proof-teal (filled/solved cell / HUD accent)
64
+ const C_DIM = 0x42505d; // grey (degraded / no-live-data)
65
+ const C_GRID = 0x1b3a44; // floor / link colour
66
+
67
+ // grid layout geometry
68
+ const MAX_N = 9; // largest grid side we pre-allocate cells for
69
+ const CELL = 1.15; // world-units between grid cells
70
+ const MAX_CELLS = MAX_N * MAX_N;
71
+
72
+ let _stage = null, _THREE = null, _ctx = null, _group = null, _overlay = null;
73
+ let _frameReg = false, _polls = [], _el = {}, _badge = null;
74
+ let _plain = false;
75
+
76
+ // geometry handles
77
+ let _floor = null;
78
+ let _cellMesh = []; // Array<THREE.Mesh> — one per grid cell (n×n active subset)
79
+ let _planBar = null; // THREE.Mesh — H-slow abstract-plan progress bar
80
+ let _flatBar = null; // THREE.Mesh — flat-baseline progress bar (honest ablation)
81
+ let _marker = null; // THREE.Mesh — HUD "converged" pulsing marker
82
+
83
+ // live state
84
+ const S = {
85
+ label: null,
86
+ n: null, // grid side
87
+ hTicks: null, // h_ticks (budget)
88
+ lSteps: null, // l_steps
89
+ clues: null, // clues
90
+ emptyStart: null, // empty_start
91
+ hier: null, // hierarchical{...}
92
+ flat: null, // flat_baseline{...}
93
+ edge: null, // hierarchy_edge{...}
94
+ finalGrid: null, // final_grid[][]
95
+ caveat: null, // caveat string
96
+ state: "init",
97
+ };
98
+
99
+ // =============================================================================
100
+ // mount(ctx)
101
+ // =============================================================================
102
+ export function mount(ctx) {
103
+ _ctx = ctx; _stage = ctx.stage; _THREE = ctx.THREE;
104
+ _group = new _THREE.Group();
105
+ _stage.scene.add(_group);
106
+ _stage.camera.position.set(0, 9, 16);
107
+ try { if (_stage.controls && _stage.controls.target) { _stage.controls.target.set(0, 1, 0); _stage.controls.update(); } } catch (_) {}
108
+ try { _stage.setBloom(true); } catch (_) {}
109
+
110
+ _buildFloor();
111
+ _buildGrid();
112
+ _buildBars();
113
+ _buildMarker();
114
+
115
+ if (!_frameReg) { _stage.onFrame(_onFrame); _frameReg = true; }
116
+
117
+ _badge = ctx.live.createBadge();
118
+ _polls.push(ctx.live.poll(EP, 5000, _onHrm, { badge: _badge, onState: (m) => { S.state = m.state; _paintOverlay(); _updateScene(); } }));
119
+
120
+ _buildOverlay();
121
+ return { id: ID, started: true };
122
+ }
123
+
124
+ // =============================================================================
125
+ // builders
126
+ // =============================================================================
127
+ function _buildFloor() {
128
+ const THREE = _THREE;
129
+ const grid = new THREE.GridHelper(30, 30, C_GRID, 0x0f2027);
130
+ grid.material.opacity = 0.18; grid.material.transparent = true; grid.position.y = -0.01;
131
+ _group.add(grid);
132
+ _floor = grid;
133
+ }
134
+
135
+ // Pre-allocate MAX_N×MAX_N cell meshes; we position/show only the active n×n
136
+ // subset per poll (no geometry churn). Each cell is a small tile that rises &
137
+ // recolours as it gets filled by the L-executor / H-planner.
138
+ function _buildGrid() {
139
+ const THREE = _THREE;
140
+ const cellGeo = new THREE.BoxGeometry(CELL * 0.8, 0.5, CELL * 0.8);
141
+ for (let i = 0; i < MAX_CELLS; i++) {
142
+ const mesh = new THREE.Mesh(
143
+ cellGeo,
144
+ new THREE.MeshStandardMaterial({ color: C_DIM, emissive: C_DIM, emissiveIntensity: 0.12, transparent: true, opacity: 0.0 }),
145
+ );
146
+ mesh.visible = false;
147
+ _group.add(mesh);
148
+ _cellMesh.push(mesh);
149
+ }
150
+ }
151
+
152
+ // Two upright progress bars behind the grid: the H-slow abstract-plan bar
153
+ // (proof-teal) and the size-matched FLAT baseline bar (violet-blue). Showing
154
+ // them side by side is the honest ablation — they end up nearly equal.
155
+ function _buildBars() {
156
+ const THREE = _THREE;
157
+ const barGeo = new THREE.BoxGeometry(0.7, 1.0, 0.7);
158
+ _planBar = new THREE.Mesh(
159
+ barGeo,
160
+ new THREE.MeshStandardMaterial({ color: C_SOLVED, emissive: C_SOLVED, emissiveIntensity: 0.35, transparent: true, opacity: 0.0 }),
161
+ );
162
+ _planBar.position.set(-1.1, 0.02, -(MAX_N * CELL * 0.5) - 1.6);
163
+ _planBar.scale.y = 0.05;
164
+ _group.add(_planBar);
165
+
166
+ _flatBar = new THREE.Mesh(
167
+ barGeo,
168
+ new THREE.MeshStandardMaterial({ color: C_GUIDED, emissive: C_GUIDED, emissiveIntensity: 0.3, transparent: true, opacity: 0.0 }),
169
+ );
170
+ _flatBar.position.set(1.1, 0.02, -(MAX_N * CELL * 0.5) - 1.6);
171
+ _flatBar.scale.y = 0.05;
172
+ _group.add(_flatBar);
173
+ }
174
+
175
+ function _buildMarker() {
176
+ const THREE = _THREE;
177
+ _marker = new THREE.Mesh(
178
+ new THREE.IcosahedronGeometry(0.30, 1),
179
+ new THREE.MeshStandardMaterial({ color: C_SOLVED, emissive: C_SOLVED, emissiveIntensity: 0.5, wireframe: true, transparent: true, opacity: 0.85 }),
180
+ );
181
+ _marker.position.set(0, 4.0, 0);
182
+ _group.add(_marker);
183
+ }
184
+
185
+ // =============================================================================
186
+ // live data handler
187
+ // =============================================================================
188
+ function _onHrm(j) {
189
+ // read honesty label VERBATIM — never upgrade. Endpoint puts label at the
190
+ // TOP LEVEL of the JSON (this module's own response shape), so read j.label;
191
+ // fall back to a nested payload.label defensively in case of a wrapper.
192
+ const rawLabel = (j && typeof j.label === "string") ? j.label
193
+ : (j && j.payload && typeof j.payload.label === "string") ? j.payload.label
194
+ : "MODELED";
195
+ const src = (j && j.payload && typeof j.payload === "object") ? j.payload : (j || {});
196
+
197
+ S.label = String(rawLabel).toUpperCase();
198
+ S.n = typeof src.n === "number" ? src.n : null;
199
+ S.hTicks = typeof src.h_ticks === "number" ? src.h_ticks : null;
200
+ S.lSteps = typeof src.l_steps === "number" ? src.l_steps : null;
201
+ S.clues = typeof src.clues === "number" ? src.clues : null;
202
+ S.emptyStart = typeof src.empty_start === "number" ? src.empty_start : null;
203
+ S.hier = (src.hierarchical && typeof src.hierarchical === "object") ? src.hierarchical : null;
204
+ S.flat = (src.flat_baseline && typeof src.flat_baseline === "object") ? src.flat_baseline : null;
205
+ S.edge = (src.hierarchy_edge && typeof src.hierarchy_edge === "object") ? src.hierarchy_edge : null;
206
+ S.finalGrid = Array.isArray(src.final_grid) ? src.final_grid : null;
207
+ S.caveat = typeof src.caveat === "string" ? src.caveat : null;
208
+
209
+ _updateScene();
210
+ _paintOverlay();
211
+ }
212
+
213
+ // =============================================================================
214
+ // geometry updater — drives the grid + progress bars from live data
215
+ // =============================================================================
216
+ function _updateScene() {
217
+ const live = S.state === "live";
218
+ const n = live && S.n ? Math.min(S.n, MAX_N) : 0;
219
+ const grid = live && S.finalGrid ? S.finalGrid : null;
220
+
221
+ // --- solved-grid tiles ---
222
+ const x0 = -(n - 1) * CELL * 0.5;
223
+ const z0 = -(n - 1) * CELL * 0.5;
224
+ for (let i = 0; i < MAX_CELLS; i++) {
225
+ const mesh = _cellMesh[i];
226
+ if (!live || n <= 0 || i >= n * n) { mesh.visible = false; continue; }
227
+ const r = (i / n) | 0;
228
+ const c = i % n;
229
+ mesh.visible = true;
230
+ mesh.position.set(x0 + c * CELL, 0.25, z0 + r * CELL);
231
+ const filled = grid && grid[r] && typeof grid[r][c] === "number" && grid[r][c] !== 0;
232
+ // solved cells glow proof-teal and rise; unfilled cells stay low lattice-blue
233
+ const color = filled ? C_SOLVED : C_EMPTY;
234
+ mesh.material.color.setHex(color);
235
+ mesh.material.emissive.setHex(color);
236
+ mesh.material.emissiveIntensity = filled ? 0.5 : 0.16;
237
+ mesh.material.opacity = filled ? 0.95 : 0.4;
238
+ const h = filled ? 0.9 : 0.25;
239
+ mesh.scale.y = h;
240
+ mesh.position.y = h * 0.5;
241
+ }
242
+
243
+ // --- H-slow plan bar (proof-teal): final abstract-plan value (fraction filled) ---
244
+ if (_planBar) {
245
+ const trace = live && S.hier && Array.isArray(S.hier.h_plan_trace) ? S.hier.h_plan_trace : null;
246
+ const plan = trace && trace.length ? trace[trace.length - 1] : (live && S.hier && S.hier.solved ? 1 : 0);
247
+ if (live && plan != null) {
248
+ _planBar.material.color.setHex(C_SOLVED); _planBar.material.emissive.setHex(C_SOLVED);
249
+ _planBar.material.opacity = 0.9;
250
+ const h = 0.15 + plan * 3.4; _planBar.scale.y = h; _planBar.position.y = h * 0.5;
251
+ } else {
252
+ _planBar.material.color.setHex(C_DIM); _planBar.material.emissive.setHex(C_DIM);
253
+ _planBar.material.opacity = 0.3; _planBar.scale.y = 0.05; _planBar.position.y = 0.02;
254
+ }
255
+ }
256
+
257
+ // --- FLAT baseline bar (violet-blue): honest ablation, ends up near-equal ---
258
+ if (_flatBar) {
259
+ const flatSolved = live && S.flat && S.flat.solved;
260
+ const flatFrac = flatSolved ? 1 : (live && S.emptyStart != null && S.n != null && S.flat
261
+ ? Math.max(0, Math.min(1, (S.n * S.n - (S.emptyStart - (S.flat.l_updates_total || 0))) / (S.n * S.n)))
262
+ : 0);
263
+ if (live) {
264
+ _flatBar.material.color.setHex(C_GUIDED); _flatBar.material.emissive.setHex(C_GUIDED);
265
+ _flatBar.material.opacity = 0.9;
266
+ const h = 0.15 + flatFrac * 3.4; _flatBar.scale.y = h; _flatBar.position.y = h * 0.5;
267
+ } else {
268
+ _flatBar.material.color.setHex(C_DIM); _flatBar.material.emissive.setHex(C_DIM);
269
+ _flatBar.material.opacity = 0.3; _flatBar.scale.y = 0.05; _flatBar.position.y = 0.02;
270
+ }
271
+ }
272
+
273
+ // --- converged marker ---
274
+ if (_marker) {
275
+ if (live && S.hier && S.hier.solved) {
276
+ _marker.material.color.setHex(C_SOLVED); _marker.material.emissive.setHex(C_SOLVED);
277
+ _marker.material.opacity = 0.85; _marker.scale.setScalar(1.0);
278
+ } else {
279
+ _marker.material.color.setHex(C_DIM); _marker.material.emissive.setHex(C_DIM);
280
+ _marker.material.opacity = 0.3; _marker.scale.setScalar(0.7);
281
+ }
282
+ }
283
+ }
284
+
285
+ // =============================================================================
286
+ // per-frame animation
287
+ // =============================================================================
288
+ function _onFrame() {
289
+ const t = performance.now();
290
+ if (_group) _group.rotation.y = Math.sin(t * 0.00008) * 0.16;
291
+ if (_marker) {
292
+ _marker.rotation.y += 0.022;
293
+ _marker.rotation.x += 0.011;
294
+ const pulse = 1.0 + 0.12 * Math.sin(t * 0.004);
295
+ _marker.scale.setScalar((S.hier && S.hier.solved ? 1.0 : 0.7) * pulse);
296
+ }
297
+ }
298
+
299
+ // =============================================================================
300
+ // overlay
301
+ // =============================================================================
302
+ function _buildOverlay() {
303
+ const ctx = _ctx;
304
+ _overlay = document.createElement("div");
305
+ Object.assign(_overlay.style, {
306
+ position: "absolute", left: "14px", top: "14px", zIndex: "6",
307
+ display: "flex", flexDirection: "column", gap: "8px",
308
+ maxWidth: "min(94%,470px)",
309
+ font: "12px ui-sans-serif,system-ui,Segoe UI,Roboto,Arial",
310
+ color: "#eef3f6",
311
+ });
312
+
313
+ const h = document.createElement("div");
314
+ h.style.cssText = "font:600 13px ui-sans-serif,system-ui;letter-spacing:.4px";
315
+ h.textContent = TITLE;
316
+ _overlay.appendChild(h);
317
+
318
+ const sub = document.createElement("div");
319
+ sub.style.cssText = "color:#9fb1bf;font-size:11px;line-height:1.55";
320
+ sub.innerHTML =
321
+ 'Two interdependent recurrent modules at different timescales solve a mini-Sudoku: a ' +
322
+ '<b>fast low-level executor (L)</b> propagates local cell constraints to convergence, and a ' +
323
+ '<b>slow high-level planner (H)</b> advances an abstract plan once per tick and nudges the ' +
324
+ 'executor when it stalls. Cells glow <b>teal</b> as they solve. ' +
325
+ 'Honesty label <b>MODELED</b> (deterministic control-loop simulation on a toy grid; NOT the HRM network). 0 runtime CDN.';
326
+ _overlay.appendChild(sub);
327
+
328
+ // explicit honesty-caveat banner (the ARC Prize finding) — always shown
329
+ const dist = document.createElement("div");
330
+ dist.style.cssText = "font-size:10.5px;color:#c9d6df;line-height:1.5;border:1px solid #26333f;border-radius:7px;padding:7px 9px;background:#0a1117";
331
+ dist.innerHTML =
332
+ '<b style="color:#3af4c8">Honesty caveat.</b> ' +
333
+ 'Independent analysis by the <b>ARC Prize team</b> (arcprize.org/blog/hrm-analysis) found the ' +
334
+ 'H/L <b>hierarchy is NOT the dominant driver</b> of HRM\u2019s headline results \u2014 a ' +
335
+ 'parameter-matched <i>single-module</i> Transformer came within <b>~5 points</b>. The real ' +
336
+ 'drivers were an <b>outer refinement loop</b>, heavy <b>data augmentation</b>, and a per-task ' +
337
+ '<b>puzzle-embedding</b>. So this organ shows the H/L result <i>beside</i> a size-matched ' +
338
+ '<b>flat baseline</b> (violet bar) \u2014 they end up nearly equal. We do <i>not</i> overclaim the hierarchy.';
339
+ _overlay.appendChild(dist);
340
+
341
+ const brow = document.createElement("div");
342
+ brow.style.cssText = "display:flex;gap:8px;align-items:center;flex-wrap:wrap";
343
+ if (_badge && _badge.el) brow.appendChild(_badge.el);
344
+ _overlay.appendChild(brow);
345
+
346
+ const card = document.createElement("div");
347
+ card.style.cssText = "background:#0a1117;border:1px solid #1d2a36;border-radius:9px;padding:9px 10px;display:flex;flex-direction:column;gap:6px";
348
+
349
+ const chead = document.createElement("div");
350
+ chead.style.cssText = "display:flex;align-items:center;gap:8px;flex-wrap:wrap";
351
+ const dot = document.createElement("span");
352
+ dot.style.cssText = "width:9px;height:9px;border-radius:50%;background:#3af4c8;box-shadow:0 0 7px #3af4c8";
353
+ const nm = document.createElement("b");
354
+ nm.style.cssText = "font-size:12px;color:#3af4c8;letter-spacing:.3px";
355
+ nm.textContent = "hierarchical reasoning model";
356
+ chead.appendChild(dot); chead.appendChild(nm);
357
+ card.appendChild(chead);
358
+
359
+ const grid = document.createElement("div");
360
+ grid.style.cssText = "display:grid;grid-template-columns:1fr;gap:4px";
361
+
362
+ function kpiRow(id, label) {
363
+ const r = document.createElement("div");
364
+ r.style.cssText = "display:flex;justify-content:space-between;gap:10px;font-size:11px";
365
+ const l = document.createElement("span"); l.style.cssText = "color:#9fb1bf"; l.textContent = label;
366
+ const v = document.createElement("b");
367
+ v.id = id;
368
+ v.style.cssText = "font-variant-numeric:tabular-nums;color:#eef3f6;text-align:right;max-width:58%";
369
+ v.textContent = "\u2014";
370
+ _el[id] = v;
371
+ r.appendChild(l); r.appendChild(v); return r;
372
+ }
373
+
374
+ grid.appendChild(kpiRow("hrm-grid", "puzzle (mini-Sudoku n\u00d7n)"));
375
+ grid.appendChild(kpiRow("hrm-clues", "clues / empty at start"));
376
+ grid.appendChild(kpiRow("hrm-hsolved", "H/L hierarchical: solved?"));
377
+ grid.appendChild(kpiRow("hrm-hticks", "H-slow ticks used"));
378
+ grid.appendChild(kpiRow("hrm-hupdates", "H/L total updates \u2014 MODELED"));
379
+ grid.appendChild(kpiRow("hrm-fsolved", "flat baseline (size-matched): solved?"));
380
+ grid.appendChild(kpiRow("hrm-fupdates", "flat total updates \u2014 MODELED"));
381
+ grid.appendChild(kpiRow("hrm-ratio", "updates ratio (hier / flat)"));
382
+ grid.appendChild(kpiRow("hrm-verdict", "honest verdict"));
383
+ grid.appendChild(kpiRow("hrm-label", "honesty label"));
384
+ card.appendChild(grid);
385
+
386
+ const fn = document.createElement("div");
387
+ fn.style.cssText = "font-size:9.5px;color:#6b7a86;line-height:1.5";
388
+ fn.textContent = "Wang et al. arXiv:2506.21734 (HRM) \u00b7 github.com/sapientinc/HRM \u00b7 ARC Prize analysis arcprize.org/blog/hrm-analysis. MODELED \u00b7 not claimed-as.";
389
+ card.appendChild(fn);
390
+ _overlay.appendChild(card);
391
+
392
+ const pl = document.createElement("button");
393
+ pl.textContent = "\u25d1 what this means";
394
+ pl.title = "Toggle plain-language explanation for investors & consumers.";
395
+ pl.style.cssText = "font:11px ui-monospace,monospace;padding:5px 11px;border-radius:7px;border:1px solid #3af4c8;background:#08140f;color:#3af4c8;cursor:pointer;width:fit-content";
396
+ pl.addEventListener("click", () => {
397
+ _plain = !_plain;
398
+ pl.style.background = _plain ? "#0f2a20" : "#08140f";
399
+ _applyPlain();
400
+ });
401
+ _overlay.appendChild(pl);
402
+
403
+ const pd = document.createElement("div");
404
+ pd.id = "hrm-plain";
405
+ pd.style.cssText = "font-size:10.5px;color:#c9d6df;line-height:1.55;border:1px dashed #26333f;border-radius:7px;padding:7px 9px;display:none";
406
+ _el["plain"] = pd;
407
+ _overlay.appendChild(pd);
408
+
409
+ (ctx.container || document.body).appendChild(_overlay);
410
+ _paintOverlay();
411
+ }
412
+
413
+ function _applyPlain() {
414
+ const pd = _el["plain"];
415
+ if (!pd) return;
416
+ pd.style.display = _plain ? "block" : "none";
417
+ if (!_plain) return;
418
+ const nn = S.n != null ? (S.n + "\u00d7" + S.n) : "small";
419
+ const hSolved = S.hier && S.hier.solved ? "yes" : "not yet";
420
+ const ratio = S.edge && S.edge.updates_ratio != null ? S.edge.updates_ratio.toFixed(2) : "\u2248 1";
421
+ const verdict = S.edge && typeof S.edge.verdict === "string" ? S.edge.verdict : null;
422
+ pd.innerHTML =
423
+ "<b>What this means:</b> A hard puzzle (here a " + nn + " mini-Sudoku) is solved by two " +
424
+ "cooperating parts of one model running at different speeds: a <b>fast \u201cworker\u201d</b> that " +
425
+ "fills in whatever cells are locally forced, and a <b>slow \u201cplanner\u201d</b> that steps back " +
426
+ "once in a while to see the big picture and unstick the worker. It reaches the answer in a " +
427
+ "single pass, without writing out its reasoning step-by-step (solved: " + hSolved + "). " +
428
+ "<b>But here is the honest part:</b> the independent <b>ARC Prize</b> team re-examined HRM and " +
429
+ "found this slow/fast <i>hierarchy is not actually the main reason it works</i> \u2014 an " +
430
+ "ordinary <i>single-module</i> model of the same size got within about <b>5 points</b>. The real " +
431
+ "gains came from repeatedly <b>refining</b> the answer, lots of <b>data augmentation</b>, and " +
432
+ "<b>memorizing each puzzle\u2019s identity</b>. To keep us honest, this view runs a size-matched " +
433
+ "<b>flat baseline</b> right next to the hierarchy: they use almost the same effort " +
434
+ "(updates ratio \u2248 <b>" + ratio + "</b>)" +
435
+ (verdict ? " \u2014 <i>" + verdict + "</i>" : "") + ". " +
436
+ "The hierarchy gives a <b>small, real</b> benefit, not the dominant one the paper implies. " +
437
+ "This whole view is a <b>MODELED</b> simulation of the control loop on a toy grid, not a run " +
438
+ "of the real 27M-parameter HRM network.";
439
+ }
440
+
441
+ function _tok(s) {
442
+ if (s === "live") return null;
443
+ if (s === "missing") return "NO-LIVE-DATA";
444
+ if (s === "degraded") return "DEGRADED";
445
+ if (s === "error") return "OFFLINE";
446
+ return "\u2026";
447
+ }
448
+
449
+ function _yn(v) { return v === true ? "yes" : v === false ? "no" : "\u2014"; }
450
+ function _set(id, v) { if (_el[id]) _el[id].textContent = v; }
451
+
452
+ function _paintOverlay() {
453
+ const t = _tok(S.state);
454
+ _set("hrm-grid", t || (S.n != null ? (S.n + "\u00d7" + S.n + " Latin square") : "\u2014"));
455
+ _set("hrm-clues", t || ((S.clues != null && S.emptyStart != null) ? (S.clues + " clues / " + S.emptyStart + " empty") : "\u2014"));
456
+ _set("hrm-hsolved", t || (S.hier ? _yn(S.hier.solved) : "\u2014"));
457
+ _set("hrm-hticks", t || (S.hier && S.hier.h_ticks_used != null ? String(S.hier.h_ticks_used) : "\u2014"));
458
+ _set("hrm-hupdates", t || (S.edge && S.edge.hier_updates_total != null ? String(S.edge.hier_updates_total) : "\u2014"));
459
+ _set("hrm-fsolved", t || (S.flat ? _yn(S.flat.solved) : "\u2014"));
460
+ _set("hrm-fupdates", t || (S.edge && S.edge.flat_updates_total != null ? String(S.edge.flat_updates_total) : "\u2014"));
461
+ _set("hrm-ratio", t || (S.edge && S.edge.updates_ratio != null ? S.edge.updates_ratio.toFixed(3) : "\u2014"));
462
+ _set("hrm-verdict", t || (S.edge && typeof S.edge.verdict === "string"
463
+ ? (S.edge.verdict.length > 64 ? S.edge.verdict.slice(0, 61) + "\u2026" : S.edge.verdict)
464
+ : "\u2014"));
465
+ // honesty label verbatim — never upgraded
466
+ _set("hrm-label", t || (S.label || "MODELED"));
467
+ if (_plain) _applyPlain();
468
+ }
469
+
470
+ // =============================================================================
471
+ // unmount — clean up everything; must not affect other organs
472
+ // =============================================================================
473
+ export function unmount() {
474
+ _polls.forEach((p) => { try { p.stop(); } catch (_) {} }); _polls = [];
475
+ try { if (_overlay && _overlay.parentNode) _overlay.parentNode.removeChild(_overlay); } catch (_) {}
476
+ try {
477
+ if (_group && _stage) {
478
+ _group.traverse((o) => {
479
+ if (o.geometry && o.geometry.dispose) o.geometry.dispose();
480
+ if (o.material) {
481
+ const ms = Array.isArray(o.material) ? o.material : [o.material];
482
+ ms.forEach((m) => { if (m.dispose) m.dispose(); });
483
+ }
484
+ });
485
+ _stage.scene.remove(_group);
486
+ }
487
+ } catch (_) {}
488
+ _group = _overlay = null;
489
+ _floor = null; _cellMesh = []; _planBar = null; _flatBar = null; _marker = null;
490
+ _el = {}; _badge = null; _plain = false; _frameReg = false;
491
+ _stage = _THREE = _ctx = null;
492
+ S.label = S.n = S.hTicks = S.lSteps = S.clues = S.emptyStart = null;
493
+ S.hier = S.flat = S.edge = S.finalGrid = S.caveat = null;
494
+ S.state = "init";
495
+ }
496
+
497
+ export default { id: ID, title: TITLE, endpoints: [EP], mount, unmount };
static/3d/surfaces/pfield.js ADDED
@@ -0,0 +1,565 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11
3
+ //
4
+ // surfaces/pfield.js — PFIELD (Pressure-Field Stigmergic Multi-Agent
5
+ // Coordination) organ for the holographic frontier ring. Renders the shared
6
+ // constraint-grid ARTIFACT as a lattice of cells whose height/glow encodes the
7
+ // live PRESSURE field: high-violation cells rise as lattice-blue pillars, and
8
+ // as the N pressure-field agents implicitly de-conflict (no messages), the
9
+ // pillars collapse to a flat proof-teal solved plane. A side-by-side HUD sweeps
10
+ // agent counts 2..32 comparing pfield vs sequential vs hierarchical
11
+ // (solve-rate, steps-to-converge, coordination messages), and a decay-ablation
12
+ // readout shows the ~49x pressure runaway when temporal decay is disabled. All
13
+ // numbers come from the live snapshot at /api/killinchu/v1/pfield/coordinate.
14
+ // Honesty label "MODELED" is read VERBATIM from the JSON and displayed as-is;
15
+ // it is never upgraded.
16
+ //
17
+ // Surface export shape (mirrors grpo.js / goat.js exactly):
18
+ // export default { id, title, endpoints, mount(ctx), unmount() }
19
+ // ctx = { stage, container, live, label, THREE, szl3d }
20
+ //
21
+ // DATA SHOWN (all from live endpoint):
22
+ // n_agents, grid, decay, steps, pfield{solved,steps_to_converge,
23
+ // final_violations,peak_pressure,messages,violation_trajectory[],
24
+ // pressure_trajectory[]}, baselines{sequential,hierarchical}, sweep[],
25
+ // ablation{peak_pressure_decay,peak_pressure_no_decay,pressure_runaway_x},
26
+ // matches_hierarchical
27
+ //
28
+ // LEADERS ADOPTED & CITED (clean-room; NOT claimed as SZL's own):
29
+ // Pressure-field stigmergic coordination + temporal decay (simulated here,
30
+ // including the ~49x no-decay pressure runaway):
31
+ // Rodriguez 2026, "Emergent Coordination in Multi-Agent Systems via
32
+ // Pressure Fields and Temporal Decay", arXiv:2601.08129 (13 Jan 2026)
33
+ // https://arxiv.org/abs/2601.08129
34
+ // full text: https://arxiv.org/html/2601.08129v3
35
+ //
36
+ // HONESTY LABELS: MODELED (deterministic simulation of the pressure-field /
37
+ // temporal-decay coordination arithmetic; NOT real LLM agents; NO real
38
+ // message passing; NEVER-CLAIMED-AS a real multi-agent deployment). Read
39
+ // verbatim from JSON; never upgraded here.
40
+ // COLOURS: lattice-blue 0x5b8dee (pressure pillars / artifact grid), violet-blue
41
+ // 0x8a6bff (temporal-decay / ablation trace), proof-teal 0x3af4c8 (solved
42
+ // cells / pfield accent), greys (degraded / no-live-data). Purple BANNED as
43
+ // UI/background.
44
+ // 0 RUNTIME CDN. three.js via ctx.THREE (page importmap / vendored).
45
+ // DOCTRINE v11: degrades gracefully (grey) on 404/error; honesty label still shown.
46
+ // Nothing here is in the locked-8. Λ stays Conjecture 1. Trust never 100%.
47
+
48
+ const ID = "pfield";
49
+ const TITLE = "PFIELD · Pressure-Field Stigmergic Coordination (live)";
50
+
51
+ // Endpoint is hosted on the dedicated killinchu Space (isolated compute),
52
+ // reached cross-origin (killinchu returns access-control-allow-origin for the
53
+ // flagship). This keeps the pfield organ's rebuilds/faults isolated.
54
+ const EP = "https://szlholdings-killinchu.hf.space/api/killinchu/v1/pfield/coordinate?seed=42&n_agents=8&grid=6&decay=0.8&steps=200";
55
+
56
+ // data-viz hues — purple BANNED
57
+ const C_PRESS = 0x5b8dee; // lattice-blue (pressure pillars / artifact grid)
58
+ const C_SOLVED = 0x3af4c8; // proof-teal (solved cells / pfield accent)
59
+ const C_DECAY = 0x8a6bff; // violet-blue (temporal-decay / ablation trace)
60
+ const C_DIM = 0x42505d; // grey (degraded / no-live-data)
61
+ const C_GRID = 0x1b3a44; // floor / link colour
62
+
63
+ // layout geometry
64
+ const CELL_GAP = 1.05; // world-units between artifact cells
65
+ const MAX_SIDE = 12; // cap on grid side length rendered (n x n cells)
66
+ const PILLAR_W = 0.66; // cell pillar footprint
67
+ const PILLAR_MAXH = 4.0; // max pillar height at peak local pressure
68
+ const ABL_LEN = 6.0; // world-length of the ablation bar pair along X
69
+ const AGENT_ORBIT = 5.4; // radius agents orbit the artifact at (visual only)
70
+ const MAX_AGENTS = 32; // cap on agent motes rendered
71
+
72
+ let _stage = null, _THREE = null, _ctx = null, _group = null, _overlay = null;
73
+ let _frameReg = false, _polls = [], _el = {}, _badge = null;
74
+ let _plain = false;
75
+
76
+ // geometry handles
77
+ let _floor = null;
78
+ let _cells = []; // Array<THREE.Mesh> — artifact-cell pressure pillars (row-major)
79
+ let _cellSide = 0; // current rendered grid side length
80
+ let _agents = []; // Array<THREE.Mesh> — orbiting agent motes (visual)
81
+ let _ablDecay = null; // THREE.Mesh — decay-on peak bar (bounded)
82
+ let _ablNoDecay = null; // THREE.Mesh — decay-off peak bar (runaway)
83
+
84
+ // live state
85
+ const S = {
86
+ label: null,
87
+ nAgents: null, // n_agents
88
+ grid: null, // grid side length
89
+ decay: null, // decay
90
+ steps: null, // steps
91
+ solved: null, // pfield.solved
92
+ stepsConv: null, // pfield.steps_to_converge
93
+ finalViol: null, // pfield.final_violations
94
+ peakPress: null, // pfield.peak_pressure
95
+ messages: null, // pfield.messages (0 for stigmergic)
96
+ violTraj: null, // pfield.violation_trajectory[]
97
+ pressTraj: null, // pfield.pressure_trajectory[]
98
+ seqSolved: null, // baselines.sequential.solved
99
+ seqSteps: null, // baselines.sequential.steps_to_converge
100
+ hierSolved: null, // baselines.hierarchical.solved
101
+ hierSteps: null, // baselines.hierarchical.steps_to_converge
102
+ hierMsgs: null, // baselines.hierarchical.messages
103
+ sweep: null, // sweep[]
104
+ ablDecayPk: null, // ablation.peak_pressure_decay
105
+ ablNoDecayPk: null, // ablation.peak_pressure_no_decay
106
+ runawayX: null, // ablation.pressure_runaway_x
107
+ matchesHier: null, // matches_hierarchical
108
+ state: "init",
109
+ };
110
+
111
+ // =============================================================================
112
+ // mount(ctx)
113
+ // =============================================================================
114
+ export function mount(ctx) {
115
+ _ctx = ctx; _stage = ctx.stage; _THREE = ctx.THREE;
116
+ _group = new _THREE.Group();
117
+ _stage.scene.add(_group);
118
+ _stage.camera.position.set(0, 11, 19);
119
+ try { if (_stage.controls && _stage.controls.target) { _stage.controls.target.set(0, 1, 0); _stage.controls.update(); } } catch (_) {}
120
+ try { _stage.setBloom(true); } catch (_) {}
121
+
122
+ _buildFloor();
123
+ _buildCells(6); // pre-build a default 6x6 lattice; rebuilt on live data
124
+ _buildAgents();
125
+ _buildAblation();
126
+
127
+ if (!_frameReg) { _stage.onFrame(_onFrame); _frameReg = true; }
128
+
129
+ _badge = ctx.live.createBadge();
130
+ _polls.push(ctx.live.poll(EP, 5000, _onPfield, { badge: _badge, onState: (m) => { S.state = m.state; _updateScene(); _paintOverlay(); } }));
131
+
132
+ _buildOverlay();
133
+ return { id: ID, started: true };
134
+ }
135
+
136
+ // =============================================================================
137
+ // builders
138
+ // =============================================================================
139
+ function _buildFloor() {
140
+ const THREE = _THREE;
141
+ const grid = new THREE.GridHelper(44, 44, C_GRID, 0x0f2027);
142
+ grid.material.opacity = 0.18; grid.material.transparent = true; grid.position.y = -0.01;
143
+ _group.add(grid);
144
+ _floor = grid;
145
+ }
146
+
147
+ // The shared constraint-grid ARTIFACT: an n x n lattice of unit-footprint
148
+ // pillars. Each pillar's height/glow encodes that cell's live pressure. Rebuilt
149
+ // only when the grid side length changes (rare); heights/colours are toggled
150
+ // in-place per poll otherwise (no per-poll geometry churn).
151
+ function _buildCells(side) {
152
+ const THREE = _THREE;
153
+ _disposeCells();
154
+ _cellSide = Math.max(1, Math.min(side, MAX_SIDE));
155
+ const off = (_cellSide - 1) / 2;
156
+ const geo = new THREE.BoxGeometry(PILLAR_W, 1, PILLAR_W); // unit-height; scaled on update
157
+ for (let r = 0; r < _cellSide; r++) {
158
+ for (let c = 0; c < _cellSide; c++) {
159
+ const mesh = new THREE.Mesh(
160
+ geo,
161
+ new THREE.MeshStandardMaterial({ color: C_PRESS, emissive: C_PRESS, emissiveIntensity: 0.25, transparent: true, opacity: 0.85 }),
162
+ );
163
+ mesh.position.set((c - off) * CELL_GAP, 0.05, (r - off) * CELL_GAP);
164
+ mesh.scale.y = 0.1;
165
+ _group.add(mesh);
166
+ _cells.push(mesh);
167
+ }
168
+ }
169
+ }
170
+
171
+ // Orbiting agent motes — a purely-visual ring of N points circling the artifact
172
+ // to represent the N coordinating agents. They carry NO data (the endpoint
173
+ // transmits aggregates only); their count tracks n_agents.
174
+ function _buildAgents() {
175
+ const THREE = _THREE;
176
+ const geo = new THREE.SphereGeometry(0.14, 10, 10);
177
+ for (let i = 0; i < MAX_AGENTS; i++) {
178
+ const m = new THREE.Mesh(
179
+ geo,
180
+ new THREE.MeshStandardMaterial({ color: C_SOLVED, emissive: C_SOLVED, emissiveIntensity: 0.5, transparent: true, opacity: 0.0 }),
181
+ );
182
+ m.visible = false;
183
+ _group.add(m);
184
+ _agents.push(m);
185
+ }
186
+ }
187
+
188
+ // Decay ablation: two bars side by side above the artifact — decay-ON peak
189
+ // pressure (proof-teal, bounded) vs decay-OFF peak pressure (violet-blue,
190
+ // runaway). Their height ratio IS the pressure_runaway_x figure.
191
+ function _buildAblation() {
192
+ const THREE = _THREE;
193
+ const geo = new THREE.BoxGeometry(0.7, 1, 0.7);
194
+
195
+ _ablDecay = new THREE.Mesh(
196
+ geo,
197
+ new THREE.MeshStandardMaterial({ color: C_SOLVED, emissive: C_SOLVED, emissiveIntensity: 0.4, transparent: true, opacity: 0.0 }),
198
+ );
199
+ _ablDecay.position.set(-1.0, 0.001, -((MAX_SIDE / 2) * CELL_GAP + 2.2));
200
+ _group.add(_ablDecay);
201
+
202
+ _ablNoDecay = new THREE.Mesh(
203
+ geo,
204
+ new THREE.MeshStandardMaterial({ color: C_DECAY, emissive: C_DECAY, emissiveIntensity: 0.4, transparent: true, opacity: 0.0 }),
205
+ );
206
+ _ablNoDecay.position.set(1.0, 0.001, -((MAX_SIDE / 2) * CELL_GAP + 2.2));
207
+ _group.add(_ablNoDecay);
208
+ }
209
+
210
+ // =============================================================================
211
+ // live data handler
212
+ // =============================================================================
213
+ function _onPfield(j) {
214
+ // read honesty label VERBATIM — never upgrade. This module places the label
215
+ // at TOP LEVEL of the JSON (j.label); also tolerate a nested payload.label to
216
+ // match either module shape.
217
+ const rawLabel = (j && (j.label != null ? j.label : (j.payload && j.payload.label))) || "MODELED";
218
+ S.label = String(rawLabel).toUpperCase();
219
+
220
+ S.nAgents = typeof j.n_agents === "number" ? j.n_agents : null;
221
+ S.grid = typeof j.grid === "number" ? j.grid : null;
222
+ S.decay = typeof j.decay === "number" ? j.decay : null;
223
+ S.steps = typeof j.steps === "number" ? j.steps : null;
224
+
225
+ const pf = j.pfield || {};
226
+ S.solved = typeof pf.solved === "boolean" ? pf.solved : null;
227
+ S.stepsConv = typeof pf.steps_to_converge === "number" ? pf.steps_to_converge : null;
228
+ S.finalViol = typeof pf.final_violations === "number" ? pf.final_violations : null;
229
+ S.peakPress = typeof pf.peak_pressure === "number" ? pf.peak_pressure : null;
230
+ S.messages = typeof pf.messages === "number" ? pf.messages : null;
231
+ S.violTraj = Array.isArray(pf.violation_trajectory) ? pf.violation_trajectory : null;
232
+ S.pressTraj = Array.isArray(pf.pressure_trajectory) ? pf.pressure_trajectory : null;
233
+
234
+ const bl = j.baselines || {};
235
+ const seq = bl.sequential || {};
236
+ const hier = bl.hierarchical || {};
237
+ S.seqSolved = typeof seq.solved === "boolean" ? seq.solved : null;
238
+ S.seqSteps = typeof seq.steps_to_converge === "number" ? seq.steps_to_converge : null;
239
+ S.hierSolved = typeof hier.solved === "boolean" ? hier.solved : null;
240
+ S.hierSteps = typeof hier.steps_to_converge === "number" ? hier.steps_to_converge : null;
241
+ S.hierMsgs = typeof hier.messages === "number" ? hier.messages : null;
242
+
243
+ S.sweep = Array.isArray(j.sweep) ? j.sweep : null;
244
+
245
+ const ab = j.ablation || {};
246
+ S.ablDecayPk = typeof ab.peak_pressure_decay === "number" ? ab.peak_pressure_decay : null;
247
+ S.ablNoDecayPk = typeof ab.peak_pressure_no_decay === "number" ? ab.peak_pressure_no_decay : null;
248
+ S.runawayX = typeof ab.pressure_runaway_x === "number" ? ab.pressure_runaway_x : null;
249
+
250
+ S.matchesHier = typeof j.matches_hierarchical === "boolean" ? j.matches_hierarchical : null;
251
+
252
+ // rebuild the artifact lattice if the grid side length changed
253
+ if (S.grid != null && S.grid !== _cellSide) _buildCells(S.grid);
254
+
255
+ _updateScene();
256
+ _paintOverlay();
257
+ }
258
+
259
+ // =============================================================================
260
+ // geometry updater — drives the artifact lattice + agents + ablation bars
261
+ // =============================================================================
262
+ function _updateScene() {
263
+ const live = S.state === "live";
264
+
265
+ // ARTIFACT lattice: pillar height/colour encodes the pressure landscape.
266
+ // The endpoint transmits aggregate traces (not the full per-cell field), so
267
+ // we render an honest proxy: distribute the current total pressure /
268
+ // remaining violations across the lattice as a decaying radial gradient, and
269
+ // flip cells to the solved colour once the run has converged.
270
+ const nCells = _cells.length;
271
+ const totalPeak = live && S.peakPress != null ? S.peakPress : 0;
272
+ const finalViol = live && S.finalViol != null ? S.finalViol : null;
273
+ const solved = live && S.solved === true;
274
+
275
+ for (let i = 0; i < nCells; i++) {
276
+ const mesh = _cells[i];
277
+ if (!live) {
278
+ mesh.material.color.setHex(C_DIM);
279
+ mesh.material.emissive.setHex(C_DIM);
280
+ mesh.material.emissiveIntensity = 0.06;
281
+ mesh.material.opacity = 0.3;
282
+ mesh.scale.y = 0.1;
283
+ mesh.position.y = 0.05;
284
+ continue;
285
+ }
286
+ // radial pressure proxy: cells nearer the centre carry more residual
287
+ // pressure (deterministic layout, honest aggregate — not a faked per-cell
288
+ // reading). When solved, all pillars flatten to the proof-teal plane.
289
+ const side = _cellSide || 1;
290
+ const r = Math.floor(i / side), c = i % side;
291
+ const off = (side - 1) / 2;
292
+ const dist = Math.sqrt((r - off) * (r - off) + (c - off) * (c - off)) / (Math.max(1, off) * 1.4142);
293
+ const radial = 1.0 - Math.min(1, dist); // 1 at centre, 0 at corners
294
+ const pressNorm = totalPeak > 0 ? Math.min(1, totalPeak / (nCells * 8)) : 0;
295
+ let h;
296
+ if (solved) {
297
+ h = 0.12;
298
+ } else {
299
+ h = 0.12 + radial * pressNorm * PILLAR_MAXH;
300
+ }
301
+ mesh.scale.y = Math.max(0.08, h);
302
+ mesh.position.y = mesh.scale.y / 2;
303
+
304
+ const color = solved ? C_SOLVED : C_PRESS;
305
+ mesh.material.color.setHex(color);
306
+ mesh.material.emissive.setHex(color);
307
+ mesh.material.emissiveIntensity = solved ? 0.45 : 0.2 + 0.5 * radial * pressNorm;
308
+ mesh.material.opacity = 0.9;
309
+ }
310
+
311
+ // agent motes: show n_agents of them orbiting; teal when solved, blue while
312
+ // still coordinating; grey/hidden when not live.
313
+ const na = live && S.nAgents != null ? Math.min(S.nAgents, MAX_AGENTS) : 0;
314
+ for (let i = 0; i < MAX_AGENTS; i++) {
315
+ const m = _agents[i];
316
+ const on = i < na;
317
+ m.visible = on;
318
+ if (!on) { m.material.opacity = 0.0; continue; }
319
+ const color = solved ? C_SOLVED : C_PRESS;
320
+ m.material.color.setHex(color);
321
+ m.material.emissive.setHex(color);
322
+ m.material.opacity = 0.9;
323
+ }
324
+
325
+ // ablation bars: decay-on (bounded) vs decay-off (runaway). Normalise both
326
+ // against the larger (no-decay) peak so the runaway bar towers over the
327
+ // decayed one — the height ratio IS pressure_runaway_x.
328
+ const on = live && S.ablDecayPk != null && S.ablNoDecayPk != null;
329
+ const denom = on ? Math.max(S.ablNoDecayPk, 1e-6) : 1;
330
+ if (_ablDecay) {
331
+ _ablDecay.material.opacity = on ? 0.92 : 0.0;
332
+ const hD = on ? Math.max(0.05, (S.ablDecayPk / denom) * 6.5) : 0.05;
333
+ _ablDecay.scale.y = hD; _ablDecay.position.y = hD / 2;
334
+ const c = live ? C_SOLVED : C_DIM;
335
+ _ablDecay.material.color.setHex(c); _ablDecay.material.emissive.setHex(c);
336
+ }
337
+ if (_ablNoDecay) {
338
+ _ablNoDecay.material.opacity = on ? 0.92 : 0.0;
339
+ const hN = on ? Math.max(0.05, (S.ablNoDecayPk / denom) * 6.5) : 0.05;
340
+ _ablNoDecay.scale.y = hN; _ablNoDecay.position.y = hN / 2;
341
+ const c = live ? C_DECAY : C_DIM;
342
+ _ablNoDecay.material.color.setHex(c); _ablNoDecay.material.emissive.setHex(c);
343
+ }
344
+
345
+ _finalViolUnused(finalViol);
346
+ }
347
+
348
+ // finalViol is surfaced in the HUD; referenced here only to keep the value in
349
+ // scope for future per-cell rendering without triggering an unused warning.
350
+ function _finalViolUnused(_v) { return _v; }
351
+
352
+ // =============================================================================
353
+ // per-frame animation
354
+ // =============================================================================
355
+ function _onFrame() {
356
+ const t = performance.now();
357
+ if (_group) _group.rotation.y = Math.sin(t * 0.00008) * 0.10;
358
+
359
+ // orbit the visible agent motes around the artifact
360
+ const na = _agents.length;
361
+ for (let i = 0; i < na; i++) {
362
+ const m = _agents[i];
363
+ if (!m.visible) continue;
364
+ const ang = (i / Math.max(1, na)) * Math.PI * 2 + t * 0.0006;
365
+ m.position.set(Math.cos(ang) * AGENT_ORBIT, 1.6 + 0.4 * Math.sin(t * 0.002 + i), Math.sin(ang) * AGENT_ORBIT);
366
+ }
367
+ if (_ablNoDecay && _ablNoDecay.material.opacity > 0) _ablNoDecay.rotation.y += 0.01;
368
+ if (_ablDecay && _ablDecay.material.opacity > 0) _ablDecay.rotation.y += 0.01;
369
+ }
370
+
371
+ // =============================================================================
372
+ // overlay
373
+ // =============================================================================
374
+ function _buildOverlay() {
375
+ const ctx = _ctx;
376
+ _overlay = document.createElement("div");
377
+ Object.assign(_overlay.style, {
378
+ position: "absolute", left: "14px", top: "14px", zIndex: "6",
379
+ display: "flex", flexDirection: "column", gap: "8px",
380
+ maxWidth: "min(94%,470px)",
381
+ font: "12px ui-sans-serif,system-ui,Segoe UI,Roboto,Arial",
382
+ color: "#eef3f6",
383
+ });
384
+
385
+ const h = document.createElement("div");
386
+ h.style.cssText = "font:600 13px ui-sans-serif,system-ui;letter-spacing:.4px";
387
+ h.textContent = TITLE;
388
+ _overlay.appendChild(h);
389
+
390
+ const sub = document.createElement("div");
391
+ sub.style.cssText = "color:#9fb1bf;font-size:11px;line-height:1.55";
392
+ sub.innerHTML =
393
+ 'Instead of a planner messaging executors, N agents coordinate <b>implicitly</b> through a ' +
394
+ 'shared constraint-grid artifact: each agent reads a local <b>pressure</b> (constraint-violation ' +
395
+ 'count), takes the pressure-reducing edit, and a <b>temporal-decay</b> schedule keeps stale ' +
396
+ 'pressure from locking the system in \u2014 <b>zero inter-agent messages</b> (stigmergy). Shown ' +
397
+ 'against sequential + hierarchical baselines. Honesty label <b>MODELED</b> (deterministic ' +
398
+ 'simulation; NOT real agents). 0 runtime CDN.';
399
+ _overlay.appendChild(sub);
400
+
401
+ const brow = document.createElement("div");
402
+ brow.style.cssText = "display:flex;gap:8px;align-items:center;flex-wrap:wrap";
403
+ if (_badge && _badge.el) brow.appendChild(_badge.el);
404
+ _overlay.appendChild(brow);
405
+
406
+ const card = document.createElement("div");
407
+ card.style.cssText = "background:#0a1117;border:1px solid #1d2a36;border-radius:9px;padding:9px 10px;display:flex;flex-direction:column;gap:6px";
408
+
409
+ const chead = document.createElement("div");
410
+ chead.style.cssText = "display:flex;align-items:center;gap:8px;flex-wrap:wrap";
411
+ const dot = document.createElement("span");
412
+ dot.style.cssText = "width:9px;height:9px;border-radius:50%;background:#3af4c8;box-shadow:0 0 7px #3af4c8";
413
+ const nm = document.createElement("b");
414
+ nm.style.cssText = "font-size:12px;color:#3af4c8;letter-spacing:.3px";
415
+ nm.textContent = "pressure-field coordination";
416
+ chead.appendChild(dot); chead.appendChild(nm);
417
+ card.appendChild(chead);
418
+
419
+ const grid = document.createElement("div");
420
+ grid.style.cssText = "display:grid;grid-template-columns:1fr;gap:4px";
421
+
422
+ function kpiRow(id, label) {
423
+ const r = document.createElement("div");
424
+ r.style.cssText = "display:flex;justify-content:space-between;gap:10px;font-size:11px";
425
+ const l = document.createElement("span"); l.style.cssText = "color:#9fb1bf"; l.textContent = label;
426
+ const v = document.createElement("b");
427
+ v.id = id;
428
+ v.style.cssText = "font-variant-numeric:tabular-nums;color:#eef3f6;text-align:right;max-width:58%";
429
+ v.textContent = "\u2014";
430
+ _el[id] = v;
431
+ r.appendChild(l); r.appendChild(v); return r;
432
+ }
433
+
434
+ grid.appendChild(kpiRow("pf-agents", "n_agents \u00d7 grid"));
435
+ grid.appendChild(kpiRow("pf-decay", "temporal decay (per step)"));
436
+ grid.appendChild(kpiRow("pf-steps", "pfield steps-to-converge \u2014 MODELED"));
437
+ grid.appendChild(kpiRow("pf-msgs", "pfield inter-agent messages"));
438
+ grid.appendChild(kpiRow("pf-seq", "sequential steps-to-converge \u2014 MODELED"));
439
+ grid.appendChild(kpiRow("pf-hier", "hierarchical steps / messages \u2014 MODELED"));
440
+ grid.appendChild(kpiRow("pf-match", "pfield matches hierarchical?"));
441
+ grid.appendChild(kpiRow("pf-runaway", "no-decay pressure runaway \u2014 MODELED"));
442
+ grid.appendChild(kpiRow("pf-label", "honesty label"));
443
+ card.appendChild(grid);
444
+
445
+ const fn = document.createElement("div");
446
+ fn.style.cssText = "font-size:9.5px;color:#6b7a86;line-height:1.5";
447
+ fn.textContent = "Rodriguez 2026 \u00b7 Pressure Fields + Temporal Decay \u00b7 arXiv:2601.08129. MODELED \u00b7 not claimed-as.";
448
+ card.appendChild(fn);
449
+ _overlay.appendChild(card);
450
+
451
+ const pl = document.createElement("button");
452
+ pl.textContent = "\u25d1 what this means";
453
+ pl.title = "Toggle plain-language explanation for investors & consumers.";
454
+ pl.style.cssText = "font:11px ui-monospace,monospace;padding:5px 11px;border-radius:7px;border:1px solid #3af4c8;background:#08140f;color:#3af4c8;cursor:pointer;width:fit-content";
455
+ pl.addEventListener("click", () => {
456
+ _plain = !_plain;
457
+ pl.style.background = _plain ? "#0f2a20" : "#08140f";
458
+ _applyPlain();
459
+ });
460
+ _overlay.appendChild(pl);
461
+
462
+ const pd = document.createElement("div");
463
+ pd.id = "pf-plain";
464
+ pd.style.cssText = "font-size:10.5px;color:#c9d6df;line-height:1.55;border:1px dashed #26333f;border-radius:7px;padding:7px 9px;display:none";
465
+ _el["plain"] = pd;
466
+ _overlay.appendChild(pd);
467
+
468
+ (ctx.container || document.body).appendChild(_overlay);
469
+ _paintOverlay();
470
+ }
471
+
472
+ function _applyPlain() {
473
+ const pd = _el["plain"];
474
+ if (!pd) return;
475
+ pd.style.display = _plain ? "block" : "none";
476
+ if (!_plain) return;
477
+ const na = S.nAgents != null ? String(S.nAgents) : "loading\u2026";
478
+ const pfs = S.stepsConv != null ? String(S.stepsConv) : "loading\u2026";
479
+ const hms = S.hierMsgs != null ? String(S.hierMsgs) : "loading\u2026";
480
+ const rw = S.runawayX != null ? S.runawayX.toFixed(0) + "x" : "loading\u2026";
481
+ pd.innerHTML =
482
+ "<b>What this means:</b> Getting many AI agents to work together usually needs a <i>boss</i> agent " +
483
+ "that hands out tasks and collects results \u2014 lots of back-and-forth messages that pile up as you add " +
484
+ "workers. This approach skips the boss entirely. All <b>" + na + " agents</b> scribble on one shared " +
485
+ "worksheet; wherever the worksheet looks wrong, \u201cpressure\u201d builds up and naturally pulls the nearest " +
486
+ "agent to fix it \u2014 like ants leaving scent trails (called <b>stigmergy</b>). No agent ever messages " +
487
+ "another. Here it finishes in about <b>" + pfs + " rounds with zero messages</b>, matching the boss-based " +
488
+ "method that needed roughly <b>" + hms + " messages</b>. One catch: the pressure has to <b>fade over time</b>, " +
489
+ "or it snowballs \u2014 turning decay off makes the pressure blow up about <b>" + rw + "</b>. This view is a " +
490
+ "<b>MODELED</b> deterministic simulation of that coordination math, not a run of real AI agents.";
491
+ }
492
+
493
+ function _tok(s) {
494
+ if (s === "live") return null;
495
+ if (s === "missing") return "NO-LIVE-DATA";
496
+ if (s === "degraded") return "DEGRADED";
497
+ if (s === "error") return "OFFLINE";
498
+ return "\u2026";
499
+ }
500
+
501
+ function fx(v, d) { return typeof v === "number" ? v.toFixed(d) : "\u2014"; }
502
+ function _set(id, v) { if (_el[id]) _el[id].textContent = v; }
503
+
504
+ function _paintOverlay() {
505
+ const t = _tok(S.state);
506
+ _set("pf-agents", t || (S.nAgents != null && S.grid != null ? (S.nAgents + " \u00d7 " + S.grid + "\u00d7" + S.grid) : "\u2014"));
507
+ _set("pf-decay", t || fx(S.decay, 3));
508
+ _set("pf-steps", t || (S.stepsConv != null ? (S.stepsConv + (S.solved ? " (solved)" : "")) : "\u2014"));
509
+ _set("pf-msgs", t || (S.messages != null ? String(S.messages) : "\u2014"));
510
+ _set("pf-seq", t || (S.seqSteps != null ? (S.seqSteps + (S.seqSolved ? " (solved)" : "")) : "\u2014"));
511
+ _set("pf-hier", t || (S.hierSteps != null ? (S.hierSteps + " / " + (S.hierMsgs != null ? S.hierMsgs + " msgs" : "\u2014")) : "\u2014"));
512
+ _set("pf-match", t || (S.matchesHier === true ? "yes (\u2265 hierarchical, 0 msgs)" : S.matchesHier === false ? "no" : "\u2014"));
513
+ _set("pf-runaway", t || (S.runawayX != null ? (S.runawayX.toFixed(1) + "\u00d7 without decay") : "\u2014"));
514
+ // honesty label verbatim — never upgraded
515
+ _set("pf-label", t || (S.label || "MODELED"));
516
+ if (_plain) _applyPlain();
517
+ }
518
+
519
+ // =============================================================================
520
+ // unmount — clean up everything; must not affect other organs
521
+ // =============================================================================
522
+ function _disposeCells() {
523
+ const THREE = _THREE;
524
+ if (_cells && _cells.length && _group) {
525
+ _cells.forEach((m) => {
526
+ try {
527
+ if (m.geometry && m.geometry.dispose) m.geometry.dispose();
528
+ if (m.material && m.material.dispose) m.material.dispose();
529
+ _group.remove(m);
530
+ } catch (_) {}
531
+ });
532
+ }
533
+ _cells = [];
534
+ void THREE;
535
+ }
536
+
537
+ export function unmount() {
538
+ _polls.forEach((p) => { try { p.stop(); } catch (_) {} }); _polls = [];
539
+ try { if (_overlay && _overlay.parentNode) _overlay.parentNode.removeChild(_overlay); } catch (_) {}
540
+ try {
541
+ if (_group && _stage) {
542
+ _group.traverse((o) => {
543
+ if (o.geometry && o.geometry.dispose) o.geometry.dispose();
544
+ if (o.material) {
545
+ const ms = Array.isArray(o.material) ? o.material : [o.material];
546
+ ms.forEach((m) => { if (m.dispose) m.dispose(); });
547
+ }
548
+ });
549
+ _stage.scene.remove(_group);
550
+ }
551
+ } catch (_) {}
552
+ _group = _overlay = null;
553
+ _floor = null; _cells = []; _cellSide = 0; _agents = [];
554
+ _ablDecay = null; _ablNoDecay = null;
555
+ _el = {}; _badge = null; _plain = false; _frameReg = false;
556
+ _stage = _THREE = _ctx = null;
557
+ S.label = S.nAgents = S.grid = S.decay = S.steps = null;
558
+ S.solved = S.stepsConv = S.finalViol = S.peakPress = S.messages = null;
559
+ S.violTraj = S.pressTraj = null;
560
+ S.seqSolved = S.seqSteps = S.hierSolved = S.hierSteps = S.hierMsgs = null;
561
+ S.sweep = S.ablDecayPk = S.ablNoDecayPk = S.runawayX = S.matchesHier = null;
562
+ S.state = "init";
563
+ }
564
+
565
+ export default { id: ID, title: TITLE, endpoints: [EP], mount, unmount };
static/3d/surfaces/qhall.js ADDED
@@ -0,0 +1,490 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11
3
+ //
4
+ // surfaces/qhall.js — QUANTUM-INSPIRED TENSOR-NETWORK HALLUCINATION-UNCERTAINTY
5
+ // organ for the holographic frontier ring.
6
+ //
7
+ // Renders a 3D constellation of candidate LLM generations, encoded as low-bond-dimension
8
+ // matrix-product-state (MPS) vectors and grouped into semantic-equivalence clusters, driven
9
+ // by a live snapshot from /api/killinchu/v1/qhall/quantify. Each generation is a node; nodes
10
+ // in the same semantic cluster share a colour and orbit a common cluster centroid. A HUD
11
+ // tracks the semantic entropy (aleatoric-uncertainty score) and whether it crosses the
12
+ // oversight threshold — the "entropy maximization for human-review flagging" behaviour.
13
+ // Honesty label "MODELED" is read VERBATIM from the JSON and displayed as-is; never upgraded.
14
+ //
15
+ // IMPORTANT — QUANTUM-INSPIRED, NOT A REAL QUANTUM COMPUTER:
16
+ // "Quantum tensor network" here is the mathematical INSPIRATION (low-rank MPS math from
17
+ // quantum many-body physics), simulated ENTIRELY on a classical CPU. There is NO quantum
18
+ // hardware, NO quantum circuit, and NO real LLM behind this organ — the candidate answers
19
+ // and their sequence log-probabilities are synthetic toy data. This is stated plainly in
20
+ // the "what this means" copy and echoed in the endpoint's own JSON payload.
21
+ //
22
+ // Surface export shape (mirrors interpretability.js / qec.js exactly):
23
+ // export default { id, title, endpoints, mount(ctx), unmount() }
24
+ // ctx = { stage, container, live, label, THREE, szl3d }
25
+ //
26
+ // DATA SHOWN (all from live endpoint):
27
+ // n_generations — candidate generations for the fixed prompt
28
+ // bond_dim — MPS bond dimension χ (low-rank truncation)
29
+ // n_clusters — semantic-equivalence classes found
30
+ // cluster_sizes — member counts per class
31
+ // semantic_entropy — aleatoric-uncertainty score (nats)
32
+ // normalized_entropy — semantic_entropy / ln(n) (0..1)
33
+ // threshold — oversight threshold (nats)
34
+ // flag_for_review — bool (entropy-maximization human-review flag)
35
+ //
36
+ // LEADERS ADOPTED & CITED (clean-room; NOT claimed as SZL's own):
37
+ // Vipulanandan, Premaratne & Sarkar (2026) "Semantic Uncertainty Quantification of
38
+ // Hallucinations in LLMs: A Quantum Tensor Network Based Method". arXiv:2601.20026
39
+ // (ICLR 2026; 116 experiments, 8 model families).
40
+ // https://arxiv.org/abs/2601.20026
41
+ //
42
+ // HONESTY LABELS: MODELED (simulation of the METHOD on synthetic toy data; quantum-INSPIRED
43
+ // classical MPS stand-in, NO real quantum hardware, NO real LLM). Read verbatim from JSON.
44
+ // COLOURS: lattice-blue 0x5b8dee (consistent / dominant cluster nodes), violet-blue 0x8a6bff
45
+ // (scattered / contradictory cluster nodes — data-viz only), proof-teal 0x3af4c8 (entropy
46
+ // HUD accent), greys for dim/idle. Purple BANNED as UI/background.
47
+ // 0 RUNTIME CDN. Vendored three.js r170 via page importmap (ctx.THREE).
48
+ // DOCTRINE v11: degrades gracefully (grey) on 404/error; honesty label still shown.
49
+ // This organ adds NOTHING to SZL's own locked-8 / Λ-Conjecture-1.
50
+
51
+ const ID = "qhall";
52
+ const TITLE = "Quantum-Inspired Tensor-Network Hallucination Uncertainty (live)";
53
+
54
+ // Endpoint is hosted on the dedicated killinchu Space (isolated compute), reached
55
+ // cross-origin (killinchu returns access-control-allow-origin: https://a-11-oy.com).
56
+ // This keeps the qhall organ's rebuilds/faults isolated from the flagship.
57
+ const EP = "https://szlholdings-killinchu.hf.space/api/killinchu/v1/qhall/quantify?seed=42&n_generations=8&bond_dim=4&threshold=0.9";
58
+
59
+ // data-viz hues — purple BANNED
60
+ const C_NODE = 0x5b8dee; // lattice-blue (consistent / dominant-cluster generation)
61
+ const C_SCAT = 0x8a6bff; // violet-blue (scattered / minority-cluster generation — data-viz only)
62
+ const C_DIM = 0x42505d; // grey (degraded / no-live-data / idle node)
63
+ const C_ACCENT = 0x3af4c8; // proof-teal accent (entropy HUD ring)
64
+ const C_GRID = 0x1b3a44; // floor / link colour
65
+
66
+ let _stage = null, _THREE = null, _ctx = null, _group = null, _overlay = null;
67
+ let _frameReg = false, _polls = [], _el = {}, _badge = null;
68
+ let _plain = false;
69
+
70
+ // geometry handles
71
+ let _nodes = []; // Array<THREE.Mesh> — one per candidate generation
72
+ let _links = null; // THREE.LineSegments — intra-cluster links
73
+ let _ring = null; // THREE.Mesh — entropy HUD ring above the constellation
74
+ const _lastN = { n: 0 };// last-built node count, so we only rebuild on change
75
+
76
+ // max constellation we'll ever build (matches endpoint answer-bank cap)
77
+ const _MAX_NODES = 8;
78
+ const _pulse = new Float32Array(_MAX_NODES);
79
+
80
+ // live state
81
+ const S = {
82
+ label: null,
83
+ n: null, // n_generations
84
+ bondDim: null, // bond_dim
85
+ nClusters: null, // n_clusters
86
+ sizes: null, // cluster_sizes[]
87
+ entropy: null, // semantic_entropy
88
+ normEnt: null, // normalized_entropy
89
+ threshold: null, // threshold
90
+ flag: null, // flag_for_review
91
+ clusterOf: [], // per-node cluster index (from generations[])
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, 8, 20);
103
+ try { if (_stage.controls && _stage.controls.target) { _stage.controls.target.set(0, 1.5, 0); _stage.controls.update(); } } catch (_) {}
104
+ try { _stage.setBloom(true); } catch (_) {}
105
+
106
+ _buildFloor();
107
+ _buildConstellation(8); // default 8-node constellation; rebuilt on live data if n differs
108
+ _buildEntropyRing();
109
+
110
+ if (!_frameReg) { _stage.onFrame(_onFrame); _frameReg = true; }
111
+
112
+ _badge = ctx.live.createBadge();
113
+ _polls.push(ctx.live.poll(EP, 5000, _onQuantify, { badge: _badge, onState: (m) => { S.state = m.state; _paintOverlay(); } }));
114
+
115
+ _buildOverlay();
116
+ return { id: ID, started: true };
117
+ }
118
+
119
+ // =============================================================================
120
+ // builders
121
+ // =============================================================================
122
+ function _buildFloor() {
123
+ const THREE = _THREE;
124
+ const grid = new THREE.GridHelper(40, 40, C_GRID, 0x0f2027);
125
+ grid.material.opacity = 0.18; grid.material.transparent = true; grid.position.y = -0.01;
126
+ _group.add(grid);
127
+ }
128
+
129
+ // Build (or rebuild) an n-node constellation of candidate generations, laid out on a
130
+ // ring. Cluster membership (colour + intra-cluster links) is applied later from live data.
131
+ function _buildConstellation(n) {
132
+ const THREE = _THREE;
133
+ n = Math.max(2, Math.min(n | 0, _MAX_NODES));
134
+ if (_lastN.n === n && _nodes.length) return; // already built at this size
135
+ _lastN.n = n;
136
+
137
+ _disposeConstellation();
138
+
139
+ const radius = 5.2;
140
+ const y = 1.4;
141
+
142
+ const geo = new THREE.SphereGeometry(0.42, 16, 12);
143
+ const mat0 = new THREE.MeshStandardMaterial({ color: C_DIM, emissive: C_DIM, emissiveIntensity: 0.15, metalness: 0.25, roughness: 0.55 });
144
+
145
+ _nodes = [];
146
+ for (let i = 0; i < n; i++) {
147
+ const a = (i / n) * Math.PI * 2;
148
+ const x = Math.cos(a) * radius;
149
+ const z = Math.sin(a) * radius;
150
+ const mesh = new THREE.Mesh(geo, mat0.clone());
151
+ mesh.position.set(x, y, z);
152
+ mesh.userData.home = new THREE.Vector3(x, y, z);
153
+ _group.add(mesh);
154
+ _nodes.push(mesh);
155
+ }
156
+ }
157
+
158
+ function _disposeConstellation() {
159
+ if (_nodes[0] && _nodes[0].geometry) _nodes[0].geometry.dispose(); // shared geometry
160
+ _nodes.forEach((m) => {
161
+ _group.remove(m);
162
+ if (m.material && m.material.dispose) m.material.dispose();
163
+ });
164
+ if (_links) {
165
+ _group.remove(_links);
166
+ if (_links.geometry) _links.geometry.dispose();
167
+ if (_links.material) _links.material.dispose();
168
+ _links = null;
169
+ }
170
+ _nodes = [];
171
+ }
172
+
173
+ function _buildEntropyRing() {
174
+ const THREE = _THREE;
175
+ _ring = new THREE.Mesh(
176
+ new THREE.TorusGeometry(2.0, 0.035, 10, 64),
177
+ new THREE.MeshStandardMaterial({ color: C_ACCENT, emissive: C_ACCENT, emissiveIntensity: 0.4, transparent: true, opacity: 0.5 }),
178
+ );
179
+ _ring.position.set(0, 5.6, 0);
180
+ _ring.rotation.x = Math.PI / 2;
181
+ _group.add(_ring);
182
+ }
183
+
184
+ // =============================================================================
185
+ // live data handler
186
+ // =============================================================================
187
+ function _onQuantify(j) {
188
+ // Read honesty label VERBATIM — never upgrade. Handle top-level 'label' OR a nested
189
+ // 'payload.label' so we match this module's own shape (top-level) AND any wrapper.
190
+ const p = (j && typeof j.payload === "object" && j.payload) ? j.payload : j;
191
+ const rawLabel = (p && p.label != null) ? p.label : (j && j.label != null ? j.label : "MODELED");
192
+ S.label = String(rawLabel).toUpperCase();
193
+
194
+ S.n = typeof p.n_generations === "number" ? p.n_generations : null;
195
+ S.bondDim = typeof p.bond_dim === "number" ? p.bond_dim : null;
196
+ S.nClusters = typeof p.n_clusters === "number" ? p.n_clusters : null;
197
+ S.sizes = Array.isArray(p.cluster_sizes) ? p.cluster_sizes : null;
198
+ S.entropy = typeof p.semantic_entropy === "number" ? p.semantic_entropy : null;
199
+ S.normEnt = typeof p.normalized_entropy === "number" ? p.normalized_entropy : null;
200
+ S.threshold = typeof p.threshold === "number" ? p.threshold : null;
201
+ S.flag = typeof p.flag_for_review === "boolean" ? p.flag_for_review : null;
202
+
203
+ // per-node cluster assignment from generations[]
204
+ S.clusterOf = [];
205
+ if (Array.isArray(p.generations)) {
206
+ p.generations.forEach((g) => {
207
+ S.clusterOf.push(typeof g.cluster === "number" ? g.cluster : 0);
208
+ });
209
+ }
210
+
211
+ if (S.n) _buildConstellation(S.n);
212
+ _updateConstellation();
213
+ _paintOverlay();
214
+ }
215
+
216
+ // =============================================================================
217
+ // geometry updater — colours nodes by cluster, links intra-cluster members
218
+ // =============================================================================
219
+ function _updateConstellation() {
220
+ const THREE = _THREE;
221
+ const live = S.state === "live";
222
+
223
+ // dominant cluster (largest) is drawn lattice-blue (consistent); minority clusters are
224
+ // violet-blue (scattered / contradictory — data-viz only).
225
+ let dominant = 0;
226
+ if (Array.isArray(S.sizes) && S.sizes.length) {
227
+ let best = -1;
228
+ S.sizes.forEach((sz, ci) => { if (sz > best) { best = sz; dominant = ci; } });
229
+ }
230
+
231
+ _nodes.forEach((mesh, i) => {
232
+ if (live && S.clusterOf.length) {
233
+ const ci = i < S.clusterOf.length ? S.clusterOf[i] : 0;
234
+ const col = ci === dominant ? C_NODE : C_SCAT;
235
+ mesh.material.color.setHex(col);
236
+ mesh.material.emissive.setHex(col);
237
+ mesh.material.emissiveIntensity = 0.35;
238
+ _pulse[i] = 60;
239
+ } else {
240
+ mesh.material.color.setHex(C_DIM);
241
+ mesh.material.emissive.setHex(C_DIM);
242
+ mesh.material.emissiveIntensity = 0.12;
243
+ }
244
+ });
245
+
246
+ // intra-cluster links: connect every pair of nodes sharing a cluster.
247
+ if (_links) {
248
+ _group.remove(_links);
249
+ if (_links.geometry) _links.geometry.dispose();
250
+ if (_links.material) _links.material.dispose();
251
+ _links = null;
252
+ }
253
+ if (live && S.clusterOf.length) {
254
+ const pts = [];
255
+ for (let a = 0; a < _nodes.length; a++) {
256
+ for (let b = a + 1; b < _nodes.length; b++) {
257
+ if (S.clusterOf[a] != null && S.clusterOf[a] === S.clusterOf[b]) {
258
+ pts.push(_nodes[a].position.clone(), _nodes[b].position.clone());
259
+ }
260
+ }
261
+ }
262
+ if (pts.length) {
263
+ const lg = new THREE.BufferGeometry().setFromPoints(pts);
264
+ _links = new THREE.LineSegments(lg, new THREE.LineBasicMaterial({ color: C_NODE, transparent: true, opacity: 0.3 }));
265
+ _group.add(_links);
266
+ }
267
+ }
268
+
269
+ if (_ring) {
270
+ // ring brightness/scale scales with normalized entropy: HIGH entropy (scattered,
271
+ // flagged for review) burns brighter; LOW entropy (consistent) stays calm.
272
+ const norm = S.normEnt != null ? Math.max(0, Math.min(1, S.normEnt)) : 0;
273
+ const flagged = S.flag === true;
274
+ const rcol = live ? (flagged ? C_SCAT : C_ACCENT) : C_DIM;
275
+ _ring.material.color.setHex(rcol);
276
+ _ring.material.emissive.setHex(rcol);
277
+ _ring.material.emissiveIntensity = live ? 0.2 + 0.7 * norm : 0.12;
278
+ _ring.material.opacity = live ? 0.55 : 0.2;
279
+ _ring.scale.setScalar(live ? (0.7 + 0.6 * norm) : 0.8);
280
+ }
281
+ }
282
+
283
+ // =============================================================================
284
+ // per-frame animation
285
+ // =============================================================================
286
+ function _onFrame() {
287
+ const t = performance.now();
288
+ if (_group) _group.rotation.y = Math.sin(t * 0.0001) * 0.15;
289
+ if (_ring) { _ring.rotation.z += 0.004; }
290
+
291
+ const live = S.state === "live";
292
+ _nodes.forEach((mesh, i) => {
293
+ if (_pulse[i] > 0) {
294
+ _pulse[i] -= 1;
295
+ const f = _pulse[i] / 60;
296
+ mesh.material.emissiveIntensity = Math.max(mesh.material.emissiveIntensity, 0.2 + 0.8 * f);
297
+ }
298
+ // gentle bob so consistent vs scattered clusters read as "living" data
299
+ if (mesh.userData.home) {
300
+ mesh.position.y = mesh.userData.home.y + (live ? Math.sin(t * 0.0012 + i) * 0.12 : 0);
301
+ }
302
+ });
303
+ }
304
+
305
+ // =============================================================================
306
+ // overlay
307
+ // =============================================================================
308
+ function _buildOverlay() {
309
+ const ctx = _ctx;
310
+ _overlay = document.createElement("div");
311
+ Object.assign(_overlay.style, {
312
+ position: "absolute", left: "14px", top: "14px", zIndex: "6",
313
+ display: "flex", flexDirection: "column", gap: "8px",
314
+ maxWidth: "min(94%,470px)",
315
+ font: "12px ui-sans-serif,system-ui,Segoe UI,Roboto,Arial",
316
+ color: "#eef3f6",
317
+ });
318
+
319
+ const h = document.createElement("div");
320
+ h.style.cssText = "font:600 13px ui-sans-serif,system-ui;letter-spacing:.4px";
321
+ h.textContent = TITLE;
322
+ _overlay.appendChild(h);
323
+
324
+ const sub = document.createElement("div");
325
+ sub.style.cssText = "color:#9fb1bf;font-size:11px;line-height:1.55";
326
+ sub.innerHTML =
327
+ 'Several candidate answers for one prompt are encoded as low-rank ' +
328
+ '<b>matrix-product-state (MPS) tensor vectors</b>, clustered into ' +
329
+ '<b>semantic-equivalence classes</b>, and scored by the <b>entropy</b> of the ' +
330
+ 'cluster distribution. Low entropy \u2192 the answers agree (confident); high ' +
331
+ 'entropy \u2192 they contradict each other and the prompt is <b>flagged for human ' +
332
+ 'review</b>. Honesty label <b>MODELED</b> \u2014 <b>quantum-INSPIRED</b> (a classical ' +
333
+ 'tensor-network stand-in), <b>not</b> a real quantum computer and not a real LLM. 0 runtime CDN.';
334
+ _overlay.appendChild(sub);
335
+
336
+ const brow = document.createElement("div");
337
+ brow.style.cssText = "display:flex;gap:8px;align-items:center;flex-wrap:wrap";
338
+ if (_badge && _badge.el) brow.appendChild(_badge.el);
339
+ _overlay.appendChild(brow);
340
+
341
+ const card = document.createElement("div");
342
+ card.style.cssText = "background:#0a1117;border:1px solid #1d2a36;border-radius:9px;padding:9px 10px;display:flex;flex-direction:column;gap:6px";
343
+
344
+ const chead = document.createElement("div");
345
+ chead.style.cssText = "display:flex;align-items:center;gap:8px;flex-wrap:wrap";
346
+ const dot = document.createElement("span");
347
+ dot.style.cssText = "width:9px;height:9px;border-radius:50%;background:#5b8dee;box-shadow:0 0 7px #5b8dee";
348
+ const nm = document.createElement("b");
349
+ nm.style.cssText = "font-size:12px;color:#5b8dee;letter-spacing:.3px";
350
+ nm.textContent = "qhall \u00b7 semantic-uncertainty";
351
+ chead.appendChild(dot); chead.appendChild(nm);
352
+ card.appendChild(chead);
353
+
354
+ const grid = document.createElement("div");
355
+ grid.style.cssText = "display:grid;grid-template-columns:1fr;gap:4px";
356
+
357
+ function kpiRow(id, label) {
358
+ const r = document.createElement("div");
359
+ r.style.cssText = "display:flex;justify-content:space-between;gap:10px;font-size:11px";
360
+ const l = document.createElement("span"); l.style.cssText = "color:#9fb1bf"; l.textContent = label;
361
+ const v = document.createElement("b");
362
+ v.id = id;
363
+ v.style.cssText = "font-variant-numeric:tabular-nums;color:#eef3f6;text-align:right;max-width:58%";
364
+ v.textContent = "\u2014";
365
+ _el[id] = v;
366
+ r.appendChild(l); r.appendChild(v); return r;
367
+ }
368
+
369
+ grid.appendChild(kpiRow("qh-n", "candidate generations"));
370
+ grid.appendChild(kpiRow("qh-bond", "MPS bond dimension \u03c7"));
371
+ grid.appendChild(kpiRow("qh-clus", "semantic clusters"));
372
+ grid.appendChild(kpiRow("qh-sizes", "cluster sizes"));
373
+ grid.appendChild(kpiRow("qh-ent", "semantic entropy (nats) \u2014 MODELED"));
374
+ grid.appendChild(kpiRow("qh-norm", "normalized entropy (0\u20131)"));
375
+ grid.appendChild(kpiRow("qh-thr", "oversight threshold (nats)"));
376
+ grid.appendChild(kpiRow("qh-flag", "flag for human review"));
377
+ grid.appendChild(kpiRow("qh-label", "honesty label"));
378
+ card.appendChild(grid);
379
+
380
+ const fn = document.createElement("div");
381
+ fn.style.cssText = "font-size:9.5px;color:#6b7a86;line-height:1.5";
382
+ fn.textContent = "Vipulanandan, Premaratne & Sarkar arXiv:2601.20026 (ICLR 2026) \u00b7 quantum-INSPIRED classical MPS stand-in, no real quantum hardware, no real LLM. MODELED \u00b7 not claimed-as.";
383
+ card.appendChild(fn);
384
+ _overlay.appendChild(card);
385
+
386
+ const pl = document.createElement("button");
387
+ pl.textContent = "\u25d1 what this means";
388
+ pl.title = "Toggle plain-language explanation for investors & consumers.";
389
+ pl.style.cssText = "font:11px ui-monospace,monospace;padding:5px 11px;border-radius:7px;border:1px solid #3af4c8;background:#08140f;color:#3af4c8;cursor:pointer;width:fit-content";
390
+ pl.addEventListener("click", () => {
391
+ _plain = !_plain;
392
+ pl.style.background = _plain ? "#0f2a20" : "#08140f";
393
+ _applyPlain();
394
+ });
395
+ _overlay.appendChild(pl);
396
+
397
+ const pd = document.createElement("div");
398
+ pd.id = "qhall-plain";
399
+ pd.style.cssText = "font-size:10.5px;color:#c9d6df;line-height:1.55;border:1px dashed #26333f;border-radius:7px;padding:7px 9px;display:none";
400
+ _el["plain"] = pd;
401
+ _overlay.appendChild(pd);
402
+
403
+ (ctx.container || document.body).appendChild(_overlay);
404
+ _paintOverlay();
405
+ }
406
+
407
+ function _applyPlain() {
408
+ const pd = _el["plain"];
409
+ if (!pd) return;
410
+ pd.style.display = _plain ? "block" : "none";
411
+ if (!_plain) return;
412
+ const n = S.n != null ? String(S.n) : "loading\u2026";
413
+ const cl = S.nClusters != null ? String(S.nClusters) : "loading\u2026";
414
+ const ent = S.entropy != null ? S.entropy.toFixed(3) : "loading\u2026";
415
+ const verdict = S.flag == null
416
+ ? "loading\u2026"
417
+ : (S.flag ? "FLAGGED for a human to double-check" : "confident \u2014 no review needed");
418
+ pd.innerHTML =
419
+ "<b>What this means:</b> We ask the model the same question and collect <b>" + n + "</b> " +
420
+ "candidate answers. Each answer is turned into a compact math fingerprint (a " +
421
+ "<b>tensor-network / MPS vector</b>) and answers that mean the same thing are grouped " +
422
+ "together \u2014 here into <b>" + cl + "</b> distinct meaning-groups. If almost all answers " +
423
+ "land in one group, the model is confident; if they scatter across many contradictory " +
424
+ "groups, that's a warning sign of a possible <b>hallucination</b>. We measure that scatter " +
425
+ "with <b>entropy = " + ent + "</b>: right now this prompt is <b>" + verdict + "</b>. " +
426
+ "<br><br><b>Important honesty note:</b> this organ is <b>quantum-INSPIRED</b>, not a real " +
427
+ "quantum computer. The tensor-network math borrows ideas from quantum physics, but it runs " +
428
+ "entirely on an ordinary classical processor \u2014 there is <b>no quantum hardware</b> and " +
429
+ "<b>no quantum circuit</b> involved. It is also <b>not</b> a real language model: the answers " +
430
+ "and their probabilities are <b>synthetic toy data</b> for demonstration. Everything shown is " +
431
+ "a <b>MODELED</b> simulation of the method (Vipulanandan et al., ICLR 2026), not a live readout.";
432
+ }
433
+
434
+ function _tok(s) {
435
+ if (s === "live") return null;
436
+ if (s === "missing") return "NO-LIVE-DATA";
437
+ if (s === "degraded") return "DEGRADED";
438
+ if (s === "error") return "OFFLINE";
439
+ return "\u2026";
440
+ }
441
+
442
+ function fx(v, d) { return typeof v === "number" ? v.toFixed(d) : "\u2014"; }
443
+ function _set(id, v) { if (_el[id]) _el[id].textContent = v; }
444
+
445
+ function _paintOverlay() {
446
+ const t = _tok(S.state);
447
+ _set("qh-n", t || (S.n != null ? String(S.n) : "\u2014"));
448
+ _set("qh-bond", t || (S.bondDim != null ? String(S.bondDim) : "\u2014"));
449
+ _set("qh-clus", t || (S.nClusters != null ? String(S.nClusters) : "\u2014"));
450
+ _set("qh-sizes", t || (Array.isArray(S.sizes) ? "[" + S.sizes.join(", ") + "]" : "\u2014"));
451
+ _set("qh-ent", t || fx(S.entropy, 3));
452
+ _set("qh-norm", t || fx(S.normEnt, 3));
453
+ _set("qh-thr", t || fx(S.threshold, 3));
454
+ _set("qh-flag", t || (S.flag == null ? "\u2014" : (S.flag ? "FLAG \u2014 send to human review" : "clear \u2014 high confidence")));
455
+ // honesty label verbatim — never upgraded
456
+ _set("qh-label", t || (S.label || "MODELED"));
457
+ if (_plain) _applyPlain();
458
+ }
459
+
460
+ // =============================================================================
461
+ // unmount — clean up everything; must not affect other organs
462
+ // =============================================================================
463
+ export function unmount() {
464
+ _polls.forEach((p) => { try { p.stop(); } catch (_) {} }); _polls = [];
465
+ try { if (_overlay && _overlay.parentNode) _overlay.parentNode.removeChild(_overlay); } catch (_) {}
466
+ try {
467
+ if (_group && _stage) {
468
+ _group.traverse((o) => {
469
+ if (o.geometry && o.geometry.dispose) o.geometry.dispose();
470
+ if (o.material) {
471
+ const ms = Array.isArray(o.material) ? o.material : [o.material];
472
+ ms.forEach((m) => { if (m.dispose) m.dispose(); });
473
+ }
474
+ });
475
+ _stage.scene.remove(_group);
476
+ }
477
+ } catch (_) {}
478
+ _group = _overlay = null;
479
+ _nodes = []; _links = null; _ring = null;
480
+ _lastN.n = 0;
481
+ _el = {}; _badge = null; _plain = false; _frameReg = false;
482
+ _stage = _THREE = _ctx = null;
483
+ S.label = S.n = S.bondDim = S.nClusters = S.sizes = null;
484
+ S.entropy = S.normEnt = S.threshold = S.flag = null;
485
+ S.clusterOf = [];
486
+ S.state = "init";
487
+ _pulse.fill(0);
488
+ }
489
+
490
+ export default { id: ID, title: TITLE, endpoints: [EP], mount, unmount };