GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Maps, GIS and field navigation / gridatlas / tools/proofs

Quantumspawn Recovery Proof and 4 more files

A JavaScript module in the proofs folder of GridAtlas that reads shift log. It is built from the check step (`check`) and the git step (`git`).

607 lines of JavaScript from gridatlas, in 5 files. Topic: Maps, GIS and field navigation. Section 647 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. All Versions Proof interaction · gridatlas / tools/proofs/202609012150-all-versions.proof.mjs lines 388–462
  2. Data Contract Parity Proof ingest · gridatlas / tools/proofs/202609012214-data-contract-parity.proof.mjs lines 1–145
  3. Estate Deep Scan Proof ingest · gridatlas / tools/proofs/202609012240-estate-deep-scan.proof.mjs lines 1–40
  4. Quantumspawn Recovery Proof ingest · gridatlas / tools/proofs/202609012305-quantumspawn-recovery.proof.mjs lines 1–174
  5. Transit Layer Availability Proof render · gridatlas / tools/proofs/202609040212-transit-layer-availability.proof.mjs lines 1–173

All Versions Proof

A JavaScript module in the proofs folder of GridAtlas that reads composition, solar and 750kV, using haversine.

interactiongridatlas / tools/proofs/202609012150-all-versions.proof.mjs · lines 388–462 of 462 · version 2026-09-01 21:50 (continued from section 646) · Not reached from any entry point (candidate for review) · pattern sandbox (shared by 2 files)

What it does
It loads composition, solar and 750kV. Defines 8 functions or classes, including check, sandbox, makeElement, MutationObserverStub, cartridgeContext. Uses libraries node:fs/promises, node:path, node:url, node:vm. Side effects: changes the web page (DOM); reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'gridatlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: solar, 750kV, 415kV, 415V.
Inputs & outputs
In: JSON file current.json; JSON file -composition.json. Coordinate systems named: WGS84 / EPSG:4326. Voltage levels named: 750kV, 415kV, 415V.
Downstream impact
Used directly by 2 files: Local CI (gridatlas); Shift (gridatlas).
What it achieves
It makes element (`makeElement`) and is built from the check step (`check`) and the sandbox step (`sandbox`). Built vs all previous versions. Its code works with 750 kV and 415 kV.
Why it matters
Run by Local CI and Shift.
Application
gridatlas · tools/proofs · JavaScript module
Uses
GridAtlas — Atlas Page (estate URL), node:fs/promises, node:path, node:url, node:vm
Used by
run by Local CI (script call), run by Shift (script call)
Produces
check, sandbox, makeElement, MutationObserverStub, cartridgeContext, walk, withoutComments, currentSandboxFile
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/proofs/202609012150-all-versions.proof.mjs:388-462 · blob a265d35d514411da535cdc862803bca25028cc72 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
       waving it through: the module must be right, and any version that
       differs must differ by having been wrong in that specific way. */
    const IMPOSSIBLE = [['33000;750', 0.75], ['33000;11000;415', 0.415]];
    for (const [voltage, correctKv] of IMPOSSIBLE) {
      const theirs = measure.voltagesKv({ voltage });
      const mine = geodesy.voltagesKv({ voltage });
      const moduleIsRight = mine.includes(correctKv)
        && !mine.some(kv => kv > 400);
      const theyAgree = JSON.stringify(theirs) === JSON.stringify(mine);
      const theirsIsTheKnownBug = theirs.some(kv => kv === correctKv * 1000);
      check(`${surface.file} (${surface.version}): "${voltage}" is `
        + (theyAgree ? 'read correctly' : 'the pre-v9.32 impossible-voltage bug'),
        moduleIsRight && (theyAgree || theirsIsTheKnownBug),
        `${JSON.stringify(theirs)} vs ${JSON.stringify(mine)}`);
    }
  }
  compared += 1;
}

check('every version that measures was actually compared',
  compared === SURFACES.length, `${compared} of ${SURFACES.length}`);

/* ─────────────────────────────────────────────────────────────────────────
   3. THE HISTORY THE PAGE SHOWS IS THE HISTORY ON DISK
   ───────────────────────────────────────────────────────────────────────── */

console.log('\nthe versions the page lists are the versions that shipped\n');

const current = JSON.parse(await readFile(join(ATLAS, 'current.json'), 'utf8'));
const composedSandbox = current.cartridges.find(c => c.id === 'sld-sandbox');
const shipped = await readFile(
  join(ATLAS, 'cartridges', composedSandbox.path.replace('./cartridges/', '')), 'utf8');
const ledger = JSON.parse(shipped.match(/const VERSION_LEDGER = (\[[\s\S]*?\]);/)[1]);

/* Strictly increasing, except after the one stamp recorded as typed ahead
   of the clock (v9.67, 202609012250, cut at 18:51 UTC). The sandbox proof
   holds the same record; an unrecorded step backwards is a typed stamp. */
const TYPED_AHEAD = new Set(['202609012250']);
check('the ledger is not empty and is strictly increasing, except after the one stamp typed ahead',
  ledger.length > 25 && ledger.every((e, i) => i === 0 || e.g > ledger[i - 1].g
    || TYPED_AHEAD.has(ledger[i - 1].g)));
check('the versions in the ledger are strictly increasing without exception',
  ledger.every((e, i) => i === 0 || Number(e.v.slice(3)) > Number(ledger[i - 1].v.slice(3))));
check('its newest entry is the composition actually being served',
  ledger[ledger.length - 1].g === current.generation
  && ledger[ledger.length - 1].v === current.composition_version);

const compositions = (await readdir(join(ATLAS, 'manifests')))
  .filter(f => f.endsWith('-composition.json'))
  .map(f => f.slice(0, 12));
const claimed = new Set(ledger.map(e => e.g));
/* Only from the ledger's own first entry onward. The ledger begins at
   v9.16; four composition manifests predate it, and the cartridge already
   counts that era as PRE_SCOPE_COMPOSITIONS. Demanding they appear would
   be demanding the ledger claim a history it never had. */
const ledgerBegins = ledger[0].g;
const undeclared = compositions.filter(g => g >= ledgerBegins && !claimed.has(g));
check('every composition manifest from the ledger era onward appears in it',
  undeclared.length === 0, undeclared.join(', '));

/* A version in the ledger with no manifest is NOT a failure: the estate
   keeps only the compositions it still needs, and the ledger is the
   longer memory. It is reported so the difference stays visible. */
const withoutManifest = ledger.filter(e => !compositions.includes(e.g));
console.log(`         ${ledger.length} versions listed, ${compositions.length} composition `
  + `manifests retained, ${withoutManifest.length} versions older than the retained set`);

console.log(`\n${passed}/${passed + failures.length} checks passed`);
if (failures.length) {
  console.error('\nFAILURES');
  for (const failure of failures) console.error('  ' + failure);
  process.exit(1);
}
console.log('every version this estate has shipped measures the same Earth, '
  + 'and the history the page shows is the history on disk.');

Data Contract Parity Proof

A JavaScript module in the proofs folder of GridAtlas that reads connection points from the data-grid-GB repository. It reads JSON (`readJson`) and joins literals (`joinLiterals`).

ingestgridatlas / tools/proofs/202609012214-data-contract-parity.proof.mjs · lines 1–145 of 145 · version 2026-09-01 22:14 · pattern readJson (shared by 43 files)

What it does
It loads connection points. Defines 7 functions or classes, including read, readJson, check, joinLiterals, productsNamedBy. Uses libraries node:fs, node:path, node:url. Side effects: reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'gridatlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
In: data source: data-grid-gb data; JSON file connection-points.v3.json; JSON file current.json.
Downstream impact
Used directly by 3 files: Local CI (gridatlas); Shift (gridatlas); GridAtlas — Release (gridatlas). Reached from 27 other entry points, including GridAtlas Cartridge Proof Workflow (gridatlas); GridAtlas PR File Size Guard Workflow (gridatlas); GridAtlas Verify Live Workflow (gridatlas).
What it achieves
Data-contract parity: what a cartridge's bytes fetch is what its manifest entry declares, product for product and schema for schema. It reads `atlas/current.json`.
Why it matters
Run by Local CI, Shift and GridAtlas — Release.
Application
gridatlas · tools/proofs · JavaScript module
Uses
node:fs, node:path, node:url
Used by
run by Local CI (script call), run by Shift (script call), run by GridAtlas — Release (script call)
Produces
read, readJson, check, joinLiterals, productsNamedBy, schemaFromModule, declaredBy
Defines here
read, readJson, check, joinLiterals, productsNamedBy, schemaFromModule, declaredBy
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/proofs/202609012214-data-contract-parity.proof.mjs:1-145 · blob dd442e3732bfde16aaee8891cd69597b3dc41ee4 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
/**
 * Data-contract parity: what a cartridge's bytes fetch is what its manifest
 * entry declares, product for product and schema for schema.
 *
 * Why this proof exists. From v9.63 to v9.69 the substation-intelligence
 * entry in atlas/current.json (and therefore every derived composition
 * manifest) declared derived/connection-points.v2.json with schema v2,
 * while the cartridge's own source required connection-points.v3 from
 * v9.65 onward, and the same entry listed both "v2-consumed" and
 * "v3-consumed" as capabilities. Codex held the release on it at
 * 202609011820 and again at 202609012205; the hold was right. A manifest
 * that names a superseded product is a provenance lie, and the immutable
 * manifests inherit it generation after generation until a gate stops it.
 *
 * What it checks, for every cartridge in current.json:
 *   - every Ventusltd product URL the cartridge's bytes name
 *     (https://raw.githubusercontent.com/Ventusltd/<repo>/main/<path>,
 *     string concatenations resolved) is declared on the entry, under
 *     data_source or data_sources, with the same repository and product;
 *   - the schema the bytes require for that product (the constant assigned
 *     next to the URL, or the module's ACCEPTS for the topology product)
 *     equals the entry's schema_required;
 *   - every declared source is actually named by the bytes (a declaration
 *     nothing fetches is as false as a fetch nothing declares);
 *   - no capability names a product version the entry does not declare;
 *   - the composition manifest of the current generation carries the same
 *     entries (it is derived, and this proves the derivation held).
 *
 * Fail closed: an entry with an undeclared fetch, or a declared source the
 * bytes do not name, is a FAIL, not a warning.
 *
 *   node tools/proofs/202609012214-data-contract-parity.proof.mjs
 */

import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
const ATLAS = path.join(ROOT, 'atlas');
const read = (rel) => fs.readFileSync(path.join(ROOT, rel), 'utf8');
const readJson = (rel) => JSON.parse(read(rel));

let passed = 0, failed = 0;
const failures = [];
function check(name, ok, detail) {
  if (ok) { passed++; console.log(`  PASS ${name}`); }
  else { failed++; failures.push(name + (detail ? ` - ${detail}` : '')); console.log(`  FAIL ${name}${detail ? ' - ' + detail : ''}`); }
}

/* ── what the bytes name ──────────────────────────────────────────────
   String literals joined by + across line breaks are resolved first, so
   'https://raw.githubusercontent.com/Ventusltd/data-grid-gb/'
     + 'main/derived/connection-points.v3.json'
   reads as one URL. */
const joinLiterals = (source) => source.replace(/'\s*\n\s*\+\s*'/g, '').replace(/"\s*\n\s*\+\s*"/g, '');
const PRODUCT_URL = /https:\/\/raw\.githubusercontent\.com\/Ventusltd\/([A-Za-z0-9._-]+)\/main\/([A-Za-z0-9._/-]+)/g;

function productsNamedBy(source) {
  const joined = joinLiterals(source);
  const found = new Map();
  for (const m of joined.matchAll(PRODUCT_URL)) {
    const key = `${m[1]}:${m[2]}`;
    if (found.has(key)) continue;
    /* the schema constant is the nearest one AFTER the URL within 600
       characters, in one of the spellings the estate uses */
    const after = joined.slice(m.index, m.index + 600);
    const schema = after.match(/(?:REQUIRED_SCHEMA|GB_SCHEMA|ACCEPTS|SCHEMA)\s*=\s*'([^']+)'/);
    found.set(key, { repository: `Ventusltd/${m[1]}`, product: m[2], schema_in_bytes: schema ? schema[1] : null });
  }
  return found;
}

/* the topology product's schema lives in the network-topology module's
   ACCEPTS, not next to the URL in the body; resolve it from the bytes of
   the same cartridge (the module is composed into it) */
function schemaFromModule(source, product) {
  if (!/gb-transmission-network/.test(product)) return null;
  const m = source.match(/const ACCEPTS = '([^']+)'/);
  return m ? m[1] : null;
}

/* ── what the manifest declares ─────────────────────────────────────── */
function declaredBy(entry) {
  const list = [];
  if (entry.data_source) list.push(entry.data_source);
  for (const s of entry.data_sources || []) list.push(s);
  return list;
}

const current = readJson('atlas/current.json');
console.log(`\ndata-contract parity for ${current.composition_id} (${current.cartridges.length} cartridges)\n`);

for (const entry of current.cartridges) {
  const rel = path.join('atlas', entry.path.replace('./', ''));
  const source = read(rel);
  /* every cartridge this composition serves, for the sibling lookup */
  const compositionSource = (current.cartridges || [])
    .map(c => read(path.join('atlas', String(c.path).replace('./', ''))))
    .join('\n');
  const named = productsNamedBy(source);
  const declared = declaredBy(entry);
  console.log(`${entry.id} ${entry.generation}: bytes name ${named.size} product(s), entry declares ${declared.length}`);

  for (const [, p] of named) {
    const d = declared.find(s => s.repository === p.repository && s.product === p.product);
    check(`${entry.id}: ${p.product} fetched by the bytes is declared on the entry`, !!d,
      d ? undefined : `declared: ${declared.map(s => s.product).join(', ') || 'nothing'}`);
    if (!d) continue;
    /* The schema may be declared by a module in a sibling cartridge:
       since 202609012350 the network modules live in the cartridge
       the shell loads first, while the fetch stayed in the sandbox.
       Both ship in the same composition and load together, so the
       composition is where the requirement is looked for. */
    const schema = p.schema_in_bytes
      || schemaFromModule(source, p.product)
      || schemaFromModule(compositionSource, p.product);
    check(`${entry.id}: ${p.product} schema in the bytes is the schema the entry requires`,
      !!schema && schema === d.schema_required, `bytes ${schema}, entry ${d.schema_required}`);
  }
  for (const d of declared) {
    const key = `${d.repository.replace('Ventusltd/', '')}:${d.product}`;
    check(`${entry.id}: declared source ${d.product} is named by the bytes`, named.has(key));
  }
  /* a capability that says "<product>-vN-consumed" must agree with a
     declared schema of that version */
  for (const cap of entry.capabilities || []) {
    const m = cap.match(/^(?:neso-etys-)?connection-points-v(\d+)-consumed$/);
    if (!m) continue;
    check(`${entry.id}: capability ${cap} agrees with a declared schema`,
      declared.some(s => s.schema_required && s.schema_required.endsWith(`.v${m[1]}`)));
  }
}

/* ── the derived manifest carries the same declarations ─────────────── */
const manifest = readJson(`atlas/manifests/${current.generation}-composition.json`);
check('the composition manifest is the current generation', manifest.generation === current.generation);
for (const entry of current.cartridges) {
  const twin = (manifest.cartridges || []).find(c => c.id === entry.id);
  check(`${entry.id}: the composition manifest declares the same sources as current.json`,
    !!twin && JSON.stringify(declaredBy(twin)) === JSON.stringify(declaredBy(entry)));
}

console.log(`\n${passed}/${passed + failed} checks passed`);
if (failed) { console.log('FAILURES'); for (const f of failures) console.log('  ' + f); process.exit(1); }

Estate Deep Scan Proof

A JavaScript module in the proofs folder of GridAtlas.

ingestgridatlas / tools/proofs/202609012240-estate-deep-scan.proof.mjs · lines 1–40 of 40 · version 2026-09-01 22:40 · Not reached from any entry point (candidate for review)

What it does
It loads data. Defines check. Uses libraries node:assert/strict, node:child_process, node:fs, node:path, node:os. Side effects: reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'gridatlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
In: JSON file 202609012240-estate-deep-scan.json.
What it achieves
Defines `check`.
Why it matters
No other file in the estate was found to import it.
Application
gridatlas · tools/proofs · JavaScript module
Uses
CI Estate Deep Scan (script call), node:assert/strict, node:child_process, node:fs, node:path, node:os, node:url
Used by
none found
Produces
check
Defines here
check
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/proofs/202609012240-estate-deep-scan.proof.mjs:1-40 · blob 559827933b40d24816aff09f6c49b02e24dc12b7 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
import { tmpdir } from 'node:os';
import { fileURLToPath } from 'node:url';

const root = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..');
const scanner = join(root, 'tools/ci/202609012240-estate-deep-scan.mjs');
const out = mkdtempSync(join(tmpdir(), 'gridatlas-estate-scan-'));
let passed = 0;
const check = (name, condition) => {
  assert.ok(condition, name);
  passed += 1;
  console.log(`PASS ${name}`);
};

const source = readFileSync(scanner, 'utf8');
check('scanner source contains no literal backspace bytes', !source.includes(String.fromCharCode(8)));
check('zero deep-link matches are an explicit failure', /proved-by-zero-diagnostic/.test(source));
check('Pipeline News producer scan is restricted to GridAtlas surfaces', /gridAtlasOnly: true/.test(source));
check('composition proofs derive from generation and cartridge id',
  /\$\{cartridge\.generation\}-\$\{cartridge\.id\}\.proof\.mjs/.test(source));

execFileSync(process.execPath, [scanner, '--out', out], { cwd: root, stdio: 'pipe' });
const report = JSON.parse(readFileSync(join(out, '202609012240-estate-deep-scan.json'), 'utf8'));
check('both application repositories were scanned',
  report.scope.includes('gridatlas') && report.scope.includes('pipelinenews'));
check('producer and consumer scans bound real variables',
  report.deep_link.producer_variables_bound > 0 && report.deep_link.consumer_variables_bound > 0);
check('the identity parameter is produced and consumed',
  report.deep_link.produced.includes('repd_ref') && report.deep_link.consumed.includes('repd_ref'));
check('every current cartridge exists', report.composition.cartridges.every(item => item.exists));
check('every current cartridge has its generation-matched proof',
  report.composition.cartridges.every(item => item.proof_exists));
check('the scan retains complete commit counts',
  report.repos.gridatlas.commits > 200 && report.repos.pipelinenews.commits > 300);

rmSync(out, { recursive: true, force: true });
console.log(`${passed}/${passed} checks passed`);

Quantumspawn Recovery Proof

A JavaScript module in the proofs folder of GridAtlas that reads shift log. It is built from the check step (`check`) and the git step (`git`).

ingestgridatlas / tools/proofs/202609012305-quantumspawn-recovery.proof.mjs · lines 1–174 of 174 · version 2026-09-01 23:05 · Not reached from any entry point (candidate for review)

What it does
It loads shift log. Defines check, git. Uses libraries node:fs, node:path, node:url, node:child_process. Side effects: reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'gridatlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
In: JSON file current.json; JSON file shift-log.json.
What it achieves
QuantumSpawn recovery: the capsule is checked against current Git.
Why it matters
No other file in the estate was found to import it.
Application
gridatlas · tools/proofs · JavaScript module
Uses
node:fs, node:path, node:url, node:child_process
Used by
none found
Produces
check, git
Defines here
check, git
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/proofs/202609012305-quantumspawn-recovery.proof.mjs:1-174 · blob 4700d1096f8e8773728790034dacdefff6a3d7a5 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/**
 * QuantumSpawn recovery: the capsule is checked against current Git.
 *
 * Codex's vaccine (cvaa `quantumspawn-recovery`, 202609012359) requires
 * that a repository running an unattended version loop owns BOTH a
 * timestamped recovery capsule AND an independent executable proof that
 * detects drift from current repository state. This is that proof.
 *
 * The failure it exists to prevent is specific and it has already happened
 * in this estate in another form: a document that describes the system
 * accurately on the day it is written, is never checked again, and is read
 * six generations later as if it were still true. A recovery capsule that
 * has gone stale is worse than none, because a replacement executor trusts
 * it and rebuilds the wrong thing.
 *
 * So every factual claim the capsule makes about files, gates and live
 * state is re-derived here from the repository itself. Prose is not
 * checked; claims are.
 *
 *   node tools/proofs/202609012305-quantumspawn-recovery.proof.mjs
 */
import { readFileSync, existsSync, readdirSync } from 'node:fs';
import { join, dirname, resolve, basename } from 'node:path';
import { fileURLToPath } from 'node:url';
import { spawnSync } from 'node:child_process';

const HERE = dirname(fileURLToPath(import.meta.url));
const ROOT = resolve(HERE, '..', '..');

let passed = 0;
const failures = [];
function check(name, condition, detail = '') {
  if (condition) { passed += 1; console.log(`  [PASS] ${name}`); }
  else { failures.push(`${name}${detail ? ' - ' + detail : ''}`); console.log(`  [FAIL] ${name}${detail ? ' - ' + detail : ''}`); }
}
const git = (...args) => spawnSync('git', args, { cwd: ROOT, encoding: 'utf8' }).stdout?.trim() || '';

console.log('\nthe capsule exists and is the newest one\n');

const GOV = join(ROOT, 'governance');
const capsules = existsSync(GOV)
  ? readdirSync(GOV).filter(f => /^\d{12}-quantumspawn-recovery\.md$/.test(f)).sort()
  : [];
check('a timestamped recovery capsule exists', capsules.length > 0);
if (!capsules.length) {
  console.log(`\n${passed}/${passed + failures.length} checks passed`);
  console.log('FAILURES'); for (const f of failures) console.log(`  ${f}`);
  process.exit(1);
}
const capsuleName = capsules[capsules.length - 1];
const capsule = readFileSync(join(GOV, capsuleName), 'utf8');
const stamp = capsuleName.slice(0, 12);
console.log(`  (reading ${capsuleName})`);

/* This proof must itself be findable by the antibody, which looks for
   tools/proofs/<12 digits>-quantumspawn-recovery.proof.mjs. */
check('this proof is named so the antibody can find it',
  /^\d{12}-quantumspawn-recovery\.proof\.mjs$/.test(basename(fileURLToPath(import.meta.url))));

console.log('\nthe unattended loop the capsule describes is really there\n');

const LOOP = 'tools/overnight';
check('the loop directory exists', existsSync(join(ROOT, LOOP)));
const runners = readdirSync(join(ROOT, LOOP)).filter(f => /^\d{12}-shift\.mjs$/.test(f));
check('exactly one runner is present', runners.length === 1, runners.join(','));
check('the capsule names the runner that is actually on disk',
  runners.every(r => capsule.includes(r)), runners.join(','));

const STEPS = join(ROOT, LOOP, 'steps');
const steps = existsSync(STEPS) ? readdirSync(STEPS).filter(f => f.endsWith('.mjs')) : [];
check('the loop has at least one step to run', steps.length > 0, `${steps.length}`);

console.log('\nevery gate the capsule names is a file that exists\n');

/* Pulled out of the capsule text rather than hard-coded here: the point is
   to catch the capsule naming a gate that has been renamed or deleted. */
const named = [...new Set(capsule.match(/tools\/(?:proofs|ci)\/[\w.\-]+\.mjs/g) || [])];
check('the capsule names some gates at all', named.length >= 4, `${named.length}`);
for (const rel of named) {
  const generic = rel.replace('<generation>', '');
  if (rel.includes('<generation>')) {
    const suffix = generic.split('/').pop();
    const found = readdirSync(join(ROOT, 'tools', 'proofs')).some(f => f.endsWith(suffix));
    check(`a gate matching ${rel} exists`, found);
  } else {
    check(`${rel} exists`, existsSync(join(ROOT, rel)));
  }
}

console.log('\nthe capsule tells the truth about what is shipped\n');

const current = JSON.parse(readFileSync(join(ROOT, 'atlas', 'current.json'), 'utf8'));
check('the capsule names the generation that current.json points at',
  capsule.includes(current.generation), current.generation);

const sld = (current.cartridges || []).find(c => c.id === 'sld-sandbox');
check('the capsule names the version that is pointed at',
  !sld || capsule.includes(sld.version), sld ? sld.version : 'no sld-sandbox');

/* The count in the capsule must match the log, and the log's only
   creditable outcome is `live`. This is the check that stops a recovering
   executor from inheriting an inflated tally. */
const LOG = join(ROOT, LOOP, 'shift-log.json');
check('the shift log exists', existsSync(LOG));
if (existsSync(LOG)) {
  const runs = JSON.parse(readFileSync(LOG, 'utf8')).runs || [];
  const live = runs.filter(r => r.outcome === 'live');
  const liveGenerations = [...new Set(live.map(r => r.generation).filter(Boolean))];
  check('the log records at least one live cut', live.length > 0);
  check('every generation the log calls live is named in the capsule',
    liveGenerations.every(g => capsule.includes(g)),
    liveGenerations.filter(g => !capsule.includes(g)).join(','));
  check('the capsule does not claim a generation the log never marked live', (() => {
    const claimed = [...new Set(capsule.match(/\b2026\d{8}\b/g) || [])]
      .filter(g => /^20260[89]/.test(g));
    const known = new Set([...liveGenerations, current.generation, current.previous_generation, stamp]);
    /* generations named in prose as history are fine; what must not happen
       is the capsule naming one as LIVE that the log never marked live */
    const asLive = [...new Set((capsule.match(/`(2026\d{8})`[^\n]{0,40}(?:live|is live)/gi) || [])
      .map(m => (m.match(/2026\d{8}/) || [])[0]))];
    return asLive.every(g => known.has(g));
  })());
  check('the capsule distinguishes attended cuts from unattended ones',
    /attended/i.test(capsule));
  const attended = runs.filter(r => r.attended === true);
  check('an attended run in the log is described as attended in the capsule',
    attended.length === 0 || /attended/i.test(capsule), `${attended.length} attended`);
}

console.log('\nthe standards that stop a release are all carried\n');

/* If one of these disappears from the capsule, a recovering executor loses
   the rule and re-ships the mistake it was written for. */
for (const [label, pattern] of [
  ['never grade a grid position', /never grade|no STRONG|never graded/i],
  ['a straight line is not a route', /not a cable route|straight line is not/i],
  ['never mix voltages', /never mix voltages/i],
  ['never decode voltage from a node code', /decode a voltage from a node code|never decode/i],
  ['R/X/B carried never computed with', /carried, never computed with/i],
  ['ratings are never summed', /never summed|not summed/i],
  ['a rating is not headroom', /not headroom|no field expressing spare/i],
  ['a skip is not a pass', /skip is not a pass/i],
  ['fail closed on an unknown schema', /fail closed/i],
  ['never amend a shipped generation', /never amend/i],
  ['stamps are read from the clock', /read from `?date -u`?|read from the clock/i],
]) {
  check(`the capsule carries: ${label}`, pattern.test(capsule));
}

console.log('\nit is a witness, not an authority\n');

check('the capsule says current Git wins over itself',
  /witness, never authority|in favour of current evidence/i.test(capsule));
check('the wake sequence is read-only before it changes anything',
  /read-only first/i.test(capsule) && /Change nothing until/i.test(capsule));
check('it points at the coordination board',
  /BOARD\.md/.test(capsule));
check('it records what is NOT yet done rather than only what is',
  /not yet built|still open|not to be claimed/i.test(capsule));

console.log('\nthe capsule is committed, not just sitting in the tree\n');

const tracked = git('ls-files', `governance/${capsuleName}`);
check('the capsule is tracked by git', tracked.length > 0,
  tracked ? '' : 'untracked - a recovery capsule that is not committed does not survive');

console.log(`\n${passed}/${passed + failures.length} checks passed`);
if (failures.length) {
  console.log('FAILURES');
  for (const f of failures) console.log(`  ${f}`);
  process.exit(1);
}
console.log('the capsule matches the repository it claims to describe, and says');
console.log('plainly that current Git outranks it.');

Transit Layer Availability Proof

A JavaScript module in the proofs folder of GridAtlas that fetches UK metros trams root, using SHA-256 from the data-GridAtlas repository. It is built from the public bytes helper (`publicBytes`).

rendergridatlas / tools/proofs/202609040212-transit-layer-availability.proof.mjs · lines 1–173 of 173 · version 2026-09-04 02:12 · Not reached from any entry point (candidate for review)

What it does
It fetches UK metros trams root. Defines sha256, publicBytes. Uses libraries node:assert/strict, node:crypto, node:fs/promises, node:path, node:url. Side effects: changes the web page (DOM); reads or writes files; makes network requests; uses storage (browser storage, DuckDB or Parquet).
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'gridatlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
In: data source: data-gridatlas data; Parquet file uk_metros_trams_root.parquet; JSON file release.json; JSON file browser-layer-registry.json.
What it achieves
Defines `sha256` and `publicBytes`.
Why it matters
No other file in the estate was found to import it.
Application
gridatlas · tools/proofs · JavaScript module
Uses
node:assert/strict, node:crypto, node:fs/promises, node:path, node:url, node:vm
Used by
none found
Produces
sha256, publicBytes
Defines here
sha256, publicBytes
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/proofs/202609040212-transit-layer-availability.proof.mjs:1-173 · blob 9699acb82c955be419055a47e38f75a29b1d42ab · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom, filesystem, network, storage · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
import { readFile } from 'node:fs/promises';
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import vm from 'node:vm';

const HERE = dirname(fileURLToPath(import.meta.url));
const REPO = resolve(HERE, '..', '..');
const OLD_PART = 'atlas/parts/202609040045-ventus-corev8engine-deep-link-receiver.js';
const NEW_PART = 'atlas/parts/202609040212-ventus-corev8engine-layer-availability.js';
const OWNER_GENERATION = '202608291237-data-gridatlas';
const OWNER_COMMIT = '32459230b958ff6ddbdb24365f56da83ab1cdc93';
const OWNER_BASE = `https://ventusltd.github.io/data-gridatlas/${OWNER_GENERATION}`;
const PARTITION_PATH = 'data/partitions/uk_metros_trams_root.parquet';
const PARTITION_BYTES = 1_411_687;
const PARTITION_SHA256 = '49d46beb139b22afdd4e64bdbcf550f53b6a1bd09910d27e7174e5d1761c4c7a';
const RELEASE_BYTES = 18_333;
const RELEASE_SHA256 = '19684ac3e86fac4346fab121a948bab0aa857108564fec5be242484d2baefd06';
const REGISTRY_BYTES = 64_993;
const REGISTRY_SHA256 = '9b2169bcfd47bf51f0aaf8350487de19578e32358e191b961385a149a4637e1b';
const OLD_PART_BYTES = 92_388;
const OLD_PART_SHA256 = 'b1da9baca77c7ddc1b45ce3396c60d1da17e38fdf4faa0a5fc70ea1639a92dfc';

const sha256 = (bytes) => createHash('sha256').update(bytes).digest('hex');

async function publicBytes(path) {
  const response = await fetch(`${OWNER_BASE}/${path}`, { cache: 'no-store' });
  assert.equal(response.status, 200, `${path} public response`);
  return Buffer.from(await response.arrayBuffer());
}

const oldPartBytes = await readFile(join(REPO, OLD_PART));
const newPartSource = await readFile(join(REPO, NEW_PART), 'utf8');
assert.equal(oldPartBytes.length, OLD_PART_BYTES, 'historical receiver byte count is immutable');
assert.equal(sha256(oldPartBytes), OLD_PART_SHA256, 'historical receiver hash is immutable');
assert.match(newPartSource, /updateTransitSourceStates\(TRANSIT_SOURCE_MAP\[layerId\], features\)/,
  'successfully fetched transit bytes are classified before the UI reports success');
assert.doesNotMatch(newPartSource,
  /TRANSIT_IDS\.forEach\(tid => \{ if \(TRANSIT_SOURCE_MAP\[tid\].+updateUIState\(tid, 'OK'\)/,
  'the shared-source fast path no longer calls every sibling OK');

const releaseBytes = await publicBytes('release.json');
assert.equal(releaseBytes.length, RELEASE_BYTES, 'public owner release byte count');
assert.equal(sha256(releaseBytes), RELEASE_SHA256, 'public owner release is the audited immutable release');
const ownerRelease = JSON.parse(releaseBytes.toString('utf8'));
const partitionEntry = ownerRelease.files.find((entry) => entry.path === PARTITION_PATH);
assert.deepEqual(
  { bytes: partitionEntry?.bytes, sha256: partitionEntry?.sha256 },
  { bytes: PARTITION_BYTES, sha256: PARTITION_SHA256 },
  'owner release binds the deployed metro/tram partition'
);
const registryEntry = ownerRelease.files.find((entry) => entry.path === 'browser-layer-registry.json');
assert.deepEqual(
  { bytes: registryEntry?.bytes, sha256: registryEntry?.sha256 },
  { bytes: REGISTRY_BYTES, sha256: REGISTRY_SHA256 },
  'owner release binds the browser layer registry'
);

const [partitionBytes, registryBytes] = await Promise.all([
  publicBytes(PARTITION_PATH),
  publicBytes('browser-layer-registry.json')
]);
assert.equal(partitionBytes.length, PARTITION_BYTES, 'deployed partition byte count');
assert.equal(sha256(partitionBytes), PARTITION_SHA256, 'deployed partition exact hash');
assert.equal(registryBytes.length, REGISTRY_BYTES, 'deployed registry byte count');
assert.equal(sha256(registryBytes), REGISTRY_SHA256, 'deployed registry exact hash');

const registry = JSON.parse(registryBytes.toString('utf8'));
assert.equal(registry.generation, OWNER_GENERATION, 'registry generation');
assert.equal(registry.classification, 'LIVE_IMMUTABLE_DATA_RELEASE', 'registry is the live immutable owner release');
const ownerLayers = registry.groups.flatMap((group) => group.layers);
for (const id of ['dlr', 'metro', 'tram']) {
  const layer = ownerLayers.find((entry) => entry.id === id);
  assert.ok(layer, `${id} is present in the owner registry`);
  assert.equal(layer.type, 'point', `${id} is configured as a point layer`);
  assert.equal(layer.v9_data.parquet_path, 'partitions/uk_metros_trams_root.parquet', `${id} uses the audited partition`);
  assert.equal(layer.v9_data.disposition, 'QUARANTINED_GEOMETRY_MISMATCH', `${id} remains quarantined`);
  assert.equal(layer.v9_data.candidate_enabled, false, `${id} is not enabled as a v9 data candidate`);
  assert.equal(layer.v9_data.candidate_publishable, false, `${id} is not published as a v9 data candidate`);
}

const start = newPartSource.indexOf('    function transitExpressionValue(');
const end = newPartSource.indexOf('    async function hydrateLayer(', start);
assert.ok(start >= 0 && end > start, 'availability implementation has extractable boundaries');
const subjectSource = newPartSource.slice(start, end);

const layerConfigs = new Map([
  ['dlr', { filter: ['all', ['in', 'Docklands', ['get', 'operator']], ['!', ['in', 'London Underground', ['get', 'operator']]]] }],
  ['metro', { filter: ['any', ['in', 'Tyne', ['get', 'operator']], ['in', 'Metrolink', ['get', 'operator']]] }],
  ['tram', { filter: ['all', ['==', ['get', 'type'], 'Tram / Light Rail'], ['!', ['in', 'London Underground', ['get', 'operator']]]] }]
]);
const mapTypes = { dlr: 'circle', metro: 'circle', tram: 'circle' };
const controls = Object.fromEntries(['dlr', 'metro', 'tram'].map((id) => [id,
  [{ checked: true, disabled: false }, { checked: true, disabled: false }]]));
const layoutWrites = [];
const uiWrites = [];
const box = {
  console,
  Map,
  Array,
  Object,
  String,
  TRANSIT_IDS: ['dlr', 'metro', 'tram'],
  TRANSIT_SOURCE_MAP: { dlr: 'src-metros', metro: 'src-metros', tram: 'src-metros' },
  RUNTIME_STATE: Object.fromEntries(['dlr', 'metro', 'tram'].map((id) => [id,
    { loaded: false, loading: true, status: 'LOAD' }])),
  getLayerConfig: (id) => layerConfigs.get(id),
  map: {
    getLayer: (id) => mapTypes[id.replace(/^l-/, '')] ? { type: mapTypes[id.replace(/^l-/, '')] } : null,
    setLayoutProperty: (id, property, value) => layoutWrites.push({ id, property, value })
  },
  document: {
    querySelectorAll: (selector) => controls[selector.match(/data-layer-id="([^"]+)"/)?.[1]] || []
  },
  updateUIState: (id, state) => {
    box.RUNTIME_STATE[id].status = state;
    uiWrites.push({ id, state });
  },
  _visibleInteractiveIds: ['l-dlr', 'l-metro', 'l-tram'],
  _visibleHoverIds: ['l-dlr', 'l-metro', 'l-tram']
};
vm.createContext(box);
vm.runInContext(`${subjectSource}\nthis.subject = { transitFilterMatches, geometryFitsMapLayer, countTransitFeaturesLayerCanDraw, updateTransitSourceStates };`,
  box, { filename: NEW_PART });

const retainedProjectionFixture = [
  { geometry: { type: 'LineString', coordinates: [[-0.1, 51.5], [-0.08, 51.51]] }, properties: { operator: 'Docklands Light Railway' } },
  { geometry: { type: 'LineString', coordinates: [[-2.2, 53.4], [-2.1, 53.5]] }, properties: { operator: 'Manchester Metrolink' } },
  { geometry: { type: 'LineString', coordinates: [[-1.5, 53.3], [-1.4, 53.4]] }, properties: { type: 'route' } }
];
assert.equal(retainedProjectionFixture.some((feature) => 'railway' in feature.properties), false,
  'fixture reflects the deployed projection: railway is not retained');
box.subject.updateTransitSourceStates('src-metros', retainedProjectionFixture);

for (const id of ['dlr', 'metro', 'tram']) {
  assert.deepEqual(
    { loaded: box.RUNTIME_STATE[id].loaded, loading: box.RUNTIME_STATE[id].loading, status: box.RUNTIME_STATE[id].status },
    { loaded: true, loading: false, status: 'EMPTY' },
    `${id} reports EMPTY when its circle layer cannot draw the retained LineStrings`
  );
  assert.equal(controls[id].every((control) => !control.checked && control.disabled), true,
    `${id} controls are unchecked and disabled`);
  assert.ok(layoutWrites.some((write) => write.id === `l-${id}` && write.property === 'visibility' && write.value === 'none'),
    `${id} is hidden after the empty verdict`);
}
assert.deepEqual(box._visibleInteractiveIds, [], 'unavailable transit layers leave the click cache');
assert.deepEqual(box._visibleHoverIds, [], 'unavailable transit layers leave the hover cache');
assert.equal(uiWrites.every((write) => write.state === 'EMPTY'), true, 'no quarantined layer is called OK');

const pointDlr = { geometry: { type: 'Point', coordinates: [-0.1, 51.5] }, properties: { operator: 'Docklands Light Railway' } };
assert.equal(box.subject.countTransitFeaturesLayerCanDraw('dlr', [pointDlr]), 1,
  'a compatible feature matching the configured filter remains available');
assert.equal(box.subject.countTransitFeaturesLayerCanDraw('metro', [pointDlr]), 0,
  'the filter still separates a compatible DLR feature from Metro');
assert.equal(box.subject.geometryFitsMapLayer('line', 'LineString'), true, 'line/LineString compatibility');
assert.equal(box.subject.geometryFitsMapLayer('circle', 'LineString'), false, 'circle/LineString incompatibility');
assert.equal(box.subject.transitFilterMatches(['future-expression'], pointDlr), true,
  'unknown future expressions cannot be used as evidence to disable a layer');

console.log(JSON.stringify({
  status: 'PASS',
  owner_commit: OWNER_COMMIT,
  owner_generation: OWNER_GENERATION,
  deployed_partition: {
    url: `${OWNER_BASE}/${PARTITION_PATH}`,
    bytes: partitionBytes.length,
    sha256: sha256(partitionBytes)
  },
  owner_disposition: 'QUARANTINED_GEOMETRY_MISMATCH',
  runtime_verdict: Object.fromEntries(['dlr', 'metro', 'tram'].map((id) => [id, box.RUNTIME_STATE[id].status])),
  historical_part_preserved: { path: OLD_PART, bytes: oldPartBytes.length, sha256: sha256(oldPartBytes) }
}, null, 2));