Spaces:
Running
Running
chore(sync): mirror backend .py + Dockerfile to Space (hf-sync-backend)
Browse filesAutomated backend sync from szl-holdings/a11oy main via hf-sync-backend.
Updated (differed from the Space): a11oy_frontier_page.py
Deleted (gone from the repo + Dockerfile COPY set): (none)
Keeps the Space-built backend (serve.py + the Dockerfile-COPY'd .py
modules) identical to GitHub main so the Space never rebuilds from a
stale backend, new endpoints don't 404 there, and orphaned modules
removed from the repo don't linger in the Space tree.
- a11oy_frontier_page.py +253 -4
a11oy_frontier_page.py
CHANGED
|
@@ -44,10 +44,158 @@ sovereign=false on this path. Doctrine v11 LOCKED.
|
|
| 44 |
"""
|
| 45 |
from __future__ import annotations
|
| 46 |
|
|
|
|
|
|
|
|
|
|
| 47 |
from fastapi import FastAPI
|
| 48 |
from fastapi.responses import HTMLResponse, JSONResponse
|
| 49 |
|
| 50 |
DOCTRINE = {"version": "v11", "lambda": "Conjecture 1", "sovereign": False}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
HONEST_BANNER = (
|
| 52 |
"HONEST SHOWCASE — every tile carries its own label (MEASURED / MODELED / "
|
| 53 |
"ROADMAP / SAMPLE) and a provenance pointer; no label is upgraded, nothing is faked"
|
|
@@ -55,6 +203,8 @@ HONEST_BANNER = (
|
|
| 55 |
|
| 56 |
# The LIVE backend roll-up this surface renders (PR #472). Wired client-side.
|
| 57 |
_MANIFEST_EP = "/api/{ns}/v1/frontier/manifest"
|
|
|
|
|
|
|
| 58 |
|
| 59 |
# 0-CDN vendored three.js r160 — the proven, allowlisted, runtime-served hero path
|
| 60 |
# (serve.py GET /hero/vendor3d/{fname}; identical to the /orbital page importmap).
|
|
@@ -64,6 +214,7 @@ _THREE_ADDONS = "/hero/vendor3d/"
|
|
| 64 |
|
| 65 |
def _page_html(ns: str) -> str:
|
| 66 |
manifest_ep = _MANIFEST_EP.format(ns=ns)
|
|
|
|
| 67 |
return f"""<!doctype html>
|
| 68 |
<html lang="en"><head>
|
| 69 |
<meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
@@ -142,6 +293,16 @@ def _page_html(ns: str) -> str:
|
|
| 142 |
.badge.roadmap {{ background:rgba(157,122,216,.16); color:var(--violet); border:1px solid rgba(157,122,216,.5); }}
|
| 143 |
.badge.sample {{ background:rgba(77,143,204,.16); color:var(--indigo); border:1px solid rgba(77,143,204,.45); }}
|
| 144 |
.badge.unavailable {{ background:rgba(216,98,74,.16); color:var(--red); border:1px solid rgba(216,98,74,.5); }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
/* Per-tile persistent honest banner on non-MEASURED tiles. */
|
| 146 |
.tile-banner {{ font-family:ui-monospace,monospace; font-size:.66rem; line-height:1.4;
|
| 147 |
border-radius:8px; padding:.4rem .55rem; letter-spacing:.03em; }}
|
|
@@ -187,6 +348,19 @@ def _page_html(ns: str) -> str:
|
|
| 187 |
<span class="lg sample">SAMPLE — illustrative only</span>
|
| 188 |
</div>
|
| 189 |
<div id="rollup"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
<div id="grid"></div>
|
| 191 |
<div class="status-line" id="status">fetching /frontier/manifest…</div>
|
| 192 |
<div class="status-line"><a class="back" href="/">← back to console</a> ·
|
|
@@ -378,6 +552,52 @@ function fail(msg) {{
|
|
| 378 |
fail('manifest unavailable: ' + e + ' (nothing fabricated — raw data at ' + MANIFEST_EP + ')');
|
| 379 |
}}
|
| 380 |
}})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
</script>
|
| 382 |
</body></html>"""
|
| 383 |
|
|
@@ -390,6 +610,14 @@ def register(app: FastAPI, ns: str = "a11oy") -> str:
|
|
| 390 |
async def frontier_page() -> HTMLResponse: # noqa: ANN202
|
| 391 |
return HTMLResponse(_page_html(ns))
|
| 392 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
@app.get(f"/api/{ns}/v1/frontier/page-manifest", include_in_schema=False)
|
| 394 |
async def frontier_page_manifest() -> JSONResponse: # noqa: ANN202
|
| 395 |
return JSONResponse({
|
|
@@ -398,8 +626,9 @@ def register(app: FastAPI, ns: str = "a11oy") -> str:
|
|
| 398 |
"kind": "unified-ecosystem-showcase",
|
| 399 |
"banner": HONEST_BANNER,
|
| 400 |
"doctrine": DOCTRINE,
|
| 401 |
-
"renders_endpoints": [_MANIFEST_EP.format(ns=ns)],
|
| 402 |
-
"links": {"orbital_page": "/orbital", "manifest": _MANIFEST_EP.format(ns=ns)
|
|
|
|
| 403 |
"vendored_3d": {"three": _THREE_MAIN, "addons": _THREE_ADDONS,
|
| 404 |
"revision": "r160", "runtime_cdn": 0},
|
| 405 |
"note": ("Unified frontier showcase — renders the live /frontier/manifest "
|
|
@@ -408,7 +637,9 @@ def register(app: FastAPI, ns: str = "a11oy") -> str:
|
|
| 408 |
"no label is upgraded, nothing is fabricated."),
|
| 409 |
})
|
| 410 |
|
| 411 |
-
return "frontier-page mounted: GET /frontier + page-manifest
|
|
|
|
|
|
|
| 412 |
|
| 413 |
|
| 414 |
def _selftest() -> None:
|
|
@@ -429,8 +660,26 @@ def _selftest() -> None:
|
|
| 429 |
# 6) links to the orbital MODELED tier are present
|
| 430 |
assert 'href="/orbital"' in html, "orbital tier link missing"
|
| 431 |
assert "Conjecture 1" in html, "Λ label missing"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 432 |
print("a11oy_frontier_page: ALL OK (honest banner, manifest wired, 0 CDN, render marker, "
|
| 433 |
-
"per-tile honest banners, orbital link
|
|
|
|
| 434 |
|
| 435 |
|
| 436 |
if __name__ == "__main__":
|
|
|
|
| 44 |
"""
|
| 45 |
from __future__ import annotations
|
| 46 |
|
| 47 |
+
import pathlib
|
| 48 |
+
import re
|
| 49 |
+
|
| 50 |
from fastapi import FastAPI
|
| 51 |
from fastapi.responses import HTMLResponse, JSONResponse
|
| 52 |
|
| 53 |
DOCTRINE = {"version": "v11", "lambda": "Conjecture 1", "sovereign": False}
|
| 54 |
+
|
| 55 |
+
# --------------------------------------------------------------------------- #
|
| 56 |
+
# Frontier 3D-surface manifest (GET /api/<ns>/v1/frontier/surfaces)
|
| 57 |
+
#
|
| 58 |
+
# A machine-verifiable roll-up of every 3D holographic frontier surface. The
|
| 59 |
+
# SINGLE SOURCE OF TRUTH for the surface LIST is the `SURFACES` array declared in
|
| 60 |
+
# static/3d/holographic.html (the same array the holographic viewer loads); the
|
| 61 |
+
# SINGLE SOURCE OF TRUTH for each surface's honesty LABEL is the surface's own JS
|
| 62 |
+
# source — the label is PARSED from the file, never hardcoded a second time here.
|
| 63 |
+
#
|
| 64 |
+
# Doctrine v11 honesty (non-negotiable):
|
| 65 |
+
# * A missing asset at runtime -> UNAVAILABLE with a reason, NEVER a fabricated
|
| 66 |
+
# present/green tile.
|
| 67 |
+
# * The label is read from the surface source and reported VERBATIM — never
|
| 68 |
+
# upgraded. Where a surface declares no doctrine token at all, it is honestly
|
| 69 |
+
# UNAVAILABLE (undeclared), not padded to a nicer label.
|
| 70 |
+
# * This is a pure READ (parse files on disk). It signs nothing and appends to
|
| 71 |
+
# no provenance chain — receipts belong on writes, never on GETs.
|
| 72 |
+
# --------------------------------------------------------------------------- #
|
| 73 |
+
|
| 74 |
+
# Repo root — this module lives flat at the repo root next to static/3d/.
|
| 75 |
+
_REPO_ROOT = pathlib.Path(__file__).resolve().parent
|
| 76 |
+
_HOLOGRAPHIC_REL = "static/3d/holographic.html"
|
| 77 |
+
|
| 78 |
+
# Recognized doctrine honesty vocabulary (weakest→strongest claim ordering is not
|
| 79 |
+
# needed here — this is just the accepted set). UNAVAILABLE is reserved for a
|
| 80 |
+
# missing asset or an undeclared label; it is never a "normal" surface label.
|
| 81 |
+
_VALID_LABELS = ("MEASURED", "LIVE", "SAMPLE", "MODELED", "STRUCTURAL-ONLY", "ROADMAP")
|
| 82 |
+
UNAVAILABLE = "UNAVAILABLE"
|
| 83 |
+
|
| 84 |
+
# `{ id: "grpo", title: "GRPO Reward Dynamics", mod: "/static/3d/surfaces/grpo.js" }`
|
| 85 |
+
_SURFACE_ENTRY_RE = re.compile(
|
| 86 |
+
r'\{\s*id:\s*"([^"]+)"\s*,\s*title:\s*"([^"]+)"\s*,\s*mod:\s*"([^"]+)"\s*\}')
|
| 87 |
+
# Runtime-default label the surface renders absent live data: `S.label = (j.label || "MODELED")`.
|
| 88 |
+
_LABEL_DEFAULT_RE = re.compile(r'\b\w+\.label\s*=\s*\(\s*[\w.]+\s*\|\|\s*"([A-Z][A-Z-]+)"')
|
| 89 |
+
# Declared honesty chip / billboard token (surfaces without a runtime-default label).
|
| 90 |
+
_LABEL_CHIP_RE = re.compile(r'\.chip\(\s*"([A-Z][A-Z-]+)"')
|
| 91 |
+
_LABEL_BILL_RE = re.compile(r'billboard\([^,]*,\s*"([A-Z][A-Z-]+)"')
|
| 92 |
+
# Any quoted UPPER token (last-resort scan, e.g. the hub surface's ROADMAP literal).
|
| 93 |
+
_TOKEN_RE = re.compile(r'"([A-Z][A-Z-]+)"')
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def _derive_label(src: str) -> tuple[str | None, str]:
|
| 97 |
+
"""Derive a surface's honesty label from its JS source. Returns (label, source).
|
| 98 |
+
|
| 99 |
+
Ordered, deterministic, and never over-claims: the headline label is the
|
| 100 |
+
surface's own declared token, read verbatim. A surface can never be reported
|
| 101 |
+
stronger than it declares (none of these first-match rules can yield MEASURED
|
| 102 |
+
for a surface that only models/samples)."""
|
| 103 |
+
m = _LABEL_DEFAULT_RE.search(src)
|
| 104 |
+
if m and m.group(1) in _VALID_LABELS:
|
| 105 |
+
return m.group(1), "js-runtime-default"
|
| 106 |
+
for rx, source in ((_LABEL_CHIP_RE, "js-honesty-chip"),
|
| 107 |
+
(_LABEL_BILL_RE, "js-honesty-billboard"),
|
| 108 |
+
(_TOKEN_RE, "js-doctrine-literal")):
|
| 109 |
+
for mm in rx.finditer(src):
|
| 110 |
+
if mm.group(1) in _VALID_LABELS:
|
| 111 |
+
return mm.group(1), source
|
| 112 |
+
return None, "none"
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def _declared_labels(src: str) -> list[str]:
|
| 116 |
+
"""Every recognized doctrine token the surface source declares (audit trail)."""
|
| 117 |
+
return sorted({t for t in _TOKEN_RE.findall(src) if t in _VALID_LABELS})
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def _build_surface_entry(sid: str, title: str, mod: str) -> dict:
|
| 121 |
+
"""Build one manifest entry for a surface. Missing asset -> honest UNAVAILABLE."""
|
| 122 |
+
asset_rel = mod.lstrip("/")
|
| 123 |
+
asset_path = _REPO_ROOT / asset_rel
|
| 124 |
+
entry: dict = {"id": sid, "title": title, "asset": mod, "label_verbatim": True}
|
| 125 |
+
if not asset_path.is_file():
|
| 126 |
+
entry.update({
|
| 127 |
+
"label": UNAVAILABLE,
|
| 128 |
+
"label_source": "missing-asset",
|
| 129 |
+
"declared_labels": [],
|
| 130 |
+
"present": False,
|
| 131 |
+
"reason": f"surface asset not found at {mod}",
|
| 132 |
+
})
|
| 133 |
+
return entry
|
| 134 |
+
src = asset_path.read_text(encoding="utf-8", errors="replace")
|
| 135 |
+
label, label_source = _derive_label(src)
|
| 136 |
+
entry["present"] = True
|
| 137 |
+
entry["declared_labels"] = _declared_labels(src)
|
| 138 |
+
if label is None:
|
| 139 |
+
entry.update({
|
| 140 |
+
"label": UNAVAILABLE,
|
| 141 |
+
"label_source": "no-declared-label",
|
| 142 |
+
"reason": "surface source declares no recognized doctrine honesty token",
|
| 143 |
+
})
|
| 144 |
+
else:
|
| 145 |
+
entry.update({"label": label, "label_source": label_source})
|
| 146 |
+
return entry
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def build_surfaces_manifest(ns: str = "a11oy") -> dict:
|
| 150 |
+
"""Compose the machine-verifiable 3D-surface manifest from the live registry.
|
| 151 |
+
|
| 152 |
+
The surface list is parsed from static/3d/holographic.html's SURFACES array;
|
| 153 |
+
each label is parsed from the surface's own JS. Never fabricates a surface,
|
| 154 |
+
a count, or a label. If holographic.html itself is missing the manifest still
|
| 155 |
+
returns 200 with an honest empty list + error."""
|
| 156 |
+
endpoint = f"/api/{ns}/v1/frontier/surfaces"
|
| 157 |
+
holo = _REPO_ROOT / _HOLOGRAPHIC_REL
|
| 158 |
+
base = {
|
| 159 |
+
"endpoint": endpoint,
|
| 160 |
+
"source": _HOLOGRAPHIC_REL,
|
| 161 |
+
"hub": "frontier",
|
| 162 |
+
"doctrine": {
|
| 163 |
+
"version": "v11",
|
| 164 |
+
"lambda": "Conjecture 1",
|
| 165 |
+
"note": ("surface list parsed from holographic.html SURFACES; each label "
|
| 166 |
+
"parsed from the surface JS source and reported verbatim, never "
|
| 167 |
+
"upgraded; missing asset -> UNAVAILABLE, never fabricated"),
|
| 168 |
+
},
|
| 169 |
+
}
|
| 170 |
+
if not holo.is_file():
|
| 171 |
+
base.update({"ok": False, "count": 0, "surfaces": [],
|
| 172 |
+
"error": f"registry not found at {_HOLOGRAPHIC_REL}",
|
| 173 |
+
"summary": {"count": 0, "label_counts": {}, "labels_valid": True}})
|
| 174 |
+
return base
|
| 175 |
+
|
| 176 |
+
html = holo.read_text(encoding="utf-8", errors="replace")
|
| 177 |
+
entries = _SURFACE_ENTRY_RE.findall(html)
|
| 178 |
+
surfaces = [_build_surface_entry(sid, title, mod) for sid, title, mod in entries]
|
| 179 |
+
|
| 180 |
+
label_counts: dict[str, int] = {}
|
| 181 |
+
for s in surfaces:
|
| 182 |
+
label_counts[s["label"]] = label_counts.get(s["label"], 0) + 1
|
| 183 |
+
valid_set = set(_VALID_LABELS) | {UNAVAILABLE}
|
| 184 |
+
labels_valid = all(s["label"] in valid_set for s in surfaces)
|
| 185 |
+
|
| 186 |
+
base.update({
|
| 187 |
+
"ok": True,
|
| 188 |
+
"count": len(surfaces),
|
| 189 |
+
"surfaces": surfaces,
|
| 190 |
+
"summary": {
|
| 191 |
+
"count": len(surfaces),
|
| 192 |
+
"present": sum(1 for s in surfaces if s.get("present")),
|
| 193 |
+
"unavailable": sum(1 for s in surfaces if s["label"] == UNAVAILABLE),
|
| 194 |
+
"label_counts": label_counts,
|
| 195 |
+
"labels_valid": labels_valid,
|
| 196 |
+
},
|
| 197 |
+
})
|
| 198 |
+
return base
|
| 199 |
HONEST_BANNER = (
|
| 200 |
"HONEST SHOWCASE — every tile carries its own label (MEASURED / MODELED / "
|
| 201 |
"ROADMAP / SAMPLE) and a provenance pointer; no label is upgraded, nothing is faked"
|
|
|
|
| 203 |
|
| 204 |
# The LIVE backend roll-up this surface renders (PR #472). Wired client-side.
|
| 205 |
_MANIFEST_EP = "/api/{ns}/v1/frontier/manifest"
|
| 206 |
+
# The 3D-surface manifest this page renders its surface list from (one source of truth).
|
| 207 |
+
_SURFACES_EP = "/api/{ns}/v1/frontier/surfaces"
|
| 208 |
|
| 209 |
# 0-CDN vendored three.js r160 — the proven, allowlisted, runtime-served hero path
|
| 210 |
# (serve.py GET /hero/vendor3d/{fname}; identical to the /orbital page importmap).
|
|
|
|
| 214 |
|
| 215 |
def _page_html(ns: str) -> str:
|
| 216 |
manifest_ep = _MANIFEST_EP.format(ns=ns)
|
| 217 |
+
surfaces_ep = _SURFACES_EP.format(ns=ns)
|
| 218 |
return f"""<!doctype html>
|
| 219 |
<html lang="en"><head>
|
| 220 |
<meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
|
|
| 293 |
.badge.roadmap {{ background:rgba(157,122,216,.16); color:var(--violet); border:1px solid rgba(157,122,216,.5); }}
|
| 294 |
.badge.sample {{ background:rgba(77,143,204,.16); color:var(--indigo); border:1px solid rgba(77,143,204,.45); }}
|
| 295 |
.badge.unavailable {{ background:rgba(216,98,74,.16); color:var(--red); border:1px solid rgba(216,98,74,.5); }}
|
| 296 |
+
.badge.structural-only {{ background:rgba(138,151,163,.16); color:#9fb1bf; border:1px solid rgba(138,151,163,.5); }}
|
| 297 |
+
.badge.live {{ background:rgba(47,208,122,.16); color:var(--green); border:1px solid rgba(47,208,122,.45); }}
|
| 298 |
+
/* 3D-surface list — compact honest pills, one per surface. */
|
| 299 |
+
#surfaces-section {{ margin-top:1.6rem; }}
|
| 300 |
+
#surfaces-section h2 {{ font-size:clamp(1.1rem,2vw,1.4rem); margin:.2rem 0 0; }}
|
| 301 |
+
#surfaces-list {{ display:flex; flex-wrap:wrap; gap:.5rem; margin-top:1rem; }}
|
| 302 |
+
.surface-pill {{ display:flex; align-items:center; gap:.5rem; background:rgba(16,26,46,.84);
|
| 303 |
+
border:1px solid #21304d; border-radius:10px; padding:.4rem .6rem;
|
| 304 |
+
font-family:ui-monospace,monospace; font-size:.72rem; color:var(--ink); }}
|
| 305 |
+
.surface-pill .sid {{ color:var(--muted); }}
|
| 306 |
/* Per-tile persistent honest banner on non-MEASURED tiles. */
|
| 307 |
.tile-banner {{ font-family:ui-monospace,monospace; font-size:.66rem; line-height:1.4;
|
| 308 |
border-radius:8px; padding:.4rem .55rem; letter-spacing:.03em; }}
|
|
|
|
| 348 |
<span class="lg sample">SAMPLE — illustrative only</span>
|
| 349 |
</div>
|
| 350 |
<div id="rollup"></div>
|
| 351 |
+
|
| 352 |
+
<!-- 3D holographic surfaces — count + honest labels, from the SAME manifest the
|
| 353 |
+
holographic showcase is built from (one source of truth: /frontier/surfaces). -->
|
| 354 |
+
<div id="surfaces-section">
|
| 355 |
+
<h2 id="surfaces-h">3D holographic surfaces</h2>
|
| 356 |
+
<p class="sub" id="surfaces-sub">The holographic frontier surfaces, listed live from
|
| 357 |
+
<code>/frontier/surfaces</code> — the same machine-verifiable manifest that names each
|
| 358 |
+
surface's asset and its honest label (parsed from the surface source, never upgraded).</p>
|
| 359 |
+
<div id="surfaces-rollup"></div>
|
| 360 |
+
<div id="surfaces-list"></div>
|
| 361 |
+
<div class="status-line" id="surfaces-status">fetching /frontier/surfaces…</div>
|
| 362 |
+
</div>
|
| 363 |
+
|
| 364 |
<div id="grid"></div>
|
| 365 |
<div class="status-line" id="status">fetching /frontier/manifest…</div>
|
| 366 |
<div class="status-line"><a class="back" href="/">← back to console</a> ·
|
|
|
|
| 552 |
fail('manifest unavailable: ' + e + ' (nothing fabricated — raw data at ' + MANIFEST_EP + ')');
|
| 553 |
}}
|
| 554 |
}})();
|
| 555 |
+
|
| 556 |
+
// ---- 3D-surface list: rendered FROM /frontier/surfaces (one source of truth) ---
|
| 557 |
+
const SURFACES_EP = {surfaces_ep!r};
|
| 558 |
+
const SURF_CLASS = {{
|
| 559 |
+
MEASURED:'measured', LIVE:'live', SAMPLE:'sample', MODELED:'modeled',
|
| 560 |
+
'STRUCTURAL-ONLY':'structural-only', ROADMAP:'roadmap', UNAVAILABLE:'unavailable',
|
| 561 |
+
}};
|
| 562 |
+
function surfCls(label) {{ return SURF_CLASS[label] || 'unavailable'; }}
|
| 563 |
+
|
| 564 |
+
(async function loadSurfaces() {{
|
| 565 |
+
const statusEl = document.getElementById('surfaces-status');
|
| 566 |
+
try {{
|
| 567 |
+
const r = await fetch(SURFACES_EP, {{ headers:{{Accept:'application/json'}} }});
|
| 568 |
+
const m = await r.json();
|
| 569 |
+
const surfaces = m.surfaces || [];
|
| 570 |
+
const s = m.summary || {{}};
|
| 571 |
+
const lc = s.label_counts || {{}};
|
| 572 |
+
|
| 573 |
+
// honest roll-up: true count + per-label counts, straight from the manifest
|
| 574 |
+
const chips = [`<span class="chip"><b>${{esc(m.count ?? surfaces.length)}}</b> surfaces</span>`];
|
| 575 |
+
for (const [label, n] of Object.entries(lc)) {{
|
| 576 |
+
chips.push(`<span class="chip">${{esc(label)}} <b>${{esc(n)}}</b></span>`);
|
| 577 |
+
}}
|
| 578 |
+
if (s.unavailable) chips.push(`<span class="chip">unavailable <b>${{esc(s.unavailable)}}</b></span>`);
|
| 579 |
+
chips.push(`<span class="chip">labels valid: <b>${{esc(String(s.labels_valid))}}</b></span>`);
|
| 580 |
+
document.getElementById('surfaces-rollup').innerHTML = chips.join('');
|
| 581 |
+
|
| 582 |
+
// one honest pill per surface: id · title · label badge
|
| 583 |
+
document.getElementById('surfaces-list').innerHTML = surfaces.map(su => {{
|
| 584 |
+
const label = su.label || 'UNAVAILABLE';
|
| 585 |
+
return `<span class="surface-pill" title="${{esc(su.asset || '')}}">`
|
| 586 |
+
+ `<span class="sid">${{esc(su.id)}}</span>`
|
| 587 |
+
+ `<span>${{esc(su.title || '')}}</span>`
|
| 588 |
+
+ `<span class="badge ${{surfCls(label)}}">${{esc(label)}}</span></span>`;
|
| 589 |
+
}}).join('');
|
| 590 |
+
|
| 591 |
+
statusEl.className = 'status-line';
|
| 592 |
+
statusEl.textContent = (m.ok === false)
|
| 593 |
+
? ('surface registry unavailable: ' + esc(m.error || 'unknown') + ' (nothing fabricated)')
|
| 594 |
+
: ('live · ' + esc(m.count ?? surfaces.length) + ' surfaces from ' + esc(SURFACES_EP)
|
| 595 |
+
+ ' · labels_valid=' + esc(String(s.labels_valid)));
|
| 596 |
+
}} catch (e) {{
|
| 597 |
+
statusEl.className = 'status-line err';
|
| 598 |
+
statusEl.textContent = 'surfaces unavailable: ' + e + ' (nothing fabricated — raw data at ' + SURFACES_EP + ')';
|
| 599 |
+
}}
|
| 600 |
+
}})();
|
| 601 |
</script>
|
| 602 |
</body></html>"""
|
| 603 |
|
|
|
|
| 610 |
async def frontier_page() -> HTMLResponse: # noqa: ANN202
|
| 611 |
return HTMLResponse(_page_html(ns))
|
| 612 |
|
| 613 |
+
@app.get(f"/api/{ns}/v1/frontier/surfaces")
|
| 614 |
+
async def frontier_surfaces() -> JSONResponse: # noqa: ANN202
|
| 615 |
+
"""Machine-verifiable manifest of every 3D frontier surface.
|
| 616 |
+
|
| 617 |
+
id + title + honesty label (parsed from the surface source, verbatim) +
|
| 618 |
+
asset path. Missing asset -> UNAVAILABLE with reason. Pure read; no sign."""
|
| 619 |
+
return JSONResponse(build_surfaces_manifest(ns))
|
| 620 |
+
|
| 621 |
@app.get(f"/api/{ns}/v1/frontier/page-manifest", include_in_schema=False)
|
| 622 |
async def frontier_page_manifest() -> JSONResponse: # noqa: ANN202
|
| 623 |
return JSONResponse({
|
|
|
|
| 626 |
"kind": "unified-ecosystem-showcase",
|
| 627 |
"banner": HONEST_BANNER,
|
| 628 |
"doctrine": DOCTRINE,
|
| 629 |
+
"renders_endpoints": [_MANIFEST_EP.format(ns=ns), _SURFACES_EP.format(ns=ns)],
|
| 630 |
+
"links": {"orbital_page": "/orbital", "manifest": _MANIFEST_EP.format(ns=ns),
|
| 631 |
+
"surfaces": _SURFACES_EP.format(ns=ns)},
|
| 632 |
"vendored_3d": {"three": _THREE_MAIN, "addons": _THREE_ADDONS,
|
| 633 |
"revision": "r160", "runtime_cdn": 0},
|
| 634 |
"note": ("Unified frontier showcase — renders the live /frontier/manifest "
|
|
|
|
| 637 |
"no label is upgraded, nothing is fabricated."),
|
| 638 |
})
|
| 639 |
|
| 640 |
+
return ("frontier-page mounted: GET /frontier + page-manifest + "
|
| 641 |
+
f"/api/{ns}/v1/frontier/surfaces (3D-surface manifest, parsed from "
|
| 642 |
+
"holographic.html; renders /frontier/manifest roll-up + surface list, 0 CDN)")
|
| 643 |
|
| 644 |
|
| 645 |
def _selftest() -> None:
|
|
|
|
| 660 |
# 6) links to the orbital MODELED tier are present
|
| 661 |
assert 'href="/orbital"' in html, "orbital tier link missing"
|
| 662 |
assert "Conjecture 1" in html, "Λ label missing"
|
| 663 |
+
# 7) the 3D-surface manifest is wired into the page (one source of truth)
|
| 664 |
+
assert "/api/a11oy/v1/frontier/surfaces" in html, "surfaces endpoint not wired"
|
| 665 |
+
assert 'id="surfaces-list"' in html and 'id="surfaces-rollup"' in html, \
|
| 666 |
+
"surfaces section markers missing"
|
| 667 |
+
assert "loadSurfaces" in html, "surfaces client loader missing"
|
| 668 |
+
|
| 669 |
+
# 8) the manifest builder parses the live registry honestly
|
| 670 |
+
man = build_surfaces_manifest("a11oy")
|
| 671 |
+
assert man["ok"] is True, f"surfaces manifest not ok: {man.get('error')}"
|
| 672 |
+
assert man["count"] == len(man["surfaces"]) and man["count"] > 0, "surface count mismatch"
|
| 673 |
+
valid = set(_VALID_LABELS) | {UNAVAILABLE}
|
| 674 |
+
assert all(su["label"] in valid for su in man["surfaces"]), "invalid honesty label found"
|
| 675 |
+
assert man["summary"]["labels_valid"] is True, "labels_valid should be True"
|
| 676 |
+
# missing asset -> honest UNAVAILABLE, never fabricated present/green
|
| 677 |
+
miss = _build_surface_entry("nope", "Nope", "/static/3d/surfaces/__does_not_exist__.js")
|
| 678 |
+
assert miss["label"] == UNAVAILABLE and miss["present"] is False and "reason" in miss, \
|
| 679 |
+
"missing asset must be UNAVAILABLE with a reason"
|
| 680 |
print("a11oy_frontier_page: ALL OK (honest banner, manifest wired, 0 CDN, render marker, "
|
| 681 |
+
"per-tile honest banners, orbital link, "
|
| 682 |
+
f"{man['count']} surfaces parsed, labels {man['summary']['label_counts']})")
|
| 683 |
|
| 684 |
|
| 685 |
if __name__ == "__main__":
|