File size: 26,632 Bytes
ab626bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>a11oy — Proven Energy Engine · SZL Holdings</title>
<meta name="description" content="Live, honest view of the agentic-GPU engine: sovereign GPU posture (NVIDIA RTX 5000 @ betterwithage), the Bekenstein-gated energy+information budget ledger (F19/TH6, proven inequality), and the off-peak power window. Energy figures are SAMPLE/ESTIMATE — no real power meter is wired. No free-energy claims."/>
<link rel="preconnect" href="https://fonts.googleapis.com"/><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin/>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet"/>
<style>
:root{
  --ground:#0a0a0a; --panel:#0e0e0e; --panel2:#080808; --rail:#0b0b0b;
  --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; --warn:#c9a05f;
  --green:#39d98a; --yellow:#f5c451; --red:#ff6a5a; --blue:#5bc8ff;
  --mono:'JetBrains Mono',ui-monospace,SFMono-Regular,monospace;
  --display:'Space Grotesk',Georgia,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;}
.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;}
.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.7rem;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;}
.econ{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:12px;color:var(--paragraph);line-height:1.7;}
.econ .k{color:var(--gold);text-transform:uppercase;letter-spacing:.08em;font-size:10px;}
.econ .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;}
.panel h2 .meta{font-family:var(--mono);font-size:10px;color:var(--dim);text-transform:uppercase;letter-spacing:.06em;}
.kv{font-family:var(--mono);font-size:12px;color:var(--paragraph);line-height:1.9;margin-top:.5rem;}
.kv .k{color:var(--dim);display:inline-block;min-width:128px;}
.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.dim{color:var(--muted);}
.sample{font-family:var(--mono);font-size:9px;letter-spacing:.06em;text-transform:uppercase;color:var(--warn);border:1px solid var(--warn);border-radius:4px;padding:.05rem .3rem;margin-left:.35rem;white-space:nowrap;}
.simnote{border:1px solid var(--warn);background:rgba(201,160,95,.06);border-radius:8px;padding:.7rem .9rem;margin-top:.8rem;font-family:var(--mono);font-size:11px;color:#d8c39a;line-height:1.65;}
.simnote b{color:var(--warn);}
.bek{margin-top:.7rem;}
.bek-bar{position:relative;height:30px;border:1px solid var(--gold-line);border-radius:6px;background:#0c0c0c;overflow:hidden;}
.bek-fill{position:absolute;top:0;left:0;bottom:0;background:linear-gradient(90deg,rgba(95,179,163,.55),rgba(95,179,163,.9));transition:width .4s;}
.bek-fill.over{background:linear-gradient(90deg,rgba(255,106,90,.55),rgba(255,106,90,.95));}
.bek-ceiling{position:absolute;top:-3px;bottom:-3px;right:0;width:2px;background:var(--gold);box-shadow:0 0 6px var(--gold);}
.bek-lbl{display:flex;justify-content:space-between;font-family:var(--mono);font-size:10.5px;color:var(--muted);margin-top:.4rem;}
.win{display:grid;grid-template-columns:repeat(3,1fr);gap:.5rem;margin-top:.6rem;}
.win .cell{border:1px solid var(--gold-line);border-radius:7px;padding:.6rem .7rem;text-align:center;font-family:var(--mono);}
.win .cell .t{font-size:9.5px;letter-spacing:.1em;text-transform:uppercase;color:var(--dim);}
.win .cell .v{font-size:1.05rem;font-weight:600;margin-top:.25rem;color:var(--muted);}
.win .cell.on{border-color:var(--teal-line);background:var(--teal-soft);}
.win .cell.on .v{color:var(--teal);}
table{width:100%;border-collapse:collapse;margin-top:.6rem;font-family:var(--mono);font-size:11px;}
th,td{text-align:left;padding:.4rem .5rem;border-bottom:1px solid var(--gold-line);white-space:nowrap;}
th{color:var(--dim);font-weight:500;font-size:9.5px;letter-spacing:.08em;text-transform:uppercase;}
td{color:var(--paragraph);}
td.ok{color:var(--green);}
td.bad{color:var(--red);}
.scrollx{overflow-x:auto;}
.empty{font-family:var(--mono);font-size:11.5px;color:var(--muted);border:1px dashed var(--gold-line);border-radius:8px;padding:.9rem 1rem;margin-top:.6rem;line-height:1.6;}
.footnote{margin-top:1.6rem;font-family:var(--mono);font-size:10.5px;color:var(--muted);line-height:1.7;border-top:1px solid var(--gold-line);padding-top:.9rem;}
.footnote b{color:var(--cream);}
@media(max-width:980px){.cards{grid-template-columns:repeat(2,1fr);}.grid2{grid-template-columns:1fr;}}
</style>
</head>
<body>
<div class="topbar">
  <span>SZL HOLDINGS</span><span class="sep">/</span><span>a11oy</span><span class="sep">/</span><span>PROVEN ENERGY ENGINE</span>
  <span class="sep">/</span><span class="live"><span class="live-dot"></span><span id="livelbl">LIVE · RT</span></span>
  <span class="switcher">
    <a class="flag active" href="/energy">Energy</a>
    <a class="flag" href="/fleet-c2">Fleet C2</a>
    <a class="flag" href="/living-anatomy">Living Anatomy</a>
    <a class="flag" href="/code">Code</a>
  </span>
</div>
<div class="wrap">
  <h1>Proven Energy Engine<span class="badge">honest GPU posture · Bekenstein-gated budget (F19/TH6) · SAMPLE energy</span></h1>
  <p class="lede">A live, <b>honest</b> view of the agentic-GPU engine. Sovereign posture is read from <b>/code/healthz</b><b>sovereign:true only when the local GPU actually serves</b> (NVIDIA RTX 5000 @ betterwithage, Ollama/vLLM), else router fallback. Every task receipt passes the <b>Bekenstein gate</b><code>shannon_bits ≤ output_bytes·8</code> (F19/TH6, a <b>proven inequality</b>, not an assertion) — and the ledger sums them. <b>Energy figures are SAMPLE/ESTIMATE</b>: no real power meter is wired, so joules are labeled, never presented as measured. <b>No free-energy / perpetual-motion claims</b>: the engine harvests WASTED energy and proves bounded information work.</p>
  <div class="econ"><span class="k">Why it matters:</span> sovereignty and energy efficiency are <span class="hi">measured-or-labeled, never assumed</span> — the half-state (claiming more energy or sovereignty than is real) is the only unacceptable outcome, so this surface refuses to over-claim.</div>
  <div class="cards">
    <div class="card"><div class="lbl">Sovereign</div><div class="big" id="c_sov"></div><div class="sub">local GPU serving?</div></div>
    <div class="card"><div class="lbl">Tasks gated</div><div class="big" id="c_tasks" style="color:var(--blue)"></div><div class="sub">Bekenstein ledger</div></div>
    <div class="card"><div class="lbl">All within bound</div><div class="big" id="c_within" style="color:var(--green)"></div><div class="sub">F19/TH6 gate</div></div>
    <div class="card"><div class="lbl">Total joules <span class="sample">sample</span></div><div class="big" id="c_joules" style="color:var(--warn)"></div><div class="sub">estimate · not metered</div></div>
  </div>
  <div class="grid2">
    <div class="panel">
      <h2>(1) GPU engine status<span class="meta">/code/healthz</span></h2>
      <div class="kv" id="hz_kv" style="display:none">
        <div><span class="k">Hardware</span><span class="v">NVIDIA RTX 5000 @ betterwithage</span></div>
        <div><span class="k">Sovereign</span><span class="v" id="hz_sov"></span></div>
        <div><span class="k">Inference path</span><span class="v" id="hz_inf"></span></div>
        <div><span class="k">Backend / mode</span><span class="v" id="hz_back"></span></div>
        <div><span class="k">GPU</span><span class="v" id="hz_gpu"></span></div>
        <div><span class="k">Doctrine</span><span class="v" id="hz_doc"></span></div>
        <div><span class="k">Posture</span><span class="v" id="hz_posture"></span></div>
      </div>
      <div class="empty" id="hz_empty">/code/healthz unreachable — posture cannot be confirmed. Showing no sovereignty claim (honest empty-state).</div>
    </div>
    <div class="panel">
      <h2>(4) Power window<span class="meta">off-peak clock</span></h2>
      <div class="win" id="win">
        <div class="cell" data-w="cheap"><div class="t">Cheap (off-peak)</div><div class="v"></div></div>
        <div class="cell" data-w="normal"><div class="t">Normal</div><div class="v"></div></div>
        <div class="cell" data-w="dear"><div class="t">Dear (peak)</div><div class="v"></div></div>
      </div>
      <div class="simnote"><b>Client-side estimate:</b> the window (cheap / normal / dear) is computed from <b>your local clock</b> as an off-peak heuristic (cheap before 08:00 / after 20:00) — it mirrors the engine's off-peak provider but is <b>not</b> a live tariff feed. No price is claimed as metered.</div>
    </div>
  </div>
  <div class="panel">
    <h2>(3) Bekenstein bound<span class="meta">Σ shannon_bits vs Σ (output_bytes · 8)</span></h2>
    <div class="bek" id="bek" style="display:none">
      <div class="bek-bar"><div class="bek-fill" id="bek_fill" style="width:0%"></div><div class="bek-ceiling" title="ceiling = Σ output_bytes·8"></div></div>
      <div class="bek-lbl">
        <span>Σ shannon_bits: <span id="bek_sh" style="color:var(--teal)"></span></span>
        <span>ceiling Σ n·8: <span id="bek_ceil" style="color:var(--gold)"></span> · <span id="bek_pct"></span></span>
      </div>
      <div class="simnote" id="bek_note"><b>Proven inequality (F19/TH6):</b> empirical byte-entropy is always ≤ n·8, so the fill never exceeds the gold ceiling unless an upstream over-claim occurs (then it turns red). Kernel-checked in EnergyBudgetWitness.lean (0-sorry).</div>
    </div>
    <div class="empty" id="bek_empty">/v1/energy/budget unreachable — no bound to plot (honest empty-state).</div>
  </div>
  <div class="panel">
    <h2>(2) Energy-budget ledger<span class="meta">/v1/energy/budget · per-task receipts</span></h2>
    <div class="scrollx" id="led_wrap" style="display:none">
      <table>
        <thead><tr>
          <th>task_hash</th><th>bytes</th><th>shannon_bits</th><th>bekenstein n·8</th><th>within</th><th>energy_source</th><th>joules_est <span class="sample">sample</span></th><th>ts</th>
        </tr></thead>
        <tbody id="led_body"></tbody>
      </table>
    </div>
    <div class="empty" id="led_empty">No per-task receipts available. The in-memory ledger resets on process restart; track a task via <code>/v1/energy/budget?bytes=…</code> to populate it. Showing summary only if present.</div>
    <div class="simnote"><b>joules_est is SAMPLE/ESTIMATE</b> — no real power meter is wired (doctrine v11/v12). The <b>within</b> check is the real, proven F19/TH6 gate: <code>shannon_bits ≤ output_bytes·8</code>.</div>
  </div>
  <div class="panel" id="energy3d_panel">
    <h2>(5) 3D Energy / GPU Hologram<span class="meta">holographic GPU blocks · live J/token · 0 CDN · 2D-fallback</span>
      <button class="flag" id="e3d_toggle" style="float:right;font-size:11px;cursor:pointer;">Enable 3D</button>
    </h2>
    <div class="simnote" style="margin-bottom:.6rem">
      A holographic view of the sovereign-inference engine on the shared 0-CDN WebGL2 kit: the <b>GPU/serving block</b>
      colors by the live <code>/code/healthz</code> sovereign posture (<b>sovereign:true only on a real local-GPU probe</b>),
      a <b>trust sphere</b> morphs with Λ (Conjecture 1, &lt;1.0), and the <b>J/token</b> readout is
      <b>MEASURED only on a live GPU power probe</b> — with no meter wired it stays an honest <b>ROADMAP/SAMPLE</b> estimate,
      never presented as measured. CPU/old-GPU renders the same data on a <b>2D canvas fallback</b>; the panels above are the
      complete non-3D experience. Patterns: vLLM/SGLang J/token, 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:.4rem 0;">
      <span>J/token <span id="e3d_jtok" style="color:var(--warn)"></span> <span id="e3d_jtok_lbl"></span></span>
      <span>sovereign <span id="e3d_sov" style="color:var(--cream)"></span></span>
      <span>within Bekenstein <span id="e3d_within" style="color:var(--green)"></span></span>
      <span id="e3d_caps" style="color:var(--dim)"></span>
    </div>
    <div id="energy3d_mount" style="width:100%;height:400px;border:1px solid var(--gold-line);border-radius:10px;background:#060606;display:none;position:relative;"></div>
    <div class="empty" id="e3d_off">3D is off (default). Click <b>Enable 3D</b> to render the holographic energy view on the live <code>/v1/energy/budget</code> + <code>/code/healthz</code> endpoints. The 2D panels above are always available as the fallback.</div>
    <div class="meta mono" style="color:var(--muted);font-size:10px;margin-top:.5rem;">
      0 runtime CDN · WebGL2 + 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="footnote">
    <b>Honest by design.</b> Posture is <b>derived</b> from /code/healthz: GREEN only when <code>sovereign:true</code> AND <code>inference=self-hosted-gpu</code>; MAINTENANCE when reachable but on router fallback; DOWN when unreachable — sovereignty is <b>never assumed</b>. The Bekenstein gate is <b>F19 (locked-8) / TH6</b>, a machine-checked inequality (EnergyBudgetWitness.lean, 0-sorry). <b>All energy figures are SAMPLE/ESTIMATE</b> until a real meter is wired. <b>No free-energy / perpetual-motion claims.</b> Λ trust = <b>Conjecture 1</b> (machine-checked FALSE — advisory, never a theorem). Coherence governor C(t)=C₀·e^(−t/τ_c) via /v1/qbio/coherence is EXPERIMENTAL. Fonts via Google Fonts; no runtime logic/3D CDN.
  </div>
</div>
<script>
const A="/api/a11oy";
const $=id=>document.getElementById(id);
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 esc(s){return String(s==null?'':s).replace(/[&<>]/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;'}[c]));}
function fmt(n,d){if(n==null||isNaN(n))return '—';const x=Number(n);return d!=null?x.toFixed(d):String(x);}

// (1) GPU engine status — posture DERIVED honestly (never assume sovereign)
function derivePosture(hz){
  if(!hz)return {cls:'red',txt:'DOWN — healthz unreachable'};
  const sov=hz.sovereign===true, inf=String(hz.inference||'');
  if(sov && inf==='self-hosted-gpu')return {cls:'green',txt:'GREEN — sovereign GPU serving'};
  return {cls:'yellow',txt:'MAINTENANCE — router fallback (not sovereign)'};
}
async function loadHealthz(){
  const hz=await getJSON(A+"/code/healthz");
  if(!hz){
    $('hz_kv').style.display='none'; $('hz_empty').style.display='block';
    $('c_sov').textContent='—'; $('c_sov').style.color='var(--muted)';
    $('livelbl').textContent='FALLBACK';
    return;
  }
  $('hz_empty').style.display='none'; $('hz_kv').style.display='block';
  const sov=hz.sovereign===true;
  $('hz_sov').innerHTML=`<span class="pill ${sov?'green':'yellow'}">${sov?'true':'false'}</span>`;
  $('hz_inf').textContent=esc(hz.inference||'—');
  $('hz_back').textContent=esc((hz.backend||'—')+' / '+(hz.mode||'—'));
  $('hz_gpu').textContent=esc(hz.gpu!=null?(typeof hz.gpu==='object'?JSON.stringify(hz.gpu):hz.gpu):'(not reported by healthz)');
  $('hz_doc').textContent=esc(hz.doctrine||'—');
  const p=derivePosture(hz);
  $('hz_posture').innerHTML=`<span class="pill ${p.cls}">${esc(p.txt)}</span>`;
  $('c_sov').textContent=sov?'YES':'NO';
  $('c_sov').style.color=sov?'var(--green)':'var(--yellow)';
  $('livelbl').textContent=(hz.mode==='live')?'LIVE · RT':'STUB';
}

// (4) power window — client-side off-peak heuristic (mirrors OffPeakProvider)
function offPeakWindow(d){const h=d.getHours();return (h<8||h>=20)?'cheap':'normal';}
function loadWindow(){
  const now=new Date();
  const w=offPeakWindow(now);
  const hh=String(now.getHours()).padStart(2,'0')+':'+String(now.getMinutes()).padStart(2,'0');
  document.querySelectorAll('#win .cell').forEach(c=>{
    const on=c.dataset.w===w; c.classList.toggle('on',on);
    c.querySelector('.v').textContent=on?('NOW · '+hh):'—';
  });
}

// (2)+(3) Bekenstein ledger + bound visual
function renderBek(sumSh,sumCeil){
  if(sumCeil==null||sumCeil<=0){$('bek').style.display='none';$('bek_empty').style.display='block';return;}
  $('bek_empty').style.display='none'; $('bek').style.display='block';
  const pct=sumSh/sumCeil; const over=sumSh>sumCeil+1e-9;
  const f=$('bek_fill');
  f.style.width=Math.min(pct,1)*100+'%';
  f.classList.toggle('over',over);
  $('bek_sh').textContent=fmt(sumSh,1);
  $('bek_ceil').textContent=fmt(sumCeil,0);
  $('bek_pct').textContent=(pct*100).toFixed(1)+'% of ceiling'+(over?' — OVER (upstream over-claim!)':'');
}
function ledgerRows(b){
  // accept several shapes: explicit ledger/receipts array, single receipt, else none
  if(Array.isArray(b.ledger))return b.ledger;
  if(Array.isArray(b.receipts))return b.receipts;
  if(b.receipt)return [b.receipt];
  return [];
}
async function loadBudget(){
  const b=await getJSON(A+"/v1/energy/budget");
  if(!b){
    $('led_wrap').style.display='none'; $('led_empty').style.display='block';
    $('bek').style.display='none'; $('bek_empty').style.display='block';
    $('c_tasks').textContent='—'; $('c_within').textContent='—'; $('c_joules').textContent='—';
    return;
  }
  const rows=ledgerRows(b);
  // summary cards (prefer explicit summary fields; fall back to row sums)
  const s=b.summary||b;
  const tc=s.task_count!=null?s.task_count:rows.length;
  $('c_tasks').textContent=tc;
  const allWithin=(s.all_within_bound!=null)?s.all_within_bound
                  :(rows.length?rows.every(r=>r.within_bound):null);
  $('c_within').textContent=allWithin==null?'—':(allWithin?'YES':'NO');
  $('c_within').style.color=allWithin===false?'var(--red)':'var(--green)';
  const tj=(s.total_joules_est!=null)?s.total_joules_est
           :rows.reduce((a,r)=>a+(Number(r.joules_est)||0),0);
  $('c_joules').textContent=fmt(tj,2);
  // bound visual
  const sumSh=(s.total_shannon_bits!=null)?s.total_shannon_bits
              :rows.reduce((a,r)=>a+(Number(r.shannon_bits)||0),0);
  const sumCeil=(s.total_bekenstein_bound_bits!=null)?s.total_bekenstein_bound_bits
              :rows.reduce((a,r)=>a+(Number(r.bekenstein_bound_bits)||0),0);
  renderBek(sumSh,sumCeil);
  // ledger table
  if(!rows.length){$('led_wrap').style.display='none'; $('led_empty').style.display='block'; return;}
  $('led_empty').style.display='none'; $('led_wrap').style.display='block';
  $('led_body').innerHTML=rows.map(r=>{
    const wb=r.within_bound===true;
    return `<tr>
      <td title="${esc(r.task_hash||'')}">${esc(String(r.task_hash||'—').slice(0,16))}…</td>
      <td>${esc(r.output_bytes??'—')}</td>
      <td>${fmt(r.shannon_bits,1)}</td>
      <td>${esc(r.bekenstein_bound_bits??'—')}</td>
      <td class="${wb?'ok':'bad'}">${r.within_bound==null?'—':(wb?'✓':'✗')}</td>
      <td>${esc(r.energy_source||'—')}</td>
      <td>${fmt(r.joules_est,3)}</td>
      <td>${esc(r.ts||'—')}</td>
    </tr>`;
  }).join('');
}

async function loadAll(){loadWindow();await Promise.all([loadHealthz(),loadBudget()]);}
loadAll();
setInterval(loadAll,30000);
</script>

<!-- F4 · 3D Energy/GPU hologram (additive). Loads the shared 0-CDN holographic kit. -->
<script src="/static/shared/szl_holo3d.js"></script>
<script>
"use strict";
(function(){
  var EA="/api/a11oy";
  var mount=document.getElementById('energy3d_mount');
  var offEl=document.getElementById('e3d_off');
  var toggle=document.getElementById('e3d_toggle');
  if(!mount||!toggle||!window.SZLHolo){ if(toggle){toggle.disabled=true;toggle.textContent='3D unavailable';} return; }
  var scene=null, started=false, poll=null, anim=null;
  var JT=document.getElementById('e3d_jtok'), JTL=document.getElementById('e3d_jtok_lbl');
  var SOV=document.getElementById('e3d_sov'), WIN=document.getElementById('e3d_within'), CAP=document.getElementById('e3d_caps');
  function esc3(s){return String(s==null?'':s).replace(/[&<>]/g,function(c){return {'&':'&amp;','<':'&lt;','>':'&gt;'}[c];});}
  function getJSON(u,opt){return fetch(u,opt).then(function(r){return r.ok?r.json():null;}).catch(function(){return null;});}

  function applyBudget(b){
    if(!b){ JT.textContent='—'; JTL.innerHTML=''; WIN.textContent='—'; 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);
    var joules=Number(b.total_joules_est||0);
    if(measured && toks>0){
      JT.textContent=(joules/toks).toFixed(4)+' J/tok';
      JTL.innerHTML='<span style="color:var(--green);font-size:9px;border:1px solid var(--green);padding:1px 5px;border-radius:5px">MEASURED · live probe</span>';
    }else{
      JT.textContent=(joules>0&&toks>0)?(joules/toks).toFixed(4)+' J/tok*':'— J/tok';
      JTL.innerHTML='<span style="color:var(--yellow);font-size:9px;border:1px solid var(--yellow);padding:1px 5px;border-radius:5px">ROADMAP · no meter ('+esc3(b.total_joules_est_label||'SAMPLE/ESTIMATE')+')</span>';
    }
    WIN.textContent=(b.all_within_bound===true)?'✓ within (F19/TH6)':(b.all_within_bound===false?'✗ overclaim':'—');
  }

  var _sovereign=false;
  function applyHealthz(hz){
    var sov=!!(hz&&hz.sovereign===true&&String(hz.inference||'').indexOf('gpu')>=0);
    _sovereign=sov;
    SOV.textContent=hz?(sov?'true · local-GPU probe':'false · router fallback'):'— (healthz unreachable)';
    rebuild();
  }

  function rebuild(){
    if(!scene)return;
    try{
      scene.graphs=[]; scene.spheres=[]; scene.pulses=[];
      // GPU/serving block + router; honest sovereign label baked into the node label
      var gpuLab=_sovereign?'GPU·SOVEREIGN':'GPU·ROADMAP';
      scene.addGraph({nodes:[
        {id:'router',label:'\u039b-ENGINE'},
        {id:'gpu',label:gpuLab},
        {id:'bek',label:'BEKENSTEIN'}
      ],edges:[
        {id:'e0',from:'router',to:'gpu'},
        {id:'e1',from:'router',to:'bek'}
      ]});
      var lam=(typeof window.__e3dLambda==='number')?window.__e3dLambda:0.62;
      scene.addTrustSphere({lambda:lam}); scene.setLambda(lam);
    }catch(e){}
  }
  function pulse(){ if(scene){ try{ scene.signPulse('e0'); }catch(_){} } }

  function refresh(){
    getJSON(EA+'/v1/energy/budget').then(applyBudget);
    getJSON(EA+'/code/healthz').then(applyHealthz);
  }
  function start(){
    if(started)return; started=true;
    mount.style.display='block'; offEl.style.display='none'; toggle.textContent='Disable 3D'; toggle.classList.add('active');
    scene=window.SZLHolo.createScene(mount,{sample:false});
    var caps=window.SZLHolo.capabilities();
    CAP.textContent='mode:'+caps.mode+(caps.webgpu?' · webgpu-detected(ROADMAP)':'');
    rebuild(); scene.start();
    refresh();
    poll=setInterval(refresh,30000);
    anim=setInterval(pulse,3000);
  }
  function stop(){
    if(!started)return; started=false;
    mount.style.display='none'; offEl.style.display='block'; toggle.textContent='Enable 3D'; toggle.classList.remove('active');
    if(poll)clearInterval(poll); if(anim)clearInterval(anim);
    try{ if(scene){scene.stop();scene.dispose();} }catch(e){}
    scene=null;
  }
  toggle.addEventListener('click',function(){ started?stop():start(); });
})();
</script>

</body>
</html>