GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Grid network and substations / ventus-grid-engine / proofs

Network Topology Proof and 4 more files

A JavaScript module in the proofs folder of Ventus Grid Engine covering transformers, overhead lines (OHL), 400kV and 132kV. It is built from the check step (`check`).

641 lines of JavaScript from ventus-grid-engine, in 5 files. Topic: Grid network and substations. Section 463 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. Interconnector Economics Proof energy-data · ventus-grid-engine / proofs/interconnector-economics.proof.mjs lines 1–166
  2. Network Topology Proof other · ventus-grid-engine / proofs/network-topology.proof.mjs lines 1–234
  3. Voltage Drop Proof electrical · ventus-grid-engine / proofs/voltage-drop.proof.mjs lines 1–161
  4. Single-Line Diagram (SLD) Sandbox Boot Trigger Excerpt electrical · ventus-grid-engine / sources/deeplink-extracts/receiver/sld-sandbox-boot-trigger.excerpt.js lines 1–43
  5. Single-Line Diagram (SLD) Sandbox Deep Link Plan Excerpt electrical · ventus-grid-engine / sources/deeplink-extracts/receiver/sld-sandbox-deep-link-plan.excerpt.js lines 1–37

Interconnector Economics Proof

A JavaScript module in the proofs folder of Ventus Grid Engine covering interconnectors. It is built from the check step (`check`), the near step (`near`) and the throws step (`throws`).

energy-dataventus-grid-engine / proofs/interconnector-economics.proof.mjs · lines 1–166 of 166 · Not reached from any entry point (candidate for review) · pattern throws (shared by 12 files)

What it does
It lists and searches interconnectors. Defines check, near, throws. Side effects: starts processes.
Why it exists in the grid workflow
Domain stage upstream_foresight (path word 'interconnector'): 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: interconnectors.
What it achieves
An edge between two systems, priced. Its code works with 10.3 GW, 1 GW and 7.65 GW.
Why it matters
No other file in the estate was found to import it.
Application
ventus-grid-engine · proofs · JavaScript module
Uses
Interconnector Economics (import)
Used by
none found
Produces
check, near, throws
Defines here
check, near, throws
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 proofs/interconnector-economics.proof.mjs:1-166 · blob 3c2cd9fa12217d80e05d710bb67ecd5e11a4134f · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: duplicate_candidate
/* interconnector-economics.proof.mjs — an edge between two systems, priced.
 *
 * The fleet used throughout is the real one in data-interconnectors:
 * ten operational links with BMRS codes totalling 10.3 GW, and six future
 * projects totalling 7.65 GW with no code yet. The distinction those codes
 * mark — observable flow against planned capacity — is the one most easily
 * lost when someone adds the two numbers together.
 *
 * Run: node proofs/interconnector-economics.proof.mjs
 */

import * as mod from '../engine/interconnector-economics.js';
const { schema, NOT_COMPUTED, flowDirection, energyTransferredGwh,
    congestionRentGbp, fleetCapacity, shareOfDemand } = mod;

const failures = [];
let passed = 0;
const check = (n, c) => { c ? passed += 1 : failures.push(n); };
const near = (a, b, tol) => Math.abs(a - b) <= tol;
const throws = (fn, p) => { try { fn(); return false; } catch (e) { return p.test(e.message); } };

/* The committed reference table, reference/interconnector_cables.csv. */
const FLEET = [
    { bmrsCode: 'INTFR', country: 'France', name: 'IFA', capacityGw: 2.0, status: 'operational' },
    { bmrsCode: 'INTIFA2', country: 'France', name: 'IFA2', capacityGw: 1.0, status: 'operational' },
    { bmrsCode: 'INTELEC', country: 'France', name: 'ElecLink', capacityGw: 1.0, status: 'operational' },
    { bmrsCode: 'INTNED', country: 'Netherlands', name: 'BritNed', capacityGw: 1.0, status: 'operational' },
    { bmrsCode: 'INTNEM', country: 'Belgium', name: 'Nemo Link', capacityGw: 1.0, status: 'operational' },
    { bmrsCode: 'INTNSL', country: 'Norway', name: 'North Sea Link', capacityGw: 1.4, status: 'operational' },
    { bmrsCode: 'INTVKL', country: 'Denmark', name: 'Viking Link', capacityGw: 1.4, status: 'operational' },
    { bmrsCode: 'INTEW', country: 'Ireland', name: 'East West Interconnector', capacityGw: 0.5, status: 'operational' },
    { bmrsCode: 'INTGRNL', country: 'Ireland', name: 'Greenlink', capacityGw: 0.5, status: 'operational' },
    { bmrsCode: 'INTIRL', country: 'Northern Ireland', name: 'Moyle', capacityGw: 0.5, status: 'operational' },
    { bmrsCode: '', country: 'Germany', name: 'NeuConnect', capacityGw: 1.4, status: 'future' },
    { bmrsCode: '', country: 'Germany', name: 'Tarchon Energy', capacityGw: 1.4, status: 'future' },
    { bmrsCode: '', country: 'Netherlands', name: 'LionLink', capacityGw: 2.0, status: 'future' },
    { bmrsCode: '', country: 'Belgium', name: 'Nautilus', capacityGw: 1.4, status: 'future' },
    { bmrsCode: '', country: 'Ireland', name: 'MaresConnect', capacityGw: 0.75, status: 'future' },
    { bmrsCode: '', country: 'Northern Ireland', name: 'LirIC', capacityGw: 0.7, status: 'future' }
];

check('schema is declared', schema === 'ventus-grid-engine.interconnector-economics.v1');

/* ── Direction follows the spread, not a preference. ────────────────────── */

check('GB dearer than the neighbour imports',
    flowDirection({ gbPriceGbpPerMwh: 90, neighbourPriceGbpPerMwh: 60 }).direction === 'import to GB');

check('GB cheaper than the neighbour exports',
    flowDirection({ gbPriceGbpPerMwh: 40, neighbourPriceGbpPerMwh: 75 }).direction === 'export from GB');

check('equal prices give no commercial incentive, and say a link may still flow for system reasons',
    flowDirection({ gbPriceGbpPerMwh: 70, neighbourPriceGbpPerMwh: 70 }).direction === 'no commercial incentive'
    && /system reasons/i.test(flowDirection({ gbPriceGbpPerMwh: 70, neighbourPriceGbpPerMwh: 70 }).basis));

check('the spread is reported unsigned, and the signed value is kept alongside it',
    (r => r.spreadGbpPerMwh === 35 && r.signedSpreadGbpPerMwh === -35)(
        flowDirection({ gbPriceGbpPerMwh: 40, neighbourPriceGbpPerMwh: 75 })));

check('both prices travel back with the direction, so it cannot be quoted without them',
    (r => r.from.gbPriceGbpPerMwh === 90 && r.from.neighbourPriceGbpPerMwh === 60)(
        flowDirection({ gbPriceGbpPerMwh: 90, neighbourPriceGbpPerMwh: 60 })));

check('a negative price is accepted, because negative prices are real',
    flowDirection({ gbPriceGbpPerMwh: -15, neighbourPriceGbpPerMwh: 40 }).direction === 'export from GB');

check('the basis says an interconnector generates nothing',
    /generates nothing/i.test(flowDirection({ gbPriceGbpPerMwh: 90, neighbourPriceGbpPerMwh: 60 }).basis));

/* ── Energy and rent. ───────────────────────────────────────────────────── */

check('IFA at 2 GW and 70% utilisation over a year moves 12,264 GWh',
    near(energyTransferredGwh({ capacityGw: 2.0, hours: 8760, utilisation: 0.7 }).value, 12264, 1));

check('a full year at full utilisation on 1 GW is 8,760 GWh',
    energyTransferredGwh({ capacityGw: 1, hours: 8760, utilisation: 1 }).value === 8760);

{
    /* 1 GW, one hour, full utilisation, £30/MWh spread = 1,000 MWh x 30 = £30,000. */
    const r = congestionRentGbp({ capacityGw: 1, hours: 1, utilisation: 1, spreadGbpPerMwh: 30 });
    check('one GW-hour across a £30/MWh spread is £30,000 of gross rent',
        near(r.value, 30000, 1e-6));
    check('the energy moved is reported alongside the money', r.energyGwh === 1);
    check('the basis says gross, and names losses, outages, cost and cap-and-floor as excluded',
        /GROSS/.test(r.basis) && /losses/i.test(r.basis) && /cap-and-floor/i.test(r.basis));
    check('the basis states plainly that it is not profit',
        /not profit/i.test(r.basis));
}

/* Scale check against the real fleet: the whole operational fleet, at a
   plausible utilisation and spread, for a year. */
check('the operational fleet at 10.3 GW and 40% for a year moves about 36 TWh',
    near(energyTransferredGwh({ capacityGw: 10.3, hours: 8760, utilisation: 0.4 }).value / 1000, 36.1, 0.2));

/* ── The fleet, and the distinction the BMRS codes mark. ────────────────── */
{
    const f = fleetCapacity({ links: FLEET });
    check('the sixteen links total 17.95 GW', near(f.value, 17.95, 1e-9));
    check('ten operational links total 10.3 GW', near(f.byStatus.operational, 10.3, 1e-9));
    check('six future links total 7.65 GW', near(f.byStatus.future, 7.65, 1e-9));
    check('capacity with a BMRS code is observable; capacity without one is a plan',
        near(f.observableGw, 10.3, 1e-9) && near(f.unobservableGw, 7.65, 1e-9));
    check('France is the largest single-country connection at 4 GW',
        near(f.byCountry.France, 4.0, 1e-9));
    check('Ireland and Northern Ireland are counted separately, because they are different systems',
        'Ireland' in f.byCountry && 'Northern Ireland' in f.byCountry);
    check('the basis warns that capacity is not energy',
        /Capacity is not energy/i.test(f.basis));
    check('the basis distinguishes an observable flow from a planned capacity',
        /observable/i.test(f.basis) && /plan rather than a measurement/i.test(f.basis));
}

/* ── Share of demand, which is meaningless without the demand. ──────────── */
{
    const s = shareOfDemand({ transferGw: 6, gbDemandGw: 40 });
    check('6 GW against a 40 GW demand is 15%', near(s.percent, 15, 1e-9));
    check('the demand used is returned with the share', s.from.gbDemandGw === 40);
    check('the basis says the same link is a different share of a summer minimum and a winter peak',
        /summer minimum and a winter peak/i.test(s.basis));
}

/* ── Input discipline. ──────────────────────────────────────────────────── */

check('a utilisation of 70 is refused, and the message says to pass 0.7',
    throws(() => energyTransferredGwh({ capacityGw: 2, hours: 8760, utilisation: 70 }), /fraction.*0\.7/s));

check('a non-numeric price is refused by type rather than coerced',
    throws(() => flowDirection({ gbPriceGbpPerMwh: '90', neighbourPriceGbpPerMwh: 60 }), /finite number/));

check('an empty fleet is refused', throws(() => fleetCapacity({ links: [] }), /non-empty array/));

check('a link without a status is refused, naming the index',
    throws(() => fleetCapacity({ links: [{ capacityGw: 1, country: 'France' }] }), /links\[0\]\.status/));

check('a zero-capacity link is refused, naming the index',
    throws(() => fleetCapacity({ links: [{ capacityGw: 0, country: 'X', status: 'operational' }] }),
        /links\[0\]\.capacityGw/));

/* ── The refusal that matters most here. ────────────────────────────────── */
{
    const callable = Object.keys(mod).filter(k => typeof mod[k] === 'function');
    check('no function returns geometry, a route, or coordinates',
        callable.every(n => !/geometry|route|coordinate|latitude|longitude|draw|map/i.test(n)));
    check('no export carries a coordinate of any kind',
        !JSON.stringify(Object.entries(mod).filter(([, v]) => typeof v !== 'function'))
            .match(/"(lat|lon|lng|coordinates|geometry)"/i));
    check('the geometry refusal names the licensing reason rather than leaving a gap',
        /licensed/i.test(NOT_COMPUTED.cableGeometry) && /TeleGeography/i.test(NOT_COMPUTED.cableGeometry));
    check('the geometry refusal says neither NESO nor National Grid publishes an alternative',
        /NESO/.test(NOT_COMPUTED.cableGeometry) && /National Grid/.test(NOT_COMPUTED.cableGeometry));
    check('the geometry refusal says what to do if terms ever change, and warns against a screenshot',
        /deliberately/i.test(NOT_COMPUTED.cableGeometry) && /screenshot/i.test(NOT_COMPUTED.cableGeometry));
    check('no function forecasts a price',
        callable.every(n => !/forecast|predict|project(ion)?Price/i.test(n)));
    check('the refusals name geometry, price forecasting, scheduled flow, profit and losses',
        ['cableGeometry', 'priceForecast', 'scheduledFlow', 'profit', 'lossesAndAvailability']
            .every(k => k in NOT_COMPUTED));
}

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

Network Topology Proof

A JavaScript module in the proofs folder of Ventus Grid Engine covering transformers, overhead lines (OHL), 400kV and 132kV. It is built from the check step (`check`).

otherventus-grid-engine / proofs/network-topology.proof.mjs · lines 1–234 of 234 · Not reached from any entry point (candidate for review)

What it does
Defines check. Side effects: starts processes.
Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'topology'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: transformers, overhead lines (OHL), 400kV, 132kV.
Inputs & outputs
Voltage levels named: 400kV, 132kV.
What it achieves
What the network operator publishes about one site, read as a graph, with the one property that made this module worth promoting on its own. Its code works with 400 kV, 132 kV and 9999 MVA.
Why it matters
No other file in the estate was found to import it.
Application
ventus-grid-engine · proofs · JavaScript module
Uses
Network Topology (import)
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
ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 proofs/network-topology.proof.mjs:1-234 · blob 09f6131b1b2ba7fed563c1c6e57a3505d00f3b3f · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: process · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
/* network-topology.proof.mjs — what the network operator publishes about
 * one site, read as a graph, with the one property that made this module
 * worth promoting on its own: a site that owns both ends of a branch
 * publishes it twice, and physicalUnits() must fold that back to one.
 *
 * The fixture network (COWL/DIDC/STRA/ISLE/PLCH) is reused, unchanged, by
 * electrical-distance.proof.mjs and rating-envelope.proof.mjs, so the same
 * graph backs all three promoted modules' proofs.
 *
 * Run: node proofs/network-topology.proof.mjs
 */

import { ACCEPTS, UNDECLARED, physicalUnits, ratingsOf, parametersOf, index, schema }
    from '../engine/network-topology.js';

const failures = [];
let passed = 0;
const check = (name, condition) => {
    if (condition) passed += 1;
    else failures.push(name);
};

/* ── The fixture: five real sites ────────────────────────────────────────
 *
 * COWL (Cowley) at 400kV and 132kV, joined by an internal transformer —
 * the branch that gets published from both ends.
 * COWL4 --circuit(400-400)--> DIDC4 (Didcot) --circuit(400-400)--> STRA4
 * (Strand): a genuine two-hop chain, reached by electrical-distance.
 * COWL4 --circuit(400-132)--> ISLE1 (Isolated): a circuit whose two ends
 * carry different declared voltages — legal data here (network-topology
 * does not judge legality), and electrical-distance's refusal fixture.
 * COWL4 --circuit--> PLCH4 (Placeholder, 400kV): one season published at
 * 9999 MVA — rating-envelope's implausible-value fixture.
 */

const PRODUCT = {
    schema: ACCEPTS,
    sites: [
        { code: 'COWL', name: 'Cowley', transmission_owner: 'NGET', voltages_kv: [400, 132] },
        { code: 'DIDC', name: 'Didcot', transmission_owner: 'NGET', voltages_kv: [400] },
        { code: 'STRA', name: 'Strand', transmission_owner: 'NGET', voltages_kv: [400] },
        { code: 'ISLE', name: 'Isolated', transmission_owner: 'NGET', voltages_kv: [132] },
        { code: 'PLCH', name: 'Placeholder', transmission_owner: 'NGET', voltages_kv: [400] }
    ],
    nodes: [
        { node: 'COWL4', site_code: 'COWL', voltage_kv: 400, voltage_consistent_with_site: true },
        { node: 'COWL1', site_code: 'COWL', voltage_kv: 132, voltage_consistent_with_site: true },
        { node: 'DIDC4', site_code: 'DIDC', voltage_kv: 400, voltage_consistent_with_site: true },
        { node: 'STRA4', site_code: 'STRA', voltage_kv: 400, voltage_consistent_with_site: true },
        { node: 'ISLE1', site_code: 'ISLE', voltage_kv: 132, voltage_consistent_with_site: true },
        { node: 'PLCH4', site_code: 'PLCH', voltage_kv: 400, voltage_consistent_with_site: true }
    ],
    circuits: [
        { node_1: 'COWL4', node_2: 'DIDC4', circuit_type: 'OHL', transmission_owner: 'NGET',
          winter_mva: 1200, spring_mva: 1100, summer_mva: 900, autumn_mva: 1150,
          r_pct_100mva: 0.5, x_pct_100mva: 5, b_pct_100mva: 10, ohl_km: 20 },
        { node_1: 'DIDC4', node_2: 'STRA4', circuit_type: 'OHL', transmission_owner: 'NGET',
          winter_mva: 800, spring_mva: 750, summer_mva: 600, autumn_mva: 700, ohl_km: 15 },
        { node_1: 'COWL4', node_2: 'ISLE1', circuit_type: 'OHL', transmission_owner: 'NGET',
          winter_mva: 500, spring_mva: 480, summer_mva: 400, autumn_mva: 450 },
        { node_1: 'COWL4', node_2: 'PLCH4', circuit_type: 'OHL', transmission_owner: 'NGET',
          winter_mva: 9999, spring_mva: 100, summer_mva: 90, autumn_mva: 95 }
    ],
    transformers: [
        { node_1: 'COWL4', node_2: 'COWL1', rating_mva: 240, transmission_owner: 'NGET' }
    ],
    planned_changes: [
        { node_1: 'STRA4', node_2: 'FUTR1', year: 2029, status: 'proposed', asset: 'new circuit' }
    ]
};

const idx = index(PRODUCT);

/* A second, minimal fixture whose only job is the UNDECLARED-voltage band:
 * ALFAX shares ALFA's site but the product does NOT confirm its voltage. */
const PRODUCT_UNDECLARED = {
    schema: ACCEPTS,
    sites: [{ code: 'ALFA', name: 'Alfa', voltages_kv: [400] },
            { code: 'BETA', name: 'Beta', voltages_kv: [400] }],
    nodes: [
        { node: 'ALFA4', site_code: 'ALFA', voltage_kv: 400, voltage_consistent_with_site: true },
        { node: 'ALFAX', site_code: 'ALFA', voltage_kv: 132, voltage_consistent_with_site: false },
        { node: 'BETA4', site_code: 'BETA', voltage_kv: 400, voltage_consistent_with_site: true }
    ],
    circuits: [
        { node_1: 'ALFA4', node_2: 'BETA4', winter_mva: 100, spring_mva: 90, summer_mva: 80, autumn_mva: 85 },
        { node_1: 'ALFAX', node_2: 'BETA4', winter_mva: 10, spring_mva: 9, summer_mva: 8, autumn_mva: 8.5 }
    ]
};
const idxU = index(PRODUCT_UNDECLARED);

/* ── Schema gate ──────────────────────────────────────────────────────── */

check('a payload with the wrong schema is refused with null, not read '
    + 'partially or guessed at',
    index({ schema: 'something.else' }) === null && index(null) === null);

check('the module identifies itself with a stable schema string',
    schema === 'gridatlas.module.network-topology.v1' && idx.schema === schema);

check('a matching payload indexes every site and node it declares',
    idx.counts.sites === 5 && idx.counts.nodes === 6);

/* ── physicalUnits(): the branch counted from both ends folds to one ────── */

check('a branch seen from BOTH its ends counts as one physical unit, not '
    + 'two — this is the Cowley 5-vs-10 case the module exists to fix',
    physicalUnits([{ from_node: 'A', to_node: 'B' }, { from_node: 'B', to_node: 'A' }]) === 1);

check('a branch seen from only one end still counts as one unit — a '
    + 'voltage-filtered query that only sees one side must not undercount',
    physicalUnits([{ from_node: 'A', to_node: 'B' }]) === 1);

check('two genuinely different branches count as two units',
    physicalUnits([{ from_node: 'A', to_node: 'B' }, { from_node: 'C', to_node: 'D' }]) === 2);

check('an empty record set is zero units, not an error',
    physicalUnits([]) === 0);

/* ── Site lookup: by code or by exact name, case-insensitive ────────────── */

check('a site resolves by its code and by its exact name, regardless of '
    + 'case',
    idx.site('COWL').code === 'COWL' && idx.site('cowl').code === 'COWL'
    && idx.site('Cowley').code === 'COWL' && idx.site('cowley').code === 'COWL');

check('an unknown key resolves to null, not to a plausible-looking guess',
    idx.site('NOWHERE') === null && idx.site(null) === null);

/* ── at(): the full picture for one site ─────────────────────────────────── */

const cowl = idx.at('COWL');

check('at() groups strictly by node voltage and never returns a '
    + 'site-wide range across voltages: the 400kV and 132kV bands are '
    + 'separate entries, highest voltage first',
    cowl.by_voltage.length === 2
    && cowl.by_voltage[0].voltage_kv === 400 && cowl.by_voltage[1].voltage_kv === 132);

check('the internal transformer between COWL4 and COWL1 is published TWICE '
    + '(once landing on each node) but counted as ONE physical unit — the '
    + 'exact property physicalUnits exists to guarantee',
    cowl.counts.transformer_landings === 2 && cowl.counts.transformers === 1);

check('the three circuits landing only at COWL4 are three distinct '
    + 'physical units, none of them internally duplicated',
    cowl.counts.circuit_landings === 3 && cowl.counts.circuits === 3);

check('neighbours are the SITES those circuits reach, not the nodes — '
    + 'three circuits from COWL4 reach three distinct neighbour sites',
    cowl.neighbours.length === 3
    && cowl.neighbours.every(n => n.circuits === 1)
    && new Set(cowl.neighbours.map(n => n.site_code)).size === 3);

check('a voltage filter restricts at() to just that band',
    idx.at('COWL', { voltageKv: 400 }).by_voltage.length === 1
    && idx.at('COWL', { voltageKv: 400 }).by_voltage[0].voltage_kv === 400);

check('an unknown site returns null from at(), not an empty-but-present '
    + 'result that could be mistaken for a site with nothing published',
    idx.at('NOWHERE') === null);

/* ── The voltage-trust rule: a digit in a node code is never enough ──────── */

const alfa = idxU.at('ALFA');
const undeclaredBand = alfa.by_voltage.find(b => b.voltage_kv == null);
check('a node whose voltage the product does not confirm '
    + '(voltage_consistent_with_site: false) is reported as undeclared, '
    + 'never as the digit its own code happens to suggest',
    undeclaredBand !== undefined && undeclaredBand.circuits.length === 1
    && undeclaredBand.circuits[0].from_node === 'ALFAX');

check('the undeclared band sorts LAST, after every declared voltage, high '
    + 'to low',
    alfa.by_voltage[alfa.by_voltage.length - 1].voltage_kv == null
    && alfa.by_voltage[0].voltage_kv === 400);

/* ── planned_changes: visible in at(), absent from graph() edges ────────── */

const stra = idx.at('STRA');
check('a planned change is published at the site it was declared for',
    stra.by_voltage[0].planned_changes.length === 1
    && stra.by_voltage[0].planned_changes[0].year === 2029);

check('a planned change is NOT a neighbour and NOT a graph edge — it has '
    + 'not been built, so it cannot be walked',
    stra.neighbours.every(n => n.site_code !== 'FUTR')
    && idx.graph().edgesAt('STRA4').every(e => e.kind !== 'planned_change'));

/* ── graph(): the read-only adjacency view ───────────────────────────────── */

const g = idx.graph();
check('graph() declares its own schema so a consumer can refuse to run '
    + 'against the wrong shape of index',
    g.schema === 'gridatlas.module.network-topology.graph.v1');

check('graph().has() and nodeSiteCode() agree with what index() itself '
    + 'declared for the same nodes',
    g.has('COWL4') === true && g.nodeSiteCode('COWL4') === 'COWL'
    && g.has('NOPE') === false && g.nodeSiteCode('NOPE') === null);

check('graph().nodeVoltageKv() applies the exact same trust rule as at() '
    + 'does, on the second fixture — undeclared for ALFAX, declared for '
    + 'its neighbour',
    idxU.graph().nodeVoltageKv('ALFAX') === null
    && idxU.graph().nodeVoltageKv('BETA4') === 400
    && g.nodeVoltageKv('ISLE1') === 132);

check('graph().nodesOfSite() returns every node at a site, sorted, and '
    + 'graph().siteByCode() returns the site record itself',
    JSON.stringify(g.nodesOfSite('COWL')) === JSON.stringify(['COWL1', 'COWL4'])
    && g.siteByCode('DIDC').name === 'Didcot' && g.siteByCode('NOPE') === null);

/* ── ratingsOf / parametersOf: only what is actually published ──────────── */

check('ratingsOf returns only the seasons the row actually publishes, and '
    + 'null when none are',
    Object.keys(ratingsOf({ winter_mva: 100 })).length === 1
    && ratingsOf({}) === null);

check('parametersOf returns only the R/X/B fields the row actually '
    + 'publishes, and null when none are',
    Object.keys(parametersOf({ r_pct_100mva: 0.5 })).length === 1
    && parametersOf({}) === null);

/* ── Report ─────────────────────────────────────────────────────────────── */

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

Voltage Drop Proof

A JavaScript module in the proofs folder of Ventus Grid Engine covering cables. It is built from the check step (`check`), the near step (`near`) and the throws step (`throws`).

electricalventus-grid-engine / proofs/voltage-drop.proof.mjs · lines 1–161 of 161 · Not reached from any entry point (candidate for review) · pattern throws (shared by 12 files)

What it does
It lists and searches cables. Defines check, near, throws. Side effects: starts processes.
Why it exists in the grid workflow
Domain stage sub33kv_design (voltage levels 400V (all 33kV or below)): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: cables, 400V.
Inputs & outputs
Voltage levels named: 400V.
What it achieves
Volts and watts along a run. Its code works with 3 kW.
Why it matters
No other file in the estate was found to import it.
Application
ventus-grid-engine · proofs · JavaScript module
Uses
Voltage Drop (import)
Used by
none found
Produces
check, near, throws
Defines here
check, near, throws
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 proofs/voltage-drop.proof.mjs:1-161 · blob bf1e87a1befffcf15224ea51c5e4d996e719ccef · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: process · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
/* voltage-drop.proof.mjs — volts and watts along a run.
 *
 * Two errors this exists to prevent, both of which produce a confident wrong
 * answer in a consistent direction:
 *
 *   1. The wrong phase factor. sqrt(3) against 2 is a 15% error every time.
 *   2. Dropping the reactance term, or applying it as if the power factor were
 *      unity. On a large cable X approaches R, and a poorly corrected load is
 *      exactly where that under-statement lands.
 *
 * Run: node proofs/voltage-drop.proof.mjs
 */

import * as mod from '../engine/voltage-drop.js';
const { schema, PHASE_FACTOR, NOT_COMPUTED,
    voltageDropVolts, dropPercent, lossesWatts, annualLossKwh } = mod;

const failures = [];
let passed = 0;
const check = (n, c) => { c ? passed += 1 : failures.push(n); };
const near = (a, b, tol) => Math.abs(a - b) <= tol;
const throws = (fn, p) => { try { fn(); return false; } catch (e) { return p.test(e.message); } };

check('schema is declared', schema === 'ventus-grid-engine.voltage-drop.v1');

check('the phase factors are sqrt(3) and 2, not 1.73 typed in',
    PHASE_FACTOR.three === Math.sqrt(3) && PHASE_FACTOR.single === 2);

/* ── A worked run: 200 A, 250 m, 0.1 ohm/km R, 0.08 ohm/km X, pf 0.9. ───── */
{
    const a = { currentA: 200, lengthM: 250, resistanceOhmPerKm: 0.1,
        reactanceOhmPerKm: 0.08, powerFactor: 0.9, phases: 'three' };
    const r = voltageDropVolts(a);
    const sinPhi = Math.sqrt(1 - 0.9 * 0.9);
    const expected = Math.sqrt(3) * 200 * 0.25 * (0.1 * 0.9 + 0.08 * sinPhi);
    check('the three-phase drop matches the formula exactly', near(r.value, expected, 1e-9));
    check('resistive and reactive parts are reported separately and sum to the whole',
        near(r.resistiveVolts + r.reactiveVolts, r.value, 1e-9));
    check('the reactive part is a real fraction of the answer at pf 0.9, not a rounding artefact',
        r.reactiveVolts / r.value > 0.25);
}

/* The phase factor. Same circuit, both conventions. */
{
    const base = { currentA: 200, lengthM: 250, resistanceOhmPerKm: 0.1,
        reactanceOhmPerKm: 0.08, powerFactor: 0.9 };
    const three = voltageDropVolts({ ...base, phases: 'three' }).value;
    const single = voltageDropVolts({ ...base, phases: 'single' }).value;
    check('single phase drops more than three phase for the same current and run',
        single > three);
    check('and the ratio is exactly 2 over sqrt(3) — a 15.5% error if the factor is wrong',
        near(single / three, 2 / Math.sqrt(3), 1e-12));
}

/* The reactance term against power factor. */
{
    const base = { currentA: 200, lengthM: 250, resistanceOhmPerKm: 0.1, reactanceOhmPerKm: 0.15 };
    const unity = voltageDropVolts({ ...base, powerFactor: 1 });
    const poor = voltageDropVolts({ ...base, powerFactor: 0.8 });
    check('at unity power factor the reactance contributes exactly nothing',
        unity.reactiveVolts === 0);
    check('at unity the drop is the resistive term alone',
        near(unity.value, Math.sqrt(3) * 200 * 0.25 * 0.1, 1e-9));
    check('at 0.8 the reactance contributes 60% of its value, because sin(phi) is 0.6',
        near(poor.reactiveVolts, Math.sqrt(3) * 200 * 0.25 * 0.15 * 0.6, 1e-9));
    /* On a cable where X exceeds R, ignoring X is the bigger error. */
    const ignoringX = voltageDropVolts({ ...base, reactanceOhmPerKm: 0, powerFactor: 0.8 }).value;
    check('ignoring reactance on a cable where X exceeds R under-states the drop by over a third',
        (poor.value - ignoringX) / poor.value > 0.33);
    check('the basis warns about exactly that',
        /ignoring X on a large\s+cable/i.test(poor.basis.replace(/\s+/g, ' '))
        || /ignoring X on a large cable/i.test(poor.basis.replace(/\s+/g, ' ')));
}

/* ── Percentage, and the absence of an asserted limit. ──────────────────── */
{
    const p = dropPercent({ dropVolts: 9.2, nominalVolts: 400 });
    check('9.2 V on 400 V is 2.3%', near(p.value, 2.3, 1e-9));
    check('no permitted limit is asserted, and the basis says why',
        /No limit is asserted here/i.test(p.basis));
}

/* ── Losses: only resistance, and the right conductor count. ────────────── */
{
    const l3 = lossesWatts({ currentA: 200, lengthM: 250, resistanceOhmPerKm: 0.1, phases: 'three' });
    check('three-phase losses count three conductors', l3.conductors === 3);
    check('losses are I squared R times the conductor count',
        near(l3.value, 3 * 200 * 200 * 0.1 * 0.25, 1e-9));

    const l1 = lossesWatts({ currentA: 200, lengthM: 250, resistanceOhmPerKm: 0.1, phases: 'single' });
    check('single-phase losses count two conductors, both carrying the full current',
        l1.conductors === 2 && near(l1.value, 2 * 200 * 200 * 0.1 * 0.25, 1e-9));

    /* Reactance must not appear in heat. This is the check that catches
       somebody "improving" losses by passing the impedance in. */
    const withX = lossesWatts({ currentA: 200, lengthM: 250, resistanceOhmPerKm: 0.1, phases: 'three' });
    check('reactance cannot enter the loss calculation, because losses take only R',
        !('reactanceOhmPerKm' in withX.from));
    check('the basis says reactance stores and returns energy rather than dissipating it',
        /stores and returns energy/i.test(withX.basis));

    /* Losses follow the square of current: double the current, quadruple the heat. */
    const doubled = lossesWatts({ currentA: 400, lengthM: 250, resistanceOhmPerKm: 0.1, phases: 'three' });
    check('doubling the current quadruples the losses', near(doubled.value / l3.value, 4, 1e-9));
}

/* ── Annual losses, and the trap in scaling them. ───────────────────────── */
{
    const a = annualLossKwh({ peakLossWatts: 3000, lossLoadFactor: 0.3 });
    check('3 kW at peak with a 0.3 loss load factor is 7,884 kWh a year',
        near(a.value, 3000 * 0.3 * 8760 / 1000, 1e-9));
    check('the basis says the LOSS load factor is not the load factor, and why',
        /LOSS load factor is not the load factor/i.test(a.basis)
        && /square of\s+current/i.test(a.basis.replace(/\s+/g, ' ')));
}

/* ── Input discipline. ──────────────────────────────────────────────────── */

check('an unknown phase convention is refused, and the two valid ones are named',
    throws(() => voltageDropVolts({ currentA: 100, lengthM: 100, resistanceOhmPerKm: 0.1,
        powerFactor: 0.9, phases: 'two' }), /"three" or "single"/));

check('a power factor of 90 is refused, and the message says to pass 0.9',
    throws(() => voltageDropVolts({ currentA: 100, lengthM: 100, resistanceOhmPerKm: 0.1,
        powerFactor: 90 }), /fraction.*0\.9/s));

check('a zero resistance is refused — a conductor with no resistance is not a conductor',
    throws(() => voltageDropVolts({ currentA: 100, lengthM: 100, resistanceOhmPerKm: 0,
        powerFactor: 0.9 }), /greater than zero/));

check('a zero reactance IS accepted, because a purely resistive figure is a legitimate input',
    voltageDropVolts({ currentA: 100, lengthM: 100, resistanceOhmPerKm: 0.1,
        reactanceOhmPerKm: 0, powerFactor: 0.9 }).reactiveVolts === 0);

check('a negative reactance is refused',
    throws(() => voltageDropVolts({ currentA: 100, lengthM: 100, resistanceOhmPerKm: 0.1,
        reactanceOhmPerKm: -0.05, powerFactor: 0.9 }), /not be negative/));

/* ── Refusals. ──────────────────────────────────────────────────────────── */
{
    const callable = Object.keys(mod).filter(k => typeof mod[k] === 'function');
    check('no function selects or sizes a cable',
        callable.every(n => !/select|size|choose|csa|recommend/i.test(n)));
    check('no conductor parameters are carried as data',
        !Object.keys(mod).some(k => /^(CABLE|CONDUCTOR|CSA|R_|X_)/i.test(k)));
    check('the refusals name selection, conductor parameters, permitted drop and fault withstand',
        ['cableSelection', 'conductorParameters', 'permittedDrop', 'faultWithstand']
            .every(k => k in NOT_COMPUTED));
    check('the conductor-parameter refusal says a plausible default would be the dangerous thing',
        /most dangerous thing this file could contain/i.test(NOT_COMPUTED.conductorParameters));
    check('the fault refusal warns a cable adequate for volts and amps can still fail a fault',
        /still be inadequate for a fault/i.test(NOT_COMPUTED.faultWithstand));
}

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

Single-Line Diagram (SLD) Sandbox Boot Trigger Excerpt

A JavaScript file in the receiver folder of Ventus Grid Engine that works with attempt arrival (`attemptArrival`).

electricalventus-grid-engine / sources/deeplink-extracts/receiver/sld-sandbox-boot-trigger.excerpt.js · lines 1–43 of 43 · Not reached from any entry point (candidate for review) · pattern arrivalHasVisibleOutcome (shared by 7 files)

What it does
Defines arrivalHasVisibleOutcome, attemptArrival. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
What it achieves
It is built from the arrival has visible outcome helper (`arrivalHasVisibleOutcome`) and the attempt arrival helper (`attemptArrival`). `head_sha` (GridAtlas).
Why it matters
No other file in the estate was found to import it.
Application
ventus-grid-engine · sources/deeplink-extracts/receiver · script
Uses
none found
Used by
none found
Produces
arrivalHasVisibleOutcome, attemptArrival
Defines here
arrivalHasVisibleOutcome, attemptArrival
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 sources/deeplink-extracts/receiver/sld-sandbox-boot-trigger.excerpt.js:1-43 · blob 209a7291cacd33ad674af275051f270075eb1a9e · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: experimental · users: none · canonical: unreached_review
/*
 * PROVENANCE (excerpt)
 * source_repo: gridatlas
 * source_path: atlas/parts/202609041234-sld-sandbox-technology-buckets.js
 * head_sha (gridatlas): 64268fd06a0da54ddffbcdaaaee382e314e829f7
 * lines: 4623-4650
 *
 * The visibility-gated boot trigger that calls runDeepLink() (see
 * sld-sandbox-run-deep-link.excerpt.js). Never starts the arrival while the
 * tab is hidden (iOS Safari does not tick requestAnimationFrame in a background
 * tab, which stalled MapLibre's flyTo entirely when Pipeline News' MAP button
 * opened target="_blank" on a touch device); retries up to
 * MAX_AUTO_ARRIVAL_ATTEMPTS=5 times whenever the tab becomes visible without a
 * visible outcome yet.
 */
       map.flyTo() there does not throw and is not a failure this cartridge
       can see: the animation is simply never given a frame to advance, so
       the camera stays exactly where it started, forever, even once the
       tab is later brought to the front -- because this function had
       already run to its own conclusion and nothing called it again.

       So: never START the arrival until the document is actually visible,
       and never leave an arrival that has not produced a visible outcome
       stranded -- run it again the first time the tab is genuinely seen. */
    let arrivalAttempts = 0;
    const MAX_AUTO_ARRIVAL_ATTEMPTS = 5;   // a real, non-visibility failure must still stop retrying
    function arrivalHasVisibleOutcome() {
      // Both already-published, already-relied-upon fields: links_drawn is
      // read the same way by the electron-flow visibility listener just
      // below, and the not-in-active-register message is this cartridge's
      // own genuine "nothing more to show" terminal state.
      return link.links_drawn > 0
        || link.origin_source === 'not-in-active-register-no-supplied-point';
    }
    function attemptArrival() {
      if (document.visibilityState !== 'visible') return;
      arrivalAttempts += 1;
      link.arrival_attempts = arrivalAttempts;
      void runDeepLink();
    }
    if (document.visibilityState === 'visible') {
      attemptArrival();
    } else {

Single-Line Diagram (SLD) Sandbox Deep Link Plan Excerpt

A JavaScript file in the receiver folder of Ventus Grid Engine. It is built from the deep link plan helper (`deepLinkPlan`).

electricalventus-grid-engine / sources/deeplink-extracts/receiver/sld-sandbox-deep-link-plan.excerpt.js · lines 1–37 of 37 · Not reached from any entry point (candidate for review) · pattern deepLinkPlan (shared by 10 files)

What it does
It calculates its inputs. Defines deepLinkPlan.
Why it exists in the grid workflow
Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
What it achieves
`head_sha` (GridAtlas).
Why it matters
No other file in the estate was found to import it.
Application
ventus-grid-engine · sources/deeplink-extracts/receiver · script
VEDIC
PLAN PROJECT MAP ARRIVAL (GG2050-VEDIC-000104): GridAtlas / Map integration · Map integration. raw_longitude, raw_latitude, raw_repd_ref → Frozen record of parsed longitude, latitude, trimmed repd_ref, coordinates_usable and route MEASURE_LINK_FIRST, WAIT_FOR_REGISTER or NO_USABLE_POINT.
Uses
none found
Used by
none found
Produces
deepLinkPlan
Defines here
deepLinkPlan
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 sources/deeplink-extracts/receiver/sld-sandbox-deep-link-plan.excerpt.js:1-37 · blob 45d3a127901c38d541f0adef0b9b1dbcb48bcd85 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: unreached_review
/*
 * PROVENANCE (excerpt)
 * source_repo: gridatlas
 * source_path: atlas/parts/202609041234-sld-sandbox-technology-buckets.js
 * head_sha (gridatlas): 64268fd06a0da54ddffbcdaaaee382e314e829f7
 * lines: 1684-1702
 *
 * deepLinkPlan(): the pure decision of what route an arrival takes, based on
 * whether the link supplied usable coordinates and/or a repd_ref. Exported as
 * link.measure.deepLinkPlan so a proof can run it against the whole PipelineNews
 * link corpus without booting a map.
 *   MEASURE_LINK_FIRST -- usable longitude+latitude present: measure/draw at
 *     once using the link's own point; register identity verifies concurrently.
 *   WAIT_FOR_REGISTER  -- no usable coordinates but a repd_ref is present:
 *     nothing safe to draw until the register (see the search-lane excerpt)
 *     resolves it.
 *   NO_USABLE_POINT    -- neither: nothing this cartridge can do.
 */
  /* The receiver decision is pure and exported because Pipeline News owns
     the complete link corpus. The product path below consumes this exact
     plan; the corpus proof can therefore pass all 8,756 derived source
     points (8,753 served coordinate rows and 8,743 clickable actions)
     through the same decision without booting a map or a 35.7 MB register. */
  function deepLinkPlan(rawLon, rawLat, rawRepdRef) {
    const longitude = rawLon === null ? NaN : Number(rawLon);
    const latitude = rawLat === null ? NaN : Number(rawLat);
    const repdRef = String(rawRepdRef || '').trim();
    const coordinatesUsable = Number.isFinite(longitude) && Number.isFinite(latitude)
      && Math.abs(longitude) <= 180 && Math.abs(latitude) <= 90
      && !(Math.abs(longitude) < 1e-9 && Math.abs(latitude) < 1e-9);
    return Object.freeze({
      longitude, latitude, repd_ref: repdRef, coordinates_usable: coordinatesUsable,
      route: coordinatesUsable ? 'MEASURE_LINK_FIRST'
        : (repdRef ? 'WAIT_FOR_REGISTER' : 'NO_USABLE_POINT')
    });
  }
  link.measure.deepLinkPlan = deepLinkPlan;