GLOBALGRID2050 / EXPLORE CODE

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

Rating Envelope Proof and 1 more file

A JavaScript module in the proofs folder of GridAtlas that reads GB transmission network, 400kV and overhead lines (OHL).

405 lines of JavaScript from gridatlas, in 2 files. Topic: Maps, GIS and field navigation. Section 659 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. Source Registry Proof render · gridatlas / tools/proofs/modules/202609012245-source-registry.proof.mjs lines 1–147
  2. Rating Envelope Proof electrical · gridatlas / tools/proofs/modules/202609012250-rating-envelope.proof.mjs lines 1–258

Source Registry Proof

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

rendergridatlas / tools/proofs/modules/202609012245-source-registry.proof.mjs · lines 1–147 of 147 · version 2026-09-01 22:45 · Not reached from any entry point (candidate for review) · pattern state (shared by 17 files)

What it does
It loads substations. Defines check, state. 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: substations.
Downstream impact
Used directly by 1 file: Local CI (gridatlas).
What it achieves
The registry's whole value is that it tells the truth about ABSENCE, so most of these checks build a window with a source deliberately missing, half-loaded or broken, and assert that the answer says so.
Why it matters
Run by Local CI.
Application
gridatlas · tools/proofs/modules · JavaScript module
Uses
node:fs/promises, node:path, node:url, node:vm
Used by
run by Local CI (script call)
Produces
check, state
Defines here
check, state
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/modules/202609012245-source-registry.proof.mjs:1-147 · blob a722d362f56ba32b7341cdd85da7738fd5a1f068 · 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
/**
 * Proof for the source-registry module.
 *
 * The registry's whole value is that it tells the truth about ABSENCE, so
 * most of these checks build a window with a source deliberately missing,
 * half-loaded or broken, and assert that the answer says so. A registry that
 * only works when everything is present would be worth nothing: everything
 * present is the case nobody needs help with.
 *
 *   node tools/proofs/modules/202609012245-source-registry.proof.mjs
 */

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, '..', '..', '..');

let passed = 0;
const failures = [];
function check(label, condition, detail) {
  if (condition) { passed += 1; console.log('  [PASS] ' + label); }
  else {
    failures.push(label + (detail ? ` — ${detail}` : ''));
    console.log('  [FAIL] ' + label + (detail ? ` — ${detail}` : ''));
  }
}

const box = { window: {}, console, Math, JSON, Number, String, Array, Object,
  Map, Set, Boolean, Error, RegExp };
box.window.window = box.window;
vm.createContext(box);
const source = await readFile(
  join(REPO, 'atlas', 'modules', '202609012245-source-registry.js'), 'utf8');
vm.runInContext(source, box, { filename: 'source-registry.js' });
const registry = box.window.__GRIDATLAS_MODULES__.sourceRegistry;

console.log('\nit declares what it knows about\n');
check('the module loaded and froze its surface',
  !!registry && Object.isFrozen(registry));
check('it declares six sources by name',
  registry.declared.length === 6
  && registry.declared.includes('neso-connection-points')
  && registry.declared.includes('mapped-substations')
  && registry.declared.includes('network-topology'));
check('the declared list is in the module, not scanned off window', (() => {
  /* Enumerating window would report whatever happens to be there and would
     start consuming a new global the day someone added one. */
  const scanned = /for\s*\(\s*const\s+\w+\s+(of|in)\s+Object\.keys\(\s*w(indow)?\s*\)/;
  return !scanned.test(source) && /const SOURCES = \[/.test(source);
})());

console.log('\nan empty page: everything is missing, and it says which\n');
const empty = registry.survey({});
check('nothing is reported ready', empty.counts.ready === 0);
check('every declared source is reported missing',
  empty.counts.missing === empty.counts.declared);
check('the sentence names what did not answer',
  /Not answering/.test(empty.sentence)
  && /neso-connection-points/.test(empty.sentence));
check('and refuses to let an absence read as an absence in the world',
  /missing from this answer, not/.test(empty.sentence)
  && /absent from the world/.test(empty.sentence));

console.log('\nloaded is not the same as useful\n');
/* The state that actually occurs on a phone: the cartridge has evaluated,
   its global exists, and its payload has not arrived. A probe that tested
   only for the global would call this ready and answer with nothing. */
const halfway = registry.survey({
  __GRIDATLAS_NEON_LINKS__: { measure: { distanceKm: () => 0 }, substations_loaded: 0 },
  __GRIDATLAS_NETWORK__: { loaded: false },
  __GRIDATLAS_MODULES__: {}
});
const state = (survey, id) => survey.sources.find(s => s.id === id).state;
check('a link cartridge with no substations yet is not ready',
  state(halfway, 'mapped-substations') === 'loaded, no substations yet');
check('a network cartridge still fetching is reported as loading',
  state(halfway, 'neso-connection-points') === 'loading');
check('neither counts towards ready', halfway.counts.ready === 0);

console.log('\na failure is distinguished from an absence\n');
const broken = registry.survey({
  __GRIDATLAS_NETWORK__: { loaded: false, failed: true },
  __GRIDATLAS_NEON_LINKS__: { substations_loaded: 5800 }
});
check('a failed fetch says failed, not absent',
  state(broken, 'neso-connection-points') === 'failed to load');
check('a link cartridge that cannot measure says so, not "ready"',
  state(broken, 'mapped-substations') === 'loaded, cannot measure');
check('a probe that throws is caught and reported, not fatal', (() => {
  const hostile = registry.survey({
    get __GRIDATLAS_NETWORK__() { throw new Error('hostile getter'); }
  });
  return /probe threw/.test(state(hostile, 'neso-connection-points'));
})());

console.log('\na fully loaded page\n');
const full = registry.survey({
  __GRIDATLAS_V9_MAP__: {},
  __GRIDATLAS_NEON_LINKS__: { measure: { distanceKm: () => 0 }, substations_loaded: 5800 },
  __GRIDATLAS_NETWORK__: { loaded: true, count: 886, schema: 'data-grid-gb.connection-points.v3' },
  __GRIDATLAS_MODULES__: { gridScope: {}, networkTopology: {} },
  __GRIDATLAS_SLD__: { declared: {} }
});
check('all six answer', full.counts.ready === 6 && full.counts.missing === 0);
check('the sentence says so plainly', /All 6 sources answered/.test(full.sentence));
check('a ready source carries its detail',
  full.sources.find(s => s.id === 'neso-connection-points').detail.connection_points === 886);
check('a source that is not ready carries no detail',
  empty.sources.every(s => s.detail === null));

console.log('\nthe single-source question\n');
const FULL_WINDOW = {
  __GRIDATLAS_V9_MAP__: {},
  __GRIDATLAS_NEON_LINKS__: { measure: { distanceKm: () => 0 }, substations_loaded: 5800 },
  __GRIDATLAS_NETWORK__: { loaded: true, count: 886, schema: 'data-grid-gb.connection-points.v3' },
  __GRIDATLAS_MODULES__: { gridScope: {}, networkTopology: {} },
  __GRIDATLAS_SLD__: { declared: {} }
};
check('ready() agrees with the survey on every declared source',
  registry.declared.every(id =>
    registry.ready(id, FULL_WINDOW)
    === full.sources.find(s => s.id === id).ready));
check('ready() is false where the survey reports loading, not just absent',
  registry.ready('neso-connection-points',
    { __GRIDATLAS_NETWORK__: { loaded: false } }) === false);
check('ready() is false for a source that is absent',
  registry.ready('neso-connection-points', {}) === false);
check('ready() is false for a name it does not know',
  registry.ready('not-a-source', {}) === false);

console.log('\nit reads and nothing else\n');
check('it never fetches', !/\bfetch\s*\(/.test(source));
check('it never renders', !/document\.|innerHTML|appendChild/.test(source));
check('it never grades what it finds',
  !/\b(good|poor|strong|weak|sufficient|adequate)\b/i.test(source));

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('the registry says what answered, what did not, and why - '
  + 'and never lets a gap in the page read as a gap in the world.');

Rating Envelope Proof

A JavaScript module in the proofs folder of GridAtlas that reads GB transmission network, 400kV and overhead lines (OHL).

electricalgridatlas / tools/proofs/modules/202609012250-rating-envelope.proof.mjs · lines 1–258 of 258 · version 2026-09-01 22:50 · Not reached from any entry point (candidate for review) · pattern fakeIndex (shared by 2 files)

What it does
It loads GB transmission network, 400kV and overhead lines (OHL). Defines check, banned, fakeIndex, N. Uses libraries node:fs, node:path, node:url. 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: 400kV, overhead lines (OHL), 132kV.
Inputs & outputs
In: JSON file gb-transmission-network.v1.json. Voltage levels named: 400kV, 132kV.
Downstream impact
Used directly by 1 file: Local CI (gridatlas).
What it achieves
It is built from the check step (`check`), the banned step (`banned`) and the fake index helper (`fakeIndex`). The load-bearing check in this file is a NEGATIVE one: that no code path anywhere in the module produces a sum of circuit ratings. Its code works with 400 kV, 9999 MVA and 130 MVA.
Why it matters
Run by Local CI.
Application
gridatlas · tools/proofs/modules · JavaScript module
Uses
node:fs, node:path, node:url
Used by
run by Local CI (script call)
Produces
check, banned, fakeIndex, N
Defines here
check, banned, fakeIndex, N
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/modules/202609012250-rating-envelope.proof.mjs:1-258 · blob ade155d8cd7e0b5dcb5cfb70bc711f4650549c36 · 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
/**
 * Proof for the rating-envelope module.
 *
 * The load-bearing check in this file is a NEGATIVE one: that no code
 * path anywhere in the module produces a sum of circuit ratings. Every
 * other check could pass while the module quietly printed a site total,
 * and that total is the exact number a reader would take as headroom.
 *
 * Run against the real published payload. A skip is not a pass: if the
 * sibling data-grid-gb checkout is absent this FAILS.
 *
 *   node tools/proofs/modules/202609012250-rating-envelope.proof.mjs
 */
import { readFileSync, existsSync } from 'node:fs';
import { join, dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

const HERE = dirname(fileURLToPath(import.meta.url));
const ROOT = resolve(HERE, '..', '..', '..');
const PRODUCT = resolve(ROOT, '..', 'data-grid-gb', 'derived', 'gb-transmission-network.v1.json');

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 TOPOLOGY = 'atlas/modules/202609012245-network-topology.js';
const ENVELOPE = 'atlas/modules/202609012250-rating-envelope.js';

const window = { __GRIDATLAS_MODULES__: {} };
for (const rel of [TOPOLOGY, ENVELOPE]) {
  const path = join(ROOT, rel);
  if (!existsSync(path)) { console.error(`missing module: ${rel}`); process.exit(1); }
  new Function('window', readFileSync(path, 'utf8'))(window);
}
const NS = window.__GRIDATLAS_MODULES__;
const topology = NS.networkTopology;
const envelope = NS.ratingEnvelope;

console.log('\nthe refusal to sum, asserted structurally\n');

const source = readFileSync(join(ROOT, ENVELOPE), 'utf8');
const codeOnly = source.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/[^\n]*/g, '');

check('the module registered', !!envelope);
/* The whole point. A reduce over ratings, a `+=` accumulating them, or a
   field whose name contains total/sum - any of the three would be the
   number that must not exist. */
check('no reduce anywhere in the module', !/\.reduce\(/.test(codeOnly));
/* The denial constant is literally called NEVER_SUMMED and the field that
   carries it is `never_summed`, so a check that bans the substring "sum"
   fires on the very thing that makes the refusal legible. The words are
   permitted only where they are prefixed by `never`. */
/* Naming a sum is banned; naming a SEASON is not. "summer_mva" contains
   the letters s-u-m and is the most important field in this module, so
   the test is on WORDS and on camelCase humps, never on substrings:
   `\bsum\b` does not fire inside "summer", and `[a-z]Sum` catches
   `siteSum` where a word boundary cannot. The check is self-tested below
   against both a name that must fail and one that must pass, because a
   pattern this fiddly is exactly the kind that silently matches nothing
   and reports success forever. */
const banned = (text) =>
  /(?:^|[^A-Za-z])(total|totals|sum|sums|aggregate|combined|cumulative)(?![A-Za-z])/i.test(text)
  || /[a-z](Total|Sum|Aggregate|Combined)(?![a-z])/.test(text);

/* The two denial constants must SAY "sum" in order to deny it, so they
   are removed before the scan - the same distinction as everywhere else
   in this estate: a denial is not a claim. */
const withoutDenials = codeOnly
  .split(/const (?:NEVER_SUMMED|NOT_A_CAPACITY)\s*=[\s\S]*?;/).join(' ');
check('the denials were actually found and removed, not silently absent',
  withoutDenials.length < codeOnly.length - 200);
check('nothing in the module outside the denials names a total or a sum',
  !banned(withoutDenials));
check('the denial does say "sum", which is why it had to be excluded',
  /(?:^|[^A-Za-z])sum(?![A-Za-z])/i.test(codeOnly));
check('the pattern fires on a real total', banned('const siteTotal = 0;'));
check('the pattern fires on a snake-case total', banned('const site_total = 0;'));
check('the pattern does NOT fire on the season it must not break', !banned('summer_mva'));
check('the pattern does NOT fire on the denial that must stay legible', !banned('never_summed'));
check('no accumulator assigns into anything named like a total',
  !/\b\w*(total|aggregate)\w*\s*\+?=/i.test(codeOnly));
check('no arithmetic operator is applied to a rating value',
  !/ratings_mva\[[^\]]+\]\s*[+\-*/]/.test(codeOnly)
  && !/_mva\s*[+*]/.test(codeOnly));
check('no mean or average is computed',
  !/\/\s*values\.length|\baverage\b|\bmean\b/i.test(codeOnly));
check('the only reductions over values are Math.min and Math.max, which are published values',
  /Math\.min\.apply/.test(codeOnly) && /Math\.max\.apply/.test(codeOnly));
check('the refusal is stated in words the page can print',
  /not additive/.test(envelope.never_summed) && /no code that produces one/.test(envelope.never_summed));
check('a rating is distinguished from what is free on it',
  /not what is free on it/.test(envelope.not_a_capacity));
check('it never fetches and never renders',
  !/\b(fetch|document|innerHTML)\b/.test(codeOnly));

console.log('\nbehaviour, on circuits built for the edge cases\n');

function fakeIndex(nodes, edges, sites) {
  const byNode = new Map();
  for (const e of edges) {
    for (const [near, far] of [['node_1', 'node_2'], ['node_2', 'node_1']]) {
      const n = e.row[near];
      if (!byNode.has(n)) byNode.set(n, []);
      byNode.get(n).push({ kind: e.kind, row: e.row, near, far });
    }
  }
  return {
    site: (key) => sites.find(s => s.code === String(key).toUpperCase()) || null,
    graph: () => ({
      schema: 'gridatlas.module.network-topology.graph.v1',
      has: (n) => nodes.some(x => x.node === n),
      nodeVoltageKv: (n) => {
        const node = nodes.find(x => x.node === n);
        if (!node || node.voltage_consistent_with_site !== true) return null;
        return Number.isFinite(node.voltage_kv) ? node.voltage_kv : null;
      },
      nodeSiteCode: (n) => (nodes.find(x => x.node === n) || {}).site_code || null,
      edgesAt: (n) => (byNode.get(n) || []).filter(e => e.kind !== 'planned_change'),
      nodesOfSite: (c) => nodes.filter(x => x.site_code === c).map(x => x.node).sort(),
      siteByCode: (c) => sites.find(s => s.code === c) || null,
      ratingsOf: () => null,
      parametersOf: (row) => (Number.isFinite(row.x_pct_100mva) ? { x_pct: row.x_pct_100mva } : null)
    })
  };
}
const N = (node, site_code, voltage_kv, ok = true) =>
  ({ node, site_code, voltage_kv, voltage_consistent_with_site: ok });

/* Two circuits, all four seasons published. */
{
  const idx = fakeIndex(
    [N('AAA4-', 'AAA', 400), N('BBB4-', 'BBB', 400), N('CCC4-', 'CCC', 400)],
    [{ kind: 'circuit', row: { node_1: 'AAA4-', node_2: 'BBB4-', winter_mva: 3000, spring_mva: 2800, summer_mva: 2500, autumn_mva: 2800, circuit_type: 'OHL', ohl_km: 40, cable_km: 0 } },
     { kind: 'circuit', row: { node_1: 'AAA4-', node_2: 'CCC4-', winter_mva: 1800, spring_mva: 1700, summer_mva: 1500, autumn_mva: 1700, circuit_type: 'Cable', ohl_km: 0, cable_km: 12 } }],
    [{ code: 'AAA', name: 'ALPHA' }, { code: 'BBB', name: 'BETA' }, { code: 'CCC', name: 'GAMMA' }]);
  const r = envelope.at(idx, 'AAA', { voltageKv: 400 });
  check('both circuits are reported individually', r.circuits.length === 2);
  check('each circuit keeps its own four seasonal ratings',
    r.circuits[0].ratings_mva.summer === 2500 && r.circuits[1].ratings_mva.summer === 1500);
  check('the season range is a lowest and a highest, both real published values',
    r.by_season.summer.lowest_circuit_mva === 1500
    && r.by_season.summer.highest_circuit_mva === 2500);
  check('the answer contains no total of 4800 anywhere',
    !JSON.stringify(r).includes('4800'));
  check('summer is reported separately from winter, not folded into it',
    r.by_season.winter.highest_circuit_mva === 3000
    && r.by_season.summer.highest_circuit_mva === 2500);
  check('circuit type and length are carried as published',
    r.circuits[0].circuit_type === 'OHL' && r.circuits[1].cable_km === 12);
}

/* A circuit publishing only winter - the other seasons are named absent. */
{
  const idx = fakeIndex(
    [N('AAA4-', 'AAA', 400), N('BBB4-', 'BBB', 400)],
    [{ kind: 'circuit', row: { node_1: 'AAA4-', node_2: 'BBB4-', winter_mva: 900 } }],
    [{ code: 'AAA', name: 'ALPHA' }, { code: 'BBB', name: 'BETA' }]);
  const r = envelope.at(idx, 'AAA');
  check('a season the product does not publish is named absent, not filled in',
    r.circuits[0].seasons_not_published.join(',') === 'spring,summer,autumn');
  check('an unpublished season reports published:false rather than a number',
    r.by_season.summer.published === false && r.by_season.summer.circuits === 0);
  check('the count of circuits missing a season is surfaced',
    r.counts.with_a_season_not_published === 1);
}

/* The placeholder value. */
{
  const idx = fakeIndex(
    [N('AAA4-', 'AAA', 400), N('BBB4-', 'BBB', 400), N('CCC4-', 'CCC', 400)],
    [{ kind: 'circuit', row: { node_1: 'AAA4-', node_2: 'BBB4-', winter_mva: 9999, ohl_km: 0, cable_km: 1 } },
     { kind: 'circuit', row: { node_1: 'AAA4-', node_2: 'CCC4-', winter_mva: 2000 } }],
    [{ code: 'AAA', name: 'ALPHA' }, { code: 'BBB', name: 'BETA' }, { code: 'CCC', name: 'GAMMA' }]);
  const r = envelope.at(idx, 'AAA');
  check('a 9999 MVA rating is flagged, not silently used',
    r.counts.with_a_flagged_value === 1
    && /placeholder/.test(r.circuits.find(c => c.flags.length).flags[0].reason));
  check('the flagged value is excluded from the highest, which would otherwise be 9999',
    r.by_season.winter.highest_circuit_mva === 2000
    && r.by_season.winter.excluded_as_implausible === 1);
  check('the flagged value is still reported on its own circuit, not deleted',
    r.circuits.some(c => c.ratings_mva.winter === 9999));
}

/* Voltage scoping. */
{
  const idx = fakeIndex(
    [N('AAA4-', 'AAA', 400), N('AAA1-', 'AAA', 132), N('BBB4-', 'BBB', 400), N('CCC1-', 'CCC', 132)],
    [{ kind: 'circuit', row: { node_1: 'AAA4-', node_2: 'BBB4-', winter_mva: 3000 } },
     { kind: 'circuit', row: { node_1: 'AAA1-', node_2: 'CCC1-', winter_mva: 130 } }],
    [{ code: 'AAA', name: 'ALPHA' }, { code: 'BBB', name: 'BETA' }, { code: 'CCC', name: 'GAMMA' }]);
  const at400 = envelope.at(idx, 'AAA', { voltageKv: 400 });
  const all = envelope.at(idx, 'AAA');
  check('scoped to 400 kV, only the 400 kV circuit is reported',
    at400.circuits.length === 1 && at400.circuits[0].ratings_mva.winter === 3000);
  check('a 130 MVA 132 kV circuit never widens a 400 kV range',
    at400.by_season.winter.lowest_circuit_mva === 3000);
  check('unscoped, the answer says plainly that it spans voltages',
    all.circuits.length === 2 && /a number about neither of them/.test(all.scope));
}

/* ── the real payload ────────────────────────────────────────────────── */
console.log('\nthe published network\n');

if (!existsSync(PRODUCT)) {
  console.error(`\nFAILED: the published product is not at ${PRODUCT}.`);
  console.error('A skip is not a pass. Check out Ventusltd/data-grid-gb beside this repository.');
  process.exit(1);
}

const product = JSON.parse(readFileSync(PRODUCT, 'utf8'));
const index = topology.index(product);
check('the topology module accepts the published schema', !!index);

const wb = envelope.at(index, 'WBUR', { voltageKv: 400 });
check('West Burton reports circuits at 400 kV', !!wb && wb.circuits.length > 0);
check('every reported circuit carries at least a winter rating',
  wb.circuits.every(c => Number.isFinite(c.ratings_mva.winter)));
check('no circuit at 400 kV carries a rating from another voltage',
  wb.circuits.every(c => c.voltage_kv === 400));
check('the answer carries no summed figure',
  !/total|sum_/i.test(JSON.stringify(wb).replace(/never_summed":"[^"]*"/, '')));

/* The placeholder finding, verified against the whole product rather than
   asserted from the survey. */
const implausible = (product.circuits || [])
  .filter(c => Number.isFinite(c.winter_mva) && c.winter_mva >= 9999);
check(`the product does publish circuits at or above 9999 MVA (${implausible.length} found)`,
  implausible.length > 0, `${implausible.length}`);
check('every one of them is on a short span, which is why they read as placeholders',
  implausible.every(c => (c.ohl_km || 0) + (c.cable_km || 0) <= 5),
  implausible.map(c => `${c.node_1}-${c.node_2}:${(c.ohl_km || 0) + (c.cable_km || 0)}km`).join(' '));

/* Summer is not winter, and the difference is the point of carrying it. */
let differing = 0;
let bothPublished = 0;
for (const c of product.circuits || []) {
  if (!Number.isFinite(c.winter_mva) || !Number.isFinite(c.summer_mva)) continue;
  bothPublished += 1;
  if (c.summer_mva !== c.winter_mva) differing += 1;
}
check(`summer and winter ratings differ on real circuits (${differing} of ${bothPublished})`,
  differing > 0, `${differing}/${bothPublished}`);
check('a majority of circuits publish a summer rating at all',
  bothPublished > (product.circuits || []).length / 2,
  `${bothPublished} of ${(product.circuits || []).length}`);

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('every rating is reported on its own circuit, in its own season, and');
console.log('there is no code path in the module that adds two of them together.');