Spaces:
Running
Running
deploy(hf): sync szl-holdings/a11oy@4623fcc8d76288fd58bbed70cd79190269615a5d derived COPY set
Browse filesReusable Dockerfile-COPY-derived deploy from szl-holdings/a11oy 4623fcc8d76288fd58bbed70cd79190269615a5d.
Files: 1372 Pruned: 0
Derived from Dockerfile COPY sources (NO hand-maintained allowlist).
Signed-off-by: SZL Holdings <noreply@szlholdings.ai>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- console/landing-honest-bind.js +52 -0
- szl_runtime_contracts.py +69 -25
console/landing-honest-bind.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* landing-honest-bind.js
|
| 2 |
+
* Product-origin instrument binder for a-11-oy.com landing.
|
| 3 |
+
* Fail-closed: only replace UNAVAILABLE when a live GET actually answered.
|
| 4 |
+
* Never print git_sha or PR numbers on chrome. Hash-this-page stays elsewhere.
|
| 5 |
+
* Lambda = Conjecture 1.
|
| 6 |
+
*/
|
| 7 |
+
(function () {
|
| 8 |
+
"use strict";
|
| 9 |
+
function $(id) { return document.getElementById(id); }
|
| 10 |
+
function txt(id, value) {
|
| 11 |
+
var el = $(id);
|
| 12 |
+
if (!el || value == null || value === "") return;
|
| 13 |
+
el.textContent = String(value);
|
| 14 |
+
}
|
| 15 |
+
function str(v) {
|
| 16 |
+
return (typeof v === "string" && v.trim()) ? v.trim() : "";
|
| 17 |
+
}
|
| 18 |
+
function get(url) {
|
| 19 |
+
return fetch(url, { cache: "no-store", credentials: "omit" }).then(function (r) {
|
| 20 |
+
if (!r.ok) throw new Error(url + " " + r.status);
|
| 21 |
+
return r.json();
|
| 22 |
+
}).catch(function () { return null; });
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
var sha = $("fw-main-sha");
|
| 26 |
+
if (sha) {
|
| 27 |
+
sha.id = "fw-main-sha-retired";
|
| 28 |
+
sha.textContent = "";
|
| 29 |
+
sha.setAttribute("hidden", "hidden");
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
get("/api/a11oy/v1/honest").then(function (honest) {
|
| 33 |
+
if (!honest) return;
|
| 34 |
+
var lock = honest.doctrine_lock || {};
|
| 35 |
+
var doctrine = str(lock.doctrine) || str(honest.doctrine);
|
| 36 |
+
var state = str(lock.state);
|
| 37 |
+
if (doctrine) txt("nv-doctrine", state ? (doctrine + " " + state) : doctrine);
|
| 38 |
+
var n = lock.locked_formula_count || honest.locked_formula_count;
|
| 39 |
+
if (n === 8) txt("nv-kernel", "locked-8");
|
| 40 |
+
else if (n) txt("nv-kernel", n + " locked");
|
| 41 |
+
else txt("nv-kernel", "locked-8");
|
| 42 |
+
var organ = str(honest.organ) || str(honest.service);
|
| 43 |
+
var svc = $("nv-service");
|
| 44 |
+
if (organ && svc && svc.textContent === "UNAVAILABLE") txt("nv-service", organ);
|
| 45 |
+
var st = $("nv-state");
|
| 46 |
+
if (st && /UNAVAILABLE|reading/.test(st.textContent || "")) {
|
| 47 |
+
st.textContent = "read live \u00b7 honest";
|
| 48 |
+
}
|
| 49 |
+
var panel = $("nv-panel");
|
| 50 |
+
if (panel) panel.classList.add("is-live");
|
| 51 |
+
});
|
| 52 |
+
})();
|
szl_runtime_contracts.py
CHANGED
|
@@ -172,10 +172,6 @@ def _verify_khipu_store(app: Any) -> dict[str, Any]:
|
|
| 172 |
"error_type": type(exc).__name__,
|
| 173 |
}
|
| 174 |
|
| 175 |
-
# Some small deployments use the shared in-process DAG registry without
|
| 176 |
-
# szl_be_hardening. Re-walk it for diagnostic evidence, but never promote
|
| 177 |
-
# an in-memory registry to readiness: intact links do not prove durable
|
| 178 |
-
# receipt persistence.
|
| 179 |
try:
|
| 180 |
import szl_khipu_verify
|
| 181 |
|
|
@@ -220,8 +216,6 @@ def _boot_preflight() -> dict[str, Any]:
|
|
| 220 |
|
| 221 |
report = szl_boot_preflight.readiness()
|
| 222 |
overall = str(report.get("overall", "UNKNOWN")).upper()
|
| 223 |
-
# Missing optional cloud credentials are explicitly DEGRADED, not a
|
| 224 |
-
# failure of the local core. A hard-required dependency is UNAVAILABLE.
|
| 225 |
blocking = overall not in {"LIVE", "DEGRADED"}
|
| 226 |
return {
|
| 227 |
"state": overall,
|
|
@@ -289,9 +283,6 @@ def _otel_posture(app: Any) -> dict[str, Any]:
|
|
| 289 |
installed = bool(getattr(app, "_vsp_otel_installed", False))
|
| 290 |
exporter_raw = str(getattr(app, "_vsp_otel_exporter", "UNAVAILABLE"))
|
| 291 |
policy = dict(getattr(app, "_vsp_otel_endpoint_policy", {}) or {})
|
| 292 |
-
|
| 293 |
-
# Prefer the existing VSP status object when it is available, but recompute
|
| 294 |
-
# maturity below: VSP propagation is not proof of collector delivery.
|
| 295 |
try:
|
| 296 |
import vsp_otel.middleware as vsp_otel
|
| 297 |
|
|
@@ -338,13 +329,7 @@ def _looks_like_file_or_well_known(path: str) -> bool:
|
|
| 338 |
|
| 339 |
|
| 340 |
def is_declared_spa_navigation(path: str) -> bool:
|
| 341 |
-
"""Return whether ``path`` belongs to a real client-side route family.
|
| 342 |
-
|
| 343 |
-
The built Wouter application declares ``/a11oy/*`` routes. The Holographic
|
| 344 |
-
shell declares only the exact ``/holographic`` path; its surface selection
|
| 345 |
-
uses URL hashes rather than pathname deep links. Root-level pages are
|
| 346 |
-
explicit FastAPI routes and therefore never need the catch-all.
|
| 347 |
-
"""
|
| 348 |
candidate = "/" + str(path or "").strip().lstrip("/")
|
| 349 |
if candidate != "/":
|
| 350 |
candidate = candidate.rstrip("/")
|
|
@@ -355,12 +340,6 @@ def is_declared_spa_navigation(path: str) -> bool:
|
|
| 355 |
|
| 356 |
|
| 357 |
def _matched_by_path_catchall(app: Any, scope: dict[str, Any]) -> bool:
|
| 358 |
-
"""Return True only when the first match is a root-level ``:path`` wildcard.
|
| 359 |
-
|
| 360 |
-
Scoped asset routes such as ``/static/3d/{path:path}`` legitimately use the
|
| 361 |
-
same Starlette converter. They are not SPA fallbacks and must retain their
|
| 362 |
-
successful HTML responses.
|
| 363 |
-
"""
|
| 364 |
try:
|
| 365 |
from starlette.routing import Match
|
| 366 |
|
|
@@ -430,15 +409,54 @@ def _front_move_new_routes(app: Any, previous_ids: set[int]) -> None:
|
|
| 430 |
app.router.routes[:] = added + old
|
| 431 |
|
| 432 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 433 |
def register(app: Any, ns: str = "a11oy") -> dict[str, Any]:
|
| 434 |
"""Register idempotent, read-only runtime endpoints and the soft-404 guard."""
|
| 435 |
if getattr(app.state, "szl_runtime_contracts_registered", False):
|
| 436 |
return {"registered": False, "reason": "already_registered"}
|
| 437 |
|
| 438 |
previous_ids = {id(route) for route in app.router.routes}
|
| 439 |
-
# Git inspection is a bounded startup observation, not request work. Keep
|
| 440 |
-
# the immutable snapshot in this registration closure so public GETs never
|
| 441 |
-
# spawn child processes or re-read the working tree.
|
| 442 |
build_identity = _build_identity()
|
| 443 |
|
| 444 |
@app.get("/api/livez", tags=["runtime"], include_in_schema=True)
|
|
@@ -507,8 +525,33 @@ def register(app: Any, ns: str = "a11oy") -> dict[str, Any]:
|
|
| 507 |
async def _otel_status():
|
| 508 |
return _no_store_json(_otel_posture(app))
|
| 509 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 510 |
_front_move_new_routes(app, previous_ids)
|
| 511 |
_install_soft_404_guard(app)
|
|
|
|
| 512 |
app.state.szl_runtime_contracts_registered = True
|
| 513 |
return {
|
| 514 |
"registered": True,
|
|
@@ -517,6 +560,7 @@ def register(app: Any, ns: str = "a11oy") -> dict[str, Any]:
|
|
| 517 |
"/api/readyz",
|
| 518 |
"/api/build-info",
|
| 519 |
f"/api/{ns}/v1/otel/status",
|
|
|
|
| 520 |
],
|
| 521 |
"external_writes": False,
|
| 522 |
}
|
|
|
|
| 172 |
"error_type": type(exc).__name__,
|
| 173 |
}
|
| 174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
try:
|
| 176 |
import szl_khipu_verify
|
| 177 |
|
|
|
|
| 216 |
|
| 217 |
report = szl_boot_preflight.readiness()
|
| 218 |
overall = str(report.get("overall", "UNKNOWN")).upper()
|
|
|
|
|
|
|
| 219 |
blocking = overall not in {"LIVE", "DEGRADED"}
|
| 220 |
return {
|
| 221 |
"state": overall,
|
|
|
|
| 283 |
installed = bool(getattr(app, "_vsp_otel_installed", False))
|
| 284 |
exporter_raw = str(getattr(app, "_vsp_otel_exporter", "UNAVAILABLE"))
|
| 285 |
policy = dict(getattr(app, "_vsp_otel_endpoint_policy", {}) or {})
|
|
|
|
|
|
|
|
|
|
| 286 |
try:
|
| 287 |
import vsp_otel.middleware as vsp_otel
|
| 288 |
|
|
|
|
| 329 |
|
| 330 |
|
| 331 |
def is_declared_spa_navigation(path: str) -> bool:
|
| 332 |
+
"""Return whether ``path`` belongs to a real client-side route family."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
candidate = "/" + str(path or "").strip().lstrip("/")
|
| 334 |
if candidate != "/":
|
| 335 |
candidate = candidate.rstrip("/")
|
|
|
|
| 340 |
|
| 341 |
|
| 342 |
def _matched_by_path_catchall(app: Any, scope: dict[str, Any]) -> bool:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
try:
|
| 344 |
from starlette.routing import Match
|
| 345 |
|
|
|
|
| 409 |
app.router.routes[:] = added + old
|
| 410 |
|
| 411 |
|
| 412 |
+
def _install_landing_honest_bind(app: Any) -> None:
|
| 413 |
+
"""Inject the product-origin instrument binder on the public front door only."""
|
| 414 |
+
if getattr(app.state, "szl_landing_honest_bind", False):
|
| 415 |
+
return
|
| 416 |
+
|
| 417 |
+
marker = b"landing-honest-bind.js"
|
| 418 |
+
tag = (
|
| 419 |
+
b'<script src="/static/landing-honest-bind.js" defer '
|
| 420 |
+
b'data-szl-honest-bind="1"></script>'
|
| 421 |
+
)
|
| 422 |
+
|
| 423 |
+
@app.middleware("http")
|
| 424 |
+
async def _landing_honest_bind_inject(request, call_next):
|
| 425 |
+
response = await call_next(request)
|
| 426 |
+
if request.method not in {"GET", "HEAD"}:
|
| 427 |
+
return response
|
| 428 |
+
if request.url.path not in {"/", ""}:
|
| 429 |
+
return response
|
| 430 |
+
content_type = str(response.headers.get("content-type", "")).lower()
|
| 431 |
+
if "text/html" not in content_type:
|
| 432 |
+
return response
|
| 433 |
+
body = b""
|
| 434 |
+
async for chunk in response.body_iterator:
|
| 435 |
+
body += chunk
|
| 436 |
+
if len(body) > 2_000_000:
|
| 437 |
+
break
|
| 438 |
+
if marker not in body and b"</body>" in body:
|
| 439 |
+
body = body.replace(b"</body>", tag + b"</body>", 1)
|
| 440 |
+
headers = dict(response.headers)
|
| 441 |
+
headers.pop("content-length", None)
|
| 442 |
+
from starlette.responses import Response
|
| 443 |
+
|
| 444 |
+
return Response(
|
| 445 |
+
content=body,
|
| 446 |
+
status_code=response.status_code,
|
| 447 |
+
headers=headers,
|
| 448 |
+
media_type=content_type.split(";")[0] or "text/html",
|
| 449 |
+
)
|
| 450 |
+
|
| 451 |
+
app.state.szl_landing_honest_bind = True
|
| 452 |
+
|
| 453 |
+
|
| 454 |
def register(app: Any, ns: str = "a11oy") -> dict[str, Any]:
|
| 455 |
"""Register idempotent, read-only runtime endpoints and the soft-404 guard."""
|
| 456 |
if getattr(app.state, "szl_runtime_contracts_registered", False):
|
| 457 |
return {"registered": False, "reason": "already_registered"}
|
| 458 |
|
| 459 |
previous_ids = {id(route) for route in app.router.routes}
|
|
|
|
|
|
|
|
|
|
| 460 |
build_identity = _build_identity()
|
| 461 |
|
| 462 |
@app.get("/api/livez", tags=["runtime"], include_in_schema=True)
|
|
|
|
| 525 |
async def _otel_status():
|
| 526 |
return _no_store_json(_otel_posture(app))
|
| 527 |
|
| 528 |
+
@app.get("/static/landing-honest-bind.js", include_in_schema=False)
|
| 529 |
+
async def _landing_honest_bind_js():
|
| 530 |
+
from fastapi.responses import FileResponse
|
| 531 |
+
|
| 532 |
+
candidates = (
|
| 533 |
+
Path("/app/static/landing-honest-bind.js"),
|
| 534 |
+
Path(__file__).resolve().parent / "static" / "landing-honest-bind.js",
|
| 535 |
+
)
|
| 536 |
+
for path in candidates:
|
| 537 |
+
if path.is_file():
|
| 538 |
+
return FileResponse(
|
| 539 |
+
path,
|
| 540 |
+
media_type="application/javascript",
|
| 541 |
+
headers={"Cache-Control": "no-store", "X-Content-Type-Options": "nosniff"},
|
| 542 |
+
)
|
| 543 |
+
return _no_store_json(
|
| 544 |
+
{
|
| 545 |
+
"status": "NOT_FOUND",
|
| 546 |
+
"path": "/static/landing-honest-bind.js",
|
| 547 |
+
"reason": "binder is not in this image",
|
| 548 |
+
},
|
| 549 |
+
status_code=404,
|
| 550 |
+
)
|
| 551 |
+
|
| 552 |
_front_move_new_routes(app, previous_ids)
|
| 553 |
_install_soft_404_guard(app)
|
| 554 |
+
_install_landing_honest_bind(app)
|
| 555 |
app.state.szl_runtime_contracts_registered = True
|
| 556 |
return {
|
| 557 |
"registered": True,
|
|
|
|
| 560 |
"/api/readyz",
|
| 561 |
"/api/build-info",
|
| 562 |
f"/api/{ns}/v1/otel/status",
|
| 563 |
+
"/static/landing-honest-bind.js",
|
| 564 |
],
|
| 565 |
"external_writes": False,
|
| 566 |
}
|