In this section
- Build Graph render · ventus-grid-engine / genome/build-graph.mjs lines 1–405
- Browser Observer Proof other · ventus-grid-engine / proofs/browser-observer.proof.mjs lines 1–25
- Compute Observer Proof transform · ventus-grid-engine / proofs/compute-observer.proof.mjs lines 1–92
- Connection Capacity Proof energy-data · ventus-grid-engine / proofs/connection-capacity.proof.mjs lines 1–154
Build Graph
A JavaScript module in the genome folder of Ventus Grid Engine covering maths provenance, engine graph and battery storage (BESS), using haversine and SHA-256. Served with the page at https://ventusltd.github.io/ventus-grid-engine/genome/.
renderventus-grid-engine / genome/build-graph.mjs · lines 1–405 of 405 · Entry point
- What it does
- Uses libraries node:fs, node:url, node:path. Side effects: changes the web page (DOM); reads or writes files.
- Why it exists in the grid workflow
- Domain terms in the code: battery storage (BESS), substations.
- Inputs & outputs
- In: JSON file v9-maths-provenance.json. Out: JSON file engine-graph.json.
- Downstream impact
- Used directly by 1 file: Genome Workflow (ventus-grid-engine). It is itself an entry point, published at https://ventusltd.github.io/ventus-grid-engine/genome/.
- What it achieves
- Generates `genome/engine-graph.json` from a named node/edge list, so edges are written by name (not by hand-counted array index) and a transcription error becomes a ReferenceError instead of a wrong edge. Its code works with 10.3 GW, 14 GW and 156 kVA.
- Why it matters
- Run by Genome Workflow.
- Application
- ventus-grid-engine · genome · JavaScript module
- Uses
- Geo Core (estate URL), Geo Area (estate URL), Geo Shapes (estate URL), Geo GeoJSON (estate URL), V9 Geodesy (estate URL), V9 Nearest Search (estate URL), Contract (estate URL), Network Topology (estate URL), and 32 more, node:fs, node:url, node:path
- Used by
- run by Genome Workflow (workflow run)
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 genome/build-graph.mjs:1-405 · blob d899ccaba93b68a9e0cdf9b8f413ef8438db2418 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem · domain stage: unknown · users: none · canonical: production_core
/* build-graph.mjs — generates genome/engine-graph.json from a named node/edge
* list, so edges are written by name (not by hand-counted array index) and a
* transcription error becomes a ReferenceError instead of a wrong edge.
*
* This script is NOT part of verify.mjs and is not a proof. It is a one-time
* (and CI-rerunnable) generator, matching the brief's request that the CI
* workflow "regenerates the graph". Run manually with:
* node genome/build-graph.mjs
*/
import { writeFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
const here = dirname(fileURLToPath(import.meta.url));
// ---------------------------------------------------------------------------
// Nodes. `id` is the stable key edges reference below; `type` drives the
// badge/colour in genome/index.html (see its BADGE/RAG/ECSS tables, which
// extend — not replace — the Spider Sandbox vocabulary read from
// data-federation-map-for-globalgrid2050-all-repos/dashboard/sandbox/spider_full_po_test.html).
const nodes = [
// ---- Canonical, ventus-grid-engine/engine + deeplink (rag: green) ----
{ id: 'geo-core', label: 'engine/geo-core.js', type: 'canonical', rag: 'green',
reason: 'the one haversine + R_ATLAS/R_UK/R_MEAN, (lon,lat) order',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/geo-core.js' },
{ id: 'geo-area', label: 'engine/geo-area.js', type: 'canonical', rag: 'green',
reason: 'polygonAreaKm2, polylinePerimeterKm, circleCapAreaKm2',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/geo-area.js' },
{ id: 'geo-shapes', label: 'engine/geo-shapes.js', type: 'canonical', rag: 'green',
reason: 'destinationCirclePoints, the deduplicated circle generator',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/geo-shapes.js' },
{ id: 'geo-geojson', label: 'engine/geo-geojson.js', type: 'canonical', rag: 'green',
reason: 'circleFeatureCollection, GeoJSON shaping kept out of the maths',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/geo-geojson.js' },
{ id: 'v9-geodesy', label: 'engine/v9-geodesy.js', type: 'canonical', rag: 'green',
reason: 'distanceKm, destinationPoint, initialBearingDeg, voltagesKv, representativePoint',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/v9-geodesy.js' },
{ id: 'v9-nearest-search', label: 'engine/v9-nearest-search.js', type: 'canonical', rag: 'green',
reason: 'normalise + index, exhaustive scan, proven free of the ring-search bug',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/v9-nearest-search.js' },
{ id: 'deeplink-contract', label: 'deeplink/contract.js', type: 'canonical', rag: 'green',
reason: 'buildDeepLink/parseDeepLink, LAYER_ID_FOR_BUCKET, the MAP button as one testable thing',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/deeplink/contract.js' },
{ id: 'network-topology', label: 'engine/network-topology.js', type: 'canonical', rag: 'green',
reason: 'PROMOTED this session: index/at/graph over one site’s published nodes/branches',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/network-topology.js' },
{ id: 'electrical-distance', label: 'engine/electrical-distance.js', type: 'canonical', rag: 'green',
reason: 'PROMOTED this session: between/within, BFS hop-count over network-topology.graph()',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/electrical-distance.js' },
{ id: 'rating-envelope', label: 'engine/rating-envelope.js', type: 'canonical', rag: 'green',
reason: 'PROMOTED this session: at(), per-season lowest/highest range, never summed',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/rating-envelope.js' },
{ id: 'corridor-estimate', label: 'engine/corridor-estimate.js', type: 'canonical', rag: 'green',
reason: 'PROMOTED this session: forCable(), calibrated straight-line-to-corridor multiplier',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/corridor-estimate.js' },
{ id: 'published-fault-level', label: 'engine/published-fault-level.js', type: 'canonical', rag: 'green',
reason: 'AUTHORED 2026-09-05: record() and quote() for a fault figure that is published, dated and named by exact metric; no callable computes a current or a headroom, and the proof asserts that absence. Vocabulary copied from data-grid-gb ingest_etys.py FAULT_COLUMNS.',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/published-fault-level.js' },
{ id: 'electrification-demand', label: 'engine/electrification-demand.js', type: 'canonical', rag: 'green',
reason: 'AUTHORED 2026-09-06: the arithmetic of the electrification paper made exact — average power, peak from a stated load factor, load factor measured from a published peak, nameplate at a capacity factor, and electricity for displaced fuel. Every worked example in the paper is recomputed by the proof. No callable returns headroom, connection availability, per-site uplift or adequacy, and … [line shortened here: 433 characters; full line on GitHub]
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/electrification-demand.js' },
{ id: 'firm-capacity', label: 'engine/firm-capacity.js', type: 'canonical', rag: 'green',
reason: 'AUTHORED 2026-09-06: N-1 firm capacity, apparent power from a stated power factor, and utilisation against a caller-supplied rating. Exposes the gap the paper names - a site at 42 MVA on two 30 MVA units is 70% of installed and 140% of firm. Refuses spare capacity, connection availability, cyclic ratings and P2/7 compliance; the proof asserts that absence.',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/firm-capacity.js' },
{ id: 'diversified-demand', label: 'engine/diversified-demand.js', type: 'canonical', rag: 'green',
reason: 'AUTHORED 2026-09-06: After Diversity Maximum Demand, coincidence measured from a group peak rather than assumed, and average-across-a-window kept separate from peak-inside-a-window. The 10 million vehicles in the paper read 2.85 GW annual average, 8.56 GW across an 8-hour window and 14 GW at 20% coincidence - the same vehicles, differing by a factor of five.',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/diversified-demand.js' },
{ id: 'connection-capacity', label: 'engine/connection-capacity.js', type: 'canonical', rag: 'green',
reason: 'AUTHORED 2026-09-06: sizing against a STATED connection cap for developers, EPCs and heavy users. Exceedance over a profile, battery power from the peak excess and store from the area above the cap, solar clipping, and net position against separate import/export caps. A spike and a plateau share a peak and need eight times the store; the proof holds both.',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/connection-capacity.js' },
{ id: 'route-obstacles', label: 'engine/route-obstacles.js', type: 'canonical', rag: 'green',
reason: 'AUTHORED 2026-09-06: the check a scalar corridor function could not make. corridor-estimate.forCable() takes one kilometre and never sees coordinates, so it printed 177.05 km of highway corridor for South Antrim to Western HVDC - 142 km of Irish Sea. This module classifies declared crossings, refuses a corridor factor across open water, and sizes trenchless crossings where the setback … [line shortened here: 528 characters; full line on GitHub]
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/route-obstacles.js' },
{ id: 'interconnector-economics', label: 'engine/interconnector-economics.js', type: 'canonical', rag: 'green',
reason: 'AUTHORED 2026-09-06: an interconnector as an edge between two systems, priced. Direction follows the spread, congestion rent is gross and never called profit, and fleet capacity separates the 10.3 GW that carries a BMRS code and is observable from the 7.65 GW that is a plan. Holds NO geometry: subsea routes are licensed (TeleGeography) and neither NESO nor National Grid publishes an a … [line shortened here: 497 characters; full line on GitHub]
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/interconnector-economics.js' },
{ id: 'power-factor', label: 'engine/power-factor.js', type: 'canonical', rag: 'green',
reason: 'AUTHORED 2026-09-06: the cheapest capacity anybody buys. 1,000 kW at 0.85 draws 1,176 kVA; corrected to 0.98 it draws 1,020 and releases 156 kVA - 13.3% of the site demand on its connection, for no reduction in consumption. Reactive power is computed from the identity rather than arccos/tan so unity is exactly zero. Refuses capacitor bank design, because a real bank needs a harmonic r … [line shortened here: 446 characters; full line on GitHub]
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/power-factor.js' },
{ id: 'voltage-drop', label: 'engine/voltage-drop.js', type: 'canonical', rag: 'green',
reason: 'AUTHORED 2026-09-06: volts and watts along a run, which decides cable size on a long collection more often than ampacity does. Phase factor is sqrt(3) or 2 and never typed as 1.73; the reactance term is carried against sin(phi), because ignoring X on a large cable feeding a poorly corrected load under-states the drop by over a third. Losses take only R, and the loss load factor is req … [line shortened here: 566 characters; full line on GitHub]
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/engine/voltage-drop.js' },
// ---- Staged, unpromoted (rag: blue) ----
{ id: 'sizing-arithmetic-extract', label: 'sources/v9-extracts/sizing-arithmetic.mjs', type: 'extract', rag: 'blue',
reason: 'staged verbatim, promotion DECLINED this session — impure + financial-domain, see population-plan.md §4',
gh: 'https://github.com/Ventusltd/ventus-grid-engine/blob/main/sources/v9-extracts/sizing-arithmetic.mjs' },
// ---- Fragments: geodesy / haversine family ----
{ id: 'v8-haversine', label: 'ventus-corev8engine.js haversine()', type: 'fragment', rag: 'green',
reason: 'the one distance primitive in the V8 monolith, correctly reused everywhere — not duplicated',
gh: 'https://github.com/Ventusltd/globalgrid2050/blob/main/repd_grid_atlasv8/ventus-corev8engine.js#L45-L50' },
{ id: 'gridatlas-geodesy-module', label: 'gridatlas 202609011950-geodesy.js', type: 'fragment', rag: 'green',
reason: 'live, composed module; source that engine/v9-geodesy.js was extracted from, byte-identical',
gh: 'https://github.com/Ventusltd/gridatlas/blob/main/atlas/modules/202609011950-geodesy.js' },
{ id: 'gridatlas-cartridge-geodesy-1', label: 'substation-intelligence cartridge, geodesy copy #1', type: 'fragment', rag: 'amber',
reason: 'inline legacy V8 haversine at line 57 of a 6,277-line composed cartridge',
gh: 'https://github.com/Ventusltd/gridatlas/blob/main/atlas/cartridges/202609041330-substation-intelligence-v9-63.js#L57-L71' },
{ id: 'gridatlas-cartridge-geodesy-2', label: 'substation-intelligence cartridge, geodesy copy #2', type: 'fragment', rag: 'amber',
reason: 'a SECOND inline NS.geodesy IIFE at line 1544 of the SAME file as copy #1',
gh: 'https://github.com/Ventusltd/gridatlas/blob/main/atlas/cartridges/202609041330-substation-intelligence-v9-63.js#L1541-L1550' },
{ id: 'neon-links-geodesy', label: 'neon-substation-links-v9-6.js R_ATLAS/distanceKm', type: 'fragment', rag: 'amber',
reason: 'hand-rolled constant and distance function, own comment: “the house constant”',
gh: 'https://github.com/Ventusltd/gridatlas/blob/main/atlas/cartridges/202608311910-neon-substation-links-v9-6.js#L120' },
{ id: 'pipelinenews-grid-proximity-geodesy', label: 'grid-proximity/build_payload.py haversine_km()', type: 'fragment', rag: 'amber',
reason: 'hand-rolled A_WGS84/R_ATLAS + haversine_km, does not import grid-distance-maths despite a sibling cartridge doing so',
gh: 'https://github.com/Ventusltd/pipelinenews/blob/main/tools/intelligence/cartridges/grid-proximity/build_payload.py#L44-L90' },
{ id: 'pipelinenews-grid-distance-column', label: 'grid-distance-column/build_payload.py', type: 'fragment', rag: 'green',
reason: 'the POSITIVE control: imports grid-distance-maths/src/geodesy.py directly and refuses to run without it',
gh: 'https://github.com/Ventusltd/pipelinenews/blob/main/tools/intelligence/cartridges/grid-distance-column/build_payload.py#L50-L69' },
{ id: 'grid-distance-maths-geodesy', label: 'grid-distance-maths/src/geodesy.mjs', type: 'reference', rag: 'blue',
reason: 'the estate’s canonical geodesy repository — R_ATLAS/R_UK/R_MEAN identical to geo-core.js, by design',
gh: 'https://github.com/Ventusltd/grid-distance-maths/blob/main/src/geodesy.mjs' },
// ---- Fragments: area / circle-point (V8 monolith) ----
{ id: 'v8-area-a', label: 'ventus-corev8engine.js _zoneDrawCalcArea (Impl A)', type: 'fragment', rag: 'green',
reason: 'spherical-excess polygon area, Zone Draw tool',
gh: 'https://github.com/Ventusltd/globalgrid2050/blob/main/repd_grid_atlasv8/ventus-corev8engine.js#L134-L149' },
{ id: 'v8-area-b', label: 'ventus-corev8engine.js updateMeasureDisplay (Impl B)', type: 'fragment', rag: 'amber',
reason: 'the identical shoelace-on-sphere formula, copy-pasted into the Measure tool',
gh: 'https://github.com/Ventusltd/globalgrid2050/blob/main/repd_grid_atlasv8/ventus-corev8engine.js#L481-L490' },
{ id: 'v8-area-c', label: 'ventus-corev8engine.js doRadiusAreaMeasure (Impl C)', type: 'fragment', rag: 'green',
reason: 'spherical-cap area — a different question, correctly kept separate',
gh: 'https://github.com/Ventusltd/globalgrid2050/blob/main/repd_grid_atlasv8/ventus-corev8engine.js#L576-L582' },
{ id: 'v8-circle-a', label: 'ventus-corev8engine.js _zoneDrawCirclePoints', type: 'fragment', rag: 'green',
reason: 'destination-point circle generator, Zone Draw (n=24)',
gh: 'https://github.com/Ventusltd/globalgrid2050/blob/main/repd_grid_atlasv8/ventus-corev8engine.js#L122-L132' },
{ id: 'v8-circle-b', label: 'ventus-corev8engine.js createGeoJSONCircle', type: 'fragment', rag: 'amber',
reason: 'byte-identical destination-point formula, Radius tool (n=64/96/128), plus FeatureCollection wrapping',
gh: 'https://github.com/Ventusltd/globalgrid2050/blob/main/repd_grid_atlasv8/ventus-corev8engine.js#L727-L740' },
// ---- Fragments: sizing-arithmetic double-count bug (5 live copies) ----
{ id: 'sld-calc-v5', label: 'solar-bess-topology-v5/gis-sld-v5-calculations.js', type: 'fragment', rag: 'red',
reason: 'ac_mw_direct double-count bug, line 147, LIVE and unfixed',
gh: 'https://github.com/Ventusltd/globalgrid2050/blob/main/solar-bess-topology-v5/gis-sld-v5-calculations.js#L147' },
{ id: 'sld-calc-v6', label: 'solar-bess-topology-v6/.../gis-sld-v5-calculations.js', type: 'fragment', rag: 'red',
reason: 'the same bug, same line number, byte-identical',
gh: 'https://github.com/Ventusltd/globalgrid2050/blob/main/solar-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-calculations.js#L147' },
{ id: 'sld-calc-v7', label: 'solar-bess-topology-v7/.../gis-sld-v5-calculations.js', type: 'fragment', rag: 'red',
reason: 'the same bug, same line number, byte-identical',
gh: 'https://github.com/Ventusltd/globalgrid2050/blob/main/solar-bess-topology-v7/gis-sld-financial-sandbox/gis-sld-v5-calculations.js#L147' },
{ id: 'sld-calc-v8a', label: 'solar-bess-topology-v8/bess-gis-sld-financial-sandbox/gis-sld-v5-calculations.js', type: 'fragment', rag: 'red',
reason: 'the same bug, same line number, byte-identical',
gh: 'https://github.com/Ventusltd/globalgrid2050/blob/main/solar-bess-topology-v8/bess-gis-sld-financial-sandbox/gis-sld-v5-calculations.js#L147' },
{ id: 'sld-calc-v8b', label: 'solar-bess-topology-v8/bess-pcs-standalone/gis-sld-v5-calculations.js', type: 'fragment', rag: 'red',
reason: 'the same bug, same line number, byte-identical — fifth copy',
gh: 'https://github.com/Ventusltd/globalgrid2050/blob/main/solar-bess-topology-v8/bess-pcs-standalone/gis-sld-v5-calculations.js#L147' },
{ id: 'gridatlas-sizing-arithmetic', label: 'gridatlas 202609012205-sizing-arithmetic.js', type: 'fragment', rag: 'green',
reason: 'the CORRECTED port: Math.min(inverter_ac_total, skid_ac_total) — the fix none of the five above has',
gh: 'https://github.com/Ventusltd/gridatlas/blob/main/atlas/modules/202609012205-sizing-arithmetic.js#L220-L250' },
// ---- Fragments: nearest-search ----
{ id: 'gridatlas-substation-lookup', label: 'gridatlas 202609011950-substation-lookup.js', type: 'fragment', rag: 'grey',
reason: 'committed but DEAD — zero manifests reference it; source engine/v9-nearest-search.js was extracted from',
gh: 'https://github.com/Ventusltd/gridatlas/blob/main/atlas/modules/202609011950-substation-lookup.js' },
{ id: 'gridatlas-cartridge-nearest', label: 'substation-intelligence cartridge, inline nearest()', type: 'fragment', rag: 'red',
reason: 'live duplicate, LESS defensive than the dead module — can throw on a point with no voltages_kv',
gh: 'https://github.com/Ventusltd/gridatlas/blob/main/atlas/cartridges/202609041330-substation-intelligence-v9-63.js#L6014-L6095' },
{ id: 'declared-connections-nearest', label: 'declared-connections.js nearestTransmission()', type: 'fragment', rag: 'amber',
reason: 'hand-rolled running-min scan, correct by construction but not importing the shared search',
gh: 'https://github.com/Ventusltd/gridatlas/blob/main/atlas/modules/202609012128-declared-connections.js#L213-L244' },
{ id: 'pipelinenews-ring-search', label: 'grid-proximity/build_payload.py nearest_segment()/nearest_substations()', type: 'fragment', rag: 'green',
reason: 'the estate’s REFERENCE ring-search: cell-bucketed with a proven early-termination bound; grid-distance-maths credits it as origin',
gh: 'https://github.com/Ventusltd/pipelinenews/blob/main/tools/intelligence/cartridges/grid-proximity/build_payload.py#L190-L299' },
// ---- Fragments: deep-link ----
{ id: 'pipelinenews-spine-emitter', label: 'atlas-pointer-deep-link.mjs buildAtlasV9DeepLink()', type: 'fragment', rag: 'amber',
reason: 'the LIVE emitter app.mjs actually imports; hand-rolls its own URL construction',
gh: 'https://github.com/Ventusltd/pipelinenews/blob/main/releases/202609032329-pipelinenews/assets/202608312037-atlas-pointer-deep-link.mjs#L156-L187' },
{ id: 'pipelinenews-wider-fleet-emitter', label: 'wider-fleet.mjs atlasLink()', type: 'fragment', rag: 'amber',
reason: 'a SECOND, independent emitter for ~20 non-spine technology types; its own URLSearchParams, own code path',
gh: 'https://github.com/Ventusltd/pipelinenews/blob/main/tools/intelligence/cartridges/wider-fleet/assets/wider-fleet.mjs#L58-L70' },
{ id: 'gridatlas-bucket-table', label: 'sld-sandbox-technology-buckets.js LAYER_ID_FOR_BUCKET', type: 'fragment', rag: 'green',
reason: 'the LIVE source table deeplink/contract.js copied verbatim from; the v9.109 100%-failure fix',
gh: 'https://github.com/Ventusltd/gridatlas/blob/main/atlas/parts/202609041234-sld-sandbox-technology-buckets.js#L266-L276' },
{ id: 'gridatlas-v8-delegation', label: 'ventus-corev8engine-exact-repd-delegation.js', type: 'fragment', rag: 'grey',
reason: 'the engine’s OWN former deep-link handler, now inert: publishes DEFERRED_TO_EXACT_REPD_RECEIVER and returns',
gh: 'https://github.com/Ventusltd/gridatlas/blob/main/atlas/parts/202609040229-ventus-corev8engine-exact-repd-delegation.js#L796-L840' },
{ id: 'gridatlas-identity-receiver', label: 'place-global-search-arrival-identity.js receiveExactRepdDeepLink()', type: 'fragment', rag: 'red',
reason: 'the LIVE receiver-side parse — its identity regex is BROADER than the emitter’s, a live pattern drift',
gh: 'https://github.com/Ventusltd/gridatlas/blob/main/atlas/parts/202609040229-place-global-search-arrival-identity.js#L566-L747' },
// ---- Fragments: the composed live sources of the four newly-promoted modules ----
{ id: 'gridatlas-network-topology-live', label: 'gridatlas 202609012245-network-topology.js', type: 'fragment', rag: 'green',
reason: 'live, composed module — the direct source engine/network-topology.js was promoted from',
gh: 'https://github.com/Ventusltd/gridatlas/blob/main/atlas/modules/202609012245-network-topology.js' },
{ id: 'gridatlas-electrical-distance-live', label: 'gridatlas 202609012245-electrical-distance.js', type: 'fragment', rag: 'green',
reason: 'live, composed module — the direct source engine/electrical-distance.js was promoted from',
gh: 'https://github.com/Ventusltd/gridatlas/blob/main/atlas/modules/202609012245-electrical-distance.js' },
{ id: 'gridatlas-rating-envelope-live', label: 'gridatlas 202609012250-rating-envelope.js', type: 'fragment', rag: 'green',
reason: 'live, composed module — the direct source engine/rating-envelope.js was promoted from',
gh: 'https://github.com/Ventusltd/gridatlas/blob/main/atlas/modules/202609012250-rating-envelope.js' },
{ id: 'gridatlas-corridor-estimate-live', label: 'gridatlas 202609030205-corridor-estimate.js', type: 'fragment', rag: 'green',
reason: 'live, composed module — the direct source engine/corridor-estimate.js was promoted from',
gh: 'https://github.com/Ventusltd/gridatlas/blob/main/atlas/modules/202609030205-corridor-estimate.js' },
];
// ---------------------------------------------------------------------------
// Edges. `kind` in {duplicates, supersedes, imports, should_import, drifts_from}.
// `evidence` is mandatory: { file, lines, method }.
const edges = [
// ---- geodesy ----
{ from: 'geo-core', to: 'v8-haversine', kind: 'supersedes',
evidence: { file: 'globalgrid2050/repd_grid_atlasv8/ventus-corev8engine.js', lines: '45-50',
method: 'verbatim extraction, verified by sha256 in sources/provenance.json; docs/v8-duplication.md confirms this was the one undupliated primitive' } },
{ from: 'v9-geodesy', to: 'gridatlas-geodesy-module', kind: 'supersedes',
evidence: { file: 'gridatlas/atlas/modules/202609011950-geodesy.js', lines: '1-145',
method: 'sources/provenance.json: "otherwise byte-identical to the source"; parity asserted bit-for-bit by proofs/v9-engine.proof.mjs' } },
{ from: 'gridatlas-geodesy-module', to: 'gridatlas-cartridge-geodesy-1', kind: 'duplicates',
evidence: { file: 'gridatlas/atlas/cartridges/202609041330-substation-intelligence-v9-63.js', lines: '50-71',
method: 'grep -n EARTH_RADIUS_KM across gridatlas; docs/v9-constants.md row "gridatlas (live cartridge, copy #1)"' } },
{ from: 'gridatlas-cartridge-geodesy-1', to: 'gridatlas-cartridge-geodesy-2', kind: 'duplicates',
evidence: { file: 'gridatlas/atlas/cartridges/202609041330-substation-intelligence-v9-63.js', lines: '57 and 1544',
method: 'docs/v9-constants.md finding 3: two EARTH_RADIUS_KM definitions in the same 6,277-line file' } },
{ from: 'gridatlas-cartridge-geodesy-1', to: 'v9-geodesy', kind: 'should_import',
evidence: { file: 'genome/population-plan.md', lines: '§1, row 1',
method: 'manual review: this inline copy could be replaced by an import with no behaviour change (constants already agree)' } },
{ from: 'gridatlas-cartridge-geodesy-2', to: 'v9-geodesy', kind: 'should_import',
evidence: { file: 'genome/population-plan.md', lines: '§1, row 1',
method: 'same as copy #1 — second inline copy in the same file' } },
{ from: 'neon-links-geodesy', to: 'v9-geodesy', kind: 'duplicates',
evidence: { file: 'gridatlas/atlas/cartridges/202608311910-neon-substation-links-v9-6.js', lines: '120, 174-180',
method: 'docs/v9-duplication.md 2(b) item 2: own comment "Identical in form and constant to ventus-corev8engine.js haversine()"' } },
{ from: 'neon-links-geodesy', to: 'v9-geodesy', kind: 'should_import',
evidence: { file: 'genome/population-plan.md', lines: '§1, row 2', method: 'manual review' } },
{ from: 'pipelinenews-grid-proximity-geodesy', to: 'grid-distance-maths-geodesy', kind: 'duplicates',
evidence: { file: 'pipelinenews/tools/intelligence/cartridges/grid-proximity/build_payload.py', lines: '44-47, 90',
method: 'docs/v9-constants.md row "pipelinenews"; A_WGS84/R_ATLAS hard-coded, matches canonical value exactly (no drift)' } },
{ from: 'pipelinenews-grid-proximity-geodesy', to: 'grid-distance-maths-geodesy', kind: 'should_import',
evidence: { file: 'genome/population-plan.md', lines: '§1, row 3',
method: 'sibling cartridge grid-distance-column/build_payload.py:50-69 already does this in the same directory' } },
{ from: 'pipelinenews-grid-distance-column', to: 'grid-distance-maths-geodesy', kind: 'imports',
evidence: { file: 'pipelinenews/tools/intelligence/cartridges/grid-distance-column/build_payload.py', lines: '50-69',
method: 'source inspection: sys.path.insert + `from geodesy import ...`, raises SystemExit if the canonical repo is not present' } },
{ from: 'geo-core', to: 'grid-distance-maths-geodesy', kind: 'duplicates',
evidence: { file: 'engine/geo-core.js vs grid-distance-maths/src/geodesy.mjs', lines: '50-60 vs 16-27',
method: 'value comparison: R_ATLAS/R_UK/R_MEAN identical to the last published digit; README states this repo follows grid-distance-maths/docs/EARTH-MODEL.md by design, so no drift is expected or found' } },
// ---- area / circle-point ----
{ from: 'geo-area', to: 'v8-area-a', kind: 'supersedes',
evidence: { file: 'globalgrid2050/repd_grid_atlasv8/ventus-corev8engine.js', lines: '134-149',
method: 'sources/provenance.json engine/geo-area.js entry' } },
{ from: 'geo-area', to: 'v8-area-b', kind: 'supersedes',
evidence: { file: 'globalgrid2050/repd_grid_atlasv8/ventus-corev8engine.js', lines: '481-490',
method: 'sources/provenance.json engine/geo-area.js entry: "Implementations A and B verified numerically identical and collapsed"' } },
{ from: 'v8-area-a', to: 'v8-area-b', kind: 'duplicates',
evidence: { file: 'globalgrid2050/repd_grid_atlasv8/ventus-corev8engine.js', lines: '134-149 vs 481-490',
method: 'docs/v8-duplication.md: identical to 8 decimal places on a reference London polygon (0.30664823 km2) and a 1km square' } },
{ from: 'geo-area', to: 'v8-area-c', kind: 'supersedes',
evidence: { file: 'globalgrid2050/repd_grid_atlasv8/ventus-corev8engine.js', lines: '576-582',
method: 'sources/provenance.json: "kept separate and unmerged: different question, correct as written"' } },
{ from: 'geo-shapes', to: 'v8-circle-a', kind: 'supersedes',
evidence: { file: 'globalgrid2050/repd_grid_atlasv8/ventus-corev8engine.js', lines: '122-132',
method: 'sources/provenance.json engine/geo-shapes.js entry' } },
{ from: 'geo-shapes', to: 'v8-circle-b', kind: 'supersedes',
evidence: { file: 'globalgrid2050/repd_grid_atlasv8/ventus-corev8engine.js', lines: '727-740',
method: 'sources/provenance.json engine/geo-shapes.js entry' } },
{ from: 'v8-circle-a', to: 'v8-circle-b', kind: 'duplicates',
evidence: { file: 'globalgrid2050/repd_grid_atlasv8/ventus-corev8engine.js', lines: '122-132 vs 727-740',
method: 'docs/v8-duplication.md: "0 absolute difference over 64 points" between the two destination-point implementations' } },
// ---- sizing-arithmetic: the worst duplication found in this crawl ----
{ from: 'sld-calc-v5', to: 'sld-calc-v6', kind: 'duplicates',
evidence: { file: 'globalgrid2050/solar-bess-topology-v{5,6}/.../gis-sld-v5-calculations.js', lines: '147',
method: 'grep -n "ac_mw_direct = total_blocks \\* central_skid_mva \\* inv_per_mv" across both files, both 170 lines, byte-identical' } },
{ from: 'sld-calc-v5', to: 'sld-calc-v7', kind: 'duplicates',
evidence: { file: 'globalgrid2050/solar-bess-topology-v{5,7}/.../gis-sld-v5-calculations.js', lines: '147',
method: 'grep -n across both files, both 170 lines, byte-identical' } },
{ from: 'sld-calc-v5', to: 'sld-calc-v8a', kind: 'duplicates',
evidence: { file: 'globalgrid2050/solar-bess-topology-v{5,8}/.../gis-sld-v5-calculations.js', lines: '147',
method: 'grep -n across both files, both 170 lines, byte-identical' } },
{ from: 'sld-calc-v5', to: 'sld-calc-v8b', kind: 'duplicates',
evidence: { file: 'globalgrid2050/solar-bess-topology-v5 vs v8/bess-pcs-standalone', lines: '147',
method: 'grep -n across both files, both 170 lines, byte-identical — fifth copy of the same file' } },
{ from: 'sld-calc-v5', to: 'gridatlas-sizing-arithmetic', kind: 'drifts_from',
evidence: { file: 'globalgrid2050/solar-bess-topology-v5/gis-sld-v5-calculations.js:147 vs gridatlas/atlas/modules/202609012205-sizing-arithmetic.js:~230',
method: 'docs/v9-maths-inventory.md §7: shipped defaults give 211.2 MW (bug: total_blocks double-counts inv_per_mv and multiplies by a transformer rating) vs the corrected Math.min(inverter_ac_total=105.6, skid_ac_total=52.8)=52.8 MW' } },
{ from: 'sld-calc-v6', to: 'gridatlas-sizing-arithmetic', kind: 'drifts_from',
evidence: { file: 'globalgrid2050/solar-bess-topology-v6/.../gis-sld-v5-calculations.js:147', lines: '147',
method: 'same bug, same worked numbers, confirmed by direct file read of this copy' } },
{ from: 'sld-calc-v7', to: 'gridatlas-sizing-arithmetic', kind: 'drifts_from',
evidence: { file: 'globalgrid2050/solar-bess-topology-v7/.../gis-sld-v5-calculations.js:147', lines: '147',
method: 'same bug, same worked numbers, confirmed by direct file read of this copy' } },
{ from: 'sld-calc-v8a', to: 'gridatlas-sizing-arithmetic', kind: 'drifts_from',
evidence: { file: 'globalgrid2050/solar-bess-topology-v8/bess-gis-sld-financial-sandbox/gis-sld-v5-calculations.js:147', lines: '147',
method: 'same bug, same worked numbers, confirmed by direct file read of this copy' } },
{ from: 'sld-calc-v8b', to: 'gridatlas-sizing-arithmetic', kind: 'drifts_from',
evidence: { file: 'globalgrid2050/solar-bess-topology-v8/bess-pcs-standalone/gis-sld-v5-calculations.js:147', lines: '147',
method: 'same bug, same worked numbers, confirmed by direct file read of this copy' } },
{ from: 'sizing-arithmetic-extract', to: 'gridatlas-sizing-arithmetic', kind: 'duplicates',
evidence: { file: 'sources/v9-maths-provenance.json', lines: 'extract/sizing-arithmetic.mjs entry',
method: 'verbatim staged copy, promotion declined this session (see population-plan.md §4) — correctly carries the FIXED form, not the bug' } },
// ---- nearest-search ----
{ from: 'v9-nearest-search', to: 'gridatlas-substation-lookup', kind: 'supersedes',
evidence: { file: 'gridatlas/atlas/modules/202609011950-substation-lookup.js', lines: '1-82',
method: 'sources/provenance.json engine/v9-nearest-search.js entry' } },
{ from: 'gridatlas-substation-lookup', to: 'gridatlas-cartridge-nearest', kind: 'duplicates',
evidence: { file: 'gridatlas/atlas/cartridges/202609041330-substation-intelligence-v9-63.js', lines: '6014-6095',
method: 'docs/v9-duplication.md 2(a): full side-by-side diff of normalise() and nearest(), byte-different, semantically near-identical' } },
{ from: 'gridatlas-cartridge-nearest', to: 'v9-nearest-search', kind: 'should_import',
evidence: { file: 'genome/population-plan.md', lines: '§3, row 1', method: 'manual review' } },
{ from: 'gridatlas-cartridge-nearest', to: 'gridatlas-substation-lookup', kind: 'drifts_from',
evidence: { file: 'gridatlas/atlas/cartridges/202609041330-substation-intelligence-v9-63.js:6083-6092 vs atlas/modules/202609011950-substation-lookup.js:57-70',
method: 'docs/v9-duplication.md 2(a) points 2-3: options?.limit ?? 1 vs (options&&options.limit)||1 disagree at limit:0; cartridge lacks the voltages_kv||[] default and can throw where the module cannot — confirmed by proofs/v9-engine.proof.mjs' } },
{ from: 'declared-connections-nearest', to: 'v9-nearest-search', kind: 'duplicates',
evidence: { file: 'gridatlas/atlas/modules/202609012128-declared-connections.js', lines: '213-244',
method: 'docs/v9-duplication.md 2(b) item 3: running-min scan over every candidate' } },
{ from: 'declared-connections-nearest', to: 'v9-nearest-search', kind: 'should_import',
evidence: { file: 'genome/population-plan.md', lines: '§3, row 2', method: 'manual review' } },
{ from: 'pipelinenews-ring-search', to: 'v9-nearest-search', kind: 'duplicates',
evidence: { file: 'pipelinenews/tools/intelligence/cartridges/grid-proximity/build_payload.py', lines: '190-299',
method: 'docs/v9-duplication.md 2(b) item 4: same nearest-node concern, but an INDEXED ring-search rather than v9-nearest-search’s exhaustive scan — algorithmically ahead, not a should_import candidate' } },
// ---- deep-link ----
{ from: 'deeplink-contract', to: 'gridatlas-bucket-table', kind: 'supersedes',
evidence: { file: 'gridatlas/atlas/parts/202609041234-sld-sandbox-technology-buckets.js', lines: '266-276',
method: 'sources/provenance.json deeplink/contract.js entry: "LAYER_ID_FOR_BUCKET and layerIdForBucket copied verbatim from the receiver"' } },
{ from: 'gridatlas-bucket-table', to: 'deeplink-contract', kind: 'should_import',
evidence: { file: 'genome/population-plan.md', lines: '§5, row 3',
method: 'values already agree byte-for-byte; only packaging (composed, SHA-256-verified cartridge) is open' } },
{ from: 'pipelinenews-spine-emitter', to: 'deeplink-contract', kind: 'duplicates',
evidence: { file: 'pipelinenews/.../202608312037-atlas-pointer-deep-link.mjs', lines: '104-187',
method: 'docs/deeplink-contract.md §1a; sources/provenance.json: "buildDeepLink and parseDeepLink are NEW... neither was a reusable function" before this extraction' } },
{ from: 'pipelinenews-spine-emitter', to: 'deeplink-contract', kind: 'should_import',
evidence: { file: 'genome/population-plan.md', lines: '§5, row 1', method: 'manual review' } },
{ from: 'pipelinenews-wider-fleet-emitter', to: 'pipelinenews-spine-emitter', kind: 'duplicates',
evidence: { file: 'pipelinenews/tools/intelligence/cartridges/wider-fleet/assets/wider-fleet.mjs', lines: '58-70',
method: 'docs/deeplink-contract.md §1b: "a SECOND cartridge... builds its own URLSearchParams independently... own code path"' } },
{ from: 'pipelinenews-wider-fleet-emitter', to: 'deeplink-contract', kind: 'should_import',
evidence: { file: 'genome/population-plan.md', lines: '§5, row 1', method: 'manual review' } },
{ from: 'gridatlas-v8-delegation', to: 'deeplink-contract', kind: 'duplicates',
evidence: { file: 'gridatlas/atlas/parts/202609040229-ventus-corev8engine-exact-repd-delegation.js', lines: '796-840',
method: 'docs/deeplink-contract.md §3 Step 2: re-parses repd_ref/technology, validates, then publishes DEFERRED_TO_EXACT_REPD_RECEIVER and returns — inert but structurally a second parser' } },
{ from: 'gridatlas-identity-receiver', to: 'deeplink-contract', kind: 'should_import',
evidence: { file: 'genome/population-plan.md', lines: '§5, row 2', method: 'manual review' } },
{ from: 'gridatlas-identity-receiver', to: 'pipelinenews-spine-emitter', kind: 'drifts_from',
evidence: { file: 'gridatlas/atlas/parts/202609040229-place-global-search-arrival-identity.js:604 vs pipelinenews/.../atlas-pointer-deep-link.mjs:161',
method: 'docs/deeplink-contract.md §3 Step 1 and §1a: receiver regex /^[A-Za-z0-9-]{1,40}$/ vs emitter regex /^\\d+$/ — the receiver silently accepts identities the live emitter would never send' } },
// ---- the composed live sources this session promoted from ----
{ from: 'network-topology', to: 'gridatlas-network-topology-live', kind: 'supersedes',
evidence: { file: 'gridatlas/atlas/modules/202609012245-network-topology.js', lines: '1-384',
method: 'sources/provenance.json engine/network-topology.js entry (added this session); sha256 recorded' } },
{ from: 'electrical-distance', to: 'gridatlas-electrical-distance-live', kind: 'supersedes',
evidence: { file: 'gridatlas/atlas/modules/202609012245-electrical-distance.js', lines: '1-365',
method: 'sources/provenance.json engine/electrical-distance.js entry (added this session); sha256 recorded' } },
{ from: 'rating-envelope', to: 'gridatlas-rating-envelope-live', kind: 'supersedes',
evidence: { file: 'gridatlas/atlas/modules/202609012250-rating-envelope.js', lines: '1-213',
method: 'sources/provenance.json engine/rating-envelope.js entry (added this session); sha256 recorded' } },
{ from: 'corridor-estimate', to: 'gridatlas-corridor-estimate-live', kind: 'supersedes',
evidence: { file: 'gridatlas/atlas/modules/202609030205-corridor-estimate.js', lines: '1-114',
method: 'sources/provenance.json engine/corridor-estimate.js entry (added this session); sha256 recorded' } },
{ from: 'electrical-distance', to: 'network-topology', kind: 'imports',
evidence: { file: 'engine/electrical-distance.js', lines: '21-22, 111-113',
method: 'source inspection: REQUIRES = "gridatlas.module.network-topology.graph.v1"; between()/within() call index.graph() and refuse to run on a mismatched schema; exercised by proofs/electrical-distance.proof.mjs' } },
{ from: 'rating-envelope', to: 'network-topology', kind: 'imports',
evidence: { file: 'engine/rating-envelope.js', lines: '21-22, 85-87',
method: 'source inspection: REQUIRES = "gridatlas.module.network-topology.graph.v1"; at() calls index.graph() and refuses on schema mismatch; exercised by proofs/rating-envelope.proof.mjs' } },
];
const idIndex = new Map(nodes.map((n, i) => [n.id, i]));
for (const e of edges) {
if (!idIndex.has(e.from)) throw new Error('unknown edge.from: ' + e.from);
if (!idIndex.has(e.to)) throw new Error('unknown edge.to: ' + e.to);
}
const KIND_LABEL = {
duplicates: 'duplicates',
supersedes: 'supersedes',
imports: 'imports',
should_import: 'should import',
drifts_from: 'drifts from'
};
const graph = {
schema: 'ventus-grid-engine.genome.v1',
label: 'ventus-grid-engine genome · the spider pattern applied to the engine’s own maths',
generated_utc: new Date().toISOString(),
note: 'Nodes and edges match the node shape used by the live Spider Sandbox '
+ '(data-federation-map-for-globalgrid2050-all-repos/dashboard/sandbox/spider_full_po_test.html: '
+ 'SCOPES[key].nodes = [{label,type,rag,reason,gh,ext,child}], edges = [from,to,type]). '
+ 'Edges here are objects, not bare [from,to,type] tuples, because every edge in this '
+ 'genome must carry evidence; edge.type stays a plain string for compatibility with a '
+ 'receiver expecting the tuple shape (read edges[i].type, .from, .to as the tuple).',
focus_default: idIndex.get('geo-core'),
kind_labels: KIND_LABEL,
nodes: nodes.map(({ id, ...rest }) => rest),
node_ids: nodes.map(n => n.id), // parallel array: node_ids[i] is nodes[i]'s stable key
edges: edges.map(e => ({
from: idIndex.get(e.from),
to: idIndex.get(e.to),
type: e.kind,
evidence: e.evidence
}))
};
const counts = {};
for (const e of graph.edges) counts[e.type] = (counts[e.type] || 0) + 1;
graph.edge_kind_counts = counts;
writeFileSync(join(here, 'engine-graph.json'), JSON.stringify(graph, null, 2) + '\n');
console.log('wrote genome/engine-graph.json:', nodes.length, 'nodes,', edges.length, 'edges');
console.log('edge kinds:', JSON.stringify(counts));Browser Observer Proof
A JavaScript module in the proofs folder of Ventus Grid Engine.
otherventus-grid-engine / proofs/browser-observer.proof.mjs · lines 1–25 of 25 · Not reached from any entry point (candidate for review)
- What it does
- Uses libraries node:assert/strict, node:vm.
- What it achieves
- No statement of purpose was found in the file, a README line naming it, or its name. Described from its file name only (a candidate, not yet checked against the code).
- Why it matters
- No other file in the estate was found to import it.
- Application
- ventus-grid-engine · proofs · JavaScript module
- Uses
- Build Browser Observer (import), Compute Presentation (import), V9 Geodesy (import), node:assert/strict, node:vm
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 proofs/browser-observer.proof.mjs:1-25 · blob 0a09823b9d9a47216e7bf54dda00ce87eeff20c7 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: unknown · effects: none found · domain stage: unknown · users: none · canonical: unreached_review
import assert from 'node:assert/strict';
import vm from 'node:vm';
import { buildBrowserObserver } from '../tools/build-browser-observer.mjs';
import { describeComputeReceipt } from '../engine/compute-presentation.js';
import { distanceKm } from '../engine/v9-geodesy.js';
const sandbox = {};
vm.runInNewContext(buildBrowserObserver(), sandbox);
const api = sandbox.VentusGridCompute;
const observer = api.createComputeObserver();
const entity = {kind:'repd',id:'12588'}, location={lon:-1.3489728,lat:51.8132088};
const id=observer.request({entity,location});
assert.equal(api.describeComputeReceipt(observer.snapshot()).status,'requested');
const node={node_id:'test-node',lon:-1.35,lat:51.8};
let invoked=0;
const completed=await observer.run(id,()=>{invoked++;return {entity,origin:location,measurements:[{...node,km:distanceKm(location.lon,location.lat,node.lon,node.lat)}]};});
assert.equal(invoked,1);
assert.equal(api.distanceKm(location.lon,location.lat,node.lon,node.lat),distanceKm(location.lon,location.lat,node.lon,node.lat));
assert.equal(completed.status,'completed');
assert.equal(api.describeComputeReceipt(completed).unit,'km');
assert.equal(JSON.stringify(api.describeComputeReceipt(completed)),JSON.stringify(describeComputeReceipt(completed)));
assert.match(api.describeComputeReceipt(completed).scope,/not an electrical connection/);
assert.equal(describeComputeReceipt({status:'failed',reason:'dataset unavailable'}).distance_km,null);
assert.equal(describeComputeReceipt(null).status,'not_requested');
assert.equal(buildBrowserObserver(),buildBrowserObserver());
console.log('browser observer PASS — 10 checks');Compute Observer Proof
A JavaScript module in the proofs folder of Ventus Grid Engine that works with the Renewable Energy Planning Database (REPD) register.
transformventus-grid-engine / proofs/compute-observer.proof.mjs · lines 1–92 of 92 · Not reached from any entry point (candidate for review)
- What it does
- It calculates the REPD register. Defines check, compute. Uses libraries node:assert/strict.
- Why it exists in the grid workflow
- Domain terms in the code: the REPD register. README: "`engine/compute-observer.js` provides browser-neutral computation receipts for the Test Code detector."
- What it achieves
- It is built from the check step (`check`) and the compute step (`compute`). The README says: `engine/compute-observer.js` provides browser-neutral computation receipts for the Test Code detector.
- Why it matters
- No other file in the estate was found to import it.
- Application
- ventus-grid-engine · proofs · JavaScript module
- Uses
- Compute Observer (import), V9 Nearest Search (import), node:assert/strict
- Used by
- none found
- Produces
- check, compute
- Defines here
- check, compute
- 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/compute-observer.proof.mjs:1-92 · blob 9bfe9efcdeb956b6f5513e89312a39b8b2f38db1 · GitHub at these lines
- State
- achieves: readme · context: readme_derived · stage: transform · effects: none found · domain stage: unknown · users: none · canonical: unreached_review
import assert from 'node:assert/strict';
import { createComputeObserver } from '../engine/compute-observer.js';
import { index } from '../engine/v9-nearest-search.js';
let checks = 0;
const check = (name, fn) => { fn(); checks++; console.log(' PASS ' + name); };
const selection = { entity: { kind: 'repd', id: '10919' }, location: { lon: -3, lat: 54 } };
const lookup = index([{ name: 'Fixture grid node', location: { lon: -2.9, lat: 54 }, voltages_kv: [400] }]);
const compute = request => {
const found = lookup.nearest(request.location.lon, request.location.lat);
return { entity: request.entity, origin: request.location, measurements: [{
node_id: found.point.name, ...found.point.location, km: found.km
}] };
};
const events = [];
const observer = createComputeObserver({ onEvent: event => events.push(event) });
check('never requested cannot pass', () => assert.equal(observer.assess('absent', selection).passed, false));
let id = observer.request(selection);
check('request alone cannot pass', () => assert.equal(observer.assess(id, selection).passed, false));
await observer.run(id, compute);
check('actual nearest calculation produces finite verified measurement', () => {
assert.equal(observer.assess(id, selection).passed, true);
assert.ok(observer.snapshot(id).measurements[0].km > 0);
assert.deepEqual(events.map(event => event.status), ['requested', 'started', 'completed']);
});
check('wrong project cannot use a completed result', () => assert.equal(observer.assess(id, {
...selection, entity: { kind: 'repd', id: 'different' }
}).passed, false));
check('wrong location cannot use a completed result', () => assert.equal(observer.assess(id, {
...selection, location: { lon: -4, lat: 54 }
}).passed, false));
const oldId = id;
id = observer.request(selection);
check('same project selected again invalidates old attempt', () => assert.equal(observer.assess(oldId, selection).reason, 'stale-attempt'));
await observer.run(id, () => { throw new Error('Network unavailable'); });
check('exception is recorded and cannot pass', () => {
assert.equal(observer.assess(id, selection).passed, false);
assert.match(observer.snapshot(id).reason, /Network unavailable/);
});
for (const [name, mutate] of [
['empty results', result => { result.measurements = []; }],
['NaN distance', result => { result.measurements[0].km = NaN; }],
['null distance', result => { result.measurements[0].km = null; }],
['negative distance', result => { result.measurements[0].km = -1; }],
['invented distance', result => { result.measurements[0].km += 1; }],
['stale result origin', result => { result.origin = { lon: -4, lat: 54 }; }],
['stale result identity', result => { result.entity = { kind: 'repd', id: 'old' }; }]
]) {
id = observer.request(selection);
await observer.run(id, request => { const result = compute(request); mutate(result); return result; });
check(name + ' fails closed', () => assert.equal(observer.snapshot(id).status, 'failed'));
}
id = observer.request({ ...selection, location: { lon: null, lat: 54 } });
let invoked = false;
await observer.run(id, () => { invoked = true; });
check('missing geometry is unsupported, never completed or invoked', () => {
assert.equal(invoked, false); assert.equal(observer.snapshot(id).status, 'unsupported');
});
id = observer.request(selection);
await observer.run(id, request => ({ entity: request.entity, origin: request.location,
measurements: [], search_completed: true, scanned_count: 45 }));
check('completed empty scan is explicit and never passes as a measured result', () => {
assert.equal(observer.snapshot(id).status, 'completed_empty');
assert.equal(observer.snapshot(id).summary.scanned_count, 45);
assert.equal(observer.assess(id, selection).passed, false);
});
id = observer.request(selection);
let release;
const pending = observer.run(id, async request => {
await new Promise(resolve => { release = resolve; }); return compute(request);
});
check('running calculation is not a success', () => assert.equal(observer.snapshot(id).status, 'started'));
observer.request(selection);
release(); await pending;
check('late completion from previous selection stays stale', () => assert.equal(observer.assess(id, selection).reason, 'stale-attempt'));
check('consumer mutation cannot turn requested into completed', () => {
const receipt = observer.snapshot(); receipt.status = 'completed';
assert.equal(observer.snapshot().status, 'requested');
});
const brokenListener = createComputeObserver({ onEvent() { throw Error('logger'); } });
id = brokenListener.request(selection); await brokenListener.run(id, compute);
check('logging errors do not suppress real computation', () => assert.equal(brokenListener.assess(id, selection).passed, true));
await assert.rejects(() => brokenListener.run(id, compute), /already invoked/);
check('attempt cannot be run twice', () => assert.equal(brokenListener.snapshot(id).events.length, 3));
const industrial = { entity: { kind: 'industrial', id: 'fixture-emitter-1' }, location: { lon: -2.9, lat: 54 } };
id = observer.request(industrial); await observer.run(id, compute);
check('industrial identity supports actual zero-distance results without invented capacity', () => {
assert.equal(observer.assess(id, industrial).passed, true);
assert.equal(observer.snapshot(id).measurements[0].km, 0);
assert.equal(observer.snapshot(id).entity.kind, 'industrial');
});
console.log(`compute-observer PASS — ${checks} checks`);Connection Capacity 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/connection-capacity.proof.mjs · lines 1–154 of 154 · 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: starts processes.
- What it achieves
- Sizing an asset against a stated cap. Its code works with 30 MW and 20 MW.
- Why it matters
- No other file in the estate was found to import it.
- Application
- ventus-grid-engine · proofs · JavaScript module
- Uses
- Connection Capacity (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/connection-capacity.proof.mjs:1-154 · blob 15c619b79917cadbc452ce468c6db4d44296cb14 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: unknown · effects: process · domain stage: unknown · users: none · canonical: unreached_review
/* connection-capacity.proof.mjs — sizing an asset against a stated cap.
*
* The case that drives every check: a site capped at 30 MW whose profile
* exceeds it. Peak excess sets the power; the AREA above the cap sets the
* store. Two profiles with an identical peak and very different shapes must
* produce the same power and very different energy — that is the whole reason
* this module takes a profile rather than a peak.
*
* Run: node proofs/connection-capacity.proof.mjs
*/
import * as mod from '../engine/connection-capacity.js';
const { schema, NOT_COMPUTED, exceedance, batteryForPeakShaving, clippedEnergy, netAtConnection } = 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); } };
const HALF_HOUR = 0.5;
check('schema is declared', schema === 'ventus-grid-engine.connection-capacity.v1');
/* ── Exceedance. ────────────────────────────────────────────────────────── */
{
/* Four half-hours: 20, 42, 36, 20 MW against a 30 MW cap. */
const ex = exceedance({ profileKw: [20, 42, 36, 20], capKw: 30, intervalHours: HALF_HOUR });
check('peak and peak excess are found', ex.peakKw === 42 && ex.peakExcessKw === 12);
check('two of four intervals are above the cap', ex.intervalsAboveCap === 2);
check('energy above the cap is the area, not the peak: (12 + 6) x 0.5 = 9',
near(ex.energyAboveCapKwh, 9, 1e-9));
check('fraction of time above the cap is reported', near(ex.fractionOfTimeAboveCap, 0.5, 1e-12));
check('site load factor is computed from the profile',
near(ex.siteLoadFactor, (20 + 42 + 36 + 20) * 0.5 / (42 * 2), 1e-12));
check('a profile inside the cap reports withinCap and needs no shaving',
exceedance({ profileKw: [10, 20, 25], capKw: 30, intervalHours: HALF_HOUR }).withinCap === true);
}
/* THE point of taking a profile: same peak, different shape, same power,
very different store. A spike and a plateau are not the same asset. */
{
const spike = exceedance({ profileKw: [30, 42, 30, 30, 30, 30, 30, 30], capKw: 30, intervalHours: HALF_HOUR });
const plateau = exceedance({ profileKw: [42, 42, 42, 42, 42, 42, 42, 42], capKw: 30, intervalHours: HALF_HOUR });
check('a spike and a plateau share the same peak excess',
spike.peakExcessKw === plateau.peakExcessKw && spike.peakExcessKw === 12);
check('but the plateau needs eight times the energy above the cap',
near(plateau.energyAboveCapKwh / spike.energyAboveCapKwh, 8, 1e-9));
check('so sizing from the peak alone would under-size the store eightfold — '
+ 'the basis says the two can differ by a factor of forty in cost',
/factor of forty/i.test(spike.basis));
}
/* ── Battery sizing. ────────────────────────────────────────────────────── */
{
const b = batteryForPeakShaving({
profileKw: [20, 42, 36, 20], capKw: 30, intervalHours: HALF_HOUR,
roundTripEfficiency: 0.88, depthOfDischarge: 0.9
});
check('power comes from the peak excess', b.powerKw === 12);
check('usable energy is the area above the cap', near(b.usableEnergyKwh, 9, 1e-9));
check('stored energy divides by round-trip efficiency: 9 / 0.88',
near(b.chargeEnergyRequiredKwh, 9 / 0.88, 1e-9));
check('installed energy divides again by depth of discharge: 9 / 0.88 / 0.9',
near(b.installedEnergyKwh, 9 / 0.88 / 0.9, 1e-9));
check('efficiency and depth of discharge only ever make the asset bigger',
b.installedEnergyKwh > b.usableEnergyKwh);
check('duration is installed energy over power', near(b.durationHours, b.installedEnergyKwh / 12, 1e-12));
check('the basis says this sizes a physical duty and is not an optimised dispatch',
/not an optimised revenue dispatch/i.test(b.basis));
const none = batteryForPeakShaving({
profileKw: [10, 20], capKw: 30, intervalHours: HALF_HOUR,
roundTripEfficiency: 0.88, depthOfDischarge: 0.9
});
check('a site inside its cap needs no battery for shaving, and the basis says a battery '
+ 'may still be worth having for reasons this function does not assess',
none.powerKw === 0 && none.installedEnergyKwh === 0 && /does not assess them/i.test(none.basis));
}
/* ── Solar clipping. ────────────────────────────────────────────────────── */
{
const c = clippedEnergy({ generationKw: [0, 5, 12, 14, 12, 5, 0], exportCapKw: 10, intervalHours: 1 });
check('clipped energy is the area above the export cap: 2 + 4 + 2 = 8',
near(c.clippedKwh, 8, 1e-9));
check('delivered energy caps each clipped interval at the export limit',
near(c.deliveredKwh, 0 + 5 + 10 + 10 + 10 + 5 + 0, 1e-9));
check('potential is delivered plus clipped', near(c.potentialKwh, c.deliveredKwh + c.clippedKwh, 1e-9));
check('the clipped fraction is reported as a proportion of what the array would have made',
near(c.clippedFraction, 8 / 48, 1e-9));
check('an array inside its cap clips nothing',
clippedEnergy({ generationKw: [0, 5, 9], exportCapKw: 10, intervalHours: 1 }).clippedKwh === 0);
}
/* ── Net position, with separate import and export caps. ────────────────── */
{
const n = netAtConnection({
loadKw: [10, 10, 10, 40], generationKw: [0, 25, 5, 0],
importCapKw: 30, exportCapKw: 10, intervalHours: HALF_HOUR
});
check('peak import is the worst net demand', n.peakImportKw === 40);
check('peak export is the worst net generation', n.peakExportKw === 15);
check('an import breach is counted', n.importBreaches === 1);
check('an export breach is counted separately', n.exportBreaches === 1);
check('a site breaching either cap is not within both', n.withinBothCaps === false);
check('the basis warns that netting import and export into one figure hides a breach',
/hides a breach in either direction/i.test(n.basis));
check('a site inside both caps says so',
netAtConnection({ loadKw: [10, 10], generationKw: [0, 5], importCapKw: 30, exportCapKw: 10, intervalHours: HALF_HOUR })
.withinBothCaps === true);
}
/* ── Input discipline. ──────────────────────────────────────────────────── */
check('an efficiency of 88 is refused, and the message says to pass 0.88',
throws(() => batteryForPeakShaving({ profileKw: [40], capKw: 30, intervalHours: 0.5, roundTripEfficiency: 88, depthOfDischarge: 0.9 }),
/fraction.*0\.88/s));
check('an empty profile is refused', throws(() => exceedance({ profileKw: [], capKw: 30, intervalHours: 0.5 }), /non-empty array/));
check('a negative profile value is refused, naming the index',
throws(() => exceedance({ profileKw: [10, -5], capKw: 30, intervalHours: 0.5 }), /profileKw\[1\].*not be negative/s));
check('mismatched load and generation profiles are refused, naming both lengths',
throws(() => netAtConnection({ loadKw: [1, 2, 3], generationKw: [1], importCapKw: 10, exportCapKw: 10, intervalHours: 0.5 }),
/3 intervals.*generationKw has 1;.*same period/s));
check('an interval longer than a day is refused',
throws(() => exceedance({ profileKw: [10], capKw: 5, intervalHours: 48 }), /at most 24/));
/* ── Refusals. ──────────────────────────────────────────────────────────── */
{
const callable = Object.keys(mod).filter(k => typeof mod[k] === 'function');
check('no function returns available connection capacity, headroom or a cost',
callable.every(n => !/available|headroom|spare|cost|price/i.test(n)));
check('no function claims to optimise a dispatch',
callable.every(n => !/optimi[sz]e|dispatch|revenue|arbitrage/i.test(n)));
check('the refusals name all four boundaries',
['availableConnectionCapacity', 'connectionCost', 'optimisedDispatch', 'degradationAndWarranty']
.every(k => k in NOT_COMPUTED));
check('the refusal on available capacity says it is commercial, not physical, '
+ 'and that nothing on a map implies it',
/commercial parameter, not a physical property/i.test(NOT_COMPUTED.availableConnectionCapacity)
&& /nothing on a map implies it/i.test(NOT_COMPUTED.availableConnectionCapacity));
}
if (failures.length) {
console.error('connection-capacity proof FAILED (' + failures.length + ' of '
+ (failures.length + passed) + '):\n- ' + failures.join('\n- '));
process.exit(1);
}
console.log('connection-capacity proof PASS — ' + passed + ' checks');
export default { status: 'PASS', checks: passed };