GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Kuiper, cosmos and drawing engines / galaxies-wafers / proof/browser

Root Check and 4 more files

A JavaScript module in the browser folder of Galaxies Wafers that zooms run (`zoomRun`).

662 lines of JavaScript and HTML from galaxies-wafers, in 5 files. Topic: Kuiper, cosmos and drawing engines. Section 1228 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. Root Check render · galaxies-wafers / proof/browser/root.check.mjs lines 1–252
  2. Smoke test · galaxies-wafers / proof/browser/smoke.mjs lines 1–74
  3. Checks transform · galaxies-wafers / proof/checks.mjs lines 1–188
  4. Engine Check other · galaxies-wafers / proof/engine.check.mjs lines 1–46
  5. Galaxies Wafers — Proof Page render · galaxies-wafers / proof/index.html lines 1–102

Root Check

A JavaScript module in the browser folder of Galaxies Wafers that zooms run (`zoomRun`).

rendergalaxies-wafers / proof/browser/root.check.mjs · lines 1–252 of 252 · Not reached from any entry point (candidate for review) · pattern opened (shared by 2 files)

What it does
It lists and searches its content. Defines 20 functions or classes, including check, sleep, serve, newPage, goto. Uses libraries node:http, node:fs, node:os, node:path, node:child_process. Side effects: changes the web page (DOM); reads or writes files; starts processes.
What it achieves
It zooms run (`zoomRun`) and is built from the check step (`check`) and the sleep step (`sleep`). The root page, checked in a real browser against the root it replaced.
Why it matters
No other file in the estate was found to import it.
Application
galaxies-wafers · proof/browser · JavaScript module
Uses
Galaxies Wafers — Index Page (new URL import.meta.url), node:http, node:fs, node:os, node:path, node:child_process, node:module
Used by
none found
Produces
check, sleep, serve, newPage, goto, until, close, tagsOf, allOK, zoomRun, syntheticPinch, ev
Defines here
check, sleep, serve, newPage, goto, until, close, tagsOf, allOK, zoomRun, syntheticPinch, ev, cdpPinch, touch, opened, p95, sample, drag, ev, max
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 proof/browser/root.check.mjs:1-252 · blob 52418844e1dd07b54a6300235b5bf9b4f6d08d74 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, process · domain stage: unknown · users: none · canonical: unreached_review
/* The root page, checked in a real browser against the root it replaced.
 *
 * Run from the repository root:
 *   PPTR_REQUIRE=<path to a package.json that can require puppeteer-core> \
 *   CHROME_PATH=<chrome executable> node proof/browser/root.check.mjs
 *   ENGINE=webkit PLAYWRIGHT_MODULE=<file URL of playwright's index.mjs> node proof/browser/root.check.mjs
 *
 * It serves two directories from this process: the repository (the root page as
 * it now is) and BASE_REF's root page (default: the commit before the root
 * promotion) extracted with git archive into a temporary directory outside the
 * repository. Both load the numbered database from the network, as the page does.
 *
 * Asserted, and each one printed with its measurement:
 *   1. zero page errors on every load;
 *   2. ?layers=module-Ps,module-Gn,module-x126 reaches OK on all three rows;
 *   3. ?layers=ghost shows the dropped-from-the-URL warning naming ghost;
 *   4. a pinch release opens neither the line panel nor a code card (Chrome: a
 *      real two-finger CDP touch; both engines: synthetic pointer events). The
 *      same gesture is run on the baseline and its result printed, so the gate
 *      is seen failing on the page that had the defect;
 *   5. a tap that opens a card ticks no layer checkbox;
 *   6. zoom p95 frame interval is lower than the baseline's, measured in the same
 *      run, same browser, same layers (180 frames, one wheel step per frame);
 *   7. panning across the whole wafer diameter in x and y with the tiled copying
 *      layer ticked keeps features in memory at or under the ceiling, element
 *      count growth under 150, and (Chrome) JS heap under 200 MB.
 */
import http from 'node:http';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { execSync } from 'node:child_process';
import { createRequire } from 'node:module';

const ENGINE = process.env.ENGINE || 'chrome';
const BASE_REF = process.env.BASE_REF || '16516e919120e05aff8e13a358026d0fd44bfe12';
const REPO = path.resolve(new URL('../../', import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1'));
const OWNER = 'module-Ps,module-Gn,module-x126';
const results = [];
const failures = [];
const check = (name, ok, detail) => { results.push({ name, ok, detail }); if (!ok) failures.push(name); console.log(`${ok ? 'PASS' : 'FAIL'} ${name} :: ${JSON.stringify(detail)}`); };
const sleep = ms => new Promise(r => setTimeout(r, ms));

/* ── two static servers ───────────────────────────────────────────────────── */
const MIME = { '.html': 'text/html', '.mjs': 'text/javascript', '.js': 'text/javascript', '.css': 'text/css', '.json': 'application/json', '.png': 'image/png' };
function serve(dir) {
  return new Promise(res => {
    const srv = http.createServer((q, r) => {
      let p = decodeURIComponent(new URL(q.url, 'http://x').pathname);
      if (p.endsWith('/')) p += 'index.html';
      const f = path.join(dir, p);
      if (!f.startsWith(dir) || !fs.existsSync(f) || fs.statSync(f).isDirectory()) { r.writeHead(404); r.end('not found'); return; }
      r.writeHead(200, { 'content-type': MIME[path.extname(f)] || 'application/octet-stream' });
      fs.createReadStream(f).pipe(r);
    }).listen(0, '127.0.0.1', () => res(srv));
  });
}
const baseDir = fs.mkdtempSync(path.join(os.tmpdir(), 'wafer-baseline-'));
execSync(`git archive --format=tar ${BASE_REF} app.mjs layers-panel.mjs lib.mjs wafer.mjs style.css index.html layers | tar -x -C "${baseDir.replace(/\\/g, '/')}"`, { cwd: REPO, shell: true, stdio: ['ignore', 'ignore', 'inherit'] });
const [srvNew, srvOld] = await Promise.all([serve(REPO), serve(baseDir)]);
const NEW = `http://127.0.0.1:${srvNew.address().port}/`, OLD = `http://127.0.0.1:${srvOld.address().port}/`;
console.log(`engine ${ENGINE} · new ${NEW} · baseline ${BASE_REF.slice(0, 7)} at ${OLD}`);

/* ── the browser ──────────────────────────────────────────────────────────── */
/* __origRaf: the frame clock the zoom run reads. Pointer capture: a synthetic
   PointerEvent has no live pointer, so setPointerCapture would throw on it; the
   test (not the page) makes that call tolerant so synthetic gestures can run. */
const INSTR = `(() => {
  window.__origRaf = window.requestAnimationFrame.bind(window);
  const cap = Element.prototype.setPointerCapture;
  Element.prototype.setPointerCapture = function (id) { try { return cap.call(this, id); } catch (e) { return undefined; } };
})();`;
let browser;
async function newPage() {
  let page, cdp = null;
  if (ENGINE === 'webkit') {
    const { webkit, devices } = await import(process.env.PLAYWRIGHT_MODULE || 'playwright');
    browser ||= await webkit.launch();
    const ctx = await browser.newContext({ ...devices['iPhone 13'] });
    page = await ctx.newPage();
    await page.addInitScript(INSTR);
  } else {
    if (!process.env.PPTR_REQUIRE || !process.env.CHROME_PATH) throw new Error('set PPTR_REQUIRE and CHROME_PATH');
    const puppeteer = createRequire(process.env.PPTR_REQUIRE)('puppeteer-core');
    browser ||= await puppeteer.launch({ executablePath: process.env.CHROME_PATH, headless: 'new',
      args: ['--use-angle=swiftshader', '--enable-unsafe-swiftshader', '--enable-precise-memory-info', '--js-flags=--expose-gc'] });
    page = await browser.newPage();
    await page.setViewport({ width: 390, height: 844, deviceScaleFactor: 3, isMobile: true, hasTouch: true });
    await page.evaluateOnNewDocument(INSTR);
    cdp = await page.createCDPSession();
    await cdp.send('Performance.enable');
  }
  const errors = [];
  page.on('pageerror', e => errors.push(String(e.message || e).slice(0, 200)));
  page.on('crash', () => errors.push('CRASH'));
  const goto = u => page.goto(u, { waitUntil: ENGINE === 'webkit' ? 'networkidle' : 'networkidle0', timeout: 90000 });
  const until = (fn, arg, ms = 60000) => ENGINE === 'webkit' ? page.waitForFunction(fn, arg, { timeout: ms }) : page.waitForFunction(fn, { timeout: ms }, arg);
  const close = () => ENGINE === 'webkit' ? page.context().close() : page.close();
  return { page, cdp, errors, goto, until, close };
}
const tagsOf = (page, ids) => page.evaluate(ids => ids.map(id => (document.getElementById('L-' + id)?.closest('.lrow')?.querySelector('.ltag')?.textContent || 'absent').replace(/[\[\]]/g, '')), ids);
const allOK = ids => ids.every(id => /\[OK\]/.test(document.getElementById('L-' + id)?.closest('.lrow')?.textContent || ''));

/* one wheel step per animation frame for 180 frames; intervals between frames */
const zoomRun = page => page.evaluate(async () => {
  const raf = window.__origRaf, stage = document.getElementById('stage'), r = stage.getBoundingClientRect();
  const iv = []; let last = 0;
  for (let i = 0; i < 180; i++) {
    await new Promise(res => raf(() => { const n = performance.now(); if (last) iv.push(n - last); last = n;
      stage.dispatchEvent(new WheelEvent('wheel', { deltaY: (i % 60) < 30 ? -40 : 40, clientX: r.width / 2, clientY: r.height / 2, bubbles: true, cancelable: true }));
      res(); }));
  }
  await new Promise(res => setTimeout(res, 400));
  const s = iv.sort((x, y) => x - y), q = p => +s[Math.min(s.length - 1, Math.floor(p * s.length))].toFixed(1);
  return { median: q(0.5), p95: q(0.95) };
});

/* a pinch as pointer events on the stage: two fingers apart, then lifted one by one */
const syntheticPinch = page => page.evaluate(async () => {
  const st = document.getElementById('stage');
  const ev = (type, id, x, y) => st.dispatchEvent(new PointerEvent(type, { pointerId: id, pointerType: 'touch', isPrimary: id === 11, clientX: x, clientY: y, bubbles: true, cancelable: true }));
  ev('pointerdown', 11, 185, 420); ev('pointerdown', 12, 205, 420);
  for (let i = 1; i <= 10; i++) { ev('pointermove', 11, 185 - i * 6, 420); ev('pointermove', 12, 205 + i * 6, 420); await new Promise(r => requestAnimationFrame(r)); }
  ev('pointerup', 12, 265, 420);
  ev('pointerup', 11, 125, 420);   /* the last finger lifts where it has not moved since the other lifted */
  await new Promise(r => setTimeout(r, 300));
});
const cdpPinch = async (cdp) => {
  const touch = (type, pts) => cdp.send('Input.dispatchTouchEvent', { type, touchPoints: pts.map(([x, y], i) => ({ x, y, id: i + 1 })) });
  await touch('touchStart', [[175, 400], [215, 400]]);
  for (let i = 1; i <= 20; i++) { await touch('touchMove', [[175 - i * 5, 400], [215 + i * 5, 400]]); await sleep(16); }
  await touch('touchEnd', [[75, 400]]);
  await sleep(30);
  await touch('touchEnd', []);
  await sleep(400);
};
const opened = page => page.evaluate(() => ({ panel: !document.getElementById('panel').hidden, card: !!document.getElementById('card') && !document.getElementById('card').hidden, inspect: !!document.getElementById('layersInspect') && !document.getElementById('layersInspect').hidden }));

try {
  /* 2, 6 (new), 4, 5 */
  {
    const P = await newPage();
    await P.goto(NEW + '?layers=' + OWNER);
    await P.until(allOK, OWNER.split(',')).catch(() => {});
    const tags = await tagsOf(P.page, OWNER.split(','));
    check('owner layers reach OK', tags.every(t => t === 'OK'), { tags, url: await P.page.evaluate(() => location.search) });
    await sleep(1200);
    const zNew = [await zoomRun(P.page), await zoomRun(P.page)];

    await syntheticPinch(P.page);
    const synth = await opened(P.page);
    let real = null;
    if (P.cdp) { await cdpPinch(P.cdp); real = await opened(P.page); }
    check('pinch release opens no panel or card', !synth.panel && !synth.card && (!real || (!real.panel && !real.card)), { synthetic: synth, cdpTouch: real });

    const before = await P.page.evaluate(() => [...document.querySelectorAll('#layersList input')].filter(i => i.checked).map(i => i.id));
    await P.page.touchscreen.tap(195, 430);
    await sleep(2500);
    const afterTap = await opened(P.page);
    const after = await P.page.evaluate(() => [...document.querySelectorAll('#layersList input')].filter(i => i.checked).map(i => i.id));
    check('a tap opens a code card and ticks no checkbox', afterTap.card && JSON.stringify(before) === JSON.stringify(after), { card: afterTap.card, checkedBefore: before, checkedAfter: after });
    check('zero page errors (owner link, zoom, pinch, tap)', P.errors.length === 0, P.errors);
    await P.close();

    /* the same on the baseline */
    const B = await newPage();
    await B.goto(OLD + '?layers=' + OWNER);
    await B.until(allOK, OWNER.split(',')).catch(() => {});
    await sleep(1200);
    const zOld = [await zoomRun(B.page), await zoomRun(B.page)];
    await syntheticPinch(B.page);
    const bSynth = await opened(B.page);
    await B.page.click('#close').catch(() => {});
    await B.page.evaluate(() => { document.getElementById('panel').hidden = true; });
    let bReal = null;
    if (B.cdp) { await cdpPinch(B.cdp); bReal = await opened(B.page); }
    console.log(`baseline pinch release (the defect, expected open): ${JSON.stringify({ synthetic: bSynth, cdpTouch: bReal })}`);
    await B.close();

    const p95 = z => Math.min(...z.map(r => r.p95));
    check('zoom p95 frame interval lower than the baseline root', p95(zNew) < p95(zOld), { newRuns: zNew, baselineRuns: zOld, newBestP95: p95(zNew), baselineBestP95: p95(zOld) });
  }

  /* 3 */
  {
    const P = await newPage();
    await P.goto(NEW + '?layers=ghost');
    await P.until(() => /dropped from the URL[^]*ghost/.test(document.getElementById('layers')?.textContent || ''), null, 30000).catch(() => {});
    const warn = await P.page.evaluate(() => { const w = [...document.querySelectorAll('#layers .lwarn')].find(n => !n.hidden && /ghost/.test(n.textContent)); return w ? w.textContent : null; });
    check('?layers=ghost shows the dropped warning', !!warn, { warn, errors: P.errors });
    check('zero page errors (ghost link)', P.errors.length === 0, P.errors);
    await P.close();
  }

  /* 7 */
  {
    const P = await newPage();
    await P.goto(NEW + '?layers=copying,' + OWNER);
    await P.until(allOK, ['copying', ...OWNER.split(',')]).catch(() => {});
    const home = await P.page.evaluate(() => window.__waferLayers.stats);
    await P.page.evaluate(async () => {
      const stage = document.getElementById('stage');
      for (let i = 0; i < 60; i++) { stage.dispatchEvent(new WheelEvent('wheel', { deltaY: -40, clientX: 195, clientY: 422, bubbles: true, cancelable: true })); await new Promise(r => requestAnimationFrame(r)); }
    });
    await sleep(1200);
    const zoom = await P.page.evaluate(() => window.__wafer.view.zoom);
    const R = await P.page.evaluate(() => Math.sqrt(342795));
    const samples = [];
    const sample = async () => {
      const s = await P.page.evaluate(() => ({ ...window.__waferLayers.stats, dom: document.getElementsByTagName('*').length, heap: performance.memory ? performance.memory.usedJSHeapSize : null, x: window.__wafer.view.x, y: window.__wafer.view.y }));
      if (P.cdp) { const m = await P.cdp.send('Performance.getMetrics'); s.nodes = m.metrics.find(x => x.name === 'Nodes').value; }
      samples.push(s);
    };
    await sample();
    /* drags as pointer events on the stage: the same handler a finger reaches */
    const drag = (dx, dy) => P.page.evaluate(async ([dx, dy]) => {
      const st = document.getElementById('stage');
      const ev = (type, x, y) => st.dispatchEvent(new PointerEvent(type, { pointerId: 21, pointerType: 'touch', isPrimary: true, clientX: x, clientY: y, bubbles: true, cancelable: true }));
      ev('pointerdown', 195, 422);
      for (let i = 1; i <= 6; i++) { ev('pointermove', 195 + dx * i / 6, 422 + dy * i / 6); await new Promise(r => requestAnimationFrame(r)); }
      ev('pointerup', 195 + dx, 422 + dy);
    }, [dx, dy]);
    const per = 300 / zoom, n = d => Math.ceil(d / per);
    for (let i = 0; i < n(R); i++) await drag(300, 0);
    await sleep(500); await sample();
    for (let i = 0; i < n(2 * R); i++) { await drag(-300, 0); await sleep(180); if (i % 4 === 0) await sample(); }
    for (let i = 0; i < n(R); i++) await drag(300, 0);
    for (let i = 0; i < n(R); i++) await drag(0, 300);
    await sleep(500);
    for (let i = 0; i < n(2 * R); i++) { await drag(0, -300); await sleep(180); if (i % 4 === 0) await sample(); }
    await sleep(1500); await sample();
    const max = k => Math.max(...samples.map(s => s[k] ?? 0)), min = k => Math.min(...samples.map(s => s[k] ?? 0));
    const detail = { zoom: +zoom.toFixed(2), samples: samples.length, atHomeHeld: home.held,
      xRange: [Math.round(min('x')), Math.round(max('x'))], yRange: [Math.round(min('y')), Math.round(max('y'))],
      maxHeld: max('held'), cap: samples[0].cap, maxBands: max('bandsInMemory'), maxKeysDrawn: max('keysDrawn'), evictions: samples.at(-1).evictions, fetches: samples.at(-1).fetches,
      domMin: min('dom'), domMax: max('dom'), cdpNodesMax: P.cdp ? max('nodes') : null,
      heapMaxMB: samples[0].heap ? +(max('heap') / 1e6).toFixed(1) : null, heapEndMB: samples[0].heap ? +(samples.at(-1).heap / 1e6).toFixed(1) : null };
    const crossed = detail.xRange[0] < -R * 0.8 && detail.xRange[1] > R * 0.8 && detail.yRange[0] < -R * 0.8 && detail.yRange[1] > R * 0.8;
    check('pan across the whole wafer keeps memory, DOM and heap bounded',
      crossed && detail.maxHeld <= detail.cap && detail.domMax - detail.domMin < 150 && (detail.heapMaxMB === null || detail.heapMaxMB < 200), detail);
    check('zero page errors (pan)', P.errors.length === 0, P.errors);
    await P.close();
  }
} catch (e) {
  check('the check ran to the end', false, String(e && e.stack || e).slice(0, 400));
} finally {
  await browser?.close();
  srvNew.close(); srvOld.close();
  fs.rmSync(baseDir, { recursive: true, force: true });
}
console.log(failures.length ? `root check FAILED (${failures.length} of ${results.length}): ${failures.join('; ')}` : `root check PASS — ${results.length} assertions, ${ENGINE}`);
process.exit(failures.length ? 1 : 0);

Smoke

A JavaScript module in the browser folder of Galaxies Wafers that tests smoke result.

testgalaxies-wafers / proof/browser/smoke.mjs · lines 1–74 of 74 · Entry point

What it does
It tests smoke result. Defines f, q. Uses libraries node:fs, puppeteer. Side effects: changes the web page (DOM); reads or writes files; starts processes.
Inputs & outputs
Out: JSON file smoke-result.json.
Downstream impact
Used directly by 1 file: Browser Matrix Workflow (galaxies-wafers).
What it achieves
One browser job: load a served page, let its requested layers settle, zoom it for three seconds, and record what happened. It writes `smoke-result.json`.
Why it matters
Run by Browser Matrix Workflow.
Application
galaxies-wafers · proof/browser · JavaScript module
Uses
Judge (import), Galaxies Wafers — Index Page (estate URL), node:fs, puppeteer
Used by
run by Browser Matrix Workflow (workflow run)
Produces
f, q
Defines here
f, q
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 proof/browser/smoke.mjs:1-74 · blob 5decfb363f7dac24bc06d3e830a9ec1dacc35e86 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, process · domain stage: unknown · users: none · canonical: unknown
/* One browser job: load a served page, let its requested layers settle, zoom it
 * for three seconds, and record what happened. Fails on any page error, any
 * failed same-site request, or any requested layer that does not end OK or EMPTY
 * within 45 seconds (a layer left in WAIT is a failure, not a pass).
 * Environment: PAGE (path under BASE), SIZE (phone | desktop), BASE. */
import fs from 'node:fs';
import { judge } from './judge.mjs';

const { PAGE = '', SIZE = 'phone', BASE = 'https://ventusltd.github.io/galaxies-wafers/' } = process.env;
const url = BASE + PAGE;
const viewport = SIZE === 'phone'
  ? { width: 390, height: 844, deviceScaleFactor: 3, isMobile: true, hasTouch: true }
  : { width: 1400, height: 900, deviceScaleFactor: 1 };

const out = { url, size: SIZE, started: new Date().toISOString(), errors: [], failedRequests: [] };
const { default: puppeteer } = await import('puppeteer');
const browser = await puppeteer.launch({ args: ['--no-sandbox'] });
try {
  const page = await browser.newPage();
  await page.setViewport(viewport);
  page.on('pageerror', e => out.errors.push(e.message.slice(0, 300)));
  page.on('response', r => {
    if (r.status() >= 400 && r.url().startsWith(BASE) && !r.url().endsWith('favicon.ico')) out.failedRequests.push(`${r.status()} ${r.url()}`);
  });
  const cdp = await page.createCDPSession();
  await cdp.send('Performance.enable');
  const t0 = Date.now();
  await page.goto(url, { waitUntil: 'networkidle2', timeout: 90000 });
  out.loadMs = Date.now() - t0;

  const wanted = new URL(url).searchParams.get('layers')?.split(',').filter(Boolean) ?? [];
  const deadline = Date.now() + 45000;
  let states = {};
  while (Date.now() < deadline) {
    states = await page.evaluate(ids => Object.fromEntries(ids.map(id => {
      const cb = document.getElementById('L-' + id);
      const tag = cb?.closest('.lrow')?.querySelector('.ltag')?.textContent ?? 'absent';
      return [id, tag.replace(/[\[\]]/g, '')];
    })), wanted);
    if (Object.values(states).every(s => /^(OK|EMPTY|FAIL|absent)$/.test(s))) break;
    await new Promise(r => setTimeout(r, 500));
  }
  out.layers = states;
  out.settleMs = Date.now() - t0;

  const stage = await page.$('canvas');
  if (stage) {
    const box = await stage.boundingBox();
    await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
    await page.evaluate(() => {
      window.__frames = [];
      let last = performance.now();
      const f = t => { window.__frames.push(t - last); last = t; if (window.__frames.length < 2000) requestAnimationFrame(f); };
      requestAnimationFrame(f);
    });
    const zoomEnd = Date.now() + 3000;
    let dir = -1;
    while (Date.now() < zoomEnd) { await page.mouse.wheel({ deltaY: 120 * dir }); dir = -dir; await new Promise(r => setTimeout(r, 50)); }
    const frames = await page.evaluate(() => window.__frames.slice(1).sort((a, b) => a - b));
    const q = p => frames.length ? +frames[Math.min(frames.length - 1, Math.floor(p * frames.length))].toFixed(1) : null;
    out.zoomFrames = { count: frames.length, medianMs: q(0.5), p95Ms: q(0.95) };
  }
  const m = Object.fromEntries((await cdp.send('Performance.getMetrics')).metrics.map(x => [x.name, x.value]));
  out.heapMB = Math.round(m.JSHeapUsedSize / 1048576);
  out.domNodes = m.Nodes;
} catch (e) {
  out.errors.push('harness: ' + e.message.slice(0, 300));
} finally {
  await browser.close();
}
Object.assign(out, judge(out));
fs.writeFileSync('smoke-result.json', JSON.stringify(out, null, 1));
console.log(JSON.stringify(out, null, 1));
process.exit(out.pass ? 0 : 1);

Checks

A JavaScript module in the proof folder of Galaxies Wafers that calculates planar distances, using SHA-256. Served with the page at https://ventusltd.github.io/galaxies-wafers/proof/.

transformgalaxies-wafers / proof/checks.mjs · lines 1–188 of 188 · Entry point · pattern buildChecks (shared by 2 files)

What it does
It calculates its inputs. Defines buildChecks.
Downstream impact
Used directly by 2 files: Galaxies Wafers — Proof Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/proof/); Wafer Check (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/proof/). Reached from 242 other entry points, including 404 (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/404.html); Galaxies Wafers — Index Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/); Galaxies Wafers — Iterations Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/). It is itself an entry point, published at https://ventusltd.github.io/galaxies-wafers/proof/.
What it achieves
The checks behind The Line Wafer, written once and run in two places: `proof/index.html` runs them in a browser on a phone, `proof/wafer.check`.mjs runs them under Node with no browser for CI.
Why it matters
Loaded by the Proof page at https://ventusltd.github.io/galaxies-wafers/proof/. Also imported by Wafer Check.
Application
galaxies-wafers · proof · JavaScript module
Uses
Galaxies Wafers — Lib (import)
Used by
imported by Galaxies Wafers — Proof Page (import), imported by Wafer Check (import)
Produces
buildChecks
Defines here
buildChecks
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 proof/checks.mjs:1-188 · blob 479af13d6d5c02aea409491f0f401f267026179a · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: unknown · users: none · canonical: unknown
/* The checks behind The Line Wafer, written once and run in two places:
 * proof/index.html runs them in a browser on a phone, proof/wafer.check.mjs
 * runs them under Node with no browser for CI. Both read the same bytes the
 * page itself reads and compute every number rather than asserting it.
 *
 * A check takes no arguments and returns true or false. Its name is the claim
 * it is testing, written so that a reader who has never seen the code can tell
 * what failed.
 */

/* These are the page's own functions, not copies of them. The first version of
   this file reimplemented the logic it was meant to be checking, so a check
   could pass while the page was wrong. It imports from lib.mjs now. */
import { GOLDEN, place, ownersOf, indexOfKey, parseKey, connectAnswer, fanoutCount, esc } from '../lib.mjs';
export { GOLDEN, place, ownersOf, indexOfKey, parseKey, connectAnswer, fanoutCount, esc };

/* Every claim the page or its README makes, as a list of named checks. */
export function buildChecks(D) {
  const { meta, keys, lens, inFam, families, famLines } = D;
  let carried = 0;
  for (let i = 0; i < inFam.length; i++) carried += inFam[i];
  const owner = ownersOf(families, famLines);
  const shared = [...owner.values()].filter(v => v.length > 1).length;
  const two = owner.get(2) || [];

  return [
    ['the three parallel arrays are the same length, so index i means one line in all three',
      () => keys.length === lens.length && lens.length === inFam.length],

    ['the count the page prints, 250,174, is the number of keys in the pack and the number the pack declares',
      () => keys.length === 250174 && meta.lines === keys.length],

    ['the numbering runs 1 to 342,795 exactly as the pack header states',
      () => keys[0] === 1 && keys[keys.length - 1] === meta.max && meta.max === 342795],

    ['the keys ascend strictly, which is the only reason the page may binary search them',
      () => { for (let i = 1; i < keys.length; i++) if (keys[i] <= keys[i - 1]) return false; return true; }],

    ['numbers were skipped, so a gap on the surface is a real answer and not a missing record',
      () => meta.max > keys.length && meta.max - keys.length === 92621],

    ['no number is issued twice, which is what makes a number a permanent name for one line',
      () => meta.duplicate_rows === 0 && new Set(keys).size === keys.length],

    ['128,369 lines are carried by a function family, matching the flag pack and the header',
      () => carried === 128369 && carried === meta.in_a_family],

    ['every family range lies inside lines.bin, and the ranges between them account for all of it',
      () => families.every(f => f.lineOffset >= 0 && f.lineOffset + f.lineCount <= famLines.length)
         && families.reduce((a, f) => a + f.lineCount, 0) === famLines.length],

    ['the family ranges resolve exactly the same LINES the flag pack marks as carried - every row is '
      + 'checked, not merely the same total, because two different sets can share one size',
      () => { if (owner.size !== carried) return false;
              for (let i = 0; i < keys.length; i++) {
                const has = owner.has(keys[i]) ? 1 : 0;
                if (has !== inFam[i]) return false;
              } return true; }],

    ['every family offset and count is a non-negative integer and the ranges tile lines.bin exactly '
      + 'once, end to end, with no gap and no overlap',
      () => { const sorted = [...families].sort((a, b) => a.lineOffset - b.lineOffset);
              let at = 0;
              for (const f of sorted) {
                if (!Number.isInteger(f.lineOffset) || !Number.isInteger(f.lineCount)) return false;
                if (f.lineOffset < 0 || f.lineCount < 0) return false;
                if (f.lineOffset !== at) return false;
                at += f.lineCount;
              }
              return at === famLines.length; }],

    ['45,671 lines are carried by more than one family: those, and only those, can be connected. '
      + 'The page counts this from the data rather than carrying the number, because the first number '
      + 'written here by hand was wrong by about a thousand',
      () => shared === 45671 && shared < owner.size],

    ['line 2 is an empty line carried by thousands of families, so the page ships a real example of a '
      + 'connection that is true and worthless',
      () => lens[indexOfKey(keys, 2)] === 0 && two.length > 2000],

    ['CONNECT, the rule this page exists to meet: two DIFFERENT lines that share one single family join '
      + 'through it. The page first claimed a line in only one family had nothing to join to. That was '
      + 'wrong, and this fixture is the proof it was wrong',
      () => { const a = connectAnswer(3, 4, { keys, owner });
              return a.verdict === 'joined' && a.both.length >= 1
                && (owner.get(3) || []).length === 1 && (owner.get(4) || []).length === 1; }],

    ['CONNECT: two lines whose families do not overlap are refused rather than joined',
      () => { let x = -1, y = -1;
              for (let i = 0; i < keys.length && y < 0; i++) {
                const o = owner.get(keys[i]);
                if (!o || o.length !== 1) continue;
                if (x < 0) { x = keys[i]; continue; }
                if (!owner.get(x).includes(o[0])) y = keys[i];
              }
              if (x < 0 || y < 0) return false;
              return connectAnswer(x, y, { keys, owner }).verdict === 'disjoint'; }],

    ['CONNECT: a number that was never issued is refused and named, rather than silently drawn',
      () => { let gap = -1;
              for (let k = meta.max; k > meta.max - 5000 && gap < 0; k--) if (indexOfKey(keys, k) < 0) gap = k;
              if (gap < 0) return false;
              const a = connectAnswer(3, gap, { keys, owner });
              return a.verdict === 'absent' && a.absent.includes(gap); }],

    ['CONNECT: a line no family carries is refused and named as the one without a family',
      () => { let k = -1;
              for (let i = 0; i < keys.length; i++) if (inFam[i] === 0) { k = keys[i]; break; }
              if (k < 0) return false;
              const a = connectAnswer(3, k, { keys, owner });
              return a.verdict === 'no-family' && a.without.includes(k); }],

    ['CONNECT: joining a line to itself is answered explicitly rather than reported as a discovery',
      () => connectAnswer(3, 3, { keys, owner }).verdict === 'same-line'],

    ['FANOUT and CO-MEMBERSHIP are different relations and the page keeps them apart: fanout is one '
      + 'number in several families, co-membership is two numbers in one family, and a line with no '
      + 'fanout is still connectable',
      () => fanoutCount(owner) === shared && shared < owner.size
         && (owner.get(3) || []).length === 1
         && connectAnswer(3, 4, { keys, owner }).verdict === 'joined'],

    ['a line the flag pack calls uncarried is carried by no family - every one of the 250,174 rows is '
      + 'checked, not the first forty thousand',
      () => { for (let i = 0; i < keys.length; i++) if (inFam[i] === 0 && owner.has(keys[i])) return false; return true; }],

    ['the number parser refuses what parseInt would have accepted: trailing letters, a number too large '
      + 'to hold exactly, zero, a negative and empty text; and it accepts a number typed with separators',
      () => !parseKey('12abc').ok && !parseKey('9007199254740993').ok && !parseKey('0').ok
         && !parseKey('-5').ok && !parseKey('').ok && !parseKey(' 1e5 ').ok
         && parseKey(' 8,285 ').ok && parseKey(' 8,285 ').key === 8285],

    ['dataset text is escaped before it reaches the page, because a code catalogue may legitimately '
      + 'contain markup characters in a function name',
      () => esc('<img src=x onerror=1>') === '&lt;img src=x onerror=1&gt;'
         && esc('a&b') === 'a&amp;b'
         && !esc('<b>').includes('<')],

    ['placing the same number twice in this process returns the identical point. That is determinism of '
      + 'the function, not a measurement of every device: it is double arithmetic, and the claim beyond '
      + 'this process is an argument rather than a test',
      () => { const a = place(8285), b = place(8285); return a[0] === b[0] && a[1] === b[1]; }],

    ['a number beyond those issued still has a finite place, and beyond the safe integer range the '
      + 'parser refuses rather than the arithmetic quietly losing precision',
      () => Number.isFinite(place(meta.max + 100000)[0]) && Number.isFinite(place(1e9)[1])
         && !parseKey(String(Number.MAX_SAFE_INTEGER + 2)).ok],

    ['the arrangement spreads the numbers rather than stacking them: fewer than one sampled point in '
      + 'twenty shares a quarter-unit cell with an earlier one',
      () => {
        const seen = new Set(); let hit = 0, n = 0;
        for (let i = 0; i < keys.length; i += 7) {
          const [x, y] = place(keys[i]);
          const g = Math.round(x * 4) + ':' + Math.round(y * 4);
          if (seen.has(g)) hit++; else seen.add(g);
          n++;
        }
        return hit / n < 0.05;
      }],

    ['consecutive numbers land far apart, so a ring of the picture is a period of the estate history '
      + 'and not one run of code',
      () => { const a = place(100000), b = place(100001); return Math.hypot(b[0] - a[0], b[1] - a[1]) > 1; }],

    ['the pack states where it came from and what it hashed to, so every number on the page is traceable '
      + 'to a source rather than typed in',
      () => typeof meta.source?.sha256 === 'string' && meta.source.sha256.length === 64
         && /LINES\.md$/.test(meta.source.url || '')],

    ['exactly one line reaches the ceiling of the sixteen-bit length field, so the pack cannot state its '
      + 'true length and the page says so instead of printing 65,535 as a measurement',
      () => { let cap = 0, m = 0;
              for (let i = 0; i < lens.length; i++) { if (lens[i] === 65535) cap++; if (lens[i] > m) m = lens[i]; }
              return cap === 1 && m === 65535; }],

    ['every family has a name and a kind, so no card the page draws is nameless',
      () => families.every(f => typeof f.name === 'string' && f.name.length > 0
                             && typeof f.kind === 'string' && f.kind.length > 0)],

    ['1,689 families carry no category at all, which is why the page prints "no category recorded" '
      + 'rather than the word null on a card',
      () => families.filter(f => f.category === null).length === 1689],

    ['no family claims more lines than the whole estate has numbered',
      () => families.every(f => f.lineCount >= 0 && f.lineCount <= keys.length)]
  ];
}

Engine Check

A JavaScript module in the proof folder of Galaxies Wafers. Served with the page at https://ventusltd.github.io/galaxies-wafers/proof/. It is built from the check step (`check`) and the throws step (`throws`).

othergalaxies-wafers / proof/engine.check.mjs · lines 1–46 of 46 · Not reached from any entry point (candidate for review) · pattern throws (shared by 12 files)

What it does
Defines check, throws. Side effects: starts processes.
What it achieves
The code galaxy's deep-link contract, checked offline.
Why it matters
No other file in the estate was found to import it.
Application
galaxies-wafers · proof · JavaScript module
Uses
Code Galaxy Engine (import)
Used by
none found
Produces
check, throws
Defines here
check, throws
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 proof/engine.check.mjs:1-46 · blob a3bb5b119284348e46625b09ee4892042285094a · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: process · domain stage: unknown · users: none · canonical: unreached_review
/* engine.check.mjs — the code galaxy's deep-link contract, checked offline.
 * Same discipline as the grid engine's deeplink proof: no socket, no DOM.
 * Run: node proof/engine.check.mjs
 */
import { schema, LIFTED_FROM, IDENTITY_PARAM, PARAMS, RECEIVERS, NOT_COMPUTED,
         buildDeepLink, parseDeepLink } from '../engine/code-galaxy-engine.mjs';

const failures = []; let passed = 0;
const check = (n, c) => { c ? passed++ : failures.push(n); };
const throws = (fn, K) => { try { fn(); return false; } catch (e) { return e instanceof K; } };

check('the contract says what it was lifted from', /ventus-grid-engine/.test(LIFTED_FROM) && /deeplink\.v1$/.test(schema));
check('the identity is the permanent line number, and it is required',
  IDENTITY_PARAM === 'line' && PARAMS.line.required === true && PARAMS.line.type === 'integer');
check('the contract carries no position, and says so', /wafer\.mjs/.test(NOT_COMPUTED.place) && !('latitude' in PARAMS) && !('longitude' in PARAMS));
check('every receiver has an id, a status and a URL', RECEIVERS.every(r => r.id && r.status && /^https:\/\//.test(r.url)));
check('the receivers table is frozen', Object.isFrozen(RECEIVERS) && RECEIVERS.every(Object.isFrozen));

const link = buildDeepLink('galaxies-wafers', { line: 8285, to: 34201, layers: ['engine', 'declared'], zoom: 9 });
check('a full link round-trips exactly',
  (() => { const p = parseDeepLink(link); return p.ok && p.line === 8285 && p.to === 34201
    && p.layers.join(',') === 'engine,declared' && p.zoom === 9 && p.receiver === 'galaxies-wafers'; })());
check('the link carries only permanent identifiers and numbers: no names, no coordinates',
  !/lat|lon|name|%20/.test(link) && /\?line=8285&to=34201&layers=engine,declared&zoom=9$/.test(link));
check('a link to the layerless wafer refuses a layers field rather than emitting one it cannot read',
  throws(() => buildDeepLink('line-wafer-202609151339', { line: 3, layers: ['engine'] }), Error));
check('a link to an unknown receiver throws rather than returning a dead link',
  throws(() => buildDeepLink('atlas-v8', { line: 3 }), Error));
check('a non-integer identity throws at build time',
  throws(() => buildDeepLink('galaxies-wafers', { line: '8285' }), TypeError)
  && throws(() => buildDeepLink('galaxies-wafers', { line: 0 }), TypeError)
  && throws(() => buildDeepLink('galaxies-wafers', { line: 2 ** 53 }), TypeError));
check('zoom outside the wafer\'s range throws', throws(() => buildDeepLink('galaxies-wafers', { line: 3, zoom: 5000 }), RangeError));
check('a layer id with unsafe characters throws', throws(() => buildDeepLink('galaxies-wafers', { line: 3, layers: ['<b>'] }), TypeError));
check('parse never throws: a bad link comes back with ok false and a reason',
  !parseDeepLink('nonsense').ok && /not a URL/.test(parseDeepLink('nonsense').why)
  && !parseDeepLink('https://x/?to=4').ok && /missing line/.test(parseDeepLink('https://x/?to=4').why)
  && !parseDeepLink('https://x/?line=12abc').ok && !parseDeepLink('https://x/?line=1e308').ok);
check('a bad second number keeps the first so the receiver can refuse and still show the line',
  (() => { const p = parseDeepLink('https://x/?line=3&to=banana'); return !p.ok && p.line === 3; })());
check('duplicate layer ids collapse and empty ones drop',
  parseDeepLink('https://x/?line=3&layers=engine,,engine,%20').layers.join(',') === 'engine');

if (failures.length) { console.error('engine proof FAILED (' + failures.length + ' of ' + (failures.length + passed) + '):\n- ' + failures.join('\n- ')); process.exit(1); }
console.log('engine proof PASS — ' + passed + ' checks');
export default { status: 'PASS', checks: passed };

Galaxies Wafers — Proof Page

A web page that draws lines meta and families, using SHA-256. Published at https://ventusltd.github.io/galaxies-wafers/proof/. It is built from the fmt step (`fmt`) and the bin step (`bin`).

rendergalaxies-wafers / proof/index.html · lines 1–102 of 102 · Entry point

What it does
It draws lines meta and families. Defines $, fmt, bin. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
README: "The page (`index.html`, `app.mjs`, `lib.mjs`) is inherited unchanged from testcode/202609151339."
Inputs & outputs
In: JSON file all-lines.meta.json; JSON file families.json. Out: web page.
Downstream impact
Used directly by 16 files: Iterations — 01 Route Alpha Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/01-route-alpha/); Galaxies Wafers — Index Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/); Iterations — 02 Tunnels Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/02-tunnels/); Iterations — 03 Code Particle Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/03-code-particle/); and 12 more. Reached from 226 other entry points, including 404 (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/404.html); Galaxies Wafers — Iterations Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/); Iterations — 09 Deeplink Receiver (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/09-deeplink-receiver/). It is itself an entry point, published at https://ventusltd.github.io/galaxies-wafers/proof/.
What it achieves
Proofs — The Line Wafer.
Why it matters
Loaded by the 01 Route Alpha page at https://ventusltd.github.io/galaxies-wafers/iterations/01-route-alpha/ and 15 other pages.
Application
galaxies-wafers · proof · page
Uses
Checks (import), Galaxies Wafers — Index Page (link)
Used by
linked from Iterations — 01 Route Alpha Page (link), linked from Galaxies Wafers — Index Page (link), linked from Iterations — 02 Tunnels Page (link), linked from Iterations — 03 Code Particle Page (link), linked from Iterations — 04 400kV Engine Page (link), linked from Iterations — 05 Periodic Table Page (link), linked from Iterations — 06 Stars As Engines Page (link), linked from Iterations — 07 Code Card Page (link), and 8 more
Produces
$, fmt, bin
Defines here
$, fmt, bin
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 proof/index.html:1-102 · blob 4587c387928afce91e306136db9de96d0f71eac1 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: unknown · users: none · canonical: unknown
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="color-scheme" content="dark">
<title>Proofs — The Line Wafer</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='none' stroke='%23d8dee9'/%3E%3Ccircle cx='8' cy='8' r='2' fill='%23ffd54a'/%3E%3C/svg%3E">
<style>
  :root{--ink:#d8dee9;--dim:#8b93a7;--ground:#0b0d12;--edge:#1b2030;--ok:#7fd6a2;--bad:#ff8a80;--lit:#ffd54a}
  *{box-sizing:border-box}
  body{margin:0;background:var(--ground);color:var(--ink);
    padding:calc(env(safe-area-inset-top,0px) + 1rem) 1rem calc(env(safe-area-inset-bottom,0px) + 2rem);
    font:14px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;-webkit-text-size-adjust:100%}
  main{max-width:46rem;margin:0 auto}
  h1{font-size:17px;letter-spacing:.06em;margin:0 0 .25rem}
  a{color:#5ec8f2}
  .dim{color:var(--dim)}
  #tally{margin:1rem 0;padding:.75rem .9rem;border:1px solid var(--edge);border-radius:8px;font-size:15px}
  .ok{color:var(--ok)} .bad{color:var(--bad)}
  ol{padding-left:1.4rem;margin:1rem 0}
  li{margin:.6rem 0}
  li .v{display:inline-block;min-width:3.4rem;font-weight:600}
  #err{color:var(--lit);white-space:pre-wrap;overflow-wrap:anywhere}
  footer{margin-top:2rem;border-top:1px solid var(--edge);padding-top:.75rem;font-size:12px}
</style>
</head>
<body>
<main>
  <h1>PROOFS · THE LINE WAFER</h1>
  <p class="dim">Every claim the wafer makes, checked in this browser against the same bytes the page reads.
  Nothing is asserted here; each number is computed on your device when you open this page.
  <a href="../">Open the wafer</a></p>

  <div id="tally">running…</div>
  <ol id="list"></ol>
  <p id="err"></p>

  <footer class="dim">
    <div id="prov">provenance loading</div>
    <div>A check that fails is a defect in the page or in the data, not in the check. Both are worth knowing.</div>
  </footer>
</main>

<script type="module">
import { buildChecks } from './checks.mjs';

const D = 'https://globalgrid2050.com/testcode/202609142202/data/';
const $ = id => document.getElementById(id);
const fmt = n => n.toLocaleString('en-GB');

async function bin(name, Kind) {
  const r = await fetch(D + name, { cache: 'default' });
  if (!r.ok) throw new Error(D + name + ' returned HTTP ' + r.status);
  return new Kind(await r.arrayBuffer());
}

try {
  const [meta, keys, lens, inFam, families, famLines] = await Promise.all([
    fetch(D + 'all-lines.meta.json').then(r => r.json()),
    bin('all-lines.bin', Uint32Array),
    bin('all-lines.len.bin', Uint16Array),
    bin('all-lines.family.bin', Uint8Array),
    fetch(D + 'families.json').then(r => r.json()),
    bin('lines.bin', Uint32Array)
  ]);

  $('prov').textContent =
    `numbered database built ${meta.built_utc.slice(0,16).replace('T',' ')} UTC · source ${meta.source.url} · sha256 ${meta.source.sha256.slice(0,16)}…`;

  const checks = buildChecks({ meta, keys, lens, inFam, families, famLines });
  const list = $('list');
  let pass = 0, fail = 0;

  for (const [name, fn] of checks) {
    let ok = false, threw = null;
    const t0 = performance.now();
    try { ok = fn() === true; } catch (e) { threw = e.message; }
    const ms = Math.round(performance.now() - t0);
    ok ? pass++ : fail++;
    const li = document.createElement('li');
    li.innerHTML = `<span class="v ${ok ? 'ok' : 'bad'}">${ok ? 'PASS' : 'FAIL'}</span> ${name}` +
      (threw ? ` <span class="bad">— threw: ${threw}</span>` : '') +
      (ms > 40 ? ` <span class="dim">(${ms} ms)</span>` : '');
    list.appendChild(li);
    $('tally').innerHTML =
      `<span class="${fail ? 'bad' : 'ok'}">${fail ? fail + ' FAILED' : 'ALL PASSING'}</span> · ` +
      `${pass} of ${checks.length} checked`;
    await new Promise(r => setTimeout(r, 0));   /* let the phone paint between checks */
  }

  $('tally').innerHTML =
    `<span class="${fail ? 'bad' : 'ok'}">${fail ? fail + ' of ' + checks.length + ' FAILED' : 'ALL ' + checks.length + ' CHECKS PASS'}</span>` +
    ` <span class="dim">· over ${fmt(keys.length)} numbered lines and ${fmt(families.length)} families</span>`;
} catch (e) {
  $('tally').innerHTML = '<span class="bad">COULD NOT RUN</span>';
  $('err').textContent = 'The proofs could not read the numbered database: ' + e.message
    + '\nThat is itself a finding: the page they check reads the same files.';
}
</script>
</body>
</html>