GLOBALGRID2050 / EXPLORE CODE

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

Data Contract Parity and 2 more files

A JavaScript module in the steps folder of GridAtlas that draws connection points, GB transmission network, price decade rollup and substations. It is built from the once step (`once`).

593 lines of JavaScript from gridatlas, in 3 files. Topic: Maps, GIS and field navigation. Section 642 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. Data Contract Parity render · gridatlas / tools/overnight/steps/202609012217-data-contract-parity.mjs lines 1–264
  2. Electrical Distance geodesy · gridatlas / tools/overnight/steps/202609012245-electrical-distance.mjs lines 1–172
  3. Rating Envelope electrical · gridatlas / tools/overnight/steps/202609012250-rating-envelope.mjs lines 1–157

Data Contract Parity

A JavaScript module in the steps folder of GridAtlas that draws connection points, GB transmission network, price decade rollup and substations. It is built from the once step (`once`).

rendergridatlas / tools/overnight/steps/202609012217-data-contract-parity.mjs · lines 1–264 of 264 · version 2026-09-01 22:17 · Not reached from any entry point (candidate for review)

What it does
It draws connection points, GB transmission network, price decade rollup and substations. Defines once. Side effects: changes the web page (DOM).
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.
Inputs & outputs
In: JSON file current.json; JSON file connection-points.v3.json; JSON file gb-transmission-network.v1.json; JSON file price-decade-rollup.json; JSON file connection-points.v2.json.
What it achieves
The manifest tells the truth about what the bytes fetch.
Why it matters
No other file in the estate was found to import it.
Application
gridatlas · tools/overnight/steps · JavaScript module
Uses
none found
Used by
none found
Produces
once
Defines here
once
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/overnight/steps/202609012217-data-contract-parity.mjs:1-264 · blob 330bb622990a015d9e251500452d9c0025d30fe2 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/**
 * Step: the manifest tells the truth about what the bytes fetch.
 *
 * Codex held v9.65 at 202609011820 and v9.68 at 202609012205 on the same
 * finding, and the finding is right: atlas/current.json has declared
 * derived/connection-points.v2.json (schema v2) for the substation-
 * intelligence cartridge since v9.63, while the cartridge's own bytes have
 * required connection-points.v3 since v9.65, and the same entry listed both
 * "v2-consumed" and "v3-consumed". Every composition manifest since is
 * derived from that entry, so every one of them inherits the lie. And the
 * sld-sandbox entry declared nothing at all while its bytes fetch two
 * products (the transmission network, the price rollup).
 *
 * Nothing shipped is amended. This generation:
 *   - corrects the two entries in current.json, records why and since when;
 *   - brings a data-contract parity proof that reads every cartridge's
 *     bytes for the Ventusltd products it names and the schema it requires,
 *     and fails unless the entry declares exactly those - both directions;
 *   - succeeds the source-registry module so the registry itself states,
 *     for each fetching source, the product and schema it REQUIRES, in
 *     every state, not only the loaded one; and registers the GB price
 *     rollup, which the sandbox has fetched since v9.41 without a row;
 *   - gives the sandbox body a loader state for that rollup on the window
 *     (idle / loading / withheld / failed / ready), as the topology loader
 *     already has, and names the schema the topology loader requires
 *     before the fetch;
 *   - puts the parity proof and every module proof into local CI, and
 *     makes an absent CI gate a failure rather than a line in yellow.
 */

const BODY = 'atlas/parts/202609012045-sld-sandbox-body.js';
const OLD_REGISTRY = 'atlas/modules/202609012135-source-registry.js';
const NEW_REGISTRY = 'atlas/modules/202609012217-source-registry.js';
const REGISTRY_PROOF = 'tools/proofs/modules/202609012217-source-registry.proof.mjs';
const PARITY_PROOF = 'tools/proofs/202609012214-data-contract-parity.proof.mjs';
const CI = 'tools/ci/202609012200-local-ci.mjs';
const CURRENT = 'atlas/current.json';

export default {
  id: 'data-contract-parity',
  version: 'v9.70',
  scope: 'the composition manifest is proven against the bytes: substation-intelligence declares connection-points.v3 as it has required since v9.65 (the entry said v2 from v9.63 until this cut), sld-sandbox declares the transmission network and the price rollup it fetches, a data-contract parity proof holds every entry to its bytes in both directions, the source registry states what each fetching  … [line shortened here: 511 characters; full line on GitHub]
  note: 'the manifest is held to the bytes: connection-points v3 declared as consumed, every fetched product declared with its schema, and a parity gate so no generation inherits a false contract again',
  brings: [REGISTRY_PROOF, PARITY_PROOF],
  replaceModules: [`${OLD_REGISTRY}=${NEW_REGISTRY}`],
  proofs: [REGISTRY_PROOF],
  /* the parity proof reads the composition manifest, which exists for this
     generation only after recompose has cut it */
  postProofs: [PARITY_PROOF],
  apply({ read, write, patch, sandboxProof }) {
    /* ── 1. the source registry, succeeded ──────────────────────────── */
    let registry = read(OLD_REGISTRY);
    const once = (from, to) => {
      const n = registry.split(from).length - 1;
      if (n !== 1) throw new Error(`registry anchor found ${n} times: ${from.slice(0, 50)}`);
      registry = registry.replace(from, () => to);
    };
    once(` * Successor to 202609012245 at generation 202609012135: the network-topology probe
 * reads the loader state, not the module's existence, and the declared-
 * connections probe reads the module that now holds the table.
`, ` * Successor to 202609012135 at generation 202609012217: every source that
 * fetches a product declares what it REQUIRES (repository, product, schema)
 * and the survey carries that in every state, because a contract stated
 * only once the load has succeeded is no help to the reader of a failure.
 * The GB price rollup, fetched since v9.41 without a row here, is
 * registered with the loader state the sandbox now publishes.
`);
    once(`      id: 'neso-connection-points',
      surface: '__GRIDATLAS_NETWORK__',
`, `      id: 'neso-connection-points',
      surface: '__GRIDATLAS_NETWORK__',
      requires: { repository: 'Ventusltd/data-grid-gb',
        product: 'derived/connection-points.v3.json',
        schema: 'data-grid-gb.connection-points.v3' },
`);
    once(`      id: 'network-topology',
      surface: '__GRIDATLAS_MODULES__.networkTopology + __GRIDATLAS_TOPOLOGY__',
`, `      id: 'network-topology',
      surface: '__GRIDATLAS_MODULES__.networkTopology + __GRIDATLAS_TOPOLOGY__',
      requires: { repository: 'Ventusltd/data-grid-gb',
        product: 'derived/gb-transmission-network.v1.json',
        schema: 'data-grid-gb.transmission-network.v1' },
`);
    once(`      probe: (w) => (w.__GRIDATLAS_MODULES__?.declaredConnections?.count > 0 ? 'ready' : 'absent'),
      detail: (w) => ({ records: w.__GRIDATLAS_MODULES__?.declaredConnections?.count || null })
    }
  ];
`, `      probe: (w) => (w.__GRIDATLAS_MODULES__?.declaredConnections?.count > 0 ? 'ready' : 'absent'),
      detail: (w) => ({ records: w.__GRIDATLAS_MODULES__?.declaredConnections?.count || null })
    },
    {
      id: 'gb-electricity-conditions',
      surface: '__GRIDATLAS_GB_CONDITIONS__',
      contributes: 'the GB wholesale price context a project card carries: '
        + 'negative-price days and the record daily mean, from the owner rollup',
      requires: { repository: 'Ventusltd/data-gb-electricity',
        product: 'derived/price-decade-rollup.json',
        schema: 'data-gb-electricity.price-decade-rollup.v2' },
      /* Withheld is its own state: the product was reached and was not the
         schema this consumer answers, so the panel shows nothing and says
         why. That is neither a failure of the network nor a source ready. */
      probe: (w) => {
        const loader = w.__GRIDATLAS_GB_CONDITIONS__;
        if (!loader) return 'absent';
        if (loader.state === 'ready') return 'ready';
        if (loader.state === 'loading') return 'loading';
        if (loader.state === 'failed') return 'failed to load';
        if (loader.state === 'withheld') return 'withheld: ' + String(loader.reason || 'schema not supported');
        return 'idle, loads on first use';
      },
      detail: (w) => ({ schema: w.__GRIDATLAS_GB_CONDITIONS__?.schema || null,
        renders: w.__GRIDATLAS_GB_CONDITIONS__?.renders || 0 })
    }
  ];
`);
    once(`      return { id: source.id, surface: source.surface,
        contributes: source.contributes, state, ready: state === READY, detail };
`, `      return { id: source.id, surface: source.surface,
        contributes: source.contributes, requires: source.requires || null,
        state, ready: state === READY, detail };
`);
    write(NEW_REGISTRY, registry);

    /* ── 2. the body: loader states on the window ───────────────────── */
    patch(BODY, [
      [`  const topology = { state: 'idle', product: TOPOLOGY_PRODUCT, schema: null,
    bytes: null, sites: null, index: null, error: null,
    started_at: null, ready_at: null, blocks_filled: 0 };
`, `  const topology = { state: 'idle', product: TOPOLOGY_PRODUCT, schema: null,
    schema_required: topologyModule()?.accepts || null,
    bytes: null, sites: null, index: null, error: null,
    started_at: null, ready_at: null, blocks_filled: 0 };
`, 'topology loader names the schema it requires before the fetch'],
      [`  const GB_SCHEMA = 'data-gb-electricity.price-decade-rollup.v2';
`, `  const GB_SCHEMA = 'data-gb-electricity.price-decade-rollup.v2';
  /* Loader state on the window, as the topology loader's is, so the source
     registry can say whether this product answered, was withheld (reached,
     not the schema this consumer answers) or failed - generation 202609012217. */
  const gbLoader = { state: 'idle', product: GB_ROLLUP, schema_required: GB_SCHEMA,
    schema: null, reason: null, error: null, renders: 0 };
  window.__GRIDATLAS_GB_CONDITIONS__ = gbLoader;
`, 'GB conditions loader state'],
      [`  async function renderGbConditions(body) {
    let product = null;
    try {
`, `  async function renderGbConditions(body) {
    let product = null;
    gbLoader.state = 'loading';
    try {
`, 'GB loader: loading'],
      [`    } catch (error) {
      product = null;
    }
    if (!product) {
      body.innerHTML = '<p class="gb-note">The price rollup could not be '
`, `    } catch (error) {
      product = null;
      gbLoader.error = String(error && error.message || error);
    }
    if (!product) {
      gbLoader.state = 'failed';
      body.innerHTML = '<p class="gb-note">The price rollup could not be '
`, 'GB loader: failed'],
      [`    const productError = gbProductError(product);
    if (productError) {
`, `    const productError = gbProductError(product);
    if (productError) {
      gbLoader.state = 'withheld';
      gbLoader.reason = productError;
      gbLoader.schema = product.schema || null;
`, 'GB loader: withheld'],
      [`    link.gb_conditions = {
      reached: true,
      schema_supported: true,
`, `    gbLoader.state = 'ready';
    gbLoader.schema = product.schema;
    gbLoader.renders += 1;
    link.gb_conditions = {
      reached: true,
      schema_supported: true,
`, 'GB loader: ready'],
    ]);

    /* ── 3. current.json: the entries say what the bytes fetch ──────── */
    const current = JSON.parse(read(CURRENT));
    const substation = current.cartridges.find(c => c.id === 'substation-intelligence');
    const sandbox = current.cartridges.find(c => c.id === 'sld-sandbox');
    if (!substation || !sandbox) throw new Error('current.json lacks the entries this step corrects');
    if (substation.data_source.product !== 'derived/connection-points.v2.json') {
      throw new Error('substation-intelligence no longer declares v2; this step is stale');
    }
    substation.data_source.product = 'derived/connection-points.v3.json';
    substation.data_source.schema_required = 'data-grid-gb.connection-points.v3';
    substation.data_source.corrected_at = {
      generation: '202609012217',
      finding: 'the entry declared connection-points.v2 from v9.63 (202609012045) to v9.69 while the cartridge bytes required v3 from v9.65; held by Codex at 202609011820 and 202609012205',
      proof: PARITY_PROOF
    };
    substation.capabilities = substation.capabilities.filter(c => c !== 'neso-etys-connection-points-v2-consumed');
    if (!substation.capabilities.includes('connection-points-v3-consumed')) substation.capabilities.push('connection-points-v3-consumed');
    sandbox.data_sources = [
      { repository: 'Ventusltd/data-grid-gb',
        product: 'derived/gb-transmission-network.v1.json',
        schema_required: 'data-grid-gb.transmission-network.v1',
        fetched: 'on the first click that asks, never at load; indexed by the network-topology module',
        upstream: 'NESO Electricity Ten Year Statement 2025, appendix B' },
      { repository: 'Ventusltd/data-gb-electricity',
        product: 'derived/price-decade-rollup.json',
        schema_required: 'data-gb-electricity.price-decade-rollup.v2',
        fetched: 'when a project card opens its GB conditions panel; revalidated with no-cache every open',
        upstream: 'Elexon settlement prices as the owner repository publishes them' }
    ];
    write(CURRENT, `${JSON.stringify(current, null, 1)}\n`);

    /* ── 4. local CI carries every proof, and an absent gate is red ─── */
    patch(CI, [
      [`  ['source registry', ['tools/proofs/modules/202609012135-source-registry.proof.mjs']],
  ['map-click network', ['tools/proofs/modules/202609012230-map-click-network.proof.mjs']],
  ['declared connections', ['tools/proofs/modules/202609012130-declared-connections.proof.mjs']]
];`, `  ['source registry', ['tools/proofs/modules/202609012217-source-registry.proof.mjs']],
  ['map-click network', ['tools/proofs/modules/202609012230-map-click-network.proof.mjs']],
  ['declared connections', ['tools/proofs/modules/202609012130-declared-connections.proof.mjs']],
  ['sizing arithmetic', ['tools/proofs/modules/202609012205-sizing-arithmetic.proof.mjs']],
  ['data-contract parity', ['tools/proofs/202609012214-data-contract-parity.proof.mjs']]
];`, 'CI gate list'],
      [`  if (!existsSync(join(GRIDATLAS, args[0]))) {
    console.log(\`  \\x1b[33m\${name.padEnd(22)} absent\\x1b[0m  \${args[0]}\`);
    continue;
  }`, `  if (!existsSync(join(GRIDATLAS, args[0]))) {
    /* an absent gate was a yellow line and a continue until 202609012217;
       a skip is not a pass, so it is red and counted */
    console.log(\`  \\x1b[31m\${name.padEnd(22)} ABSENT\\x1b[0m  \${args[0]}\`);
    flaws.push(\`gate absent: \${name} (\${args[0]})\`);
    report.gates[name] = { ok: false, summary: 'absent' };
    continue;
  }`, 'absent gate is red'],
    ]);

    /* ── 5. the sandbox proof: one fetchable URL, declarations welcome ─
       The check counted every occurrence of the product NAME and required
       exactly one. Its intent was that the URL is defined in a single
       place, so a second definition cannot drift from the first. The
       source registry now DECLARES the same product as a requirement,
       which is the whole point of it - a reader can see what a source
       needs without reading the fetch. That is a second mention and not a
       second definition, and the check as written would have forced the
       registry to describe its requirement vaguely to stay green.

       So it is made precise rather than loosened: exactly one occurrence
       is part of a fetchable URL (`main/derived/...`), and the registry's
       declared product must equal the one the body fetches. That is a
       STRONGER guarantee than counting - it catches a registry that
       declares a product the cartridge does not actually read, which the
       old check could not see at all. */
    patch(sandboxProof, [
      [`  const urls = cartridgeSource.match(/gb-transmission-network\\.v1\\.json/g) || [];
  return urls.length === 1`,
       `  const urls = cartridgeSource.match(/main\\/derived\\/gb-transmission-network\\.v1\\.json/g) || [];
  const declared = cartridgeSource.match(/product: 'derived\\/gb-transmission-network\\.v1\\.json'/g) || [];
  return urls.length === 1 && declared.length === 1`,
       'one fetchable URL, one registry declaration'],
    ]);
  }
};

Electrical Distance

A JavaScript module in the steps folder of GridAtlas that works with distance module (`distanceModule`) (units: kV), covering transformers.

geodesygridatlas / tools/overnight/steps/202609012245-electrical-distance.mjs · lines 1–172 of 172 · version 2026-09-01 22:45 · Not reached from any entry point (candidate for review) · pattern distanceModule (shared by 10 files)

What it does
Defines distanceModule, reach. Side effects: changes the web page (DOM).
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: transformers.
What it achieves
It is built from the distance module helper (`distanceModule`) and the reach step (`reach`). The map learns to measure in circuits, not only in kilometres.
Why it matters
No other file in the estate was found to import it.
Application
gridatlas · tools/overnight/steps · JavaScript module
Uses
none found
Used by
none found
Produces
distanceModule, reach
Defines here
distanceModule, reach
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/overnight/steps/202609012245-electrical-distance.mjs:1-172 · blob a6d349e7de3eb488a1324bac4a69fcff13916880 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/**
 * Step: the map learns to measure in circuits, not only in kilometres.
 *
 * Everything this Atlas has measured until now has been geometry. The
 * geodesy module answers "how many kilometres to that substation" and
 * answers it to the last place - but a kilometre is not a connection, and
 * a card that shows only the kilometre invites a reader to infer one.
 *
 * This step lands the other measurement, from the other source: on the
 * network NESO publishes in Appendix B, how many circuits lie between two
 * sites, and which ones. Every hop is a published row. A voltage changes
 * only across a named transformer, and a circuit whose two ends declare
 * different voltages is refused and reported rather than walked.
 *
 * Three artefacts:
 *   - 202609012245-network-topology.js, the incumbent's own bytes plus a
 *     graph() handle, proven to answer identically on all 921 sites;
 *   - 202609012245-electrical-distance.js, the traversal;
 *   - the card gains one sentence naming what is two hops away.
 *
 * The successor exists so there is ONE implementation of "which voltages
 * are real". A second copy of voltageOf inside the traversal would be a
 * second opinion, and this estate has already shipped one cartridge
 * carrying two geodesies that disagreed in the last place.
 */

const MODULES = 'atlas/modules';
const OLD_TOPOLOGY = `${MODULES}/202609012145-network-topology.js`;
const NEW_TOPOLOGY = `${MODULES}/202609012245-network-topology.js`;
const DISTANCE = `${MODULES}/202609012245-electrical-distance.js`;
const PROOF = 'tools/proofs/modules/202609012245-electrical-distance.proof.mjs';
const BODY = 'atlas/parts/202609012045-sld-sandbox-body.js';
const REGISTRY = `${MODULES}/202609012217-source-registry.js`;
const CI = 'tools/ci/202609012200-local-ci.mjs';

export default {
  id: 'electrical-distance',
  version: 'v9.71',
  scope: 'the Atlas measures in the operator\'s own circuits as well as in kilometres: an electrical-distance module traverses the published node/branch model, a voltage changes only across a named transformer and a circuit that appears to change voltage is refused and recorded, planned changes are never walked as if they existed today, every hop carries its published rating and its R/X/B untouche  … [line shortened here: 447 characters; full line on GitHub]
  note: 'a hop is a published circuit, not a distance and not a capacity; the topology module hands out its graph so there is one implementation of which voltages are real, proven identical to the incumbent on all 921 published sites',

  brings: [NEW_TOPOLOGY, DISTANCE, PROOF],
  replaceModules: [`${OLD_TOPOLOGY}=${NEW_TOPOLOGY}`],
  addModules: [DISTANCE],
  proofs: [PROOF],

  apply({ read, write, patch, sandboxProof }) {
    /* ── 1. the body reaches the new module and publishes its state ─── */
    patch(BODY, [
      [`    try { return window.__GRIDATLAS_MODULES__?.networkTopology || null; }`,
       `    try { return window.__GRIDATLAS_MODULES__?.networkTopology || null; }`,
       'topology accessor present'],
    ]);

    let body = read(BODY);

    const ACCESSOR_ANCHOR = `  function topologyBlockHtml(queries) {`;
    if (body.split(ACCESSOR_ANCHOR).length - 1 !== 1) {
      throw new Error('topologyBlockHtml anchor is not unique');
    }
    body = body.replace(ACCESSOR_ANCHOR, `  /* The electrical-distance module, read the same way the topology
     module is read: absent is absent, never an excuse to guess. */
  function distanceModule() {
    try { return window.__GRIDATLAS_MODULES__?.electricalDistance || null; }
    catch (_) { return null; }
  }

${ACCESSOR_ANCHOR}`);

    /* ── 2. one sentence: what is two hops away ──────────────────────── */
    const NEIGHBOUR_ANCHOR = `      if (facts.neighbours.length) {`;
    if (body.split(NEIGHBOUR_ANCHOR).length - 1 !== 1) {
      throw new Error('neighbours anchor is not unique');
    }
    body = body.replace(NEIGHBOUR_ANCHOR, `      /* Electrical distance, beside the one-hop view.
         ---------------------------------------------------------------
         "Circuits reach" above is one hop. This is the second, and it is
         reported as a COUNT of sites at each hop rather than as a claim
         about any of them: naming a site two hops away and nothing else
         would read as a recommendation, which no published appendix
         supports. The hop count is never called a distance. */
      const reach = (() => {
        const mod = distanceModule();
        if (!mod) return null;
        try { return mod.within(topology.index, point.site_code, { hops: 2, voltageKv: kv }); }
        catch (_) { return null; }
      })();
      if (reach && reach.sites.length) {
        const atOne = reach.counts.by_hop[1] || 0;
        const atTwo = reach.counts.by_hop[2] || 0;
        out += caveat(\`<b>On the published network:</b> \${atOne} site\${atOne === 1 ? '' : 's'} \`
          + \`one circuit away\${atTwo ? \`, \${atTwo} more at two\` : ''}. \`
          + \`A hop is a published circuit, not a distance - a site one hop away may be a \`
          + \`hundred kilometres away.\${reach.refusals.length
            ? \` \${reach.refusals.length} branch\${reach.refusals.length === 1 ? ' was' : 'es were'} \`
              + \`not walked because a circuit cannot change voltage; only a transformer can.\`
            : ''}\`);
        electrical.answered += 1;
        electrical.refusals += reach.refusals.length;
      }
${NEIGHBOUR_ANCHOR}`);

    /* ── 3. the state the source registry and the proofs can see ─────── */
    const STATE_ANCHOR = `  window.__GRIDATLAS_TOPOLOGY__ = topology;`;
    if (body.split(STATE_ANCHOR).length - 1 !== 1) {
      throw new Error('topology state anchor is not unique');
    }
    body = body.replace(STATE_ANCHOR, `${STATE_ANCHOR}

  /* Published so a reviewer can ask the page how many cards the traversal
     actually answered, and how many published branches it refused to walk.
     A refusal is a finding about the data, not a failure of the page. */
  const electrical = { answered: 0, refusals: 0 };
  window.__GRIDATLAS_ELECTRICAL__ = electrical;`);

    write(BODY, body);

    /* ── 4. the registry needs no change, and that is worth stating ───
       It probes `__GRIDATLAS_MODULES__.networkTopology` by GLOBAL name,
       not by file name, so the successor registers under exactly the same
       key and the registry keeps working without being restamped. What
       the registry does NOT yet know about is the traversal itself: it
       has no `electrical-distance` source, so a page where the module
       failed to load would report every source healthy. That is a real
       gap, it is recorded here rather than quietly left, and closing it
       means a successor registry - which is its own generation, not a
       silent edit to one that has shipped. */

    /* ── 5. the CI carries the new proof ─────────────────────────────── */
    patch(CI, [
      [`  ['data-contract parity', ['tools/proofs/202609012214-data-contract-parity.proof.mjs']]
];`,
       `  ['data-contract parity', ['tools/proofs/202609012214-data-contract-parity.proof.mjs']],
  ['electrical distance', ['tools/proofs/modules/202609012245-electrical-distance.proof.mjs']]
];`, 'CI gate list'],
    ]);

    /* ── 6. the sandbox proof holds the wiring ───────────────────────── */
    const proof = read(sandboxProof);
    const TAIL = `console.log(\`\\n\${passed}/\${passed + failures.length} checks passed\`);`;
    if (proof.split(TAIL).length - 1 !== 1) {
      throw new Error('sandbox proof tail anchor is not unique');
    }
    write(sandboxProof, proof.replace(TAIL, `console.log('\\nthe map measures in circuits as well as in kilometres\\n');

/* The module can be perfect and composed into nothing - that is exactly
   what happened to network-topology at 202609012145, proven 46/46 and
   present in no served cartridge for two generations. These checks are
   about the BYTES that ship. */
check('the electrical-distance module is in the served cartridge',
  /gridatlas\\.module\\.electrical-distance\\.v1/.test(cartridgeSource));
check('it is evaluated before the body that calls it',
  cartridgeSource.indexOf('gridatlas.module.electrical-distance.v1')
    < cartridgeSource.indexOf('function distanceModule('));
check('the successor topology module ships, not the incumbent',
  /gridatlas\\.module\\.network-topology\\.graph\\.v1/.test(cartridgeSource));
check('the card asks for two hops, scoped to the connection voltage',
  /mod\\.within\\(topology\\.index, point\\.site_code, \\{ hops: 2, voltageKv: kv \\}\\)/.test(cartridgeSource));
check('a missing module is an absence, never a guess',
  /if \\(!mod\\) return null;/.test(cartridgeSource));
check('the page says plainly that a hop is not a distance',
  /A hop is a published circuit, not a distance/.test(cartridgeSource));
check('refusals are surfaced to the reader, not swallowed',
  /not walked because a circuit cannot change voltage/.test(cartridgeSource));
check('the traversal state is published for review',
  /window\\.__GRIDATLAS_ELECTRICAL__ = electrical;/.test(cartridgeSource));
check('no kilometre figure is taken from the topology answer',
  !/reach[\\s\\S]{0,200}_km/.test(cartridgeSource));

${TAIL}`));
  }
};

Rating Envelope

A JavaScript module in the steps folder of GridAtlas. It is built from the ratings step (`ratings`).

electricalgridatlas / tools/overnight/steps/202609012250-rating-envelope.mjs · lines 1–157 of 157 · version 2026-09-01 22:50 · Not reached from any entry point (candidate for review) · pattern ratings (shared by 10 files)

What it does
Defines ratings. Side effects: changes the web page (DOM).
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.
What it achieves
The card reports summer as well as winter, and refuses to add up.
Why it matters
No other file in the estate was found to import it.
Application
gridatlas · tools/overnight/steps · JavaScript module
Uses
none found
Used by
none found
Produces
ratings
Defines here
ratings
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/overnight/steps/202609012250-rating-envelope.mjs:1-157 · blob b5ddc45e4d33ab332abdc213311e66863be8fd4a · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/**
 * Step: the card reports summer as well as winter, and refuses to add up.
 *
 * The owner product publishes a site-wide WINTER envelope, and the card
 * has been printing it. Two things are wrong with stopping there.
 *
 * First, summer is the binding season for a thermally limited circuit,
 * and the product publishes it on 1,276 of 1,392 circuits. Measured
 * against the payload, summer differs from winter on 1,081 of the 1,276
 * that publish both - so a card that shows only winter is showing the
 * more generous number on the great majority of circuits it describes.
 *
 * Second, the shape of the number invites a sum. Eight circuits rated
 * 3,000 MVA is not 24,000 MVA of anything, but nothing in the code has
 * ever prevented that figure from being produced, and it is the single
 * most persuasive wrong number available from this data.
 *
 * So the module reports each circuit in each season and contains no code
 * path that produces a total; its proof asserts the absence structurally,
 * not the intention. It also names the four circuits the product
 * publishes at 9,999 MVA - each on a span of a kilometre or less with
 * zero impedance, which is the shape of a placeholder rather than a
 * rating - and excludes them from the range while still reporting them.
 */

const MODULE = 'atlas/modules/202609012250-rating-envelope.js';
const PROOF = 'tools/proofs/modules/202609012250-rating-envelope.proof.mjs';
const BODY = 'atlas/parts/202609012045-sld-sandbox-body.js';
const CI = 'tools/ci/202609012200-local-ci.mjs';

export default {
  id: 'rating-envelope',
  version: 'v9.72',
  scope: 'the card reports every season the operator publishes rather than winter alone, each circuit keeping its own rating and its own season, scoped to the connection voltage; four circuits published at 9,999 MVA on spans of a kilometre or less are named as placeholders and excluded from the range while still being reported; and the module that produces all of this contains no code path that ad  … [line shortened here: 463 characters; full line on GitHub]
  note: 'summer differs from winter on 1,081 of the 1,276 circuits that publish both, so winter alone was the more generous number on the great majority of them; a sum of circuit ratings is not a quantity that exists in the network and is now impossible to produce here',

  brings: [MODULE, PROOF],
  addModules: [MODULE],
  proofs: [PROOF],

  apply({ read, write, patch, sandboxProof }) {
    let body = read(BODY);

    /* ── the accessor, beside the other two ──────────────────────────── */
    const ANCHOR = `  function topologyBlockHtml(queries) {`;
    if (body.split(ANCHOR).length - 1 !== 1) throw new Error('topologyBlockHtml anchor is not unique');
    body = body.replace(ANCHOR, `  function ratingModule() {
    try { return window.__GRIDATLAS_MODULES__?.ratingEnvelope || null; }
    catch (_) { return null; }
  }

${ANCHOR}`);

    /* ── the seasonal sentence, before the electrical one ────────────── */
    const REACH_ANCHOR = `      /* Electrical distance, beside the one-hop view.`;
    if (body.split(REACH_ANCHOR).length - 1 !== 1) throw new Error('electrical anchor is not unique');
    body = body.replace(REACH_ANCHOR, `      /* Seasonal ratings, per circuit, never added together.
         ---------------------------------------------------------------
         The lowest and the highest are two REAL published values, not a
         range around a mean, and each is labelled with the season it
         belongs to. Where the operator publishes a placeholder rather
         than a rating, the card says so rather than quietly carrying the
         larger number into the maximum. */
      const ratings = (() => {
        const mod = ratingModule();
        if (!mod) return null;
        try { return mod.at(topology.index, point.site_code, kv != null ? { voltageKv: kv } : undefined); }
        catch (_) { return null; }
      })();
      if (ratings && ratings.circuits.length) {
        const said = [];
        for (const season of ['winter', 'summer']) {
          const band = ratings.by_season[season];
          if (!band || !band.circuits) continue;
          said.push(\`\${season} \${band.lowest_circuit_mva === band.highest_circuit_mva
            ? band.lowest_circuit_mva
            : \`\${band.lowest_circuit_mva}-\${band.highest_circuit_mva}\`} MVA\`);
        }
        if (said.length) {
          const flagged = ratings.counts.with_a_flagged_value;
          out += caveat(\`<b>Circuit ratings:</b> \${escapeHtml(said.join(', '))}, \`
            + \`across \${ratings.counts.circuits} circuit\${ratings.counts.circuits === 1 ? '' : 's'}. \`
            + \`Each figure is one circuit's rating in that season. They are not added \`
            + \`together: the sum of the circuits at a site is not a quantity that exists \`
            + \`in the network, and a rating is not what is free on the circuit.\`
            + (flagged ? \` \${flagged} circuit\${flagged === 1 ? ' publishes a value' : 's publish values'} \`
              + \`at or above 9,999 MVA on spans of a kilometre or less; \`
              + \`\${flagged === 1 ? 'it reads' : 'they read'} as a placeholder and \`
              + \`\${flagged === 1 ? 'is' : 'are'} excluded from the range above.\` : ''));
          rating.answered += 1;
          rating.flagged += flagged;
        }
      }

${REACH_ANCHOR}`);

    /* ── published state, beside the electrical state ────────────────── */
    const STATE = `  window.__GRIDATLAS_ELECTRICAL__ = electrical;`;
    if (body.split(STATE).length - 1 !== 1) throw new Error('electrical state anchor is not unique');
    body = body.replace(STATE, `${STATE}

  /* How many cards quoted a seasonal rating, and how many placeholder
     values the published record turned out to contain. */
  const rating = { answered: 0, flagged: 0 };
  window.__GRIDATLAS_RATINGS__ = rating;`);

    write(BODY, body);

    patch(CI, [
      [`  ['electrical distance', ['tools/proofs/modules/202609012245-electrical-distance.proof.mjs']]
];`,
       `  ['electrical distance', ['tools/proofs/modules/202609012245-electrical-distance.proof.mjs']],
  ['rating envelope', ['tools/proofs/modules/202609012250-rating-envelope.proof.mjs']]
];`, 'CI gate list'],
    ]);

    const proof = read(sandboxProof);
    const TAIL = `console.log(\`\\n\${passed}/\${passed + failures.length} checks passed\`);`;
    if (proof.split(TAIL).length - 1 !== 1) throw new Error('sandbox proof tail anchor is not unique');
    write(sandboxProof, proof.replace(TAIL, `console.log('\\nevery season the operator publishes, and no total\\n');

check('the rating-envelope module is in the served cartridge',
  /gridatlas\\.module\\.rating-envelope\\.v1/.test(cartridgeSource));
check('it is evaluated before the body that calls it',
  cartridgeSource.indexOf('gridatlas.module.rating-envelope.v1')
    < cartridgeSource.indexOf('function ratingModule('));
check('the card asks for summer, not winter alone',
  /for \\(const season of \\['winter', 'summer'\\]\\)/.test(cartridgeSource));
check('the card is scoped to the connection voltage when there is one',
  /mod\\.at\\(topology\\.index, point\\.site_code, kv != null \\? \\{ voltageKv: kv \\}/.test(cartridgeSource));
check('the page states plainly that the ratings are not added together',
  /not a quantity that exists/.test(cartridgeSource));
check('the page distinguishes a rating from what is free on the circuit',
  /a rating is not what is free on the circuit/.test(cartridgeSource));
/* The sentence is split across a template interpolation for the
   singular/plural, so the words "reads as a placeholder" never appear
   adjacent in the source. Pin the two halves that do ship verbatim. */
check('a placeholder value is named to the reader, not hidden',
  /as a placeholder and/.test(cartridgeSource)
  && /at or above 9,999 MVA on spans of a kilometre or less/.test(cartridgeSource)
  && /excluded from the range above/.test(cartridgeSource));
check('the served bytes contain no site total of circuit ratings', (() => {
  const start = cartridgeSource.indexOf('gridatlas.module.rating-envelope.v1');
  const end = cartridgeSource.indexOf('NS.ratingEnvelope = Object.freeze');
  if (start < 0 || end < 0) return false;
  const module = cartridgeSource.slice(start, end)
    .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '').replace(/\\/\\/[^\\n]*/g, '')
    .split(/const (?:NEVER_SUMMED|NOT_A_CAPACITY)\\s*=[\\s\\S]*?;/).join(' ');
  return !/(?:^|[^A-Za-z])(total|sum|aggregate)(?![A-Za-z])/i.test(module)
    && !/\\.reduce\\(/.test(module);
})());
check('the rating state is published for review',
  /window\\.__GRIDATLAS_RATINGS__ = rating;/.test(cartridgeSource));

${TAIL}`));
  }
};