fix(holographic): enforce same-origin bounded brain evidence

#6
static/3d/brain.html CHANGED
@@ -8,18 +8,19 @@
8
  /static/3d/vendor/... importmap below (see VENDOR_MANIFEST.md). System fonts only.
9
 
10
  This page is a SELF-CONTAINED, MOLDABLE 3D brain of the SZL Holdings estate.
11
- Eight lobes are wired to eight LIVE public reads, fetched client-side on load:
 
12
  · Models / Datasets / Spaces / Collections — Hugging Face Hub API (SZLHOLDINGS)
13
  · Repositories — GitHub REST API (org szl-holdings)
14
- · Proved formulas — the ProvedFormulas.lean source file, fetched raw from the
15
- szl-holdings/a11oy repository and its `theorem` declarations counted in-browser.
16
  · Fleet vitals — live /healthz probes of the organ Spaces (a11oy · killinchu ·
17
  anatomy · amaru · sentra), each answer is that organ's own, right now.
18
  · Open frontier — live Hub counts of the open-weights orgs the a11oy backbone
19
  is built to route to (DeepSeek · Qwen · Kimi/Moonshot) plus GLM/Z.ai (watched).
20
  Every number on screen is MEASURED from those live reads (a real 0 stays 0) or
21
  UNKNOWN where the source exposes none; an unreachable feed degrades to an honest
22
- NO-LIVE-DATA state. Nothing is ever fabricated.
23
 
24
  MOLDING is a local, display-only sculpt: dragging in Mold mode displaces mesh
25
  vertices on YOUR device only. It never changes, and can never change, any
@@ -125,7 +126,7 @@
125
  </div>
126
  <div id="surface-caption" title=""></div>
127
  <footer>Doctrine v11 · Λ = Conjecture 1 · eight lobes wired live: Hugging Face Hub (SZLHOLDINGS + open-frontier orgs) ·
128
- GitHub org (szl-holdings) · ProvedFormulas.lean counted in-browser from raw source · organ /healthz vitals ·
129
  every count MEASURED or honestly UNKNOWN / NO-LIVE-DATA · sculpting is local + display-only ·
130
  0 runtime CDN (three.js vendored in-image) · trust &lt; 100%</footer>
131
 
@@ -136,16 +137,16 @@ import * as label from "/static/3d/szl3d/szl3d_label.js";
136
  import * as THREE from "three";
137
 
138
  // ---------------------------------------------------------------------------
139
- // Doctrine v11 (binding): WIRE TO LIVE DATA. Eight lobes = eight live public reads.
 
140
  // Every value is MEASURED from a live read (a real 0 stays 0), or UNKNOWN where
141
  // the source exposes none. A failed feed shows NO-LIVE-DATA, never a guess.
142
  // Molding is a local display-only sculpt — it cannot alter any measured value.
143
  // ---------------------------------------------------------------------------
144
 
145
- const HF_API = "https://huggingface.co/api";
146
  const HF_ORG = "SZLHOLDINGS";
147
  const GH_ORG = "szl-holdings";
148
- const LEAN_RAW = "https://raw.githubusercontent.com/szl-holdings/a11oy/main/proofs/lutar-lean/Lutar/Puriq/Formulas/ProvedFormulas.lean";
149
 
150
  // Palette accents (doctrine-safe — NEVER purple). One per lobe.
151
  const COL = {
@@ -161,54 +162,57 @@ const COL = {
161
  wire: 0x2a8f86,
162
  };
163
 
164
- function numOr(x) {
165
- if (x === null || x === undefined) return null;
166
- const n = typeof x === "number" ? x : Number(x);
167
- return Number.isFinite(n) ? n : null;
168
- }
169
-
170
  // Each lobe: a fixed anatomical direction on the cortex + one live read.
171
  // `fetchStat` returns { text, honesty, caption } — resolved independently so a
172
  // single failing feed only degrades its own lobe.
173
- const PAGE_CAP = 100;
174
- function capText(n) { return n >= PAGE_CAP ? PAGE_CAP + "+ (page cap — lower bound)" : String(n); }
175
- function capHonesty(n) { return n >= PAGE_CAP ? "STRUCTURAL-ONLY" : "MEASURED"; }
176
-
177
- async function getJSON(url) {
178
- // 10s abort: a hung request must degrade to NO-LIVE-DATA, never hang at "…".
179
- const r = await fetch(url, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(10000) });
180
  if (!r.ok) throw new Error("HTTP " + r.status);
181
  const j = await r.json();
182
- if (!Array.isArray(j)) throw new Error("unexpected payload");
 
 
183
  return j;
184
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
185
 
186
  const LOBES = [
187
  {
188
  key: "formulas", name: "Frontal — proved formulas", color: COL.formulas,
189
  dir: [0, 0.55, 0.95], url: "https://github.com/" + GH_ORG + "/a11oy/blob/main/proofs/lutar-lean/Lutar/Puriq/Formulas/ProvedFormulas.lean",
190
  fetchStat: async () => {
191
- // Count `theorem` declarations in the live source bytes — a real in-browser
192
- // measurement of the file as it exists on main right now.
193
- const r = await fetch(LEAN_RAW, { signal: AbortSignal.timeout(10000) });
194
- if (!r.ok) throw new Error("HTTP " + r.status);
195
- const src = await r.text();
196
- const n = (src.match(/(^|\n)\s*theorem\s/g) || []).length;
197
  return { text: n + " theorems", honesty: "MEASURED",
198
- caption: "Frontal lobe · " + n + " `theorem` declarations counted in-browser from the live " +
199
- "ProvedFormulas.lean source on main · MEASURED (raw.githubusercontent.com) · click to read the proofs" };
200
  },
201
  },
202
  {
203
  key: "models", name: "Parietal — models", color: COL.models,
204
  dir: [0.55, 0.85, -0.15], url: "https://huggingface.co/" + HF_ORG,
205
  fetchStat: async () => {
206
- const j = await getJSON(HF_API + "/models?author=" + HF_ORG + "&limit=" + PAGE_CAP + "&full=false");
207
- let dl = 0, dlKnown = true;
208
- j.forEach((m) => { const d = numOr(m.downloads); if (d === null) dlKnown = false; else dl += d; });
209
- return { text: capText(j.length), honesty: capHonesty(j.length),
210
- caption: "Parietal lobe · " + capText(j.length) + " models on the live Hub · " +
211
- (dlKnown ? "Σ " + dl.toLocaleString() + " downloads · MEASURED (live Hub)" : "some download counts UNKNOWN") +
212
  " · click to open " + HF_ORG + " on Hugging Face" };
213
  },
214
  },
@@ -216,12 +220,10 @@ const LOBES = [
216
  key: "datasets", name: "Temporal L — datasets", color: COL.datasets,
217
  dir: [-0.95, -0.05, 0.15], url: "https://huggingface.co/" + HF_ORG + "?tab=datasets" ,
218
  fetchStat: async () => {
219
- const j = await getJSON(HF_API + "/datasets?author=" + HF_ORG + "&limit=" + PAGE_CAP + "&full=false");
220
- let dl = 0, dlKnown = true;
221
- j.forEach((d) => { const n = numOr(d.downloads); if (n === null) dlKnown = false; else dl += n; });
222
- return { text: capText(j.length), honesty: capHonesty(j.length),
223
- caption: "Left temporal lobe · " + capText(j.length) + " datasets on the live Hub · " +
224
- (dlKnown ? "Σ " + dl.toLocaleString() + " downloads · MEASURED (live Hub)" : "some download counts UNKNOWN") +
225
  " · click to open the datasets" };
226
  },
227
  },
@@ -229,12 +231,10 @@ const LOBES = [
229
  key: "spaces", name: "Temporal R — Spaces", color: COL.spaces,
230
  dir: [0.95, -0.05, 0.15], url: "https://huggingface.co/" + HF_ORG + "?tab=spaces",
231
  fetchStat: async () => {
232
- const j = await getJSON(HF_API + "/spaces?author=" + HF_ORG + "&limit=" + PAGE_CAP + "&full=false");
233
- let likes = 0, lKnown = true;
234
- j.forEach((s) => { const n = numOr(s.likes); if (n === null) lKnown = false; else likes += n; });
235
- return { text: capText(j.length), honesty: capHonesty(j.length),
236
- caption: "Right temporal lobe · " + capText(j.length) + " live Spaces · " +
237
- (lKnown ? "Σ " + likes.toLocaleString() + " likes · MEASURED (live Hub)" : "some like counts UNKNOWN") +
238
  " · Space downloads: UNKNOWN (Hub exposes none) · click to open the Spaces" };
239
  },
240
  },
@@ -242,9 +242,10 @@ const LOBES = [
242
  key: "collections", name: "Occipital — collections", color: COL.collections,
243
  dir: [0, 0.35, -1], url: "https://huggingface.co/" + HF_ORG,
244
  fetchStat: async () => {
245
- const j = await getJSON(HF_API + "/collections?owner=" + HF_ORG + "&limit=" + PAGE_CAP);
246
- return { text: capText(j.length), honesty: capHonesty(j.length),
247
- caption: "Occipital lobe · " + capText(j.length) + " curated collections on the live Hub · " + capHonesty(j.length) + " · " +
 
248
  "click to open " + HF_ORG };
249
  },
250
  },
@@ -252,12 +253,10 @@ const LOBES = [
252
  key: "repos", name: "Cerebellum — repositories", color: COL.repos,
253
  dir: [0, -0.75, -0.75], url: "https://github.com/" + GH_ORG,
254
  fetchStat: async () => {
255
- const j = await getJSON("https://api.github.com/orgs/" + GH_ORG + "/repos?per_page=" + PAGE_CAP + "&type=public");
256
- let stars = 0, sKnown = true;
257
- j.forEach((r) => { const n = numOr(r.stargazers_count); if (n === null) sKnown = false; else stars += n; });
258
- return { text: capText(j.length), honesty: capHonesty(j.length),
259
- caption: "Cerebellum · " + capText(j.length) + " public repositories in the live GitHub org · " +
260
- (sKnown ? "Σ " + stars.toLocaleString() + " stars · MEASURED (GitHub API)" : "some star counts UNKNOWN") +
261
  " · click to open github.com/" + GH_ORG };
262
  },
263
  },
@@ -265,23 +264,10 @@ const LOBES = [
265
  key: "fleet", name: "Brainstem — fleet vitals", color: COL.fleet,
266
  dir: [0, -0.92, 0.05], url: "https://huggingface.co/" + HF_ORG,
267
  fetchStat: async () => {
268
- // Live /healthz probes of the organ Spaces — each value is that organ's OWN
269
- // answer, fetched right now. A 404 means "no health endpoint exposed", which
270
- // is reported as exactly that never claimed as up OR down.
271
- const ORGANS = ["a11oy", "killinchu", "anatomy", "amaru", "sentra"];
272
- const results = await Promise.all(ORGANS.map(async (o) => {
273
- try {
274
- const r = await fetch("https://szlholdings-" + o + ".hf.space/healthz",
275
- { headers: { accept: "application/json" }, signal: AbortSignal.timeout(10000) });
276
- if (!r.ok) return { o, state: "no /healthz (HTTP " + r.status + ")", up: false };
277
- const j = await r.json();
278
- return { o, state: (j && j.status) ? String(j.status) : "unknown payload", up: !!(j && j.status === "ok") };
279
- } catch (_) { return { o, state: "unreachable", up: false }; }
280
- }));
281
- const up = results.filter((r) => r.up).length;
282
- return { text: up + "/" + ORGANS.length + " organs report ok", honesty: "MEASURED",
283
- caption: "Brainstem · live /healthz probes made from your browser just now — " +
284
- results.map((r) => r.o + ": " + (r.up ? "ok" : r.state)).join(" · ") +
285
  " · MEASURED (each value is that organ's own live answer; a missing endpoint is said, not guessed)" };
286
  },
287
  },
@@ -289,22 +275,13 @@ const LOBES = [
289
  key: "frontier", name: "R frontal — open frontier", color: COL.frontier,
290
  dir: [0.7, 0.45, 0.62], url: "https://huggingface.co/deepseek-ai",
291
  fetchStat: async () => {
292
- // The open-weights orgs the multi-provider backbone is built to route to
293
- // (DeepSeek, Qwen, Kimi/Moonshot are wired providers; GLM/Z.ai is watched).
294
- // Counted live from the public Hub — page cap makes totals honest lower bounds.
295
- const ORGS = ["deepseek-ai", "Qwen", "moonshotai", "zai-org"];
296
- const counts = await Promise.all(ORGS.map(async (a) => {
297
- const j = await getJSON(HF_API + "/models?author=" + a + "&limit=" + PAGE_CAP + "&full=false");
298
- return { a, n: j.length };
299
- }));
300
- let total = 0, capped = false;
301
- counts.forEach((c) => { total += c.n; if (c.n >= PAGE_CAP) capped = true; });
302
- return { text: (capped ? "\u2265 " + total : String(total)) + " open models",
303
- honesty: capped ? "STRUCTURAL-ONLY" : "MEASURED",
304
  caption: "Right frontal · the open-weights frontier harnessed by the a11oy backbone " +
305
  "(DeepSeek · Qwen · Kimi/Moonshot — wired providers · GLM/Z.ai — watched) · " +
306
- counts.map((c) => c.a + ": " + (c.n >= PAGE_CAP ? PAGE_CAP + "+" : c.n)).join(" · ") +
307
- " · counted live from the public Hub (page cap " + PAGE_CAP + "/org \u2014 lower bound)" };
308
  },
309
  },
310
  ];
@@ -586,8 +563,9 @@ function buildHud() {
586
 
587
  const note = document.createElement("div");
588
  note.className = "note";
589
- note.textContent = "Each lobe is one live public read (Hugging Face Hub, GitHub API, the raw " +
590
- "ProvedFormulas.lean source counted in-browser, or the organs' own /healthz answers). " +
 
591
  "Every count is MEASURED from that read (a real 0 stays 0); " +
592
  "UNKNOWN where the source exposes none; NO-LIVE-DATA if a feed is unreachable. Molding the cortex is a " +
593
  "local, display-only sculpt — it never changes a measured number. Nothing is fabricated. \u039b = Conjecture 1.";
 
8
  /static/3d/vendor/... importmap below (see VENDOR_MANIFEST.md). System fonts only.
9
 
10
  This page is a SELF-CONTAINED, MOLDABLE 3D brain of the SZL Holdings estate.
11
+ Eight lobes are wired to one same-origin evidence contract. On each request the
12
+ server performs fixed-allowlist, read-only, timeout + byte-bounded public reads:
13
  · Models / Datasets / Spaces / Collections — Hugging Face Hub API (SZLHOLDINGS)
14
  · Repositories — GitHub REST API (org szl-holdings)
15
+ · Proved formulas — the ProvedFormulas.lean source file, fetched server-side from
16
+ szl-holdings/a11oy and its `theorem` declarations counted in that observation.
17
  · Fleet vitals — live /healthz probes of the organ Spaces (a11oy · killinchu ·
18
  anatomy · amaru · sentra), each answer is that organ's own, right now.
19
  · Open frontier — live Hub counts of the open-weights orgs the a11oy backbone
20
  is built to route to (DeepSeek · Qwen · Kimi/Moonshot) plus GLM/Z.ai (watched).
21
  Every number on screen is MEASURED from those live reads (a real 0 stays 0) or
22
  UNKNOWN where the source exposes none; an unreachable feed degrades to an honest
23
+ NO-LIVE-DATA state. There is no stale cache or hidden fallback. Nothing is fabricated.
24
 
25
  MOLDING is a local, display-only sculpt: dragging in Mold mode displaces mesh
26
  vertices on YOUR device only. It never changes, and can never change, any
 
126
  </div>
127
  <div id="surface-caption" title=""></div>
128
  <footer>Doctrine v11 · Λ = Conjecture 1 · eight lobes wired live: Hugging Face Hub (SZLHOLDINGS + open-frontier orgs) ·
129
+ GitHub org (szl-holdings) · ProvedFormulas.lean counted through a same-origin bounded evidence route · organ /healthz vitals ·
130
  every count MEASURED or honestly UNKNOWN / NO-LIVE-DATA · sculpting is local + display-only ·
131
  0 runtime CDN (three.js vendored in-image) · trust &lt; 100%</footer>
132
 
 
137
  import * as THREE from "three";
138
 
139
  // ---------------------------------------------------------------------------
140
+ // Doctrine v11 (binding): WIRE TO LIVE DATA. Eight lobes = one same-origin
141
+ // evidence contract backed by fixed, bounded, read-only public observations.
142
  // Every value is MEASURED from a live read (a real 0 stays 0), or UNKNOWN where
143
  // the source exposes none. A failed feed shows NO-LIVE-DATA, never a guess.
144
  // Molding is a local display-only sculpt — it cannot alter any measured value.
145
  // ---------------------------------------------------------------------------
146
 
 
147
  const HF_ORG = "SZLHOLDINGS";
148
  const GH_ORG = "szl-holdings";
149
+ const BRAIN_EVIDENCE = "/api/a11oy/v1/holographic/brain/evidence";
150
 
151
  // Palette accents (doctrine-safe — NEVER purple). One per lobe.
152
  const COL = {
 
162
  wire: 0x2a8f86,
163
  };
164
 
 
 
 
 
 
 
165
  // Each lobe: a fixed anatomical direction on the cortex + one live read.
166
  // `fetchStat` returns { text, honesty, caption } — resolved independently so a
167
  // single failing feed only degrades its own lobe.
168
+ async function getEvidence() {
169
+ // One same-origin browser read. The server performs a fixed-allowlist, read-only,
170
+ // timeout + byte-bounded observation. There is no last-good or hidden fallback.
171
+ const r = await fetch(BRAIN_EVIDENCE, {
172
+ headers: { accept: "application/json" }, cache: "no-store",
173
+ signal: AbortSignal.timeout(12000),
174
+ });
175
  if (!r.ok) throw new Error("HTTP " + r.status);
176
  const j = await r.json();
177
+ if (!j || j.schema !== "a11oy.holographic.brain-evidence.v1" || !j.lobes) {
178
+ throw new Error("unexpected evidence payload");
179
+ }
180
  return j;
181
  }
182
+ const EVIDENCE = getEvidence();
183
+
184
+ function requireLive(evidence, key) {
185
+ const lobe = evidence.lobes && evidence.lobes[key];
186
+ if (!lobe || lobe.state !== "LIVE") {
187
+ throw new Error((lobe && lobe.reason) || "source unavailable");
188
+ }
189
+ return lobe;
190
+ }
191
+
192
+ function countText(lobe) {
193
+ return lobe.lower_bound ? lobe.count + "+ (page cap — lower bound)" : String(lobe.count);
194
+ }
195
 
196
  const LOBES = [
197
  {
198
  key: "formulas", name: "Frontal — proved formulas", color: COL.formulas,
199
  dir: [0, 0.55, 0.95], url: "https://github.com/" + GH_ORG + "/a11oy/blob/main/proofs/lutar-lean/Lutar/Puriq/Formulas/ProvedFormulas.lean",
200
  fetchStat: async () => {
201
+ const s = requireLive(await EVIDENCE, "formulas");
202
+ const n = s.theorem_count;
 
 
 
 
203
  return { text: n + " theorems", honesty: "MEASURED",
204
+ caption: "Frontal lobe · " + n + " `theorem` declarations counted server-side from the live " +
205
+ "ProvedFormulas.lean source on main · MEASURED via same-origin bounded evidence route · click to read the proofs" };
206
  },
207
  },
208
  {
209
  key: "models", name: "Parietal — models", color: COL.models,
210
  dir: [0.55, 0.85, -0.15], url: "https://huggingface.co/" + HF_ORG,
211
  fetchStat: async () => {
212
+ const s = requireLive(await EVIDENCE, "models");
213
+ return { text: countText(s), honesty: s.lower_bound ? "STRUCTURAL-ONLY" : "MEASURED",
214
+ caption: "Parietal lobe · " + countText(s) + " models on the live Hub · " +
215
+ (s.downloads_sum_known ? " + s.downloads_sum.toLocaleString() + " downloads · MEASURED (live Hub)" : "some download counts UNKNOWN") +
 
 
216
  " · click to open " + HF_ORG + " on Hugging Face" };
217
  },
218
  },
 
220
  key: "datasets", name: "Temporal L — datasets", color: COL.datasets,
221
  dir: [-0.95, -0.05, 0.15], url: "https://huggingface.co/" + HF_ORG + "?tab=datasets" ,
222
  fetchStat: async () => {
223
+ const s = requireLive(await EVIDENCE, "datasets");
224
+ return { text: countText(s), honesty: s.lower_bound ? "STRUCTURAL-ONLY" : "MEASURED",
225
+ caption: "Left temporal lobe · " + countText(s) + " datasets on the live Hub · " +
226
+ (s.downloads_sum_known ? " + s.downloads_sum.toLocaleString() + " downloads · MEASURED (live Hub)" : "some download counts UNKNOWN") +
 
 
227
  " · click to open the datasets" };
228
  },
229
  },
 
231
  key: "spaces", name: "Temporal R — Spaces", color: COL.spaces,
232
  dir: [0.95, -0.05, 0.15], url: "https://huggingface.co/" + HF_ORG + "?tab=spaces",
233
  fetchStat: async () => {
234
+ const s = requireLive(await EVIDENCE, "spaces");
235
+ return { text: countText(s), honesty: s.lower_bound ? "STRUCTURAL-ONLY" : "MEASURED",
236
+ caption: "Right temporal lobe · " + countText(s) + " live Spaces · " +
237
+ (s.likes_sum_known ? " + s.likes_sum.toLocaleString() + " likes · MEASURED (live Hub)" : "some like counts UNKNOWN") +
 
 
238
  " · Space downloads: UNKNOWN (Hub exposes none) · click to open the Spaces" };
239
  },
240
  },
 
242
  key: "collections", name: "Occipital — collections", color: COL.collections,
243
  dir: [0, 0.35, -1], url: "https://huggingface.co/" + HF_ORG,
244
  fetchStat: async () => {
245
+ const s = requireLive(await EVIDENCE, "collections");
246
+ const honesty = s.lower_bound ? "STRUCTURAL-ONLY" : "MEASURED";
247
+ return { text: countText(s), honesty,
248
+ caption: "Occipital lobe · " + countText(s) + " curated collections on the live Hub · " + honesty + " · " +
249
  "click to open " + HF_ORG };
250
  },
251
  },
 
253
  key: "repos", name: "Cerebellum — repositories", color: COL.repos,
254
  dir: [0, -0.75, -0.75], url: "https://github.com/" + GH_ORG,
255
  fetchStat: async () => {
256
+ const s = requireLive(await EVIDENCE, "repos");
257
+ return { text: countText(s), honesty: s.lower_bound ? "STRUCTURAL-ONLY" : "MEASURED",
258
+ caption: "Cerebellum · " + countText(s) + " public repositories in the live GitHub org · " +
259
+ (s.stargazers_count_sum_known ? " + s.stargazers_count_sum.toLocaleString() + " stars · MEASURED (GitHub API)" : "some star counts UNKNOWN") +
 
 
260
  " · click to open github.com/" + GH_ORG };
261
  },
262
  },
 
264
  key: "fleet", name: "Brainstem — fleet vitals", color: COL.fleet,
265
  dir: [0, -0.92, 0.05], url: "https://huggingface.co/" + HF_ORG,
266
  fetchStat: async () => {
267
+ const s = requireLive(await EVIDENCE, "fleet");
268
+ return { text: s.up_count + "/" + s.organ_count + " organs report ok", honesty: "MEASURED",
269
+ caption: "Brainstem · live /healthz probes made by the same-origin bounded evidence route — " +
270
+ s.organs.map((r) => r.organ + ": " + (r.up ? "ok" : r.health_state)).join(" · ") +
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  " · MEASURED (each value is that organ's own live answer; a missing endpoint is said, not guessed)" };
272
  },
273
  },
 
275
  key: "frontier", name: "R frontal — open frontier", color: COL.frontier,
276
  dir: [0.7, 0.45, 0.62], url: "https://huggingface.co/deepseek-ai",
277
  fetchStat: async () => {
278
+ const s = requireLive(await EVIDENCE, "frontier");
279
+ return { text: (s.lower_bound ? "\u2265 " + s.count : String(s.count)) + " open models",
280
+ honesty: s.data_label,
 
 
 
 
 
 
 
 
 
281
  caption: "Right frontal · the open-weights frontier harnessed by the a11oy backbone " +
282
  "(DeepSeek · Qwen · Kimi/Moonshot — wired providers · GLM/Z.ai — watched) · " +
283
+ s.sources.map((c) => c.org + ": " + c.count_display).join(" · ") +
284
+ " · counted live from the public Hub via same-origin bounded evidence (page cap 100/org lower bound when capped)" };
285
  },
286
  },
287
  ];
 
563
 
564
  const note = document.createElement("div");
565
  note.className = "note";
566
+ note.textContent = "Each lobe is one live public observation (Hugging Face Hub, GitHub API, the raw " +
567
+ "ProvedFormulas.lean source, or the organs' own /healthz answers), exposed to this page through one " +
568
+ "same-origin, fixed-allowlist, bounded read-only evidence contract with no stale fallback. " +
569
  "Every count is MEASURED from that read (a real 0 stays 0); " +
570
  "UNKNOWN where the source exposes none; NO-LIVE-DATA if a feed is unreachable. Molding the cortex is a " +
571
  "local, display-only sculpt — it never changes a measured number. Nothing is fabricated. \u039b = Conjecture 1.";
szl3d_holographic.py CHANGED
@@ -25,9 +25,15 @@ Mirrors the existing in-image static-serve pattern (serve.py /static/shared/{fna
25
  """
26
  from __future__ import annotations
27
 
 
 
28
  import os
 
 
29
  from pathlib import Path
30
- from typing import Any, Dict, List
 
 
31
 
32
  # Surface slots (id, human title) — the frontier tier + the 9 estate surfaces.
33
  SURFACES: List[Dict[str, str]] = [
@@ -236,6 +242,226 @@ def no_cdn_violations(base: Path):
236
  break
237
 
238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  def shell_html(ns: str = "a11oy") -> str:
240
  """Read the holographic shell HTML off disk (single source of truth:
241
  static/3d/holographic.html). Falls back to a minimal honest stub if missing."""
@@ -268,6 +494,7 @@ def info(ns: str = "a11oy") -> Dict[str, Any]:
268
  },
269
  "surfaces": SURFACES,
270
  "shell": {"page": "/holographic", "alias": "/a11oy/holographic"},
 
271
  "selftest": "/static/3d/selftest/index.html",
272
  "doctrine": {"locked_proven": 8, "lambda": "Conjecture 1", "khipu_bft": "Conjecture 2",
273
  "runtime_cdn": 0, "webgpu": "attempt-then-WebGL2-fallback"},
@@ -311,9 +538,15 @@ def register(app, ns: str = "a11oy") -> Dict[str, Any]:
311
  async def _info():
312
  return JSONResponse(info(ns))
313
 
 
 
 
 
314
  for prefix in (f"/api/{ns}/v1/holographic", "/v1/holographic"):
315
  app.add_api_route(f"{prefix}/info", _info, methods=["GET"], include_in_schema=False)
 
316
  registered.append(f"GET /api/{ns}/v1/holographic/info")
 
317
 
318
  return {"registered": registered, "count": len(registered),
319
  "capability": "szl3d toolkit + holographic shell", "surfaces": len(SURFACES),
 
25
  """
26
  from __future__ import annotations
27
 
28
+ import asyncio
29
+ import json
30
  import os
31
+ from concurrent.futures import ThreadPoolExecutor, as_completed
32
+ from datetime import datetime, timezone
33
  from pathlib import Path
34
+ from typing import Any, Callable, Dict, List
35
+ from urllib.error import HTTPError
36
+ from urllib.request import Request, urlopen
37
 
38
  # Surface slots (id, human title) — the frontier tier + the 9 estate surfaces.
39
  SURFACES: List[Dict[str, str]] = [
 
242
  break
243
 
244
 
245
+ # The Brain surface is a browser-side part of the sovereign 0-CDN tree. It must
246
+ # never call third-party hosts directly. These URLs are therefore fixed here,
247
+ # server-side, with no caller-controlled target (and thus no open proxy / SSRF
248
+ # surface). GET /.../brain/evidence performs one bounded, read-only observation
249
+ # and returns explicit LIVE / DEGRADED / UNAVAILABLE states. There is deliberately
250
+ # no stale cache and no silent fallback.
251
+ _BRAIN_PAGE_CAP = 100
252
+ _BRAIN_TIMEOUT_S = 4.0
253
+ _BRAIN_MAX_BYTES = 5 * 1024 * 1024
254
+ _BRAIN_SOURCES: Dict[str, str] = {
255
+ "formulas": "https://raw.githubusercontent.com/szl-holdings/a11oy/main/proofs/lutar-lean/Lutar/Puriq/Formulas/ProvedFormulas.lean",
256
+ "models": "https://huggingface.co/api/models?author=SZLHOLDINGS&limit=100&full=false",
257
+ "datasets": "https://huggingface.co/api/datasets?author=SZLHOLDINGS&limit=100&full=false",
258
+ "spaces": "https://huggingface.co/api/spaces?author=SZLHOLDINGS&limit=100&full=false",
259
+ "collections": "https://huggingface.co/api/collections?owner=SZLHOLDINGS&limit=100",
260
+ "repos": "https://api.github.com/orgs/szl-holdings/repos?per_page=100&type=public",
261
+ "organ:a11oy": "https://szlholdings-a11oy.hf.space/healthz",
262
+ "organ:killinchu": "https://szlholdings-killinchu.hf.space/healthz",
263
+ "organ:anatomy": "https://szlholdings-anatomy.hf.space/healthz",
264
+ "organ:amaru": "https://szlholdings-amaru.hf.space/healthz",
265
+ "organ:sentra": "https://szlholdings-sentra.hf.space/healthz",
266
+ "frontier:deepseek-ai": "https://huggingface.co/api/models?author=deepseek-ai&limit=100&full=false",
267
+ "frontier:Qwen": "https://huggingface.co/api/models?author=Qwen&limit=100&full=false",
268
+ "frontier:moonshotai": "https://huggingface.co/api/models?author=moonshotai&limit=100&full=false",
269
+ "frontier:zai-org": "https://huggingface.co/api/models?author=zai-org&limit=100&full=false",
270
+ }
271
+
272
+
273
+ def _brain_read(url: str) -> bytes:
274
+ """Read one allowlisted public source with a hard time and byte bound."""
275
+ req = Request(url, headers={"Accept": "application/json, text/plain;q=0.9",
276
+ "User-Agent": "a11oy-holographic-evidence/1.0"})
277
+ with urlopen(req, timeout=_BRAIN_TIMEOUT_S) as response: # nosec B310: fixed allowlist
278
+ data = response.read(_BRAIN_MAX_BYTES + 1)
279
+ if len(data) > _BRAIN_MAX_BYTES:
280
+ raise ValueError("response_too_large")
281
+ return data
282
+
283
+
284
+ def _brain_json(url: str) -> Any:
285
+ return json.loads(_brain_read(url).decode("utf-8"))
286
+
287
+
288
+ def _brain_text(url: str) -> str:
289
+ return _brain_read(url).decode("utf-8")
290
+
291
+
292
+ def _brain_health(url: str) -> Dict[str, Any]:
293
+ """Observe an organ health endpoint. An HTTP response is itself a measured
294
+ observation; a missing endpoint is not rewritten into either UP or DOWN."""
295
+ try:
296
+ payload = _brain_json(url)
297
+ status = str(payload.get("status", "unknown payload")) if isinstance(payload, dict) else "unknown payload"
298
+ return {"read_state": "LIVE", "health_state": status, "up": status == "ok"}
299
+ except HTTPError as exc:
300
+ return {"read_state": "LIVE", "health_state": f"no /healthz (HTTP {exc.code})", "up": False}
301
+
302
+
303
+ def _brain_error(exc: BaseException) -> str:
304
+ if isinstance(exc, HTTPError):
305
+ return f"upstream_http_{exc.code}"
306
+ if isinstance(exc, (TimeoutError, OSError)):
307
+ return "upstream_unreachable_or_timeout"
308
+ if isinstance(exc, (UnicodeError, json.JSONDecodeError)):
309
+ return "upstream_invalid_payload"
310
+ if isinstance(exc, ValueError) and str(exc) == "response_too_large":
311
+ return "upstream_response_too_large"
312
+ return "upstream_read_failed"
313
+
314
+
315
+ def _unavailable(source_url: str, exc: BaseException) -> Dict[str, Any]:
316
+ return {"state": "UNAVAILABLE", "data_label": "UNAVAILABLE",
317
+ "source_url": source_url, "reason": _brain_error(exc)}
318
+
319
+
320
+ def _count_payload(items: Any, source_url: str, sum_field: str | None = None) -> Dict[str, Any]:
321
+ if not isinstance(items, list):
322
+ raise ValueError("unexpected_payload_shape")
323
+ n = len(items)
324
+ result: Dict[str, Any] = {
325
+ "state": "LIVE", "data_label": "MEASURED", "source_url": source_url,
326
+ "count": n, "count_display": f"{n}+" if n >= _BRAIN_PAGE_CAP else str(n),
327
+ "page_cap": _BRAIN_PAGE_CAP, "lower_bound": n >= _BRAIN_PAGE_CAP,
328
+ }
329
+ if sum_field:
330
+ values = [item.get(sum_field) for item in items if isinstance(item, dict)]
331
+ known = len(values) == n and all(isinstance(value, (int, float)) for value in values)
332
+ result[f"{sum_field}_sum"] = sum(values) if known else None
333
+ result[f"{sum_field}_sum_known"] = known
334
+ return result
335
+
336
+
337
+ def brain_evidence(
338
+ fetch_json: Callable[[str], Any] = _brain_json,
339
+ fetch_text: Callable[[str], str] = _brain_text,
340
+ fetch_health: Callable[[str], Dict[str, Any]] = _brain_health,
341
+ ) -> Dict[str, Any]:
342
+ """Build one honest Brain observation from fixed public sources.
343
+
344
+ All reads run concurrently under fixed worker, timeout, and response-size
345
+ bounds. Partial results remain visible, but an incomplete composite lobe is
346
+ UNAVAILABLE rather than being presented as a complete count.
347
+ """
348
+ observed_at = datetime.now(timezone.utc).isoformat().replace("+00:00", "Z")
349
+ raw: Dict[str, Any] = {}
350
+ errors: Dict[str, BaseException] = {}
351
+
352
+ def read(key: str) -> Any:
353
+ url = _BRAIN_SOURCES[key]
354
+ if key == "formulas":
355
+ return fetch_text(url)
356
+ if key.startswith("organ:"):
357
+ return fetch_health(url)
358
+ return fetch_json(url)
359
+
360
+ with ThreadPoolExecutor(max_workers=8, thread_name_prefix="brain-evidence") as pool:
361
+ futures = {pool.submit(read, key): key for key in _BRAIN_SOURCES}
362
+ for future in as_completed(futures):
363
+ key = futures[future]
364
+ try:
365
+ raw[key] = future.result()
366
+ except BaseException as exc: # each source degrades independently
367
+ errors[key] = exc
368
+
369
+ lobes: Dict[str, Dict[str, Any]] = {}
370
+ try:
371
+ if "formulas" in errors:
372
+ raise errors["formulas"]
373
+ source = raw["formulas"]
374
+ theorem_count = len(_re.findall(r"(^|\n)\s*theorem\s", source))
375
+ lobes["formulas"] = {
376
+ "state": "LIVE", "data_label": "MEASURED",
377
+ "source_url": _BRAIN_SOURCES["formulas"], "theorem_count": theorem_count,
378
+ }
379
+ except BaseException as exc:
380
+ lobes["formulas"] = _unavailable(_BRAIN_SOURCES["formulas"], exc)
381
+
382
+ for key, sum_field in (("models", "downloads"), ("datasets", "downloads"),
383
+ ("spaces", "likes"), ("collections", None),
384
+ ("repos", "stargazers_count")):
385
+ try:
386
+ if key in errors:
387
+ raise errors[key]
388
+ lobes[key] = _count_payload(raw[key], _BRAIN_SOURCES[key], sum_field)
389
+ except BaseException as exc:
390
+ lobes[key] = _unavailable(_BRAIN_SOURCES[key], exc)
391
+
392
+ organ_keys = [key for key in _BRAIN_SOURCES if key.startswith("organ:")]
393
+ organs: List[Dict[str, Any]] = []
394
+ fleet_complete = True
395
+ for key in organ_keys:
396
+ name = key.split(":", 1)[1]
397
+ if key in errors:
398
+ fleet_complete = False
399
+ organs.append({"organ": name, **_unavailable(_BRAIN_SOURCES[key], errors[key]), "up": False})
400
+ else:
401
+ health = raw[key]
402
+ if health.get("read_state") != "LIVE":
403
+ fleet_complete = False
404
+ organs.append({"organ": name, "state": health.get("read_state", "UNAVAILABLE"),
405
+ "data_label": "MEASURED" if health.get("read_state") == "LIVE" else "UNAVAILABLE",
406
+ "source_url": _BRAIN_SOURCES[key], "health_state": health.get("health_state"),
407
+ "up": bool(health.get("up"))})
408
+ lobes["fleet"] = {
409
+ "state": "LIVE" if fleet_complete else "UNAVAILABLE",
410
+ "data_label": "MEASURED" if fleet_complete else "UNAVAILABLE",
411
+ "organs": organs, "up_count": sum(1 for organ in organs if organ["up"]),
412
+ "organ_count": len(organs),
413
+ "reason": None if fleet_complete else "one_or_more_health_reads_unavailable",
414
+ }
415
+
416
+ frontier_keys = [key for key in _BRAIN_SOURCES if key.startswith("frontier:")]
417
+ frontier_sources: List[Dict[str, Any]] = []
418
+ frontier_complete = True
419
+ frontier_total = 0
420
+ frontier_capped = False
421
+ for key in frontier_keys:
422
+ org = key.split(":", 1)[1]
423
+ try:
424
+ if key in errors:
425
+ raise errors[key]
426
+ item = _count_payload(raw[key], _BRAIN_SOURCES[key])
427
+ frontier_total += item["count"]
428
+ frontier_capped = frontier_capped or item["lower_bound"]
429
+ frontier_sources.append({"org": org, **item})
430
+ except BaseException as exc:
431
+ frontier_complete = False
432
+ frontier_sources.append({"org": org, **_unavailable(_BRAIN_SOURCES[key], exc)})
433
+ lobes["frontier"] = {
434
+ "state": "LIVE" if frontier_complete else "UNAVAILABLE",
435
+ "data_label": "MEASURED" if frontier_complete and not frontier_capped else
436
+ ("STRUCTURAL-ONLY" if frontier_complete else "UNAVAILABLE"),
437
+ "count": frontier_total if frontier_complete else None,
438
+ "lower_bound": frontier_capped if frontier_complete else None,
439
+ "sources": frontier_sources,
440
+ "reason": None if frontier_complete else "one_or_more_frontier_reads_unavailable",
441
+ }
442
+
443
+ available = sum(1 for lobe in lobes.values() if lobe["state"] == "LIVE")
444
+ overall = "LIVE" if available == len(lobes) else ("DEGRADED" if available else "UNAVAILABLE")
445
+ overall_label = ("MEASURED" if overall == "LIVE" and
446
+ all(lobe["data_label"] == "MEASURED" for lobe in lobes.values()) else
447
+ ("STRUCTURAL-ONLY" if overall == "LIVE" else overall))
448
+ return {
449
+ "schema": "a11oy.holographic.brain-evidence.v1",
450
+ "state": overall,
451
+ "data_label": overall_label,
452
+ "observed_at": observed_at,
453
+ "lobe_count": len(lobes), "live_lobes": available,
454
+ "lobes": lobes,
455
+ "limits": {
456
+ "read_only": True, "same_origin_browser_read": True,
457
+ "fixed_allowlist": True, "timeout_seconds_per_source": _BRAIN_TIMEOUT_S,
458
+ "response_byte_cap": _BRAIN_MAX_BYTES, "page_cap": _BRAIN_PAGE_CAP,
459
+ "cache_or_last_good_fallback": False,
460
+ "note": "Every request is a fresh bounded observation. Missing sources remain UNAVAILABLE.",
461
+ },
462
+ }
463
+
464
+
465
  def shell_html(ns: str = "a11oy") -> str:
466
  """Read the holographic shell HTML off disk (single source of truth:
467
  static/3d/holographic.html). Falls back to a minimal honest stub if missing."""
 
494
  },
495
  "surfaces": SURFACES,
496
  "shell": {"page": "/holographic", "alias": "/a11oy/holographic"},
497
+ "brain_evidence": f"/api/{ns}/v1/holographic/brain/evidence",
498
  "selftest": "/static/3d/selftest/index.html",
499
  "doctrine": {"locked_proven": 8, "lambda": "Conjecture 1", "khipu_bft": "Conjecture 2",
500
  "runtime_cdn": 0, "webgpu": "attempt-then-WebGL2-fallback"},
 
538
  async def _info():
539
  return JSONResponse(info(ns))
540
 
541
+ async def _brain_evidence():
542
+ payload = await asyncio.to_thread(brain_evidence)
543
+ return JSONResponse(payload, headers={"Cache-Control": "no-store"})
544
+
545
  for prefix in (f"/api/{ns}/v1/holographic", "/v1/holographic"):
546
  app.add_api_route(f"{prefix}/info", _info, methods=["GET"], include_in_schema=False)
547
+ app.add_api_route(f"{prefix}/brain/evidence", _brain_evidence, methods=["GET"], include_in_schema=False)
548
  registered.append(f"GET /api/{ns}/v1/holographic/info")
549
+ registered.append(f"GET /api/{ns}/v1/holographic/brain/evidence")
550
 
551
  return {"registered": registered, "count": len(registered),
552
  "capability": "szl3d toolkit + holographic shell", "surfaces": len(SURFACES),
test/test_holographic_zero_cdn.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Zero-CDN and honest same-origin evidence contract regressions."""
2
+ from __future__ import annotations
3
+
4
+ import unittest
5
+ from pathlib import Path
6
+ from unittest.mock import patch
7
+
8
+ from fastapi import FastAPI
9
+ from fastapi.testclient import TestClient
10
+
11
+ import szl3d_holographic as holographic
12
+
13
+
14
+ class HolographicZeroCdnTests(unittest.TestCase):
15
+ def _json(self, url: str):
16
+ if "api/models" in url:
17
+ return [{"downloads": 3}, {"downloads": 7}]
18
+ if "api/datasets" in url:
19
+ return [{"downloads": 11}]
20
+ if "api/spaces" in url:
21
+ return [{"likes": 5}]
22
+ if "api/collections" in url:
23
+ return [{"slug": "governed-estate"}]
24
+ if "api.github.com" in url:
25
+ return [{"stargazers_count": 2}]
26
+ raise AssertionError(f"unexpected test URL: {url}")
27
+
28
+ @staticmethod
29
+ def _health(_url: str):
30
+ return {"read_state": "LIVE", "health_state": "ok", "up": True}
31
+
32
+ def test_authored_3d_tree_has_no_external_runtime_fetch(self):
33
+ violations = list(holographic.no_cdn_violations(holographic._base_dir()))
34
+ self.assertEqual(violations, [])
35
+ brain = (Path(__file__).parents[1] / "static" / "3d" / "brain.html").read_text(encoding="utf-8")
36
+ self.assertIn('fetch(BRAIN_EVIDENCE', brain)
37
+ self.assertIn('const BRAIN_EVIDENCE = "/api/a11oy/v1/holographic/brain/evidence"', brain)
38
+ self.assertNotIn('fetch("https://', brain)
39
+ self.assertNotIn("fetch('https://", brain)
40
+
41
+ def test_complete_observation_is_live_and_measured(self):
42
+ payload = holographic.brain_evidence(
43
+ fetch_json=self._json,
44
+ fetch_text=lambda _url: "theorem one : True := by trivial\n theorem two : True := by trivial\n",
45
+ fetch_health=self._health,
46
+ )
47
+ self.assertEqual(payload["state"], "LIVE")
48
+ self.assertEqual(payload["live_lobes"], payload["lobe_count"])
49
+ self.assertEqual(payload["lobes"]["formulas"]["theorem_count"], 2)
50
+ self.assertEqual(payload["lobes"]["models"]["downloads_sum"], 10)
51
+ self.assertEqual(payload["lobes"]["fleet"]["up_count"], 5)
52
+ self.assertFalse(payload["limits"]["cache_or_last_good_fallback"])
53
+ self.assertTrue(payload["limits"]["fixed_allowlist"])
54
+
55
+ def test_failed_composite_source_is_not_hidden_by_partial_count(self):
56
+ def partial_json(url: str):
57
+ if "author=zai-org" in url:
58
+ raise TimeoutError("test timeout")
59
+ return self._json(url)
60
+
61
+ payload = holographic.brain_evidence(
62
+ fetch_json=partial_json,
63
+ fetch_text=lambda _url: "theorem one : True := by trivial\n",
64
+ fetch_health=self._health,
65
+ )
66
+ frontier = payload["lobes"]["frontier"]
67
+ self.assertEqual(payload["state"], "DEGRADED")
68
+ self.assertEqual(frontier["state"], "UNAVAILABLE")
69
+ self.assertIsNone(frontier["count"])
70
+ failed = next(row for row in frontier["sources"] if row["org"] == "zai-org")
71
+ self.assertEqual(failed["reason"], "upstream_unreachable_or_timeout")
72
+
73
+ def test_route_is_get_only_no_store_and_same_contract(self):
74
+ app = FastAPI()
75
+ expected = {
76
+ "schema": "a11oy.holographic.brain-evidence.v1",
77
+ "state": "UNAVAILABLE",
78
+ "lobes": {},
79
+ }
80
+ with patch.object(holographic, "brain_evidence", return_value=expected):
81
+ holographic.register(app, ns="a11oy")
82
+ client = TestClient(app)
83
+ response = client.get("/api/a11oy/v1/holographic/brain/evidence")
84
+ self.assertEqual(response.status_code, 200)
85
+ self.assertEqual(response.json(), expected)
86
+ self.assertEqual(response.headers["cache-control"], "no-store")
87
+ methods = {
88
+ method
89
+ for route in app.routes
90
+ if getattr(route, "path", None) == "/api/a11oy/v1/holographic/brain/evidence"
91
+ for method in route.methods
92
+ }
93
+ self.assertEqual(methods, {"GET"})
94
+
95
+
96
+ if __name__ == "__main__":
97
+ unittest.main()