GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Automation and CI / globalgrid2050 / testcode/202609160224/enforcers

Render Proof and 4 more files

A JavaScript module in the enforcers folder of GlobalGrid2050. It is built from the project step (`project`), the is ground helper (`isGround`) and the ground of helper (`groundOf`).

618 lines of JavaScript and HTML from globalgrid2050, in 5 files. Topic: Automation and CI. Section 1798 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. Render Proof transform · globalgrid2050 / testcode/202609160224/enforcers/render-proof.mjs lines 1–260
  2. Card Check storage · globalgrid2050 / testcode/202609160224/proof/card.check.mjs lines 1–75
  3. Estate Vacuity Check other · globalgrid2050 / testcode/202609160224/proof/estate-vacuity.check.mjs lines 1–95
  4. Testcode — Proof Page render · globalgrid2050 / testcode/202609160224/proof/index.html lines 1–92
  5. Laws Check ingest · globalgrid2050 / testcode/202609160224/proof/laws.check.mjs lines 1–96

Render Proof

A JavaScript module in the enforcers folder of GlobalGrid2050. It is built from the project step (`project`), the is ground helper (`isGround`) and the ground of helper (`groundOf`).

transformglobalgrid2050 / testcode/202609160224/enforcers/render-proof.mjs · lines 1–260 of 260 · version 2026-09-16 02:24 · Entry point · pattern project (shared by 18 files)

What it does
It calculates its inputs. Defines 10 functions or classes, including project, isGround, groundOf, onCamera, liveness.
Why it exists in the grid workflow
Domain stage experimental (path word 'testcode'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
Downstream impact
Used directly by 1 file: Testcode — Proof Page (globalgrid2050, https://globalgrid2050.com/testcode/202609160224/proof/).
What it achieves
Proving the picture, not just the data.
Why it matters
Loaded by the Proof page at https://globalgrid2050.com/testcode/202609160224/proof/.
Application
globalgrid2050 · testcode/202609160224/enforcers · JavaScript module
Uses
none found
Used by
imported by Testcode — Proof Page (import)
Produces
GOLDEN, project, groundOf, onCamera, liveness, placement, derivation, honesty, report
Defines here
project, isGround, groundOf, onCamera, liveness, placement, near, derivation, honesty, report
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/202609160224/enforcers/render-proof.mjs:1-260 · blob 72772015391c188ada76879407f6abd73153bc25 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: production_core
/* render-proof.mjs — proving the picture, not just the data.
 *
 * WHY THIS EXISTS, and it is not a test-coverage gap. Tonight testcode/202609160224
 * passed particles.check.mjs 6/6 honest and 3/6 mutated, and nest.check.mjs 6/6 and
 * 2/6, while rendering ZERO pixels at its default zoom. Both statements were true at
 * once and neither check was wrong: they examine bands, places, derivation and counts,
 * and the failure was in the raster. Not one proof in this estate asserted that a
 * pixel had ever reached a canvas.
 *
 * For an ordinary application that is a coverage gap. Here it is a category error.
 * We are building a graphical language: if the UI and the code are the same language,
 * the picture is not the presentation of the result, the picture IS the result. A
 * blank canvas is the language failing to speak while every check reports the grammar
 * is sound. (The argument is vikra-ac's, at 02:25Z; the implementation is the chair's.)
 *
 * WHY IT NEEDS NO GOLDEN IMAGE. Rendering is normally checked against a stored
 * baseline: brittle, machine-dependent, and a maintenance burden that rots. Not here,
 * because position is a pure function of the key —
 *
 *     r = sqrt(key)        theta = key x 2.39996...
 *
 * so given a camera, THE EXPECTED PICTURE IS COMPUTABLE WITHOUT RENDERING IT. We can
 * say in advance which pixel key 192,067 must occupy. The check and the thing checked
 * derive from the same formula, so they cannot drift apart.
 *
 * WHY IT IS A MODULE AND NOT PART OF ONE SURFACE. Every wafer in the estate places by
 * this law — the line wafer, the code wafer, the family wafer when it is built, and
 * each of the ten laws in 202609151413. One render proof serves all of them, the same
 * way lib.mjs is shared: the law is shared, so the proof of the law is shared.
 */

export const GOLDEN = Math.PI * (3 - Math.sqrt(5));

/* The camera a surface is using, as plain numbers, so the proof needs no access to
   the page's internals — only what it would need to draw. */
export function project(key, cam) {
  const r = Math.sqrt(key), a = key * GOLDEN;
  return {
    x: cam.cx + Math.cos(a) * r * cam.scale * cam.zoom + cam.panX,
    y: cam.cy + Math.sin(a) * r * cam.scale * cam.zoom + cam.panY,
  };
}

const isGround = (d, o, g) => d[o] === g[0] && d[o + 1] === g[1] && d[o + 2] === g[2];

/* MEASURE THE GROUND, NEVER TAKE IT ON THE PAGE'S WORD.
 *
 * nest.mjs declares `ground: [5, 7, 11]` — the colour it fills with. vikra-ac drove the
 * live canvas and found (0,0,0) across 243,667 of 329,160 pixels: createImageData starts
 * at zero and putImageData overwrites the fillRect ground. So the declared ground matched
 * almost nothing, EVERY PIXEL COUNTED AS LIT, and liveness reported the entire canvas
 * against a floor of 12,508. Both levels were vacuous while passing.
 *
 * That is the within-artifact failure vikra-ac named: an artifact's self-description
 * diverging from its behaviour. Its rule is the estate's founding move pointed inward —
 * AN ARTIFACT MAY NOT DECLARE ANYTHING ABOUT ITSELF THAT IT COULD MEASURE. The wafer
 * derives a position rather than storing one because a derived thing cannot drift. A
 * ground colour is exactly as derivable.
 *
 * The modal pixel is the ground, by construction: the wafer is sparse, so whatever colour
 * most of the canvas is, is the background. That cannot be wrong about a canvas it just
 * read, whatever the page believes it drew. The page's declaration is now a HINT that gets
 * reported when it disagrees, rather than a contract that gets trusted.
 */
export function groundOf(ctx, w, h, declared) {
  const d = ctx.getImageData(0, 0, w, h).data;
  const seen = new Map();
  for (let o = 0; o < d.length; o += 4) {
    const k = (d[o] << 16) | (d[o + 1] << 8) | d[o + 2];
    seen.set(k, (seen.get(k) || 0) + 1);
  }
  let best = 0, bestN = -1;
  for (const [k, n] of seen) if (n > bestN) { bestN = n; best = k; }
  const measured = [(best >> 16) & 255, (best >> 8) & 255, best & 255];
  const agrees = declared && declared.every((v, i) => v === measured[i]);
  return {
    ground: measured,
    pixels: bestN,
    total: w * h,
    declared: declared || null,
    agrees: !!agrees,
    note: declared
      ? (agrees
        ? 'the page declared ' + declared.join(',') + ' and the canvas agrees'
        : 'THE PAGE DECLARED ' + declared.join(',') + ' AND THE CANVAS IS ' + measured.join(',') +
          ' — measured, because a declaration is not evidence about the thing declaring it')
      : 'no declaration offered; measured from the canvas',
  };
}

/* How many of these keys the camera can actually show. Derived, like everything
   else: project each key and count the ones that land on the canvas. This is what
   makes the liveness floor honest instead of a constant. */
export function onCamera(keys, cam, w, h) {
  let n = 0;
  for (const k of keys) {
    const p = project(k, cam);
    if (p.x >= 0 && p.y >= 0 && p.x < w && p.y < h) n++;
  }
  return n;
}

/* LEVEL 1 — LIVENESS. Did anything at all reach the canvas?
 *
 * The first version took a constant, and vikra-ac was right that it was far too
 * weak: keyCount/1000 is 250 pixels on a 1378x852 canvas — 0.02% of it — so a
 * projection that collapsed every particle into one corner would still light
 * hundreds of pixels and PASS. A check that a broken picture can satisfy is not
 * a check.
 *
 * The floor is now derived from the camera. Count how many keys the camera can
 * show, and require a twentieth of them to be lit; at deep zoom, where few keys are
 * visible, the floor falls with them, so one rule serves both without a special case.
 *
 * PASS THE WHOLE KEY ARRAY, NEVER A SAMPLE. The first wiring handed this function
 * sampleKeys(4000), so it counted 4,000 keys on camera and set the floor at 200 —
 * LOWER than the keyCount/1000 constant it replaced, and 363x slack against the
 * 72,689 pixels actually lit. The comment claimed "tens of thousands"; the code
 * produced 200. A PROVENANCE failure, not a scope one: the value was correct for
 * the thing it was computed from and wrong for the thing it was about. With every
 * key, the default camera gives 12,508 — which is what was always meant.
 *
 * vikra-ac found it only because this function PRINTS THE NUMBERS IT REASONED FROM
 * — "4,000 keys are on camera, so the floor is 200" — and 4,000 is not 250,174.
 * A check that prints only its verdict hides its own inputs. */
export function liveness(ctx, w, h, ground, keys, cam) {
  const expected = onCamera(keys, cam, w, h);
  const floor = Math.max(1, Math.floor(expected / 20));
  const d = ctx.getImageData(0, 0, w, h).data;
  let lit = 0;
  for (let o = 0; o < d.length; o += 4) if (!isGround(d, o, ground)) lit++;
  return {
    name: 'the canvas holds a picture',
    ok: lit >= floor,
    detail: lit.toLocaleString() + ' non-ground pixels of ' + (w * h).toLocaleString() +
      ' · ' + expected.toLocaleString() + ' keys are on camera, so the floor is ' +
      floor.toLocaleString() + ' (a twentieth)',
  };
}

/* LEVEL 2 — PLACEMENT. Is it the picture of THESE KEYS?
   Liveness passes on noise. This computes where each key must land from the law and
   requires a lit pixel within `tol` of it, which catches the whole family of
   projection bugs that look plausible and are wrong: a bad scale, a dropped pan
   offset, a sign error in y. */
export function placement(ctx, w, h, ground, keys, cam, tol = 1) {
  const d = ctx.getImageData(0, 0, w, h).data;
  const near = (px, py) => {
    for (let dy = -tol; dy <= tol; dy++) {
      for (let dx = -tol; dx <= tol; dx++) {
        const x = Math.round(px) + dx, y = Math.round(py) + dy;
        if (x < 0 || y < 0 || x >= w || y >= h) continue;
        if (!isGround(d, (y * w + x) * 4, ground)) return true;
      }
    }
    return false;
  };
  /* THE SKIP IS ONLY ALLOWED WHEN OFF-CAMERA IS LEGITIMATE.
     The first version skipped any sample key that projected off the canvas, which
     vikra-ac identified as the same defect shape as everything else tonight: a
     check quietly narrowing its own scope. At the DEFAULT camera every key is on
     screen by construction — the page's own footer says "250,174 on screen of
     250,174" — so a skip there cannot be legitimate and is itself the bug. Under
     the default camera an off-screen sample FAILS. Only a zoomed or panned camera
     may skip, because there off-screen is the honest answer. */
  const isDefault = cam.zoom === 1 && cam.panX === 0 && cam.panY === 0;
  const checked = [], missed = [], offCamera = [];
  for (const k of keys) {
    const p = project(k, cam);
    if (p.x < 0 || p.y < 0 || p.x >= w || p.y >= h) { offCamera.push(k); continue; }
    checked.push(k);
    if (!near(p.x, p.y)) missed.push(k);
  }
  const illegalSkip = isDefault && offCamera.length > 0;
  return {
    name: 'the picture is the picture of these keys',
    ok: checked.length > 0 && missed.length === 0 && !illegalSkip,
    detail: illegalSkip
      ? offCamera.length + ' sampled keys projected OFF a default camera, where every key must be on screen: ' +
        offCamera.slice(0, 6).join(', ') + ' — the projection is wrong, not the sample'
      : checked.length === 0
        ? 'no sample key was on camera — the sample or the camera is wrong'
        : (checked.length - missed.length) + ' of ' + checked.length +
          ' sampled keys found a lit pixel within ' + tol + 'px of where the law puts them' +
          (missed.length ? ' · missing: ' + missed.slice(0, 6).join(', ') : '') +
          (offCamera.length ? ' · ' + offCamera.length + ' off-camera, allowed because zoom ' +
            cam.zoom.toFixed(2) + ' is not the default' : ''),
  };
}

/* LEVEL 3 — DERIVATION. Is the picture a pure function of the keys?
   `drawWith(order)` must render the same camera using the given iteration order. If
   reversing the order changes one byte, the raster depends on something other than
   the keys. This is the direct test of a claim the code makes and cannot otherwise
   defend: ties between two particles on one pixel are the COMMON case — vikra-ac
   measured 361 of 486 reachable channel-sums produced by more than one colour — so
   the tie-break is load-bearing. Today it is key order, which is derived. The day
   someone batches by nature or draws band by band, this fails loudly instead of the
   picture changing in silence.

   RUN AT 12ea17ee IT RETURNED A VERDICT, not an argument: reversing the iteration
   order changed NO BYTE of 601,440. It also REFINED the measurement rather than
   confirming it. Ties are REACHABLE — 361 of 486 channel-sums — but at that camera
   no two co-located particles actually tie. Possibility is not occurrence. Both
   statements are true and sound contradictory, so both are recorded. */
export function derivation(ctx, w, h, drawWith) {
  drawWith('ascending');
  const a = ctx.getImageData(0, 0, w, h).data.slice();
  drawWith('descending');
  const b = ctx.getImageData(0, 0, w, h).data;
  let first = -1, diff = 0;
  for (let i = 0; i < a.length; i++) {
    if (a[i] !== b[i]) { diff++; if (first < 0) first = i; }
  }
  drawWith('ascending');                 /* leave the canvas as the reader expects */
  return {
    name: 'the raster is a pure function of the keys',
    ok: diff === 0,
    detail: diff === 0
      ? 'reversing the iteration order changed no byte of ' + a.length.toLocaleString()
      : diff.toLocaleString() + ' bytes differ, first at offset ' + first +
        ' — the picture depends on draw order, not only on the keys',
  };
}

/* LEVEL 0 — HONESTY. Does the artifact tell the truth about itself?
 *
 * This runs BEFORE the other three, because it decides whether they mean anything. When
 * nest.mjs declared ground (5,7,11) and the canvas was (0,0,0), every pixel counted as
 * lit: liveness passed on the whole canvas and placement found a "lit" pixel wherever it
 * looked. Both were vacuous while green, across 24 surfaces, and nothing said so.
 *
 * groundOf() measured the disagreement and REPORTED it — which, by the charter's own rule
 * a-gate-must-not-be-ignorable, is advice. A report the caller can ignore has the standing
 * of prose. So the disagreement now FAILS.
 *
 * That is the boundary charter.json named for measure-dont-declare, and this is it built:
 * an artifact may not declare anything about itself that it could measure, and the proof
 * refuses rather than printing the divergence beside a pass.
 */
export function honesty(g) {
  return {
    name: 'the page tells the truth about its own ground',
    ok: !g.declared || g.agrees,
    detail: g.note + ' · ' + g.pixels.toLocaleString() + ' of ' + g.total.toLocaleString() +
      ' px' + (g.declared && !g.agrees
        ? ' — EVERY OTHER LEVEL IS VACUOUS UNTIL THIS PASSES: a wrong ground makes every pixel count as lit'
        : ''),
  };
}

export function report(results) {
  let failed = 0;
  const lines = results.map((r) => {
    if (!r.ok) failed++;
    return (r.ok ? 'PASS  ' : 'FAIL  ') + r.name + '\n        ' + r.detail;
  });
  lines.push('\n' + (results.length - failed) + '/' + results.length + ' passed');
  return { text: lines.join('\n'), failed };
}

Card Check

A JavaScript module in the proof folder of GlobalGrid2050. Served with the page at https://globalgrid2050.com/testcode/202609160224/proof/. It is built from the read step (`read`).

storageglobalgrid2050 / testcode/202609160224/proof/card.check.mjs · lines 1–75 of 75 · version 2026-09-16 02:24 · Not reached from any entry point (candidate for review)

What it does
It loads data. Defines read, ok. Uses libraries node:fs, node:url, node:path. Side effects: reads or writes files; starts processes; uses storage (browser storage, DuckDB or Parquet).
Why it exists in the grid workflow
Domain stage experimental (path word 'testcode'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
Inputs & outputs
In: command-line arguments.
What it achieves
The card must get out of the way without getting lost. It responds to pointermove events.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · testcode/202609160224/proof · JavaScript module
Uses
node:fs, node:url, node:path
Used by
none found
Produces
read, ok
Defines here
read, ok
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/202609160224/proof/card.check.mjs:1-75 · blob da32cf9e863662d37002fc118686ae39d251a924 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, process, storage · domain stage: experimental · users: none · canonical: unreached_review
/* card.check.mjs — the card must get out of the way without getting lost.
 *
 * Run: node proof/card.check.mjs            (from testcode/202609160224)
 *      node proof/card.check.mjs --mutate   (shows the checks can fail)
 *
 * This reads the three shipped files rather than a copy of their logic. It cannot
 * click, so it checks the CONTRACT that makes clicking work: the handle exists, the
 * states are defined, the handlers are bound, and the card no longer covers the sky.
 * Where it cannot verify something, it says so rather than passing quietly.
 */
import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import path from 'node:path';

const here = path.dirname(fileURLToPath(import.meta.url));
const read = f => readFileSync(path.join(here, '..', f), 'utf8');
const MUT = process.argv.includes('--mutate');

let html = read('index.html'), css = read('style.css'), js = read('nest.mjs');
if (MUT) {                      // break each contract in turn
  html = html.replace('id="grip"', 'id="grip-broken"').replace('id="reopen"', 'id="reopen-broken"');
  css = css.replace('#panel.min #panelbody{display:none}', '');
  js = js.replace("gripEl.addEventListener('pointermove'", "gripEl.noSuchThing('pointermove'");
}

const checks = [];
const ok = (name, cond, detail) => checks.push({ name, pass: !!cond, detail });

ok('the card has a drag handle', /id="grip"/.test(html), 'index.html #grip');
ok('the handle carries a title, minimise and close',
   /id="griptitle"/.test(html) && /id="min"/.test(html) && /id="close"/.test(html),
   'griptitle + min + close');
ok('a reopen control exists outside the card', /id="reopen"/.test(html),
   'index.html #reopen — a closed card must be recoverable');

ok('the card no longer spans the viewport',
   !/#panel\{[^}]*bottom:calc\(var\(--bot\) \+ 2\.2rem\)[^}]*\}/.test(css.split('@media')[0]),
   'top+bottom pinning removed from the base rule, so the galaxy stays visible');
ok('the card has a bounded width', /#panel\{[^}]*width:min\(/.test(css), 'width:min(30rem, …)');
ok('minimised hides the body but keeps the handle',
   /#panel\.min #panelbody\{display:none\}/.test(css), '#panel.min #panelbody{display:none}');
ok('the handle is exempt from browser touch panning',
   /#grip\{[^}]*touch-action:none/.test(css), 'touch-action:none — drag works on touch');
ok('the handle shows it is draggable', /#grip\{[^}]*cursor:grab/.test(css), 'cursor:grab');

ok('drag is wired to pointer events',
   /gripEl\.addEventListener\('pointerdown'/.test(js) &&
   /gripEl\.addEventListener\('pointermove'/.test(js) &&
   /gripEl\.addEventListener\('pointerup'/.test(js), 'pointerdown/move/up on the grip');
ok('a drag that leaves the window still ends', /pointercancel/.test(js), 'pointercancel bound');
ok('buttons inside the handle do not start a drag',
   /e\.target\.closest\('button'\)/.test(js), "closest('button') guard");
ok('the card is kept inside the window', /function clampToView/.test(js), 'clampToView()');
ok('minimise toggles both ways', /function setMin/.test(js) && /setMin\(!panel\.classList\.contains\('min'\)\)/.test(js),
   'setMin(on) with a toggle caller');
ok('reopen restores and un-minimises',
   /reopenEl\.addEventListener\('click'[\s\S]{0,200}setMin\(false\)/.test(js), 'reopen -> setMin(false)');
ok('stored position never breaks the card',
   (js.match(/catch \(_\)/g) || []).length >= 2 && /sessionStorage/.test(js),
   'sessionStorage reads and writes are guarded — blocked storage must not stop the card');
ok('phone escape targets meet WCAG 2.2 SC 2.5.8 (24x24 minimum)',
   /@media \(max-width:640px\)[\s\S]*?#grip button\{[\s\S]*?min-width:44px[\s\S]*?min-height:44px/.test(css),
   'on the one device class where the card cannot be dragged, minimise must be hittable');
ok('the escape target is separated from the destructive one',
   /@media \(max-width:640px\)[\s\S]*?#grip button\{[\s\S]*?margin-left:8px/.test(css),
   'minimise hides the card, close destroys it — a mis-tap must not cost the reader their card');
ok('phones dock the card instead of dragging it',
   /@media \(max-width:640px\)/.test(css) && /innerWidth <= 640/.test(js),
   'CSS dock + JS drag guard agree on the same breakpoint');

const pass = checks.filter(c => c.pass).length;
for (const c of checks) console.log(`${c.pass ? 'PASS' : 'FAIL'}  ${c.name}\n        ${c.detail}`);
console.log(`\n${pass}/${checks.length} passed` + (MUT ? '   (--mutate: failures above are the proof the checks can fail)' : ''));
console.log('NOT CHECKED HERE: that a real pointer drags a real card. That needs a browser; this proves the contract only.');
process.exit(MUT ? 0 : (pass === checks.length ? 0 : 1));

Estate Vacuity Check

A JavaScript module in the proof folder of GlobalGrid2050. Served with the page at https://globalgrid2050.com/testcode/202609160224/proof/.

otherglobalgrid2050 / testcode/202609160224/proof/estate-vacuity.check.mjs · lines 1–95 of 95 · version 2026-09-16 02:24 · Not reached from any entry point (candidate for review)

What it does
It lists and searches its content. Defines check, run, fails. Uses libraries node:fs, node:path, node:child_process. Side effects: reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage experimental (path word 'testcode'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
Inputs & outputs
In: command-line arguments.
What it achieves
It is built from the check step (`check`), the run step (`run`) and the fails step (`fails`). The 24 generated surfaces must be able to fail too.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · testcode/202609160224/proof · JavaScript module
Uses
node:fs, node:path, node:child_process
Used by
none found
Produces
check, run, fails
Defines here
check, run, fails
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/202609160224/proof/estate-vacuity.check.mjs:1-95 · blob e9413d516d38a7a489d6d3cdbc1687a97ee9a9fc · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: experimental · users: none · canonical: unreached_review
/* estate-vacuity.check.mjs — the 24 generated surfaces must be able to fail too.
 *
 * charter.check.mjs holds a vacuity gate over the suites in THIS surface's proof/ folder:
 * every one must fail strictly more under --mutate than honestly, because a mutation that
 * bites nothing is a proof of nothing. Five went vacuous tonight and a person caught each.
 *
 * THE GATE STOPPED AT THIS SURFACE'S EDGE. The 24 generated law surfaces each carry their
 * own proof/law.check.mjs, and nothing measured whether THEIR mutations bite. That matters
 * more than usual here: vikra-2e's first generator mutation used Math.random()*0 — a no-op
 * — and reported all 24 at 6/6, meaning none could be shown to fail. It fixed that itself
 * before handing them over, and the chair then verified it by hand.
 *
 * A HAND-VERIFICATION IS PROSE. It was true when it was run and nothing holds it. That is
 * the night's whole lesson — reporting discipline decays because it lives in prose,
 * structural discipline does not because it lives in the tool — so the hand-check becomes
 * a gate.
 *
 * It is a separate suite rather than an extension of charter.check.mjs because it spawns
 * 48 node processes and the charter gate should stay quick enough to run on every commit.
 *
 * Run:  node proof/estate-vacuity.check.mjs
 *       node proof/estate-vacuity.check.mjs --mutate
 */
import fs from 'node:fs';
import path from 'node:path';
import { execFileSync } from 'node:child_process';

const HERE = path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1'));
const SURF = path.resolve(HERE, '..');
const ROOT = path.resolve(SURF, '..');
const MUTATE = process.argv.includes('--mutate');

const results = [];
const check = (n, ok, d) => results.push({ n, ok: !!ok, d });

function run(dir, mutate) {
  try {
    return execFileSync(process.execPath,
      ['proof/law.check.mjs', ...(mutate ? ['--mutate'] : [])],
      { cwd: dir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
  } catch (e) { return (e.stdout || '') + (e.stderr || ''); }
}

/* Count failures the way the suite reports them, not the way this file prefers —
   a leading FAIL, or an N/M tally. Same correction the charter gate needed. */
function fails(out) {
  const marked = (out.match(/^\s*FAIL/gm) || []).length;
  if (marked) return marked;
  const m = /(\d+)\/(\d+) passed/.exec(out);
  return m ? Number(m[2]) - Number(m[1]) : 0;
}

const surfaces = fs.readdirSync(ROOT)
  .filter((d) => /^\d{10,14}$/.test(d) && fs.existsSync(path.join(ROOT, d, 'proof', 'law.check.mjs')));

check('the generated surfaces were found', surfaces.length >= 20,
  surfaces.length + ' surfaces carry their own proof/law.check.mjs');

const vacuous = [], broken = [], measured = [];
for (const d of surfaces) {
  const dir = path.join(ROOT, d);
  const honest = fails(run(dir, false));
  const mutated = fails(run(dir, true));
  measured.push(d + ' ' + honest + '->' + mutated);
  if (honest > 0) broken.push(d + ' fails ' + honest + ' honestly');
  if (mutated <= honest) vacuous.push(d + ' (' + honest + ' -> ' + mutated + ')');
}

/* --mutate here means: pretend one surface's mutation bites nothing, and require this
   gate to notice. Without it, a gate that reported "0 vacuous" could be reporting that
   because it never looked. */
const injected = MUTATE ? ['injected-surface (2 -> 2)'] : [];
const all = vacuous.concat(injected);

check('every generated surface can be shown to fail', all.length === 0,
  all.length
    ? all.length + ' prove nothing — mutation bites no harder than the honest run: ' +
      all.slice(0, 4).join(' · ')
    : surfaces.length + ' surfaces, each failing more under mutation · ' +
      measured.slice(0, 3).join(' · ') + ' · …');

check('every generated surface passes honestly', broken.length === 0,
  broken.length ? broken.slice(0, 4).join(' · ')
    : surfaces.length + ' surfaces, 0 failures on the honest run');

let failed = 0;
for (const r of results) {
  if (!r.ok) failed++;
  console.log((r.ok ? 'PASS  ' : 'FAIL  ') + r.n + '\n        ' + r.d);
}
console.log('\n' + (results.length - failed) + '/' + results.length + ' passed' +
  (MUTATE ? '   (--mutate: a surface whose mutation bites nothing is injected and must be caught)' : ''));
console.log('NOT CHECKED HERE: that any surface DRAWS what its law computes. That needs a browser.');
console.log('END OF REPORT - ' + results.length + ' checks');
process.exit(MUTATE ? 0 : failed ? 1 : 0);

Testcode — Proof Page

A web page in GlobalGrid2050 that draws on a canvas. Published at https://globalgrid2050.com/testcode/202609160224/proof/. It is built from the wait for helper (`waitFor`).

renderglobalgrid2050 / testcode/202609160224/proof/index.html · lines 1–92 of 92 · version 2026-09-16 02:24 · Entry point

What it does
It draws its content. Defines waitFor. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage experimental (path word 'testcode'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
Inputs & outputs
Out: web page; canvas drawing.
Downstream impact
It is itself an entry point, published at https://globalgrid2050.com/testcode/202609160224/proof/.
What it achieves
Wafer Galaxy — render proof. It responds to load events.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
globalgrid2050 · testcode/202609160224/proof · page
Uses
Render Proof (import), GlobalGrid2050 — Testcode Page (iframe)
Used by
none found
Produces
waitFor
Defines here
waitFor
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/202609160224/proof/index.html:1-92 · blob a513a0cac20c9751f682e9c43cd1e88b14861840 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: experimental · users: none · canonical: production_core
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="color-scheme" content="dark">
<title>Wafer Galaxy — render proof</title>
<style>
 body{margin:0;background:#05070b;color:#d8dee9;font:12px/1.6 ui-monospace,Menlo,Consolas,monospace;padding:1rem}
 h1{font-size:12px;letter-spacing:.14em;color:#ffd54a;margin:0 0 .2rem}
 .dim{color:#8b93a7}
 pre{white-space:pre-wrap;margin:.8rem 0;padding:.6rem;background:#000;border:1px solid #2a2a2a;border-radius:3px}
 .pass{color:#7fd67f} .fail{color:#ff6b6b}
 iframe{width:100%;height:420px;border:1px solid #444;border-radius:3px;background:#000}
</style>
</head>
<body>
<h1>WAFER GALAXY — RENDER PROOF</h1>
<p class="dim">
  Proving the picture, not the data. The surface below is the real page, loaded in a frame;
  these checks read <em>its</em> canvas rather than a copy of its drawing code — a proof that
  reimplements the thing it checks proves only that two implementations agree.
  No golden image is stored: because position is a pure function of the key, the expected
  picture is computable, so the check and the thing checked derive from the same formula.
</p>
<pre id="out">loading the surface…</pre>
<iframe id="surface" src="../index.html" title="the wafer under proof"></iframe>

<script type="module">
import { honesty, liveness, placement, derivation, report, groundOf } from '../enforcers/render-proof.mjs';

const out = document.getElementById('out');
const frame = document.getElementById('surface');

const waitFor = (test, ms = 20000) => new Promise((res, rej) => {
  const t0 = Date.now();
  (function poll() {
    let ok = false;
    try { ok = test(); } catch { ok = false; }
    if (ok) return res();
    if (Date.now() - t0 > ms) return rej(new Error('timed out after ' + ms + 'ms'));
    setTimeout(poll, 120);
  })();
});

frame.addEventListener('load', async () => {
  try {
    const win = frame.contentWindow;
    out.textContent = 'surface loaded — waiting for the numbered pack (1.75 MB)…';
    await waitFor(() => win.__wafer && win.__wafer.ready());

    const W = win.__wafer;
    const cam = W.camera();
    const canvas = frame.contentDocument.getElementById('stage');
    const ctx = canvas.getContext('2d');
    /* MEASURED, not taken from the page. W.ground declared [5,7,11]; vikra-ac found the
       canvas is (0,0,0) across 74% of its pixels, so every pixel counted as lit and both
       levels passed vacuously. The page's declaration is now a hint, reported when it
       disagrees, never trusted. */
    const g = groundOf(ctx, cam.w, cam.h, W.ground);
    const ground = g.ground;

    /* EVERY key, not a sample of them. Handing liveness sampleKeys(4000) made its
       camera count 4,000 and its floor 200 — lower than the keyCount/1000 constant
       it replaced, and 363x slack against the 72,689 pixels actually lit. Projecting
       250,174 points is one cheap loop, and it is what the rule always claimed. */
    const results = [
      /* Level 0 first: it decides whether the other three mean anything. A declared
         ground that disagrees with the canvas makes every pixel count as lit. */
      honesty(g),
      liveness(ctx, cam.w, cam.h, ground, W.allKeys(), cam),
      placement(ctx, cam.w, cam.h, ground, W.sampleKeys(20), cam, 1),
      derivation(ctx, cam.w, cam.h, (order) => W.drawWith(order)),
    ];

    const { text, failed } = report(results);
    out.textContent =
      'camera: ' + cam.w + 'x' + cam.h + ' dpr ' + cam.dpr +
      ' zoom ' + cam.zoom + ' scale ' + cam.scale.toFixed(5) + '\n' +
      'keys:   ' + W.keyCount().toLocaleString() + '\n\n' + text;
    out.className = failed ? 'fail' : 'pass';
    document.title = (failed ? 'FAIL ' : 'PASS ') + document.title;
  } catch (err) {
    out.className = 'fail';
    out.textContent = 'the proof could not run: ' + err.message +
      '\n\nThat is a failure, not an absence of one: a render proof that cannot reach the canvas' +
      ' tells you nothing about the picture.';
  }
});
</script>
</body>
</html>

Laws Check

A JavaScript module in the proof folder of GlobalGrid2050. Served with the page at https://globalgrid2050.com/testcode/202609160224/proof/. It is built from the check step (`check`) and the tier step (`tier`).

ingestglobalgrid2050 / testcode/202609160224/proof/laws.check.mjs · lines 1–96 of 96 · version 2026-09-16 02:24 · Not reached from any entry point (candidate for review)

What it does
It loads data. Defines check, tier. Uses libraries node:fs, node:path. Side effects: reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage experimental (path word 'testcode'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
Inputs & outputs
In: command-line arguments.
What it achieves
A law may only run on facts the page actually has.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · testcode/202609160224/proof · JavaScript module
Uses
Laws (import), node:fs, node:path
Used by
none found
Produces
check, tier
Defines here
check, tier
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/202609160224/proof/laws.check.mjs:1-96 · blob cc56d87ee59e20b78e4e4b7543dac8479cbe223c · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: experimental · users: none · canonical: unreached_review
/* laws.check.mjs — a law may only run on facts the page actually has.
 *
 * Vikram asked for twenty variations. A variation is a LAW over the same estate, and
 * testcode/202609151413/physics.mjs already holds ten of them. The temptation is to
 * ship all ten and call it ten variations. Three of them read facts this page has no
 * source for, and JavaScript will not stop you: hand a law `undefined` and the
 * arithmetic still runs, a picture still appears, and it is a plausible lie.
 *
 * That is the failure this estate spent the night cataloguing, one level up. So this
 * proof asserts that the classification is real, derived from the laws' own source,
 * and that a refused law is refused BY NAME rather than quietly run on zeros.
 *
 * Run:  node proof/laws.check.mjs
 *       node proof/laws.check.mjs --mutate
 */
import fs from 'node:fs';
import path from 'node:path';
import { requirementsOf, catalogue, classify, ALL, FROM_PACK, FROM_BAND, ABSENT, READY, ON_BAND, REFUSED }
  from '../laws.mjs';

const HERE = path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1'));
const SURF = path.resolve(HERE, '..');
const PHYSICS = path.resolve(SURF, '..', '202609151413', 'physics.mjs');
const MUTATE = process.argv.includes('--mutate');

const results = [];
const check = (n, ok, d) => results.push({ n, ok: !!ok, d });

const src = fs.readFileSync(PHYSICS, 'utf8');
const reqs = requirementsOf(src);
const cat = catalogue(reqs);
const tier = (t) => cat.filter((c) => c.tier === t);

/* 1. The requirements are PARSED FROM THE LAWS, not restated. A hand-written table
      would drift from physics.mjs the first time a law changed, and nothing would
      say so — the same reason the header count reads NATURE_NAME[NOISE] rather than
      typing "dust" a second time. */
const waferNeeds = reqs.wafer || [];
check('requirements are read from physics.mjs, not retyped',
  waferNeeds.length === 1 && waferNeeds[0] === 'key' && Object.keys(reqs).length >= 10,
  Object.keys(reqs).length + ' laws parsed · wafer needs [' + waferNeeds.join(', ') + ']');

/* 2. Every fact a law asks for is classified somewhere. An unclassified field would
      fall through as available and be handed undefined at runtime. */
const known = new Set([...FROM_PACK, ...FROM_BAND, ...ABSENT]);
const unclassified = [...new Set(Object.values(reqs).flat())].filter((f) => !known.has(f));
check('every fact a law reads is classified', unclassified.length === 0,
  unclassified.length ? 'UNCLASSIFIED: ' + unclassified.join(', ') +
    ' — these would be handed undefined and drawn anyway'
    : [...known].length + ' facts classified across ' + Object.keys(reqs).length + ' laws');

/* 3. A law needing an absent fact is REFUSED, and names what it wants. */
const refused = tier(REFUSED);
const unnamed = refused.filter((c) => !c.missing.length);
check('every refused law names the fact it lacks', refused.length > 0 && unnamed.length === 0,
  refused.map((c) => c.id + ' needs ' + c.missing.join(', ')).join(' · ') || 'nothing refused');

/* 4. No refused law is silently runnable. This is the assertion that stops twenty
      variations being twenty plausible lies. */
const leaked = refused.filter((c) => classify(c.needs).tier !== REFUSED);
check('no refused law can be run', leaked.length === 0,
  leaked.length ? 'LEAK: ' + leaked.map((c) => c.id).join(', ') :
    refused.length + ' refused and unrunnable: ' + refused.map((c) => c.id).join(', '));

/* 5. The honest count, stated rather than rounded up to ten. */
const honest = tier(READY).length + tier(ON_BAND).length;
check('the honest law count is stated',
  MUTATE ? honest === ALL.length : honest === 8 && ALL.length === 11,
  honest + ' honest of ' + ALL.length + ' — ready: ' + tier(READY).map((c) => c.id).join(', ') +
  ' · on-band: ' + tier(ON_BAND).map((c) => c.id).join(', '));

/* 6. An ON_BAND law is correct only where a band has loaded, so the page must not
      present it as covering the whole estate. Recorded here so the claim is explicit
      rather than something a reader has to infer from the tier name. */
check('on-band laws are marked as partial, not whole-estate',
  tier(ON_BAND).every((c) => c.banded.length > 0),
  tier(ON_BAND).map((c) => c.id + ' via ' + c.banded.join('+')).join(' · '));

/* 7. Every law is a pure function of what it reads: same entity, same point. */
const e = { key: 4242, chars: 60, inFamily: 1, family: 7, fanout: 3, ageDays: 10, famCount: 5, cat: 1, catCount: 4 };
const impure = ALL.filter((l) => {
  const a = l.place(e), b = l.place(e);
  return !(Number.isFinite(a[0]) && a[0] === b[0] && a[1] === b[1]);
});
check('every law is a pure function of its entity', impure.length === 0,
  impure.length ? 'impure or non-finite: ' + impure.map((l) => l.id).join(', ')
    : ALL.length + ' laws give the same point twice for the same entity');

let failed = 0;
for (const r of results) {
  if (!r.ok) failed++;
  console.log((r.ok ? 'PASS  ' : 'FAIL  ') + r.n + '\n        ' + r.d);
}
console.log('\n' + (results.length - failed) + '/' + results.length + ' passed' +
  (MUTATE ? '   (--mutate: check 5 must fail — it asserts ten honest laws where there are eight)' : ''));
process.exit(MUTATE ? 0 : failed ? 1 : 0);