// SPDX-License-Identifier: Apache-2.0 // © 2026 Lutar, Stephen P. Jr. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11 // // surfaces/braincommand.js — BRAIN COMMAND (Wave O, Dev 5). The founder's // "Brain powering the ecosystem" dashboard: one honest command view of the live // ecosystem PULSE — what the Brain has HARVESTED (knowledge), what it has HARNESSED // (energy), how many organs/surfaces it lights, the Λ advisory — plus a subscribe/ // budget view ("what is the Brain feeding this surface right now?") and the signed // receipt of the snapshot. // // SCENE: a central BRAIN CORE glows by the harnessed-energy label (teal when real // MEASURED joules are in the ledger, amber when MODELED, grey when UNAVAILABLE) and // PULSES. A ring of ORGAN nodes = the surfaces the Brain lights (count from the live // pulse). A KNOWLEDGE HALO scales with the harvested distinct-artifact count. A // blue-violet RECEIPT SEAL ring brightens when the snapshot carries a REAL DSSE // signature. HUD shows every number with its honest label and a plain-language mode. // // HONESTY (Doctrine v11, verbatim — never upgraded): // * Reads GET /api/a11oy/v1/brain/command (this Dev's backend), which PREFERS // Dev-1's central hub pulse (/brain/pulse) and falls back to an HONEST locally- // composed pulse (pulse_ok:false) when #brain-hub is not merged — never a // fabricated joule. When the backend is offline the HUD reads NO-LIVE-DATA. // * Honest labels only: LIVE / MEASURED / MODELED / UNAVAILABLE / CONJECTURE. // * Λ = Conjecture 1 — advisory, GREY, NEVER green/theorem/proven. Trust ≤ 0.97. // * locked-proven = EXACTLY 8; the Brain harvest adds nothing to it. // * palette: lattice-blue 0x5b8dee · violet-blue 0x8a6bff · proof-teal 0x3af4c8 · // amber 0xe8c074 · greys. PURPLE BANNED. 0 runtime CDN (three via ctx.THREE). // Surface export shape mirrors sovereign.js exactly: // export default { id, title, endpoints, mount, unmount } import { createShowcase } from "./_showcase.js"; const ID = "braincommand"; const TITLE = "Brain Command — powering the ecosystem"; const EP_CMD = "/api/a11oy/v1/brain/command"; const EP_SUBS = "/api/a11oy/v1/brain/command/subscribe/"; // + surface_id const EP_PULSE = "/api/a11oy/v1/brain/pulse"; // Dev-1 (read via backend when merged) // data-viz hues — purple BANNED const C_MEASURED = 0x3af4c8; // proof-teal (real MEASURED joules harnessed) const C_MODELED = 0xe8c074; // amber (MODELED energy — dry-run projection) const C_DOWN = 0x5a6570; // grey (UNAVAILABLE) const C_ORGAN = 0x5b8dee; // lattice-blue (lit organ/surface) const C_KNOW = 0x8fdcff; // light blue (knowledge halo) const C_SEAL = 0x8a6bff; // blue-violet (receipt seal — advisory, NOT purple/green) const CORE_R = 1.0, ORGAN_RING_R = 3.4, KNOW_R = 1.7, SEAL_R = 2.35; const MAX_ORGAN_MESHES = 48; // cap rendered organ dots (perf; count shown honestly regardless) let _stage=null,_THREE=null,_ctx=null,_group=null,_overlay=null; let _frameReg=false,_polls=[],_badge=null,_plain=false,_t0=0,_show=null; let _core=null,_coreGlow=null,_know=null,_seal=null,_organs=[]; const S = { label:"UNAVAILABLE", state:"init", source:null, pulseOk:false, energyLabel:"UNAVAILABLE", joules:null, kwh:null, tokens:null, jobs:null, knowLabel:"UNAVAILABLE", distinct:null, nodes:null, links:null, surfaces:null, surfacesLabel:"UNAVAILABLE", lambda:"Conjecture 1", signMode:null, signed:null, subSurface:"brain", subState:null, }; function _clamp01(x){ return x<0?0:(x>1?1:x); } function mount(ctx){ _ctx=ctx; _stage=ctx.stage; _THREE=ctx.THREE; _group=new _THREE.Group(); _stage.scene.add(_group); try{ _stage.camera.position.set(0,4.5,12); }catch(_){} try{ if(_stage.controls&&_stage.controls.target){ _stage.controls.target.set(0,0.3,0); _stage.controls.update(); } }catch(_){} try{ _stage.setBloom&&_stage.setBloom(true); }catch(_){} _t0=(typeof performance!=="undefined"?performance.now():Date.now()); _badge=ctx.live.createBadge(); _buildOverlay(ctx); _buildScaffold(); // GET the command rollup — the CORE poll. Server-side it prefers Dev-1's hub pulse // and falls back honestly (pulse_ok:false). Degrades to NO-LIVE-DATA when offline. _polls.push(ctx.live.poll(EP_CMD, 10000, _onCmd, { badge:_badge, onState:(m)=>{ S.state=m.state; _paintOverlay(); }, })); if(!_frameReg&&_stage.onFrame){ _stage.onFrame(_animate); _frameReg=true; } _paintOverlay(); return { id:ID, started:true }; } function _num(x){ return (typeof x==="number"&&isFinite(x))?x:null; } function _up(s){ return String(s==null?"UNAVAILABLE":s).toUpperCase(); } function _onCmd(j){ if(!j){ S.state="error"; _paintOverlay(); return; } S.source=j.source||null; S.pulseOk=(j.pulse_ok===true); const e=j.energy||{}; S.energyLabel=_up(e.label); S.joules=_num(e.joules_measured_billable); S.kwh=_num(e.kwh_total); S.tokens=_num(e.tokens_total); S.jobs=_num(e.jobs); const k=j.knowledge||{}; S.knowLabel=_up(k.label); S.distinct=_num(k.distinct_artifacts); S.nodes=_num(k.node_count); S.links=_num(k.link_count); const s=j.surfaces_lit||{}; S.surfaces=_num(s.count); S.surfacesLabel=_up(s.label); const lam=j.lambda||{}; S.lambda=lam.value||"Conjecture 1"; const r=j.receipt||{}; S.signed=(r.signed===true); S.signMode=S.signed?"REAL DSSE":(r.signatures&&r.signatures.length===0?"UNSIGNED-LOCAL":null); S.label=S.energyLabel; _rebuildOrgans(); _paintScene(); _paintOverlay(); } function _buildScaffold(){ // Brain core sphere. const cg=new _THREE.SphereGeometry(CORE_R,40,40); const cm=new _THREE.MeshStandardMaterial({ color:C_DOWN,emissive:C_DOWN,emissiveIntensity:0.25,metalness:0.15,roughness:0.4 }); _core=new _THREE.Mesh(cg,cm); _core.userData={role:"brain-core"}; _group.add(_core); const gg=new _THREE.SphereGeometry(CORE_R*1.4,24,24); const gm=new _THREE.MeshBasicMaterial({ color:C_DOWN,transparent:true,opacity:0.08,blending:_THREE.AdditiveBlending,depthWrite:false }); _coreGlow=new _THREE.Mesh(gg,gm); _group.add(_coreGlow); // Knowledge halo (light-blue wireframe torus; scales with distinct-artifact count). const kg=new _THREE.TorusGeometry(KNOW_R,0.03,16,90); const km=new _THREE.MeshBasicMaterial({ color:C_KNOW,transparent:true,opacity:0.5,wireframe:true }); _know=new _THREE.Mesh(kg,km); _know.rotation.x=Math.PI*0.5; _know.userData={role:"knowledge-halo"}; _group.add(_know); // Receipt seal ring (blue-violet, advisory — brightens when the snapshot is signed). const sg=new _THREE.TorusGeometry(SEAL_R,0.045,18,120); const sm=new _THREE.MeshStandardMaterial({ color:C_SEAL,emissive:C_SEAL,emissiveIntensity:0.4,metalness:0.2,roughness:0.35,transparent:true,opacity:0.85 }); _seal=new _THREE.Mesh(sg,sm); _seal.rotation.x=Math.PI/2; _seal.userData={role:"receipt-seal"}; _group.add(_seal); } function _rebuildOrgans(){ // Ring of organ dots = surfaces the Brain lights. Cap the rendered count for perf; // the HUD always shows the true count. Never fabricate organs when UNAVAILABLE. _organs.forEach((o)=>{ try{ _group.remove(o); if(o.geometry)o.geometry.dispose(); if(o.material)o.material.dispose(); }catch(_){} }); _organs=[]; const n=(S.surfaces!=null)?Math.max(0,Math.min(MAX_ORGAN_MESHES,S.surfaces)):0; for(let i=0;i{ if(o.material) o.material.opacity=oOpacity; }); } function _animate(){ if(!_group)return; const now=(typeof performance!=="undefined"?performance.now():Date.now()); const t=(now-_t0)/1000; const lit=(S.energyLabel==="MEASURED"||S.energyLabel==="LIVE"||S.energyLabel==="MODELED"); // Core pulses (the ecosystem heartbeat) — faster/brighter when energy is real. const rate=(S.energyLabel==="MEASURED")?2.0:(S.energyLabel==="MODELED"?1.3:0.8); if(_core&&_core.material){ _core.material.emissiveIntensity=(lit?0.45:0.16)+(lit?0.22:0.05)*Math.abs(Math.sin(t*rate)); } if(_coreGlow){ const s=1.0+(lit?0.07:0.02)*Math.sin(t*rate); _coreGlow.scale.setScalar(s); } if(_know) _know.rotation.z=t*0.12; if(_seal) _seal.rotation.z=-t*0.14; // Organs orbit the core; each pulses on a phase so it reads as a nervous system. const n=_organs.length; for(let i=0;iBrain powering the ecosystem — one honest command view of the live pulse: what the Brain has harvested (knowledge), harnessed (energy), and how many organs it lights. Reads Dev-1\'s central hub when merged; otherwise an honest local fallback (never a fabricated joule).'+ _row("Pulse source","bc-source")+_row("Pulse OK","bc-pulseok")+ '
'+ '
Energy harnessed
'+ _row("Label","bc-elabel")+_row("Joules (measured)","bc-joules")+_row("kWh","bc-kwh")+_row("Jobs · tokens","bc-jobs")+ '
'+ '
Knowledge harvested
'+ _row("Label","bc-klabel")+_row("Distinct artifacts","bc-distinct")+_row("Graph nodes · links","bc-nodes")+ '
'+ _row("Organs / surfaces lit","bc-surfaces")+_row("Λ advisory","bc-lambda")+_row("Signed receipt","bc-sign")+ '
'+ '
Subscribe — what is the Brain feeding a surface?
'+ '
'+ ''+ ''+ '
'+ ''+ '
'+ _leg(C_MEASURED,"MEASURED")+_leg(C_MODELED,"MODELED")+_leg(C_DOWN,"UNAVAILABLE")+ _leg(C_ORGAN,"organ lit")+_leg(C_KNOW,"knowledge")+_leg(C_SEAL,"receipt seal")+ '
'+ '
'+ ''+ ''+ '
'+ ''+ ''; _show.body.appendChild(_overlay); const pb=_overlay.querySelector("#bc-plain"); if(pb) pb.addEventListener("click",()=>{_plain=!_plain;_applyPlain();}); const ib=_overlay.querySelector("#bc-info"); if(ib) ib.addEventListener("click",()=>{ const box=_overlay.querySelector("#bc-infobox"); if(box) box.style.display=box.style.display==="none"?"block":"none"; if(box&&box.innerHTML==="") box.innerHTML=_infoHTML(); }); const go=_overlay.querySelector("#bc-subgo"); if(go) go.addEventListener("click",_askSubscribe); const inp=_overlay.querySelector("#bc-surfin"); if(inp) inp.addEventListener("keydown",(ev)=>{ if(ev.key==="Enter") _askSubscribe(); }); } function _askSubscribe(){ const inp=_overlay&&_overlay.querySelector("#bc-surfin"); const box=_overlay&&_overlay.querySelector("#bc-subbox"); if(!box) return; const sid=((inp&&inp.value)||"brain").trim().replace(/[^a-zA-Z0-9_.-]/g,"").slice(0,64)||"brain"; S.subSurface=sid; box.style.display="block"; box.textContent="Asking the Brain about “"+sid+"” …"; const url=EP_SUBS+encodeURIComponent(sid); const fetchFn=(_ctx&&_ctx.live&&_ctx.live.fetchJSON)?_ctx.live.fetchJSON:((u)=>fetch(u).then((r)=>r.json())); Promise.resolve(fetchFn(url)).then((j)=>{ if(!j){ box.textContent="UNAVAILABLE — backend offline (honest, nothing fabricated)."; return; } const a=j.allocation||{}; const en=a.energy||{}; const kn=a.knowledge||{}; const known=(a.known_surface===true)?"known surface":"not a registered surface id (still answered honestly)"; const js=(typeof en.joules_share_modeled==="number")?(en.joules_share_modeled+" J ("+_up(en.label)+")"):("— ("+_up(en.label)+")"); box.innerHTML=""+sid+" — "+known+"
"+ "Energy budget: "+js+"
"+ "Knowledge: corpus brain ("+_up(kn.label)+"), "+((kn.distinct_artifacts_available!=null)?kn.distinct_artifacts_available+" distinct artifacts available":"UNAVAILABLE")+"
"+ "Source: "+(j.source||"—")+" · receipt: "+((j.receipt&&j.receipt.signed)?"REAL DSSE ✓":"UNSIGNED-LOCAL")+"
"+ ''+((a.energy&&a.energy.note)?a.energy.note:"")+''; }).catch((e)=>{ box.textContent="UNAVAILABLE — "+(e&&e.message?e.message:"fetch failed")+" (honest)."; }); } function _row(k,id){ return '
'+k+'
'; } function _leg(hex,txt){ const c="#"+hex.toString(16).padStart(6,"0"); return ''+txt+''; } function _set(id,v){ const e=_overlay&&_overlay.querySelector("#"+id); if(e) e.textContent=v; } function _fmt(x){ return (x==null)?"—":(typeof x==="number"?x.toLocaleString():String(x)); } function _paintOverlay(){ if(!_overlay)return; const missing=(S.state==="missing"||S.state==="error"); if(_show) _show.setChip("label",S.label||"UNAVAILABLE"); if(missing){ ["bc-source","bc-pulseok","bc-elabel","bc-joules","bc-kwh","bc-jobs","bc-klabel","bc-distinct","bc-nodes","bc-surfaces","bc-lambda","bc-sign"].forEach((id)=>_set(id,"NO-LIVE-DATA")); if(_plain)_applyPlain(); return; } _set("bc-source",(S.source||"—")+(S.source==="local-fallback"?" (hub not merged)":"")); _set("bc-pulseok",S.pulseOk?"YES · hub live":"NO · local fallback (honest)"); _set("bc-elabel",S.energyLabel); _set("bc-joules",(S.joules!=null)?_fmt(S.joules)+" J":(S.energyLabel==="UNAVAILABLE"?"UNAVAILABLE (no telemetry)":"—")); _set("bc-kwh",(S.kwh!=null)?_fmt(S.kwh):"—"); _set("bc-jobs",_fmt(S.jobs)+" · "+_fmt(S.tokens)+" tok"); _set("bc-klabel",S.knowLabel); _set("bc-distinct",(S.distinct!=null)?_fmt(S.distinct):"UNAVAILABLE"); _set("bc-nodes",_fmt(S.nodes)+" · "+_fmt(S.links)); _set("bc-surfaces",(S.surfaces!=null)?_fmt(S.surfaces)+" ("+S.surfacesLabel+")":"UNAVAILABLE"); _set("bc-lambda","Λ = "+(S.lambda||"Conjecture 1")+" (advisory, never green)"); _set("bc-sign",(S.signMode||"—")+(S.signed?" ✓":(S.signMode==="UNSIGNED-LOCAL"?" (unsigned, honest)":""))); if(_plain)_applyPlain(); } function _applyPlain(){ const box=_overlay&&_overlay.querySelector("#bc-plainbox"); if(!box)return; box.style.display=_plain?"block":"none"; if(_plain) box.innerHTML="This tab is the founder\'s mission-control view of the Brain — the idea that one central Brain both learns for the whole company and powers it. It answers three plain questions honestly. How much has it learned? The light-blue halo grows with the number of distinct things harvested (papers, repos, formulas), and we show the honest count — not an inflated total. How much energy is it running on? The core glows teal when we have real measured energy from the ledger, amber when the number is only a projection, and grey when we have no reading — in which case we say UNAVAILABLE instead of inventing joules. How much does it light up? The orbiting dots are the surfaces the Brain powers, and the number is shown exactly. You can also type any surface name and hit “Ask the Brain” to see the honest energy/knowledge budget it feeds that surface. Every snapshot gets a signed receipt so it\'s tamper-evident. Trust is advisory (Λ = Conjecture 1, capped at 0.97, never a green stamp), and nothing here touches the locked-8. When our central hub isn\'t wired in yet, the view says so (“local fallback”) rather than pretending."; } function _infoHTML(){ return "What is real vs UNAVAILABLE. This panel calls GET /api/a11oy/v1/brain/command (this Dev\\u2019s backend). Server-side it PREFERS Dev-1\\u2019s central hub pulse GET /api/a11oy/v1/brain/pulse (read in-process); if szl_brain_hub isn\\u2019t merged it composes an honest local fallback from the shipped organs \\u2014 a11oy_brain_graph (knowledge), szl_energy_ledger (energy), szl3d_holographic.SURFACES (organs lit) \\u2014 and sets pulse_ok:false so you know the hub isn\\u2019t the source of truth yet.

Energy labels. MEASURED = real NVML-attested billable joules in the ledger chain; MODELED = a dry-run projection (jobs exist but no measured joules); UNAVAILABLE = no telemetry \\u2014 joules are never fabricated.

Knowledge. distinct_artifacts is the honest headline (excludes arXiv co-author person nodes); the raw node_count is never presented as all distinct work.

Subscribe / budget. \\u201cAsk the Brain\\u201d calls GET /api/a11oy/v1/brain/command/subscribe/{surface_id}. It delegates to the hub\\u2019s allocation when merged; otherwise it returns a MODELED equal-share of the harnessed-energy pool over the lit surfaces \\u2014 a transparent function, not a live per-organ meter.

Receipt. Each snapshot is a REAL ECDSA-P256 DSSE envelope in-Space (SZL cosign key) and an honest UNSIGNED-LOCAL envelope otherwise \\u2014 never a fabricated signature.

• Central hub pulse \\u2014 Dev 1, feat/brain-hub  • Energy harness \\u2014 Dev 2, feat/brain-energy  • Living body \\u2014 Dev 3, feat/brain-body  • Brain-fed flywheel \\u2014 Dev 4, feat/brain-feeds-flywheel.
• \\u039b trust gate = Conjecture 1 (lutar-lean; advisory, never green). Nothing here touches the locked-8; trust capped at 0.97, never 100%."; } function unmount(){ _polls.forEach((p)=>{ try{p.stop();}catch(_){} }); _polls=[]; try{ if(_show) _show.destroy(); }catch(_){} _show=null; try{ if(_group&&_stage){ _group.traverse((o)=>{ if(o.geometry&&o.geometry.dispose)o.geometry.dispose(); if(o.material){const ms=Array.isArray(o.material)?o.material:[o.material];ms.forEach((m)=>{if(m.dispose)m.dispose();});} }); _stage.scene.remove(_group); } }catch(_){} _group=_overlay=null; _core=_coreGlow=_know=_seal=null; _organs=[]; _badge=null; _plain=false; _frameReg=false; _stage=_THREE=_ctx=null; S.label="UNAVAILABLE"; S.state="init"; S.source=null; S.pulseOk=false; S.energyLabel="UNAVAILABLE"; S.joules=null; S.kwh=null; S.tokens=null; S.jobs=null; S.knowLabel="UNAVAILABLE"; S.distinct=null; S.nodes=null; S.links=null; S.surfaces=null; S.surfacesLabel="UNAVAILABLE"; S.signMode=null; S.signed=null; } export default { id: ID, title: TITLE, endpoints: [EP_CMD, EP_SUBS, EP_PULSE], mount, unmount };