In this section
- Pilot interaction · globalgrid2050 / testcode/wafer-development-environment/202609192215-proof-s0004/pilot.mjs lines 1–381
- Wafer Development Environment — Proof S0004 Style Sheet render · globalgrid2050 / testcode/wafer-development-environment/202609192215-proof-s0004/style.css lines 1–129
Pilot
A JavaScript module in the testcode folder of GlobalGrid2050 that draws electron, using IEC 60909 and uses data from the ventus-grid-engine repository. Served with the page at https://globalgrid2050.com/testcode/wafer-development-environment/202609192215-proof-s0004/.
interactionglobalgrid2050 / testcode/wafer-development-environment/202609192215-proof-s0004/pilot.mjs · lines 1–381 of 381 · version 2026-09-19 22:15 · Entry point · pattern clockTargets (shared by 3 files)
- What it does
- It draws electron, qubit and entangle. Defines 33 functions or classes, including $, here, hash32, mulberry32, atomOf. Side effects: changes the web page (DOM); makes network requests; uses storage (browser storage, DuckDB or Parquet).
- Why it exists in the grid workflow
- Domain stage experimental (path word '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. Domain terms in the code: 400kV, 132kV.
- Inputs & outputs
- In: data source: ventus-grid-engine data; data source: gridatlas data; data source: pipelinenews data; data source: grid-dictionary data; data source: spiders data; data source: star-solar-star data; data source: code-generator data; data source: testcode data. Out: browser storage (setItem); canvas drawing. Voltage levels named: 400kV, 132kV.
- Downstream impact
- Used directly by 1 file: Wafer Development Environment — Proof S0004 Page (globalgrid2050, https://globalgrid2050.com/testcode/wafer-development-environment/202609192215-proof-s0004/). Reached from 114 other entry points, including GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html); GlobalGrid2050 Homepage Before Four Nests (globalgrid2050, https://globalgrid2050.com/homepage-before-four-nests-20260925.html); GlobalGrid2050 — Compute Page (globalgrid2050, https://globalgrid2050.com/compute/). It is itself an entry point, published at https://globalgrid2050.com/testcode/wafer-development-environment/202609192215-proof-s0004/.
- What it achieves
- It sets stack (`setStack`), describes line (`describeLine`) and loads net (`loadNet`). Quantum Twin — primary key to actual code flights. Its code works with 132 kV, 400 kV and 100 kW. It responds to resize, pointerdown and pointermove events.
- Why it matters
- Loaded by the Proof S0004 page at https://globalgrid2050.com/testcode/wafer-development-environment/202609192215-proof-s0004/.
- Application
- globalgrid2050 · testcode/wafer-development-environment/202609192215-proof-s0004 · JavaScript module
- Uses
- GridAtlas — Atlas Page (estate URL), Grid Dictionary — Index Page (estate URL), Spiders — Index Page (estate URL), Code Generator — Index Page (estate URL), Galaxies Wafers — Index Page (estate URL), Stars — Index Page (estate URL)
- Used by
- loaded by Wafer Development Environment — Proof S0004 Page (script src)
- Produces
- $, here, hash32, mulberry32, atomOf, twinOf, setStack, log, status, n, say, esc
- Defines here
- $, here, hash32, mulberry32, atomOf, twinOf, setStack, log, status, n, say, esc, fly, gh, signal, plainLabel, describeLine, run, earthUrl, W, hud, repoOf, scopeKeys, scopeFail, rasterLogo, toWafer, logoTargets, panelLink, j, loadNet
- 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/wafer-development-environment/202609192215-proof-s0004/pilot.mjs:1-381 · blob 40397039ffa84f57230845c03fc0972375ee9fcc · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, network, storage · domain stage: experimental · users: none · canonical: production_core
// Quantum Twin — primary key to actual code flights. The pilot on top of the Line Wafer.
// Two twins: the permanent key (chronological, never reused) and the actual line it stands for (repo, commit, path, line).
// This file drives the wafer through its own controls (line number · connect to… · FLY) and adds a command box,
// a narration card, qubit/measure (the Quantum Twin Star's own model and generator), apps, entanglement and engine calls.
// It runs in two modes: on the website (static files, engine imported live from ventus-grid-engine's published modules)
// and in CPU WORLD (a local server adds read-from-git and the runner swarm). No model, no colour beyond the wafer's own.
const $ = id => document.getElementById(id);
const here = (() => { const m = document.querySelector('meta[name="wafer-data"]'); return m ? new URL(m.content, location.href).href : new URL('.', location.href).href; })();
const ENGINE_WEB = 'https://ventusltd.github.io/ventus-grid-engine/engine/';
let labels = null, apps = null, keysDb = null, qubit = null, entangle = null, serverMode = false; const born = { count: 0, seed: '2026-09-14' };
const DIES = ['sld-sandbox', 'substation-intelligence', 'place-global-search', 'streaming-parquet-bridge'];
// The Quantum Twin Star's own generator (testcode/202609142202/quantum.js), copied exactly so a measurement here reproduces one there.
function hash32(str){ let h = 0x811c9dc5 >>> 0; for (let i = 0; i < str.length; i++) { h ^= str.charCodeAt(i); h = Math.imul(h, 0x01000193) >>> 0; } return h >>> 0; }
function mulberry32(a){ return function(){ a |= 0; a = a + 0x6D2B79F5 | 0; let t = Math.imul(a ^ a >>> 15, 1 | a); t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t; return ((t ^ t >>> 14) >>> 0) / 4294967296; }; }
function atomOf(k){ if (!keysDb || !qubit) return null; const i = keysDb.keys.indexOf(k); if (i < 0) return null; const fid = String(keysDb.family[i]); const a = qubit.atoms[fid]; return a ? { fid, i, ...a } : null; }
function twinOf(k){ if (!keysDb) return null; const i = keysDb.keys.indexOf(k); if (i < 0) return null; const pl = keysDb.places[keysDb.place[i]]; return { repo: pl[0], commit: pl[1], path: pl[2], line: keysDb.line[i] }; }
const css = document.createElement('style'); css.textContent = `
/* The bottom stack: the command bar, then the footer above it, then everything else above both.
The two heights are measured on the laid out page (setStack, below) because a guessed 58px is
what put the log and the example chooser on top of the footer in the first place. */
:root{--cmd:56px;--footh:34px;--stack:calc(var(--cmd) + var(--footh) + 8px);--statush:0px;--above:calc(var(--stack) + var(--statush) + 8px);--egh:0px}
#pilot{position:fixed;left:0;right:0;bottom:0;display:flex;gap:8px;padding:8px 12px;background:#0e121bf2;border-top:1px solid #1b2030;z-index:20}
#pilot input{flex:1;font:12px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;background:#11151f;color:#cfe3f2;border:1px solid #1b2030;border-radius:6px;padding:.6rem .9rem}
#pilot input:focus{outline:1px solid #5ec8f2}
#say{position:fixed;left:50%;top:calc(var(--toph) + 8px);transform:translateX(-50%);width:min(72ch,84vw);max-height:calc(100vh - var(--toph) - var(--above) - var(--beamh) - var(--egh) - 32px);min-width:280px;min-height:64px;background:#0e121bf2;border:1px solid #1b2030;border-radius:8px;padding:0;font:14px/1.5 ui-monospace,Menlo,Consolas,monospace;color:#cfe3f2;display:none;z-index:20;white-space: … [line shortened here: 472 characters; full line on GitHub]
#say.open{display:flex} #say.max{left:12px;top:12px;right:12px;bottom:var(--above);transform:none;width:auto;max-height:none;height:auto}
#say.min{height:auto!important;max-height:none;resize:none;width:min(48ch,84vw)} #say.min #saybody{display:none}
#saybar{display:flex;align-items:center;gap:6px;padding:4px 8px;border-bottom:1px solid #1b2030;background:#11151f;cursor:move;user-select:none;font-size:11px;color:#8b93a7;letter-spacing:.06em;text-transform:uppercase}
#saybar span{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} #saybar button{font:12px ui-monospace,Menlo,Consolas,monospace;background:#0e121b;color:#cfe3f2;border:1px solid #1b2030;border-radius:4px;width:24px;height:22px;cursor:pointer;padding:0}
#saybar button:hover{border-color:#5ec8f2} #saybody{padding:.8rem 1.1rem;overflow:auto;flex:1}
#saybody b{color:#5ec8f2} #say i{color:#f2b05e;font-style:normal} #say a{color:#5ec8f2} #saybody pre{max-height:38vh;overflow:auto;background:#11151f;border:1px solid #1b2030;border-radius:4px;padding:6px 8px;margin:6px 0;font:12px/1.5 ui-monospace,Menlo,Consolas,monospace;white-space:pre}
#saybody pre em{color:#5b6377;font-style:normal} #saybody pre u{display:block;text-decoration:none;color:#5b6377;font-size:11px;padding-left:4.2em;margin:0 0 2px}
#saybody pre .hit u{color:#8b93a7}
#saybody pre .hit{display:inline-block;width:100%;background:#1b2030;color:#f2b05e}
#saybody a.dev{float:right;font-size:11px;color:#5b6377}
#say code{display:block;background:#11151f;border:1px solid #1b2030;border-radius:4px;padding:2px 6px;color:#cfe3f2;margin:4px 0}
#eg{position:fixed;right:12px;bottom:calc(var(--above) + var(--beamh) + 8px);background:#0e121bf2;border:1px solid #1b2030;border-radius:8px;padding:.5rem .7rem;display:flex;flex-direction:column;gap:4px;max-width:46vw;z-index:20}
#eg label{font:11px ui-monospace,Menlo,Consolas,monospace;letter-spacing:.08em;text-transform:uppercase;color:#8b93a7}
#eg select{font:12px ui-monospace,Menlo,Consolas,monospace;background:#11151f;color:#cfe3f2;border:1px solid #1b2030;border-radius:6px;padding:.45rem .7rem}
#plog{position:fixed;left:12px;bottom:var(--stack);width:max-content;max-width:calc(100% - 24px);background:#11151fef;border:1px solid #1b2030;border-radius:6px;padding:.3rem .6rem;font:12px/1.5 ui-monospace,Menlo,Consolas,monospace;color:#cfe3f2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;pointer-events:none;z-index:19}
#plog:empty{display:none}
@media (max-width:640px){#hud{display:none}}
#core button{pointer-events:auto;min-height:44px;min-width:44px;padding:.55rem .9rem;font:13px/1.2 ui-monospace,Menlo,Consolas,monospace;letter-spacing:.04em;background:#0e121bf2;color:#cfe3f2;border:1px solid #5ec8f2;border-radius:8px;cursor:pointer;touch-action:manipulation}
#core button:hover,#core button:focus-visible{background:#11151f;border-color:#f2b05e;outline:none} #core button small{display:block;color:#8b93a7;font-size:10px;letter-spacing:.06em;text-transform:uppercase}
/* THE APP PANEL IS NOT THERE UNTIL IT IS OPENED. This was inside the phone media query, so above
640px it was a real full width box on the page with a link in it, invisible only because the
canvas is painted over it - and a link nobody can press is worse than no link at all. */
#earth{position:fixed;inset:0;z-index:30;display:none;flex-direction:column;background:#0b0e15}
#earth.open{display:flex}
/* and its bar and frame are styled at every width, for the same reason: this whole block used to
sit inside the phone media query, which left the panel unstyled anywhere else. */
#earthbar{display:flex;align-items:center;gap:10px;padding:6px 12px;background:#11151f;border-bottom:1px solid #1b2030;font:12px ui-monospace,Menlo,Consolas,monospace;color:#cfe3f2}
#earthbar b{color:#f2b05e;letter-spacing:.08em} #earthbar span{flex:1;color:#8b93a7;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#earthbar button,#earthbar a{font:12px ui-monospace,Menlo,Consolas,monospace;background:#0e121b;color:#5ec8f2;border:1px solid #1b2030;border-radius:6px;padding:.4rem .8rem;cursor:pointer;text-decoration:none}
#earthframe{flex:1;border:0;width:100%;background:#000}
`; document.head.appendChild(css);
document.body.insertAdjacentHTML('beforeend', `
<div id="say"></div><div id="plog"></div>
<div id="eg"><label>examples: pick one, it lands in the box, press Enter</label><select id="egs">
<option value="">— choose an example sentence —</option><option value="draw grid">Draw the grid: 400 kV, 132 kV and every substation</option><option value="draw grid400">Draw the 400 kV grid</option><option value="draw grid132">Draw the 132 kV network</option><option value="draw substations">Draw every substation</option><option value="draw shotwick">Draw Shotwick Solar Farm and the grid around it … [line shortened here: 964 characters; full line on GitHub]
<option value="block 39885">Go to the most-copied line in the estate (39885)</option>
<option value="twin 39885">The code behind block 39885, in the card</option>
<option value="state 39885">State of block 39885: HOME or AWAY, from its callers</option>
<option value="measure 39885">Measure block 39885: one recorded draw, HOME or AWAY</option>
<option value="connect 39885 1217">Connect two lines with the beam</option>
<option value="app gridatlas">Go to GridAtlas</option>
<option value="land gridatlas">Land on GridAtlas: the live app, inside this page</option>
<option value="land pipelinenews">Land on Pipeline News</option>
<option value="space">Back to space: the wafer</option>
<option value="apps">List every app on the wafer</option>
<option value="run voltage-drop.voltageDropVolts {"currentA":120,"lengthM":250,"resistanceOhmPerKm":0.32,"powerFactor":0.95,"phases":"three"}">Engine: voltage drop, 120 A over 250 m, 0.32 Ω/km, pf 0.95</option>
<option value="entangle">Check: how many blocks are found at their recorded line</option>
<option value="help">Help</option></select></div>
<form id="pilot"><input id="pin" autocomplete="off" autofocus placeholder="type a sentence or a command: block 39885 · twin 39885 · state 39885 · measure 39885 · app gridatlas · run voltage-drop… · help"></form>`);
/* THE BOTTOM STACK, MEASURED. The command bar's height depends on the font a reader's browser gives
it and on how the footer wraps at their width, so both heights are read off the laid out page and
published as --cmd and --footh. A guessed 58px is what buried the line that says what this page is
not. Measured again whenever either box changes shape, which includes a phone turning sideways. */
function setStack() {
const r = document.documentElement.style;
const bar = document.getElementById('pilot'), foot = document.getElementById('foot');
if (bar) r.setProperty('--cmd', Math.ceil(bar.getBoundingClientRect().height) + 'px');
if (foot) r.setProperty('--footh', Math.ceil(foot.getBoundingClientRect().height) + 'px');
const st = document.getElementById('plog');
if (st) r.setProperty('--statush', (st.textContent.trim() ? Math.ceil(st.getBoundingClientRect().height) : 0) + 'px');
const top = document.getElementById('bar'), menu = document.getElementById('presets'),
fly = document.getElementById('beam');
if (top) r.setProperty('--barh', Math.ceil(top.getBoundingClientRect().height) + 'px');
if (menu) r.setProperty('--toph', Math.ceil(menu.getBoundingClientRect().bottom) + 'px');
if (fly) r.setProperty('--beamh', Math.ceil(fly.getBoundingClientRect().height) + 'px');
const egs = document.getElementById('eg');
if (egs) r.setProperty('--egh', Math.ceil(egs.getBoundingClientRect().height) + 'px');
}
setStack();
addEventListener('resize', setStack);
if (window.ResizeObserver) {
const ro = new ResizeObserver(setStack);
['pilot', 'foot', 'plog', 'bar', 'presets', 'beam', 'eg'].forEach(id => { const e = document.getElementById(id); if (e) ro.observe(e); });
}
const EARTH_HTML = '<div id="earth"><div id="earthbar"><b>EARTH</b><span id="earthname"></span><a id="earthtab" target="_blank">open in its own tab</a><button id="earthback">back to space</button></div><iframe id="earthframe" title="the live app"></iframe></div>';
/* THE RUNNING COMMENTARY IS NOT FOR THE FACE. It was printed straight onto the drawing, twelve lines
at a time, one of them 1530 pixels wide inside a 1366 pixel window and off the edge of every phone,
and it explained the machine: "245,170 lines placed by: edge weight = the line's initial symmetrical
short-circuit current". A page carries what this is, what it is for, and what it is not. Every line
is still written, in full and unchanged, to the browser's own console and to window.__log, which is
where a reader checking a claim can read it. The face gets one plain sentence. */
const lines = [];
const log = s => {
lines.push(s); if (lines.length > 200) lines.shift();
window.__log = lines;
try { console.log(s); } catch {}
const plain = status(s);
if (plain) { $('plog').textContent = plain; setStack(); }
};
/* Nothing reaches the face unless it is named here, in plain words. A sentence the machine invents
tomorrow leaves the status line alone rather than quietly putting the machinery back on the page. */
function status(s) {
let m;
const n = x => Number(String(x).replace(/,/g, '')).toLocaleString('en-GB');
if ((m = /^draw \w+: ([\d,]+) nodes?, ([\d,]+) edges?/.exec(s))) return `Loaded. ${n(m[1])} places, ${n(m[2])} connections.`;
if (/^clock: /.test(s)) return 'Drawn from the time on this computer.';
if (/^logo \S+: assembled$/.test(s)) return 'Drawn.';
if ((m = /showing ([\d,]+) of ([\d,]+) lines/.exec(s))) return `Showing ${m[1]} of ${m[2]} lines.`;
if (/^error: /.test(s)) return 'That did not work. Try one of the buttons at the top.';
if (/not ready$|not loaded$|missing$/.test(s)) return 'Still loading. One moment.';
return null;
}
// the card is a small window: minimise, maximise, resize (drag the corner), close; any new answer reopens it
const sayEl = $('say'); sayEl.innerHTML = '<div id="saybar"><span id="saytitle">card</span><button id="saymin" title="minimise">–</button><button id="saymax" title="maximise">▢</button><button id="sayclose" title="close">×</button></div><div id="saybody"></div>';
let lastCard = '';
const say = html => { if (!html) { sayEl.classList.remove('open'); return; } lastCard = html; $('saybody').innerHTML = html; const t = $('saybody').querySelector('b'); $('saytitle').textContent = t ? t.textContent : 'card'; sayEl.classList.remove('min'); sayEl.classList.add('open'); };
$('saymin').onclick = e => { e.stopPropagation(); sayEl.classList.toggle('min'); }; $('saymax').onclick = e => { e.stopPropagation(); sayEl.classList.remove('min'); sayEl.classList.toggle('max'); }; $('sayclose').onclick = e => { e.stopPropagation(); sayEl.classList.remove('open', 'max', 'min'); };
$('saybar').ondblclick = () => sayEl.classList.toggle('min');
(() => { let d = null; $('saybar').addEventListener('pointerdown', e => { if (e.target.tagName === 'BUTTON' || sayEl.classList.contains('max')) return; const r = sayEl.getBoundingClientRect(); d = { x: e.clientX - r.left, y: e.clientY - r.top }; sayEl.style.transform = 'none'; sayEl.style.left = r.left + 'px'; sayEl.style.top = r.top + 'px'; $('saybar').setPointerCapture(e.pointerId); });
$('saybar').addEventListener('pointermove', e => { if (!d) return; sayEl.style.left = Math.max(0, e.clientX - d.x) + 'px'; sayEl.style.top = Math.max(0, e.clientY - d.y) + 'px'; }); $('saybar').addEventListener('pointerup', () => { d = null; }); $('saybar').addEventListener('pointercancel', () => { d = null; }); })();
window.__card = () => ({ open: sayEl.classList.contains('open'), min: sayEl.classList.contains('min'), max: sayEl.classList.contains('max'), w: sayEl.offsetWidth, h: sayEl.offsetHeight, title: $('saytitle').textContent });
const esc = s => String(s).replace(/</g, '<');
const fly = (a, b) => { $('a').value = String(a); $('b').value = b ? String(b) : ''; $('beam').requestSubmit(); };
const gh = t => `https://github.com/${t.repo}/blob/${t.commit}/${t.path}#L${t.line}`;
const signal = o => { if (serverMode) fetch('/signal', { method: 'POST', body: JSON.stringify(o) }).catch(() => {}); try { const L = JSON.parse(localStorage.getItem('qt-signals') || '[]'); L.push({ ...o, t: new Date().toISOString() }); localStorage.setItem('qt-signals', JSON.stringify(L.slice(-500))); } catch {} };
// ---------- plain English: engine calls get a label; every line in the code view gets a note (same rules as pipeline/describe.py) ----------
const PLAIN = {
'voltage-drop.voltageDropVolts': a => `voltage drop for ${a.currentA} A over ${a.lengthM} m at ${a.resistanceOhmPerKm} Ω/km${a.reactanceOhmPerKm ? ' (reactance ' + a.reactanceOhmPerKm + ')' : ''}, power factor ${a.powerFactor}, ${a.phases || 'three'}-phase`,
'voltage-drop.dropPercent': a => `${a.dropVolts} V drop as a share of ${a.nominalVolts} V`, 'voltage-drop.lossesWatts': a => `heat lost in the cable: ${a.currentA} A over ${a.lengthM} m at ${a.resistanceOhmPerKm} Ω/km`,
'diversified-demand.diversifiedDemandKw': a => `demand of ${a.unitCount} units at ${a.perUnitKw} kW each, coincidence ${a.coincidenceFactor}`,
'current-from-power.currentA': a => `current for ${a.apparentPowerVa} VA at ${a.voltageV} V, ${a.phases || 'three'}-phase`, 'firm-capacity.apparentPowerMva': a => `apparent power for ${a.mw} MW at power factor ${a.powerFactor}`,
'power-factor.reactivePowerKvar': a => `reactive power for ${a.kw} kW at power factor ${a.powerFactor}`,
};
const plainLabel = (mod, fn, args) => { const f = PLAIN[`${mod}.${fn}`]; try { return f ? f(args) : `${mod.replace(/-/g, ' ')}: ${fn.replace(/([A-Z])/g, ' $1').toLowerCase()}`; } catch { return `${mod}.${fn}`; } };
const DESCRIBE_RULES = [
[/^\s*$/, 'blank line'], [/^\s*\/\//, 'a comment'], [/^\s*\/\*|^\s*\*/, 'a comment block'],
[/^\s*(import|export)\b/, 'brings code in or out of this file'], [/^\s*(?:async\s+)?function\s+(\w+)/, 'defines the function $1'],
[/^\s*(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s*)?\(?[^=]*=>/, 'defines the function $1'], [/^\s*(?:const|let|var)\s+(\w+)\s*=/, 'sets $1'],
[/\.addEventListener\(\s*['"](\w+)/, 'listens for a $1 on the page'], [/^\s*return\b/, 'hands a result back'], [/^\s*if\b/, 'decides: only when the condition holds'],
[/^\s*(?:else|\} else)/, 'otherwise'], [/^\s*for\b|^\s*while\b/, 'repeats for each item'], [/^\s*try\b/, 'tries, ready to catch a failure'], [/^\s*catch\b|\} catch/, 'handles a failure'],
[/\.(?:querySelector|getElementById)\(/, 'finds a part of the page'], [/\.innerHTML\s*=|\.textContent\s*=/, 'writes text onto the page'], [/\bfetch\(/, 'asks a server for data'],
[/\bclassList\./, 'changes how a part of the page looks'], [/\bconsole\./, 'writes to the developer console'], [/\bthrow\b/, 'stops with an error'],
[/^\s*\}\s*\)?;?\s*$|^\s*\]\s*;?\s*$/, 'closes a block'], [/^\s*(\w+)\s*\(.*\)\s*;?\s*$/, 'calls $1'], [/\bawait\b/, 'waits for a result'], [/=/, 'sets a value'],
];
const describeLine = line => { for (const [re, note] of DESCRIBE_RULES) { const m = line.match(re); if (m) return note.replace(/\$(\d)/g, (_, i) => m[+i] || ''); } return 'a line of code'; };
window.__describe = describeLine;
const cmds = {
help(){ say(`<b>commands</b>\nblock <key> · twin <key> · read <key> · state <key> · measure <key> [seed] · connect <a> <b> · land <app> · space · app <name> · apps · engine · run <module>.<fn> {…} · entangle · reset\nor a sentence: "fly to 39885", "show me gridatlas", "voltage drop for 120 A over 250 m at 0.32 ohm pf 0.95"\n\nEach … [line shortened here: 500 characters; full line on GitHub]
block(k){ k = parseInt(k, 10); if (!Number.isFinite(k)) return log('block <key>'); fly(k); say(`<b>block ${k}</b>\nthe beam is on line ${k}; the panel on the left shows what it is.\n<i>next:</i> twin ${k}`); log(`block ${k}`); },
fly(k){ return cmds.block(k); }, goto(k){ return cmds.block(k); },
async twin(k){ k = parseInt(k, 10); const t = twinOf(k); if (!t) return log(`twin ${k}: this block has no recorded line`); fly(k); return cmds.showCode(k, t, 'twin'); },
async read(k){ k = parseInt(k, 10); const t = twinOf(k); if (!t) return log(`read ${k}: this block has no recorded line`); fly(k); return cmds.showCode(k, t, 'read'); },
// the code itself, in the card, scrollable, the line highlighted; the source link is a fallback for developers
async showCode(k, t, verb){ const raw = `https://raw.githubusercontent.com/${t.repo}/${t.commit}/${t.path}`; let lines = null;
try { const r = await fetch(raw); if (r.ok) lines = (await r.text()).split(/\r?\n/); } catch {}
if (!lines && serverMode) { try { const r = await (await fetch('/line?key=' + k)).json(); if (!r.error) lines = [...r.before, r.text, ...r.after].map(x => x ?? ''); } catch {} }
const head = `<b>${verb} ${k}</b> — ${esc(t.repo.split('/').pop())} · ${esc(t.path.split('/').pop())} · line ${t.line}`;
if (!lines) { say(`${head}
could not load the file here.
<a target="_blank" href="${gh(t)}">source, for developers</a>`); return log(`${verb} ${k}: file not loaded; source link shown`); }
const from = Math.max(1, t.line - 20), to = Math.min(lines.length, t.line + 20); const rows = [];
for (let n = from; n <= to; n++) rows.push(`<span class="${n === t.line ? 'hit' : ''}"><em>${String(n).padStart(5)}</em> ${esc(lines[n - 1] ?? '')}<u>${esc(describeLine(lines[n - 1] ?? ''))}</u></span>`);
say(`${head}
<pre id="code">${rows.join('\n')}</pre><i>next:</i> state ${k} <a class="dev" target="_blank" href="${gh(t)}">source, for developers</a>`);
const hit = document.querySelector('#code .hit'); if (hit) hit.scrollIntoView({ block: 'center' }); log(`${verb} ${k}: ${t.path.split('/').pop()} line ${t.line}: ${(lines[t.line - 1] || '').trim().slice(0, 60)}`); },
state(k){ k = parseInt(k, 10); const a = atomOf(k); if (!a) return log(`state ${k}: this block has no family record`); const n = a.K + a.L + a.M; const pAway = n ? a.M / n : 0; const theta = 2 * Math.asin(Math.sqrt(pAway)); fly(k);
say(`<b>state ${k}</b> — block family #${esc(a.fid)} ${esc(a.name && a.name !== '(anonymous)' ? a.name : 'unnamed')} (${a.source === 'electron.json' ? 'from the published data' : 'estimated from where its copies sit'})\ncallers: K ${a.K} same directory · L ${a.L} same repository · M ${a.M} other repositories\nHOME P = ${(1 - pAway).toFixed(3)} · AWAY P = ${pAway.toFixed(3)} (AWAY = M ÷ (K+L+M) … [line shortened here: 593 characters; full line on GitHub]
qubit(k){ return cmds.state(k); },
measure(rest){ const [ks, seedArg] = (rest || '').split(/\s+/); const k = parseInt(ks, 10); const a = atomOf(k); if (!a) return log(`measure ${ks}: this block has no family record`); if (seedArg) born.seed = seedArg;
const n = a.K + a.L + a.M; const pAway = n ? a.M / n : 0; const r = mulberry32(hash32(`${born.seed}|${a.fid}|${born.count}`))(); born.count++; const away = r < pAway; const outcome = away ? 'AWAY' : 'HOME';
const audit = `Draw ${born.count + 1}: seed "${born.seed}" · state #${a.fid} · r=${r.toFixed(6)} ${away ? '<' : '≥'} P(away)=${pAway.toFixed(3)} → ${outcome}`;
say(`<b>measure ${k}</b> — result: <b>${outcome}</b>\n${esc(audit)}\nThe same seed, block and count always give the same result. Type <i>state ${k}</i> to see the probabilities again.`); log(audit);
signal({ kind: 'born', key: k, family: a.fid, seed: born.seed, count: born.count, r, p_away: pAway, outcome: away ? 'AWAY' : 'HOME', shells: { K: a.K, L: a.L, M: a.M } }); },
connect(ab){ const [a, b] = (ab || '').split(/\s+/).map(x => parseInt(x, 10)); if (!Number.isFinite(a) || !Number.isFinite(b)) return log('connect <a> <b>'); fly(a, b); say(`<b>connect ${a} → ${b}</b>\nthe beam joins two keys; both twins are real lines.`); log(`connect ${a} ${b}`); },
apps(){ if (!apps) return log('apps not loaded'); const list = apps.apps.filter(a => a.app); say(`<b>${list.length} apps</b> (${esc(apps.rule)})\n` + list.map((a, i) => { const L = labels && labels.labels[a.name]; return `${i + 1}. ${a.name} — ${L ? labels.kinds[L.kind] + ': ' + L.what : ''} · ${a.keys.toLocaleString()} blocks`; }).join('\n') + `\n<i>next:</i> app <name>`); log(`${list.len … [line shortened here: 415 characters; full line on GitHub]
app(name){ if (!apps) return log('apps not loaded'); const list = apps.apps.filter(a => a.app); const a = list.find(x => x.name === (name || '').toLowerCase()) || list.find(x => x.name.includes((name || '').toLowerCase())); if (!a) return log(`no app "${name}"`);
const [k0, k1] = apps.first[a.repo]; fly(k0, k1); const url = a.name === 'globalgrid2050' ? 'https://globalgrid2050.com/' : `https://ventusltd.github.io/${a.name}/`;
say(`<b>app ${esc(a.name)}</b> — ${(() => { const L = labels && labels.labels[a.name]; return L ? esc(labels.kinds[L.kind] + '. ' + L.what) : ''; })()}\n${a.keys.toLocaleString()} blocks in ${a.families} gates · index ${esc(a.index || '?')}\nthe beam spans its first and middle lines (${k0} → ${k1}).\n<a target="_blank" href="${url}">open ${esc(a.name)} — see the code in action</a> · <a targe … [line shortened here: 490 characters; full line on GitHub]
async engine(){ const mods = ['voltage-drop', 'diversified-demand', 'current-from-power', 'firm-capacity', 'power-factor', 'connection-capacity']; const out = []; for (const m of mods) { try { const mod = await import(ENGINE_WEB + m + '.js'); out.push(`${m}: ${Object.keys(mod).filter(k => typeof mod[k] === 'function').join(', ')}`); } catch (e) { out.push(`${m}: (not reachable: ${e.message})`); … [line shortened here: 403 characters; full line on GitHub]
say(`<b>engine</b> — ventus-grid-engine, imported live from its published modules\n${esc(out.join('\n'))}\n<i>next:</i> run voltage-drop.voltageDropVolts {…}`); log('engine listed'); },
async run(rest){ const m = /^([a-z0-9-]+)\.([A-Za-z0-9_]+)\s*(\{[\s\S]*\})?$/.exec((rest || '').trim()); if (!m) return log('run <module>.<fn> {…}'); let args = {}; try { args = m[3] ? JSON.parse(m[3]) : {}; } catch { return log('run: arguments are not valid JSON'); }
let result, err, us = 0; try { const mod = await import(ENGINE_WEB + m[1] + '.js'); if (typeof mod[m[2]] !== 'function') throw new Error(`no function ${m[2]} in ${m[1]}; has ${Object.keys(mod).filter(k => typeof mod[k] === 'function').join(', ')}`); const t0 = performance.now(); result = mod[m[2]](args); us = (performance.now() - t0) * 1000; } catch (e) { err = e.message; }
if (err) { say(`<b>engine ${esc(m[1])}.${esc(m[2])}</b>\n<code>refused: ${esc(err)}</code>`); return log(`run refused: ${err}`); }
const big = (result?.unit && /^(kW|kVA)$/.test(result.unit) && result.value > 100) || (result?.unit && /^(MW|MVA)$/.test(result.unit) && result.value > 0.1) || Object.entries(args).some(([k, v]) => (/mw|mva/i.test(k) && v * 1000 > 100) || (/kw|kva/i.test(k) && v > 100));
say(`<b>${esc(plainLabel(m[1], m[2], args))}</b>\nengine ${esc(m[1])}.${esc(m[2])} · ${us.toFixed(0)} µs · imported from ventusltd.github.io/ventus-grid-engine\nin <code>${esc(JSON.stringify(args))}</code>out <code>${esc(JSON.stringify(result, null, 1))}</code>${big ? '<i>above 100 kW: a chartered electrical engineer must sign any real design.</i>\n' : ''}This page shows figures; it is not the … [line shortened here: 563 characters; full line on GitHub]
entangle(){ if (!entangle) return log('entangle not loaded'); say(`<b>entangle</b> (${esc(entangle.generated_utc)})\n${entangle.resolved.toLocaleString()} of ${entangle.keys.toLocaleString()} blocks reach their twin line (${(entangle.rate * 100).toFixed(2)} %) · ${entangle.broken.toLocaleString()} broken\nmeasured by fetching every twin from its commit and hashing the line (pipeline/entangle.py) … [line shortened here: 503 characters; full line on GitHub]
reset(){ $('a').value = ''; $('b').value = ''; $('panel').hidden = true; say(''); log('reset'); }, home(){ return cmds.reset(); },
die(w){ return log('die: available in CPU WORLD (needs route-gridatlas.json)'); }, light(w){ return cmds.app('gridatlas'); },
};
async function run(line){ const [c, ...rest] = line.trim().split(/\s+/); const w = (c || '').toLowerCase(); const fn = Object.hasOwn(cmds, w) ? cmds[w] : null;
if (!fn) { const p = plan(line, { appNames: apps ? apps.apps.filter(a => a.app).map(a => a.name) : [], dies: DIES }); log(`> ${line}`); log(` plan: ${p.commands.length ? p.commands.join(' → ') : '(none)'} — ${p.because}`); if (p.commands.length) log(` you could have typed: ${p.commands.join(' then ')}`);
for (const c2 of p.commands) { const [w2, ...r2] = c2.split(/\s+/); if (Object.hasOwn(cmds, w2)) { try { await cmds[w2](r2.join(' ')); } catch (e) { log('error: ' + e.message); } } } signal({ kind: 'pilot', sentence: line, plan: p.commands }); return; }
log(`> ${line}`); try { await fn(rest.join(' ')); } catch (e) { log('error: ' + e.message); } }
$('pilot').onsubmit = e => { e.preventDefault(); const v = $('pin').value; $('pin').value = ''; if (v.trim()) run(v); };
$('egs').onchange = e => { if (e.target.value) { if (e.target.value === $('pin').dataset.last && lastCard && !sayEl.classList.contains('open')) { say(lastCard); log('card reopened'); } else { $('pin').value = e.target.value; $('pin').dataset.last = e.target.value; log('example loaded — press Enter to run it'); $('pin').focus(); } } e.target.selectedIndex = 0; };
addEventListener('keydown', e => { const t = e.target.tagName; if (t === 'INPUT' || t === 'SELECT' || t === 'TEXTAREA' || t === 'BUTTON') return; if (e.key.length === 1) $('pin').focus(); });
// ---------- space <-> earth: the live apps, by name, inside the page ----------
const EARTH = { gridatlas: 'https://ventusltd.github.io/gridatlas/atlas/', pipelinenews: 'https://ventusltd.github.io/pipelinenews/', globalgrid2050: 'https://globalgrid2050.com/', 'grid-dictionary': 'https://ventusltd.github.io/grid-dictionary/', spiders: 'https://ventusltd.github.io/spiders/', 'star-solar-star': 'https://ventusltd.github.io/star-solar-star/', 'code-generator': 'https://ventusltd … [line shortened here: 889 characters; full line on GitHub]
document.body.insertAdjacentHTML('beforeend', EARTH_HTML);
const earthUrl = name => EARTH[name] || (apps && apps.apps.find(a => a.app && a.name === name) ? `https://ventusltd.github.io/${name}/` : null);
cmds.land = function(name){ name = (name || '').toLowerCase().trim(); const key = Object.keys(EARTH).find(k => k === name) || Object.keys(EARTH).find(k => k.includes(name)) || (apps ? (apps.apps.find(a => a.app && a.name.includes(name)) || {}).name : null);
const url = key ? earthUrl(key) : null; if (!url) return log(`land <app>: ${Object.keys(EARTH).join(', ')}`);
$('earthname').textContent = `${key} · ${url}`; $('earthtab').href = url; $('earthframe').src = url; $('earth').classList.add('open'); say(''); log(`landed on ${key} — type space to come back`); };
cmds.visit = cmds.land; cmds.go = cmds.land; cmds.open = cmds.land;
cmds.space = function(){ $('earth').classList.remove('open'); $('earthframe').src = 'about:blank'; log('back in space: the wafer'); };
$('earthback').onclick = () => cmds.space();
document.body.insertAdjacentHTML('beforeend', '<div id="hud" style="position:fixed;right:12px;top:calc(var(--barh) + 8px);font:11px/1.5 ui-monospace,Menlo,Consolas,monospace;color:#8b93a7;pointer-events:none;z-index:19"></div>');
const W = () => window.__wafer; const fmtN = n => n.toLocaleString('en-GB');
const hud = s => { const st = W() && W().state(); if (!st) return; $('hud').textContent = `showing ${fmtN(st.scopeN)} of ${fmtN(st.n)} lines${s ? ' · ' + s : ''}`; };
let scopeName = 'all';
const repoOf = name => { if (!apps) return null; const a = apps.apps.find(x => x.name === name) || apps.apps.find(x => x.name.includes(name)); return a ? a.repo : null; };
// a scope is a set with a rule: all · an app (apps.json keys per repo) · module <path> · gate <family#> · line <key>
function scopeKeys(spec){ const s = (spec || 'all').trim(); const [kind, ...r] = s.split(/\s+/); const arg = r.join(' ');
if (!s || s === 'all' || s === 'estate') return { name: 'all', keys: null };
if (kind === 'line' || kind === 'key') { const k = parseInt(arg, 10); return Number.isFinite(k) ? { name: `line ${k}`, keys: [k] } : null; }
if (kind === 'gate' || kind === 'family') { if (!keysDb) return null; const fid = parseInt(arg, 10); const ks = []; for (let i = 0; i < keysDb.keys.length; i++) if (keysDb.family[i] === fid) ks.push(keysDb.keys[i]); return ks.length ? { name: `gate ${fid}`, keys: ks } : null; }
if (kind === 'module' || kind === 'file' || kind === 'die') { if (!keysDb) return null; const ks = []; for (let i = 0; i < keysDb.keys.length; i++) if (keysDb.places[keysDb.place[i]][2].includes(arg)) ks.push(keysDb.keys[i]); return ks.length ? { name: `module ${arg}`, keys: ks } : null; }
const repo = repoOf(s.toLowerCase()); const ks = repo && apps.keys ? apps.keys[repo] : null; return ks ? { name: repo.split('/').pop(), keys: ks } : null; }
const scopeFail = spec => { log(`scope ${spec}: not a scope — try all, an app name (apps), module <path>, gate <family#>, line <key>`); };
cmds.scope = function(spec){ if (!W()) return log('the wafer is not ready'); const sc = scopeKeys(spec); if (!sc) return scopeFail(spec); const r = W().scope(sc.keys); scopeName = sc.name; hud(sc.name);
log(`scope ${sc.name}: showing ${fmtN(r.shown)} of ${fmtN(r.of)} lines${r.missing ? ` · ${fmtN(r.missing)} keys not numbered here` : ''}`); return r; };
cmds.gravity = async function(spec){ if (!W()) return log('the wafer is not ready'); const sc = scopeKeys(spec); if (!sc) return scopeFail(spec); scopeName = sc.name; const k = W().kepler();
log(`gravity ${sc.name}: Kepler r(θ) = p/(1 + e·cos θ), e = ${k.e}, p = ${k.p.toFixed(1)}, the wafer's centre at the focus, points in key order`); const r = await W().gravity(sc.keys); hud(sc.name + ' · kepler'); log(`gravity ${sc.name}: ${fmtN(r.shown)} lines in orbit${r.missing ? ` · ${fmtN(r.missing)} keys not numbered here` : ''}`); return r; };
cmds.orbit = cmds.gravity; cmds.isolate = cmds.gravity;
cmds.release = async function(){ if (!W()) return log('the wafer is not ready'); const r = await W().release(); scopeName = 'all'; hud(); log(`release: showing ${fmtN(r.shown)} of ${fmtN(r.of)} lines, back on the wafer law`); return r; };
// LOGO: the same dust, the same blend; the target is the wordmark rasterised once, deterministically, off screen (sampled only, never shown)
const LOGO = { lines: ['VENTUS — CABLES AND CONNECTIVITY', 'GLOBALGRID2050'], font: 'bold 120px ui-monospace', step: 2, lineGap: 150, fill: 1.6 };
let logoRaster = null;
function rasterLogo(){ if (logoRaster) return logoRaster; const c = document.createElement('canvas'); const g = c.getContext('2d'); g.font = LOGO.font;
const w = Math.ceil(Math.max(...LOGO.lines.map(t => g.measureText(t).width))) + 40, h = LOGO.lineGap * LOGO.lines.length + 40; c.width = w; c.height = h; g.font = LOGO.font; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillStyle = '#fff';
LOGO.lines.forEach((t, i) => g.fillText(t, w / 2, 20 + LOGO.lineGap * (i + 0.5))); const px = g.getImageData(0, 0, w, h).data; const on = new Uint8Array(w * h); const samples = [];
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) { if (px[(y * w + x) * 4 + 3] > 127) { on[y * w + x] = 1; if (x % LOGO.step === 0 && y % LOGO.step === 0) samples.push(x, y); } }
const st = W().state(); const s = LOGO.fill * Math.sqrt(st.max) / w; /* wafer units per canvas px: the text spans 1.6·R inside the wafer */
const G = W().kepler().coreOut; /* the two lines part around the core: line 1 lifted by 0.10·R, line 2 lowered by it; the pupil stays empty */
const toWafer = (x, y) => [(x - w / 2) * s, (h / 2 - y) * s + (y < h / 2 ? G : -G)]; const toCanvas = (X, Y) => [X / s + w / 2, h / 2 - (Y > 0 ? Y - G : Y + G) / s];
return (logoRaster = { w, h, on, samples, n: samples.length / 2, s, toWafer, toCanvas }); }
function logoTargets(m){ const L = rasterLogo(); const t = new Float32Array(m * 2); const S = L.n;
for (let j = 0; j < m; j++) { let q, dx = 0, dy = 0; if (m <= S) q = Math.floor(j * S / m); else { q = j % S; const c = Math.floor(j / S); dx = ((c * 7) % LOGO.step) / LOGO.step - 0.5; dy = ((c * 3) % LOGO.step) / LOGO.step - 0.5; } /* cycle with a tiny deterministic offset */
const [X, Y] = L.toWafer(L.samples[2 * q] + dx, L.samples[2 * q + 1] + dy); t[2 * j] = X; t[2 * j + 1] = Y; } return t; }
cmds.logo = async function(spec){ if (!W()) return log('the wafer is not ready'); const sc = scopeKeys(spec || scopeName); if (!sc) return scopeFail(spec); const r = await W().scope(sc.keys); scopeName = sc.name; const L = rasterLogo(); const m = W().state().scopeN;
log(`logo ${sc.name}: ${fmtN(m)} lines → "${LOGO.lines.join(' / ')}" (${fmtN(L.n)} glyph samples, ${LOGO.font}, grid ${LOGO.step} px)`); say(`<b>The wordmark</b>\nThe same dots as the drawings, arranged into the name of this project. It shows that any one of them can be put anywhere on demand. A demonstration, not a measurement of anything.`);
await W().blend(logoTargets(m)); hud(sc.name + ' · logo');
log(`logo ${sc.name}: assembled`); return r; };
cmds.wordmark = cmds.logo;
// test instrument: share of in-scope points within tolPx (screen px) of a glyph pixel
window.__logoCheck = (tolPx = 3) => { const L = rasterLogo(); const st = W().state(); const rad = Math.max(1, Math.ceil(tolPx / (st.view.zoom * L.s))); const P = W().positions(); let hit = 0;
for (const [, X, Y] of P) { const [cx, cy] = L.toCanvas(X, Y); let ok = false; for (let y = Math.round(cy) - rad; y <= Math.round(cy) + rad && !ok; y++) for (let x = Math.round(cx) - rad; x <= Math.round(cx) + rad; x++) if (x >= 0 && y >= 0 && x < L.w && y < L.h && L.on[y * L.w + x]) { ok = true; break; } if (ok) hit++; }
return { n: P.length, hit, share: P.length ? hit / P.length : 0, radiusCanvasPx: rad, samples: L.n }; };
window.__scopeKeys = spec => { const sc = scopeKeys(spec); return sc ? { name: sc.name, count: sc.keys ? sc.keys.length : null } : null; };
setTimeout(() => hud(), 1500);
// an app is a scope with gravity: app <name> and land <name> pull that app's lines in under Kepler; space releases them to the wafer law
{ const _app = cmds.app, _land = cmds.land, _space = cmds.space;
cmds.app = async function(name){ const r = _app.call(cmds, name); if (W() && name && scopeKeys(name)) await cmds.gravity(name); return r; };
cmds.land = async function(name){ if (W() && name && scopeKeys(name)) await cmds.gravity(name); return _land.call(cmds, name); };
cmds.space = function(){ const r = _space.call(cmds); if (W()) cmds.release(); return r; }; }
window.__earth = () => ({ open: $('earth').classList.contains('open'), name: $('earthname').textContent, src: $('earthframe').src });
// the particles do the work: when the wafer's own panel opens for a line, add one plain link to the app that line belongs to
const APP_OF_REPO = { gridatlas: 'gridatlas', pipelinenews: 'pipelinenews', globalgrid2050: 'globalgrid2050', 'ventus-grid-engine': 'spider sandbox', elements: 'periodic table', 'grid-dictionary': 'grid-dictionary', spiders: 'spiders', 'star-solar-star': 'star-solar-star', 'code-generator': 'code-generator', testcode: 'testcode', 'galaxies-wafers': 'galaxies-wafers', stars: 'stars' };
const panelLink = () => { const body = $('panelbody'); if (!body || body.querySelector('.landlink')) return; const m = (body.innerText || '').match(/Line\s+([\d,]+)/); if (!m) return; const key = +m[1].replace(/,/g, ''); const t = twinOf(key); if (!t) return;
const repo = t.repo.split('/')[1]; const app = APP_OF_REPO[repo]; if (!app) return; const url = EARTH[app] || `https://ventusltd.github.io/${repo}/`;
body.insertAdjacentHTML('beforeend', `<p class="landlink" style="margin:.6rem 0 0"><a href="${url}" style="color:#5ec8f2">land on ${app} — this line's app</a> <span style="color:#8b93a7">· or type: land ${app}</span></p>`);
body.querySelector('.landlink a').addEventListener('click', e => { e.preventDefault(); run('land ' + app); }); };
new MutationObserver(panelLink).observe($('panelbody'), { childList: true, subtree: true });
window.__pilot = run;
(async () => {
serverMode = /^(127\.0\.0\.1|localhost)$/.test(location.hostname) && await fetch('/gpu', { cache: 'no-store' }).then(r => r.ok).catch(() => false);
if (serverMode) (async function poll(){ try { const { lines: L } = await (await fetch('/pilot/next')).json(); for (const l of L) { log(`[powershell] ${l}`); await run(l); } } catch {} setTimeout(poll, 500); })();
const j = async f => fetch(here + f).then(r => r.ok ? r.json() : null).catch(() => null);
[keysDb, qubit, apps, entangle, labels] = await Promise.all([j('keys.json'), j('qubit.json'), j('apps.json'), j('entangle.json'), j('labels.json')]);
log(`Quantum Twin — primary key to actual code. ${keysDb ? keysDb.count.toLocaleString() : '?'} blocks with a recorded line; ${qubit ? Object.keys(qubit.atoms).length.toLocaleString() : '?'} block families.`);
log('Type a sentence or a command. Every answer shows the command it became. Try: block 39885');
const qd = new URLSearchParams(location.search).get('draw'); const start = qd ? (['logo', 'clock'].includes(qd) ? qd : 'draw ' + qd) : document.querySelector('meta[name="wafer-start"]')?.content; if (start) { await new Promise(r => setTimeout(r, 1500)); const m = /^(land|visit|go|open)\s+(\S+)/.exec(start); if (m) { await run('app ' + m[2]); log(`This page stops here. To enter ${m[2]}, type: lan … [line shortened here: 570 characters; full line on GitHub]
twelve views offered a frame with a cut off title and not one sentence under it. */ }
})();
// ---------- NETWORK: a whole system drawn from a typed command, on the wafer's own dust (no new looks) ----------
// draw underground: the London Underground's topology (Transport for London open data; stations and the order of
// stops) laid out by an eight-direction schematic law, then the in-scope particles are placed along its edges and at
// its stations by the same blend gravity and the logo use. Positions are computed, never stored; identity never moves.
const netCache = {};
/* WHAT EACH DRAWING IS, IN THREE SENTENCES: what it is, what it is for, and what it is not. The
reader is the person who signs a project, not a coder, and he has about ten seconds. The title is
short on purpose: it has to fit its own bar on a phone without being cut off mid word. */
const NETWORKS = {
grid: ['The grid', 'Britain’s 400 kV and 132 kV lines and its substations, drawn from public data.', 'See what runs near a site and where it could connect.'],
grid400: ['The 400 kV grid', 'Britain’s highest voltage transmission lines, drawn from public data.', 'See how far a site sits from the main network.'],
grid132: ['The 132 kV network', 'Britain’s 132 kV lines, drawn from public data.', 'See the voltage level most new projects connect at.'],
substations: ['Substations', 'Every substation in the public map of Britain’s network.', 'See which ones are near a site before asking for a connection.'],
shotwick: ['Shotwick solar farm', 'A built solar farm and the network around it, drawn from public data.', 'See what a finished connection looks like on the map.'],
underground: ['The London Underground', 'Every line and station of the London Underground, drawn from public data.', 'See how a dense network reads at the same scale as the grid.'],
uk: ['The British Isles', 'The coastline of the British Isles, drawn from public data.', 'The outline the network drawings sit on.'],
world: ['The world', 'The coastlines of the world, drawn from public data.', 'The scale everything else on this page sits in.'],
trench: ['A cable trench', 'Four circuits in flat formation, at a stated spacing and depth.', 'See the arrangement a cable rating is worked out from.'],
fault: ['A fault study', 'The fault current paths in a published example network.', 'See which lines carry the most current when a fault happens.'],
};
const NOT_A_STUDY = 'An estimate from public data, not a study.';
const loadNet = async name => netCache[name] || (netCache[name] = await fetch(new URL(name + '-network.json', location.href)).then(r => r.ok ? r.json() : null).catch(() => null));
function networkTargets(N, m){
const S = 0.85 * W().kepler().R, st = N.stations, E = N.edges, GA = 2.399963229728653;
const perStation = E.length ? 9 : Math.max(1, Math.floor(m / st.length)), stationDots = Math.min(m, perStation * st.length), edgeDots = E.length ? m - stationDots : 0;
const lens = E.map(([a, b, w]) => Math.hypot(st[b][0] - st[a][0], st[b][1] - st[a][1]) * (w == null ? 1 : w)); const L = lens.reduce((a, b) => a + b, 0) || 1;
const t = new Float32Array(m * 2); let j = 0;
for (let e = 0; e < E.length && j < edgeDots; e++) { const [a, b] = E[e]; const k = Math.max(1, Math.round(edgeDots * lens[e] / L));
for (let i = 0; i < k && j < edgeDots; i++, j++) { const u = (i + 0.5) / k; t[2 * j] = S * (st[a][0] + (st[b][0] - st[a][0]) * u); t[2 * j + 1] = S * (st[a][1] + (st[b][1] - st[a][1]) * u); } }
for (let s = 0; j < m; s++, j++) { const q = s % st.length, c = Math.floor(s / st.length), th = c * GA, r = 0.004 * S * Math.sqrt(c);
t[2 * j] = S * st[q][0] + r * Math.cos(th); t[2 * j + 1] = S * st[q][1] + r * Math.sin(th); }
return t;
}
cmds.draw = async function(spec){
let what = (spec || '').trim().toLowerCase().split(/\s+/)[0] || ''; if (/^(tube|london)$/.test(what)) what = 'underground';
if (!NETWORKS[what]) return log('draw <system> — one of: ' + Object.keys(NETWORKS).join(', '));
if (!W()) return log('the wafer is not ready');
const N = await loadNet(what); if (!N) return log(`draw ${what}: ${what}-network.json missing`);
await W().scope(null); const m = W().state().scopeN;
log(`draw ${what}: ${N.stations.length} nodes, ${N.edges.length} edges; ${m.toLocaleString('en-GB')} lines placed by: ${N.law}`);
const [title, isWhat, isFor] = NETWORKS[what];
/* The sentences go up BEFORE the drawing assembles, not after it: they are what the reader came
for, and they do not depend on the animation having finished. */
say(`<b>${title}</b>
${isWhat} ${isFor} ${NOT_A_STUDY}
<small>${N.attribution}</small>`);
await W().blend(networkTargets(N, m)); hud(what);
log(`draw ${what}: drawn`); return { system: what, nodes: N.stations.length, edges: N.edges.length, placed: m };
};
cmds.underground = () => cmds.draw('underground'); cmds.tube = cmds.underground;
// ---------- CLOCK: time as a law on the same dust. The face is a ring of ticks, the hands are lines of particles
// from the centre; positions are a pure function of the clock at the moment of drawing; redrawn every 10 s while on.
let clockTimer = null;
function clockTargets(m, d){
const R = 0.85 * W().kepler().R, t = new Float32Array(m * 2); let j = 0;
const put = (x, y) => { if (j < m) { t[2 * j] = x; t[2 * j + 1] = y; j++; } };
const ring = Math.floor(m * 0.45), ticks = Math.floor(m * 0.15), hands = m - ring - ticks;
for (let i = 0; i < ring; i++) { const a = i / ring * 2 * Math.PI; put(R * Math.cos(a), R * Math.sin(a)); }
for (let i = 0; i < ticks; i++) { const h = i % 12, u = (Math.floor(i / 12) % 40) / 40, a = Math.PI / 2 - h * Math.PI / 6; const r = R * (0.86 + 0.1 * u); put(r * Math.cos(a), r * Math.sin(a)); }
const s = d.getSeconds() + d.getMilliseconds() / 1000, mi = d.getMinutes() + s / 60, h = (d.getHours() % 12) + mi / 60;
const handSpec = [[Math.PI / 2 - h * Math.PI / 6, 0.5, 0.45], [Math.PI / 2 - mi * Math.PI / 30, 0.75, 0.4], [Math.PI / 2 - s * Math.PI / 30, 0.8, 0.15]];
const total = handSpec.reduce((a, [, , w]) => a + w, 0);
for (const [a, len, w] of handSpec) { const n = Math.floor(hands * w / total); const side = 0.012 * R;
for (let i = 0; i < n; i++) { const u = i / n, off = ((i % 5) - 2) / 2 * side; put(u * len * R * Math.cos(a) - off * Math.sin(a), u * len * R * Math.sin(a) + off * Math.cos(a)); } }
while (j < m) put(R * Math.cos(j), R * Math.sin(j));
return t;
}
cmds.clock = async function(){
if (!W()) return log('the wafer is not ready');
await W().scope(null); const m = W().state().scopeN; const d = new Date();
await W().blend(clockTargets(m, d)); hud('clock'); scopeName = 'clock';
log(`clock: ${d.toTimeString().slice(0, 8)} drawn with ${m.toLocaleString('en-GB')} lines; the hands are a pure function of the time; redrawn every 10 s`);
say(`<b>A clock</b>\nThe time on this computer at ${d.toTimeString().slice(0, 8)}, drawn with the same dots as the networks. It shows that every drawing here is worked out at the moment you ask for it. A demonstration, not a measurement of anything.`);
if (clockTimer) clearInterval(clockTimer);
clockTimer = setInterval(async () => { if (scopeName !== 'clock') { clearInterval(clockTimer); clockTimer = null; return; } await W().blend(clockTargets(W().state().scopeN, new Date())); }, 10000);
log('draw clock: drawn'); return { drawn: m };
};
cmds.time = cmds.clock;Wafer Development Environment — Proof S0004 Style Sheet
A style sheet in the testcode folder of GlobalGrid2050. Served with the page at https://globalgrid2050.com/testcode/wafer-development-environment/202609192215-proof-s0004/.
renderglobalgrid2050 / testcode/wafer-development-environment/202609192215-proof-s0004/style.css · lines 1–129 of 129 · version 2026-09-19 22:15 · Entry point
- What it does
- 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.
- Downstream impact
- Used directly by 1 file: Wafer Development Environment — Proof S0004 Page (globalgrid2050, https://globalgrid2050.com/testcode/wafer-development-environment/202609192215-proof-s0004/). Reached from 114 other entry points, including GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html); GlobalGrid2050 Homepage Before Four Nests (globalgrid2050, https://globalgrid2050.com/homepage-before-four-nests-20260925.html); GlobalGrid2050 — Compute Page (globalgrid2050, https://globalgrid2050.com/compute/). It is itself an entry point, published at https://globalgrid2050.com/testcode/wafer-development-environment/202609192215-proof-s0004/.
- What it achieves
- Designed at 430 px first; the desktop is the same layout with more room.
- Why it matters
- Loaded by the Proof S0004 page at https://globalgrid2050.com/testcode/wafer-development-environment/202609192215-proof-s0004/.
- Application
- globalgrid2050 · testcode/wafer-development-environment/202609192215-proof-s0004 · style sheet
- Uses
- none found
- Used by
- loaded by Wafer Development Environment — Proof S0004 Page (stylesheet)
- 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/wafer-development-environment/202609192215-proof-s0004/style.css:1-129 · blob a7566ff999b52c79f32a0bf59d1b8a57cda466ec · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: experimental · users: none · canonical: production_core
/* The Line Wafer. Designed at 430 px first; the desktop is the same layout with
more room. One canvas, three chrome strips, nothing that scrolls the page. */
:root{
--ink:#d8dee9; --dim:#8b93a7; --ground:#0b0d12; --edge:#1b2030;
--lit:#ffd54a; --beam:#5ec8f2;
--top:env(safe-area-inset-top,0px); --bot:env(safe-area-inset-bottom,0px);
/* The bottom of the screen, from the floor up: the command bar (--cmd, zero when the page has
no bar), the footer above it (--footh), and a gap. Everything else that is fixed to the
bottom starts at --stack, so nothing is ever drawn on the line that says what this is not. */
--cmd:0px; --footh:34px; --stack:calc(var(--cmd) + var(--footh) + 8px);
/* and the status line above that, so the one sentence the page says about what it is doing is
never underneath the examples box either. Zero when there is nothing to say. */
--statush:0px; --above:calc(var(--stack) + var(--statush) + 8px);
/* And the top of the screen, from the ceiling down: the wordmark and count strip (--barh), then
the menu, whose bottom edge is --toph. Everything that used to be placed at a guessed 44px now
starts below the thing above it. The flight controls' own height (--beamh) is measured for the
same reason: the examples box used to be drawn straight on top of them. */
--barh:44px; --toph:52px; --beamh:44px;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
margin:0; background:var(--ground); color:var(--ink);
font:13px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
overflow:hidden; overscroll-behavior:none; -webkit-text-size-adjust:100%;
}
#stage{position:fixed; inset:0; width:100%; height:100%; display:block; touch-action:none}
#bar{
position:fixed; left:0; right:0; top:0; z-index:2;
display:flex; gap:.75rem; align-items:baseline; flex-wrap:wrap;
padding:calc(var(--top) + .5rem) .75rem .5rem;
background:linear-gradient(#0b0d12ee,#0b0d1200); pointer-events:none;
}
#wordmark{letter-spacing:.14em; font-size:11px}
.dim{color:var(--dim)}
#beam{
position:fixed; z-index:3; left:.5rem; right:.5rem;
bottom:calc(var(--bot) + var(--above));
display:flex; gap:.4rem;
}
#beam input{
flex:1 1 0; min-width:0; padding:.6rem .55rem;
background:#11151f; color:var(--ink); border:1px solid var(--edge); border-radius:6px;
font:inherit; font-size:16px; /* 16px stops iOS zooming the page on focus */
}
#beam input:focus{outline:none; border-color:var(--beam)}
#beam button{
flex:0 0 auto; padding:.6rem .9rem; border-radius:6px; cursor:pointer;
background:#11151f; color:var(--beam); border:1px solid var(--beam);
font:inherit; font-size:13px; letter-spacing:.1em;
}
#beam button:active{background:#16202c}
#panel{
position:fixed; z-index:4; left:.5rem; right:.5rem;
bottom:calc(var(--bot) + 6.6rem);
max-height:52vh; overflow:auto; -webkit-overflow-scrolling:touch;
background:#0e121bf2; border:1px solid var(--edge); border-radius:8px;
padding:.75rem .8rem 1rem;
}
#panel[hidden]{display:none!important}
#close{
position:absolute; top:.35rem; right:.4rem; width:2rem; height:2rem;
background:none; border:0; color:var(--dim); font:inherit; font-size:15px; cursor:pointer;
}
#panel h2{margin:0 .5rem .5rem 0; font-size:15px; font-weight:600; letter-spacing:.02em}
#panel h2 .n{color:var(--lit)}
#panel dl{display:grid; grid-template-columns:auto 1fr; gap:.15rem .6rem; margin:.5rem 0}
#panel dt{color:var(--dim)}
#panel dd{margin:0; overflow-wrap:anywhere}
#panel p{margin:.5rem 0 0}
#panel ul{margin:.35rem 0 0; padding-left:1.1rem}
#panel li{margin:.15rem 0}
.fam{color:var(--beam)}
.refuse{color:var(--lit)}
/* THE BOTTOM OF THE SCREEN IS A STACK, NOT A PILE. The command bar is also fixed to the bottom of
the screen, and it is drawn later and higher, so a footer at bottom:0 is a footer nobody can read:
the line that says what this page is not was underneath it in all twelve views at both widths.
--cmd is the height of the command bar, published by the bar itself; when there is no bar it is
zero and this footer sits where it always did. */
#foot{
position:fixed; z-index:2; left:0; right:0; bottom:var(--cmd,0px);
display:flex; gap:.15rem; flex-direction:column;
padding:.35rem .75rem calc(var(--bot) + .35rem);
background:#0b0d12f2; pointer-events:none;
font-size:10.5px;
}
#hint{text-align:left}
#foot a{color:var(--beam); pointer-events:auto; text-decoration:underline}
@media (min-width:760px){
#beam{left:auto; right:1rem; width:26rem; bottom:calc(var(--bot) + var(--above))}
#foot{flex-direction:row; gap:.6rem; justify-content:space-between}
#hint{text-align:right}
#panel{left:1rem; right:auto; width:26rem; bottom:calc(var(--bot) + 2.5rem); max-height:66vh}
#foot{font-size:11px}
}
/* ── reading the code ───────────────────────────────────────────────────── */
/* ── reading the code ─────────────────────────────────────────────────────
The line and the block are the only places in this page where the estate's
own text appears. Everything else is drawn from numbers; this is fetched,
one row at a time, and it is set apart so you can always tell which is
which. */
.code{margin:.4rem 0 .6rem;padding:.45rem .55rem;background:#0b0e15;border:1px solid #1b2030;border-left:2px solid #5ec8f2;
border-radius:4px;font:12px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:#cfe3f2;
white-space:pre-wrap;overflow-wrap:anywhere;max-height:14rem;overflow:auto}
.code.loading{color:#8b93a7;border-left-color:#1b2030;font-style:italic}
.code.refuse{color:#f2b05e;border-left-color:#f2b05e;white-space:normal;font-style:normal}
.code[data-empty="1"]::after{content:"an empty line";color:#5b6377;font-style:italic}
.famopen{display:block;width:100%;text-align:left;background:none;border:0;padding:.2rem 0;color:inherit;font:inherit;cursor:pointer}
.famopen:hover .fam{text-decoration:underline}
.famopen.open .fam::before{content:"▾ "}
.famopen:not(.open) .fam::before{content:"▸ "}
.famblock{margin:.3rem 0 .6rem}
.famhead{font-size:11px;letter-spacing:.04em;color:#e7ebf3;margin:.2rem 0}
ol.block{list-style:none;margin:.2rem 0;padding:0;border:1px solid #1b2030;border-radius:4px;overflow:hidden}
ol.block li+li{border-top:1px solid #141925}
.blockline{display:flex;gap:.5rem;width:100%;text-align:left;background:#0b0e15;border:0;padding:.22rem .45rem;
color:#cfe3f2;font:12px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;cursor:pointer}
.blockline:hover{background:#121826}
.blockline .n{flex:0 0 4.5rem;color:#5b6377;text-align:right;user-select:none}
.blockline code{white-space:pre-wrap;overflow-wrap:anywhere}
#storeline{font-size:10.5px;margin:.5rem 0 0}