File size: 40,311 Bytes
025c6ea
 
 
 
 
 
a0f8a7d
7153e35
 
 
 
025c6ea
7153e35
 
025c6ea
 
 
 
 
 
 
 
 
7153e35
 
025c6ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a0f8a7d
025c6ea
a0f8a7d
 
 
025c6ea
 
 
 
 
 
 
 
 
a0f8a7d
025c6ea
 
 
7153e35
025c6ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ea238f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ab626bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
025c6ea
 
 
 
 
a0f8a7d
025c6ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a0f8a7d
 
025c6ea
 
 
 
 
 
 
 
ab626bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e97df21
ab626bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
025c6ea
 
 
e97df21
025c6ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ea238f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
025c6ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ea238f
025c6ea
 
 
 
 
5ea238f
025c6ea
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>SZL-Nemo — Sovereign Governed Agent Model · SZL Holdings</title>
<meta name="description" content="SZL-Nemo: an identity-bound local inference recipe built on NVIDIA Nemotron 3 Nano 4B, with governed routing and signed receipts. The recipe is not an SZL fine-tune; readiness and quality are reported separately."/>
<!-- SOVEREIGN: 0 runtime CDN. Fonts self-hosted in-image and served same-origin at
     /vendor/fonts/*.woff2 (SAME pattern as the clean console). NO external font CDN.
     The --display/--mono stacks fall back to a geometric system sans / system mono so
     the page still renders correctly if a blob is unavailable. -->
<style>
@font-face{font-family:'Space Grotesk';font-style:normal;font-weight:300 700;font-display:swap;src:url('/vendor/fonts/SpaceGrotesk.woff2') format('woff2');}
@font-face{font-family:'JetBrains Mono';font-style:normal;font-weight:400 500;font-display:swap;src:url('/vendor/fonts/JetBrainsMono.woff2') format('woff2');}
:root{
  --ground:#0a0a0a; --panel:#0e0e0e; --panel2:#080808;
  --gold:#c9b787; --gold-bright:#d6c69a;
  --teal:#5fb3a3; --teal-soft:rgba(95,179,163,0.10);
  --cream:#f5f5f5; --paragraph:#9a9a9a; --muted:#888; --dim:#555;
  --gold-line:rgba(201,183,135,0.15); --gold-soft:rgba(201,183,135,0.04);
  --teal-line:rgba(95,179,163,0.22);
  --live:#5a8a6e; --err:#b06a5a;
  --green:#39d98a; --yellow:#f5c451; --red:#ff6a5a; --blue:#5bc8ff;
  --mono:'JetBrains Mono',ui-monospace,'SF Mono',Menlo,monospace;
  --display:'Space Grotesk',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;background:var(--ground);color:var(--cream);font-family:var(--display);-webkit-font-smoothing:antialiased;}
.mono{font-family:var(--mono);}
a{color:inherit;text-decoration:none;}
code{font-family:var(--mono);color:var(--gold-bright);font-size:.9em;}
.topbar{position:sticky;top:0;z-index:60;display:flex;align-items:center;gap:1rem;flex-wrap:wrap;padding:.5rem 1.1rem;background:rgba(10,10,10,.92);backdrop-filter:blur(10px);border-bottom:1px solid var(--gold-line);font-family:var(--mono);font-size:10.5px;letter-spacing:.1em;text-transform:uppercase;color:var(--gold);}
.topbar .sep{color:var(--dim);}
.topbar .live{display:inline-flex;align-items:center;gap:.4rem;color:var(--cream);}
.live-dot{width:6px;height:6px;border-radius:50%;background:var(--live);box-shadow:0 0 6px var(--live);animation:pulse 2.2s ease-in-out infinite;}
@keyframes pulse{0%,100%{opacity:1;}50%{opacity:.35;}}
.switcher{margin-left:auto;display:flex;align-items:center;gap:.3rem;flex-wrap:wrap;}
.flag{padding:.22rem .55rem;border-radius:6px;border:1px solid transparent;color:var(--muted);transition:.15s;}
.flag:hover{color:var(--cream);border-color:var(--gold-line);background:var(--gold-soft);}
.flag.active{color:var(--ground);background:var(--gold);border-color:var(--gold);font-weight:600;}
.wrap{max-width:1320px;margin:0 auto;padding:1.6rem 1.4rem 4rem;}
h1{font-size:1.75rem;font-weight:600;margin:.2rem 0 .3rem;letter-spacing:-.01em;}
.badge{display:inline-block;font-family:var(--mono);font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--teal);border:1px solid var(--teal-line);background:var(--teal-soft);padding:.25rem .6rem;border-radius:5px;margin-left:.4rem;vertical-align:middle;}
.lede{color:var(--paragraph);font-size:.95rem;line-height:1.65;max-width:1180px;margin:.6rem 0 1rem;}
.lede b{color:var(--cream);font-weight:600;}
.honest{border:1px solid var(--gold-line);background:var(--gold-soft);border-radius:8px;padding:.7rem 1rem;margin:.4rem 0 1.2rem;font-family:var(--mono);font-size:11.5px;color:var(--paragraph);line-height:1.7;}
.honest .k{color:var(--gold);text-transform:uppercase;letter-spacing:.08em;font-size:10px;}
.honest .hi{color:var(--teal);}
.cards{display:grid;grid-template-columns:repeat(4,1fr);gap:.8rem;margin:0 0 1.2rem;}
.card{border:1px solid var(--gold-line);background:var(--panel);border-radius:8px;padding:.85rem 1rem;}
.card .lbl{font-family:var(--mono);font-size:9.5px;letter-spacing:.1em;text-transform:uppercase;color:var(--dim);}
.card .big{font-size:1.5rem;font-weight:600;margin:.35rem 0 .15rem;color:var(--teal);}
.card .sub{font-family:var(--mono);font-size:10.5px;color:var(--muted);}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:1rem;}
.panel{border:1px solid var(--gold-line);background:var(--panel);border-radius:10px;padding:1rem 1.1rem;margin-bottom:1rem;}
.panel h2{font-size:1.05rem;font-weight:600;margin:0 0 .2rem;display:flex;align-items:center;justify-content:space-between;gap:.5rem;}
.panel h2 .meta{font-family:var(--mono);font-size:10px;color:var(--dim);text-transform:uppercase;letter-spacing:.06em;}
.panel .desc{color:var(--paragraph);font-size:.85rem;line-height:1.55;margin:.1rem 0 .6rem;}
.kv{font-family:var(--mono);font-size:12px;color:var(--paragraph);line-height:1.9;margin-top:.4rem;}
.kv .k{color:var(--dim);display:inline-block;min-width:150px;}
.kv .v{color:var(--cream);}
.pill{display:inline-block;font-family:var(--mono);font-size:10px;letter-spacing:.06em;text-transform:uppercase;padding:.18rem .5rem;border-radius:5px;border:1px solid var(--gold-line);}
.pill.green{color:var(--green);border-color:rgba(57,217,138,.4);background:rgba(57,217,138,.08);}
.pill.yellow{color:var(--yellow);border-color:rgba(245,196,81,.4);background:rgba(245,196,81,.08);}
.pill.red{color:var(--red);border-color:rgba(255,106,90,.4);background:rgba(255,106,90,.08);}
.pill.blue{color:var(--blue);border-color:rgba(91,200,255,.4);background:rgba(91,200,255,.08);}
.pill.dim{color:var(--muted);}
.expert{border:1px solid var(--gold-line);border-radius:8px;padding:.65rem .8rem;margin-bottom:.55rem;background:var(--panel2);}
.expert .hd{display:flex;align-items:center;justify-content:space-between;gap:.5rem;}
.expert .nm{font-weight:600;color:var(--gold-bright);}
.expert .det{font-family:var(--mono);font-size:11px;color:var(--paragraph);line-height:1.7;margin-top:.35rem;}
.expert .det .k{color:var(--dim);}
.btn{font-family:var(--mono);font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--ground);background:var(--gold);border:none;border-radius:6px;padding:.5rem .9rem;cursor:pointer;transition:.15s;}
.btn:hover{background:var(--gold-bright);}
.btn.ghost{color:var(--gold);background:transparent;border:1px solid var(--gold-line);}
.btn.ghost:hover{background:var(--gold-soft);}
input[type=text]{font-family:var(--mono);font-size:12px;background:var(--panel2);color:var(--cream);border:1px solid var(--gold-line);border-radius:6px;padding:.5rem .7rem;width:100%;}
.row{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;margin:.4rem 0;}
pre.rcpt{font-family:var(--mono);font-size:10.5px;color:var(--teal);background:#060606;border:1px solid var(--teal-line);border-radius:6px;padding:.6rem .7rem;overflow-x:auto;max-height:220px;white-space:pre-wrap;word-break:break-all;}
.bar{height:10px;border-radius:5px;background:#111;overflow:hidden;margin:.25rem 0;}
.bar > i{display:block;height:100%;background:linear-gradient(90deg,var(--teal),var(--gold));}
.muted{color:var(--muted);}
.tiergrid{display:grid;grid-template-columns:1fr 1fr;gap:.8rem;}
.tier{border:1px solid var(--gold-line);border-radius:8px;padding:.7rem .85rem;background:var(--panel2);}
.tier h3{margin:0 0 .25rem;font-size:.98rem;}
table.tau{width:100%;border-collapse:collapse;font-family:var(--mono);font-size:11px;margin-top:.5rem;}
table.tau th,table.tau td{text-align:left;padding:.3rem .5rem;border-bottom:1px solid var(--gold-line);color:var(--paragraph);}
table.tau th{color:var(--dim);text-transform:uppercase;font-size:9.5px;letter-spacing:.06em;}
.footer{color:var(--dim);font-family:var(--mono);font-size:10.5px;line-height:1.7;margin-top:1.5rem;border-top:1px solid var(--gold-line);padding-top:1rem;}
.cross{display:flex;gap:.5rem;flex-wrap:wrap;margin:.5rem 0;}
.cross a{font-family:var(--mono);font-size:10.5px;color:var(--teal);border:1px solid var(--teal-line);border-radius:5px;padding:.2rem .5rem;}
</style>
</head>
<body>
<div class="topbar">
  <span>SZL HOLDINGS</span><span class="sep">/</span><span>SZL-Nemo</span>
  <span class="live"><span class="live-dot"></span><span id="livelbl">LIVE</span></span>
  <span class="sep">·</span><span id="signerlbl">signer —</span>
  <span class="switcher">
    <a class="flag active" href="/nemo">SZL-Nemo</a>
    <a class="flag" href="/governance">Governance</a>
    <a class="flag" href="/energy">Energy</a>
    <a class="flag" href="/agent-loop">Agent Loop</a>
    <a class="flag" href="/router-crossover">Router</a>
    <a class="flag" href="/code">Code</a>
  </span>
</div>

<div class="wrap">
  <h1>SZL-Nemo <span class="badge" id="b_model">RUNTIME-BOUND · NOT FINE-TUNED</span></h1>
  <div class="lede">
    <b>SZL-Nemo</b> is an <b>identity-bound local recipe and governed orchestration runtime</b>.
    <b id="framing">Built on NVIDIA Nemotron 3 Nano 4B; the weights are NVIDIA's and are not SZL-fine-tuned.</b>
    The differentiator is an <b>auditable domain router</b>: a query is routed to
    <b>domain-expert heads</b> by a <b>Λ-governed router</b> (Conjecture 1, advisory floor &lt; 1.0) that reuses
    the active-flux router crossover and the RouteLLM Thompson posteriors — and <b>every expert selection emits a
    signed DSSE receipt</b>.
  </div>
  <div class="honest">
    <span class="k">Honest by design.</span>
    We did <b class="hi">NOT</b> train a foundation model from scratch — there is <b class="hi">no 550B SZL model</b> and
    <b class="hi">no local Nemotron-Ultra</b> (cloud tier only). OUR contribution is the governance layer:
    governed-MoE domain-expert routing, MTP / speculative-decode default, Reflexion + Voyager + τ-bench
    self-improvement experiments, exact-tag local serving, and tamper-evident signed receipts.
    <span class="hi">sovereign:true</span> only with a live per-GPU <code>gpu_reachable</code> probe; the cloud tier is
    always <code>sovereign:false</code>. Every number is <b>MEASURED</b> (live) or <b>ROADMAP</b> — never fabricated.
    Λ = Conjecture 1 (advisory, never a pass/fail oracle); trust &lt; 100%; locked-8 @ c7c0ba17; 0 runtime JS CDN;
    effectors SIMULATED human-on-loop. Fonts self-hosted (0 runtime CDN of any kind).
  </div>

  <div class="cross">
    <span class="muted mono" style="font-size:10px;align-self:center;">CROSS-LINK:</span>
    <a href="/governance">τ-bench &amp; calibration</a>
    <a href="/energy">J/token &amp; sovereign posture</a>
    <a href="/agent-loop">Reflexion / Voyager loop</a>
    <a href="/router-crossover">Active-flux crossover</a>
  </div>

  <div class="cards">
    <div class="card"><div class="lbl">Base (open, cited)</div><div class="big" id="c_base" style="font-size:1.2rem;"></div><div class="sub" id="c_baselic"></div></div>
    <div class="card"><div class="lbl">τ-bench (MEASURED-by-SZL)</div><div class="big" id="c_tau"></div><div class="sub" id="c_tausub"></div></div>
    <div class="card"><div class="lbl">MTP speedup (S)</div><div class="big" id="c_mtp"></div><div class="sub" id="c_mtpsub"></div></div>
    <div class="card"><div class="lbl">Sovereign-local</div><div class="big" id="c_sov" style="font-size:1.2rem;"></div><div class="sub" id="c_sovsub">live gpu_reachable probe</div></div>
  </div>

  <!-- GOVERNED-MoE ROUTER -->
  <div class="panel">
    <h2>Governed-MoE Domain-Expert Router <span class="meta">the differentiator · signed every selection</span></h2>
    <div class="desc">
      "Experts" are <b>domain heads</b> (counter-uas / maritime / governance / code / finance) — an <b>auditable MoE</b>,
      not learned FFN experts. Routing fuses the Λ governance score (Conjecture 1) with the active-flux serving
      crossover (small/local ⇄ large/cloud) and the RouteLLM Thompson posteriors. Try a query:
    </div>
    <div class="row">
      <input type="text" id="q" value="intercept a hostile drone swarm with the interceptor"/>
    </div>
    <div class="row">
      <button class="btn" id="go">Route &amp; sign</button>
      <button class="btn ghost" data-q="audit the compliance policy and check the Λ gate and conformal coverage">Governance query</button>
      <button class="btn ghost" data-q="size a finance portfolio with Kelly and Ledoit-Wolf covariance">Finance query</button>
      <button class="btn ghost" data-q="track the vessel via AIS and flag the maritime anomaly">Maritime query</button>
      <span id="r_lambda" class="pill dim">Λ —</span>
    </div>
    <div id="experts"></div>
    <div style="margin-top:.6rem;">
      <div class="meta mono" style="color:var(--dim);font-size:10px;">SIGNED DSSE RECEIPT (route decision)</div>
      <pre class="rcpt" id="r_receipt"></pre>
      <div class="kv"><span class="k">verify</span><span class="v" id="r_verify"></span></div>
    </div>
  </div>

  <!-- a11oy RESTRAINT (gates the CODE path before any diff is emitted) -->
  <div class="panel">
    <h2>a11oy Restraint <span class="meta">code-frugality ladder · gates the code path before emit · signed</span></h2>
    <div class="desc">
      Before SZL-Nemo emits ANY code, the intended diff is routed through the governed, Ponytail-derived
      <b>6-rung frugality ladder</b> (YAGNI → stdlib → native → installed-deps → one-liner → minimal). The chosen rung,
      the <code>restraint:</code> ceiling, a lines-saved estimate and a <b>signed restraint receipt</b> are attached to the
      Nemo response. Adopted from <a href="https://github.com/DietrichGebert/ponytail" target="_blank" rel="noopener">Ponytail (MIT)</a>,
      governed + Λ-scored here. <b>R1 owns the ladder module</b>; if it isn't live yet this reads honest <b>PENDING</b>
      (no rung or number fabricated).
    </div>
    <div class="row">
      <input type="text" id="cq" value="write me a Python function that validates email addresses"/>
      <button class="btn" id="cgo">Ask SZL-Nemo for code →</button>
      <span id="c_rung" class="pill dim">rung —</span>
      <span id="c_status" class="pill dim"></span>
    </div>
    <div class="kv" id="c_restraint" style="margin-top:.5rem;">— (ask SZL-Nemo for code to see the restraint verdict)</div>
    <div style="margin-top:.6rem;">
      <div class="meta mono" style="color:var(--dim);font-size:10px;">SIGNED RESTRAINT RECEIPT (nested in the Nemo code receipt)</div>
      <pre class="rcpt" id="c_receipt"></pre>
      <div class="kv"><span class="k">verify</span><span class="v" id="c_verify"></span></div>
    </div>
  </div>

  <!-- ============ 3D ROUTER DASHBOARD (F4 · additive · toggle enhancement; 2D pages above remain the fallback) ============ -->
  <div class="panel" id="router3d_panel">
    <h2>3D Router Dashboard <span class="meta">GPU blocks · particle token-flows · signed MoE routing pulses · live J/token</span>
      <button class="btn ghost" id="r3d_toggle" style="float:right;font-size:11px;">Enable 3D</button>
    </h2>
    <div class="desc">
      Holographic view of the sovereign-inference fleet: each serving <b>tier is a GPU block</b> (color = where/sovereign,
      honest <code>gpu_reachable</code> probe), animated <b>particle token-flows</b> stream from the router to the selected
      domain-expert heads, and a <b>signed routing pulse</b> lights the chosen edge when a route receipt is signed.
      The <b>J/token</b> counter is <b>MEASURED only on a live GPU power probe</b>; with no meter wired it stays an honest
      <b>ROADMAP</b> estimate (never presented as measured). Renders on the shared 0-CDN WebGL2 kit; <b>CPU/old-GPU falls
      back to a 2D canvas</b>; the panels above are the full non-3D experience. Patterns: vLLM/SGLang, NVIDIA Dynamo,
      LiteLLM, RouteLLM.
    </div>
    <div class="r3d-stats mono" style="display:flex;gap:1.2rem;flex-wrap:wrap;font-size:11px;color:var(--muted);margin:.5rem 0;">
      <span>J/token <span id="r3d_jtok" style="color:var(--warn)"></span> <span id="r3d_jtok_lbl"></span></span>
      <span>tokens routed <span id="r3d_toks" style="color:var(--blue)">0</span></span>
      <span>signed pulses <span id="r3d_pulses" style="color:var(--teal)">0</span></span>
      <span>Λ advisory <span id="r3d_lambda" style="color:var(--cream)"></span></span>
      <span id="r3d_caps" style="color:var(--dim)"></span>
    </div>
    <div id="router3d_mount" style="width:100%;height:440px;border:1px solid var(--gold-line);border-radius:10px;background:#060606;display:none;position:relative;"></div>
    <div class="empty" id="r3d_off">3D is off (default). Click <b>Enable 3D</b> to render the holographic router on the live <code>/nemo/tiers</code> + <code>/nemo/route</code> + <code>/energy/budget</code> endpoints. The 2D dashboard above is always available as the fallback.</div>
    <div class="meta mono" style="color:var(--dim);font-size:10px;margin-top:.5rem;">
      0 runtime CDN · WebGL2 baseline + honest 2D fallback · J/token MEASURED-or-ROADMAP (never fabricated) · sovereign:true only on live probe · Λ = Conjecture 1 (&lt;1.0) · trust &lt;100%.
    </div>
  </div>

  <div class="grid2">
    <!-- MTP -->
    <div class="panel">
      <h2>MTP / Speculative Decoding <span class="meta">inference default</span></h2>
      <div class="desc">Speedup <code>S = (k+1) / (k(1−α)+1)</code> (Leviathan et al. 2022). Draft model serves k tokens,
        target accepts at rate α. This remains ROADMAP and is not enabled on the verified Ollama path.</div>
      <div class="kv" id="mtp_kv"></div>
    </div>
    <!-- SELF-IMPROVEMENT -->
    <div class="panel">
      <h2>Self-Improvement Loop <span class="meta">Reflexion + Voyager + τ-bench</span></h2>
      <div class="desc">Runs the REAL τ-bench (Dev B) for a deliberately weaker baseline, adopts rule-following
        (Reflexion), admits a Voyager skill, re-runs, and <b>signs the measured delta</b>. Score history lives inside receipts.</div>
      <div class="row"><button class="btn" id="si_go">Run one iteration &amp; sign delta</button></div>
      <div class="kv" id="si_kv"></div>
      <div class="meta mono" style="color:var(--dim);font-size:10px;margin-top:.4rem;">SIGNED DELTA RECEIPT</div>
      <pre class="rcpt" id="si_receipt" style="max-height:150px;">— (run an iteration)</pre>
    </div>
  </div>

  <!-- TIERS -->
  <div class="panel">
    <h2>Serving Tiers <span class="meta">honest where / sovereign labels</span></h2>
    <div class="desc">sovereign:true ONLY with a live per-GPU <code>gpu_reachable</code> probe (Dev C). The cloud NIM
      frontier tier (Nemotron Ultra) is always <code>sovereign:false</code> — it needs ~768GB VRAM and cannot run on the 2 GPUs.</div>
    <div class="tiergrid" id="tiers"></div>
  </div>

  <!-- TAU + CARD -->
  <div class="grid2">
    <div class="panel">
      <h2>τ-bench — MEASURED-by-SZL <span class="meta">Dev B real suite</span></h2>
      <div class="desc">SZL τ-bench-style tool-rule-following suite with negative controls; an always-pass agent scores 0,
        proving non-triviality. NOT the upstream leaderboard.</div>
      <div class="kv" id="tau_kv"></div>
    </div>
    <div class="panel">
      <h2>Model Card <span class="meta">base cited · what's ours</span></h2>
      <div class="kv" id="card_kv"></div>
    </div>
  </div>

  <div class="footer" id="footer">
    SZL-Nemo runtime-bound recipe · <span id="f_diag">diag —</span><br/>
    Sources: NVIDIA Nemotron 3 Nano 4B · speculative decoding arXiv:2211.17192 · Reflexion arXiv:2303.11366 ·
    Voyager arXiv:2305.16291 · τ-bench arXiv:2406.12045 · RouteLLM (lm-sys) · active-flux crossover IEEE/APEC 911711 ·
    Nemotron via NVIDIA NIM build.nvidia.com. Receipts: DSSE ECDSA-P256-SHA256, verify against /cosign.pub.
  </div>
</div>

<!-- Shared estate modules (0 CDN; same-origin). Honest labels + receipt verify. -->
<script src="/static/shared/szl_label_engine.js"></script>
<script src="/static/shared/szl_receipt_cosign.js"></script>

<!-- F4 · 3D Router Dashboard logic (additive). Loads the shared 0-CDN holographic kit. -->
<script src="/static/shared/szl_holo3d.js"></script>
<script>
"use strict";
(function(){
  var A3="/api/a11oy/v1";
  var mount=document.getElementById('router3d_mount');
  var offEl=document.getElementById('r3d_off');
  var toggle=document.getElementById('r3d_toggle');
  if(!mount||!toggle||!window.SZLHolo){ if(toggle){toggle.disabled=true;toggle.textContent='3D unavailable';} return; }
  var scene=null, started=false, poll=null, animTimer=null;
  var tokens=0, pulses=0;
  var GP=document.getElementById('r3d_jtok'), GPL=document.getElementById('r3d_jtok_lbl');
  var TK=document.getElementById('r3d_toks'), PU=document.getElementById('r3d_pulses');
  var LM=document.getElementById('r3d_lambda'), CAP=document.getElementById('r3d_caps');

  function getJSON(u,opt){return fetch(u,opt).then(function(r){return r.ok?r.json():null;}).catch(function(){return null;});}

  // Honest J/token: MEASURED only if the budget endpoint reports a real metered
  // joules figure (joules_label !== 'sample' AND a non-empty joules_evidence).
  // Otherwise ROADMAP — never present an estimate as measured.
  function applyJtoken(b){
    if(!b){ GP.textContent='—'; GPL.innerHTML=''; return; }
    var lbl=String(b.joules_label||'').toLowerCase();
    var ev=b.joules_evidence||{};
    var measured=(lbl==='measured') && ev && Object.keys(ev).length>0;
    var toks=Number(b.total_output_bytes||0); // bytes proxy until a token meter exists
    var joules=Number(b.total_joules_est||0);
    var jpt=(measured && toks>0)?(joules/toks):null;
    if(measured && jpt!=null){
      GP.textContent=jpt.toFixed(4)+' J/tok';
      GPL.innerHTML='<span class="pill green" style="font-size:9px">MEASURED · live probe</span>';
    }else{
      // honest ROADMAP: show the SAMPLE estimate context but never claim measured
      GP.textContent=(joules>0&&toks>0)?(joules/toks).toFixed(4)+' J/tok*':'— J/tok';
      GPL.innerHTML='<span class="pill yellow" style="font-size:9px">ROADMAP · no meter ('+esc3(b.total_joules_est_label||'SAMPLE/ESTIMATE')+')</span>';
    }
  }
  function esc3(s){return String(s==null?'':s).replace(/[&<>"']/g,function(c){return({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]||c);});}

  // Build the 3D graph: router hub -> domain-expert heads; GPU blocks = tiers.
  // NOTE: the F1 kit addGraph() consumes edge.from / edge.to (NOT source/target);
  // signPulse(edgeId) matches edge.id. We assign explicit ids so pulses light the
  // correct router->expert edge.
  var _edgeIdFor={};
  function buildGraph(tiers, experts){
    var nodes=[{id:'router',label:'Λ-ROUTER'}];
    var edges=[]; _edgeIdFor={}; var ei=0;
    // GPU/tier blocks as nodes hanging off the router
    (tiers||[]).forEach(function(t,i){
      var sov=(t.sovereign===true);
      var lab=(t.where==='gpu'?'GPU·':'CLOUD·')+(sov?'SOV':'ROADMAP');
      var id='tier'+i;
      nodes.push({id:id,label:lab});
      edges.push({id:'e'+(ei++),from:'router',to:id});
    });
    // domain-expert heads (auditable MoE) from the last route
    (experts||[]).forEach(function(e,i){
      var id='exp_'+(e.expert_id||i);
      var eid='e'+(ei++);
      nodes.push({id:id,label:String(e.title||e.expert_id||('exp'+i)).slice(0,10)});
      edges.push({id:eid,from:'router',to:id});
      _edgeIdFor[id]=eid;
    });
    return {nodes:nodes,edges:edges};
  }

  var lastExperts=[];
  function rebuild(tiers){
    if(!scene)return;
    try{
      var spec=buildGraph(tiers,lastExperts);
      // clear & re-add graph (kit is additive; we re-create scene graph list)
      scene.graphs=[]; scene.pulses=[]; scene.spheres=[];
      scene.addGraph(spec);
      // drive trust sphere by latest Λ advisory (Conjecture 1, <1.0)
      var lam=window.__r3dLambda; if(typeof lam!=='number')lam=0.62; scene.addTrustSphere({lambda:lam}); scene.setLambda(lam);
    }catch(e){}
  }

  // Animate particle token-flows: emit signPulses along router->expert edges.
  function tokenFlow(){
    if(!scene||!lastExperts.length)return;
    lastExperts.forEach(function(e){
      var id='exp_'+(e.expert_id);
      var eid=_edgeIdFor[id];
      try{ scene.signPulse(eid!=null?eid:0); }catch(_){}
      tokens+=Math.max(1,Math.round((e.selection_score||1)*4));
    });
    TK.textContent=tokens;
  }

  // A signed MoE routing pulse fires when a route receipt is signed.
  function signedRoutePulse(d){
    var r=(d&&d.receipt)||{};
    var signed=(r.signatures&&r.signatures.length)||r.signed===true;
    lastExperts=(d&&d.experts)||[];
    var lam=null;
    lastExperts.forEach(function(e){ if(e.lambda_advisory!=null){ lam=(lam==null)?e.lambda_advisory:Math.min(lam,e.lambda_advisory);} });
    if(lam!=null){ window.__r3dLambda=Math.min(0.999,lam); LM.textContent=lam.toFixed(3)+(lam<0.90?' ⚠':''); }
    rebuildLatest();
    if(signed){ pulses++; PU.textContent=pulses; tokenFlow(); }
  }
  var _lastTiers=[];
  function rebuildLatest(){ rebuild(_lastTiers); }

  function refresh(){
    getJSON(A3+'/nemo/tiers').then(function(t){ _lastTiers=(t&&t.tiers)||[]; rebuildLatest(); });
    getJSON(A3+'/energy/budget').then(applyJtoken);
  }

  // Route on demand (reuses the page's query box if present); also auto-demo a route.
  function routeOnce(){
    var q=(document.getElementById('q')&&document.getElementById('q').value)||'prove a lemma and refactor the module';
    getJSON(A3+'/nemo/route',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({query:q,top_k:2})})
      .then(function(d){ if(d) signedRoutePulse(d); });
  }

  function start(){
    if(started)return; started=true;
    mount.style.display='block'; offEl.style.display='none'; toggle.textContent='Disable 3D';
    scene=window.SZLHolo.createScene(mount,{sample:false});
    var caps=window.SZLHolo.capabilities();
    CAP.textContent='mode:'+caps.mode+(caps.webgpu?' · webgpu-detected(ROADMAP)':'');
    scene.addGraph(buildGraph([], []));
    scene.addTrustSphere({lambda:0.62});
    scene.start();
    refresh(); routeOnce();
    poll=setInterval(refresh,30000);
    animTimer=setInterval(tokenFlow,2600);
    // hook the existing "Route & sign" button so a real signed route fires a pulse here too
    var go=document.getElementById('go');
    if(go && !go.__r3d){ go.__r3d=true; go.addEventListener('click',function(){ setTimeout(routeOnce,400); }); }
  }
  function stop(){
    if(!started)return; started=false;
    mount.style.display='none'; offEl.style.display='block'; toggle.textContent='Enable 3D';
    if(poll)clearInterval(poll); if(animTimer)clearInterval(animTimer);
    try{ if(scene)scene.stop(); if(scene)scene.dispose(); }catch(e){}
    scene=null;
  }
  toggle.addEventListener('click',function(){ started?stop():start(); });
})();
</script>

<script>
const A="/api/a11oy/v1/nemo";
const $=id=>document.getElementById(id);
function esc(s){return String(s==null?'':s).replace(/[&<>"']/g,function(c){return({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]||c);});}
function fmt(n,d){if(n==null||isNaN(n))return '—';const x=Number(n);return d!=null?x.toFixed(d):String(x);}
async function getJSON(u,opt){try{const r=await fetch(u,opt);if(!r.ok)return null;return await r.json();}catch(e){return null;}}
function pill(txt,cls){return `<span class="pill ${cls||'dim'}">${esc(txt)}</span>`;}
function labelPill(key){
  try{ if(window.SZLLabels&&window.SZLLabels.badgeHTML){return window.SZLLabels.badgeHTML(key);} }catch(e){}
  const k=String(key||'').toUpperCase();
  const cls=(k==='MEASURED'||k==='LIVE')?'green':(k==='ROADMAP'||k==='EXPERIMENTAL'||k==='MODELED')?'yellow':'dim';
  return pill(k,cls);
}

function renderExperts(d){
  const wrap=$('experts'); wrap.innerHTML='';
  (d.experts||[]).forEach(e=>{
    const cr=e.serving_crossover||{};
    const lamCls=e.below_advisory_floor?'yellow':'green';
    const wS=(cr.weight_small_local!=null)?Math.round(cr.weight_small_local*100):null;
    const div=document.createElement('div'); div.className='expert';
    div.innerHTML=
      `<div class="hd"><span class="nm">${esc(e.title)} <span class="muted mono" style="font-size:10px;">${esc(e.expert_id)}</span></span>`+
      `${pill('Λ '+fmt(e.lambda_advisory,3),lamCls)} ${pill(cr.route||'—',(cr.route==='small/local')?'blue':'gold')}</div>`+
      `<div class="det">`+
        `<div><span class="k">matched</span> ${esc((e.matched_keywords||[]).join(', ')||'(low overlap)')}</div>`+
        `<div><span class="k">governance</span> ${esc(e.governance_note||'')}</div>`+
        `<div><span class="k">serving</span> ${esc(cr.route||'—')} · regime ${esc(cr.regime||'—')} · difficulty ${fmt(cr.query_difficulty,3)} · reuse: ${esc((cr.reuse||'').split('(')[0])}</div>`+
        (wS!=null?`<div class="bar"><i style="width:${wS}%"></i></div><div class="muted" style="font-size:10px;">small/local ${wS}% · large/cloud ${100-wS}%</div>`:'')+
      `</div>`;
    wrap.appendChild(div);
  });
  $('r_lambda').textContent='Λ '+fmt(d.overall_lambda_advisory,3);
  $('r_lambda').className='pill '+(d.overall_lambda_advisory>=0.9?'green':'yellow');
}

async function doRoute(q){
  const d=await getJSON(A+"/route",{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({query:q,top_k:2})});
  if(!d){$('experts').innerHTML='<div class="muted mono">route endpoint unreachable</div>';return;}
  renderExperts(d);
  const r=d.receipt||{};
  $('r_receipt').textContent=JSON.stringify(r,null,1);
  // verify the signature against /cosign.pub via the shared verifier
  if(r.signatures&&r.signatures.length&&window.SZLReceipts&&window.SZLReceipts.verifyEnvelope){
    $('r_verify').textContent='verifying…';
    try{
      const v=await window.SZLReceipts.verifyEnvelope(r,{});
      const ok=v&&(v.valid||v.signature_valid);
      $('r_verify').innerHTML=ok?pill('SIGNATURE VALID','green'):pill('signed (server-verify)','blue')+' '+esc((v&&v.detail)||r.honesty||'');
    }catch(e){$('r_verify').innerHTML=pill('signed','blue')+' '+esc(r.honesty||'');}
  }else{
    $('r_verify').innerHTML=(r.signed===false)?pill('UNSIGNED','yellow')+' '+esc(r.honesty||''):pill('signed','blue')+' '+esc(r.honesty||'');
  }
}

async function doCode(q){
  $('c_restraint').innerHTML='<span class="muted mono">routing the intended diff through a11oy Restraint…</span>';
  $('c_rung').textContent='rung …'; $('c_rung').className='pill dim';
  $('c_status').textContent='…'; $('c_status').className='pill dim';
  const d=await getJSON(A+"/code",{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({query:q})});
  if(!d){$('c_restraint').innerHTML='<div class="muted mono">code endpoint unreachable</div>';return;}
  const rs=d.restraint||{};
  const status=String(rs.status||'PENDING');
  const live=(status==='LIVE');
  // "Restraint applied" indicator: rung + lines-saved estimate + restraint: ceiling
  // PENDING is not in the shared canonical vocabulary (R1 owns labels); show the
  // closest honest canonical badge (ROADMAP) + the literal PENDING word in text.
  $('c_status').innerHTML = live ? labelPill('LIVE') : (labelPill('ROADMAP')+' <span class="pill yellow">PENDING</span>');
  if(rs.stopped_at_rung!=null){
    $('c_rung').textContent='rung '+rs.stopped_at_rung+' · '+(rs.rung_key||'');
    $('c_rung').className='pill green';
  }else{
    $('c_rung').textContent='rung — (PENDING)'; $('c_rung').className='pill yellow';
  }
  const saved=(rs.lines_saved_estimate!=null)?(rs.lines_saved_estimate+' LOC ('+esc(rs.lines_saved_label||'MODELED')+')'):'— (not measured)';
  const lam=(rs.lambda_advisory!=null)?fmt(rs.lambda_advisory,3):'—';
  const applied = live
    ? `<span class="pill green">Restraint applied</span>`
    : `<span class="pill yellow">Restraint PENDING</span>`;
  $('c_restraint').innerHTML=
    `<div>${applied} <span class="k">rung</span> <span class="v">${rs.stopped_at_rung!=null?(rs.stopped_at_rung+' · '+esc(rs.rung_name||rs.rung_key||'')):'—'}</span></div>`+
    `<div><span class="k">lines saved (est.)</span> <span class="v">${saved}</span></div>`+
    `<div><span class="k">Λ advisory</span> <span class="v">${lam}</span></div>`+
    (rs.restraint_comment?`<div><span class="k">restraint: ceiling</span> <code class="mono" style="font-size:10.5px;">${esc(rs.restraint_comment)}</code></div>`:
      (rs.ceiling?`<div><span class="k">ceiling</span> <span class="v">${esc(rs.ceiling)}</span></div>`:''))+
    `<div class="muted" style="font-size:10px;margin-top:.3rem;">integration: ${esc(rs.integration||'')}</div>`+
    (rs.honesty?`<div class="muted" style="font-size:10px;">${esc(rs.honesty)}</div>`:'')+
    `<div class="muted" style="font-size:10px;">Ponytail (MIT) — adopted + governed · R1 owns a11oy_restraint.py</div>`;
  // signed restraint receipt (nested in the Nemo code receipt)
  const r=d.restraint_receipt||rs.restraint_receipt||{};
  $('c_receipt').textContent=JSON.stringify(r,null,1);
  if(r&&r.signatures&&r.signatures.length&&window.SZLReceipts&&window.SZLReceipts.verifyEnvelope){
    $('c_verify').textContent='verifying…';
    try{
      const v=await window.SZLReceipts.verifyEnvelope(r,{});
      const ok=v&&(v.valid||v.signature_valid);
      $('c_verify').innerHTML=ok?pill('SIGNATURE VALID','green'):pill('signed (server-verify)','blue');
    }catch(e){$('c_verify').innerHTML=pill('signed','blue');}
  }else{
    $('c_verify').innerHTML=(r&&r.signed===false)?pill('UNSIGNED/PENDING','yellow')+' '+esc(r.honesty||''):pill('—','dim');
  }
}

async function loadMTP(){
  const d=await getJSON(A+"/mtp"); if(!d){$('mtp_kv').textContent='unreachable';return;}
  $('mtp_kv').innerHTML=
    `<div><span class="k">status</span> ${labelPill(d.label)}</div>`+
    `<div><span class="k">draft → target</span> <span class="v">${esc(d.draft_model)}${esc(d.target_model)}</span></div>`+
    `<div><span class="k">k / α</span> <span class="v">k=${d.num_speculative_tokens_k} · α=${d.acceptance_rate_alpha}</span></div>`+
    `<div><span class="k">speedup S</span> <span class="v">${fmt(d.speedup_estimate,2)}×</span></div>`+
    `<div class="muted" style="font-size:10.5px;line-height:1.6;margin-top:.3rem;">${esc(d.honesty)}</div>`+
    `<div class="muted" style="font-size:10px;margin-top:.2rem;">${esc(d.box_status)}</div>`;
  $('c_mtp').textContent=fmt(d.speedup_estimate,2)+'×';
  $('c_mtpsub').textContent='k='+d.num_speculative_tokens_k+' · α='+d.acceptance_rate_alpha+' · '+d.label;
}

async function loadTiers(){
  const d=await getJSON(A+"/tiers"); if(!d){$('tiers').textContent='unreachable';return;}
  $('tiers').innerHTML='';
  (d.tiers||[]).forEach(t=>{
    const sov=t.sovereign===true;
    const div=document.createElement('div'); div.className='tier';
    div.innerHTML=
      `<h3>${esc(t.title)} ${labelPill(t.label)}</h3>`+
      `<div class="kv">`+
        `<div><span class="k">where</span> ${pill(t.where, t.where==='gpu'?'green':'blue')}</div>`+
        `<div><span class="k">sovereign</span> ${pill(String(sov), sov?'green':'yellow')}</div>`+
        `<div><span class="k">base</span> <span class="v">${esc(t.base_model)}</span></div>`+
        `<div class="muted" style="font-size:10.5px;line-height:1.6;margin-top:.3rem;">${esc(t.plan)}</div>`+
        `<div class="muted" style="font-size:10px;margin-top:.2rem;">${esc(t.honesty)}</div>`+
      `</div>`;
    $('tiers').appendChild(div);
    if(t.tier_id==='sovereign-local'){
      $('c_sov').textContent=sov?'true':'false';
      $('c_sov').style.color=sov?'var(--green)':'var(--yellow)';
      $('c_sovsub').textContent=esc(t.probe_note||'live gpu_reachable probe');
    }
  });
}

async function loadTau(){
  const d=await getJSON(A+"/tau"); if(!d){$('tau_kv').textContent='unreachable';return;}
  if(d.score_pct==null){
    $('tau_kv').innerHTML=`<div>${labelPill('ROADMAP')} ${esc(d.honesty||'')}</div>`;
    $('c_tau').textContent='—'; $('c_tausub').textContent='not measured'; return;
  }
  $('tau_kv').innerHTML=
    `<div><span class="k">score (pass^1)</span> <span class="v">${fmt(d.score_pct,2)}%</span> ${labelPill(d.label)}</div>`+
    `<div><span class="k">suite</span> <span class="v">${esc(d.suite_id)} ${esc(d.suite_version)}</span></div>`+
    `<div><span class="k">tasks</span> <span class="v">${d.tasks_passed}/${d.tasks_total} · ${d.negative_controls} negative controls</span></div>`+
    `<div><span class="k">as-of</span> <span class="v">${esc((d.as_of||'').slice(0,10))}</span></div>`+
    `<div><span class="k">determinism</span> <span class="v mono">${esc(d.determinism_hash)}</span></div>`+
    `<div class="muted" style="font-size:10.5px;line-height:1.6;margin-top:.3rem;">${esc(d.honesty)}</div>`;
  $('c_tau').textContent=fmt(d.score_pct,1)+'%';
  $('c_tausub').textContent=d.tasks_passed+'/'+d.tasks_total+' · '+(d.as_of||'').slice(0,10);
}

async function loadCard(){
  const d=await getJSON(A+"/card"); if(!d){$('card_kv').textContent='unreachable';return;}
  const ours=(d.what_is_ours||[]).map(x=>`<li>${esc(x)}</li>`).join('');
  const notOurs=(d.what_is_NOT_ours||[]).map(x=>`<li>${esc(x)}</li>`).join('');
  $('card_kv').innerHTML=
    `<div><span class="k">name</span> <span class="v">${esc(d.name)} ${esc(d.version)}</span></div>`+
    `<div><span class="k">base</span> <span class="v">${esc(d.base.default_base)} (${esc(d.base.default_base_license)})</span></div>`+
    `<div class="k" style="margin-top:.4rem;">what is OURS</div><ul style="margin:.2rem 0 .4rem 1rem;color:var(--paragraph);font-size:10.5px;line-height:1.5;">${ours}</ul>`+
    `<div class="k">what is NOT ours</div><ul style="margin:.2rem 0 0 1rem;color:var(--paragraph);font-size:10.5px;line-height:1.5;">${notOurs}</ul>`;
  $('c_base').textContent=d.base.default_base;
  $('c_baselic').textContent=d.base.default_base_license;
  $('framing').textContent=d.base.honest_framing;
  $('b_model').textContent='EXPERIMENTAL · SKELETON · '+esc(d.version);
}

async function loadDiag(){
  const d=await getJSON(A+"/_diag"); if(!d){$('f_diag').textContent='diag unreachable';return;}
  const reuse=d.reuse||{};
  const on=Object.keys(reuse).filter(k=>reuse[k]);
  $('f_diag').textContent='reuse live: '+on.join(', ')+' · signer '+(d.signer_present?'PRESENT':'absent');
  $('signerlbl').textContent=d.signer_present?('signer '+(d.signer_label||'in-image')):'signer absent';
}

async function doSelfImprove(){
  $('si_kv').innerHTML='<span class="muted mono">running real τ-bench baseline + improved…</span>';
  const d=await getJSON(A+"/selfimprove",{method:'POST',headers:{'Content-Type':'application/json'},body:'{}'});
  if(!d){$('si_kv').textContent='unreachable';return;}
  if(d.error){$('si_kv').innerHTML=`<div>${labelPill('ROADMAP')} ${esc(d.error)}${esc(d.honesty||'')}</div>`;return;}
  const up=d.delta_pct>0;
  $('si_kv').innerHTML=
    `<div><span class="k">iteration</span> <span class="v">#${d.iteration}</span> ${labelPill(d.label)}</div>`+
    `<div><span class="k">baseline → improved</span> <span class="v">${fmt(d.baseline_score_pct,2)}% → ${fmt(d.improved_score_pct,2)}%</span></div>`+
    `<div><span class="k">delta</span> ${pill((up?'+':'')+fmt(d.delta_pct,2)+'%', up?'green':'yellow')}</div>`+
    `<div><span class="k">voyager skill</span> ${pill(d.voyager_skill_admitted?'ADMITTED':'not admitted', d.voyager_skill_admitted?'green':'yellow')}</div>`+
    `<div class="muted" style="font-size:10.5px;line-height:1.6;margin-top:.3rem;"><b>reflection:</b> ${esc(d.reflection)}</div>`;
  const r=d.receipt||{};
  $('si_receipt').textContent=JSON.stringify(r,null,1);
}

document.querySelectorAll('button.ghost[data-q]').forEach(b=>b.addEventListener('click',()=>{$('q').value=b.getAttribute('data-q');doRoute(b.getAttribute('data-q'));}));
$('go').addEventListener('click',()=>doRoute($('q').value));
$('cgo').addEventListener('click',()=>doCode($('cq').value));
$('si_go').addEventListener('click',doSelfImprove);

(async function(){
  await Promise.all([loadDiag(),loadMTP(),loadTiers(),loadTau(),loadCard()]);
  await doRoute($('q').value);
  await doCode($('cq').value);
})();
</script>
</body>
</html>