Spaces:
Running
Running
File size: 12,557 Bytes
422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 422532a f5bf7f1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | /* =============================================================================
* live-body.js β SZL Living Anatomy Β· BODY v1 ENGINE (the living face)
* =============================================================================
* The Sovereign Org rendered as ONE living governed organism. This module is the
* HONEST DATA SPINE for live-body.html's Three.js scene. It reads the SAME live
* a11oy endpoints the unified console reads and exposes them as honest records.
*
* CRITICAL DISCIPLINE (binding β honest by construction, never a screensaver):
* - Every pulse travelling a vessel corresponds to a REAL receipt on the chain
* (/api/a11oy/v1/ledger). We never synthesize a receipt.
* - Every organ glows LIVE only on a real 2xx+JSON probe; otherwise it dims to an
* honest UNREACHABLE state. We never fabricate a green light.
* - sovereign:true is shown ONLY when /code/healthz reports the literal true.
* - Ξ is advisory and its uniqueness is Conjecture 1 β pulled live from
* /v1/lambda + /v1/honest, never hardcoded as proven.
* - Verticals (insurance/defense/finance/realestate), SLSA skeletal integrity,
* and drift have NO live endpoint on this Space today, so they render in an
* explicit ROADMAP / N-A state β limbs do NOT fake-pulse and the skeleton does
* NOT claim a verified SLSA level. Honest absence over decorative motion.
* - Read-only. No key is sent. open-weight only.
*
* No build step, no framework, no CDN β a plain ES module that runs as a static
* SDK page at the .static.hf.space URL, exactly like index.html.
* ============================================================================ */
"use strict";
/* ---- the single live host the console reads (verified live this session) --- */
const HOST = "https://szlholdings-a11oy.hf.space";
/* Real, verified endpoints (curl-checked 2026-06-30):
* /api/a11oy/v1/ledger -> {count, receipts:[{seq,action,receipt_id}]} (THE chain)
* /api/a11oy/v1/lambda -> {trust_axes,axes[],lambda,lambda_floor,pass,uniqueness}
* /api/a11oy/code/healthz -> {sovereign,backend,mode,doctrine_state,...}
* /api/a11oy/v1/honest -> {doctrine_lock:{lambda,locked_formula_ids,...}}
* /api/a11oy/readyz -> {status,operator:{operator_running,...}}
* /api/a11oy/v1/govern/health-> {engines_live,engines_total,mesh[]} */
const EP = {
ledger: HOST + "/api/a11oy/v1/ledger",
lambda: HOST + "/api/a11oy/v1/lambda",
healthz: HOST + "/api/a11oy/code/healthz",
honest: HOST + "/api/a11oy/v1/honest",
readyz: HOST + "/api/a11oy/readyz",
govern: HOST + "/api/a11oy/v1/govern/health",
};
/* ---- KANCHAY palette (canonical brand Β· purple BANNED) -------------------- */
const KANCHAY = {
void: "#080c14",
proof: "#3af4c8", // teal β proven / live
lattice: "#5b8dee", // blue β structure / vessels
gold: "#d7b96b", // gold β Ξ / heartbeat accent
warn: "#e0795b", // ember β denied / down
dim: "#3a4456", // honest unreachable / dormant
text: "#e9eef7",
};
/* ---- status vocabulary ---------------------------------------------------- */
const STATUS = {
LIVE: "live", // endpoint answered 2xx with usable JSON
UNREACHABLE: "unreachable", // network / non-2xx / not-JSON β honest unknown
PENDING: "pending", // not yet polled
};
/* ---- the 4 console organs, each a REAL probe ------------------------------ *
* These are the organs the unified console shows (Reasoning/Policy/Operator/
* Receipts). Each maps to a real endpoint that proves it is alive; LIVE only on
* a real 2xx+JSON answer, otherwise an honest UNREACHABLE dim. `pos` is a normalized
* body-space anchor [x,y,z] the scene uses to place the organ. */
const ORGANS = [
{
id: "reasoning", name: "REASONING", glyph: "βΈ", color: KANCHAY.proof,
pos: [0, 1.15, 0],
probe: "lambda",
role: "scores Ξ (13-axis) + recommends the decision under uncertainty",
actions: ["lambda.score", "decision.recommend"],
summarize: (j) => {
if (typeof j.lambda === "number")
return `Ξ ${j.lambda.toFixed(5)} ${j.pass ? "β₯" : "<"} floor ${j.lambda_floor} Β· ${j.trust_axes || (j.axes||[]).length}-axis`;
return "reasoning responding";
},
},
{
id: "policy", name: "POLICY", glyph: "β¨", color: KANCHAY.gold,
pos: [-1.15, 0.15, 0.1],
probe: "honest",
role: "the deny-by-default gate (F12) β rejects unsafe / overclaiming work",
actions: ["gate.evaluate"],
summarize: (j) => {
const lk = j.doctrine_lock || {};
const ids = lk.locked_formula_ids || [];
const f12 = ids.includes("F12");
return `${lk.locked_formula_count ?? ids.length} locked Β· F12 gate ${f12 ? "armed" : "β"}`;
},
},
{
id: "operator", name: "OPERATOR", glyph: "β", color: KANCHAY.lattice,
pos: [1.15, 0.15, 0.1],
probe: "readyz",
role: "approves + executes admitted work; the hands of the organism",
actions: ["operator.approve"],
summarize: (j) => {
const op = j.operator || {};
if (op.operator_running === true) return `operator running Β· ${j.status || "ready"}`;
if (j.status) return `status: ${j.status}`;
return "operator responding";
},
},
{
id: "receipts", name: "RECEIPTS", glyph: "β€", color: KANCHAY.warn,
pos: [0, -1.15, 0],
probe: "ledger",
role: "signs + replays a verifiable receipt for every action (the heartbeat)",
actions: ["receipt.sign", "replay.verify"],
summarize: (j) => {
const rs = j.receipts || j.items || (Array.isArray(j) ? j : null);
const n = Array.isArray(rs) ? rs.length : (typeof j.count === "number" ? j.count : null);
return n != null ? `${n} receipts on the chain` : "receipt bus reachable";
},
},
];
/* Which organ a receipt action originates from (so a pulse leaves the right
* organ and travels to RECEIPTS/heart). Unknown actions default to receipts. */
const ACTION_SOURCE = {
"gate.evaluate": "policy",
"lambda.score": "reasoning",
"decision.recommend": "reasoning",
"operator.approve": "operator",
"receipt.sign": "receipts",
"replay.verify": "receipts",
};
function organForAction(action) {
if (!action) return "receipts";
const a = String(action).toLowerCase();
if (ACTION_SOURCE[a]) return ACTION_SOURCE[a];
// honest heuristic for verbs we haven't enumerated
if (a.startsWith("gate")) return "policy";
if (a.startsWith("lambda") || a.includes("decision") || a.includes("reason")) return "reasoning";
if (a.includes("operator") || a.includes("approve") || a.includes("execute")) return "operator";
return "receipts";
}
/* An action is a DENIAL (rejected pulse) only when it honestly says so. */
function isDenied(action) {
const a = String(action || "").toLowerCase();
return a.includes("deny") || a.includes("denied") || a.includes("reject") || a.includes("block");
}
/* The 4 verticals = limbs. NO live throughput endpoint exists on this Space, so
* they render in an honest ROADMAP state and only pulse if a real receipt with a
* "<vertical>|<action>" verb appears on the chain. Never fake-pulsed. */
const VERTICALS = [
{ id: "insurance", name: "INSURANCE", pos: [-1.7, -0.7, 0.0], color: KANCHAY.proof },
{ id: "defense", name: "DEFENSE", pos: [ 1.7, -0.7, 0.0], color: KANCHAY.lattice },
{ id: "finance", name: "FINANCE", pos: [-1.7, 0.9, 0.0], color: KANCHAY.gold },
{ id: "realestate", name: "REALESTATE", pos: [ 1.7, 0.9, 0.0], color: KANCHAY.warn },
];
/* ---- one honest GET (never throws; no creds, no custom headers => simple CORS) */
async function getJSON(url, timeoutMs = 9000) {
const ctl = new AbortController();
const t = setTimeout(() => ctl.abort(), timeoutMs);
try {
const res = await fetch(url, {
method: "GET", mode: "cors", credentials: "omit",
signal: ctl.signal, cache: "no-store",
});
clearTimeout(t);
if (!res.ok) return { ok: false, why: `HTTP ${res.status}` };
const ct = res.headers.get("content-type") || "";
if (!ct.includes("json")) return { ok: false, why: "no JSON (route unmatched?)" };
return { ok: true, json: await res.json() };
} catch (e) {
clearTimeout(t);
return { ok: false, why: (e && e.name === "AbortError") ? "timeout" : "network/CORS" };
}
}
/* probe one organ honestly -> {status, detail, raw} */
async function probeOrgan(organ, timeoutMs = 9000) {
const r = await getJSON(EP[organ.probe], timeoutMs);
if (!r.ok) return { status: STATUS.UNREACHABLE, detail: r.why, raw: null };
let detail;
try { detail = organ.summarize(r.json); }
catch { detail = "responding (shape unrecognized)"; }
return { status: STATUS.LIVE, detail, raw: r.json };
}
/* fetch the REAL receipt chain. Returns normalized receipts (or honest empty). */
async function fetchLedger(timeoutMs = 9000) {
const r = await getJSON(EP.ledger, timeoutMs);
if (!r.ok) return { reachable: false, why: r.why, count: 0, receipts: [] };
const j = r.json;
const raw = j.receipts || j.items || (Array.isArray(j) ? j : []);
const receipts = (Array.isArray(raw) ? raw : []).map((x, i) => {
const action = x.action || x.verb || x.kind || "receipt";
return {
seq: typeof x.seq === "number" ? x.seq : i,
action,
id: x.receipt_id || x.id || x.hash || String(i),
organ: organForAction(action),
denied: isDenied(action),
};
});
return { reachable: true, count: j.count ?? receipts.length, receipts };
}
/* fetch Ξ posture (heartbeat driver). Honest: uniqueness stays Conjecture 1. */
async function fetchLambda(timeoutMs = 9000) {
const r = await getJSON(EP.lambda, timeoutMs);
if (!r.ok) return { reachable: false, why: r.why };
const j = r.json;
return {
reachable: true,
lambda: typeof j.lambda === "number" ? j.lambda : null,
floor: typeof j.lambda_floor === "number" ? j.lambda_floor : 0.90,
pass: j.pass === true,
axes: Array.isArray(j.axes) ? j.axes : [],
aggregate: j.aggregate || "",
uniqueness: j.uniqueness || "Conjecture 1",
raw: j,
};
}
/* fetch the GPU-mind posture (sovereign strict; default FALSE β never invent true) */
async function fetchMind(timeoutMs = 9000) {
const r = await getJSON(EP.healthz, timeoutMs);
if (!r.ok) return { reachable: false, sovereign: false, why: r.why };
const j = r.json;
return {
reachable: true,
sovereign: j.sovereign === true,
backend: j.backend || j.inference || "unknown",
mode: j.mode || "unknown",
doctrine: j.doctrine_state ? `${j.doctrine || ""} ${j.doctrine_state}`.trim() : (j.doctrine || ""),
raw: j,
};
}
/* fetch doctrine / Ξ lock for the honesty strip. */
async function fetchDoctrine(timeoutMs = 9000) {
const r = await getJSON(EP.honest, timeoutMs);
if (!r.ok) return { reachable: false };
const lk = (r.json && r.json.doctrine_lock) || {};
return {
reachable: true,
lambda: lk.lambda || "Conjecture 1",
commit: lk.commit || "",
lockedCount: lk.locked_formula_count ?? 8,
lockedIds: lk.locked_formula_ids || [],
declarations: lk.declarations, axioms: lk.axioms, sorries: lk.sorries,
state: lk.state || "",
};
}
/* fetch mesh/engine health β the only REAL drift-ish signal available today:
* engines_total - engines_live antibodies. honest immune intensity in [0,1]. */
async function fetchImmune(timeoutMs = 9000) {
const r = await getJSON(EP.govern, timeoutMs);
if (!r.ok) return { reachable: false, intensity: 0, detail: r.why };
const j = r.json;
const total = typeof j.engines_total === "number" ? j.engines_total : 0;
const live = typeof j.engines_live === "number" ? j.engines_live : total;
const down = Math.max(0, total - live);
return {
reachable: true,
intensity: total > 0 ? down / total : 0, // real fraction of mesh down
down, live, total,
detail: down > 0 ? `${down}/${total} mesh engines down β antibodies active` : `mesh ${live}/${total} healthy`,
};
}
/* ---- the engine surface --------------------------------------------------- */
const LiveBody = {
HOST, EP, KANCHAY, STATUS, ORGANS, VERTICALS,
organForAction, isDenied,
probeOrgan, fetchLedger, fetchLambda, fetchMind, fetchDoctrine, fetchImmune,
};
if (typeof window !== "undefined") window.LiveBody = LiveBody;
export default LiveBody;
export {
HOST, EP, KANCHAY, STATUS, ORGANS, VERTICALS,
organForAction, isDenied,
probeOrgan, fetchLedger, fetchLambda, fetchMind, fetchDoctrine, fetchImmune,
};
|