GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / AI agents and coordination / ventus-grid-engine / /

Spider Sandbox and 2 more files

A web page in Ventus Grid Engine that draws engine graph and uses data from Elexon Balancing Mechanism Reporting Service (BMRS) and the spiders and data-federation-map-for-GlobalGrid2050-all-repos repositories. Published at https://ventusltd.github.io/ventus-grid-engine/spider-sandbox.html.

493 lines of HTML and JavaScript and Python from ventus-grid-engine, in 3 files. Topic: AI agents and coordination. Section 1682 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. Spider Sandbox render · ventus-grid-engine / spider-sandbox.html lines 1–296
  2. Manifest Proof docs-config · ventus-grid-engine / spider/manifest.proof.mjs lines 1–119
  3. Overview storage · ventus-grid-engine / spider/overview.py lines 1–78

Spider Sandbox

A web page in Ventus Grid Engine that draws engine graph and uses data from Elexon Balancing Mechanism Reporting Service (BMRS) and the spiders and data-federation-map-for-GlobalGrid2050-all-repos repositories. Published at https://ventusltd.github.io/ventus-grid-engine/spider-sandbox.html.

renderventus-grid-engine / spider-sandbox.html · lines 1–296 of 296 · Entry point · pattern normaliseGenericGraph (shared by 7 files)

What it does
It draws engine graph and solar. Defines 19 functions or classes, including applyRootLinks, S, rebuildSelect, actionable, openUrl. Side effects: changes the web page (DOM); makes network requests; uses storage (browser storage, DuckDB or Parquet).
Why it exists in the grid workflow
Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: solar.
Inputs & outputs
In: data source: spiders data; data source: data-federation-map-for-globalgrid2050-all-repos data; data source: Elexon BMRS; JSON file nodes.json; JSON file edges.json; JSON file engine-graph.json; DuckDB queries; form fields (user input). Out: web page; SVG drawing.
Downstream impact
Used directly by 1 file: Dashboard (ventus-grid-engine). It is itself an entry point, published at https://ventusltd.github.io/ventus-grid-engine/spider-sandbox.html.
What it achieves
It applies root links (`applyRootLinks`), rebuilds select (`rebuildSelect`) and opens URL (`openUrl`). Ventus Global Grid 2050. It responds to change and click events.
Why it matters
Imported by Dashboard.
Application
ventus-grid-engine · / · page
Uses
Federation Radial (stylesheet), Estate Menu (script src), Live Sandbox — Federation Control Ledger Page (estate URL)
Used by
linked from Dashboard (link)
Produces
applyRootLinks, S, rebuildSelect, actionable, openUrl, handleTap, drillInto, popTo, neighbours, goLabel, distribute, reshapeNodes
Defines here
applyRootLinks, S, rebuildSelect, actionable, openUrl, handleTap, drillInto, popTo, neighbours, goLabel, distribute, reshapeNodes, loadJSON, loadRoot, placeholderScope, resolveRef, normaliseGenericGraph, loadManifestScope, wireReceiver
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 spider-sandbox.html:1-296 · blob b9e7d249205f547ce5f3bd9946ff29f910ac258c · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network, storage · domain stage: experimental · users: none · canonical: production_core
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<title>Ventus Global Grid 2050 · The Spider Sandbox</title>
<style>
  :root{
    --bg:#0b0d12;--panel:#12151c;--panel2:#151923;--line:#262b36;--text:#eef2fb;--muted:#9aa3b5;--cyan:#00e5ff;
    --e-data:#00e5ff;--e-governance:#b47cff;--e-archive:#7da0c8;--e-external:#5f76a4;--e-repo:#b8ccff;--e-workflow:#00ffff;
    --safe-x:clamp(12px,2.3vw,28px);--shell:1040px;--card:220px;--gap:14px;
  }
  *{box-sizing:border-box}
  html,body{margin:0;min-height:100%}
  body{background:radial-gradient(1200px 700px at 50% -10%,rgba(0,229,255,.06),transparent 60%),var(--bg);color:var(--text);font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;height:100dvh;overflow:hidden;display:flex;flex-direction:column}
  button,select{font:inherit}
  .top{border-bottom:1px solid var(--line);background:rgba(11,13,18,.92);backdrop-filter:blur(16px)}
  .bar,.controls,.crumbs,.hint{width:min(var(--shell),calc(100vw - var(--safe-x)*2));margin:0 auto}
  .bar{display:flex;align-items:center;gap:10px 14px;flex-wrap:wrap;padding:max(env(safe-area-inset-top),12px) 0 10px}
  .brand{display:flex;flex-direction:column;line-height:1.05;min-width:190px}
  .brand .ey{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.6rem;letter-spacing:.22em;text-transform:uppercase;color:var(--cyan)}
  .brand h1{margin:2px 0 0;font-size:1rem;font-weight:650}
  .pick{display:flex;align-items:center;gap:8px;flex:1 1 280px;min-width:0}
  .pick label,.grouplabel{font-family:ui-monospace,monospace;font-size:.58rem;letter-spacing:.16em;text-transform:uppercase;color:var(--muted);flex:none}
  select{flex:1 1 auto;min-width:0;background:var(--panel);color:var(--text);border:1px solid var(--line);border-radius:10px;padding:9px 32px 9px 12px;font-size:.85rem;cursor:pointer;appearance:none;background-image:linear-gradient(45deg,transparent 50%,var(--muted) 50%),linear-gradient(135deg,var(--muted) 50%,transparent 50%);background-position:calc(100% - 16px) center,calc(100% - 11px) center;b  … [line shortened here: 459 characters; full line on GitHub]
  select:focus-visible,button:focus-visible{outline:none;border-color:var(--cyan);box-shadow:0 0 0 2px rgba(0,229,255,.18)}
  .count{font-family:ui-monospace,monospace;font-size:.72rem;color:var(--muted);margin-left:auto;white-space:nowrap}
  .count b{color:var(--text);font-weight:600}
  .controls{display:flex;align-items:center;gap:8px 14px;flex-wrap:wrap;padding:8px 0 4px}
  .seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;overflow:hidden;flex:none;background:rgba(18,21,28,.7)}
  .seg button{border:0;background:transparent;color:var(--muted);font-size:.72rem;padding:7px 13px;cursor:pointer;white-space:nowrap}
  .seg button[aria-pressed="true"]{background:rgba(0,229,255,.16);color:var(--text)}
  .seg button.gh[aria-pressed="true"]{background:rgba(184,204,255,.18)}
  .seg button.ext[aria-pressed="true"]{background:rgba(95,118,164,.28)}
  .seg button:disabled{opacity:.4;cursor:not-allowed}
  .viewbtn{border:1px solid rgba(255,255,255,.55);background:rgba(255,255,255,.08);color:#fff;border-radius:999px;padding:6px 12px;cursor:pointer;font-size:.86rem;line-height:1;display:inline-flex;align-items:center;gap:7px}
  .viewbtn[aria-pressed="true"]{border-color:var(--cyan);background:rgba(0,229,255,.16);box-shadow:0 0 22px rgba(0,229,255,.12)}
  .srctag{margin-left:auto;font-family:ui-monospace,monospace;font-size:.56rem;letter-spacing:.1em;text-transform:uppercase;color:var(--muted);border:1px solid var(--line);border-radius:999px;padding:2px 8px}
  .srctag.live{color:var(--cyan);border-color:rgba(0,229,255,.4)}
  .crumbs{display:flex;align-items:center;gap:6px;padding:2px 0 0;font-family:ui-monospace,monospace;font-size:.66rem;color:var(--muted);min-height:18px}
  .crumbs a{color:var(--cyan);cursor:pointer;text-decoration:none}
  .crumbs .sep{opacity:.5}
  .hint{padding:4px 0 8px;font-family:ui-monospace,monospace;font-size:.62rem;color:var(--muted)}
  .hint b{color:var(--text);font-weight:600}
  .stage{flex:1;min-height:0;position:relative;overflow:hidden}
  .overlay{position:absolute;inset:0}
  .overlay.column{overflow-y:auto;overflow-x:hidden;padding:16px var(--safe-x) max(env(safe-area-inset-bottom),22px)}
  .shell{width:min(var(--shell),100%);margin:0 auto;display:flex;flex-direction:column;gap:12px}
  .card{border:1px solid var(--line);border-radius:14px;background:linear-gradient(160deg,rgba(255,255,255,.055),rgba(255,255,255,.014));padding:10px 12px;display:flex;flex-direction:column;gap:6px;min-height:74px;box-shadow:0 16px 44px rgba(0,0,0,.12)}
  .card .row{display:flex;align-items:center;gap:7px}
  .badge{font-family:ui-monospace,monospace;font-size:.55rem;letter-spacing:.07em;border:1px solid var(--line);border-radius:6px;padding:2px 5px;color:var(--muted);flex:none}
  .name{font-size:.85rem;font-weight:650;line-height:1.15;overflow-wrap:anywhere}
  .dot{width:9px;height:9px;border-radius:50%;flex:none;margin-left:auto;box-shadow:0 0 8px currentColor}
  .reason{font-size:.68rem;color:var(--muted);line-height:1.25}
  .relrow{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
  .reltag{font-family:ui-monospace,monospace;font-size:.55rem;letter-spacing:.05em;text-transform:uppercase;padding:1px 7px;border-radius:999px;border:1px solid currentColor}
  .arrow{font-family:ui-monospace,monospace;font-size:.62rem;color:var(--muted)}
  .go{font-family:ui-monospace,monospace;font-size:.6rem;color:var(--cyan);margin-left:auto}
  .is-center{border-color:var(--cyan);box-shadow:0 0 0 1px rgba(0,229,255,.22),0 0 26px rgba(0,229,255,.12)}
  .is-center .name{font-size:.95rem}
  .contents{align-self:flex-start;margin-top:3px;font-family:ui-monospace,monospace;font-size:.62rem;color:var(--cyan);border:1px solid rgba(0,229,255,.4);border-radius:999px;padding:4px 10px;background:rgba(0,229,255,.08);cursor:pointer}
  .inert{opacity:.34}
  .sect{font-family:ui-monospace,monospace;font-size:.6rem;letter-spacing:.14em;text-transform:uppercase;color:var(--muted);margin:16px 2px 4px}
  .branch{position:relative;padding-left:20px;display:flex;flex-direction:column;gap:9px}
  .branch::before{content:"";position:absolute;left:7px;top:-6px;bottom:14px;width:2px;background:var(--line)}
  .twig{position:relative;cursor:pointer}
  .twig::before{content:"";position:absolute;left:-13px;top:28px;width:13px;height:2px;background:var(--twig,var(--line))}
  .twig .card{border-left:3px solid var(--twig,var(--line))}
  .empty{color:var(--muted);font-size:.78rem;padding:6px 2px}
  .overlay.spider{overflow:auto;cursor:grab;background:radial-gradient(circle at center,rgba(0,229,255,.045),transparent 45%)}
  .overlay.spider.dragging{cursor:grabbing;user-select:none}
  .spiderCanvas{position:relative;min-width:100%;min-height:100%}
  .spiderGrid{position:absolute;inset:0;background-image:linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),linear-gradient(90deg,rgba(255,255,255,.03) 1px, transparent 1px);background-size:80px 80px;mask-image:radial-gradient(circle at center,black,transparent 78%);pointer-events:none}
  .wires{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;overflow:visible}
  .spoke{stroke-width:1.8;fill:none;opacity:.88}
  .place{position:absolute;transform:translate(-50%,-50%);width:var(--card);cursor:pointer}
  .place.center{width:250px;cursor:default}
  .legend{position:sticky;left:14px;bottom:10px;display:flex;flex-wrap:wrap;gap:5px 12px;width:max-content;max-width:70%;pointer-events:none;padding:4px 0 10px 14px}
  .legend span{display:flex;align-items:center;gap:6px;font-family:ui-monospace,monospace;font-size:.58rem;letter-spacing:.05em;text-transform:uppercase;color:var(--muted)}
  .legend i{width:15px;height:0;border-top:2px solid;display:inline-block}
  .maphint{position:sticky;top:12px;left:14px;width:max-content;max-width:min(560px,calc(100vw - 32px));font-family:ui-monospace,monospace;font-size:.62rem;color:var(--muted);background:rgba(18,21,28,.8);border:1px solid var(--line);border-radius:999px;padding:5px 10px;backdrop-filter:blur(10px);z-index:5}
  @media (max-width:680px){:root{--safe-x:14px}.brand{min-width:100%}.bar{gap:8px}.count{width:100%;margin-left:0}.controls{gap:7px 10px}.seg button{padding:7px 10px;font-size:.68rem}.viewbtn{padding:6px 10px}.srctag{margin-left:0}.shell{gap:10px}.card{border-radius:12px}.name{font-size:.82rem}}
</style>
<link rel="stylesheet" href="./spider/federation_radial.css" />
<!-- The shared estate menu: FILE / EDIT / VIEW / SCOPE / GRID / ABOUT on every
     surface of the estate, so a reader can navigate from here to the homepage,
     Pipeline News versions, GridAtlas and the Repository federation. One
     additive line, exactly as spiders/species/seer-spider/estate-menu/
     INTEGRATION.md specifies for this page; the module renders its bar above
     this page's own header and pushes the page down by
     --gridatlas-menu-bar-clear rather than overlapping it. Nothing else on
     this page changes. -->
<script src="https://ventusltd.github.io/spiders/species/seer-spider/estate-menu/estate-menu.js" defer></script>
</head>
<body>
  <div class="top">
    <div class="bar">
      <div class="brand"><span class="ey">Ventus · Global Grid 2050</span><h1>The Spider Sandbox</h1></div>
      <div class="pick"><label for="focus">Focus</label><select id="focus"></select></div>
      <div class="count" id="count"></div>
    </div>
    <div class="controls">
      <span class="grouplabel">Show</span>
      <div class="seg" id="relSeg" role="group" aria-label="Relationship direction">
        <button data-mode="both" aria-pressed="true">Both</button>
        <button data-mode="out" aria-pressed="false">Outgoing</button>
        <button data-mode="in" aria-pressed="false">Incoming</button>
      </div>
      <button class="viewbtn" id="spiderToggle" aria-pressed="false" title="Toggle optional spider view"><span class="spider-glyph" aria-hidden="true">🕷</span><span id="viewLabel">Spider</span></button>
      <span class="grouplabel">Tap does</span>
      <div class="seg" id="actSeg" role="group" aria-label="Tap action">
        <button data-act="explore" aria-pressed="true">Explore</button>
        <button class="gh" data-act="github" aria-pressed="false">GitHub</button>
        <button class="ext" data-act="external" aria-pressed="false">External</button>
        <button data-act="status" aria-pressed="false" disabled title="Enables when the page reads live scanner data">Status</button>
      </div>
      <span class="srctag" id="srcTag" title="Data source for this view">snapshot</span>
    </div>
    <div class="crumbs" id="crumbs"></div>
    <div class="hint" id="hint"></div>
  </div>
  <div class="stage" id="stage"><div class="overlay column" id="overlay"></div></div>
<script>
const GH_BASE="https://github.com/Ventusltd/data-federation-map-for-globalgrid2050-all-repos";
const LIVE_PAGE="https://ventusltd.github.io/data-federation-map-for-globalgrid2050-all-repos/live_sandbox/federation_control_ledger/";
const EXT_HOME={"DuckDB":"https://duckdb.org","Parquet":"https://parquet.apache.org","GitHub Actions":"https://github.com/features/actions","Elexon BMRS API":"https://bmrs.elexon.co.uk","GitHub Pages":"https://pages.github.com"};
const PAGE_HOME={"globalgrid2050":"https://globalgrid2050.com/","globalgrid2050-hompage":"https://globalgrid2050.com/","data-federation-map-for-globalgrid2050-all-repos":LIVE_PAGE};
const ROOT_NODES=[
  {label:"data-federation-map-for-globalgrid2050-all-repos",type:"data",rag:"green",reason:"active federation repository",child:"data-federation"},
  {label:"data-gb-electricity",type:"data",rag:"red",reason:"contract finding surfaced"},
  {label:"data-interconnectors",type:"data",rag:"red",reason:"contract finding surfaced"},
  {label:"gb-electricity-ui",type:"ui",rag:"red",reason:"depends on verified data repos"},
  {label:"globalgrid2050",type:"source_archive",rag:"blue",reason:"source archive"},
  {label:"globalgrid2050-hompage",type:"homepage",rag:"green",reason:"homepage dependency surfaced"},
  {label:"pandapower",type:"unknown",rag:"grey",reason:"not fully classified"},
  {label:"Podcast-transcripts",type:"unknown",rag:"amber",reason:"workflow finding"},
  {label:"pv-arc-protection-circuit",type:"unknown",rag:"amber",reason:"workflow finding"},
  {label:"Solar-PV-Hybrid-and-off-grid",type:"unknown",rag:"amber",reason:"workflow finding"},
  {label:"solar-repowering-whitepaper",type:"unknown",rag:"amber",reason:"workflow finding"},
  {label:"youengineer-code-review",type:"ui",rag:"amber",reason:"reference UI pattern source"},
  {label:"DuckDB",type:"external",rag:"blue",reason:"proof query engine"},
  {label:"Parquet",type:"external",rag:"blue",reason:"columnar proof store"},
  {label:"Elexon BMRS API",type:"external",rag:"blue",reason:"external electricity source"},
  {label:"GitHub Actions",type:"external",rag:"blue",reason:"static build runner"},
];
const ROOT_EDGES=[
  [0,12,"external"],[0,13,"external"],[0,5,"governance"],[0,15,"external"],[0,14,"external"],
  [1,4,"archive"],[1,5,"governance"],[1,14,"external"],[1,15,"external"],[1,12,"external"],[1,13,"external"],
  [2,4,"archive"],[2,5,"governance"],[2,14,"external"],[2,13,"external"],[2,1,"repo"],[2,3,"repo"],[2,15,"external"],[2,12,"external"],
  [3,1,"data"],[3,2,"data"],[3,5,"governance"],[3,15,"external"],
  [4,14,"external"],[4,15,"external"],
  [5,14,"external"],[5,0,"data"],[5,1,"data"],[5,2,"data"],[5,3,"repo"],[5,4,"archive"],[5,12,"external"],[5,13,"external"],[5,15,"external"],
  [6,15,"external"],
];
function applyRootLinks(nodes){nodes.forEach(n=>{n.gh=n.type==="external"?null:`https://github.com/Ventusltd/${n.label}`;n.ext=EXT_HOME[n.label]||PAGE_HOME[n.label]||null;});return nodes;}
applyRootLinks(ROOT_NODES);
const CHILD_NODES=[
  {label:"data-federation repo",type:"data",rag:"green",reason:"root of this child scope",gh:GH_BASE+"/tree/main"},
  {label:"live dashboard page",type:"ui",rag:"green",reason:"GitHub Pages browser UI in this repo",gh:GH_BASE+"/tree/main/live_sandbox/federation_control_ledger",ext:LIVE_PAGE},
  {label:"index.html",type:"ui",rag:"green",reason:"page shell for the board",gh:GH_BASE+"/blob/main/live_sandbox/federation_control_ledger/index.html"},
  {label:"app.js",type:"ui",rag:"green",reason:"board renderer and interaction logic",gh:GH_BASE+"/blob/main/live_sandbox/federation_control_ledger/app.js"},
  {label:"style.css",type:"ui",rag:"green",reason:"board visual system",gh:GH_BASE+"/blob/main/live_sandbox/federation_control_ledger/style.css"},
  {label:"data cartridge folder",type:"data",rag:"green",reason:"manifest, nodes, edges, layers, sectors",gh:GH_BASE+"/tree/main/live_sandbox/federation_control_ledger/data"},
  {label:"data/manifest.json",type:"data",rag:"amber",reason:"root cartridge manifest; key still flagged",gh:GH_BASE+"/blob/main/live_sandbox/federation_control_ledger/data/manifest.json"},
  {label:"data/nodes.json",type:"data",rag:"green",reason:"repo and source nodes for the board",gh:GH_BASE+"/blob/main/live_sandbox/federation_control_ledger/data/nodes.json"},
  {label:"data/edges.json",type:"data",rag:"green",reason:"relationship lines for the board",gh:GH_BASE+"/blob/main/live_sandbox/federation_control_ledger/data/edges.json"},
  {label:"reports folder",type:"unknown",rag:"green",reason:"scan reports and evidence",gh:GH_BASE+"/tree/main/reports"},
  {label:"FEDERATION_MAP_LATEST.md",type:"unknown",rag:"green",reason:"latest human-readable scan report",gh:GH_BASE+"/blob/main/reports/FEDERATION_MAP_LATEST.md"},
  {label:"every-drop-is-the-ocean",type:"unknown",rag:"green",reason:"canonical doctrine and addenda",gh:GH_BASE+"/tree/main/every-drop-is-the-ocean"},
  {label:"GitHub Pages",type:"external",rag:"blue",reason:"static public hosting",ext:LIVE_PAGE},
  {label:"GitHub Actions",type:"external",rag:"blue",reason:"future scanner and validation runner",ext:EXT_HOME["GitHub Actions"],gh:GH_BASE+"/actions"},
];
const CHILD_EDGES=[[0,1,"repo"],[1,2,"repo"],[1,3,"repo"],[1,4,"repo"],[1,5,"data"],[3,5,"data"],[5,6,"data"],[5,7,"data"],[5,8,"data"],[0,9,"governance"],[9,10,"governance"],[0,11,"governance"],[1,12,"external"],[0,13,"external"],[3,13,"external"]];
const SCOPES={"root":{label:"Federation",nodes:ROOT_NODES,edges:ROOT_EDGES},"data-federation":{label:"data-federation internals",nodes:CHILD_NODES,edges:CHILD_EDGES}};
const RAG={green:"#00ff88",amber:"#ffcc00",red:"#ff5555",blue:"#3aa0ff",grey:"#9298a6"};
const ECSS={data:"#00e5ff",governance:"#b47cff",archive:"#7da0c8",external:"#5f76a4",repo:"#b8ccff",workflow:"#00ffff"};
const BADGE={data:"DB",ui:"UI",homepage:"WEB",source_archive:"SRC",unknown:"REPO",external:"EXT"};
const REL={data:"data",governance:"governance",archive:"archive",external:"external",repo:"repo ref",workflow:"workflow"};
const SVGNS="http://www.w3.org/2000/svg";
let mode="both", action="explore", view="column", current=0, scopeKey="root", stack=[];
const sel=document.getElementById("focus"), overlay=document.getElementById("overlay"), elCount=document.getElementById("count"), elCrumbs=document.getElementById("crumbs"), elHint=document.getElementById("hint"), spiderToggle=document.getElementById("spiderToggle"), viewLabel=document.getElementById("viewLabel");
function S(){return SCOPES[scopeKey];}
function rebuildSelect(){sel.innerHTML="";S().nodes.forEach((n,i)=>{const o=document.createElement("option");o.value=i;o.textContent=n.label;sel.appendChild(o);});sel.value=current;}
sel.addEventListener("change",()=>{current=+sel.value;draw();});
document.querySelectorAll("#relSeg button").forEach(b=>b.addEventListener("click",()=>{mode=b.dataset.mode;document.querySelectorAll("#relSeg button").forEach(x=>x.setAttribute("aria-pressed",String(x===b)));draw();}));
document.querySelectorAll("#actSeg button").forEach(b=>b.addEventListener("click",()=>{if(b.disabled)return;action=b.dataset.act;document.querySelectorAll("#actSeg button").forEach(x=>x.setAttribute("aria-pressed",String(x===b)));draw();}));
spiderToggle.addEventListener("click",()=>{view=view==="spider"?"column":"spider";spiderToggle.setAttribute("aria-pressed",String(view==="spider"));viewLabel.textContent=view==="spider"?"Column":"Spider";draw();});
let rt;new ResizeObserver(()=>{clearTimeout(rt);rt=setTimeout(draw,80);}).observe(document.getElementById("stage"));
function actionable(n){return action==="explore" ? true : action==="github" ? !!n.gh : action==="external" ? !!n.ext : false;}
function openUrl(u){if(u)window.open(u,"_blank","noopener");}
function handleTap(i){const n=S().nodes[i];if(action==="explore"){current=i;sel.value=i;draw();}else if(action==="github"){openUrl(n.gh);}else if(action==="external"){openUrl(n.ext);}}
function drillInto(childKey){stack.push({key:scopeKey,current});scopeKey=childKey;current=0;mode="both";document.querySelectorAll("#relSeg button").forEach(x=>x.setAttribute("aria-pressed",String(x.dataset.mode==="both")));rebuildSelect();draw();}
function popTo(idx){const target=stack[idx];stack=stack.slice(0,idx);scopeKey=target.key;current=target.current;rebuildSelect();draw();}
function neighbours(idx){const out=[],inc=[];S().edges.forEach(([f,t,ty])=>{if(f===idx)out.push({other:t,type:ty});if(t===idx)inc.push({other:f,type:ty});});return {out,inc};}
function cardInner(node,opts={}){const center=opts.center, rel=opts.rel, dim=opts.dim;let relHTML="";if(rel){const c=ECSS[rel.type]||ECSS.repo;relHTML=`<div class="relrow"><span class="arrow">${rel.dir==="out"?"depends on →":"← depended on by"}</span><span class="reltag" style="color:${c}">${REL[rel.type]||rel.type}</span>${opts.go?`<span class="go">${opts.go}</span>`:""}</div>`;}let contents="";i  … [line shortened here: 959 characters; full line on GitHub]
function goLabel(n){return action==="github"&&n.gh?"open ↗":action==="external"&&n.ext?"open ↗":"";}
function setHint(){const base={explore:"<b>Explore</b> — tap a card to re-centre. Use the spider only when you choose it.",github:"<b>GitHub</b> — tap a repo to open it. Cards with no repo are dimmed.",external:"<b>External</b> — tap an external system to open it. Others are dimmed."};elHint.innerHTML=(base[action]||"")+(view==="spider"?" &nbsp; <b>Spider view</b> — scroll or drag the large canvas  … [line shortened here: 408 characters; full line on GitHub]
function setCrumbs(){elCrumbs.innerHTML="";const trail=[...stack.map((s,i)=>({label:SCOPES[s.key].label,idx:i})),{label:S().label,idx:-1}];trail.forEach((c,k)=>{if(k)elCrumbs.insertAdjacentHTML("beforeend",`<span class="sep">›</span>`);if(c.idx===-1){const s=document.createElement("strong");s.textContent=c.label;s.style.color="var(--text)";elCrumbs.appendChild(s);}else{const a=document.createEleme  … [line shortened here: 504 characters; full line on GitHub]
function draw(){const nodes=S().nodes,focus=nodes[current];let {out,inc}=neighbours(current);let lo=mode==="in"?[]:out,li=mode==="out"?[]:inc;elCount.innerHTML=`<b>${out.length}</b> dependencies &nbsp;·&nbsp; <b>${inc.length}</b> dependents`;setHint();setCrumbs();overlay.innerHTML="";overlay.className="overlay "+view;if(view==="spider")drawSpider(focus,lo,li);else drawColumn(focus,lo,li);overlay.q  … [line shortened here: 523 characters; full line on GitHub]
function drawColumn(focus,out,inc){const nodes=S().nodes;const shell=document.createElement("div");shell.className="shell";shell.innerHTML=`<div class="focuswrap">${cardInner(focus,{center:true,dim:!actionable(focus),go:goLabel(focus)})}</div>`;const section=(title,items,dir)=>{const s=document.createElement("div");s.innerHTML=`<div class="sect">${title}</div>`;if(!items.length){const e=document.c  … [line shortened here: 1,162 characters; full line on GitHub]
function marker(defs,type){const m=document.createElementNS(SVGNS,"marker");m.id="arr-"+type;m.setAttribute("viewBox","0 0 10 10");m.setAttribute("refX","9");m.setAttribute("refY","5");m.setAttribute("markerWidth","8");m.setAttribute("markerHeight","8");m.setAttribute("orient","auto");const p=document.createElementNS(SVGNS,"path");p.setAttribute("d","M0,0 L10,5 L0,10 z");p.setAttribute("fill",ECSS  … [line shortened here: 457 characters; full line on GitHub]
function distribute(items,side,cx,cy,gap,xGap){const n=items.length;if(!n)return[];return items.map((it,k)=>{const y=cy+(k-(n-1)/2)*gap;const stagger=(n>5&&k%2?90:0);const x=cx+side*(xGap+stagger);return{...it,dir:side>0?"out":"in",x,y};});}
function drawSpider(focus,out,inc){const stage=document.getElementById("stage");const sw=stage.clientWidth,sh=stage.clientHeight;const maxSide=Math.max(out.length,inc.length,1);const gap=176;const xGap=Math.max(420,260+maxSide*38);const cw=Math.max(sw,Math.ceil(680+xGap*2+maxSide*120));const ch=Math.max(sh,Math.ceil(520+gap*(maxSide+1)));const cx=cw/2,cy=ch/2;const pts=[...distribute(out,1,cx,cy,g  … [line shortened here: 2,606 characters; full line on GitHub]
function enableDragPan(el){/* 2026-09-14: pointer capture is taken only after the pointer has moved more than 6 px, so a plain mouse click on a card still reaches the card (before this, capture at pointerdown sent every click to the overlay and desktop mouse users could not tap cards in the spider view; touch taps were unaffected). */let down=false,captured=false,pid=null,sx=0,sy=0,sl=0,st=0;el.on  … [line shortened here: 992 characters; full line on GitHub]
const DATA_BASE="./spider/data/";
const CHILD_KEY="data-federation";
function reshapeNodes(fc){return (fc.features||[]).map(f=>{const p=f.properties||{};const cm=p.child_manifest||null;return {label:p.label||f.id,type:p.repo_type||p.scope_type||"unknown",rag:p.rag||p.status||"grey",reason:p.status_reason||"",child:(cm&&/data-federation/.test(cm))?CHILD_KEY:null};});}
async function loadJSON(path){const r=await fetch(DATA_BASE+path,{cache:"no-cache"});if(!r.ok)throw new Error(path+" "+r.status);return r.json();}
async function loadRoot(){try{const [nf,ef]=await Promise.all([loadJSON("nodes.json"),loadJSON("edges.json")]);const nodes=reshapeNodes(nf);if(!nodes.length)throw new Error("empty");applyRootLinks(nodes);SCOPES.root.nodes=nodes;SCOPES.root.edges=(ef.edges||[]).map(e=>[e[0],e[1],e[2]]);return "live";}catch(e){return "snapshot";}}
const CONTENTS_BASE="./spider/data/contents/";
const MONO_GH="https://github.com/Ventusltd/globalgrid2050";
const CONTENTS_KEY="globalgrid2050-contents";
async function loadContents(){try{const get=p=>fetch(CONTENTS_BASE+p,{cache:"no-cache"}).then(r=>{if(!r.ok)throw new Error(p+" "+r.status);return r.json();});const [mf,nf,ef]=await Promise.all([get("manifest.json"),get("nodes.json"),get("edges.json")]);if(!Array.isArray(nf)||!nf.length)throw new Error("empty nodes");BADGE.eye_app="EYE";BADGE.sense_app="SENSE";BADGE.served_surface="PAGE";REL.contai  … [line shortened here: 1,115 characters; full line on GitHub]

/* --- ventus-grid-engine receiver additions below. Nothing above this comment
   is changed in behaviour from spider_full_po_test.html, only DATA_BASE (was
   "../../live_sandbox/federation_control_ledger/data/") and CONTENTS_BASE
   (was "../../data/federation_map/contents/provenance=declared/repo=Ventusltd__globalgrid2050/")
   were repointed at the copies under ./spider/, and the stylesheet <link>
   now reads "./spider/federation_radial.css". The reference's own IIFE at
   its end is replaced by wireReceiver() below, which does the same
   loadRoot()+loadContents() call and then adds manifest-driven graphs on
   top, using the existing scope/card/FOCUS machinery unchanged. --- */
const RECEIVER_MANIFEST_PATH="./spider/manifest.json";
/* Snapshot fallback of spider/manifest.json's two receiver-owned slots, kept
   in sync with that file by hand. Exists for the same reason ROOT_NODES
   above exists: fetch() cannot load file:// resources at all in Chromium
   ("URL scheme file is not supported", confirmed while proving this page),
   so a file://-opened copy would otherwise never offer these two graphs even
   though the spider/manifest.json fetch is the source of truth whenever it
   IS reachable (e.g. served over http/https, including GitHub Pages). */
const MANIFEST_FALLBACK={graphs:[
  {id:"engine-graph",title:"Engine population",path:"./genome/engine-graph.json",source_spider:"genome/build-graph.mjs (regenerated by .github/workflows/genome.yml)",description:"The ventus-grid-engine population graph: the engine's canonical modules and the copies, drifts and should-imports they replace across the estate. Generated in this repository by genome/build-graph.mjs."},
  {id:"genome-spider",title:"genome-spider output",path:"https://ventusltd.github.io/spiders/species/genome-spider/data/nodes.json",edges_path:"https://ventusltd.github.io/spiders/species/genome-spider/data/edges.json",source_spider:"spiders/species/genome-spider (spider.mjs)",description:"The estate genome published by spiders/species/genome-spider: repositories and their significant internal uni  … [line shortened here: 458 characters; full line on GitHub]
]};
function placeholderScope(title,path){return {label:title,nodes:[{label:title+" — not yet emitted",type:"unknown",rag:"grey",reason:"Populated once "+path+" exists and is reachable from this page."}],edges:[]};}
function resolveRef(ids,r){return ids[r]!==undefined?ids[r]:r;}
function normaliseGenericGraph(raw){
  const rawNodes=Array.isArray(raw.nodes)?raw.nodes:(Array.isArray(raw.features)?raw.features.map(f=>({id:f.id,...(f.properties||{})})):[]);
  const ids={};
  const nodes=rawNodes.map((n,i)=>{const id=n.id!==undefined?n.id:i;ids[id]=i;return {label:n.label||n.title||String(id),type:n.type||n.nodeKind||n.repo_type||"unknown",rag:n.rag||n.status||"grey",reason:n.reason||n.status_reason||n.path||"",gh:n.gh||null,ext:n.ext||null};});
  const rawEdges=Array.isArray(raw.edges)?raw.edges:(Array.isArray(raw.links)?raw.links:[]);
  const edges=rawEdges.map(e=>Array.isArray(e)?[resolveRef(ids,e[0]),resolveRef(ids,e[1]),e[2]||"repo"]:[resolveRef(ids,e.from!==undefined?e.from:e.source),resolveRef(ids,e.to!==undefined?e.to:e.target),e.type||"repo"]).filter(e=>typeof e[0]==="number"&&typeof e[1]==="number");
  return {nodes,edges};
}
async function loadManifestScope(entry){
  try{const r=await fetch(entry.path,{cache:"no-cache"});if(!r.ok)throw new Error(entry.path+" "+r.status);const raw=await r.json();
    /* edges_path: a graph published as a sandbox-shaped pair (nodes in one file, edges in another, as
       federation-spider and genome-spider both publish) supplies its edges from the second file.
       Entries without edges_path behave exactly as before. */
    if(entry.edges_path){const er=await fetch(entry.edges_path,{cache:"no-cache"});if(!er.ok)throw new Error(entry.edges_path+" "+er.status);const ef=await er.json();raw.edges=Array.isArray(ef)?ef:(Array.isArray(ef.edges)?ef.edges:(Array.isArray(ef.links)?ef.links:[]));}
    const g=normaliseGenericGraph(raw);if(!g.nodes.length)throw new Error("empty");return {label:entry.title,nodes:g.nodes,edges:g.edges,live:true};}
  catch(e){return {...placeholderScope(entry.title,entry.path),live:false};}
}
async function wireReceiver(){
  let manifest=MANIFEST_FALLBACK;
  try{const r=await fetch(RECEIVER_MANIFEST_PATH,{cache:"no-cache"});if(r.ok){const live=await r.json();if(Array.isArray(live.graphs)&&live.graphs.length)manifest=live;}}catch(e){}
  /* Every graph the manifest lists, except the two the page builds itself.
     This read `g.id==="engine-graph"||g.id==="genome-spider"` - a hard-coded
     pair - so a manifest could add graphs for ever and the page would never
     request them; gridatlas-lineage sat in the live manifest and was never
     fetched (network trace, 2026-09-04). A receiver that "will constantly
     also receive cartridges like gridatlas" has to read what it is given. */
  const BUILT_IN=new Set(["federation","globalgrid2050-contents"]);
  const extra=(manifest.graphs||[]).filter(g=>g&&g.id&&g.path&&!BUILT_IN.has(g.id));
  for(const entry of extra){
    const scope=await loadManifestScope(entry);
    SCOPES[entry.id]=scope;
    SCOPES.root.nodes.push({label:entry.title,type:"unknown",rag:scope.live?"green":"grey",reason:entry.description||"",child:entry.id,gh:null,ext:null});
  }
  const qp=new URLSearchParams(location.search);
  const want=qp.get("graph");
  if(want){const key=want==="federation"?"root":want;if(SCOPES[key]){stack=key==="root"?[]:[{key:"root",current:0}];scopeKey=key;current=0;}}
  /* ?focus=<node label> centres the graph on one module.
     ------------------------------------------------------------------------
     Written 202609050300 so the dashboards can link INTO the maths rather
     than at it: a File menu in GridAtlas or Pipeline News names a module and
     lands the reader on that node with its dependencies already drawn. The
     match is on the node's own label, exact first and then case-insensitively,
     so a link is written with the same string the graph publishes -- no second
     naming scheme to drift. An unknown focus is IGNORED, never an error: the
     graph still opens on its default, which is what a reader following a stale
     link should get. */
  const wantFocus=qp.get("focus");
  if(wantFocus){
    const ns=S().nodes;
    let i=ns.findIndex(n=>n.label===wantFocus);
    if(i<0){const lc=wantFocus.toLowerCase();i=ns.findIndex(n=>String(n.label||"").toLowerCase()===lc);}
    if(i>=0)current=i;
  }
  rebuildSelect();draw();
}
(async()=>{const src=await loadRoot();await loadContents();const tag=document.getElementById("srcTag");if(tag){tag.textContent=src;tag.classList.toggle("live",src==="live");}await wireReceiver();})();
</script>
</body>
</html>

Manifest Proof

A JavaScript module in the spider folder of Ventus Grid Engine that strips bom (`stripBom`).

docs-configventus-grid-engine / spider/manifest.proof.mjs · lines 1–119 of 119 · Entry point · pattern count (shared by 27 files)

What it does
It fetches data. Defines 6 functions or classes, including arg, load, stripBom, count, statedCounts. Uses libraries node:fs, node:url, node:path. Side effects: reads or writes files; makes network requests; starts processes.
Why it exists in the grid workflow
Domain stage agent_infra (path word 'spider'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
Inputs & outputs
In: JSON file manifest.negative.json; command-line arguments.
Downstream impact
Used directly by 1 file: Spider Features Workflow (ventus-grid-engine).
What it achieves
It is built from the arg step (`arg`), the load step (`load`) and the strip bom helper (`stripBom`). Every graph `spider/manifest.json` lists is fetched, and every count the manifest states is compared with what that path serves.
Why it matters
Run by Spider Features Workflow.
Application
ventus-grid-engine · spider · JavaScript module
Uses
node:fs, node:url, node:path
Used by
run by Spider Features Workflow (workflow run)
Produces
arg, load, stripBom, count, statedCounts, check
Defines here
arg, load, stripBom, count, statedCounts, check
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 spider/manifest.proof.mjs:1-119 · blob 97d48f5e166ee84a76011aa979d4648373721967 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, network, process · domain stage: agent_infra · users: ai_agent · canonical: production_core
/* manifest.proof.mjs — every graph spider/manifest.json lists is fetched, and
 * every count the manifest states is compared with what that path serves.
 *
 * Fails if any path (or edges_path) does not load, if any entry states no
 * measured count, or if any stated count differs from the served count.
 * "Stated" means the entry's "measured" field and any "N nodes / M edges"
 * written in its description or verified line.
 *
 * Before the real manifest is checked, the checker is run against
 * spider/fixtures/manifest.negative.json, which carries one stale count and
 * one missing path beside one correct control entry. The checker must flag
 * exactly those two; if it does not, it cannot be trusted to pass anything,
 * and this proof fails.
 *
 * Counts are taken the way index.html's normaliseGenericGraph and
 * spider/update_manifest.py take them: nodes (or features) from path; edges
 * (or links) from edges_path when the entry has one, otherwise from path; a
 * bare JSON array is its own count.
 *
 * Needs the network for https paths, so it is NOT one of the offline proofs
 * verify.mjs runs. .github/workflows/spider-features.yml runs it after the
 * manifest is refreshed and before anything is committed.
 *
 *   node spider/manifest.proof.mjs
 *   node spider/manifest.proof.mjs --base=https://ventusltd.github.io/ventus-grid-engine/
 *       (read ./ paths from the published site instead of this checkout)
 *   node spider/manifest.proof.mjs --manifest=<file>
 */

import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, join, resolve } from 'node:path';

const here = dirname(fileURLToPath(import.meta.url));
const root = resolve(here, '..');
const arg = name => (process.argv.find(a => a.startsWith('--' + name + '=')) || '').slice(name.length + 3) || null;
const base = arg('base');
const manifestPath = arg('manifest') || join(here, 'manifest.json');

async function load(path) {
    const stripBom = text => (text.charCodeAt(0) === 0xFEFF ? text.slice(1) : text);
    if (/^https?:\/\//.test(path) || base) {
        const url = /^https?:\/\//.test(path) ? path : new URL(path, base).href;
        const r = await fetch(url, { headers: { 'Cache-Control': 'no-cache' } });
        if (!r.ok) throw new Error('HTTP ' + r.status + ' ' + url);
        return JSON.parse(stripBom(await r.text()));
    }
    let text;
    try { text = readFileSync(join(root, path), 'utf8'); }
    catch (err) { throw new Error(err.code === 'ENOENT' ? 'not found: ' + path : String(err.message)); }
    return JSON.parse(stripBom(text));
}

function count(raw) {
    if (Array.isArray(raw)) return [raw.length, raw.length];
    const nodes = Array.isArray(raw.nodes) ? raw.nodes : Array.isArray(raw.features) ? raw.features : [];
    const edges = Array.isArray(raw.edges) ? raw.edges : Array.isArray(raw.links) ? raw.links : [];
    return [nodes.length, edges.length];
}

function statedCounts(entry) {
    const stated = [];
    if (entry.measured) stated.push(['measured', entry.measured.nodes, entry.measured.edges]);
    for (const field of ['description', 'verified']) {
        const text = String(entry[field] || '').replace(/(\d),(\d)/g, '$1$2');
        for (const m of text.matchAll(/(\d+)\s+nodes?\s*\/\s*(\d+)\s+edges?/gi)) {
            stated.push([field, Number(m[1]), Number(m[2])]);
        }
    }
    return stated;
}

async function check(manifest) {
    const failures = [];
    const report = [];
    for (const entry of manifest.graphs || []) {
        if (!entry.id || !entry.path) { failures.push([entry.id || '?', 'no id or path']); continue; }
        let served;
        try {
            const [n, eFromPath] = count(await load(entry.path));
            const e = entry.edges_path ? count(await load(entry.edges_path))[1] : eFromPath;
            served = [n, e];
        } catch (err) {
            failures.push([entry.id, 'path does not load: ' + String(err.message || err).slice(0, 160)]);
            continue;
        }
        const stated = statedCounts(entry);
        if (!entry.measured) failures.push([entry.id, 'no measured count stated']);
        for (const [field, n, e] of stated) {
            if (n !== served[0] || e !== served[1]) {
                failures.push([entry.id, field + ' states ' + n + ' nodes / ' + e + ' edges; served ' + served[0] + ' / ' + served[1]]);
            }
        }
        report.push(entry.id + ': served ' + served[0] + ' nodes / ' + served[1] + ' edges');
    }
    return { failures, report };
}

/* 1. The checker must fail the negative fixture, and for the right reasons. */
const negative = await check(JSON.parse(readFileSync(join(here, 'fixtures', 'manifest.negative.json'), 'utf8')));
const flagged = new Set(negative.failures.map(f => f[0]));
console.log('negative fixture: ' + negative.failures.length + ' failures reported');
for (const [id, why] of negative.failures) console.log('  - ' + id + ': ' + why);
if (!flagged.has('stale-count') || !flagged.has('missing-path') || flagged.has('control')) {
    console.error('manifest proof FAILED: the checker did not flag exactly the stale count and the missing '
        + 'path in fixtures/manifest.negative.json, so its verdict on the real manifest cannot be trusted.');
    process.exit(1);
}

/* 2. The real manifest. */
const real = await check(JSON.parse(readFileSync(manifestPath, 'utf8')));
for (const line of real.report) console.log('  ' + line);
if (real.failures.length) {
    console.error('manifest proof FAILED (' + real.failures.length + '):');
    for (const [id, why] of real.failures) console.error('  - ' + id + ': ' + why);
    process.exit(1);
}
const checks = 3 + real.report.length;
console.log('manifest proof PASS — ' + checks + ' checks (' + real.report.length + ' graphs match their stated counts; negative fixture failed as it must)');

Overview

A Python module in the spider folder of Ventus Grid Engine that writes the front door: one graph whose cards are every graph the manifest lists.

storageventus-grid-engine / spider/overview.py · lines 1–78 of 78 · Entry point · pattern repo_of (shared by 2 files)

What it does
It loads data. Defines repo_of. Uses libraries datetime, json, pathlib, re. Side effects: reads or writes files.
Why it exists in the grid workflow
Domain stage agent_infra (path word 'spider'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
Inputs & outputs
In: JSON file overview.json.
Downstream impact
Used directly by 1 file: Spider Features Workflow (ventus-grid-engine).
What it achieves
Defines `repo_of`.
Why it matters
Run by Spider Features Workflow.
Application
ventus-grid-engine · spider · Python module
Uses
datetime, json, pathlib, re
Used by
run by Spider Features Workflow (workflow run)
Produces
repo_of
Defines here
repo_of
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 spider/overview.py:1-78 · blob 7ff3adaee2b719ef7c7f29c08bdaa47b01f98028 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: filesystem · domain stage: agent_infra · users: ai_agent · canonical: production_core
"""Write the front door: one graph whose cards are every graph the manifest lists.

Reads spider/manifest.json and writes spider/data/overview.json in the receiver's node and edge shape.
The overview node contains one card per manifest entry; each card's External road opens that graph on the
dashboard (?graph=<id>), and its GitHub road is the repository that publishes it, when the entry names one.

Generated from the manifest so it can never list a graph the dashboard does not have, and never miss one it
does. Run after update_manifest.py by .github/workflows/spider-features.yml. index.html is not touched: the
receiver reads the overview like any other manifest entry. Designed as data on 2026-09-14 (MSI lab draft,
overview-graph.json), so the reference page stays unchanged.
"""
import datetime
import json
import pathlib
import re

HERE = pathlib.Path(__file__).resolve().parent
MANIFEST = HERE / "manifest.json"
OUT = HERE / "data" / "overview.json"
DASHBOARD = "https://ventusltd.github.io/ventus-grid-engine/"
SELF_ID = "overview"


def repo_of(entry):
    owner = entry.get("registry") or entry.get("path") or ""
    m = re.match(r"https://ventusltd\.github\.io/([^/]+)/", owner)
    if m:
        return f"https://github.com/Ventusltd/{m.group(1)}"
    return "https://github.com/Ventusltd/ventus-grid-engine"


manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
graphs = [g for g in manifest["graphs"] if g.get("id") and g["id"] != SELF_ID]
nodes = [{
    "id": SELF_ID,
    "label": "GLOBALGRID2050 architecture",
    "type": "estate",
    "rag": "green",
    "reason": (f"The map of maps: {len(graphs)} graphs of the estate's code, its reuse, its blocks, its tests and its "
               "decisions. Tap a card's External road to open that graph."),
    "gh": "https://github.com/Ventusltd",
    "ext": DASHBOARD,
}]
edges = []
for g in graphs:
    verified = g.get("verified") or ""
    placeholder = "empty slot" in (g.get("description") or "").lower()
    nodes.append({
        "id": f"graph:{g['id']}",
        "label": g.get("title") or g["id"],
        "type": "graph",
        "rag": "grey" if placeholder else "green",
        "reason": ((g.get("description") or "").split(". ")[0].strip(". ") + "." if g.get("description") else "")
                  + (f" Verified {verified}." if verified else "")
                  + (" Placeholder: no data published yet." if placeholder else ""),
        "gh": repo_of(g),
        "ext": f"{DASHBOARD}?graph={g['id']}",
    })
    edges.append({"from": SELF_ID, "to": f"graph:{g['id']}", "type": "contains"})

out = {
    "schema": "overview-graph.v1",
    "label": "GLOBALGRID2050 architecture",
    "generated_utc": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
    "note": "Generated from spider/manifest.json by spider/overview.py; one card per registered graph.",
    "counts": {"graphs": len(graphs)},
    "nodes": nodes,
    "edges": edges,
}
OUT.parent.mkdir(parents=True, exist_ok=True)
OUT.write_text(json.dumps(out, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
# The overview is written after update_manifest.py measured it, so its own measured count is refreshed here,
# from the file just written, rather than left one run behind.
for g in manifest["graphs"]:
    if g.get("id") == SELF_ID:
        g["measured"] = {"nodes": len(nodes), "edges": len(edges)}
MANIFEST.write_text(json.dumps(manifest, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
print(f"overview: {len(graphs)} graphs -> {OUT.relative_to(HERE.parent)}")