Spaces:
Running
Running
deploy(hf): sync szl-holdings/a11oy@3b6f107e139541e7d0000ad2e1c03e36ef13bba8 derived COPY set
Browse filesReusable Dockerfile-COPY-derived deploy from szl-holdings/a11oy 3b6f107e139541e7d0000ad2e1c03e36ef13bba8.
Files: 1298 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>
- static/3d/surfaces/brainreranker.js +10 -3
- static/3d/surfaces/sovereign.js +13 -2
- szl_brain_reranker.py +44 -1
- szl_sovereign_panel.py +52 -0
static/3d/surfaces/brainreranker.js
CHANGED
|
@@ -89,7 +89,8 @@ function paint() {
|
|
| 89 |
if (!overlay) return;
|
| 90 |
const s = state.status || {}, inv = s.inventory || {}, ds = s.dataset || {};
|
| 91 |
const feed = s.feed || {}, model = s.model || {}, evaluation = s.evaluation || {};
|
| 92 |
-
overlay.querySelector("[data-v=status]").textContent =
|
|
|
|
| 93 |
overlay.querySelector("[data-v=raw]").textContent = value(inv.raw_node_count);
|
| 94 |
overlay.querySelector("[data-v=rendered]").textContent = value(
|
| 95 |
state.inventory && state.inventory.decisions ? state.inventory.decisions.length : 0
|
|
@@ -103,10 +104,16 @@ function paint() {
|
|
| 103 |
overlay.querySelector("[data-v=loop]").textContent = value(feed.status) + " · " + value(feed.checkpoint);
|
| 104 |
overlay.querySelector("[data-v=receipt]").textContent = value(feed.last_successful_receipt);
|
| 105 |
overlay.querySelector("[data-v=next]").textContent = value(feed.next_refresh_utc);
|
|
|
|
|
|
|
|
|
|
| 106 |
overlay.querySelector("[data-v=note]").textContent = state.error ||
|
| 107 |
-
((ds.reasons || []).join(" | ") ||
|
|
|
|
| 108 |
if (show) {
|
| 109 |
-
show.setChip("state", s.
|
|
|
|
|
|
|
| 110 |
show.setChip("nodes", s.inventory_label || "UNAVAILABLE", {
|
| 111 |
text: "raw nodes " + (inv.raw_node_count == null ? "UNKNOWN" : String(inv.raw_node_count))
|
| 112 |
});
|
|
|
|
| 89 |
if (!overlay) return;
|
| 90 |
const s = state.status || {}, inv = s.inventory || {}, ds = s.dataset || {};
|
| 91 |
const feed = s.feed || {}, model = s.model || {}, evaluation = s.evaluation || {};
|
| 92 |
+
overlay.querySelector("[data-v=status]").textContent =
|
| 93 |
+
value(s.label || "UNAVAILABLE") + " · pipeline " + value(s.status || state.mode);
|
| 94 |
overlay.querySelector("[data-v=raw]").textContent = value(inv.raw_node_count);
|
| 95 |
overlay.querySelector("[data-v=rendered]").textContent = value(
|
| 96 |
state.inventory && state.inventory.decisions ? state.inventory.decisions.length : 0
|
|
|
|
| 104 |
overlay.querySelector("[data-v=loop]").textContent = value(feed.status) + " · " + value(feed.checkpoint);
|
| 105 |
overlay.querySelector("[data-v=receipt]").textContent = value(feed.last_successful_receipt);
|
| 106 |
overlay.querySelector("[data-v=next]").textContent = value(feed.next_refresh_utc);
|
| 107 |
+
// The honest label ladder comes from the service: MEASURED only when the whole
|
| 108 |
+
// pipeline is READY, MODELED when the inventory was read live this request but the
|
| 109 |
+
// model/evaluation pipeline is BLOCKED, UNAVAILABLE when the graph is unreadable.
|
| 110 |
overlay.querySelector("[data-v=note]").textContent = state.error ||
|
| 111 |
+
s.label_basis || ((ds.reasons || []).join(" | ") ||
|
| 112 |
+
"No readiness claim exceeds the receipts shown here.");
|
| 113 |
if (show) {
|
| 114 |
+
show.setChip("state", s.label || "UNAVAILABLE", {
|
| 115 |
+
text: "pipeline " + value(s.status || state.mode)
|
| 116 |
+
});
|
| 117 |
show.setChip("nodes", s.inventory_label || "UNAVAILABLE", {
|
| 118 |
text: "raw nodes " + (inv.raw_node_count == null ? "UNKNOWN" : String(inv.raw_node_count))
|
| 119 |
});
|
static/3d/surfaces/sovereign.js
CHANGED
|
@@ -49,6 +49,7 @@ const S = {
|
|
| 49 |
reachable:false, baseUrl:null, envPresent:null, apiStyle:null,
|
| 50 |
modelTag:"llama3-szl-finetuned-q4", modelServed:null, modelsLive:[],
|
| 51 |
via:null, dependency:null, reachNote:null,
|
|
|
|
| 52 |
selftestLabel:"UNAVAILABLE", selftestAnswer:null, selftestPrompt:"State your doctrine in one line",
|
| 53 |
activeStage:"UNKNOWN", stageNote:null,
|
| 54 |
signMode:null, signed:null, signerFp:null,
|
|
@@ -94,6 +95,11 @@ function _onPanel(j){
|
|
| 94 |
S.via=sov.via||null;
|
| 95 |
S.dependency=sov.dependency||null;
|
| 96 |
S.reachNote=sov.note||null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
S.modelTag=j.model_tag||S.modelTag;
|
| 98 |
|
| 99 |
const st=j.doctrine_selftest||{};
|
|
@@ -179,6 +185,8 @@ function _buildOverlay(ctx){
|
|
| 179 |
'<div style="margin-top:2px;color:#8fb3bd;font-size:10.5px">Operator status of the founder\'s <b>LOCAL sovereign model</b> (Ollama on the Tower, Doctrine-v11 system prompt over base llama3.1:8b). The Tower is <b>not reachable from CI/cloud</b>, so off-Tower this reads <b>UNAVAILABLE</b> — never a fabricated live status or doctrine line.</div>'+
|
| 180 |
_row("Reachable","sv-reach")+_row("Model tag","sv-tag")+
|
| 181 |
_row("Served (live)","sv-served")+_row("Endpoint base","sv-base")+
|
|
|
|
|
|
|
| 182 |
'<hr style="border:0;border-top:1px solid #1b3a44;margin:8px 0">'+
|
| 183 |
'<div style="font-size:10.5px;color:#8fb3bd;margin-bottom:3px">Doctrine self-test — “State your doctrine in one line”</div>'+
|
| 184 |
_row("Result","sv-stlabel")+
|
|
@@ -218,14 +226,17 @@ function _paintOverlay(){
|
|
| 218 |
const missing=(S.state==="missing"||S.state==="error");
|
| 219 |
if(_show) _show.setChip("label",S.label||"UNAVAILABLE");
|
| 220 |
if(missing){
|
| 221 |
-
["sv-reach","sv-tag","sv-served","sv-base","sv-stlabel","sv-stage","sv-sign"].forEach((id)=>_set(id,"NO-LIVE-DATA"));
|
|
|
|
| 222 |
_set2("sv-answer","backend offline — NO-LIVE-DATA (honest, never fabricated).");
|
| 223 |
if(_plain)_applyPlain(); return;
|
| 224 |
}
|
| 225 |
_set("sv-reach",S.reachable?"YES · LIVE-SOVEREIGN":"NO · UNAVAILABLE");
|
| 226 |
_set("sv-tag",S.modelTag||"—");
|
| 227 |
_set("sv-served",(S.reachable&&S.modelServed)?S.modelServed:"— (node unreachable)");
|
| 228 |
-
_set("sv-base",S.baseUrl?String(S.baseUrl):(S.
|
|
|
|
|
|
|
| 229 |
_set("sv-stlabel",S.selftestLabel||"UNAVAILABLE");
|
| 230 |
_set2("sv-answer", S.selftestAnswer
|
| 231 |
? S.selftestAnswer
|
|
|
|
| 49 |
reachable:false, baseUrl:null, envPresent:null, apiStyle:null,
|
| 50 |
modelTag:"llama3-szl-finetuned-q4", modelServed:null, modelsLive:[],
|
| 51 |
via:null, dependency:null, reachNote:null,
|
| 52 |
+
reason:null, reasonText:null, baseSource:null,
|
| 53 |
selftestLabel:"UNAVAILABLE", selftestAnswer:null, selftestPrompt:"State your doctrine in one line",
|
| 54 |
activeStage:"UNKNOWN", stageNote:null,
|
| 55 |
signMode:null, signed:null, signerFp:null,
|
|
|
|
| 95 |
S.via=sov.via||null;
|
| 96 |
S.dependency=sov.dependency||null;
|
| 97 |
S.reachNote=sov.note||null;
|
| 98 |
+
// Honest, machine-readable reason for a non-live sovereign: an unset env var
|
| 99 |
+
// (environment gap) reads differently from a configured-but-silent node.
|
| 100 |
+
S.reason=(sov.unavailable_reason||j.unavailable_reason)||null;
|
| 101 |
+
S.reasonText=(sov.unavailable_reason_text||j.unavailable_reason_text)||null;
|
| 102 |
+
S.baseSource=sov.base_url_source||null;
|
| 103 |
S.modelTag=j.model_tag||S.modelTag;
|
| 104 |
|
| 105 |
const st=j.doctrine_selftest||{};
|
|
|
|
| 185 |
'<div style="margin-top:2px;color:#8fb3bd;font-size:10.5px">Operator status of the founder\'s <b>LOCAL sovereign model</b> (Ollama on the Tower, Doctrine-v11 system prompt over base llama3.1:8b). The Tower is <b>not reachable from CI/cloud</b>, so off-Tower this reads <b>UNAVAILABLE</b> — never a fabricated live status or doctrine line.</div>'+
|
| 186 |
_row("Reachable","sv-reach")+_row("Model tag","sv-tag")+
|
| 187 |
_row("Served (live)","sv-served")+_row("Endpoint base","sv-base")+
|
| 188 |
+
_row("Why not live","sv-reason")+
|
| 189 |
+
'<div id="sv-reasontext" style="margin-top:3px;font-size:10.5px;color:#9fc;line-height:1.5"></div>'+
|
| 190 |
'<hr style="border:0;border-top:1px solid #1b3a44;margin:8px 0">'+
|
| 191 |
'<div style="font-size:10.5px;color:#8fb3bd;margin-bottom:3px">Doctrine self-test — “State your doctrine in one line”</div>'+
|
| 192 |
_row("Result","sv-stlabel")+
|
|
|
|
| 226 |
const missing=(S.state==="missing"||S.state==="error");
|
| 227 |
if(_show) _show.setChip("label",S.label||"UNAVAILABLE");
|
| 228 |
if(missing){
|
| 229 |
+
["sv-reach","sv-tag","sv-served","sv-base","sv-reason","sv-stlabel","sv-stage","sv-sign"].forEach((id)=>_set(id,"NO-LIVE-DATA"));
|
| 230 |
+
_set2("sv-reasontext","panel endpoint did not answer this request \u2014 no status inferred.");
|
| 231 |
_set2("sv-answer","backend offline — NO-LIVE-DATA (honest, never fabricated).");
|
| 232 |
if(_plain)_applyPlain(); return;
|
| 233 |
}
|
| 234 |
_set("sv-reach",S.reachable?"YES · LIVE-SOVEREIGN":"NO · UNAVAILABLE");
|
| 235 |
_set("sv-tag",S.modelTag||"—");
|
| 236 |
_set("sv-served",(S.reachable&&S.modelServed)?S.modelServed:"— (node unreachable)");
|
| 237 |
+
_set("sv-base",(S.baseUrl?String(S.baseUrl):"—")+(S.baseSource?" ( "+S.baseSource+" )":""));
|
| 238 |
+
_set("sv-reason",S.reachable?"— (node answered this request)":(S.reason||"UNKNOWN"));
|
| 239 |
+
_set2("sv-reasontext",S.reachable?"":(S.reasonText||""));
|
| 240 |
_set("sv-stlabel",S.selftestLabel||"UNAVAILABLE");
|
| 241 |
_set2("sv-answer", S.selftestAnswer
|
| 242 |
? S.selftestAnswer
|
szl_brain_reranker.py
CHANGED
|
@@ -45,6 +45,8 @@ READY = "READY"
|
|
| 45 |
BLOCKED = "BLOCKED"
|
| 46 |
DEGRADED = "DEGRADED"
|
| 47 |
UNAVAILABLE = "UNAVAILABLE"
|
|
|
|
|
|
|
| 48 |
UNKNOWN = "UNKNOWN"
|
| 49 |
UNVERIFIED = "UNVERIFIED"
|
| 50 |
|
|
@@ -822,13 +824,54 @@ def service_status(ns: str = "a11oy", repo_root: pathlib.Path | str | None = Non
|
|
| 822 |
dataset["evaluation_readiness"]["status"],
|
| 823 |
)
|
| 824 |
operational = all(state == READY for state in readiness)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 825 |
return {
|
| 826 |
"ok": True, "schema_version": SERVICE_SCHEMA,
|
| 827 |
# The inventory can be measured while the train/eval/model pipeline is still
|
| 828 |
# unavailable. Keep those truths separate so the estate rollup cannot turn
|
| 829 |
# a measured node count into an operational model claim.
|
| 830 |
"status": READY if operational else BLOCKED,
|
| 831 |
-
"label":
|
|
|
|
|
|
|
|
|
|
| 832 |
"inventory_label": inventory["label"],
|
| 833 |
"inventory": inventory["inventory"],
|
| 834 |
"inventory_sha256": inventory["inventory_sha256"],
|
|
|
|
| 45 |
BLOCKED = "BLOCKED"
|
| 46 |
DEGRADED = "DEGRADED"
|
| 47 |
UNAVAILABLE = "UNAVAILABLE"
|
| 48 |
+
MEASURED = "MEASURED"
|
| 49 |
+
MODELED = "MODELED"
|
| 50 |
UNKNOWN = "UNKNOWN"
|
| 51 |
UNVERIFIED = "UNVERIFIED"
|
| 52 |
|
|
|
|
| 824 |
dataset["evaluation_readiness"]["status"],
|
| 825 |
)
|
| 826 |
operational = all(state == READY for state in readiness)
|
| 827 |
+
# ------------------------------------------------------------------
|
| 828 |
+
# Honest surface label (Doctrine v11). The previous rule collapsed the
|
| 829 |
+
# surface label to UNAVAILABLE unless ALL THREE readiness dimensions were
|
| 830 |
+
# READY, so an estate that really does compute a live evidence inventory
|
| 831 |
+
# every request (real graph read + an admission/quarantine decision per raw
|
| 832 |
+
# node) advertised itself as having nothing at all, purely because no trained
|
| 833 |
+
# reranker model manifest exists yet. That understates what is served and is
|
| 834 |
+
# as dishonest as overstating it. The ladder below reports exactly what is
|
| 835 |
+
# true THIS request and nothing more:
|
| 836 |
+
# MEASURED - dataset + model + evaluation all READY (a real trained and
|
| 837 |
+
# evaluated reranker; a performance claim is then defensible).
|
| 838 |
+
# MODELED - the inventory was read live THIS request (real graph bytes,
|
| 839 |
+
# real decisions) but the model/evaluation pipeline is BLOCKED,
|
| 840 |
+
# so structure and admission decisions are served with NO model
|
| 841 |
+
# performance claim.
|
| 842 |
+
# UNAVAILABLE - the graph itself could not be read; nothing real to show.
|
| 843 |
+
# `status` stays BLOCKED until the pipeline is genuinely operational, so no
|
| 844 |
+
# reader can mistake MODELED for an operational model.
|
| 845 |
+
inventory_measured = inventory["label"] == MEASURED
|
| 846 |
+
blocking_reasons = sorted({
|
| 847 |
+
*(dataset["dataset_readiness"]["reasons"] or []),
|
| 848 |
+
*[f"MODEL:{r}" for r in (dataset["model_readiness"].get("reasons") or [])],
|
| 849 |
+
*[f"EVALUATION:{r}" for r in (dataset["evaluation_readiness"].get("reasons") or [])],
|
| 850 |
+
})
|
| 851 |
+
if operational:
|
| 852 |
+
label = MEASURED
|
| 853 |
+
label_basis = ("dataset, model and evaluation readiness are all READY — measured "
|
| 854 |
+
"from the verified manifests read THIS request.")
|
| 855 |
+
elif inventory_measured:
|
| 856 |
+
label = MODELED
|
| 857 |
+
label_basis = ("evidence inventory read live THIS request (graph bytes hashed, one "
|
| 858 |
+
"admission/quarantine decision per raw node), but the reranker "
|
| 859 |
+
"model/evaluation pipeline is BLOCKED, so NO model-performance "
|
| 860 |
+
"claim is made. Blocking: " + (", ".join(blocking_reasons) or "none"))
|
| 861 |
+
else:
|
| 862 |
+
label = UNAVAILABLE
|
| 863 |
+
label_basis = ("the Brain graph could not be read THIS request — nothing measured "
|
| 864 |
+
"and nothing modeled; no state fabricated.")
|
| 865 |
return {
|
| 866 |
"ok": True, "schema_version": SERVICE_SCHEMA,
|
| 867 |
# The inventory can be measured while the train/eval/model pipeline is still
|
| 868 |
# unavailable. Keep those truths separate so the estate rollup cannot turn
|
| 869 |
# a measured node count into an operational model claim.
|
| 870 |
"status": READY if operational else BLOCKED,
|
| 871 |
+
"label": label,
|
| 872 |
+
"label_basis": label_basis,
|
| 873 |
+
"blocking_reasons": blocking_reasons,
|
| 874 |
+
"operational": operational,
|
| 875 |
"inventory_label": inventory["label"],
|
| 876 |
"inventory": inventory["inventory"],
|
| 877 |
"inventory_sha256": inventory["inventory_sha256"],
|
szl_sovereign_panel.py
CHANGED
|
@@ -70,6 +70,31 @@ DOCTRINE_SELFTEST_PROMPT = "State your doctrine in one line"
|
|
| 70 |
# merged yet we fall back to the registry helper / a direct probe and say so).
|
| 71 |
DEV1_HEALTH_ROUTE = "/api/a11oy/v1/llm/sovereign/health"
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
def _now_iso() -> str:
|
| 75 |
return datetime.datetime.now(datetime.timezone.utc).isoformat()
|
|
@@ -103,6 +128,8 @@ def _probe_reachability() -> dict[str, Any]:
|
|
| 103 |
"via": None,
|
| 104 |
"dependency": None,
|
| 105 |
"note": "",
|
|
|
|
|
|
|
| 106 |
}
|
| 107 |
# Preferred path: Dev-1's registry helper. It is the SAME code that backs the
|
| 108 |
# routed GET /api/a11oy/v1/llm/sovereign/health, so this panel and that endpoint
|
|
@@ -118,6 +145,8 @@ def _probe_reachability() -> dict[str, Any]:
|
|
| 118 |
out["via"] = "szl_llm_registry.sovereign_probe (backs %s)" % DEV1_HEALTH_ROUTE
|
| 119 |
out["dependency"] = "resolved: szl_llm_registry present in this runtime"
|
| 120 |
out["note"] = str(probe.get("note") or "")
|
|
|
|
|
|
|
| 121 |
return out
|
| 122 |
except Exception as exc: # noqa: BLE001 — Dev-1 module absent → honest direct fallback
|
| 123 |
out["dependency"] = (
|
|
@@ -135,6 +164,8 @@ def _probe_reachability() -> dict[str, Any]:
|
|
| 135 |
out["base_url"] = base or None
|
| 136 |
out["env_present"] = bool(base)
|
| 137 |
out["via"] = "direct SZL_LOCAL_LLM_URL probe (Dev-1 helper absent)"
|
|
|
|
|
|
|
| 138 |
if not base:
|
| 139 |
out["note"] = ("SZL_LOCAL_LLM_URL not set — sovereign node is an HONEST STUB; "
|
| 140 |
"reachability UNAVAILABLE (never fabricated).")
|
|
@@ -161,6 +192,7 @@ def _probe_reachability() -> dict[str, Any]:
|
|
| 161 |
out["reachable"] = True
|
| 162 |
out["models"] = names
|
| 163 |
out["api_style"] = kind
|
|
|
|
| 164 |
out["note"] = "node live (%s) — model list real THIS request (direct probe)." % kind
|
| 165 |
return out
|
| 166 |
out["note"] = ("SZL_LOCAL_LLM_URL set but node did not respond live this request "
|
|
@@ -349,6 +381,17 @@ def build_payload() -> dict[str, Any]:
|
|
| 349 |
# A served-model label for the healthz rollup + the panel header (honest).
|
| 350 |
live_models = reach.get("models") or []
|
| 351 |
model_label = (live_models[0] if (reachable and live_models) else SOVEREIGN_MODEL_TAG)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
|
| 353 |
snapshot: dict[str, Any] = {
|
| 354 |
"ok": True,
|
|
@@ -370,11 +413,16 @@ def build_payload() -> dict[str, Any]:
|
|
| 370 |
"base_url": reach.get("base_url"),
|
| 371 |
"env_present": reach.get("env_present"),
|
| 372 |
"api_style": reach.get("api_style"),
|
|
|
|
|
|
|
|
|
|
| 373 |
"models_live": live_models,
|
| 374 |
"via": reach.get("via"),
|
| 375 |
"dependency": reach.get("dependency"),
|
| 376 |
"note": reach.get("note"),
|
| 377 |
},
|
|
|
|
|
|
|
| 378 |
"doctrine_selftest": selftest,
|
| 379 |
"stage": stage,
|
| 380 |
"dev1_health_route": DEV1_HEALTH_ROUTE,
|
|
@@ -405,9 +453,12 @@ def rollup_signal() -> dict[str, Any]:
|
|
| 405 |
"reachable": reachable,
|
| 406 |
"model": (live_models[0] if (reachable and live_models) else SOVEREIGN_MODEL_TAG),
|
| 407 |
"label": LIVE_SOVEREIGN if reachable else UNAVAILABLE,
|
|
|
|
|
|
|
| 408 |
}
|
| 409 |
except Exception as exc: # noqa: BLE001 — never crash the health path; honest UNAVAILABLE
|
| 410 |
return {"reachable": False, "model": SOVEREIGN_MODEL_TAG, "label": UNAVAILABLE,
|
|
|
|
| 411 |
"error": f"{type(exc).__name__}: {exc}"}
|
| 412 |
|
| 413 |
|
|
@@ -420,6 +471,7 @@ def handle() -> dict[str, Any]:
|
|
| 420 |
"ok": False,
|
| 421 |
"endpoint": "frontier/sovereign",
|
| 422 |
"label": UNAVAILABLE,
|
|
|
|
| 423 |
"error": str(exc),
|
| 424 |
"doctrine": "v11: sovereign surface unavailable; no fabricated status/answer emitted.",
|
| 425 |
"timestamp_utc": _now_iso(),
|
|
|
|
| 70 |
# merged yet we fall back to the registry helper / a direct probe and say so).
|
| 71 |
DEV1_HEALTH_ROUTE = "/api/a11oy/v1/llm/sovereign/health"
|
| 72 |
|
| 73 |
+
# Machine-readable reasons for an UNAVAILABLE sovereign. These distinguish the two
|
| 74 |
+
# honestly-different causes so an operator (and the surface HUD) can tell an
|
| 75 |
+
# UNCONFIGURED estate apart from a CONFIGURED-but-down node. Neither is a code bug
|
| 76 |
+
# and neither is ever upgraded to a live label.
|
| 77 |
+
REASON_ENV_UNSET = "SZL_LOCAL_LLM_URL_UNSET" # no Tower targeted at all
|
| 78 |
+
REASON_NODE_UNREACHABLE = "NODE_UNREACHABLE_THIS_REQUEST" # env set, node silent
|
| 79 |
+
REASON_NONE = None # reachable — no reason needed
|
| 80 |
+
|
| 81 |
+
# How the probed base URL was chosen (env vs the localhost fallback default).
|
| 82 |
+
BASE_FROM_ENV = "env:SZL_LOCAL_LLM_URL"
|
| 83 |
+
BASE_FROM_DEFAULT = "default:localhost (SZL_LOCAL_LLM_URL unset)"
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def unavailable_reason(reachable: bool, env_present: bool) -> str | None:
|
| 87 |
+
"""Honest, machine-readable reason code for a non-live sovereign.
|
| 88 |
+
|
| 89 |
+
reachable=True -> None (nothing to explain; the node answered THIS request).
|
| 90 |
+
env unset -> REASON_ENV_UNSET (env gap: the estate never named a Tower;
|
| 91 |
+
the probe fell back to the localhost default and was refused).
|
| 92 |
+
env set, silent -> REASON_NODE_UNREACHABLE (Tower down / not routable from here).
|
| 93 |
+
"""
|
| 94 |
+
if reachable:
|
| 95 |
+
return REASON_NONE
|
| 96 |
+
return REASON_ENV_UNSET if not env_present else REASON_NODE_UNREACHABLE
|
| 97 |
+
|
| 98 |
|
| 99 |
def _now_iso() -> str:
|
| 100 |
return datetime.datetime.now(datetime.timezone.utc).isoformat()
|
|
|
|
| 128 |
"via": None,
|
| 129 |
"dependency": None,
|
| 130 |
"note": "",
|
| 131 |
+
"base_url_source": None,
|
| 132 |
+
"unavailable_reason": REASON_ENV_UNSET,
|
| 133 |
}
|
| 134 |
# Preferred path: Dev-1's registry helper. It is the SAME code that backs the
|
| 135 |
# routed GET /api/a11oy/v1/llm/sovereign/health, so this panel and that endpoint
|
|
|
|
| 145 |
out["via"] = "szl_llm_registry.sovereign_probe (backs %s)" % DEV1_HEALTH_ROUTE
|
| 146 |
out["dependency"] = "resolved: szl_llm_registry present in this runtime"
|
| 147 |
out["note"] = str(probe.get("note") or "")
|
| 148 |
+
out["base_url_source"] = BASE_FROM_ENV if out["env_present"] else BASE_FROM_DEFAULT
|
| 149 |
+
out["unavailable_reason"] = unavailable_reason(out["reachable"], out["env_present"])
|
| 150 |
return out
|
| 151 |
except Exception as exc: # noqa: BLE001 — Dev-1 module absent → honest direct fallback
|
| 152 |
out["dependency"] = (
|
|
|
|
| 164 |
out["base_url"] = base or None
|
| 165 |
out["env_present"] = bool(base)
|
| 166 |
out["via"] = "direct SZL_LOCAL_LLM_URL probe (Dev-1 helper absent)"
|
| 167 |
+
out["base_url_source"] = BASE_FROM_ENV if base else BASE_FROM_DEFAULT
|
| 168 |
+
out["unavailable_reason"] = unavailable_reason(False, bool(base))
|
| 169 |
if not base:
|
| 170 |
out["note"] = ("SZL_LOCAL_LLM_URL not set — sovereign node is an HONEST STUB; "
|
| 171 |
"reachability UNAVAILABLE (never fabricated).")
|
|
|
|
| 192 |
out["reachable"] = True
|
| 193 |
out["models"] = names
|
| 194 |
out["api_style"] = kind
|
| 195 |
+
out["unavailable_reason"] = REASON_NONE
|
| 196 |
out["note"] = "node live (%s) — model list real THIS request (direct probe)." % kind
|
| 197 |
return out
|
| 198 |
out["note"] = ("SZL_LOCAL_LLM_URL set but node did not respond live this request "
|
|
|
|
| 381 |
# A served-model label for the healthz rollup + the panel header (honest).
|
| 382 |
live_models = reach.get("models") or []
|
| 383 |
model_label = (live_models[0] if (reachable and live_models) else SOVEREIGN_MODEL_TAG)
|
| 384 |
+
reason = reach.get("unavailable_reason") if not reachable else REASON_NONE
|
| 385 |
+
reason_text = {
|
| 386 |
+
REASON_ENV_UNSET: ("SZL_LOCAL_LLM_URL is not set in this runtime, so no Tower was "
|
| 387 |
+
"named; the probe fell back to the localhost default and was "
|
| 388 |
+
"refused. This is an ENVIRONMENT GAP, not a failed node and not "
|
| 389 |
+
"a code fault — set SZL_LOCAL_LLM_URL to a reachable sovereign "
|
| 390 |
+
"node and this surface goes live on the next request."),
|
| 391 |
+
REASON_NODE_UNREACHABLE: ("SZL_LOCAL_LLM_URL is set but the node did not answer this "
|
| 392 |
+
"request (Tower down, or not routable from this runtime). "
|
| 393 |
+
"Honest UNAVAILABLE — no status or answer is fabricated."),
|
| 394 |
+
}.get(reason)
|
| 395 |
|
| 396 |
snapshot: dict[str, Any] = {
|
| 397 |
"ok": True,
|
|
|
|
| 413 |
"base_url": reach.get("base_url"),
|
| 414 |
"env_present": reach.get("env_present"),
|
| 415 |
"api_style": reach.get("api_style"),
|
| 416 |
+
"base_url_source": reach.get("base_url_source"),
|
| 417 |
+
"unavailable_reason": reason,
|
| 418 |
+
"unavailable_reason_text": reason_text,
|
| 419 |
"models_live": live_models,
|
| 420 |
"via": reach.get("via"),
|
| 421 |
"dependency": reach.get("dependency"),
|
| 422 |
"note": reach.get("note"),
|
| 423 |
},
|
| 424 |
+
"unavailable_reason": reason,
|
| 425 |
+
"unavailable_reason_text": reason_text,
|
| 426 |
"doctrine_selftest": selftest,
|
| 427 |
"stage": stage,
|
| 428 |
"dev1_health_route": DEV1_HEALTH_ROUTE,
|
|
|
|
| 453 |
"reachable": reachable,
|
| 454 |
"model": (live_models[0] if (reachable and live_models) else SOVEREIGN_MODEL_TAG),
|
| 455 |
"label": LIVE_SOVEREIGN if reachable else UNAVAILABLE,
|
| 456 |
+
"unavailable_reason": (reach.get("unavailable_reason")
|
| 457 |
+
if not reachable else REASON_NONE),
|
| 458 |
}
|
| 459 |
except Exception as exc: # noqa: BLE001 — never crash the health path; honest UNAVAILABLE
|
| 460 |
return {"reachable": False, "model": SOVEREIGN_MODEL_TAG, "label": UNAVAILABLE,
|
| 461 |
+
"unavailable_reason": REASON_NODE_UNREACHABLE,
|
| 462 |
"error": f"{type(exc).__name__}: {exc}"}
|
| 463 |
|
| 464 |
|
|
|
|
| 471 |
"ok": False,
|
| 472 |
"endpoint": "frontier/sovereign",
|
| 473 |
"label": UNAVAILABLE,
|
| 474 |
+
"unavailable_reason": REASON_NODE_UNREACHABLE,
|
| 475 |
"error": str(exc),
|
| 476 |
"doctrine": "v11: sovereign surface unavailable; no fabricated status/answer emitted.",
|
| 477 |
"timestamp_utc": _now_iso(),
|