In this section
- Corridor Estimate Proof other · ventus-grid-engine / proofs/corridor-estimate.proof.mjs lines 1–103
- Current from Power Proof electrical · ventus-grid-engine / proofs/current-from-power.proof.mjs lines 1–162
- Deeplink Receiver Proof ingest · ventus-grid-engine / proofs/deeplink-receiver.proof.mjs lines 1–151
- Deeplink Proof other · ventus-grid-engine / proofs/deeplink.proof.mjs lines 1–128
- Diversified Demand Proof energy-data · ventus-grid-engine / proofs/diversified-demand.proof.mjs lines 1–127
Corridor Estimate Proof
A JavaScript module in the proofs folder of Ventus Grid Engine covering cables. It is built from the check step (`check`) and the near step (`near`).
otherventus-grid-engine / proofs/corridor-estimate.proof.mjs · lines 1–103 of 103 · Not reached from any entry point (candidate for review)
- What it does
- Defines check, near. Side effects: starts processes.
- Why it exists in the grid workflow
- Domain stage hv_procurement (path word 'estimate'): HV materials procurement, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: cables.
- What it achieves
- A straight line is not a route, and this module's whole job is to say so honestly: a calibrated multiplier where one is defensible, and a refusal everywhere it is not.
- Why it matters
- No other file in the estate was found to import it.
- Application
- ventus-grid-engine · proofs · JavaScript module
- Uses
- Corridor Estimate (import)
- Used by
- none found
- Produces
- check, near
- Defines here
- check, near
- 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/corridor-estimate.proof.mjs:1-103 · blob f2417c33b31c700c0b3353a40f037bfcfebb951d · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: unknown · effects: process · domain stage: hv_procurement · users: EPC_contractor, procurement_buyer · canonical: unreached_review
/* corridor-estimate.proof.mjs — a straight line is not a route, and this
* module's whole job is to say so honestly: a calibrated multiplier where
* one is defensible, and a refusal everywhere it is not.
*
* Run: node proofs/corridor-estimate.proof.mjs
*/
import { CABLE_FACTOR, OHL_FACTOR, MINIMUM_KM, BASIS, forCable, schema }
from '../engine/corridor-estimate.js';
const failures = [];
let passed = 0;
const check = (name, condition) => {
if (condition) passed += 1;
else failures.push(name);
};
const near = (a, b, tol) => Math.abs(a - b) <= tol;
/* ── The constant itself ─────────────────────────────────────────────────── */
check('the cable factor is the published calibration value, 1.245, not a '
+ 'round number chosen for convenience',
CABLE_FACTOR === 1.245);
check('the overhead factor is published for context but is a different '
+ 'number from the cable factor, evidence the two are not interchangeable',
OHL_FACTOR === 1.13 && OHL_FACTOR !== CABLE_FACTOR);
check('the calibration basis records what it was measured against: 95 '
+ 'circuits collapsing to 59 distinct site pairs, not 95 independent '
+ 'measurements',
BASIS.circuits === 95 && BASIS.distinct_site_pairs === 59
&& BASIS.distinct_site_pairs < BASIS.circuits);
/* ── forCable(): the arithmetic ──────────────────────────────────────────── */
check('a 10 km straight line becomes a 12.45 km corridor estimate, exactly '
+ 'the calibrated factor applied once',
near(forCable(10).km, 12.45, 1e-9));
check('the estimate always carries the straight-line input it was built '
+ 'from, so a caller can recover the multiplier that was applied',
near(forCable(10).straight_km, 10, 1e-12)
&& near(forCable(10).km / forCable(10).straight_km, CABLE_FACTOR, 1e-12));
check('the estimate scales linearly — doubling the straight-line distance '
+ 'exactly doubles the corridor estimate, because the model is a fixed '
+ 'multiplier and not a curve',
near(forCable(20).km, forCable(10).km * 2, 1e-9));
/* ── The refusal below MINIMUM_KM: null is the answer, not zero ─────────── */
check('MINIMUM_KM is 1 — the documented threshold below which centroid '
+ 'resolution dominates the geometry',
MINIMUM_KM === 1);
check('a separation below the minimum withholds an estimate — km is null, '
+ 'not a small or zero number that looks like a real answer',
forCable(0.5).km === null && typeof forCable(0.5).withheld === 'string'
&& forCable(0.5).withheld.length > 0);
check('the withheld case still reports the straight-line distance it was '
+ 'given and the factor that would have applied, so a caller can see '
+ 'why nothing was returned',
near(forCable(0.5).straight_km, 0.5, 1e-12) && forCable(0.5).factor === CABLE_FACTOR);
check('exactly at the minimum the estimate is produced, not withheld — '
+ 'the threshold is a closed lower bound',
forCable(1).km !== null && near(forCable(1).km, 1.245, 1e-9));
check('just under the minimum the estimate is withheld — the boundary is '
+ 'not off by one in the other direction either',
forCable(0.999).km === null);
/* ── Non-distances: zero, negative, non-finite ───────────────────────────── */
check('zero, negative and non-finite input all return null rather than a '
+ 'negative or NaN corridor length',
forCable(0) === null && forCable(-5) === null
&& forCable(NaN) === null && forCable(undefined) === null
&& forCable('not a number') === null);
/* ── No forOverhead(): the module cannot be misused for the wrong question ── */
check('the module exports no forOverhead function — OHL_FACTOR is '
+ 'published for a reader to see, not for a caller to reach',
typeof forCable === 'function'
&& Object.prototype.hasOwnProperty.call(
await import('../engine/corridor-estimate.js'), 'forOverhead') === false);
check('the module identifies itself with a stable schema string, so a '
+ 'consumer can assert which contract it is talking to',
schema === 'gridatlas.module.corridor-estimate.v1');
/* ── Report ─────────────────────────────────────────────────────────────── */
if (failures.length) {
console.error('corridor-estimate proof FAILED (' + failures.length + ' of '
+ (failures.length + passed) + '):\n- ' + failures.join('\n- '));
process.exit(1);
}
console.log('corridor-estimate proof PASS — ' + passed + ' checks');
export default { status: 'PASS', checks: passed };Current from Power Proof
A JavaScript module in the proofs folder of Ventus Grid Engine covering 400kV, 132kV and cables.
electricalventus-grid-engine / proofs/current-from-power.proof.mjs · lines 1–162 of 162 · Not reached from any entry point (candidate for review) · pattern throws (shared by 12 files)
- What it does
- Defines check, near, throws. Side effects: starts processes.
- Why it exists in the grid workflow
- Domain terms in the code: 400kV, 132kV, cables, 400V.
- Inputs & outputs
- Voltage levels named: 400kV, 132kV, 400V.
- What it achieves
- It is built from the check step (`check`), the near step (`near`) and the throws step (`throws`). The step that was missing between a published rating and a cable calculation. Its code works with 132 kV, 400 kV and 50 kVA.
- Why it matters
- No other file in the estate was found to import it.
- Application
- ventus-grid-engine · proofs · JavaScript module
- Uses
- Current from Power (import), 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/current-from-power.proof.mjs:1-162 · blob 00882cceb88322eac56806540bf61754fa83039b · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: unknown · effects: process · domain stage: unknown · users: none · canonical: unreached_review
/* current-from-power.proof.mjs — the step that was missing between a
* published rating and a cable calculation. Every published network figure
* here is a power; every cable calculation here takes a current; nothing
* joined them. These checks fix the join, and they spend most of their
* effort on the two ways it can be got wrong silently: the single-phase
* factor, and the belief that a rating is a flow.
*
* Run: node proofs/current-from-power.proof.mjs
*/
import {
schema, CURRENT_PHASE_FACTOR, NOT_COMPUTED, NOT_A_HEADROOM,
currentA, currentFromMvaAtKv
} from '../engine/current-from-power.js';
import { PHASE_FACTOR } from '../engine/voltage-drop.js';
const failures = [];
let passed = 0;
const check = (name, condition) => {
if (condition) passed += 1;
else failures.push(name);
};
const near = (a, b, tol) => Math.abs(a - b) <= tol;
const throws = (fn, Kind) => {
try { fn(); return false; } catch (e) { return e instanceof Kind; }
};
/* ── The constants, and the one that is a trap ───────────────────────────── */
check('the three-phase divisor is root three',
near(CURRENT_PHASE_FACTOR.three, Math.sqrt(3), 1e-15));
check('the single-phase divisor is one, not two',
CURRENT_PHASE_FACTOR.single === 1);
check('the single-phase divisor DIFFERS from voltage-drop\'s single-phase '
+ 'factor, which is 2 because a drop is lost in both conductors while a '
+ 'current is one current: importing that map here would halve every '
+ 'single-phase answer',
CURRENT_PHASE_FACTOR.single !== PHASE_FACTOR.single
&& PHASE_FACTOR.single === 2);
check('the three-phase divisor MATCHES voltage-drop\'s, which is why the '
+ 'single-phase mistake is easy to make and is worth a proof',
near(CURRENT_PHASE_FACTOR.three, PHASE_FACTOR.three, 1e-15));
check('the schema names this module and this version',
schema === 'ventus-grid-engine.current-from-power.v1');
/* ── The arithmetic, against hand-computed values ────────────────────────── */
/* 1,200 MVA at 400 kV: 1.2e9 / (1.7320508 x 4e5) = 1732.0508 A */
check('1,200 MVA on a 400 kV circuit implies 1,732.05 A',
near(currentFromMvaAtKv({ mva: 1200, kv: 400 }).value, 1732.0508075688772, 1e-9));
/* 90 MVA at 132 kV: 9e7 / (1.7320508 x 1.32e5) = 393.6479 A */
check('90 MVA on a 132 kV circuit implies 393.65 A',
near(currentFromMvaAtKv({ mva: 90, kv: 132 }).value, 393.6479108111085, 1e-9));
check('the megavolt-ampere call and the base-unit call are the same '
+ 'calculation, so a caller cannot get two answers for one question',
near(currentFromMvaAtKv({ mva: 1200, kv: 400 }).value,
currentA({ apparentPowerVa: 1200e6, voltageV: 400e3 }).value, 1e-9));
/* 50 kVA at 400 V single phase: 5e4 / 4e2 = 125 A exactly */
check('50 kVA single phase at 400 V is exactly 125 A, the textbook case that '
+ 'would read 62.5 A if the wrong phase factor were used',
currentA({ apparentPowerVa: 50e3, voltageV: 400, phases: 'single' }).value === 125);
check('single phase gives root-three times the current of three phase for the '
+ 'same power and voltage, never half of it',
near(currentA({ apparentPowerVa: 1e6, voltageV: 1e3, phases: 'single' }).value
/ currentA({ apparentPowerVa: 1e6, voltageV: 1e3, phases: 'three' }).value,
Math.sqrt(3), 1e-12));
check('halving the voltage doubles the current, because the relationship is '
+ 'inverse and any other behaviour would be a dimensional error',
near(currentFromMvaAtKv({ mva: 100, kv: 66 }).value,
2 * currentFromMvaAtKv({ mva: 100, kv: 132 }).value, 1e-9));
/* ── The result carries its units and its basis ──────────────────────────── */
const answer = currentFromMvaAtKv({ mva: 1200, kv: 400 });
check('the result states its unit, so a wire into a currentA pin can be '
+ 'checked rather than assumed',
answer.unit === 'A');
check('the result names its quantity',
answer.quantity === 'current_amperes');
check('the result carries the inputs it was given back out with it',
answer.from.mva === 1200 && answer.from.kv === 400
&& answer.from.phases === 'three');
check('the result prints the formula it used, and the printed formula '
+ 'changes with the phase count',
answer.basis.includes('sqrt(3) x V_line')
&& currentA({ apparentPowerVa: 1e6, voltageV: 1e3, phases: 'single' })
.basis.includes('I = S / (V)'));
/* ── The refusals, which are the point of the module ─────────────────────── */
check('every result says in its own body that it is not what the circuit is '
+ 'carrying, because the single most likely misreading of an amps figure '
+ 'derived from a rating is that it is a flow',
answer.not_computed === NOT_COMPUTED.actualCurrent
&& /not what the circuit is carrying/.test(answer.not_computed));
check('every result refuses headroom explicitly, since a rating minus nothing '
+ 'is not spare capacity',
answer.not_a_headroom === NOT_A_HEADROOM
&& /not spare capacity/.test(NOT_A_HEADROOM));
check('the module refuses derating in writing: no ambient, grouping, burial '
+ 'depth, soil resistivity or season is applied',
/ambient temperature/.test(NOT_COMPUTED.derating)
&& /soil thermal/.test(NOT_COMPUTED.derating));
check('the module refuses to choose a voltage for a site that publishes '
+ 'several',
/never chooses one/.test(NOT_COMPUTED.voltageChoice));
check('the module refuses to convert MW to MVA, leaving power factor to the '
+ 'one file that owns it, so two files cannot disagree about one number',
/power-factor\.js/.test(NOT_COMPUTED.powerFactor));
check('the refusals are frozen, so a caller cannot edit the sentence that '
+ 'qualifies its own answer',
Object.isFrozen(NOT_COMPUTED) && Object.isFrozen(CURRENT_PHASE_FACTOR));
/* ── Guards: bad input is refused loudly, never quietly ──────────────────── */
check('a missing power throws rather than returning NaN',
throws(() => currentA({ voltageV: 400e3 }), TypeError));
check('a zero voltage throws rather than returning Infinity, which is the '
+ 'failure a division would otherwise hand downstream',
throws(() => currentA({ apparentPowerVa: 1e6, voltageV: 0 }), RangeError));
check('a negative power throws',
throws(() => currentA({ apparentPowerVa: -1, voltageV: 400e3 }), RangeError));
check('a null power throws a TypeError naming the parameter',
throws(() => currentA({ apparentPowerVa: null, voltageV: 400e3 }), TypeError));
check('an unknown phase count throws instead of defaulting, because a silent '
+ 'default here is a root-three error',
throws(() => currentA({ apparentPowerVa: 1e6, voltageV: 1e3, phases: 'two' }), RangeError));
check('phases defaults to three only when omitted entirely',
currentA({ apparentPowerVa: 1e6, voltageV: 1e3 }).from.phases === 'three');
/* ── Report ─────────────────────────────────────────────────────────────── */
if (failures.length) {
console.error('current-from-power proof FAILED (' + failures.length + ' of '
+ (failures.length + passed) + '):\n- ' + failures.join('\n- '));
process.exit(1);
}
console.log('current-from-power proof PASS — ' + passed + ' checks');
export default { status: 'PASS', checks: passed };Deeplink Receiver Proof
A JavaScript module in the proofs folder of Ventus Grid Engine that fetches receivers, the Renewable Energy Planning Database (REPD) register, substations and solar from the GridAtlas repository.
ingestventus-grid-engine / proofs/deeplink-receiver.proof.mjs · lines 1–151 of 151 · Entry point
- What it does
- It fetches receivers, the REPD register, substations and solar. Defines check. Uses libraries node:fs, node:path, node:url. Side effects: reads or writes files; makes network requests; starts processes.
- Why it exists in the grid workflow
- Domain terms in the code: the REPD register, substations, solar.
- Inputs & outputs
- In: data source: gridatlas data; JSON file receivers.json.
- Downstream impact
- Used directly by 1 file: Deeplink Receiver Audit Workflow (ventus-grid-engine).
- What it achieves
- It is built from the check step (`check`). A deep link is built against a receiver that carries the engine, and the query that finds every row needing one.
- Why it matters
- Run by Deeplink Receiver Audit Workflow.
- Application
- ventus-grid-engine · proofs · JavaScript module
- Uses
- Contract (import), GlobalGrid2050 — Renewable Energy Planning Database (REPD) Grid Atlas v8 Page (estate URL), GridAtlas — Atlas Page (estate URL), node:fs, node:path, node:url
- Used by
- run by Deeplink Receiver Audit Workflow (workflow run)
- 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/deeplink-receiver.proof.mjs:1-151 · blob a9eb191087d8775d25fe868e13e8ec1a0eee6f43 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, network, process · domain stage: unknown · users: none · canonical: production_core
/* deeplink-receiver.proof.mjs — a deep link is built against a receiver that
* carries the engine, and the query that finds every row needing one.
*
* WHY THIS EXISTS, measured 2026-09-05
* ------------------------------------
* The MAP button in Pipeline News v9.7 pointed at
* https://globalgrid2050.com/repd_grid_atlasv8/ — the V8 overlay. That page
* still serves, so nothing 404'd and no monitor complained. It carries no
* cartridge, no current.json and no nearest-substation path: 21,045 bytes with
* zero engine markers, against 20 cartridge references in the v9 shell. Every
* MAP click from Pipeline News therefore landed somewhere that could not
* compute a nearest substation, a corridor estimate or a rating envelope.
*
* It was not intermittent and it was not the browser. The route was hard-coded
* in the consumer, in atlasUrlV9_5_1(), and the contract published nothing
* about which receiver was canonical for that route to disagree with. This
* proof is the thing that was missing.
*
* It runs OFFLINE. No socket is opened. That is deliberate: the workflow that
* rewrites links is only permitted to run after this has passed on the
* machine, and a gate that needs the network cannot gate anything when the
* network is what has changed.
*
* Run: node proofs/deeplink-receiver.proof.mjs
*/
import { readFileSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import {
CANONICAL_RECEIVER,
RETIRED_RECEIVERS,
isRetiredReceiver,
buildDeepLink,
auditProjectRows
} from '../deeplink/contract.js';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const checks = [];
const check = (name, ok, detail = '') => checks.push({ name, ok: Boolean(ok), detail });
/* 1. The contract states a canonical receiver at all. */
check('the contract names a canonical receiver',
typeof CANONICAL_RECEIVER === 'string' && CANONICAL_RECEIVER.length > 0,
CANONICAL_RECEIVER);
check('the canonical receiver is the v9 Atlas, which is what carries the cartridges',
CANONICAL_RECEIVER === 'https://ventusltd.github.io/gridatlas/atlas/',
CANONICAL_RECEIVER);
/* 2. The retired one is named, so it can be refused rather than remembered. */
check('the V8 overlay is named as retired',
RETIRED_RECEIVERS.includes('https://globalgrid2050.com/repd_grid_atlasv8/'),
RETIRED_RECEIVERS.join(', '));
check('a retired receiver is recognised with or without a trailing slash',
isRetiredReceiver('https://globalgrid2050.com/repd_grid_atlasv8')
&& isRetiredReceiver('https://globalgrid2050.com/repd_grid_atlasv8/'),
'trailing slash ignored');
check('a retired receiver is recognised when the consumer has appended parameters',
isRetiredReceiver('https://globalgrid2050.com/repd_grid_atlasv8/?repd_ref=8162&technology=solar'),
'this is the exact shape atlasUrlV9_5_1 produced');
check('the canonical receiver is not itself flagged retired',
!isRetiredReceiver(CANONICAL_RECEIVER), CANONICAL_RECEIVER);
/* 3. The single-argument form, which is what every consumer should use. */
const longfield = {
repd_ref: '8162', project: 'Longfield', technology: 'solar',
capacity_mw: '500', latitude: '51.7831862', longitude: '0.5449877', zoom: '12'
};
const built = buildDeepLink(longfield);
check('buildDeepLink(project) supplies the canonical receiver itself',
built.startsWith(CANONICAL_RECEIVER), built.slice(0, 64));
check('it carries the REPD identity, which is what the arrival resolves on',
built.includes('repd_ref=8162'), 'repd_ref=8162');
check('it carries the supplied point',
built.includes('latitude=51.7831862') && built.includes('longitude=0.5449877'),
'latitude and longitude preserved');
/* 4. The refusal. This is the check that would have caught the live fault. */
let refused = false;
let refusalMessage = '';
try {
buildDeepLink('https://globalgrid2050.com/repd_grid_atlasv8/', longfield);
} catch (error) {
refused = true;
refusalMessage = String(error.message);
}
check('building against the retired receiver throws rather than returning a dead link',
refused, refusalMessage.slice(0, 96));
check('the refusal names the receiver to use instead',
refusalMessage.includes(CANONICAL_RECEIVER),
'the message is actionable, not just a rejection');
/* 5. receivers.json and the module must not drift apart. The JSON is the form
a consumer reads when it cannot import this module, so a difference
between them is two contracts wearing one name. */
const published = JSON.parse(readFileSync(path.join(ROOT, 'deeplink', 'receivers.json'), 'utf8'));
check('receivers.json agrees with the module on the canonical route',
published.canonical && published.canonical.route === CANONICAL_RECEIVER,
published.canonical && published.canonical.route);
check('receivers.json agrees with the module on what is retired',
Array.isArray(published.retired)
&& published.retired.map((r) => r.route).sort().join('|') === [...RETIRED_RECEIVERS].sort().join('|'),
(published.retired || []).map((r) => r.route).join(', '));
check('the retired entry records that it carries no engine',
(published.retired || []).every((r) => r.carries_engine === false),
'carries_engine: false');
/* 6. The query: every row with an REPD identity, and the link it should have.
Asserted on a fixture that contains each case the live corpus contains —
a good row, a row already on the retired receiver, a row with an identity
but no geometry (28 of the 7,680 in v9.5.1), and a row with no identity
at all. A check built only from rows that already pass cannot fail. */
const audit = auditProjectRows([
longfield,
{ ...longfield, repd_ref: '12588', href: 'https://globalgrid2050.com/repd_grid_atlasv8/?repd_ref=12588' },
{ repd_ref: '9999', project: 'No geometry' },
{ project: 'No identity', latitude: '51', longitude: '0' }
]);
check('the query finds every row carrying an REPD identity', audit.with_identity === 3, `${audit.with_identity} of ${audit.total}`);
check('a row with an identity but no geometry is reported, never silently skipped',
audit.no_geometry === 1 && audit.entries[2].linkable === false, `${audit.no_geometry} without geometry`);
check('a row with no REPD identity is not given a link',
audit.entries[3].expected_href === null, 'no identity, no link');
check('a row already pointing at the retired receiver is counted',
audit.on_retired_receiver === 1, `${audit.on_retired_receiver} on a retired receiver`);
check('that row is marked as needing an update, with the link it should have',
audit.needs_update === 1 && audit.entries[1].expected_href.startsWith(CANONICAL_RECEIVER),
audit.entries[1].expected_href.slice(0, 64));
/* 7. Offline. The workflow that rewrites links may only run after this has
passed on the machine, so the code it gates must not need a network to
reach a verdict.
Assert it of the CONTRACT — the module the audit and the updater both
run — rather than of this file. The first version of this check read its
own source and failed on the regex literal inside itself, which is the
same class of mistake as a check that fails on its own prose. */
const contractSource = readFileSync(path.join(ROOT, 'deeplink', 'contract.js'), 'utf8');
check('the contract opens no socket, so the audit runs offline',
!/\bfetch\s*\(|node:https|node:http\b|XMLHttpRequest/.test(contractSource),
'no network call in deeplink/contract.js');
let failed = 0;
for (const c of checks) {
if (!c.ok) failed += 1;
console.log(`${c.ok ? 'ok ' : 'FAIL'} ${c.name}${c.detail ? ' -- ' + c.detail : ''}`);
}
console.log(`\n${checks.length - failed}/${checks.length} checks passed`);
if (failed) {
console.error(`${failed} FAILED`);
process.exit(1);
}Deeplink Proof
A JavaScript module in the proofs folder of Ventus Grid Engine covering solar and wind, and uses data from the GridAtlas repository. It is built from the check step (`check`).
otherventus-grid-engine / proofs/deeplink.proof.mjs · lines 1–128 of 128 · Not reached from any entry point (candidate for review)
- What it does
- It lists and searches solar and wind. Defines check. Side effects: starts processes.
- Why it exists in the grid workflow
- Domain terms in the code: solar, wind.
- What it achieves
- The contract that broke a third of the register, held to itself so it cannot break the same way twice.
- Why it matters
- No other file in the estate was found to import it.
- Application
- ventus-grid-engine · proofs · JavaScript module
- Uses
- Contract (import), GridAtlas — Atlas Page (estate URL)
- Used by
- none found
- Produces
- check
- Defines here
- check
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 proofs/deeplink.proof.mjs:1-128 · blob d0d60cb7cc7adb9117bf55ccda8ec539ed785fde · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: unknown · effects: process · domain stage: unknown · users: none · canonical: unreached_review
/* deeplink.proof.mjs — the contract that broke a third of the register, held
* to itself so it cannot break the same way twice.
*
* Run: node proofs/deeplink.proof.mjs
*/
import {
IDENTITY_PARAM, PARAMS, BUCKETS, REPD_LAYER_IDS, LAYER_ID_FOR_BUCKET,
layerIdForBucket, bucketHasLayer, buildDeepLink, parseDeepLink
} from '../deeplink/contract.js';
const failures = [];
let passed = 0;
const check = (name, condition) => {
if (condition) passed += 1;
else failures.push(name);
};
const BASE = 'https://ventusltd.github.io/gridatlas/atlas/';
/* ── Identity ───────────────────────────────────────────────────────────── */
check('the project identity parameter is repd_ref, not repd_id — both names '
+ 'exist in the estate and they are not interchangeable',
IDENTITY_PARAM === 'repd_ref' && 'repd_ref' in PARAMS && !('repd_id' in PARAMS));
check('a link cannot be built without the identity, because a MAP button that '
+ 'names no project is a button that cannot be honoured',
(() => { try { buildDeepLink(BASE, { technology: 'solar' }); return false; }
catch { return true; } })());
/* ── The three buckets that failed 100% on v9.108 ───────────────────────── */
check('wind_onshore resolves to the engine layer that actually exists, `wind`',
layerIdForBucket('wind_onshore') === 'wind' && bucketHasLayer('wind_onshore'));
check('wind_offshore resolves to the same real `wind` layer — this is the '
+ 'bucket Berwick Bank arrives on, the first MAP button on the page',
layerIdForBucket('wind_offshore') === 'wind' && bucketHasLayer('wind_offshore'));
check('the engine has never had a layer named wind_onshore or wind_offshore, '
+ 'which is precisely why looking one up by that name failed every time',
!REPD_LAYER_IDS.includes('wind_onshore') && !REPD_LAYER_IDS.includes('wind_offshore')
&& REPD_LAYER_IDS.includes('wind'));
check('`other` short-circuits honestly to null rather than searching for a '
+ 'layer that does not exist and then reporting success',
layerIdForBucket('other') === null && bucketHasLayer('other') === false);
check('the failing case is distinguishable from the working one: a caller can '
+ 'tell "no layer exists" apart from "a layer exists and is enabled", '
+ 'which the v9.108 set-membership test could not',
bucketHasLayer('other') === false && bucketHasLayer('solar') === true);
/* ── Every other bucket maps to itself, and that must stay true ─────────── */
const selfMapping = BUCKETS.filter(b => !(b in LAYER_ID_FOR_BUCKET));
check('every bucket outside the correction table maps to itself unchanged, '
+ 'because those names already match a real engine layer id',
selfMapping.length > 0 && selfMapping.every(b => layerIdForBucket(b) === b));
check('and every one of those self-mapped buckets really does name a layer '
+ 'the engine has — if this fails, a new bucket was added to Pipeline News '
+ 'without a layer or a table entry, which is exactly the v9.108 shape',
selfMapping.every(b => REPD_LAYER_IDS.includes(b)));
check('the correction table covers every bucket that does NOT name a real '
+ 'layer, so no bucket can fall through to a lookup that cannot succeed',
BUCKETS.every(b => (b in LAYER_ID_FOR_BUCKET) || REPD_LAYER_IDS.includes(b)));
/* ── Round trip ─────────────────────────────────────────────────────────── */
const berwick = { repd_ref: '9873', technology: 'wind_offshore',
latitude: 56.05, longitude: -2.35, zoom: 9 };
const link = buildDeepLink(BASE, berwick);
const parsed = parseDeepLink(link);
check('a built link carries the identity under the name the receiver reads',
link.includes('repd_ref=9873'));
check('a link round-trips: what the emitter sent is what the receiver reads',
parsed.repd_ref === '9873' && parsed.technology === 'wind_offshore'
&& parsed.latitude === 56.05 && parsed.longitude === -2.35 && parsed.zoom === 9);
check('the receiver reports the resolved layer alongside the requested bucket, '
+ 'so the two are never confused for each other again',
parsed.layer_id === 'wind' && parsed.technology === 'wind_offshore'
&& parsed.layer_exists === true);
check('an `other` arrival parses cleanly and says plainly that no layer exists',
(() => { const p = parseDeepLink(buildDeepLink(BASE,
{ repd_ref: '1', technology: 'other' }));
return p.layer_id === null && p.layer_exists === false && p.known_bucket === true; })());
check('an unknown technology is reported as unknown rather than silently '
+ 'accepted, so a new Pipeline News bucket surfaces here first',
(() => { const p = parseDeepLink(BASE + '?repd_ref=1&technology=fusion');
return p.known_bucket === false && p.layer_exists === false; })());
/* ── Absent and malformed parameters ────────────────────────────────────── */
check('optional coordinates are absent as null, never NaN and never zero — '
+ 'zero is a real coordinate off the coast of Ghana, not a missing value',
(() => { const p = parseDeepLink(BASE + '?repd_ref=1&technology=solar');
return p.latitude === null && p.longitude === null && p.zoom === null; })());
check('a malformed coordinate is null rather than NaN, so a camera never flies '
+ 'to nowhere',
(() => { const p = parseDeepLink(BASE + '?repd_ref=1&technology=solar&latitude=abc');
return p.latitude === null; })());
check('a genuine zero coordinate survives and is not mistaken for absent',
parseDeepLink(BASE + '?repd_ref=1&technology=solar&latitude=0').latitude === 0);
check('empty optional values are dropped from the built URL rather than sent '
+ 'as empty strings the receiver has to special-case',
!buildDeepLink(BASE, { repd_ref: '1', technology: 'solar', latitude: '' })
.includes('latitude='));
/* ── Report ─────────────────────────────────────────────────────────────── */
if (failures.length) {
console.error('deeplink proof FAILED (' + failures.length + ' of '
+ (failures.length + passed) + '):\n- ' + failures.join('\n- '));
process.exit(1);
}
console.log('deeplink proof PASS — ' + passed + ' checks');
export default { status: 'PASS', checks: passed };Diversified Demand Proof
A JavaScript module in the proofs folder of Ventus Grid Engine. It is built from the check step (`check`), the near step (`near`) and the throws step (`throws`).
energy-dataventus-grid-engine / proofs/diversified-demand.proof.mjs · lines 1–127 of 127 · Not reached from any entry point (candidate for review) · pattern throws (shared by 12 files)
- What it does
- It lists and searches its content. Defines check, near, throws. Side effects: changes the web page (DOM); starts processes.
- What it achieves
- The peak of the sum is not the sum of the peaks, and the average across a window is not the peak inside it. Its code works with 14 GW, 7 kW and 210 kW.
- Why it matters
- No other file in the estate was found to import it.
- Application
- ventus-grid-engine · proofs · JavaScript module
- Uses
- Diversified Demand (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/diversified-demand.proof.mjs:1-127 · blob 13885b6c7738caa320c7e54860e4b8e914e82abe · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, process · domain stage: unknown · users: none · canonical: unreached_review
/* diversified-demand.proof.mjs — the peak of the sum is not the sum of the
* peaks, and the average across a window is not the peak inside it. Both
* confusions size networks wrongly, in opposite directions.
*
* Run: node proofs/diversified-demand.proof.mjs
*/
import * as mod from '../engine/diversified-demand.js';
const { schema, NOT_COMPUTED, diversifiedDemandKw, impliedCoincidence,
averageOverWindowGw, populationEnergyTwh } = 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.diversified-demand.v1');
/* ── The paper's EV population. ─────────────────────────────────────────── */
check('10 million vehicles at 2,500 kWh a year is 25 TWh (paper: 25)',
near(populationEnergyTwh({ unitCount: 10_000_000, perUnitKwhPerYear: 2500 }).value, 25, 1e-9));
/* The three figures the paper prints for that same population, which are three
DIFFERENT quantities and are routinely conflated. */
{
/* 25 TWh across a full year. */
const annual = 25 / 8.76;
check('25 TWh averages 2.85 GW across the year (paper: 2.85)', near(annual, 2.85, 0.01));
/* 25 TWh across an eight-hour nightly window. */
const win = averageOverWindowGw({ annualTwh: 25, windowHoursPerDay: 8 });
check('25 TWh inside an 8-hour nightly window averages 8.56 GW (paper: 8.56)',
near(win.value, 8.56, 0.01));
check('the window figure says in words that it is an average and not a peak',
/AVERAGE, not a peak/i.test(win.basis));
/* Unrestricted simultaneous draw, and the paper's 20% coincidence. */
const unrestricted = diversifiedDemandKw({ unitCount: 10_000_000, perUnitKw: 7, coincidenceFactor: 1 });
check('10 million 7 kW chargers could draw 70 GW between them (paper: 70 GW simultaneous)',
near(unrestricted.value / 1e6, 70, 1e-9));
const admd = diversifiedDemandKw({ unitCount: 10_000_000, perUnitKw: 7, coincidenceFactor: 0.2 });
check('at 20% coincidence the same population presents 14 GW (paper: 14 GW)',
near(admd.value / 1e6, 14, 1e-9));
/* The spread between the three is the point: 2.85, 8.56 and 14 GW all
describe the same vehicles. Quoting the wrong one sizes the network
wrongly by a factor of five. */
check('the three quantities for one population differ by roughly a factor of five, '
+ 'which is why they must not be collapsed',
near(admd.value / 1e6 / annual, 4.91, 0.05));
}
/* ── Diversity itself. ──────────────────────────────────────────────────── */
check('the unrestricted total travels back with the answer, so the diversity applied is visible',
diversifiedDemandKw({ unitCount: 100, perUnitKw: 7, coincidenceFactor: 0.3 }).from.unrestrictedKw === 700);
check('100 homes with 7 kW chargers at 0.3 coincidence present 210 kW, not 700',
diversifiedDemandKw({ unitCount: 100, perUnitKw: 7, coincidenceFactor: 0.3 }).value === 210);
check('a coincidence factor of 1 is permitted and means no diversity at all',
diversifiedDemandKw({ unitCount: 100, perUnitKw: 7, coincidenceFactor: 1 }).value === 700);
check('the basis warns that the factor belongs to a group of this size',
/group of THIS size/i.test(diversifiedDemandKw({ unitCount: 10, perUnitKw: 7, coincidenceFactor: 0.6 }).basis));
/* The honest direction: measure the factor, do not assume it. */
{
const imp = impliedCoincidence({ unitCount: 100, perUnitKw: 7, measuredGroupPeakKw: 210 });
check('a measured 210 kW peak on 100 x 7 kW implies a coincidence factor of 0.3',
near(imp.value, 0.3, 1e-12));
check('measuring and assuming are exact inverses',
near(diversifiedDemandKw({ unitCount: 100, perUnitKw: 7, coincidenceFactor: imp.value }).value, 210, 1e-9));
check('the measured basis says it is measured rather than assumed',
/Measured, not assumed/i.test(imp.basis));
}
/* ── Heat pumps, the paper's cold-period case. ──────────────────────────── */
check('10 million homes at 5 kW with full coincidence in a cold snap is 50 GW; '
+ 'at the paper\'s 25 GW the implied coincidence is 0.5',
near(impliedCoincidence({ unitCount: 10_000_000, perUnitKw: 5, measuredGroupPeakKw: 25_000_000 }).value, 0.5, 1e-12));
/* ── Input discipline. ──────────────────────────────────────────────────── */
check('a coincidence factor of 20 is refused, and the message says to pass 0.2',
throws(() => diversifiedDemandKw({ unitCount: 100, perUnitKw: 7, coincidenceFactor: 20 }), /fraction.*0\.2/s));
check('a fractional unit count is refused — half a house is not a load',
throws(() => diversifiedDemandKw({ unitCount: 10.5, perUnitKw: 7, coincidenceFactor: 0.3 }), /whole number/));
check('a window longer than a day is refused',
throws(() => averageOverWindowGw({ annualTwh: 25, windowHoursPerDay: 30 }), /at most 24/));
check('a measured group peak above the unrestricted total is refused as impossible',
throws(() => impliedCoincidence({ unitCount: 10, perUnitKw: 7, measuredGroupPeakKw: 100 }),
/cannot draw more than all its units/));
check('a non-numeric input is refused by type rather than coerced',
throws(() => populationEnergyTwh({ unitCount: '100', perUnitKwhPerYear: 2500 }), /finite number/));
/* ── Refusals. ──────────────────────────────────────────────────────────── */
{
const callable = Object.keys(mod).filter(k => typeof mod[k] === 'function');
check('no function derives a coincidence factor from first principles',
!callable.some(n => /^(estimate|derive|assume|default)Coincidence/i.test(n)));
check('no function decides whether a group can be connected',
callable.every(n => !/fits|canConnect|available|headroom/i.test(n)));
check('the refusals name all four boundaries',
['coincidenceFromFirstPrinciples', 'peakInsideAWindow', 'whetherTheGroupFits', 'futureCoincidence']
.every(k => k in NOT_COMPUTED));
check('the refusals are readable reasons rather than labels',
Object.values(NOT_COMPUTED).every(v => typeof v === 'string' && v.length > 60));
check('the refusals warn that measured coincidence does not survive a change in control',
/smart charging|time-of-use|vehicle-to-grid/i.test(NOT_COMPUTED.futureCoincidence));
}
if (failures.length) {
console.error('diversified-demand proof FAILED (' + failures.length + ' of '
+ (failures.length + passed) + '):\n- ' + failures.join('\n- '));
process.exit(1);
}
console.log('diversified-demand proof PASS — ' + passed + ' checks');
export default { status: 'PASS', checks: passed };