GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Websites and apps / globalgrid2050 / testcode/202609141754/code-navigation

Corporate and 4 more files

A JavaScript module in the testcode folder of GlobalGrid2050 that works with graph title (`graphTitle`) and graph description (`graphDescription`).

641 lines of JavaScript and HTML from globalgrid2050, in 5 files. Topic: Websites and apps. Section 1972 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. Testcode — Code Navigation render · globalgrid2050 / testcode/202609141754/code-navigation/core.js lines 1–182
  2. Testcode — Code Navigation Page render · globalgrid2050 / testcode/202609141754/code-navigation/index.html lines 1–17
  3. Navigation interaction · globalgrid2050 / testcode/202609141754/code-navigation/navigation.js lines 1–115
  4. Testcode — Code Record Page render · globalgrid2050 / testcode/202609141754/code-record/index.html lines 1–144
  5. Corporate transform · globalgrid2050 / testcode/202609141754/corporate.js lines 1–183

Testcode — Code Navigation

A JavaScript file in GlobalGrid2050 that draws blocks, families and names, and uses data from raw.githubusercontent.com and the stars repository. Served with the page at https://globalgrid2050.com/testcode/202609141754/code-navigation/.

renderglobalgrid2050 / testcode/202609141754/code-navigation/core.js · lines 1–182 of 182 · version 2026-09-14 17:54 · Entry point · pattern showFamilyPanel (shared by 2 files)

What it does
It draws blocks, families and names. Defines 33 functions or classes, including CORP_BASE, say, sayType, pageLink, $. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage experimental (path word 'testcode'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. README: "Wording: every data-derived string passes through `../corporate.js` (via `say()`, `sayType()` and `pageLink()` in `core.js`)."
Inputs & outputs
In: data source: raw.githubusercontent.com; data source: stars data; JSON file blocks.json; JSON file families.json; JSON file index.json; JSON file names.json.
Downstream impact
Used directly by 1 file: Testcode — Code Navigation Page (globalgrid2050, https://globalgrid2050.com/testcode/202609141754/code-navigation/). It is itself an entry point, published at https://globalgrid2050.com/testcode/202609141754/code-navigation/.
What it achieves
It gets JSON (`getJSON`), loads universe (`loadUniverse`) and renders trail (`renderTrail`). GlobalGrid2050 code reader core (public copy of `testcode/202609141423/core.js`). It responds to input events.
Why it matters
Loaded by the page of the same name at https://globalgrid2050.com/testcode/202609141754/code-navigation/.
Application
globalgrid2050 · testcode/202609141754/code-navigation · script
Uses
Stars — Index Page (estate URL)
Used by
loaded by Testcode — Code Navigation Page (script src)
Produces
CORP_BASE, say, sayType, pageLink, $, esc, el, getJSON, fail, loadUniverse, catColour, catTitle
Defines here
CORP_BASE, say, sayType, pageLink, $, esc, el, getJSON, fail, loadUniverse, catColour, catTitle, catName, blockTitle, blockDesc, blockLabel, blockFamilies, blockDeps, blockUsers, blockPage, countsLine, family, familyLines, familyLinks, famName, famKind, trailPush, renderTrail, showFamilyPanel, rel
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 testcode/202609141754/code-navigation/core.js:1-182 · blob 4ab97dabfd0296b53ffa7fcc1ea6961b8af46fa1 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: experimental · users: none · canonical: production_core
/* GlobalGrid2050 code reader core (public copy of testcode/202609141423/core.js).
 * Reads live data (all served with Access-Control-Allow-Origin: *):
 *   <data>/blocks/blocks.json     named blocks and categories
 *   <data>/blocks/families.json   block or unnamed group -> family numbers
 *   <data>/code/index.json        counts
 *   <data>/code/f/<n/500>.json    family records (lines[], uses[], used_by[], places[])
 *   <data>/code/names.json        name -> family numbers
 *   raw.githubusercontent.com     the text of a family's lines at its pinned commit
 * Wording: ../corporate.js is loaded before this file. Every data-derived string that reaches the screen goes
 * through say() / sayType(), and every origin page link through pageLink(), below.
 */
const STARS = 'https://ventusltd.github.io/stars/';
const U = { blocks: null, cats: [], groups: null, index: null, names: null, famToGroup: new Map(), buckets: new Map(), texts: new Map(), trail: [] };
const REL = { contains: '#8b93a7', 'depends on': '#ffd54a', uses: '#00e5ff', 'used by': '#ff7ab6', 'shared line': '#39d353' };

/* ---- public wording choke point ---- */
const CORP = (typeof window !== 'undefined' && window.Corporate) || null;
// Corporate.link() returns page addresses relative to a page one folder below corporate.js; resolve them from there.
const CORP_BASE = (() => { const s = [...document.scripts].find(x => /(^|\/)corporate\.js([?#]|$)/.test(x.src)); return s ? new URL('page/', s.src).href : location.href; })();
const say = (s, type) => (CORP && s != null ? CORP.label(String(s), type) : s);
const sayType = t => (CORP && t != null ? CORP.type(t) : t);
function pageLink(url) { if (!url) return url; const v = CORP ? CORP.link(url) : url; try { return new URL(v, CORP_BASE).href; } catch { return v; } }

const $ = (s, r = document) => r.querySelector(s);
const esc = s => String(s ?? '').replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
function el(tag, attrs = {}, ...kids) {
  const e = document.createElement(tag);
  for (const [k, v] of Object.entries(attrs)) { if (k === 'on') for (const [ev, fn] of Object.entries(v)) e.addEventListener(ev, fn); else if (k === 'html') e.innerHTML = v; else if (v != null) e.setAttribute(k, v); }
  for (const k of kids.flat()) if (k != null) e.append(k.nodeType ? k : document.createTextNode(k));
  return e;
}
async function getJSON(url) {
  const r = await fetch(url, { cache: 'default' });
  if (!r.ok) throw new Error(`${url} returned HTTP ${r.status}`);
  return r.json();
}
function fail(where, err) {
  const box = $(where) || document.body;
  box.prepend(el('div', { class: 'u-fail' }, `Could not load live data: ${err.message}. Check the internet connection and reload.`));
}

/* ---- data ---- */
async function loadUniverse() {
  const [b, groups, index, names] = await Promise.all([getJSON(STARS + 'blocks/blocks.json'), getJSON(STARS + 'blocks/families.json'), getJSON(STARS + 'code/index.json'), getJSON(STARS + 'code/names.json')]);
  U.blocks = b.blocks; U.cats = b.categories; U.groups = groups; U.index = index; U.names = names;
  U.bySym = new Map(U.blocks.map(x => [x.symbol, x]));
  for (const [g, fams] of Object.entries(groups)) for (const n of fams) if (!U.famToGroup.has(n)) U.famToGroup.set(n, g);
  U.catOf = new Map(U.cats.map(c => [c.id, c]));
  U.unnamed = Object.keys(groups).filter(g => !U.bySym.has(g));
  return U;
}
const catColour = id => (U.catOf.get(id) || {}).colour || '#8b93a7';
const catTitle = id => say((U.catOf.get(id) || {}).title || id);
const catName = c => say(c && c.title);
const blockTitle = b => say(b && b.title);
const blockDesc = b => say((b && b.description) || '');
function blockLabel(sym) { const b = U.bySym.get(sym); return b ? `${sym} · ${blockTitle(b)}` : `Group ${sym} (not yet named)`; }
function blockFamilies(sym) { return U.groups[sym] || []; }
function blockDeps(sym) { const b = U.bySym.get(sym); return b ? (b.depends_on || []).map(d => d.symbol || d).filter(s => U.bySym.has(s) || U.groups[s]) : []; }
function blockUsers(sym) { const b = U.bySym.get(sym); return b ? (b.used_by || []).filter(s => U.bySym.has(s) || U.groups[s]) : []; }
function blockPage(sym) { return pageLink(`${STARS}table.html?block=${encodeURIComponent(sym)}`); }
function countsLine() { return `${U.blocks.length} named blocks · ${U.unnamed.length} unnamed groups · ${U.index.families.toLocaleString('en-GB')} function families · ${U.index.lines.toLocaleString('en-GB')} unique numbered lines`; }

async function family(n) {
  const b = Math.floor(n / (U.index.bucket_size || 500));
  if (!U.buckets.has(b)) U.buckets.set(b, getJSON(`${STARS}code/f/${b}.json`));
  const bucket = await U.buckets.get(b);
  return bucket[String(n)] || null;
}
async function familyLines(rec) {
  const p = (rec.places || [])[0];
  if (!p) return rec.lines.map(k => ({ key: k, text: '(no place recorded)' }));
  const id = `${p.repo}@${p.commit}:${p.path}`;
  if (!U.texts.has(id)) U.texts.set(id, fetch(`https://raw.githubusercontent.com/${p.repo}/${p.commit}/${p.path.split('/').map(encodeURIComponent).join('/')}`).then(r => { if (!r.ok) throw new Error(`GitHub returned HTTP ${r.status}`); return r.text(); }).then(t => t.split('\n')));
  const all = await U.texts.get(id);
  const src = all.slice(p.first - 1, p.last);
  return rec.lines.map((k, i) => ({ key: k, text: src[i] ?? '' }));
}
function familyLinks(rec, n) {
  const p = (rec.places || [])[0];
  return {
    page: pageLink(`${STARS}code.html?family=${n}`),
    gh: p ? `https://github.com/${p.repo}/blob/${p.commit}/${p.path}#L${p.first}-L${p.last}` : null,
    live: pageLink((rec.places || []).map(x => x.live).find(Boolean) || null),
  };
}
const famName = rec => (rec && rec.names && rec.names[0]) || 'unnamed';  // function names are code identifiers: shown as recorded
const famKind = rec => sayType((rec && rec.kind) || 'code');

/* ---- navigation trail: shows where the reader has been ---- */
function trailPush(kind, id, label) {
  const last = U.trail[U.trail.length - 1];
  if (last && last.kind === kind && last.id === id) return;
  U.trail.push({ kind, id, label }); renderTrail();
}
function renderTrail() {
  const t = $('#trail'); if (!t) return;
  t.innerHTML = '';
  t.append(el('a', { href: '#', on: { click: e => { e.preventDefault(); U.trail = []; renderTrail(); window.goHome && window.goHome(); } } }, 'GLOBALGRID2050'));
  U.trail.forEach((s, i) => {
    t.append(' › ', el('a', { href: '#', on: { click: e => { e.preventDefault(); U.trail = U.trail.slice(0, i + 1); renderTrail(); window.goTo && window.goTo(s.kind, s.id); } } }, s.label));
  });
}

/* ---- the shared family panel: numbered lines and every relationship ---- */
async function showFamilyPanel(n, host, onFamily, onBlock) {
  host.innerHTML = '<div class="u-muted">Loading family #' + n + '…</div>';
  let rec;
  try { rec = await family(n); } catch (e) { host.innerHTML = ''; host.append(el('div', { class: 'u-fail' }, `Could not load family #${n}: ${e.message}`)); return; }
  if (!rec) { host.innerHTML = `<div class="u-fail">Family #${n} is not in the published records.</div>`; return; }
  trailPush('family', n, `#${n} ${famName(rec)}`);
  const g = U.famToGroup.get(n); const L = familyLinks(rec, n);
  host.innerHTML = '';
  host.append(
    el('div', { class: 'u-h' }, `#${n} ${famName(rec)}`),
    el('div', { class: 'u-muted' }, `${famKind(rec)} · ${rec.lines.length} numbered lines · in ${rec.repos.length} repositories · ${rec.standalone ? 'self-contained' : 'needs context'}`),
    el('div', { class: 'u-links' },
      g ? el('button', { class: 'u-chip', style: `border-color:${REL.contains}`, on: { click: () => onBlock(g) } }, `◂ contained in ${blockLabel(g)}`) : null,
      el('a', { class: 'u-chip', href: L.page, target: '_blank', rel: 'noopener' }, 'Function page ↗'),
      L.gh ? el('a', { class: 'u-chip', href: L.gh, target: '_blank', rel: 'noopener' }, 'File at commit ↗') : null,
      L.live ? el('a', { class: 'u-chip live', href: L.live, target: '_blank', rel: 'noopener' }, 'Live page ↗') : null),
  );
  const rel = (title, list, colour) => {
    if (!list.length) return;
    host.append(el('div', { class: 'u-sub', style: `color:${colour}` }, `${title} (${list.length})`));
    host.append(el('div', { class: 'u-links' }, list.slice(0, 40).map(u => el('button', { class: 'u-chip', style: `border-color:${colour}`, on: { click: () => onFamily(u.family) } }, `#${u.family} ${u.name || ''}`)), list.length > 40 ? el('span', { class: 'u-muted' }, ` and ${list.length - 40} more`) : null));
  };
  rel('→ uses', rec.uses || [], REL.uses);
  rel('← used by', rec.used_by || [], REL['used by']);
  host.append(el('div', { class: 'u-sub' }, 'Numbered lines (permanent keys)'));
  const pre = el('div', { class: 'u-code' }, 'Fetching the code at its pinned commit…'); host.append(pre);
  try {
    const rows = await familyLines(rec);
    pre.innerHTML = rows.map(r => `<div class="u-line"><span class="u-key">${r.key}</span> │ ${esc(r.text)}</div>`).join('');
  } catch (e) { pre.textContent = `The code could not be fetched (${e.message}); the line keys are ${rec.lines.join(', ')}.`; }
  // shared lines: other families in already-loaded buckets that carry the same line numbers
  const keys = new Set(rec.lines); const shared = new Map();
  for (const p of U.buckets.values()) { const bucket = await p.catch(() => ({})); for (const [m, r] of Object.entries(bucket)) { if (+m === n) continue; const hit = (r.lines || []).filter(k => keys.has(k)).length; if (hit) shared.set(+m, { family: +m, name: `${famName(r)} (${hit} shared)` }); } }
  rel('≡ shares numbered lines with (loaded records only)', [...shared.values()], REL['shared line']);
  return rec;
}

/* ---- search: a function name jumps to its family ---- */
function mountSearch(host, onFamily) {
  const input = el('input', { class: 'u-search', placeholder: 'Search a function name…', 'aria-label': 'Search a function name' });
  const hits = el('div', { class: 'u-hits' });
  input.addEventListener('input', () => {
    const q = input.value.trim().toLowerCase(); hits.innerHTML = '';
    if (q.length < 2) return;
    const found = Object.keys(U.names).filter(k => k.toLowerCase().includes(q)).sort((a, b) => a.length - b.length).slice(0, 12);
    for (const k of found) for (const n of U.names[k].slice(0, 3)) hits.append(el('button', { class: 'u-chip', on: { click: () => { hits.innerHTML = ''; input.value = ''; onFamily(n); } } }, `#${n} ${k}`));
    if (!found.length) hits.append(el('span', { class: 'u-muted' }, 'No function name contains that text.'));
  });
  host.append(input, hits);
}

function legend(host) {
  host.append(el('div', { class: 'u-legend' }, Object.entries(REL).map(([k, c]) => el('span', {}, el('i', { style: `background:${c}` }), sayType(k)))));
}
function footer(id) {
  document.body.append(el('footer', { class: 'u-foot' }, `${id} · built ${window.BUILT || ''} UTC · live data: ${STARS}blocks/, ${STARS}code/, raw.githubusercontent.com · GLOBALGRID2050`));
}

/* ---- shared look ---- */
document.head.append(el('style', { html: `
:root{color-scheme:dark}
body{margin:0;padding:12px 16px 40px;background:#0b0d12;color:#d8dee9;font:14px/1.5 ui-monospace,Menlo,Consolas,monospace}
a{color:#00e5ff} h1{font-size:20px;margin:0;letter-spacing:.06em} .u-count{color:#7da0c8;font-size:12px;margin:2px 0 8px}
#trail{font-size:12px;margin:6px 0 10px;color:#8b93a7;overflow-wrap:anywhere} #trail a{color:#9fd8ff;text-decoration:none}
.u-fail{border:1px solid #ff5c5c;color:#ffb3b3;padding:8px 10px;border-radius:8px;margin:8px 0}
.u-muted{color:#8b93a7;font-size:12px} .u-h{font-size:16px;color:#eef2fb;margin:4px 0} .u-sub{margin:12px 0 4px;font-size:12px;text-transform:uppercase;letter-spacing:.06em}
.u-links{display:flex;flex-wrap:wrap;gap:6px;margin:6px 0}
.u-chip{background:#12151c;border:1px solid #385464;color:#eef2fb;padding:5px 9px;border-radius:14px;font:inherit;font-size:12px;cursor:pointer;text-decoration:none}
.u-chip:hover{border-color:#00e5ff} .u-chip.live{border-color:#39d353}
.u-code{background:#07090d;border:1px solid #1f2633;border-radius:8px;padding:8px;overflow:auto;max-height:55vh;font-size:12px}
.u-line{white-space:pre} .u-key{color:#ffd54a}
.u-search{width:100%;box-sizing:border-box;background:#12151c;border:1px solid #385464;color:#eef2fb;padding:8px 10px;border-radius:8px;font:inherit}
.u-hits{display:flex;flex-wrap:wrap;gap:6px;margin:6px 0}
.u-legend{display:flex;flex-wrap:wrap;gap:10px;font-size:11px;color:#8b93a7;margin:6px 0} .u-legend i{display:inline-block;width:14px;height:3px;margin-right:4px;vertical-align:middle}
.u-foot{margin-top:24px;color:#566079;font-size:11px;overflow-wrap:anywhere}
.u-panel{border:1px solid #2a3140;border-radius:10px;padding:10px;background:#0f1218;margin:10px 0}
` }));

Testcode — Code Navigation Page

A web page in GlobalGrid2050 that reads inputs for block filter and category. Published at https://globalgrid2050.com/testcode/202609141754/code-navigation/.

renderglobalgrid2050 / testcode/202609141754/code-navigation/index.html · lines 1–17 of 17 · version 2026-09-14 17:54 · Entry point

What it does
It draws its content. Uses libraries navigation.css. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage experimental (path word 'testcode'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
Inputs & outputs
In: form fields (user input). Out: web page.
Downstream impact
It is itself an entry point, published at https://globalgrid2050.com/testcode/202609141754/code-navigation/.
What it achieves
No statement of purpose was found in the file, a README line naming it, or its name.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
globalgrid2050 · testcode/202609141754/code-navigation · page
Uses
Corporate (script src), Testcode — Code Navigation (script src), Testcode — Code Map Page (link), Navigation (script src), navigation.css
Used by
none found
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 testcode/202609141754/code-navigation/index.html:1-17 · blob 5c272706edde3266c17d36cefeea83ce3572b8c1 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom · 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">
<title>GlobalGrid2050 · Code navigation prototype</title>
<script src="../corporate.js"></script><script src="core.js"></script><link rel="stylesheet" href="navigation.css">
</head>
<body>
<header><div class="eyebrow">CODE NAVIGATION / PROTOTYPE 11</div><h1>GLOBALGRID2050</h1><p>Follow a block into its code, relationships and source.</p><div id="count" class="u-count" role="status">Loading the published code records…</div></header>
<nav class="toolbar" aria-label="Page navigation"><button id="back" disabled>← Back</button><a href="#">All blocks</a><a href="../code-map/index.html">Code map, ten views</a><button id="copy">Copy this view</button><span id="copy-status" role="status"></span></nav>
<main>
<aside aria-label="Block navigator"><label for="block-filter">Find a block or group</label><input id="block-filter" type="search" placeholder="Name, symbol or group…"><label for="category">Category</label><select id="category"><option value="">All categories and groups</option></select><div id="blocks"></div></aside>
<section class="workspace"><div id="search"></div><div id="trail" aria-label="Current location"></div><div id="subject" aria-live="polite"><p>Choose a block to begin. Every group is available through the navigator.</p></div></section>
</main>
<footer>Read-only prototype · permanent keys from the code database · <a href="README.md">About this page</a></footer>
<script src="navigation.js"></script>
</body></html>

Navigation

A JavaScript file in the code navigation folder of GlobalGrid2050 that draws blocks (`drawBlocks`) and renders route (`renderRoute`). Served with the page at https://globalgrid2050.com/testcode/202609141754/code-navigation/.

interactionglobalgrid2050 / testcode/202609141754/code-navigation/navigation.js · lines 1–115 of 115 · version 2026-09-14 17:54 · Entry point · pattern relationList (shared by 2 files)

What it does
It lists and searches its content. Defines 12 functions or classes, including row, paged, draw, box, link. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage experimental (path word 'testcode'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. README: "`journey.css` and `journey.js` are published here as `navigation.css` and `navigation.js`, and the on-screen wording was rewritten in plain engineering language."
Downstream impact
Used directly by 1 file: Testcode — Code Navigation Page (globalgrid2050, https://globalgrid2050.com/testcode/202609141754/code-navigation/). It is itself an entry point, published at https://globalgrid2050.com/testcode/202609141754/code-navigation/.
What it achieves
It draws blocks (`drawBlocks`) and renders route (`renderRoute`). Reuses the published code reader (`core.js`). It responds to click, popstate and hashchange events.
Why it matters
Loaded by the Code Navigation page at https://globalgrid2050.com/testcode/202609141754/code-navigation/.
Application
globalgrid2050 · testcode/202609141754/code-navigation · script
Uses
none found
Used by
loaded by Testcode — Code Navigation Page (script src)
Produces
row, paged, draw, box, link, navigate, route, groupsFor, drawBlocks, relationList, renderRoute, start
Defines here
row, paged, draw, box, link, navigate, route, groupsFor, drawBlocks, relationList, renderRoute, start
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 testcode/202609141754/code-navigation/navigation.js:1-115 · blob ad7169339f531bd974933eae9aa31c47f792915b · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: experimental · users: none · canonical: production_core
/* Reuses the published code reader (core.js). This view changes navigation, not permanent identities. */
let viewSerial = 0, journeyDepth = 0;
const subject = $('#subject');
const row = (title, detail, act) => el('button', { class: 'row', on: { click: act } }, title, detail ? el('small', {}, detail) : null);
function paged(host, list, render, size = 24) {
  let page = 0;
  function draw() {
    host.replaceChildren();
    if (!list.length) { host.append(el('p', { class: 'empty' }, 'None recorded in the published data.')); return; }
    const start = page * size, stop = Math.min(start + size, list.length);
    const prev = el('button', { 'aria-label': 'Previous page', on: { click: () => { page--; draw(); } } }, '←'); prev.disabled = page === 0;
    const next = el('button', { 'aria-label': 'Next page', on: { click: () => { page++; draw(); } } }, '→'); next.disabled = stop === list.length;
    host.append(el('div', { class: 'pager' }, prev, el('span', { role: 'status' }, `${start + 1}–${stop} of ${list.length}`), next));
    const items = el('div'); host.append(items);
    list.slice(start, stop).forEach((item, i) => items.append(render(item, start + i)));
  }
  draw();
}
function box(title) { const wrapper = el('section', { class: 'box' }, el('h3', {}, title)); const content = el('div'); wrapper.append(content); return { wrapper, content }; }
function link(label, url) {
  try { if (!/^https?:$/.test(new URL(url).protocol)) return null; } catch { return null; }
  return el('a', { class: 'u-chip', href: url, target: '_blank', rel: 'noopener noreferrer' }, label + ' ↗');
}
function navigate(kind, id) { const hash = kind ? `#${kind}=${encodeURIComponent(id)}` : '#'; if (location.hash === hash) return renderRoute(); history.pushState({ journeyDepth: ++journeyDepth }, '', hash); renderRoute(); }
function route() { const p = new URLSearchParams(location.hash.slice(1)); if (p.has('family')) return ['family', p.get('family')]; if (p.has('block')) return ['block', p.get('block')]; return ['', '']; }
function groupsFor(n) { return Object.entries(U.groups).filter(([, ns]) => ns.includes(Number(n))).map(([sym]) => sym); }
function drawBlocks() {
  const q = $('#block-filter').value.toLowerCase(), cat = $('#category').value;
  const groups = Object.keys(U.groups).filter(sym => {
    const b = U.bySym.get(sym);
    return (!cat || (cat === '_unnamed' ? !b : b?.category === cat)) && `${sym} ${blockLabel(sym)}`.toLowerCase().includes(q);
  }).sort((a, b) => (U.bySym.get(a)?.number ?? 1e9) - (U.bySym.get(b)?.number ?? 1e9) || a.localeCompare(b));
  paged($('#blocks'), groups, sym => row(blockLabel(sym), `${blockFamilies(sym).length} families`, () => navigate('block', sym)), 12);
}
function relationList(title, items, type, go) {
  const b = box(`${title} · ${items.length}`);
  paged(b.content, items, item => row(item.label, type, () => go(item.id)), 16);
  return b.wrapper;
}
async function renderRoute() {
  const serial = ++viewSerial;
  const [kind, id] = route();
  $('#back').disabled = journeyDepth === 0;
  $('#trail').replaceChildren(el('a', { href: '#' }, 'GLOBALGRID2050'), kind ? ` › ${kind === 'family' ? '#' + id : blockLabel(id)}` : ' › All blocks');
  subject.replaceChildren(); subject.setAttribute('aria-busy', 'true');
  try {
    if (!kind) {
      subject.append(el('h2', { class: 'subject-title' }, 'Navigate the code'), el('p', {}, 'Choose a block or search a function. Follow its permanent keys to the relationships and the exact source at a commit.'), el('p', { class: 'relation-legend' }, 'Contains → families · Uses → dependencies · Used by → callers · Shared lines → matching permanent keys in loaded records'));
      const picks = ['Vn', 'Dt', 'Si', 'Cg'].filter(s => U.groups[s]);
      subject.append(el('div', { class: 'two' }, picks.map(s => row(blockLabel(s), `${blockFamilies(s).length} families`, () => navigate('block', s)))));
      return;
    }
    if (kind === 'block') {
      if (!Object.hasOwn(U.groups, id)) throw Error(`Block or group ${id} is not recorded.`);
      const b = U.bySym.get(id), families = blockFamilies(id);
      subject.append(el('div', { class: 'block-summary' }, el('h2', { class: 'subject-title' }, blockLabel(id)), el('p', {}, blockDesc(b) || 'This group has not yet been given a public block name.'), el('p', { class: 'u-muted' }, `${families.length} function families · all available below`)));
      if (b) subject.append(link('Block page', blockPage(id)));
      const deps = blockDeps(id), users = (b?.used_by || []).map(x => x.symbol || x).filter(s => Object.hasOwn(U.groups, s));
      const relations = el('div', { class: 'two' }, relationList('Depends on', deps.map(s => ({ id: s, label: blockLabel(s) })), 'depends on →', s => navigate('block', s)), relationList('Used by', users.map(s => ({ id: s, label: blockLabel(s) })), '← used by', s => navigate('block', s)));
      subject.append(relations);
      const f = box(`Contains · ${families.length} families`); subject.append(f.wrapper);
      paged(f.content, families, n => {
        const button = row('#' + n, 'Open numbered code and relationships', () => navigate('family', n));
        family(n).then(rec => { if (rec && button.isConnected) button.firstChild.textContent = `#${n} ${famName(rec)}`; }).catch(() => { if (button.isConnected) button.lastChild.textContent = 'Name could not load; open to retry.'; });
        return button;
      });
      return;
    }
    if (!/^\d+$/.test(id)) throw Error('The family key must be a non-negative integer.');
    const n = Number(id), rec = await family(n);
    if (serial !== viewSerial) return;
    if (!rec) throw Error(`Family #${n} is not in the published records.`);
    subject.append(el('h2', { class: 'subject-title' }, `#${n} ${famName(rec)}`), el('p', { class: 'u-muted' }, `${famKind(rec)} · ${rec.lines.length} permanent numbered lines · ${rec.standalone ? 'self-contained' : 'needs context'}`));
    const members = groupsFor(n);
    subject.append(el('div', { class: 'u-links' }, members.map(s => row('◂ Contained in ' + blockLabel(s), '', () => navigate('block', s)))));
    const links = familyLinks(rec, n); subject.append(el('div', { class: 'u-links' }, link('Function page', links.page), links.gh ? link('File at commit', links.gh) : null, links.live ? link('Recorded live page', links.live) : el('span', { class: 'u-muted' }, 'No live page recorded.')));
    subject.append(el('div', { class: 'two' }, relationList('Uses', (rec.uses || []).map(u => ({ id: u.family, label: `#${u.family} ${u.name || ''}` })), 'uses →', m => navigate('family', m)), relationList('Used by', (rec.used_by || []).map(u => ({ id: u.family, label: `#${u.family} ${u.name || ''}` })), '← used by', m => navigate('family', m))));
    const code = box('Numbered lines · permanent keys'); subject.append(code.wrapper);
    const p = rec.places?.[0];
    if (p) code.content.append(el('p', { class: 'source-meta' }, `${p.repo} / ${p.path} · commit ${p.commit} · source lines ${p.first}–${p.last}`));
    const pre = el('div', { class: 'u-code', tabindex: '0', 'aria-label': 'Numbered source code' }, 'Fetching the source at its pinned commit…'); code.content.append(pre);
    try {
      const rows = await familyLines(rec);
      if (serial !== viewSerial) return;
      pre.replaceChildren(...rows.map(r => el('div', { class: 'u-line' }, el('span', { class: 'u-key' }, String(r.key)), ' │ ' + r.text)));
    } catch (error) { pre.textContent = `Source unavailable: ${error.message}. Permanent keys: ${rec.lines.join(', ')}.`; }
    if (serial !== viewSerial) return;
    const keys = new Set(rec.lines), shared = new Map();
    let loaded = 0, failures = 0;
    for (const promise of U.buckets.values()) {
      let bucket; try { bucket = await promise; loaded++; } catch { failures++; continue; }
      if (serial !== viewSerial) return;
      for (const [m, r] of Object.entries(bucket)) if (+m !== n) { const hits = (r.lines || []).filter(k => keys.has(k)).length; if (hits) shared.set(+m, { id: +m, label: `#${m} ${famName(r)} · ${hits} shared keys` }); }
    }
    subject.append(relationList('Shared lines in loaded records', [...shared.values()], 'shares permanent keys', m => navigate('family', m)), el('p', { class: 'u-muted' }, `Searched ${loaded} loaded buckets; ${failures} unavailable. This is a partial search, not the whole code base.`));
  } catch (error) {
    if (serial !== viewSerial) return;
    subject.replaceChildren(el('div', { class: 'u-fail', role: 'alert' }, error.message), el('button', { on: { click: () => { U.buckets.clear(); U.texts.clear(); renderRoute(); } } }, 'Retry this view'));
  } finally { if (serial === viewSerial) subject.setAttribute('aria-busy', 'false'); }
}
$('#back').addEventListener('click', () => history.back());
window.addEventListener('popstate', () => { journeyDepth = history.state?.journeyDepth || 0; renderRoute(); });
window.addEventListener('hashchange', () => { journeyDepth = history.state?.journeyDepth || 0; renderRoute(); });
$('#copy').addEventListener('click', async () => { try { await navigator.clipboard.writeText(location.href); $('#copy-status').textContent = 'Link copied'; } catch { $('#copy-status').textContent = 'Copy the address from the browser bar.'; } });
async function start() {
  try {
    await loadUniverse();
    $('#count').textContent = countsLine();
    for (const c of U.cats) $('#category').append(el('option', { value: c.id }, catName(c)));
    $('#category').append(el('option', { value: '_unnamed' }, 'Unnamed groups'));
    $('#block-filter').addEventListener('input', drawBlocks); $('#category').addEventListener('change', drawBlocks);
    mountSearch($('#search'), n => navigate('family', n)); drawBlocks(); renderRoute();
  } catch (e) { fail('#count', e); subject.replaceChildren(el('button', { on: { click: () => location.reload() } }, 'Reload live data')); }
}
start();

Testcode — Code Record Page

A web page in GlobalGrid2050 that draws blocks, families and names, using haversine, and uses data from the ventus-grid-engine and stars repositories. Published at https://globalgrid2050.com/testcode/202609141754/code-record/.

renderglobalgrid2050 / testcode/202609141754/code-record/index.html · lines 1–144 of 144 · version 2026-09-14 17:54 · Entry point · pattern fetchSource (shared by 2 files)

What it does
It draws blocks, families and names. Defines 12 functions or classes, including $, esc, T, L, repoName. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage experimental (path word 'testcode'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
Inputs & outputs
In: data source: ventus-grid-engine data; data source: stars data; JSON file blocks.json; JSON file families.json; JSON file index.json; JSON file names.json; form fields (user input). Out: web page.
Downstream impact
Used directly by 1 file: Testcode — Block Register Page (globalgrid2050, https://globalgrid2050.com/testcode/202609141754/block-register/). It is itself an entry point, published at https://globalgrid2050.com/testcode/202609141754/code-record/.
What it achieves
It loads family (`loadFamily`) and fetches source (`fetchSource`). Defines `esc`, `repoName`, `byName` and 5 more.
Why it matters
Loaded by the Block Register page at https://globalgrid2050.com/testcode/202609141754/block-register/.
Application
globalgrid2050 · testcode/202609141754/code-record · page
Uses
GlobalGrid2050 — Testcode Page (link), Testcode — Block Register Page (link), Corporate (script src), Table (estate URL), Stars — Index Page (estate URL), Standalone (estate URL)
Used by
linked from Testcode — Block Register Page (link)
Produces
$, esc, T, L, repoName, byName, purposeOf, loadFamily, search, fetchSource, show, gh
Defines here
$, esc, T, L, repoName, byName, purposeOf, loadFamily, search, fetchSource, show, gh
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 testcode/202609141754/code-record/index.html:1-144 · blob e65136ef9b5ffc113677a2f5e9641c12cc9ef150 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom, network · domain stage: experimental · users: none · canonical: production_core
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>GlobalGrid2050 · Code record</title>
<style>
  :root{color-scheme:dark}
  body{margin:0;padding:16px 18px 40px;background:#0b0d12;color:#d8dee9;font:14px/1.5 ui-monospace,Menlo,Consolas,monospace}
  a{color:#00e5ff}
  h1{font-size:22px;margin:0 0 4px}
  .ey{color:#7da0c8;text-transform:uppercase;letter-spacing:.08em;font-size:11px}
  .nav{display:flex;flex-wrap:wrap;gap:6px 14px;margin:8px 0 6px;font-size:13px}
  input{width:100%;box-sizing:border-box;padding:10px;background:#12151c;border:1px solid #2a3140;color:inherit;font:inherit;border-radius:6px;margin:12px 0}
  .hits a{display:block;padding:4px 0;border-bottom:1px solid #1a1f2a}
  .card{border:1px solid #2a3140;border-radius:8px;padding:14px;margin:14px 0;background:#0f1218}
  .green{color:#39d353}.amber{color:#ffd54a}.grey{color:#8b93a7}
  table{border-collapse:collapse;width:100%;font-size:13px}
  td,th{text-align:left;padding:4px 6px;border-bottom:1px solid #1a1f2a;vertical-align:top}
  .scroll{overflow-x:auto}
  pre{background:#070910;border:1px solid #1a1f2a;border-radius:6px;padding:10px;overflow:auto;font-size:12.5px;line-height:1.45}
  .ln{color:#4b5568;user-select:none;display:inline-block;min-width:7ch;text-align:right;margin-right:12px}
  button{background:#12151c;border:1px solid #385464;color:#d8dee9;padding:7px 12px;border-radius:6px;font:inherit;cursor:pointer;margin:4px 6px 4px 0}
  button:hover{border-color:#00e5ff}
  a > button{color:#d8dee9}
  .first button{border-color:#00e5ff}
  .muted{color:#8b93a7}
  details{margin-top:10px}summary{cursor:pointer;color:#8b93a7}
  .examples a{margin-right:12px}
  @media(max-width:600px){body{padding:12px}}
</style>
<div class="ey">Ventus · Global Grid 2050</div>
<h1>Code record</h1>
<nav class="nav"><a data-origin="https://ventusltd.github.io/ventus-grid-engine/?graph=modular" href="https://ventusltd.github.io/ventus-grid-engine/?graph=modular">← Map</a><a href="https://globalgrid2050.com/">Home</a><a href="../index.html">Start here</a><a data-origin="https://ventusltd.github.io/stars/table.html" href="../block-register/index.html">Block register</a></nav>
<div class="muted" id="status">Loading the index…</div>
<input id="q" placeholder="Type part of a function name, or its number (for example distanceKm, or 511)" autocomplete="off" aria-label="Search functions by name or number">
<div class="hits" id="hits"></div>
<div id="view"><div class="card" id="landing">
  <div>One function per record: its purpose, where it is used, the live page it runs on, and the source code when you open it.</div>
  <div class="muted" style="margin-top:8px">Matches appear as you type. Examples:</div>
  <div class="examples" style="margin-top:4px"><a href="?family=511">#511 distanceKm</a> <a href="?family=440">#440 haversine</a> <a href="?family=514">#514 nearestSubstations</a> <a href="?family=77484">#77484 voltageDrop</a></div>
  <div class="muted" style="margin-top:8px">Do not know the name? <a data-origin="https://ventusltd.github.io/stars/table.html" href="../block-register/index.html">Browse the block register by category</a>, then open a block's parts list.</div>
</div></div>
<p class="muted">Every function has a permanent number, shared by all copies of the same logic. Line numbers shown are the permanent number of each line. The code is fetched from GitHub at the exact commit. Public repositories only. <a href="https://github.com/Ventusltd/stars/blob/main/MODULAR-STAR.md">About this record</a> · <a href="https://github.com/Ventusltd/stars/blob/main/modular/SUMMARY.md  … [line shortened here: 565 characters; full line on GitHub]
<script src="../corporate.js"></script>
<script>
const ORIGIN = 'https://ventusltd.github.io/stars/';
const $ = s => document.querySelector(s);
const esc = s => String(s).replace(/[&<>"]/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[c]));
const T = s => Corporate.text(s);
const L = u => Corporate.link(u);
const repoName = r => Corporate.label(r, 'repo');
const byName = (a, b) => String(a).localeCompare(String(b), 'en');
document.querySelectorAll('a[data-origin]').forEach(a => a.href = L(a.dataset.origin));
let index, names;
const bucketCache = new Map();
let blocksPromise = null;
async function purposeOf(n) {
  if (!blocksPromise) blocksPromise = Promise.all([fetch(ORIGIN + 'blocks/blocks.json').then(r => r.json()), fetch(ORIGIN + 'blocks/families.json').then(r => r.json())]);
  const [table, fams] = await blocksPromise;
  const sym = Object.keys(fams).find(s => fams[s].includes(n)); if (!sym) return null;
  const block = table.blocks.find(b => b.symbol === sym) || { symbol: sym, title: 'other tools', category: 'other' };
  return { block, category: table.categories.find(c => c.id === block.category) || { id: 'other', title: 'Other tools' } };
}
async function loadFamily(n) {
  const b = Math.floor(n / index.bucket_size);
  if (!bucketCache.has(b)) bucketCache.set(b, fetch(`${ORIGIN}code/f/${b}.json`, {cache: 'no-cache'}).then(r => r.ok ? r.json() : {}));
  return (await bucketCache.get(b))[n] || null;
}
function search(q) {
  q = q.trim(); const hits = $('#hits'); hits.innerHTML = '';
  if (!q) return;
  if (/^#?\d+$/.test(q)) { history.pushState(null, '', `?family=${q.replace('#', '')}`); show(Number(q.replace('#', ''))); return; }
  const ql = q.toLowerCase();
  const found = Object.keys(names).filter(k => k.toLowerCase().includes(ql)).sort((a, b) => (a.toLowerCase().startsWith(ql) ? 0 : 1) - (b.toLowerCase().startsWith(ql) ? 0 : 1) || a.length - b.length || byName(a, b)).slice(0, 40);
  for (const k of found) for (const n of names[k].slice(0, 8)) {
    const a = document.createElement('a'); a.href = `?family=${n}`; a.textContent = `#${n} ${k}`;
    a.onclick = e => { e.preventDefault(); history.pushState(null, '', `?family=${n}`); show(n); };
    hits.append(a);
  }
  if (!found.length) hits.textContent = 'No function has a name containing "' + q + '". Try a shorter part of the name, or browse the block register by category.';
}
async function fetchSource(p) {
  const url = `https://raw.githubusercontent.com/${p.repo}/${p.commit}/${p.path.split('/').map(encodeURIComponent).join('/')}`;
  const r = await fetch(url); if (!r.ok) throw new Error(`GitHub ${r.status}`);
  return (await r.text()).split('\n').slice(p.first - 1, p.last);
}
async function show(n) {
  $('#hits').innerHTML = ''; const v = $('#view'); v.innerHTML = '<div class="card">Loading…</div>';
  const f = await loadFamily(n);
  if (!f) { v.innerHTML = `<div class="card">There is no function with the number ${esc(n)}. Type a name in the search box, or <a href="${esc(L(ORIGIN + 'table.html'))}">browse the block register by category</a>.</div>`; return; }
  const gh = p => `https://github.com/${p.repo}/blob/${p.commit}/${p.path.split('/').map(encodeURIComponent).join('/')}#L${p.first}-L${p.last}`;
  const c = f.places[0];
  const rag = f.standalone ? 'green' : 'amber';
  const kind = { function: 'a function', class: 'a class', method: 'a method' }[f.kind] || Corporate.type(f.kind);
  const places = f.places.slice().sort((a, b) => (b.live ? 1 : 0) - (a.live ? 1 : 0) || byName(a.repo, b.repo) || byName(a.path, b.path) || a.first - b.first);
  const uses = (f.uses || []).slice().sort((a, b) => byName(a.name, b.name));
  const usedBy = (f.used_by || []).slice().sort((a, b) => a.family - b.family);
  // Function names, needed identifiers, file paths and library exports are code identifiers and are shown exactly as written.
  v.innerHTML = `<div class="card">
    <div class="ey">function #${f.n}</div>
    <h1>${esc(f.names[0])}</h1>
    <div><span class="${rag}">●</span> ${f.standalone ? 'self-contained: works on its own' : 'external dependencies: ' + (f.needs && f.needs.length ? esc(f.needs.slice().sort(byName).join(', ')) : 'its surrounding file')}
      · ${esc(kind)} · used in ${f.places.length}${f.places.length === 40 ? '+' : ''} place${f.places.length === 1 ? '' : 's'} across ${f.files} file${f.files === 1 ? '' : 's'} in ${f.repos.length} repositor${f.repos.length === 1 ? 'y' : 'ies'} · ${f.versions} version${f.versions === 1 ? '' : 's'}${f.first_written ? ' · first written ' + f.first_written.slice(0, 10) : ''}</div>
    ${f.names.length > 1 ? `<div class="muted">also named: ${f.names.slice(1).map(esc).join(', ')}</div>` : ''}
    <div id="purpose" class="muted"></div>
    ${uses.length || usedBy.length ? `<div style="margin-top:6px">${uses.length ? `<div><span class="muted">uses:</span> ${uses.slice(0, 10).map(u => `<a href="?family=${u.family}">#${u.family} ${esc(u.name)}</a>`).join(', ')}</div>` : ''}${usedBy.length ? `<div><span class="muted">used by:</span> ${usedBy.slice(0, 12).map(u => `<a href="?family=${u.family}">#${u.family}</a>`).join(', ')}${usedBy.  … [line shortened here: 506 characters; full line on GitHub]
    <div style="margin-top:10px">
      ${c.live ? `<a class="first" href="${esc(L(c.live))}" target="_blank" rel="noopener"><button>Open the live page</button></a>` : ''}
      <a href="${esc(L('https://ventusltd.github.io/ventus-grid-engine/?graph=modular&focus=' + encodeURIComponent('#' + f.n + ' ' + f.names[0])))}"><button>See it on the map</button></a>
      <a href="${gh(c)}" target="_blank" rel="noopener"><button>Open on GitHub</button></a>
      <button id="copy">Copy the code</button>
      ${f.library ? `<button id="copyImport">Copy an import line</button>` : ''}
    </div>
    <div class="ey" style="margin-top:12px">where it is used (live pages first)</div>
    <div class="scroll"><table><tr><th>repository</th><th>file</th><th>lines</th><th>live page</th></tr>
    ${places.map(p => `<tr><td>${esc(repoName(p.repo.split('/')[1]))}</td><td><a href="${gh(p)}" target="_blank" rel="noopener">${esc(p.path)}</a></td><td>${p.first}–${p.last}</td><td>${p.live ? `<a href="${esc(L(p.live))}" target="_blank" rel="noopener">open</a>` : '<span class="muted">not published</span>'}</td></tr>`).join('')}
    </table></div>
    <details open><summary>The code (${c.last - c.first + 1} lines, from ${esc(repoName(c.repo.split('/')[1]))})</summary><pre id="src">Fetching the code from GitHub…</pre></details>
    ${f.library ? `<p class="muted">In the compiled library as <code>${esc(f.library)}</code>: <code>import { ${esc(f.library)} } from 'https://ventusltd.github.io/stars/library/standalone.mjs'</code></p>` : ''}
  </div>`;
  purposeOf(n).then(p => { const el = $('#purpose'); if (el && p) el.innerHTML = `part of: <a href="${esc(L(ORIGIN + 'table.html?category=' + encodeURIComponent(p.category.id)))}">${esc(T(p.category.title))}</a> › <a href="${esc(L(ORIGIN + 'table.html?block=' + encodeURIComponent(p.block.symbol)))}">${esc(p.block.symbol)} ${esc(T(p.block.title))}</a>`; }).catch(() => {});
  document.querySelectorAll('#view a[href^="?family="]').forEach(a => a.onclick = e => { e.preventDefault(); const m = new URLSearchParams(a.getAttribute('href')).get('family'); history.pushState(null, '', `?family=${m}`); show(Number(m)); });
  let source = '';
  try {
    const lines = await fetchSource(c);
    source = lines.join('\n');
    $('#src').innerHTML = lines.map((t, i) => `<span class="ln">${f.lines[i] ?? ''}</span>${esc(t)}`).join('\n');
  } catch (e) { $('#src').textContent = 'The code could not be fetched from GitHub: ' + e.message; }
  $('#copy').onclick = () => navigator.clipboard.writeText(`// function #${f.n} ${f.names[0]} · ${gh(c)}\n${source}\n`).then(() => $('#copy').textContent = 'Copied');
  const ci = $('#copyImport'); if (ci) ci.onclick = () => navigator.clipboard.writeText(`import { ${f.library} } from 'https://ventusltd.github.io/stars/library/standalone.mjs';\n`).then(() => ci.textContent = 'Copied');
}
(async () => {
  try {
    [index, names] = await Promise.all([fetch(ORIGIN + 'code/index.json', {cache: 'no-cache'}).then(r => r.json()), fetch(ORIGIN + 'code/names.json', {cache: 'no-cache'}).then(r => r.json())]);
    $('#status').textContent = `${index.families.toLocaleString('en-GB')} functions with a permanent number · ${index.elements.toLocaleString('en-GB')} functions and classes in the code · ${index.lines.toLocaleString('en-GB')} unique lines · updated ${index.generated_utc.slice(0, 16).replace('T', ' ')} UTC`;
    $('#q').oninput = e => search(e.target.value);
    document.querySelectorAll('#landing a[href^="?family="]').forEach(a => a.onclick = e => { e.preventDefault(); const m = new URLSearchParams(a.getAttribute('href')).get('family'); history.pushState(null, '', `?family=${m}`); show(Number(m)); });
    const n = new URLSearchParams(location.search).get('family');
    if (n) show(Number(n));
    window.onpopstate = () => { const m = new URLSearchParams(location.search).get('family'); if (m) show(Number(m)); else location.reload(); };
  } catch (e) { $('#status').textContent = 'The code index is not published yet: ' + e.message; }
})();
</script>
</html>

Corporate

A JavaScript module in the testcode folder of GlobalGrid2050 that works with graph title (`graphTitle`) and graph description (`graphDescription`).

transformglobalgrid2050 / testcode/202609141754/corporate.js · lines 1–183 of 183 · version 2026-09-14 17:54 · Entry point · pattern words (shared by 35 files)

What it does
It calculates its inputs. Defines 8 functions or classes, including words, text, label, type, graphTitle.
Why it exists in the grid workflow
Domain stage experimental (path word 'testcode'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
Downstream impact
Used directly by 14 files: Code Map — V01 Dependency Drill Page (globalgrid2050, https://globalgrid2050.com/testcode/202609141754/code-map/v01-dependency-drill/); Code Map — V02 Radial Hierarchy Page (globalgrid2050, https://globalgrid2050.com/testcode/202609141754/code-map/v02-radial-hierarchy/); Code Map — V03 Block Map Page (globalgrid2050, https://globalgrid2050.com/testcode/202609141754/code-map/v03-block-map/); Code Map — V04 Block Register Links Page (globalgrid2050, https://globalgrid2050.com/testcode/202609141754/code-map/v04-block-register-links/); and 10 more. Reached from 1 other entry point, including Testcode — Code Map Page (globalgrid2050, https://globalgrid2050.com/testcode/202609141754/code-map/).
What it achieves
It is built from the words step (`words`), the text step (`text`) and the label step (`label`). GlobalGrid2050 public wording layer (testcode ).
Why it matters
Loaded by the V01 Dependency Drill page at https://globalgrid2050.com/testcode/202609141754/code-map/v01-dependency-drill/ and 13 other pages.
Application
globalgrid2050 · testcode/202609141754 · JavaScript module
Uses
none found
Used by
loaded by Code Map — V01 Dependency Drill Page (script src), loaded by Code Map — V02 Radial Hierarchy Page (script src), loaded by Code Map — V03 Block Map Page (script src), loaded by Code Map — V04 Block Register Links Page (script src), loaded by Code Map — V05 Chord Dependencies Page (script src), loaded by Code Map — V06 Treemap Page (script src), loaded by Code Map — V07 Flow Page (script src), loaded by Code Map — V08 Ring Navigation Page (script src), and 6 more
Produces
words, text, label, type, graphTitle, graphDescription, link, graphId
Defines here
words, text, label, type, graphTitle, graphDescription, link, graphId
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 testcode/202609141754/corporate.js:1-183 · blob 6fe0726e230b84d56bf2750830db7bb70ec2bb39 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: production_core
/* GlobalGrid2050 public wording layer (testcode 202609141754).
 *
 * The origin repositories (stars, spiders, star-maker, ventus-grid-engine) keep
 * their own names and vocabulary; that is where the thinking lives. Pages served
 * to the public read the same live data through this file, which turns what a
 * reader SEES into plain engineering and business language.
 *
 * What it never changes: web addresses, file paths, repository names used as
 * names, commit hashes, numbers. A term inside a path is an address, not
 * language, and changing it would break the link.
 *
 * Usage: Corporate.text(s)   plain text or HTML fragment -> corporate wording
 *        Corporate.type(t)   node or relationship type -> display label
 *        Corporate.graphTitle(id, fallback) / graphDescription(id, fallback)
 *        Corporate.link(url) origin page URL -> corporate page URL, if one exists
 */
(function (root) {
  "use strict";

  // Physical things: repositories and their published sites keep their names.
  const REPOS = ["star-maker", "stars", "spiders", "ventus-grid-engine", "code-generator", "genome-spider", "seer-spider"];

  // Sentences or fragments that are metaphor only and carry no engineering fact.
  const DROP = [
    /\s*·\s*shells\s+K\d+\s+L\d+\s+M\d+/gi,
    /\s*·\s*valence\s+\d+/gi,
    /\s*·\s*spin\s+\w+/gi,
    /\s*·\s*mass\s+[\d.]+/gi,
    /\s*·\s*field\s+[\d.]+/gi,
    /\s*[·—–-]\s*holds no copy of the souls it bonds with/gi,
    /\s*[·—–-]\s*every bond is a tunnel/gi,
  ];

  // Ordered: longer phrases first. Each is [pattern, replacement].
  const PHRASES = [
    [/\bfrom the (electron|soul|vedic|magnetar|chemistry|star-maker|modular|periodic) star\s*[·—–-]?\s*/gi, ""],
    [/\bfive-element classification\b/gi, "five-class classification"],
    [/\bfrom the (\w+) star\b/gi, "from the $1 sample"],
    [/\bThe Spider Sandbox\b/g, "Grid Engine Sandbox"],
    [/\bSpider Sandbox\b/gi, "Grid Engine Sandbox"],
    [/\bSpider dashboard\b/gi, "Grid Engine dashboard"],
    [/\bSpider graphs?\b/gi, m => /s$/i.test(m) ? "dependency graphs" : "dependency graph"],
    [/\bSpider features\b/gi, "Dashboard graph registration"],
    [/\bSpider universe\b/gi, "code map"],
    [/\bfederation-spider\b/gi, "federation scanner"],
    [/\bspider pattern\b/gi, "dependency pattern"],
    [/\bspider view\b/gi, "canvas view"],
    [/\bGenome and spiders\b/g, "Lineage and scanners"],
    [/\bthe spiders\b/gi, m => m[0] === "T" ? "The scanners" : "the scanners"],
    [/\bspider's\b/gi, "scanner's"],
    [/\bnumbered-code universe\b/gi, "numbered code base"],
    [/\bThe code universe\b/g, "The code base"],
    [/\bcode universe\b/gi, "code base"],
    [/\buniverse builder\b/gi, "code map builder"],
    [/\bparticle universe\b/gi, "block map"],
    [/\buniverses?\b/gi, m => /^U/.test(m) ? "Code map" : "code map"],
    [/\bcharted into sense\b/gi, "organised into an assessment"],
    [/\bperiodic table of globalgrid2050\b/gi, "Block register"],
    [/\bperiodic tables?\b/gi, m => /^P/.test(m) ? "Block register" : "block register"],
    [/\bperiodic\b/gi, "block"],
    [/\bChemistry, Vedic and Random\b/g, "Compatibility, Classification and Sampling"],
    [/\bchemistry\b/gi, m => /^C/.test(m) ? "Compatibility" : "compatibility"],
    [/\bvedic\b/gi, m => /^V/.test(m) ? "Classification" : "classification"],
    [/\bModular star\b/g, "Code scan"],
    [/\bmodular star\b/g, "code scan"],
    [/\bStarmaker\b/g, "Test bench"],
    [/\bthe stars\b/gi, m => m[0] === "T" ? "The test records" : "the test records"],
    [/\bfront door\b/gi, m => /^F/.test(m) ? "Overview" : "overview"],
    [/\bstarquakes?\b/gi, "changes"],
    [/\bdrawn toward\b/gi, "linked to"],
    [/\bhomes\b(?=\s+\S)/g, "used in"],
    [/\bcompounds\b/gi, "combinations"],
    [/\bcompound\b/gi, "combination"],
    [/\bdecays_to\b/gi, "fails with"],
    [/\bdecays\b/gi, "failures"],
    [/\bdecay\b/gi, "failure"],
    [/\belements\b(?=\s*\()/gi, "Components"],
    [/\belement\b(?=\s*·)/gi, "component"],
    [/\bparticles?\b/gi, m => /s$/i.test(m) ? "points" : "point"],
    [/\bgenome\b/gi, m => /^G/.test(m) ? "Lineage" : "lineage"],
    [/\bmagnetars?\b/gi, "repository"],
    [/\bsouls?\b/gi, "test code"],
    [/\belectrons?\b/gi, "function"],
    [/\bstars\b/gi, m => /^S/.test(m) ? "Records" : "records"],
    [/\bstar\b/gi, m => /^S/.test(m) ? "Record" : "record"],
    [/\bspiders\b/gi, m => /^S/.test(m) ? "Scanners" : "scanners"],
    [/\bspider\b/gi, m => /^S/.test(m) ? "Scanner" : "scanner"],
    [/\borbits?\b/gi, "surrounds"],
    [/\bjourneys?\b/gi, m => /^J/.test(m) ? "Navigation" : "navigation"],
    [/🕷\s*/g, ""],
  ];

  const TYPES = {
    element: "component", "library element": "library component", decay: "failure",
    electron: "function", soul: "test code", vedic: "classified item", magnetar: "repository",
    chemistry: "component test", star: "record",
    DECAYS_TO: "fails with", IS_MADE_OF: "made of",
    MIGHT_TOUCH: "may affect", RHYMES_WITH: "similar to", WHAT_IF: "worth checking",
    COULD_REPLACE: "could replace", ENTANGLED_MAYBE: "possibly coupled", REMINDS_OF: "resembles",
  };

  const GRAPHS = {
    overview: ["Grid Engine overview", "One card per dependency graph; each opens that graph."],
    federation: ["Repositories", "The public repositories and how they relate: data, interface, governance and external services."],
    "engine-graph": ["Engine modules", "The engine's canonical modules, the copies measured against them and where they have drifted."],
    "genome-spider": ["Lineage scanner output", "Reserved for the lineage scanner's output; no data published yet."],
    "gridatlas-lineage": ["Grid Atlas lineage", "Grid Atlas's current composition and its ancestry: which cartridges it composed, which modules built each cartridge, and any module that has changed since."],
    "globalgrid2050-contents": ["globalgrid2050 contents", "The declared contents of the globalgrid2050 repository."],
  };

  const PAGE_LINKS = [
    [/^https:\/\/ventusltd\.github\.io\/stars\/table\.html/, "../block-register/index.html"],
    [/^https:\/\/ventusltd\.github\.io\/stars\/code\.html/, "../code-record/index.html"],
    [/^https:\/\/ventusltd\.github\.io\/stars\/((?:reports|modular|sense|proof|structure|decisions|blocks)\/[^?#]+\.md)$/, "https://github.com/Ventusltd/stars/blob/main/$1"],
    [/^https:\/\/ventusltd\.github\.io\/ventus-grid-engine\/(\?.*)?$/, "../grid-engine/index.html$1"],
  ];

  // Everything that is an address or a name: kept byte for byte.
  const KEEP = new RegExp(
    [
      String.raw`https?:\/\/[^\s"'<>]+`,
      String.raw`<[^>]+>`,                                   // HTML tags and their attributes
      String.raw`&[a-z#0-9]+;`,
      String.raw`[\w.@-]*\/[\w./@{}-]*`,                     // anything with a slash: a path
      String.raw`\b[\w-]+\.(?:html?|m?js|json|md|css|py|ya?ml|txt|csv)\b`,
      String.raw`\b(?:` + REPOS.map(r => r.replace(/-/g, "\\-")).join("|") + String.raw`)\b(?=\s+(?:repository|repo|machinery|genome|site|\S*\/))`,
      String.raw`\b[0-9a-f]{7,40}\b`,
    ].join("|"),
    "g"
  );

  function words(s) {
    for (const re of DROP) s = s.replace(re, "");
    for (const [re, rep] of PHRASES) s = s.replace(re, rep);
    return s;
  }

  function text(s) {
    if (s == null) return s;
    s = String(s);
    let out = "", last = 0;
    KEEP.lastIndex = 0;
    for (let m; (m = KEEP.exec(s)); ) {
      if (m.index === KEEP.lastIndex) KEEP.lastIndex++;
      out += words(s.slice(last, m.index)) + m[0];
      last = m.index + m[0].length;
    }
    return out + words(s.slice(last));
  }

  // A label that IS a repository name stays a name.
  function label(s, type) {
    if (type === "repo" || type === "repository" || REPOS.includes(String(s))) return s;
    return text(s);
  }

  function type(t) {
    if (t == null) return t;
    return TYPES[t] || TYPES[String(t).toLowerCase()] || text(String(t));
  }

  function graphTitle(id, fallback) { return (GRAPHS[id] && GRAPHS[id][0]) || text(fallback); }
  function graphDescription(id, fallback) { return (GRAPHS[id] && GRAPHS[id][1]) || text(fallback); }

  function link(url) {
    if (!url) return url;
    for (const [re, rep] of PAGE_LINKS) if (re.test(url)) return url.replace(re, rep);
    return url;
  }

  // Public addresses for graph ids; the origin id still works.
  const GRAPH_ALIASES = {
    repositories: "federation", "module-map": "engine-graph", "engine-modules": "engine-graph",
    applications: "generated-apps", assessment: "sense", audit: "proof-of-work",
    classification: "vedic", compatibility: "chemistry", inventory: "periodic-table",
    reuse: "modular", sampling: "random", lineage: "gridatlas-lineage",
  };
  function graphId(id) { return GRAPH_ALIASES[id] || id; }

  const api = { text, label, type, graphTitle, graphDescription, link, graphId, REPOS };
  if (typeof module !== "undefined" && module.exports) module.exports = api;
  root.Corporate = api;
})(typeof window !== "undefined" ? window : globalThis);