GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Websites and apps / ventus-grid-engine / engine

Ventus Grid Engine — Genome Page and 2 more files

A web page that draws maths provenance, engine graph, battery storage (BESS) and solar, using haversine and SHA-256. Published at https://ventusltd.github.io/ventus-grid-engine/genome/.

700 lines of HTML and JavaScript from ventus-grid-engine, in 3 files. Topic: Websites and apps. Section 2020 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. Rating Envelope electrical · ventus-grid-engine / engine/rating-envelope.js lines 1–175
  2. Site Tile geodesy · ventus-grid-engine / engine/site-tile.js lines 1–166
  3. Ventus Grid Engine — Genome Page render · ventus-grid-engine / genome/index.html lines 1–359

Rating Envelope

A JavaScript module in Ventus Grid Engine. It is built from the seasons of helper (`seasonsOf`) and the flags for helper (`flagsFor`).

electricalventus-grid-engine / engine/rating-envelope.js · lines 1–175 of 175 · Entry point · pattern seasonsOf (shared by 10 files)

What it does
It lists and searches its content. Defines seasonsOf, flagsFor, at. Side effects: changes the web page (DOM).
Downstream impact
Used directly by 3 files: Build Graph (ventus-grid-engine, https://ventusltd.github.io/ventus-grid-engine/genome/); Rating Envelope Proof (ventus-grid-engine); Ventus Grid Engine — Genome Page (ventus-grid-engine, https://ventusltd.github.io/ventus-grid-engine/genome/). Reached from 1 other entry point, including Genome Workflow (ventus-grid-engine).
What it achieves
PROMOTED from `sources/v9-extracts/rating-envelope.mjs` (itself extracted verbatim from `gridatlas/atlas/modules/202609012250-rating-envelope.js`).
Why it matters
Loaded by the Genome page at https://ventusltd.github.io/ventus-grid-engine/genome/. Also imported by Build Graph and Rating Envelope Proof.
Application
ventus-grid-engine · engine · JavaScript module
Uses
none found
Used by
named by URL in Build Graph (estate URL), imported by Rating Envelope Proof (import), named by URL in Ventus Grid Engine — Genome Page (estate URL)
Produces
SEASONS, NEVER_SUMMED, NOT_A_CAPACITY, IMPLAUSIBLE_MVA, at, schema, requires
Defines here
seasonsOf, flagsFor, at
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 engine/rating-envelope.js:1-175 · blob dfb9b0f466ee3e35a8e6ca192355cbde5dbcb73c · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: production_core
/**
 * Module: rating-envelope
 *
 * PROMOTED from sources/v9-extracts/rating-envelope.mjs (itself extracted
 * verbatim from gridatlas/atlas/modules/202609012250-rating-envelope.js).
 *
 * What the operator publishes a circuit can carry, season by season — and
 * a structural refusal to add those numbers up. Per-circuit thermal
 * ratings, never summed across a site, never averaged into a mean that no
 * circuit is rated at; only the published lowest/highest across the
 * circuits that qualify.
 *
 * Depends on: a `network-topology` index exposing `.graph()` with schema
 * 'gridatlas.module.network-topology.graph.v1', and `.site(key)`.
 *
 * CHANGED FROM THE SOURCE: the IIFE and `window.__GRIDATLAS_MODULES__`
 * registration are removed. `at()` and its helpers are otherwise
 * unchanged — verified verbatim against
 * gridatlas/atlas/modules/202609012250-rating-envelope.js at HEAD
 * 64268fd06a0da54ddffbcdaaaee382e314e829f7 (see sources/provenance.json).
 */

const SCHEMA = 'gridatlas.module.rating-envelope.v1';
const REQUIRES = 'gridatlas.module.network-topology.graph.v1';

export const SEASONS = Object.freeze(['winter', 'spring', 'summer', 'autumn']);
const FIELD = Object.freeze({
  winter: 'winter_mva', spring: 'spring_mva',
  summer: 'summer_mva', autumn: 'autumn_mva'
});

export const NEVER_SUMMED =
  'These are per-circuit thermal ratings under stated seasonal '
  + 'conditions. They are not additive and they are not simultaneous: '
  + 'the sum of the circuits at a site is not a quantity that exists in '
  + 'the network, and this module contains no code that produces one.';

export const NOT_A_CAPACITY =
  'A rating is what a circuit is rated to carry, not what is free on '
  + 'it. Existing flows, committed connections, queue position, outage '
  + 'conditions and commercial terms decide what a project could use, '
  + 'and no published appendix contains any of them.';

/* A rating that is obviously not a rating. 9999 on a one-kilometre span
   with zero impedance is a placeholder, not a thermal limit; so is
   69,275 on a hundred-metre cable. The test is deliberately narrow: a
   value at or above this threshold is flagged and excluded from the
   range, nothing else is second-guessed. */
export const IMPLAUSIBLE_MVA = 9999;

function seasonsOf(row) {
  const published = {};
  const absent = [];
  for (const season of SEASONS) {
    const value = row[FIELD[season]];
    if (Number.isFinite(value)) published[season] = value;
    else absent.push(season);
  }
  return { published, absent };
}

function flagsFor(published) {
  const flags = [];
  for (const [season, value] of Object.entries(published)) {
    if (value >= IMPLAUSIBLE_MVA) {
      flags.push({
        season,
        value,
        reason: 'at or above ' + IMPLAUSIBLE_MVA + ' MVA, which has the '
          + 'shape of a placeholder rather than a thermal rating; it is '
          + 'reported and excluded from the range below'
      });
    }
  }
  return flags;
}

/**
 * Every circuit landing at a site, at one voltage, with its own seasonal
 * ratings. No total anywhere.
 *
 * @param index      a network-topology index exposing graph()
 * @param key        site code or exact site name
 * @param options    { voltageKv }
 */
export function at(index, key, options) {
  if (!index || typeof index.graph !== 'function') return null;
  const graph = index.graph();
  if (!graph || graph.schema !== REQUIRES) return null;

  const site = index.site(key);
  if (!site) return null;

  const opts = options || {};
  const voltageKv = Number.isFinite(opts.voltageKv) ? opts.voltageKv : null;

  const nodes = graph.nodesOfSite(site.code)
    .filter((name) => voltageKv == null || graph.nodeVoltageKv(name) === voltageKv);

  const circuits = [];
  const seen = new Set();
  for (const nodeName of nodes) {
    for (const entry of graph.edgesAt(nodeName)) {
      if (entry.kind !== 'circuit') continue;
      const far = entry.row[entry.far];
      const id = [nodeName, far].sort().join('|');
      if (seen.has(id)) continue;
      seen.add(id);
      const { published, absent } = seasonsOf(entry.row);
      if (!Object.keys(published).length) continue;
      circuits.push({
        from_node: nodeName,
        to_node: far,
        to_site_code: graph.nodeSiteCode(far) || null,
        voltage_kv: graph.nodeVoltageKv(nodeName),
        circuit_type: typeof entry.row.circuit_type === 'string' ? entry.row.circuit_type : null,
        ohl_km: Number.isFinite(entry.row.ohl_km) ? entry.row.ohl_km : null,
        cable_km: Number.isFinite(entry.row.cable_km) ? entry.row.cable_km : null,
        ratings_mva: published,
        seasons_not_published: absent,
        flags: flagsFor(published),
        parameters_pct_100mva: graph.parametersOf(entry.row)
      });
    }
  }

  circuits.sort((a, b) => String(a.to_node).localeCompare(String(b.to_node)));

  /* The per-season RANGE across circuits — a lowest and a highest rating,
     which are two real published values — never a sum, and never a
     mean, which would be a number no circuit is rated at. */
  const by_season = {};
  for (const season of SEASONS) {
    const values = circuits
      .filter((c) => Number.isFinite(c.ratings_mva[season])
        && c.ratings_mva[season] < IMPLAUSIBLE_MVA)
      .map((c) => c.ratings_mva[season]);
    const excluded = circuits
      .filter((c) => Number.isFinite(c.ratings_mva[season])
        && c.ratings_mva[season] >= IMPLAUSIBLE_MVA).length;
    by_season[season] = values.length
      ? {
        lowest_circuit_mva: Math.min.apply(null, values),
        highest_circuit_mva: Math.max.apply(null, values),
        circuits: values.length,
        excluded_as_implausible: excluded
      }
      : { circuits: 0, excluded_as_implausible: excluded, published: false };
  }

  const flagged = circuits.filter((c) => c.flags.length);
  const missingSeasons = circuits.filter((c) => c.seasons_not_published.length);

  return {
    schema: SCHEMA,
    site: { code: site.code, name: site.name },
    requested_voltage_kv: voltageKv,
    scope: voltageKv == null
      ? 'every voltage at this site; a range across two busbar voltages '
        + 'is a number about neither of them'
      : voltageKv + ' kV nodes at this site only',
    circuits,
    by_season,
    counts: {
      circuits: circuits.length,
      with_a_flagged_value: flagged.length,
      with_a_season_not_published: missingSeasons.length
    },
    never_summed: NEVER_SUMMED,
    not_a_capacity: NOT_A_CAPACITY
  };
}

export const schema = SCHEMA;
export const requires = REQUIRES;

Site Tile

A JavaScript module in Ventus Grid Engine that works with floor to (`floorTo`) and cell centre (`cellCentre`) and calculates planar distances, using EPSG:27700 and SHA-256.

geodesyventus-grid-engine / engine/site-tile.js · lines 1–166 of 166 · Entry point · pattern cellCentre (shared by 2 files)

What it does
It calculates its inputs. Defines 12 functions or classes, including floorTo, tileOf, tilesForBox, tilesForRoute, add.
Inputs & outputs
Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid).
Downstream impact
Used directly by 1 file: Site Tile Proof (ventus-grid-engine).
What it achieves
It is built from the floor to helper (`floorTo`), the tile of helper (`tileOf`) and the tiles for box helper (`tilesForBox`). NEW, not extracted. The code form of wireframe rule R5, "the site tile": stream the measured ground where you arrive; never download in bulk.
Why it matters
Imported by Site Tile Proof.
Application
ventus-grid-engine · engine · JavaScript module
VEDIC
ENUMERATE BOX TILES (GG2050-VEDIC-000077): Ventus Grid Engine · Geospatial and terrain intelligence. e0, n0, e1, n1 → Array of tile corners and sizes.
VEDIC
ENUMERATE ROUTE TILES (GG2050-VEDIC-000078): Ventus Grid Engine · Geospatial and terrain intelligence. points, halfWidth → Sorted unique terrain tiles.
VEDIC
LOCATE CELL CENTRE (GG2050-VEDIC-000079): Ventus Grid Engine · Geospatial and terrain intelligence. tile, col, row → Projected easting and northing pair.
Uses
none found
Used by
imported by Site Tile Proof (import)
Produces
schema, TILE_M, PRODUCTS, GAP_S, DAILY_CAP, BACKOFF_FIRST_S, BACKOFF_MAX_S, BASIS, tileOf, tilesForBox, tilesForRoute, cellCentre
Defines here
floorTo, tileOf, tilesForBox, tilesForRoute, add, cellCentre, tileKey, missingReceiptFields, schedule, backoff, groundUse, noMeasuredGround
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 engine/site-tile.js:1-166 · blob 6dbe091d0dd0c2b4ed294107668a2911c642bb6a · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: unknown · users: none · canonical: production_core
/**
 * Module: site-tile
 *
 * NEW, not extracted. The code form of wireframe rule R5, "the site tile":
 * stream the measured ground where you arrive; never download in bulk. The
 * full rule is docs/site-tile.md. Three independent witnesses (measurement,
 * logic, conformance) were each asked to refute it, and all three signed
 * version 2.
 *
 * What this module owns is the pure maths of that rule: which fixed 2,048 m
 * lattice tiles a site or a route touches, the key and receipt fields of a
 * tile, the polite schedule of requests, the refusal back-off, and the
 * survey-year test that decides whether heights may be scanned for an asset.
 *
 * Depends on: nothing. Pure arithmetic on British National Grid metres
 * (EPSG:27700). No network and no DOM: the fetcher belongs to the client
 * (README: "engine/ — the pure maths, no DOM, no network").
 */

export const schema = 'gridatlas.module.site-tile.v1';

/** Rule 1: fixed tiles on a lattice of this pitch, in metres. */
export const TILE_M = 2048;

/** Rule 2: the products asked for, once each per tile per visit. */
export const PRODUCTS = Object.freeze(['dtm', 'dsm']);

/** Rule 3: pace. At least GAP_S seconds between requests to a public service. */
export const GAP_S = 40;

/** Rule 3: at most this many requests per client per day. A chosen cap, not a measured limit. */
export const DAILY_CAP = 16;

/** Rule 3: the first pause after a refusal, and the longest. */
export const BACKOFF_FIRST_S = 300;
export const BACKOFF_MAX_S = 3600;

/**
 * Where the numbers come from. The pace is derived from an observed refusal,
 * not chosen for convenience; the tile sizes were measured by one request each.
 */
export const BASIS = Object.freeze({
    refusal: Object.freeze({ requests: 10, within_s: 180, mean_spacing_s: 18,
        note: 'the service refused a client after about ten requests in three minutes' }),
    gap_over_refusal_spacing: 40 / 18,
    measured: Object.freeze({
        dtm_2048_http: 200, dtm_2048_bytes: 16777763, dtm_2048_cells: 4194304,
        dtm_4096_http: 200, dtm_4096_bytes: 67109795, dtm_4096_cells: 16777216,
        dsm_bytes: null,
        date: '2026-09-27',
    }),
    daily_cap: 'chosen, not measured',
});

const floorTo = (x, m) => Math.floor(x / m) * m;

/** Rule 1: the tile that contains the point (e, n). The tile corner is a cell corner. */
export function tileOf(e, n) {
    if (!Number.isFinite(e) || !Number.isFinite(n)) throw new RangeError('tileOf: e and n must be finite metres');
    return { e0: floorTo(e, TILE_M), n0: floorTo(n, TILE_M), size: TILE_M };
}

/** Rule 1: every tile a box (e0, n0)-(e1, n1) touches, west to east, then south to north. */
export function tilesForBox(e0, n0, e1, n1) {
    const a = tileOf(Math.min(e0, e1), Math.min(n0, n1));
    const b = tileOf(Math.max(e0, e1), Math.max(n0, n1));
    const out = [];
    for (let n = a.n0; n <= b.n0; n += TILE_M)
        for (let e = a.e0; e <= b.e0; e += TILE_M) out.push({ e0: e, n0: n, size: TILE_M });
    return out;
}

/**
 * Rule 1: every tile a route touches, where the route is a polyline of [e, n]
 * points with an optional half-width either side, in metres. Each segment is
 * sampled at a quarter of a tile or finer, so no tile the line crosses is
 * missed; the half-width widens each sample to a small box.
 */
export function tilesForRoute(points, halfWidth = 0) {
    if (!Array.isArray(points) || points.length === 0) return [];
    const seen = new Map();
    const add = (e, n) => {
        for (const t of tilesForBox(e - halfWidth, n - halfWidth, e + halfWidth, n + halfWidth))
            seen.set(t.e0 + ',' + t.n0, t);
    };
    add(points[0][0], points[0][1]);
    for (let i = 1; i < points.length; i++) {
        const [ea, na] = points[i - 1], [eb, nb] = points[i];
        const steps = Math.max(1, Math.ceil(Math.hypot(eb - ea, nb - na) / (TILE_M / 4)));
        for (let s = 1; s <= steps; s++) add(ea + (eb - ea) * s / steps, na + (nb - na) * s / steps);
    }
    return [...seen.values()].sort((p, q) => p.n0 - q.n0 || p.e0 - q.e0);
}

/** The centre of cell (col, row) of a tile, counted from the south-west corner: e0 + col + 0.5. */
export function cellCentre(tile, col, row) {
    return [tile.e0 + col + 0.5, tile.n0 + row + 0.5];
}

/** Rule 4: the key a tile is known by, for one product. */
export function tileKey(product, tile) {
    if (!PRODUCTS.includes(product)) throw new RangeError('tileKey: unknown product ' + product);
    return `${product}/${tile.e0}/${tile.n0}/${tile.size}`;
}

/** Rule 4 and 8: the fields a receipt must carry. The sha256 is of the decoded cell values, not the file bytes. */
export const RECEIPT_FIELDS = Object.freeze(['source', 'product', 'release', 'survey_year', 'tile', 'request',
    'fetched_utc', 'sha256_cells', 'licence', 'attribution']);

/** The receipt fields that are missing or empty. survey_year may be null, but it must be present. */
export function missingReceiptFields(receipt) {
    return RECEIPT_FIELDS.filter(f => !(receipt && f in receipt)
        || (f !== 'survey_year' && (receipt[f] === '' || receipt[f] == null)));
}

/**
 * Rules 2, 3 and 5: turn the tiles a visit needs into a request schedule.
 * Tiles with a stored wireframe or a live receipt are skipped (stored first).
 * Requests are GAP_S apart, and the plan stops at the daily cap and names
 * what it could not fetch, rather than fetching it later without saying so.
 */
export function schedule(tiles, { products = PRODUCTS, have = new Set(), usedToday = 0, startS = 0 } = {}) {
    const requests = [], missing = [], skipped = [];
    let used = usedToday, at = startS;
    const asked = new Set();
    for (const t of tiles) for (const p of products) {
        const key = tileKey(p, t);
        if (asked.has(key)) continue;
        asked.add(key);
        if (have.has(key)) { skipped.push(key); continue; }
        if (used >= DAILY_CAP) { missing.push(key); continue; }
        requests.push({ key, product: p, tile: t, at_s: at });
        used += 1; at += GAP_S;
    }
    return { requests, skipped, missing, stopped_at_cap: missing.length > 0 };
}

/** Rule 3: the pause after the n-th refusal in a row, or 'stop' once the longest pause has been refused. */
export function backoff(refusals) {
    if (!Number.isInteger(refusals) || refusals < 0) throw new RangeError('backoff: refusals must be a count');
    if (refusals === 0) return 0;
    const s = BACKOFF_FIRST_S * 2 ** (refusals - 1);
    if (s <= BACKOFF_MAX_S) return s;
    const prev = BACKOFF_FIRST_S * 2 ** (refusals - 2);
    return prev < BACKOFF_MAX_S ? BACKOFF_MAX_S : 'stop';
}

/**
 * Rule 9: may the heights be scanned for the asset? Only when the survey
 * postdates the build. Same year, earlier, or either year unknown means the
 * heights are the ground before the asset: good for piles, earthworks,
 * drainage and slope, never scanned for rows.
 */
export function groundUse({ surveyYear = null, buildYear = null } = {}) {
    if (!Number.isInteger(surveyYear) || !Number.isInteger(buildYear)) return 'pre-construction ground';
    return surveyYear > buildYear ? 'as built' : 'pre-construction ground';
}

/**
 * Rule 10: "no measured ground here", never 0 m. True for an HTTP error, a
 * box outside the envelope, exact zeros with no nodata tag, or a run of exact
 * zeros.
 */
export function noMeasuredGround({ http = 200, outsideEnvelope = false, allZeroUntagged = false, zeroRun = false } = {}) {
    return http !== 200 || outsideEnvelope || allZeroUntagged || zeroRun;
}

Ventus Grid Engine — Genome Page

A web page that draws maths provenance, engine graph, battery storage (BESS) and solar, using haversine and SHA-256. Published at https://ventusltd.github.io/ventus-grid-engine/genome/.

renderventus-grid-engine / genome/index.html · lines 1–359 of 412 · Entry point · pattern loadLive (shared by 2 files)

What it does
It draws maths provenance, engine graph, battery storage (BESS) and solar. Defines 20 functions or classes, including rebuildSelect, actionable, openUrl, handleTap, neighbours. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain terms in the code: battery storage (BESS), solar.
Inputs & outputs
In: JSON file engine-graph.json; form fields (user input). Out: web page; SVG drawing.
Downstream impact
It is itself an entry point, published at https://ventusltd.github.io/ventus-grid-engine/genome/.
What it achieves
It rebuilds select (`rebuildSelect`), opens URL (`openUrl`) and sets hint (`setHint`). Defines `rebuildSelect`, `actionable`, `openUrl` and 17 more. Its code works with 211.2 MW and 52.8 MW. It reads `./engine-graph.json`. It responds to change and click events.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
ventus-grid-engine · genome · page
Uses
Geo Core (estate URL), Geo Area (estate URL), Geo Shapes (estate URL), Geo GeoJSON (estate URL), V9 Geodesy (estate URL), V9 Nearest Search (estate URL), Contract (estate URL), Network Topology (estate URL), and 23 more
Used by
none found
Produces
rebuildSelect, actionable, openUrl, handleTap, neighbours, evidenceHTML, cardInner, goLabel, setHint, setCrumbs, draw, drawColumn
Defines here
rebuildSelect, actionable, openUrl, handleTap, neighbours, evidenceHTML, cardInner, goLabel, setHint, setCrumbs, draw, drawColumn, section, marker, distribute, drawSpider, enableDragPan
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 genome/index.html:1-359 · blob fdad5aa9c37e96d039740f426d54667ae03f79d8 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom, network · domain stage: unknown · 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 Grid Engine · The Genome Sandbox</title>
<style>
  :root{
    --bg:#0b0d12;--panel:#12151c;--panel2:#151923;--line:#262b36;--text:#eef2fb;--muted:#9aa3b5;--cyan:#00e5ff;
    --e-duplicates:#ffcc00;--e-supersedes:#00ff88;--e-imports:#00e5ff;--e-should_import:#b47cff;--e-drifts_from:#ff5555;
    --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}
  .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}
  .evi{font-size:.62rem;color:var(--muted);line-height:1.35;border-left:2px solid var(--line);padding-left:7px;margin-top:1px}
  .evi b{color:var(--text);font-weight:600}
  .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}
  .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}
  .fixedLegend{width:100%;box-sizing:border-box;flex:none;padding:6px var(--safe-x) max(env(safe-area-inset-bottom),10px);display:flex;flex-wrap:wrap;gap:5px 14px;font-family:ui-monospace,monospace;font-size:.58rem;letter-spacing:.04em;text-transform:uppercase;color:var(--muted);border-top:1px solid var(--line);max-height:34vh;overflow-y:auto}
  .fixedLegend span{display:flex;align-items:center;gap:6px;flex:none;white-space:nowrap}
  .fixedLegend i{width:15px;height:0;border-top:2px solid;display:inline-block;flex:none}
  @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>
</head>
<body>
  <div class="top">
    <div class="bar">
      <div class="brand"><span class="ey">Ventus · Grid Engine</span><h1>The Genome 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 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="No live scanner behind this snapshot — the graph is regenerated by CI, not scanned at view time">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>
  <div class="fixedLegend" id="fixedLegend"></div>

  <script id="graph-data" type="application/json">{"schema":"ventus-grid-engine.genome.v1","label":"ventus-grid-engine genome · the spider pattern applied to the engine’s own maths","generated_utc":"2026-09-04T21:06:53.448Z","note":"Nodes and edges match the node shape used by the live Spider Sandbox (data-federation-map-for-globalgrid2050-all-repos/dashboard/sandbox/spider_full_po_test.html: SCOP  … [line shortened here: 27,857 characters; full line on GitHub]
  <script>
(function(){
"use strict";

const RAG = { green:"#00ff88", amber:"#ffcc00", red:"#ff5555", blue:"#3aa0ff", grey:"#9298a6" };
const BADGE = { canonical:"ENG", extract:"STG", fragment:"FRAG", reference:"REF" };
const ECSS = { duplicates:"#ffcc00", supersedes:"#00ff88", imports:"#00e5ff", should_import:"#b47cff", drifts_from:"#ff5555" };
const REL  = { duplicates:"duplicates", supersedes:"supersedes", imports:"imports", should_import:"should import", drifts_from:"drifts from" };
const SVGNS = "http://www.w3.org/2000/svg";

let GRAPH = null;        // { label, nodes:[...], edges:[{from,to,type,evidence}] }
let mode = "both", action = "explore", view = "column", current = 0;

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"), fixedLegend = document.getElementById("fixedLegend");

function rebuildSelect(){
  sel.innerHTML = "";
  GRAPH.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 = GRAPH.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 neighbours(idx){
  const out = [], inc = [];
  GRAPH.edges.forEach(e => {
    if (e.from === idx) out.push({ other: e.to, type: e.type, evidence: e.evidence });
    if (e.to === idx) inc.push({ other: e.from, type: e.type, evidence: e.evidence });
  });
  return { out, inc };
}

function evidenceHTML(evidence){
  if (!evidence) return "";
  const file = String(evidence.file || "").replace(/&/g,"&amp;").replace(/</g,"&lt;");
  const lines = String(evidence.lines || "").replace(/&/g,"&amp;").replace(/</g,"&lt;");
  const method = String(evidence.method || "").replace(/&/g,"&amp;").replace(/</g,"&lt;");
  return `<div class="evi"><b>${file}</b>${lines ? ` : ${lines}` : ""}<br>${method}</div>`;
}

function cardInner(node, opts){
  opts = opts || {};
  const center = opts.center, rel = opts.rel, dim = opts.dim;
  let relHTML = "";
  if (rel) {
    const c = ECSS[rel.type] || "#9298a6";
    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>`
      + evidenceHTML(rel.evidence);
  }
  const name = String(node.label || "").replace(/&/g,"&amp;").replace(/</g,"&lt;");
  const reason = String(node.reason || "").replace(/&/g,"&amp;").replace(/</g,"&lt;");
  return `<div class="card${center ? " is-center" : ""}${dim ? " inert" : ""}">`
    + `<div class="row"><span class="badge">${BADGE[node.type] || "FRAG"}</span><span class="name">${name}</span>`
    + `<span class="dot" style="color:${RAG[node.rag] || RAG.grey}"></span></div>`
    + `${center ? `<div class="reason">${reason}</div>` : ""}`
    + relHTML
    + `${!rel && opts.go ? `<span class="go">${opts.go}</span>` : ""}`
    + `</div>`;
}
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.",
    github: "<b>GitHub</b> — tap a card to open its file on GitHub. Cards with no link are dimmed.",
    external: "<b>External</b> — no node in this genome is an external system; every card is dimmed in this mode."
  };
  elHint.innerHTML = (base[action] || "") + (view === "spider" ? " &nbsp; <b>Spider view</b> — scroll or drag the large canvas." : "");
}
function setCrumbs(){
  elCrumbs.innerHTML = `<strong style="color:var(--text)">${GRAPH.label}</strong>`;
}

function draw(){
  const nodes = GRAPH.nodes, focus = nodes[current];
  const { out, inc } = neighbours(current);
  const 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);
}

function drawColumn(focus, out, inc){
  const nodes = GRAPH.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.createElement("div"); e.className = "empty"; e.textContent = "None"; s.appendChild(e); return s; }
    const br = document.createElement("div"); br.className = "branch";
    items.forEach(it => {
      const node = nodes[it.other], dim = !actionable(node);
      const t = document.createElement("div"); t.className = "twig";
      t.style.setProperty("--twig", ECSS[it.type] || "#9298a6");
      t.innerHTML = cardInner(node, { rel: { type: it.type, dir, evidence: it.evidence }, dim, go: goLabel(node) });
      t.addEventListener("click", () => handleTap(it.other));
      br.appendChild(t);
    });
    s.appendChild(br); return s;
  };
  if (mode !== "in") shell.appendChild(section("Depends on →", out, "out"));
  if (mode !== "out") shell.appendChild(section("← Depended on by", inc, "in"));
  overlay.appendChild(shell);
  shell.querySelector(".focuswrap .card").addEventListener("click", () => handleTap(current));
}

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[type] || "#9298a6");
  m.appendChild(p); defs.appendChild(m);
}
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 Object.assign({}, 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 = [].concat(distribute(out, 1, cx, cy, gap, xGap), distribute(inc, -1, cx, cy, gap, xGap));
  const canvas = document.createElement("div"); canvas.className = "spiderCanvas";
  canvas.style.width = cw + "px"; canvas.style.height = ch + "px";
  canvas.innerHTML = `<div class="spiderGrid"></div><div class="maphint">🕷 Optional spider view. Cards keep their size; the canvas grows. Drag or scroll through the space.</div>`;
  const svg = document.createElementNS(SVGNS, "svg"); svg.setAttribute("class", "wires"); svg.setAttribute("viewBox", `0 0 ${cw} ${ch}`);
  const defs = document.createElementNS(SVGNS, "defs");
  Array.from(new Set(pts.map(p => p.type))).forEach(t => marker(defs, t));
  svg.appendChild(defs);
  pts.forEach(p => {
    const line = document.createElementNS(SVGNS, "line");
    const from = p.dir === "out" ? { x: cx + 130, y: cy } : p;
    const to = p.dir === "out" ? { x: p.x - 112, y: p.y } : { x: cx - 130, y: cy };
    line.setAttribute("x1", from.x); line.setAttribute("y1", from.y);
    line.setAttribute("x2", to.x); line.setAttribute("y2", to.y);
    line.setAttribute("stroke", ECSS[p.type] || "#9298a6"); line.setAttribute("class", "spoke");
    line.setAttribute("marker-end", `url(#arr-${p.type})`);
    svg.appendChild(line);
  });
  canvas.appendChild(svg);
  const center = document.createElement("div"); center.className = "place center";
  center.style.left = cx + "px"; center.style.top = cy + "px";
  center.dataset.idx = String(current);
  center.innerHTML = cardInner(focus, { center: true, dim: !actionable(focus), go: goLabel(focus) });
  canvas.appendChild(center);
  center.querySelector(".card").addEventListener("click", () => handleTap(current));
  const nodes = GRAPH.nodes;
  pts.forEach(p => {
    const node = nodes[p.other], dim = !actionable(node);
    const el = document.createElement("div"); el.className = "place";
    el.style.left = p.x + "px"; el.style.top = p.y + "px";
    el.dataset.idx = String(p.other);
    el.innerHTML = cardInner(node, { rel: { type: p.type, dir: p.dir, evidence: p.evidence }, dim, go: goLabel(node) });
    el.addEventListener("click", () => handleTap(p.other));
    canvas.appendChild(el);
  });
  const legend = document.createElement("div"); legend.className = "legend";
  Array.from(new Set(pts.map(p => p.type))).sort().forEach(t => {
    const s = document.createElement("span");
    s.innerHTML = `<i style="border-color:${ECSS[t] || "#9298a6"}"></i>${REL[t] || t}`;
    legend.appendChild(s);
  });
  canvas.appendChild(legend);
  overlay.appendChild(canvas);
  requestAnimationFrame(() => {
    overlay.scrollLeft = Math.max(0, cx - sw / 2);
    overlay.scrollTop = Math.max(0, cy - sh / 2);
    enableDragPan(overlay);
  });
}
// Drag-to-pan the spider canvas, without breaking a plain tap-to-recentre.
//
// setPointerCapture() retargets the click a browser synthesises after
// pointerup to the capturing element rather than whatever the pointer is
// actually over — verified against this page: capturing on pointerdown
// unconditionally made every card in spider view unclickable, even a tap
// with zero movement. The fix is to defer capture until real dragging is
// detected (movement past a small threshold), so a plain tap never
// captures the pointer and its native click reaches the card underneath
// exactly as drawColumn's cards already do.
function enableDragPan(el){
  const DRAG_PX = 6;
  let down = false, dragging = false, sx = 0, sy = 0, sl = 0, st = 0, pid = null;
  el.onpointerdown = e => {
    if (e.target.closest("button,select")) return;
    down = true; dragging = false; sx = e.clientX; sy = e.clientY;
    sl = el.scrollLeft; st = el.scrollTop; pid = e.pointerId;
  };
  el.onpointermove = e => {
    if (!down) return;
    const dx = e.clientX - sx, dy = e.clientY - sy;
    if (!dragging && Math.hypot(dx, dy) >= DRAG_PX) {
      dragging = true; el.classList.add("dragging");
      try { el.setPointerCapture(pid); } catch (_) {}
    }
    if (dragging) { el.scrollLeft = sl - dx; el.scrollTop = st - dy; }
  };
  el.onpointerup = e => {
    down = false; el.classList.remove("dragging");
    if (dragging) { try { el.releasePointerCapture(e.pointerId); } catch (_) {} }
    dragging = false;