GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Kuiper, cosmos and drawing engines / globalgrid2050 / testcode/wafer-development-environment/202609192138-proof-k0022

Wafer Development Environment — Proof K0022 Page

A web page in the testcode folder of GlobalGrid2050 that draws link contract and cables, and uses data from the GridAtlas repository. Published at https://globalgrid2050.com/testcode/wafer-development-environment/202609192138-proof-k0022/.

700 lines of HTML from globalgrid2050, in 1 file. Topic: Kuiper, cosmos and drawing engines. Section 1486 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. Wafer Development Environment — Proof K0022 Page render · globalgrid2050 / testcode/wafer-development-environment/202609192138-proof-k0022/index.html lines 570–1269

Wafer Development Environment — Proof K0022 Page

A web page in the testcode folder of GlobalGrid2050 that draws link contract and cables, and uses data from the GridAtlas repository. Published at https://globalgrid2050.com/testcode/wafer-development-environment/202609192138-proof-k0022/.

renderglobalgrid2050 / testcode/wafer-development-environment/202609192138-proof-k0022/index.html · lines 570–1269 of 1559 · version 2026-09-19 21:38 (continued from section 1485) · Entry point · pattern appFor (shared by 9 files)

What it does
It draws link contract and cables. Defines 76 functions or classes, including buildLink, complaints, parseLink, fmt, day. 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. Domain terms in the code: cables.
Inputs & outputs
In: data source: gridatlas data; JSON file link-contract.json; form fields (user input). Out: web page; WebGL/WebGPU drawing.
Downstream impact
Used directly by 5 files: GlobalGrid2050 Homepage Before Four Nests (globalgrid2050, https://globalgrid2050.com/homepage-before-four-nests-20260925.html); Homepage Versions — Before Refresh Page (globalgrid2050, https://globalgrid2050.com/homepage_versions/20260922-before-refresh/); Homepage V123 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v123.html); Homepage V124 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v124.html); and 1 more. Reached from 83 other entry points, including GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html); Homepage V037 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v037.html); Homepage V038 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v038.html). It is itself an entry point, published at https://globalgrid2050.com/testcode/wafer-development-environment/202609192138-proof-k0022/.
What it achieves
It builds link (`buildLink`), parses link (`parseLink`) and sets tag (`setTag`). Its `lightTime` function gives commit period summary or null from year, optional month and optional day (VEDIC: period). It reads `cosmos/link-contract.json`. It responds to error, webglcontextlost and resize events.
Why it matters
Loaded by the GlobalGrid2050 Homepage Before Four Nests page at https://globalgrid2050.com/homepage-before-four-nests-20260925.html and 4 other pages.
Application
globalgrid2050 · testcode/wafer-development-environment/202609192138-proof-k0022 · page
VEDIC
PERIOD (GG2050-VEDIC-000042): Kuiper / Code navigation · Computer science / Interactive visualisation. year, month_optional, day_optional, ordered_commits → commit_period_summary_or_null
Uses
GridAtlas — Atlas Page (estate URL)
Used by
linked from GlobalGrid2050 Homepage Before Four Nests (link), linked from Homepage Versions — Before Refresh Page (link), linked from Homepage V123 (link), linked from Homepage V124 (link), linked from Homepage V125 (link)
Produces
buildLink, complaints, parseLink, fmt, day, words, prog, U, tsv, appFor, narrow, resize
Defines here
edge, toWorld, cardFor, esc, gh, ghLink, el, drow, linkTo, sheet, setTag, revealCode, closeCard, codeWindow, lh, padTop, place, show, put, goKey, arriveAt, showNew, stepAnim, finishSelftest, loadTracked, raiseFlags, lightPath, pathSelftest, inWindow, on
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/202609192138-proof-k0022/index.html:570-1269 · blob 184f9c1af1d4ec1cc50471eb855b02f38e4c2d27 · GitHub at these lines
State
achieves: code · context: readme_derived · stage: output · effects: dom, network · domain stage: experimental · users: none · canonical: production_core
  let ms = 0;
  if (points) { const t0 = performance.now(); gl.useProgram(PK);
    gl.uniform1f(U(PK,'u_zoom'), zoom); gl.uniform2f(U(PK,'u_center'), cx, cy); gl.uniform2f(U(PK,'u_res'), W, H);
    for (const [s0, s1, rp, ci] of segs) { gl.uniform1f(U(PK,'u_hot'), (newFrom >= 0 && ci >= newFrom) ? 2 : ((rp === litRepo || (litCi && ci >= litCi[0] && ci < litCi[1])) ? 1 : 0));
      for (let off = s0; off < s1; off += 4000000) {                       // bounded calls; the driver watchdog is real
        gl.uniform1ui(U(PK,'u_k0lo'), (off % 4294967296) >>> 0); gl.uniform1f(U(PK,'u_R0'), Math.sqrt(off));
        gl.drawArrays(gl.POINTS, 0, Math.min(4000000, s1 - off)); } }
    gl.finish(); ms = performance.now() - t0; }

  const L = [], D = [];
  D.push(points ? 'RESOLVED · every issued key whose radius is in the field, drawn at its own place'
                : 'UNRESOLVED · up to ' + words(1/(Math.PI*zoom*zoom)) + ' keys to a pixel · each pixel’s issued count is computed from the law, not drawn');
  if (points) D.push(fmt(total) + ' issued keys from ' + fmt(segs.length) + ' commits passed to the GPU in ' + ms.toFixed(0) + ' ms');
  D.push('the whole · ' + fmt(N) + ' issued + ' + fmt(SPACE - N) + ' silent = ' + fmt(SPACE) + ' addresses');
  if (litRepo >= 0) { const rt = linesByRunningTotals(litRepo), rr = repos[litRepo];
    // the number on screen is the one the shading is made of, not the one the belt declared; if
    // they differ the HUD says so rather than picking the prettier of the two
    // WHAT IS HIGHLIGHTED, IN WORDS A READER CAME WITH. Whether two running totals agree is how
    // this page knows it is not lying, which matters, and belongs where the rest of the working
    // is: behind d. What stays on the face is the disagreement itself, if there ever is one,
    // because a reader must never be shown a number the page has reason to doubt.
    L.push('HIGHLIGHTED · ' + rr.name + ' · ' + fmt(rr.commits) + ' pieces of work · '
           + day(rr.t0) + ' to ' + day(rr.t1));
    D.push('running totals ' + (rt === rr.lines ? 'agree with the belt' : 'DISAGREE with the belt'));
    if (rt !== rr.lines) L.push('THIS COUNT IS IN DOUBT · two measurements of it disagree, so it is not shown');
    const wpx = widestRunPx(litRepo, zoom);
    // Said exactly, because 269 pixels of a repository whose widest run is a tenth of a pixel are
    // lit: the runs are so close together that pixel centres keep landing inside them. The claim
    // is about the run, not about the light.
    if (wpx < 1) L.push('TOO SMALL TO SEE AT THIS ZOOM · what is lit is only where this work happens to fall · zoom in to see it whole'); }
  D.push(zoom >= 1 ? 'zoom ' + zoom.toFixed(1) + ' px per key spacing' : 'zoom 1 px = ' + words(1/zoom) + ' units');
  hud.textContent = (detail ? L.concat(D) : L).join('\n');
  // A PANEL DRAWN FOR WORDS THAT ARE NOT THERE. With nothing highlighted the readout is empty, and
  // an empty bordered box sat in the corner at 1366 looking like something that had failed to load.
  hud.style.display = hud.textContent.trim() ? '' : 'none';
  o2.clearRect(0,0,ov.width,ov.height);
  { const x0 = (0 - cx)*zoom + ov.width/2, y0 = ov.height/2 + cy*zoom, M = ['JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC'];
    const a = new Date(commits[0].unix*1000), b = new Date(commits[commits.length-1].unix*1000); let lastPx = -99;
    o2.font = '10px ui-monospace,Consolas,monospace'; o2.lineWidth = 1;
    for (let y = a.getUTCFullYear(), m = a.getUTCMonth() + 1; y < b.getUTCFullYear() || (y === b.getUTCFullYear() && m <= b.getUTCMonth()); m++) {
      if (m > 11) { m = 0; y++; }
      const t = Date.UTC(y, m, 1)/1000, i = Math.min(commits.length-1, findBy('unix', t - 1) + 1), rp = Math.sqrt(commits[i].k0)*zoom;
      if (rp - lastPx < 26 || rp > 6000) continue; lastPx = rp;
      o2.strokeStyle = 'rgba(46,230,230,.30)'; o2.beginPath(); o2.arc(x0, y0, rp, 0, 6.2832); o2.stroke();
      o2.fillStyle = 'rgba(46,230,230,.85)'; o2.fillText(M[m] + ' ' + String(y).slice(2), x0 + rp*0.5 + 4, y0 - rp*0.866 - 3); } }
  if (target && target.boundary && zoom >= POINTS_FROM) {
    // at this zoom the boundary circle is straight across the screen: perpendicular to the radius
    const x = (target.x - cx)*zoom + ov.width/2, y = ov.height/2 - (target.y - cy)*zoom, rr = Math.hypot(target.x, target.y) || 1;
    const tx = -target.y/rr, ty = target.x/rr, Lp = Math.hypot(ov.width, ov.height);
    o2.strokeStyle = 'rgba(255,199,107,.95)'; o2.lineWidth = 2; o2.setLineDash([10,6]); o2.beginPath();
    o2.moveTo(x - tx*Lp, y + ty*Lp); o2.lineTo(x + tx*Lp, y - ty*Lp); o2.stroke(); o2.setLineDash([]);
    o2.font = '12px ui-monospace,Consolas,monospace'; o2.fillStyle = 'rgba(255,199,107,1)';
    // outward is newer, and which way outward points on screen depends on where this key sits, so
    // the words are placed along the real radius rather than assumed to read left to right
    const ox = target.x/rr, oy = -target.y/rr;
    o2.textAlign = 'center';
    o2.fillText('NEW CODE', x + ox*110, y + oy*110); o2.fillStyle = 'rgba(213,220,234,.85)';
    o2.fillText('older', x - ox*110, y - oy*110); o2.fillStyle = 'rgba(255,199,107,1)';
    o2.fillText('the boundary', x + tx*150, y - ty*150 - 8); o2.textAlign = 'start'; }
  if (arrow) {
    const p = keyPlace(arrow.k);
    const fx = (0 - cx)*zoom + ov.width/2, fy = ov.height/2 + cy*zoom;          // the middle: where the record begins
    const bx = (p[0] - cx)*zoom + ov.width/2, by = ov.height/2 - (p[1] - cy)*zoom;
    // WHEN THE BEGINNING IS OFF THE SCREEN, AND AFTER THE CAMERA FLIES IT ALWAYS IS, the arrow keeps
    // the true line and starts where that line crosses the edge of the window. Direction is the whole
    // of what it says; a stub of a line thousands of screen widths long says nothing at all.
    let ax = fx, ay = fy;
    { const W = ov.width, H = ov.height, dx = fx - bx, dy = fy - by;
      const far = fx < 0 || fy < 0 || fx > W || fy > H;
      if (far && (dx || dy)) {
        let t = Infinity;
        const edge = (num, den) => { if (den === 0) return; const u = num / den;
          if (u > 0 && u < t) { const x = bx + dx*u, y = by + dy*u;
            if (x >= -1 && x <= W + 1 && y >= -1 && y <= H + 1) t = u; } };
        edge(-bx, dx); edge(W - bx, dx); edge(-by, dy); edge(H - by, dy);
        if (t !== Infinity) { ax = bx + dx*t*0.98; ay = by + dy*t*0.98; }
      } }
    const u = Math.min(1, (performance.now() - arrow.t0) / ARROW_MS), e = 1 - Math.pow(1 - u, 3);
    const tx = ax + (bx - ax)*e, ty = ay + (by - ay)*e, th = Math.atan2(by - ay, bx - ax);
    o2.strokeStyle = 'rgba(255,43,214,.95)'; o2.lineWidth = 2; o2.beginPath();
    o2.moveTo(ax, ay); o2.lineTo(tx, ty);
    for (const d of [-0.36, 0.36]) { o2.moveTo(tx, ty); o2.lineTo(tx - 13*Math.cos(th + d), ty - 13*Math.sin(th + d)); }
    o2.stroke();
    // WHERE THE POINT REALLY IS, not where it was aimed. The page can be asked afterwards, and an
    // arrow that lands NEAR the answer is worse than no arrow at all, because it is believed.
    arrowTip = { x:tx, y:ty, x0:ax, y0:ay, fromX:fx, fromY:fy, done:u >= 1 };
    if (u >= 1 && !arrow.held) arrow.held = performance.now();
    if (arrow.held && performance.now() - arrow.held > ARROW_HOLD) arrow = null;     // it has said its piece
    dirty = true;
  }
  if (target) { const x = (target.x - cx)*zoom + ov.width/2, y = ov.height/2 - (target.y - cy)*zoom;
    o2.strokeStyle = 'rgba(255,43,214,.98)'; o2.lineWidth = 1.5; o2.beginPath();
    for (const [a,b,c,d] of [[-16,0,-6,0],[6,0,16,0],[0,-16,0,-6],[0,6,0,16]]) { o2.moveTo(x+a,y+b); o2.lineTo(x+c,y+d); } o2.stroke(); }
}

// ------------------------------------------------------------------------------ the controls
function toWorld(px, py){ return [cx + (px - innerWidth/2)/zoom, cy - (py - innerHeight/2)/zoom]; }
// A KEY THAT LANDS IN A CARRIED FILE SHOWS THE CODE. Until every commit's file list is published a
// browser cannot work out which file a key belongs to, so the answer is worked out beforehand, one
// public file at a time, and the page simply looks it up. Where there is no card the page says what
// it knows and does not pretend otherwise.
function cardFor(k){ return cards.find(c => k >= c.k0 && k < c.k0 + c.lines) || null; }
function esc(t){ return String(t).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;'); }
const CONTEXT = 10;
// THE ONE RULE THAT MAKES THE ADDRESS OF A LINE ON GITHUB, the same rule tools/cards.py writes
// down, so a change of commit ids can be answered by making every link again from the fields.
// The owner used to be written in here by hand: correct by luck, and wrong the first time a
// carried file came from anywhere else.
// ONE RULE, TWO SHAPES. A whole piece of work is a commit; a line is a path inside it. Nothing in
// this page types a GitHub address: every one of them comes out of here, from data, so when the
// commit ids change they can all be made again by rebuilding the data.
function gh(o){
  if (!o || !o.owner || !o.repo || !o.commit) return null;
  const base = 'https://github.com/' + o.owner + '/' + o.repo;
  if (!o.path) return base + '/commit/' + o.commit;
  return base + '/blob/' + o.commit + '/' + o.path + (o.line ? '#L' + o.line : '');
}
function ghLink(c, line){
  return gh({ owner:c.owner, repo:c.repo, commit:c.commit, path:c.path, line:line });
}
// ===== THE POP CARD =========================================================================
// The card this estate refined over many iterations, brought over rather than approximated again.
// Grid Atlas's popup look, a state chip with ONE writer, and a code window that is one <pre> with
// one text node: the numbers are part of the text, so copying the code copies what is on the
// screen, and the tapped line is marked by a bar placed from the line height.
function el(tag, cls, text){ const e = document.createElement(tag); if (cls) e.className = cls;
  if (text != null) e.textContent = text; return e; }
function drow(dl, k, v){ dl.append(el('dt', null, k)); const d = el('dd', null, v); dl.append(d); return d; }
function linkTo(href, text){ const a = el('a', 'cc-link', text); a.href = href; a.target = '_blank'; a.rel = 'noopener'; return a; }
let cardToken = 0;
function sheet(title, sub){
  const mine = ++cardToken;
  card.replaceChildren();
  card.style.display = 'block';
  card.scrollTop = 0;
  const x = el('button', 'cc-x', '\u00d7'); x.type = 'button'; x.setAttribute('aria-label', 'close');
  x.addEventListener('click', closeCard);
  card.append(x, el('span', 'cc-title', title));
  if (sub) card.append(el('span', 'cc-grey', sub));
  const tagLine = el('div', 'cc-tagline'), tag = el('span', 'cc-tag'), msg = el('span', 'cc-grey');
  tagLine.append(tag, msg); card.append(tagLine);
  const body = el('div', 'cc-body'); card.append(body);
  // THE SINGLE WRITER OF THE STATE. Nothing else touches the chip, and a writer for a card that has
  // been replaced does nothing at all.
  const setTag = (st, text) => { if (mine !== cardToken) return false;
    tag.dataset.s = st; tag.textContent = st; if (text != null) msg.textContent = text; return true; };
  dirty = true;
  return { mine, body, setTag, live: () => mine === cardToken };
}
function revealCode(){
  const w = cardShown && cardShown.window; if (!w) return;
  const cr = card.getBoundingClientRect(), pr = w.node.getBoundingClientRect();
  if (pr.bottom > cr.bottom - 4) card.scrollTop += pr.bottom - cr.bottom + 8;
  else if (pr.top < cr.top) card.scrollTop -= cr.top - pr.top + 8;
  w.scrollToTarget();
}
function closeCard(){ cardToken++; card.style.display = 'none'; card.replaceChildren();
  target = null; cardShown = null; dirty = true; }
addEventListener('keydown', e => {
  if (e.key === 'Escape' && card.style.display !== 'none') { e.preventDefault(); closeCard(); } });

function codeWindow(lines, a, b, at){
  const pre = el('pre', 'cc-code');
  pre.setAttribute('aria-label', 'the code around this line');
  const bar = el('div', 'cc-hi cc-hi-target');
  const out = [];
  for (let i = a; i <= b; i++) out.push(String(i).padStart(6) + '  ' + lines[i - 1]);
  pre.append(bar, document.createTextNode(out.join('\n')));
  const lh = () => parseFloat(getComputedStyle(pre).lineHeight) || 16;
  const padTop = () => parseFloat(getComputedStyle(pre).paddingTop) || 0;
  const place = () => { bar.style.top = (padTop() + (at - a) * lh()) + 'px'; bar.style.height = lh() + 'px'; };
  return { node:pre, bar, place, first:a, last:b, at,
    scrollToTarget(){ place(); pre.scrollTop = Math.max(0, (at - a) * lh() - pre.clientHeight/2 + lh()/2); } };
}

// WHAT A TAP OPENS. One way in for every kind of answer: the work and the day it was done, a state
// chip saying how much of it is proved, and, where the code for that line is carried on this site,
// the code itself with the tapped line marked. Nothing here sends a reader to GitHub to READ code;
// the link is there for the detail and the history, which is what GitHub is good for.
function show(a){
  cardShown = null;
  if (!a) { closeCard(); return; }
  if (a.silent) {
    const x = a.next, s = sheet('Nothing was recorded here', '');
    s.setTag('EMPTY', 'This point falls between two pieces of work, so no line of code has this address.');
    if (x) { const p = el('div', 'cc-row');
      const go = el('a', 'cc-link', 'Go to the next work: ' + repos[x.repo].name + ', ' + day(x.unix));
      go.href = buildLink({ key:x.k0 }); go.setAttribute('data-key', x.k0);
      p.append(go); s.body.append(p); }
    return;
  }
  const r = repos[a.c.repo], c = cardFor(a.k);
  litRepo = a.c.repo;
  const s = sheet('Line ' + fmt(a.k), c ? ' \u00b7 ' + c.path.split('/').pop() : ' \u00b7 ' + r.name);
  // THE ORDER OF THE CARD IS THE ORDER OF THE QUESTIONS A PERSON WHO SIGNS ASKS. What is this for,
  // and where do I open it; whose is it; what was done and when. How it is made comes last and
  // closed, one tap further in, for the engineer who is in the room but does not sign.
  { const found = r.pub ? appFor(r.owner, r.name, c ? c.path : null) : null;
    const det = el('details', 'cc-q'); det.append(el('summary', null, 'See the code behind this'));
    for (const kid of Array.from(card.children)) if (!kid.classList.contains('cc-x')) det.append(kid);
    let top;
    if (found && found.app) {
      top = el('a', 'cc-tile cc-app'); top.href = found.app.live; top.target = '_blank'; top.rel = 'noopener';
      top.setAttribute('data-app', found.app.app);
      top.append(el('div', 'cc-tile-name', found.app.button));
      if (whatItDoes[found.app.live]) top.append(el('div', 'cc-tile-what', whatItDoes[found.app.live] + '.'));
      top.append(el('span', 'cc-tile-open', 'OPEN ' + found.app.button));
    } else {
      top = el('div', 'cc-notile cc-app');
      top.setAttribute('data-app', found && found.unproved ? '?' : '');
      top.append(el('div', null, found && found.unproved
        ? 'Which app this work is part of is not proved here yet.' : 'Not part of an app yet.'));
    }
    // THE LINKS A CARD CARRIES, IN THE OPEN AND IN AS FEW WORDS AS THEY NEED: the application (above),
    // GitHub as one quiet word for those who know what it is, and the site itself whenever there is
    // nothing else to offer, so that no card is ever a dead end.
    const links = el('div', 'cc-row cc-links');
    { const gu = r.pub ? gh({ owner:r.owner, repo:r.name, commit:a.c.sha }) : null;
      if (!(found && found.app)) { const hl = linkTo('https://www.globalgrid2050.com/', 'www.globalgrid2050.com');
        hl.classList.add('cc-home'); links.append(hl); }
      if (gu) { if (links.childNodes.length) links.append(el('span', 'cc-grey', ' \u00b7 '));
        const gl = linkTo(gu, 'GitHub'); gl.classList.add('cc-gh'); links.append(gl); } }
    const brand = el('div', 'scada-brand'), inner = el('div');
    inner.append(el('div', 'scada-brand-main', 'Ventus'), el('div', 'scada-brand-sub', 'Cables & Connectivity\u00ae'));
    brand.append(inner);
    const plain = el('div', 'cc-plain', 'Engineering work in ' + r.name + ', done on ' + day(a.c.unix) + '.');
    card.append(top, links, brand, plain, det);
    det.open = codeOpen;
    // ASKED FOR MUST MEAN SEEN. With the tile, the brand and the plain line above it, the code opened
    // below the fold of the card on a phone. Opening it brings the window into view, then the line.
    det.addEventListener('toggle', () => { if (det.open && cardShown && cardShown.window) revealCode(); dirty = true; }); }
  const meta = el('dl', 'cc-dl');
  drow(meta, 'work', r.name + ' \u00b7 ' + day(a.c.unix));
  const u = r.pub ? gh({ owner:r.owner, repo:r.name, commit:a.c.sha }) : null;
  const d = drow(meta, 'history', '');
  if (u) { d.append(linkTo(u, 'GitHub')); d.append(' \u00b7 commit ' + a.c.sha.slice(0, 7)); }
  else d.textContent = 'not public, so there is no link';
  s.body.append(meta);
  if (!c) {
    s.setTag('EMPTY', 'The code for this line is not carried on this site yet, so nothing around it can be shown.');
    return;
  }
  const j = a.k - c.k0;
  s.setTag('LOAD', 'reading the lines around it from this site\u2026');
  const put = data => {
    if (!s.live()) return;
    cardShown = { card:c, line:j, data, sheet:s };
    const short = c.commit.slice(0, 7), fileName = c.path.split('/').pop();
    // THE ARITHMETIC THIS CARD IS ABOUT TO RELY ON, CHECKED BEFORE IT IS RELIED ON. The pack was
    // built from git and every line proved against it when it was built; what can still go wrong
    // here is the pack and the list disagreeing about the length of the file, and then every number
    // below would be a guess.
    if (!c.here || data.lines !== c.lines || data.text.length !== c.lines || !(j >= 0 && j < c.lines)) {
      s.setTag('FAIL', !c.here
        ? 'This file is no longer in the repository, so its neighbours today would not be this line\u2019s neighbours. Nothing around it is shown.'
        : 'The record says this file has ' + fmt(c.lines) + ' lines and the text carried for it has '
          + fmt(data.text.length) + ', so the numbering cannot be trusted. Nothing around it is shown.');
      const h = el('div', 'cc-codehead');
      h.append(c.path + ' \u00b7 ' + c.repo + ' @ ' + short + ' \u00b7 line ' + fmt(j + 1) + ' \u00b7 ');
      h.append(linkTo(ghLink(c, j + 1), 'GitHub'));
      s.body.append(h);
      dirty = true; return;
    }
    const from = Math.max(1, j + 1 - CONTEXT), to = Math.min(data.text.length, j + 1 + CONTEXT);
    const head = el('div', 'cc-codehead');
    head.append(c.path + ' \u00b7 ' + c.repo + ' @ ' + short + ' \u00b7 line ' + fmt(j + 1)
              + ' \u00b7 showing ' + fmt(from) + '\u2013' + fmt(to) + ' of ' + fmt(data.text.length) + ' \u00b7 ');
    head.append(linkTo(ghLink(c, j + 1), 'GitHub'));
    s.body.append(head);
    s.body.append(el('div', 'cc-check',
      'These lines are carried on this site, read from ' + c.repo + ' at commit ' + short
      + ' when this page was built and checked line for line against it then \u00b7 '
      + fmt(j + 1 - from) + ' above, ' + fmt(to - j - 1) + ' below. Scroll inside the window to see them all;'
      + ' a long line scrolls sideways.'));
    const w = codeWindow(data.text, from, to, j + 1);
    s.body.append(w.node);
    cardShown.window = w;
    s.setTag('OK', 'the line and the lines around it, as the file stood that day');
    s.body.append(el('div', 'cc-disclaimer',
      'Provided as is, without warranty of any kind; a chart, not a design.'));
    requestAnimationFrame(() => { if (s.live()) revealCode(); });
    revealCode();
    dirty = true;
  };
  if (cardCache[c.file]) { put(cardCache[c.file]); return; }
  fetch('cosmos/cards/' + c.file).then(x => x.json()).then(dd => { cardCache[c.file] = dd; put(dd); })
    .catch(e => s.setTag('FAIL', 'the lines around this one could not be read from this site: ' + (e && e.message || e)));
}
function goKey(k){ const p = keyPlace(k); target = { x:p[0], y:p[1] }; show(address(k)); flyTo(p[0], p[1], 14); }
// ARRIVING BY SOMEBODY ELSE'S LINK. The view flies, the arrow is shot, the card opens: three things
// in that order, because a card that appears over a picture of nine thousand pieces of work asks to
// be taken on trust, and an arrow from the middle of the record to one dot does not.
function arriveAt(k){
  const a = address(k);
  if (!a) return;
  const p = keyPlace(k);
  target = null; arrow = null; arrowTip = null; card.style.display = 'none';
  flyTo(p[0], p[1], Math.max(14, zoom));
  setTimeout(() => { arrow = { k, t0:performance.now() }; dirty = true; }, 920);
  setTimeout(() => { target = { x:p[0], y:p[1] }; show(a); dirty = true; }, 920 + ARROW_MS);
}
// SHOW NEW CODE. "New" is measured from the newest commit, not from the wall clock, so the same
// page gives the same answer tomorrow. Keys run in time order, so what is new is always one
// contiguous band at the rim: the boundary is a single circle, and that circle is drawn.
function showNew(hours){
  const last = commits[commits.length-1].unix, cut = last - hours*3600;
  newFrom = findBy('unix', cut - 1) + (commits[0].unix >= cut ? 0 : 1); if (newFrom >= commits.length) newFrom = commits.length - 1;
  litRepo = -1; target = null; card.style.display = 'none'; tween = null;
  const R = Math.sqrt(SPACE); cx = 0; cy = 0; zoom = (Math.min(cv.width, cv.height)/2) * 0.80 / R;
  anim_hours = hours; anim = { t0:performance.now(), hours, R }; dirty = true;
}
function stepAnim(){
  const t = (performance.now() - anim.t0) / 1000; dirty = true;
  if (t < 1.6) { const u = t/1.6; pulse = anim.R * (u*u*(3-2*u)); flash = 0; }
  else if (t < 2.5) { pulse = -1; flash = 1 - 0.45*((t-1.6)/0.9); if (selftest && selftest.wantPixels === undefined) selftest.wantPixels = true; }
  else { const c = commits[newFrom], n = commits.length - newFrom; let lines = 0; for (let i = newFrom; i < commits.length; i++) lines += commits[i].lines;
    flash = 0.35; anim = null; const p = keyPlace(c.k0); target = { x:p[0], y:p[1], boundary:true };
    card.style.display = 'block';
    { const r0 = repos[c.repo], u0 = r0.pub ? gh({ owner:r0.owner, repo:r0.name, commit:c.sha }) : null;
      card.classList.remove('sheet');
      card.innerHTML = 'NEW CODE · the last ' + anim_hours + ' hours of work, as a band at the rim'
        + '\n<b>' + fmt(n) + '</b> pieces of work, <b>' + fmt(lines) + '</b> lines added'
        + '\nbegins with <b>' + r0.name + '</b>, ' + day(c.unix)
        + (u0 ? '\n<a href="' + u0 + '" target="_blank" rel="noopener">Open this piece of work on GitHub</a>' : ''); }
    flyTo(p[0], p[1], 14);
    if (selftest) finishSelftest(c, n, lines); }
}
let anim_hours = 24;
// THE TESTS, run by the page on itself with ?selftest=new, so the verdict is not an opinion.
function finishSelftest(c, n, lines){
  let maxOld = 0; for (let i = 0; i < newFrom; i++) maxOld = Math.max(maxOld, commits[i].k1);
  const a = address(c.k0), nb = selftest.newBandPixel || [0,0,0], pp = selftest.pupilPixel || [0,0,0];
  const T = { T1_new_is_one_band_beyond_everything_older: c.k0 >= maxOld,
              T2_boundary_key_resolves_to_a_new_commit: !!(a && !a.silent && a.i >= newFrom && a.m === 0),
              T3_flash_is_amber_on_the_new_band: nb[0] > 150 && nb[0] > nb[2] + 40,
              T3_no_flash_on_the_silent_centre: pp[0] < 40 && pp[1] < 40,
              new_commits: n, new_lines: lines, boundary_key: c.k0, newBandPixel: nb, pupilPixel: pp };
  T.PASS = T.T1_new_is_one_band_beyond_everything_older && T.T2_boundary_key_resolves_to_a_new_commit && T.T3_flash_is_amber_on_the_new_band && T.T3_no_flash_on_the_silent_centre;
  window.__selftest = T; document.title = 'selftest ' + (T.PASS ? 'PASS' : 'FAIL');
}
// ------------------------------------------------------------------ where a page is on the wafer
// A PAGE IS NOT A PLACE. tools/where.py asks git which commits touched a path and cosmos/wafer.tsv
// where each of those commits landed, and writes both files this reads. The page then does the same
// key arithmetic over its own commit table and the test is that the two agree exactly, commit by
// commit, key by key. Neither is trusted: they are made to contradict each other or agree.
async function loadTracked(){
  if (tracked) return tracked;
  const [tt, cc] = await Promise.all([tsv('cosmos/tracked.tsv'), tsv('cosmos/tracked-commits.tsv')]);
  tracked = { paths:tt.map(p => ({ repo:p[0], path:p[1], use:p[2], in_git:+p[3], on_wafer:+p[4],
                lines_in_those_commits:+p[5], k0:+p[6], k1:+p[7], first:p[8], last:p[9] })),
              commits:cc.map(p => ({ path:p[0], sha:p[1], unix:+p[2], lines:+p[3], k0:+p[4], k1:+p[5] })) };
  return tracked;
}
function raiseFlags(idx){
  pathFlags.fill(0); for (const i of idx) pathFlags[i] = 1;
  gl.activeTexture(gl.TEXTURE1); gl.bindTexture(gl.TEXTURE_2D, pathTex);
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.R32F, TW, pathRows, 0, gl.RED, gl.FLOAT, pathFlags);
  gl.activeTexture(gl.TEXTURE0);
}
async function lightPath(name, quiet){
  const T = await loadTracked();
  const row = T.paths.find(p => p.path.toLowerCase() === String(name).toLowerCase());
  if (!row) return { error:'no tracked page of that name: run tools/where.py --five', asked_for:name };
  const want = T.commits.filter(c => c.path === row.path);
  const idx = [], missing = [], disagreed = [];
  for (const c of want) { const i = bySha.get(c.sha);
    if (i === undefined) { missing.push(c.sha); continue; }
    if (commits[i].k0 !== c.k0 || commits[i].k1 !== c.k1) disagreed.push({ sha:c.sha, page:[commits[i].k0, commits[i].k1], tool:[c.k0, c.k1] });
    idx.push(i); }
  idx.sort((a, b) => a - b);
  litRepo = -1; litK = [-1,-1]; litCi = null; newFrom = -1; flash = 0; pulse = -1; target = null;
  litPath = { row, idx }; raiseFlags(idx);
  tween = null; cx = 0; cy = 0; zoom = (Math.min(cv.width, cv.height)/2)*0.80/Math.sqrt(SPACE); draw();
  if (!quiet) { card.style.display = 'block';
    card.classList.remove('sheet'), card.innerHTML = 'PATH:' + row.path + '\n' + row.repo + '\n\n' + fmt(row.on_wafer) + ' commits touched it, of ' + fmt(row.in_git)
      + ' git knows\nfirst ' + row.first + ', last ' + row.last
      + '\n\nkeys ' + fmt(row.k0) + ' .. ' + fmt(row.k1)
      + '\n' + fmt(row.lines_in_those_commits) + ' lines in those commits, which is the commits, not the page'
      + '\n\nuse: ' + row.use; }
  return { row, idx, want:want.length, missing, disagreed };
}
// THE TEST. ?selftest=path:<name>. The count the page lit must be the count the tool counted, every
// sha the tool named must be a commit this wafer holds, and every key must match to the digit. Then
// the picture: at a zoom where one of those commits is more than a pixel wide, that pixel must
// actually carry the path's light, or the page is lighting a set it never drew.
async function pathSelftest(name){
  const r = await lightPath(name, true);
  if (r.error) { window.__selftest = { PASS:false, asked_for:name, error:r.error }; document.title = 'selftest FAIL'; return; }
  let raised = 0; for (let i = 0; i < pathFlags.length; i++) if (pathFlags[i] > 0.5) raised++;
  const T = { page:r.row.path, repository:r.row.repo, use:r.row.use,
    commits_lit_by_the_page:r.idx.length, commits_counted_by_where_py:r.row.on_wafer, commits_git_knows:r.row.in_git,
    shas_the_wafer_does_not_hold:r.missing, keys_where_tool_and_page_disagree:r.disagreed, flags_raised_in_the_texture:raised,
    first_key:r.row.k0, last_key:r.row.k1,
    T1_the_page_lit_what_where_py_counted: r.idx.length === r.row.on_wafer && r.idx.length === r.want,
    T2_every_sha_the_tool_named_is_on_this_wafer: r.missing.length === 0,
    T3_tool_and_page_give_every_commit_the_same_keys: r.disagreed.length === 0,
    T4_the_light_was_actually_raised: raised === r.idx.length && r.idx.length > 0 };
  // the picture: the widest of its commits, at a zoom that makes it three pixels of radius
  let best = -1, bestW = 0;
  for (const i of r.idx) { const w = Math.sqrt(commits[i].k1) - Math.sqrt(commits[i].k0); if (w > bestW) { bestW = w; best = i; } }
  const zWant = 3/Math.max(bestW, 1e-12), z = Math.min(zWant, POINTS_FROM*0.9), wpx = bestW*z;
  T.widest_commit_px_at_the_zoom_used = +wpx.toFixed(3);
  if (best >= 0 && wpx >= 1) {
    const mid = (Math.sqrt(commits[best].k0) + Math.sqrt(commits[best].k1))/2, p = keyPlace(mid*mid);
    tween = null; cx = p[0]; cy = p[1]; zoom = z; dirty = true; draw();
    const px = new Uint8Array(4); gl.readPixels(Math.round(cv.width/2), Math.round(cv.height/2), 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, px);
    T.pixel_at_the_middle_of_its_widest_commit = [px[0], px[1], px[2]];
    T.T5_that_pixel_carries_the_paths_light = px[0] > 120 && px[2] > 100 && px[0] > px[1] + 40 && px[2] > px[1] + 30;
  } else { T.T5_that_pixel_carries_the_paths_light = null; T.why_no_pixel_was_read = 'every commit of this page is finer than one pixel at any zoom the field is drawn at'; }
  T.PASS = T.T1_the_page_lit_what_where_py_counted && T.T2_every_sha_the_tool_named_is_on_this_wafer
        && T.T3_tool_and_page_give_every_commit_the_same_keys && T.T4_the_light_was_actually_raised
        && T.T5_that_pixel_carries_the_paths_light !== false;
  window.__selftest = T; document.title = 'selftest ' + (T.PASS ? 'PASS' : 'FAIL');
}

// THE CARD, TESTED. A key in the middle of a carried file is tapped by the page itself; the line the
// card shows must be the line that file holds at that number, the marked line must be that one and no
// other, and the panel must be on the screen. A key with no card must say so and show no code at all.
// A RECTANGLE IS NOT A SIGHTING. The link's box was inside the window and the sheet's own overflow
// was hiding it, so the check passed and the photograph showed no link. Ask what is actually at the
// point, which is the question a thumb asks.
const inWindow = r => !!r && r.width > 4 && r.height > 4 && r.top >= -0.5 && r.bottom <= innerHeight + 0.5
                && r.left >= -0.5 && r.right <= innerWidth + 0.5;
const on = el => { if (!el) return false; const r = el.getBoundingClientRect(); if (!inWindow(r)) return false;
  const hit = document.elementFromPoint(Math.round(r.left + r.width / 2), Math.round(r.top + r.height / 2));
  return !!hit && (hit === el || el.contains(hit) || hit.contains(el)); };

async function cardSelftest(){
  codeOpen = true;                       // the engineer's questions first, asked with the code opened
  const T = { cards_carried: cards.length };
  if (!cards.length) { T.PASS = false; T.error = 'no file carries its keys on this page';
    window.__selftest = T; document.title = 'selftest FAIL'; return; }
  const c = cards[0], j = Math.floor(c.lines / 2), k = c.k0 + j;
  T.file = c.path; T.line_asked_for = j + 1; T.key = k;
  show(address(k));
  for (let i = 0; i < 60 && !cardShown; i++) await new Promise(r => setTimeout(r, 100));
  const d = cardShown && cardShown.data;
  T.T1_the_card_opened_for_that_key = !!cardShown && cardShown.line === j;
  T.T2_the_line_shown_is_the_line_that_file_holds = !!d && typeof d.text[j] === 'string';
  const html = card.innerHTML;
  const want = d ? d.text[j] : null;
  const esc1 = t => String(t).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  T.T3_that_exact_text_is_on_the_screen = !!want && (want.trim() === '' || card.textContent.indexOf(want) >= 0);
  // THE MARKED ROW IS THE ONE THE KEY ASKED FOR, and the text in it is that file's line. Marking the
  // wrong row is the one failure a reader could not catch: the code would be real and the answer wrong.
  { const w = cardShown && cardShown.window, pre = w && w.node;
    const lh = pre ? parseFloat(getComputedStyle(pre).lineHeight) || 16 : 16;
    const pad = pre ? parseFloat(getComputedStyle(pre).paddingTop) || 0 : 0;
    if (w) w.place();
    T.marked_line = w ? w.at : null;
    T.T4_it_is_the_marked_line = !!w && w.at === j + 1
      && Math.abs(parseFloat(w.bar.style.top) - (pad + (w.at - w.first) * lh)) < 0.6
      && pre.textContent.split('\n')[w.at - w.first] === String(w.at).padStart(6) + '  ' + String(want); }
  const r = card.getBoundingClientRect();
  T.T5_the_card_is_on_the_screen = r.width > 40 && r.height > 20 && r.left >= -0.5 && r.right <= innerWidth + 0.5;
  // and a key that no file carries must say so, and show no code
  const far = cards.reduce((m, x) => Math.max(m, x.k0 + x.lines), 0) + 1000;
  show(address(far));
  await new Promise(r => setTimeout(r, 150));
  T.T6_a_key_with_no_card_shows_no_code = !card.querySelector('pre');
  // AND IT SAYS THE THREE THINGS A PERSON ASKED. Almost every tap a stranger makes lands here, so
  // this is the card that matters most: what the work was, the day it was done, one link to it.
  const seenText = card.textContent.replace(/\s+/g, ' ');
  T.the_plain_card = seenText.slice(0, 160);
  const lnk = card.querySelector('a[href*="github.com/"]');
  const chip = card.querySelector('.cc-tag');
  T.the_state_it_shows = chip ? chip.getAttribute('data-s') : null;
  T.T11_it_says_the_work_the_day_and_where_to_see_it =
       /(?<!\d)\d{1,2} [A-Z][a-z]{2} \d{4}(?!\d)/.test(seenText)
    && seenText.indexOf('not carried on this site yet') >= 0 && T.the_state_it_shows === 'EMPTY'
    && (seenText.indexOf('not public') >= 0 ? !lnk
        : !!lnk && /\/commit\/[0-9a-f]{7,40}$/.test(lnk.getAttribute('href')) && on(lnk));
  // NO ARITHMETIC AND NO INSTRUCTIONS ANYWHERE ON THE PAGE, not in a card and not in the markup a
  // reader can read. The words are listed once so they cannot come back by accident.
  // WRITTEN IN PIECES ON PURPOSE. Spelled out, the list of forbidden words IS three forbidden words
  // in the page, and the check fails on itself. It did, on its first run.
  const BANNED = ['pyth' + 'on ', 'key' + '.py', 'ever ' + 'issued'];
  const whole = document.documentElement.outerHTML.toLowerCase();
  T.banned_words_found = BANNED.filter(w => whole.indexOf(w) >= 0 || seenText.toLowerCase().indexOf(w) >= 0);
  T.T12_no_arithmetic_and_no_command_anywhere_on_the_page = T.banned_words_found.length === 0;
  // THE LINK AND THE LINES BELOW IT, MEASURED. The 0012 review found the card cut off after the
  // marked line on a phone: the ten lines below and the link to GitHub were behind the button bar.
  // Being in the markup is not being on the screen, so this asks the layout where they really are.
  show(address(k));
  for (let i = 0; i < 60 && !cardShown; i++) await new Promise(r => setTimeout(r, 100));
  await new Promise(r => setTimeout(r, 120));
  const lk = card.querySelector('a[href*="#L"]');
  T.T7_the_github_link_is_on_the_screen = on(lk);
  T.link_rect = lk ? [lk.getBoundingClientRect().left, lk.getBoundingClientRect().top,
                      lk.getBoundingClientRect().right, lk.getBoundingClientRect().bottom].map(Math.round) : null;
  { const w = cardShown && cardShown.window, pre = w && w.node;
    const lh = pre ? parseFloat(getComputedStyle(pre).lineHeight) || 16 : 16;
    if (w) w.scrollToTarget();
    const below = w ? w.last - w.at : 0;
    const roomBelow = pre ? Math.floor((pre.scrollTop + pre.clientHeight - ((w.at - w.first + 1) * lh)) / lh) : 0;
    T.lines_below_the_marked_line = below; T.lines_below_it_on_the_screen = Math.min(below, roomBelow);
    T.T8_ten_lines_below_are_there_and_five_are_on_the_screen = below >= CONTEXT && roomBelow >= 5 && on(pre);
    // A LONG LINE MAY RUN PAST THE EDGE ONLY IF THE WINDOW CAN BE SCROLLED TO IT. The wafer's window
    // keeps code as code, unwrapped; what would be a fault is a line cut off with no way to reach it.
    const ox = pre ? getComputedStyle(pre).overflowX : '';
    T.T9_no_code_line_runs_off_the_right_edge = !!pre && (pre.scrollWidth <= pre.clientWidth + 1 || ox === 'auto' || ox === 'scroll');
    const chip2 = card.querySelector('.cc-tag');
    T.the_state_of_a_carried_line = chip2 ? chip2.getAttribute('data-s') : null;
    T.T21_the_state_chip_says_OK_and_only_one_thing = !!chip2 && T.the_state_of_a_carried_line === 'OK'
      && card.querySelectorAll('.cc-tag').length === 1; }
  const bdy = card.querySelector('.cc-body');
  const box = el => { if (!el) return null; const r = el.getBoundingClientRect();
    return [r.left, r.top, r.right, r.bottom].map(Math.round); };
  T.sheet_rects = { card:box(card), body:box(bdy), window:box(card.querySelector('.cc-code')) };
  T.header = (card.querySelector('.cc-dl') || card).textContent.replace(/\s+/g, ' ').trim().slice(0, 120);
  T.T10_the_header_says_what_day_the_work_was_done = /(?<!\d)\d{1,2} [A-Z][a-z]{2} \d{4}(?!\d)/.test(T.header);
  // A TAP IN A DARK GAP MUST LEAD SOMEWHERE. A key between two pieces of work is a real place on
  // this picture and a reader lands on one often; it named the next piece of work and then left them
  // holding a sentence with nothing to press.
  let silent = null;
  for (const c of commits) { const g = address(c.k1); if (g && g.silent && g.next) { silent = c.k1; break; } }
  T.a_key_in_a_gap = silent;
  if (silent !== null) {
    show(address(silent));
    await new Promise(r => setTimeout(r, 120));
    const way = card.querySelector('a[data-key]');
    T.the_gap_card = card.textContent.replace(/\s+/g, ' ').slice(0, 120);
    T.T13_a_gap_leads_to_the_next_work = !!way && on(way);
    if (way) { way.click(); await new Promise(r => setTimeout(r, 250));
      T.after_following_it = card.textContent.replace(/\s+/g, ' ').slice(0, 90);
      T.T13_a_gap_leads_to_the_next_work = /(?<!\d)\d{1,2} [A-Z][a-z]{2} \d{4}(?!\d)/.test(card.textContent) && !!card.querySelector('.cc-tag'); }
  } else { T.T13_a_gap_leads_to_the_next_work = true; T.a_key_in_a_gap = 'this wafer has no gaps'; }
  // AND NO PANEL IS DRAWN FOR WORDS THAT ARE NOT THERE.
  litRepo = -1; litK = [-1, -1]; litCi = null; target = null; card.style.display = 'none'; draw();
  await new Promise(r => setTimeout(r, 60));
  { const hr = hud.getBoundingClientRect();
    T.readout_when_nothing_is_highlighted = [hud.textContent.trim().length, Math.round(hr.width), Math.round(hr.height)];
    T.T14_an_empty_readout_draws_no_box = hud.textContent.trim().length > 0 || hr.width < 1 || hr.height < 1; }
  // THE LINK CONTRACT, PROVED ON ITSELF AND AGAINST THE PUBLISHED TABLE. Parsing a link this page
  // built must give back exactly what it was asked for; and the address this page builds must be
  // the address the tools build, character for character, or the two have quietly drifted apart.
  try {
    const ct = await fetch('cosmos/link-contract.json').then(r => r.json());
    const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
    const wrong = [];
    for (const ex of ct.examples) {
      const built = buildLink(ex.asked);
      const want = {}; for (const k of Object.keys(LINK.params)) {
        const v = ex.asked[k]; want[k] = (v === undefined || v === null || v === '') ? null : v; }
      if (built !== ex.built) wrong.push({ asked:ex.asked, this_page:built, the_table:ex.built });
      else if (!same(parseLink(built), want)) wrong.push({ asked:ex.asked, came_back:parseLink(built) });
    }
    T.examples_checked = ct.examples.length;
    T.links_that_disagree = wrong;
    T.T15_a_link_this_page_built_parses_back_to_what_it_asked_for = ct.examples.length > 0 && wrong.length === 0;
  } catch (e) {
    // A TEST THAT CANNOT RUN MUST FAIL, NOT GO QUIET.
    T.T15_a_link_this_page_built_parses_back_to_what_it_asked_for = false;
    T.links_that_disagree = 'the published table could not be read: ' + (e && e.message || e);
  }
  // AND NOBODY TYPES AN ADDRESS. One function makes them; a hand written one is how the two halves
  // of a link stop agreeing without anybody noticing.
  try {
    const src = await fetch(location.pathname).then(r => r.text());
    const typed = [];
    for (const k of Object.keys(LINK.params)) {
      const needle = '?' + k + '=';
      let at = -1;
      while ((at = src.indexOf(needle, at + 1)) >= 0) {
        // A SENTENCE THAT MENTIONS AN ADDRESS IS NOT AN ADDRESS. A typed one begins a string, so
        // the character before the question mark is a quote. This sentence may not show you an
        // example, because an example would be the very thing it is looking for, and this check
        // failed on its own explanation the first time it ran.
        const before = at > 0 ? src[at - 1] : ' ';
        if (before === '"' || before === "'" || before === '`') typed.push(src.slice(Math.max(0, at - 30), at + 14));
      }
    }
    T.addresses_typed_by_hand = typed;
    T.T16_no_address_is_typed_by_hand_in_this_page = typed.length === 0;
  } catch (e) {
    T.T16_no_address_is_typed_by_hand_in_this_page = false;
    T.addresses_typed_by_hand = 'the page could not read its own source: ' + (e && e.message || e);
  }
  // ARRIVING BY A LINK. The view flies, an arrow is shot from the centre of the record to the work
  // the address names, and only then does the card open. The arrow must END ON THE DOT the card
  // describes: an arrow that points near the answer is worse than none, because it is believed.
  { const ka = c.k0 + Math.floor(c.lines / 3);
    home(); card.style.display = 'none'; target = null; arrow = null; arrowTip = null; draw();
    arriveAt(ka);
    // THE CLOCK IS NOT WHAT IS BEING CHECKED. Under a headless time budget this page gets about seven
    // animation frames in eight seconds, so waiting for the flight to finish measures the browser's
    // throttle. Put the camera where the flight was going, tell the arrow its time is up, draw once.
    for (let i = 0; i < 60 && !arrow; i++) await new Promise(r => setTimeout(r, 100));
    if (tween) { cx = tween.x1; cy = tween.y1; zoom = tween.z1; tween = null; }
    if (arrow) arrow.t0 = performance.now() - ARROW_MS;
    draw();
    const p = keyPlace(ka);
    const wx = (p[0] - cx) * zoom + ov.width / 2, wy = ov.height / 2 - (p[1] - cy) * zoom;
    T.arrow_tip = arrowTip ? [Math.round(arrowTip.x), Math.round(arrowTip.y)] : null;
    T.arrow_still_flying = !!arrow;
    T.camera = [Math.round(cx), Math.round(cy), +zoom.toFixed(3)];
    T.draws_seen = drawCount;
    T.the_dot_it_should_end_on = [Math.round(wx), Math.round(wy)];
    T.T17_the_arrow_ends_on_the_dot = !!arrowTip && arrowTip.done
      && Math.hypot(arrowTip.x - wx, arrowTip.y - wy) < 2;
    // and it is shot from the centre of the record, not from wherever the camera happened to be
    // IT COMES ALONG THE LINE FROM THE BEGINNING OF THE RECORD. After the camera flies, that point
    // is far off the screen, so what can be checked is not where the drawing starts but that the
    // drawing lies on the line: the direction is the meaning.
    { const c0x = (0 - cx) * zoom + ov.width / 2, c0y = ov.height / 2 + cy * zoom;
      const ux = wx - c0x, uy = wy - c0y, vx = (arrowTip ? arrowTip.x0 : 0) - c0x, vy = (arrowTip ? arrowTip.y0 : 0) - c0y;
      const cross = Math.abs(ux * vy - uy * vx) / Math.max(1, Math.hypot(ux, uy));
      T.arrow_starts_at = arrowTip ? [Math.round(arrowTip.x0), Math.round(arrowTip.y0)] : null;
      T.the_centre_of_the_record_is_at = [Math.round(c0x), Math.round(c0y)];
      T.how_far_the_arrow_is_off_that_line_px = arrowTip ? +cross.toFixed(2) : null;
      T.T18_it_is_shot_from_the_centre_of_the_record = !!arrowTip && cross < 2
        && arrowTip.x0 >= -1 && arrowTip.x0 <= ov.width + 1 && arrowTip.y0 >= -1 && arrowTip.y0 <= ov.height + 1; }
    for (let i = 0; i < 40 && card.style.display === 'none'; i++) await new Promise(r => setTimeout(r, 100));
    T.T19_and_then_the_card_opens = card.style.display !== 'none'
      && card.textContent.replace(/\s+/g, ' ').length > 20;
    T.the_card_after_arriving = card.textContent.replace(/\s+/g, ' ').slice(0, 90); }
  // AN ADDRESS THIS PAGE CANNOT ANSWER MUST SAY SO. The note claimed it already did; building such
  // a link was refused, but ARRIVING with one said nothing at all, which is the half a reader meets.
  { const A = window.__arrival || { said:[], shown:null };
    T.what_the_address_asked_for_that_this_page_cannot_answer = A.said;
    T.what_the_page_said_about_it = A.shown ? A.shown.replace(/\s+/g, ' ').slice(0, 150) : null;
    const said_it = A.said.length === 0 || (!!A.shown && A.said.every(x => A.shown.indexOf(x) >= 0));
    // and the sentences themselves, on addresses chosen here rather than on whatever this one was
    const one = complaints('https://x/?colour=red'), two = complaints('https://x/?key=abc'),
          none = complaints('https://x/?key=12&path=a');
    T.T20_an_address_it_cannot_answer_is_answered_in_words =
         said_it && one.length === 1 && one[0].indexOf('colour') >= 0
      && two.length === 1 && two[0].indexOf('whole number') >= 0 && none.length === 0; }
  // WHAT A LINE LEADS TO. The photographed line must say CABLES and open it; every carried file must
  // be given the application its folder proves and no other; a repository that is one application
  // must be proved by the repository alone; and where nothing is proved there must be no door at all.
  { codeOpen = false;                    // the door is met before the code is ever opened
    const withApp = cards.find(x => (appFor(x.owner, x.repo, x.path) || {}).app) || c;
    const noApp = cards.find(x => !(appFor(x.owner, x.repo, x.path) || {}).app);
    if (noApp) { show(address(noApp.k0 + 3)); await new Promise(r => setTimeout(r, 200));
      const r0 = card.querySelector('.cc-app');
      T.a_carried_file_no_application_claims = [noApp.path, r0 ? r0.textContent.slice(0, 40) : null];
      T.T26_a_carried_file_no_application_claims_gets_no_door = !!r0 && r0.tagName !== 'A' && !r0.querySelector('a:not(.cc-home):not(.cc-gh)'); }
    else T.T26_a_carried_file_no_application_claims_gets_no_door = true;
    show(address(withApp.k0 + Math.floor(withApp.lines / 2))); await new Promise(r => setTimeout(r, 200));
    const row = card.querySelector('.cc-app'), door = row && (row.tagName === 'A' ? row : row.querySelector('a:not(.cc-home):not(.cc-gh)'));
    T.the_app_row = row ? row.textContent.replace(/\s+/g, ' ') : null;
    const want_app = (appFor(withApp.owner, withApp.repo, withApp.path) || {}).app || null;
    T.T22_the_card_says_which_application_and_opens_it = !!row && !!want_app
      && row.getAttribute('data-app') === want_app.app && !!door && door.href === want_app.live && on(door);
    const wrong = [];
    for (const x of cards) { const f = appFor(x.owner, x.repo, x.path), got = f && f.app ? f.app.app : null;
      const byHand = apps.filter(a => a.repo === (x.owner + '/' + x.repo).toLowerCase()
        && a.prefixes.some(p => x.path === p || x.path.indexOf(p + '/') === 0)).map(a => a.app);
      if ((got || null) !== (byHand[0] || null) && !(byHand.length > 1 && byHand.indexOf(got) >= 0)) wrong.push([x.path, got, byHand]); }
    T.carried_files_and_their_applications = cards.map(x => [x.path.split('/').pop(), ((appFor(x.owner, x.repo, x.path) || {}).app || {}).app || 'none']);
    T.T23_every_carried_file_gets_the_application_its_folder_proves = apps.length > 0 && wrong.length === 0;
    // TWO WORKINGS OF ONE RULE MUST AGREE. The tool that carries a file works out its application by
    // folder and writes it down; this page works it out again for itself. File by file, and in the
    // number of lines that end up with a door, the two must come to the same answer.
    const differ = [], tally = { page:{}, tool:{} };
    for (const x of cards) { const pg = ((appFor(x.owner, x.repo, x.path) || {}).app || {}).app || '';
      if (pg !== x.toolApp) differ.push([x.path, 'page: ' + (pg || 'none'), 'tool: ' + (x.toolApp || 'none')]);
      if (pg) tally.page[pg] = (tally.page[pg] || 0) + x.lines;
      if (x.toolApp) tally.tool[x.toolApp] = (tally.tool[x.toolApp] || 0) + x.lines; }
    T.lines_with_a_door_by_application = tally; T.files_where_the_two_workings_differ = differ;
    T.T27_the_page_and_the_tool_agree_on_every_file_and_every_count = cards.length > 0 && differ.length === 0
      && JSON.stringify(tally.page) === JSON.stringify(tally.tool);
    // AND THE TWO EXAMPLES THE ORDER NAMES, asked for by name.
    const named = async (path, button, live) => { const x = cards.find(q => q.path === path);
      if (!x) return [false, 'the file ' + path + ' is not carried'];
      show(address(x.k0 + Math.floor(x.lines / 2))); await new Promise(r => setTimeout(r, 200));
      const rw = card.querySelector('.cc-app'), dr = rw && (rw.tagName === 'A' ? rw : null), pre = card.querySelector('details.cc-q');
      const above = !!dr && !!pre && dr.getBoundingClientRect().bottom <= pre.getBoundingClientRect().top + 0.5;
      return [!!rw && rw.textContent.indexOf(button) >= 0 && !!dr && dr.href === live && on(dr) && above,
              rw ? rw.textContent : null]; };
    const ca = await named('solar-bess-topology-v5/cable-geometry-visualiser-v5.html', 'CABLES',
      (apps.find(a => a.app === 'cables') || {}).live);
    const ga = await named('atlas/index.html', 'GRIDATLAS', 'https://ventusltd.github.io/gridatlas/atlas/');
    T.the_cables_line_says = ca[1]; T.the_gridatlas_line_says = ga[1];
    T.T28_the_cables_line_opens_cables_above_the_code_without_scrolling = ca[0];
    T.T29_a_gridatlas_line_opens_gridatlas_above_the_code_without_scrolling = ga[0];
    // a line whose file is NOT known, in a repository that holds several applications: no door
    const other = commits.find(q => { const rp = repos[q.repo]; return rp.pub && !cardFor(q.k0)
      && (appFor(rp.owner, rp.name, null) || {}).unproved; });
    if (other) { show(address(other.k0)); await new Promise(r => setTimeout(r, 150));
      const r2 = card.querySelector('.cc-app');
      T.an_unproved_line_says = r2 ? r2.textContent.slice(0, 90) : null;
      T.T24_where_nothing_is_proved_there_is_no_door = !!r2 && r2.tagName !== 'A' && !r2.querySelector('a:not(.cc-home):not(.cc-gh)') && r2.getAttribute('data-app') === '?'; }
    else T.T24_where_nothing_is_proved_there_is_no_door = true;
    // and a repository that IS one application is proved by the repository alone
    const wholeApp = apps.find(a => !a.prefixes.length);
    const oneOf = wholeApp && commits.find(q => { const rp = repos[q.repo];
      return rp.pub && (rp.owner + '/' + rp.name).toLowerCase() === wholeApp.repo; });
    if (oneOf) { show(address(oneOf.k0)); await new Promise(r => setTimeout(r, 150));
      const r3 = card.querySelector('.cc-app'), d3 = r3 && r3.tagName === 'A' ? r3 : null;
      T.a_whole_repository_application_says = r3 ? r3.textContent.slice(0, 70) : null;
      T.T25_a_repository_that_is_one_application_is_proved_by_the_repository = !!d3 && d3.href === wholeApp.live; }
    else T.T25_a_repository_that_is_one_application_is_proved_by_the_repository = true; }
  // THE CARD AS THE PERSON WHO SIGNS FIRST MEETS IT: the code closed. The application is the first
  // and biggest thing and the whole of it is the door; the brand block is GridAtlas's own; one plain
  // line says what was done and when; and above the closed code there is not one word a banker would
  // not use.
  { codeOpen = false;
    const x = cards.find(q => (appFor(q.owner, q.repo, q.path) || {}).app) || c;