In this section
- Neon Substation Links V9 6 geodesy · gridatlas / atlas/cartridges/202608311910-neon-substation-links-v9-6.js lines 529–707
- Single-Line Diagram (SLD) Sandbox V9 8 geodesy · gridatlas / atlas/cartridges/202611180026-sld-sandbox-v9-8.js lines 1–521
Neon Substation Links V9 6
A JavaScript file in the cartridges folder of GridAtlas that maps grid substations, 33kV, solar and wind, using haversine.
geodesygridatlas / atlas/cartridges/202608311910-neon-substation-links-v9-6.js · lines 529–707 of 707 · version 2026-08-31 19:10 (continued from section 369) · pattern interactiveLayerIds (shared by 10 files)
- What it does
- It maps grid substations, 33kV, solar and wind. Defines 24 functions or classes, including distanceKm, voltagesKv, representativePoint, loadSubstations, nearestSubstations. Side effects: changes the web page (DOM); makes network requests.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'atlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: 33kV, solar, wind, 11kV.
- Inputs & outputs
- In: GeoJSON file grid_substations.geojson. Out: interactive map. Coordinate systems named: WGS84 / EPSG:4326. Voltage levels named: 33kV, 11kV.
- Downstream impact
- Used directly by 2 files: Build Graph (ventus-grid-engine, https://ventusltd.github.io/ventus-grid-engine/genome/); Ventus Grid Engine — Genome Page (ventus-grid-engine, https://ventusltd.github.io/ventus-grid-engine/genome/). Reached from 1 other entry point, including Genome Workflow (ventus-grid-engine).
- What it achieves
- It loads substations (`loadSubstations`), removes card block (`removeCardBlock`) and stops animation (`stopAnimation`). Slot: replace-script for… Its code works with 33 kV and 11 kV. It responds to keydown and visibilitychange events.
- Why it matters
- Loaded by the Genome page in Ventus Grid Engine at https://ventusltd.github.io/ventus-grid-engine/genome/. Also imported by Build Graph, from Ventus Grid Engine.
- Application
- gridatlas · atlas/cartridges · script
- VEDIC
- MEASURE (GG2050-VEDIC-000001): GridAtlas / Geodesy · Mathematics / Spherical geometry. coordinate_pair, coordinate_pair → distance_km
- VEDIC
- VOLTAGE (GG2050-VEDIC-000003): GridAtlas / Geodesy · Computer science / Data normalisation. voltage_properties → kilovolt_list
- VEDIC
- REPRESENT (GG2050-VEDIC-000002): GridAtlas / Geodesy · Computer science / Geometry processing. geojson_geometry → coordinate_pair_or_null
- Uses
- none found
- Used by
- named by URL in Build Graph (estate URL), named by URL in Ventus Grid Engine — Genome Page (estate URL)
- Produces
- distanceKm, voltagesKv, representativePoint, loadSubstations, nearestSubstations, nearestProjects, installStyles, escapeHtml, caveatHtml, cardBlockHtml, injectIntoCard, removeCardBlock
- Defines here
- drawLinks, interactiveLayerIds, install, attach, boot, PatchedMap
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 atlas/cartridges/202608311910-neon-substation-links-v9-6.js:529-707 · blob bd525ab78b2c589a662a6a08d4a0489e7c24c7dd · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
link.last_selection = null;
}
function drawLinks(map, origin, name, tech, links, direction) {
ensureLayers(map);
// A link takes the colour of the project end, whichever end was clicked.
const colour = direction === 'from-substation'
? SUBSTATION_COLOUR
: (TECH_COLOUR[tech] || SUBSTATION_COLOUR);
const lines = links.map((l, index) => ({
type: 'Feature',
properties: {
colour,
// The nearest link burns brightest; the rest fade back in order, so
// rank is legible without reading the numbers.
strength: Math.max(0.20, 0.62 - index * 0.10),
km: l.km
},
geometry: { type: 'LineString', coordinates: [origin, l.at] }
}));
const nodes = links.map(l => {
const tail = l.kv && l.kv.length ? `${l.kv[0]} kV`
: (l.mw != null ? `${l.mw} MW` : '');
return {
type: 'Feature',
properties: {
colour,
label: tail ? `${l.km.toFixed(2)} km · ${tail}` : `${l.km.toFixed(2)} km`
},
geometry: { type: 'Point', coordinates: l.at }
};
});
map.getSource(SRC).setData({ type: 'FeatureCollection', features: lines });
map.getSource(SRC_NODES).setData({ type: 'FeatureCollection', features: nodes });
// The popup is built by the engine and rendered synchronously in its own
// click handler, but MapLibre attaches it on the next frame in some paths.
// One retry covers that without polling forever.
if (!injectIntoCard(links, direction)) {
requestAnimationFrame(() => injectIntoCard(links, direction));
}
startAnimation(map);
link.links_drawn = links.length;
link.last_selection = { name, tech, direction, count: links.length,
nearest_km: links.length ? Number(links[0].km.toFixed(3)) : null };
}
/* ── selection ───────────────────────────────────────────────────────── */
function interactiveLayerIds(map) {
// Whatever the engine has made visible and interactive. Reading the style
// rather than hard-coding ids keeps this working as layers come and go.
try {
return map.getStyle().layers
.filter(layer => /^l-/.test(layer.id) && layer.type !== 'background')
.map(layer => layer.id)
.filter(id => {
try { return map.getLayoutProperty(id, 'visibility') !== 'none'; }
catch (_) { return false; }
});
} catch (_) {
return [];
}
}
function install(map) {
installStyles();
ensureLayers(map);
// The lines belong to the card. When the card closes, they go with it --
// leaving neon on the map with nothing explaining it is how a screenshot
// ends up quoted without its caveat.
const popupWatcher = new MutationObserver(() => {
if (link.links_drawn > 0 && !document.querySelector('.maplibregl-popup')) clearLinks();
});
try {
popupWatcher.observe(map.getContainer(), { childList: true, subtree: true });
} catch (error) {
link.failures.push(String(error?.message || error));
}
// Registered after the engine's own click handler, so the engine's popup
// opens first and this decorates it rather than racing it.
map.on('click', async (event) => {
try {
const ids = interactiveLayerIds(map);
if (!ids.length) return;
let features = [];
try { features = map.queryRenderedFeatures(event.point, { layers: ids }); }
catch (_) { return; }
if (!features.length) { clearLinks(); return; }
// Either end of a link is a valid place to start. Whichever pixel was
// clicked, the card that came up is the one the distances are written
// onto, and the lines run to the other end.
const hit = features.find(feature => {
const properties = feature.properties || {};
const tech = String(properties.tech || properties.type || '');
return PROJECT_TECHS.has(tech) || feature.layer?.id === SUBS_LAYER_ID;
});
if (!hit) { clearLinks(); return; }
const properties = hit.properties || {};
const fromSubstation = hit.layer?.id === SUBS_LAYER_ID;
const tech = String(properties.tech || properties.type || '');
const origin = representativePoint(hit.geometry)
|| [event.lngLat.lng, event.lngLat.lat];
const name = properties.name || properties.SiteName || properties['Site Name']
|| (fromSubstation ? 'Unnamed substation' : 'Unnamed project');
if (fromSubstation) {
// No fetch needed: the projects are already in the engine's own
// source, and reading them there keeps one set of coordinates.
drawLinks(map, origin, name, tech,
nearestProjects(map, origin[0], origin[1]), 'from-substation');
return;
}
const subs = await loadSubstations();
drawLinks(map, origin, name, tech,
nearestSubstations(origin[0], origin[1], subs), 'to-substation');
} catch (error) {
link.failures.push(String(error?.message || error));
}
});
// Escape clears, the way a game HUD does.
document.addEventListener('keydown', (event) => {
if (event.key === 'Escape') clearLinks();
});
// A backgrounded tab should not keep an animation frame loop alive.
document.addEventListener('visibilitychange', () => {
if (document.hidden) stopAnimation();
else if (link.links_drawn > 0 && capturedMap) startAnimation(capturedMap);
});
}
/* ── capture the map ─────────────────────────────────────────────────── */
function attach(map) {
if (capturedMap) return;
capturedMap = map;
link.map_captured = true;
const boot = () => {
try { install(map); }
catch (error) { link.failures.push(String(error?.message || error)); }
};
if (map.isStyleLoaded?.()) boot(); else map.once('load', boot);
}
// The engine keeps its map in a closure and returns nothing, so the only
// clean handle is the constructor -- and the engine builds its map inside
// initVentusMap, which runs after this file, so it is still ours to wrap.
try {
const gl = window.maplibregl;
if (gl && typeof gl.Map === 'function' && !gl.Map.__gridatlasNeonWrapped) {
const OriginalMap = gl.Map;
function PatchedMap(...args) {
const instance = new OriginalMap(...args);
try { attach(instance); }
catch (error) { link.failures.push(String(error?.message || error)); }
return instance;
}
PatchedMap.prototype = OriginalMap.prototype;
PatchedMap.__gridatlasNeonWrapped = true;
Object.setPrototypeOf(PatchedMap, OriginalMap);
gl.Map = PatchedMap;
} else if (!gl) {
link.failures.push('maplibregl unavailable when the neon cartridge loaded');
}
} catch (error) {
link.failures.push(String(error?.message || error));
}
})();Single-Line Diagram (SLD) Sandbox V9 8
A JavaScript file in the cartridges folder of GridAtlas that maps connection points, GB transmission network, price decade rollup and grid substations, using haversine.
Set aside from the main view: 99% of its lines are the same as atlas/modules/202612020205-secondary-neon-engine.js (gridatlas), which stays. (near-copy-of, proposed by families.py). 98% of lines shared with Secondary Neon Engine; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.9877 to gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 atlas/modules/202612020205-secondary-neon-engine.js:1-9008 26e5045a356c11088820207d3cbe95eb4b89374f
- sha256 d8b2e61b4b14f7af456a2c0c1721efc4d0bb2e9d43fbadc8cac6075b8465eccb
- target sha256 b9e2b3ce36d3f46184c4a0f0416d70892feb49507d1c93833d3ab00a27c84263
- group of 3 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
geodesygridatlas / atlas/cartridges/202611180026-sld-sandbox-v9-8.js · lines 1–521 of 9047 · version 2026-11-18 00:26 · Not reached from any entry point (candidate for review) · pattern isInterconnectorArrival (shared by 3 files)
- What it does
- It maps connection points, GB transmission network, price decade rollup and grid substations. Defines 276 functions or classes, including distanceKm, distanceKm, representativePoint, voltagesKv, destinationPoint. Side effects: changes the web page (DOM); reads or writes files; makes network requests; uses storage (browser storage, DuckDB or Parquet).
- Why it exists in the grid workflow
- Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: 750kV, 415kV, 400kV, 275kV, 220kV, 132kV.
- Inputs & outputs
- In: JSON file connection-points.v3.json; JSON file gb-transmission-network.v1.json; JSON file price-decade-rollup.json; GeoJSON file grid_substations.geojson; JSON file neso-connection-sites.lean.json; GeoJSON file interconnectors.geojson; browser storage (getItem); DuckDB queries. Out: browser storage (setItem); interactive map. Coordinate systems named: WGS84 / EPSG:4326. Voltage levels named: 750kV, 415kV, 400kV, 275kV, 220kV, 132kV, 110kV, 66kV.
- What it achieves
- It creates compute observer (`createComputeObserver`), describes compute receipt (`describeComputeReceipt`) and builds stats (`buildStats`). Receipt and distance owner: Ventusltd/ventus-grid-engine. Its code works with 400 kV, 132 kV and 33 kV. It responds to click, keydown and touchstart events.
- Why it matters
- No other file in the estate was found to import it.
- Application
- gridatlas · atlas/cartridges · script
- VEDIC
- MEASURE (GG2050-VEDIC-000001): GridAtlas / Geodesy · Mathematics / Spherical geometry. coordinate_pair, coordinate_pair → distance_km
- VEDIC
- REPRESENT (GG2050-VEDIC-000002): GridAtlas / Geodesy · Computer science / Geometry processing. geojson_geometry → coordinate_pair_or_null
- VEDIC
- VOLTAGE (GG2050-VEDIC-000003): GridAtlas / Geodesy · Computer science / Data normalisation. voltage_properties → kilovolt_list
- Uses
- none found
- Used by
- mentioned in Standalone (comment link)
- Produces
- distanceKm, distanceKm, representativePoint, voltagesKv, destinationPoint, initialBearingDeg, copy, finite, located, sameLocation, sameEntity, createComputeObserver
- Defines here
- distanceKm, distanceKm, representativePoint, voltagesKv, destinationPoint, initialBearingDeg, copy, finite, located, sameLocation, sameEntity, createComputeObserver, publish, get, describeComputeReceipt, classOf, scope
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 atlas/cartridges/202611180026-sld-sandbox-v9-8.js:1-521 · blob 4336ae8ea8d1eafcf57a97906bbb6c661f9c8318 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, network, storage · domain stage: experimental · users: none · canonical: unreached_review
/* Receipt and distance owner: Ventusltd/ventus-grid-engine 487ec7bd38dfa5aecb1c75da53b4a866ab2101cb */
/* Ventus Grid Engine: generated receipt observer; not a substitute nearest engine. */
(() => {
'use strict';
const distanceKm = (() => {
/**
* Module: geodesy
*
* Extracted verbatim (formula and constant unchanged) from
* gridatlas/atlas/modules/202609011950-geodesy.js.
*
* One Earth radius for the whole estate, and the three operations every
* measurement here is built from. This existed three times tonight - in
* the sandbox, in the substation cartridge and in the data repository -
* which is exactly how two of them end up on different radii without
* anyone noticing.
*
* Radius 6378.137 km, matching Ventusltd/grid-distance-maths. Haversine.
* No projection, no turf, no second radius for geometry.
*
* Pure functions. No DOM, no network, no state.
*
* CHANGED: source wraps this in `(() => { ... NS.geodesy = Object.freeze({...}) })()`
* and registers itself on `window.__GRIDATLAS_MODULES__.geodesy`. That
* closure/global-namespace wiring is removed; every function below is
* otherwise byte-identical to the source, including the atan2 argument
* order that the source's own comment insists on for numerical parity
* with ventus-corev8engine.js haversine() (see distanceKm below).
*/
const EARTH_RADIUS_KM = 6378.137;
const DEG = Math.PI / 180;
function distanceKm(lon1, lat1, lon2, lat2) {
const dLat = (lat2 - lat1) * DEG;
const dLon = (lon2 - lon1) * DEG;
const a = Math.sin(dLat / 2) ** 2
+ Math.cos(lat1 * DEG) * Math.cos(lat2 * DEG) * Math.sin(dLon / 2) ** 2;
/* atan2, in this operand order, because that is the form every version
of this estate has shipped - ventus-corev8engine.js haversine() and
every cartridge carried from it.
-------------------------------------------------------------------
The extraction wrote 2 * R * asin(sqrt(a)) instead. Algebraically the
same; numerically one unit in the last place apart, which the
all-versions proof caught on West Burton Solar to Cottam:
7.050150827184836 shipped, 7.050150827184837 from the module. It is
1e-15 km and changes no figure any reader will ever see - and it is
still wrong, because the claim being made is PARITY. A module that is
nearly the incumbent is a module that has to be argued about every
time a digit differs. */
return EARTH_RADIUS_KM * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
}
/* A polygon reduces to the mean of its outer ring, not its first corner.
A substation drawn as a compound outline would otherwise be measured
from whichever vertex the mapper happened to start at.
Point, Polygon and MultiPolygon, and NOTHING ELSE. The first draft of
this module accepted any nested coordinate array and so returned a
mean for a LineString where the incumbent returns null; the parity
proof caught it against the live cartridge. Extraction is not the
moment to change behaviour, so the behaviour is pinned here and any
widening becomes its own version with its own reasoning.
One deliberate difference, on malformed input only: this returns null
where the incumbent would throw on a Point with no coordinates. No
real geometry reaches that path, and a proof asserts it. */
function representativePoint(geometry) {
if (!geometry) return null;
const { type, coordinates } = geometry;
if (type === 'Point') {
return Array.isArray(coordinates) && coordinates.length >= 2
? [coordinates[0], coordinates[1]] : null;
}
const ring = type === 'Polygon' ? coordinates && coordinates[0]
: type === 'MultiPolygon' ? coordinates && coordinates[0] && coordinates[0][0]
: null;
if (!Array.isArray(ring) || !ring.length) return null;
let sumLon = 0;
let sumLat = 0;
for (const point of ring) {
sumLon += point[0];
sumLat += point[1];
}
return [sumLon / ring.length, sumLat / ring.length];
}
/* OpenStreetMap's `voltage` is VOLTS at every magnitude, and a feature
may carry several separated by a semicolon. Magnitude is not the unit:
750 is a DC traction supply at a railway depot, not 750 kV. An audit
of the served payload found 229 features (3.95%) carrying a token
below 1,000, every one of which had been misread. An explicit `kv`
property is already kilovolts and is trusted as such. */
function voltagesKv(properties) {
if (!properties) return [];
const out = [];
const explicit = properties.kv ?? properties.KV;
if (explicit != null && String(explicit).trim() !== '') {
for (const token of String(explicit).match(/\d+(?:\.\d+)?/g) || []) {
const value = Number(token);
if (Number.isFinite(value) && value > 0) out.push(value);
}
}
const volts = properties.voltage ?? properties.VOLTAGE;
if (volts != null) {
for (const token of String(volts).match(/\d+(?:\.\d+)?/g) || []) {
const value = Number(token);
if (Number.isFinite(value) && value > 0) out.push(value / 1000);
}
}
return [...new Set(out)].sort((a, b) => b - a);
}
/* Projection and bearing, carried in from the sandbox verbatim.
----------------------------------------------------------------------
The deep scan found the body carrying a SECOND geodesy section - "the
geodesy the layout needs, all on R_ATLAS" - four hundred lines away
from the first. Two geodesies in one file, on a constant that must
never differ, is the configuration that produced the divergence the
all-versions proof caught. Both belong here, on the one radius, and
the body now delegates rather than defining.
The bodies below are the incumbent's, character for character apart
from the radius identifier, so parity is a property of the move rather
than something to argue about afterwards. */
function destinationPoint(lon, lat, km, bearingDeg) {
const ad = km / EARTH_RADIUS_KM;
const brg = bearingDeg * DEG;
const p1 = lat * DEG;
const p2 = Math.asin(Math.sin(p1) * Math.cos(ad)
+ Math.cos(p1) * Math.sin(ad) * Math.cos(brg));
const l2 = lon * DEG + Math.atan2(
Math.sin(brg) * Math.sin(ad) * Math.cos(p1),
Math.cos(ad) - Math.sin(p1) * Math.sin(p2));
return [l2 / DEG, p2 / DEG];
}
function initialBearingDeg(lon1, lat1, lon2, lat2) {
const p1 = lat1 * DEG; const p2 = lat2 * DEG;
const dl = (lon2 - lon1) * DEG;
const y = Math.sin(dl) * Math.cos(p2);
const x = Math.cos(p1) * Math.sin(p2) - Math.sin(p1) * Math.cos(p2) * Math.cos(dl);
return (Math.atan2(y, x) / DEG + 360) % 360;
}
const schema = 'gridatlas.module.geodesy.v1';
return distanceKm;
})();
/** Actual-computation receipts, shared by Node and browsers. No DOM or network. */
const schema = 'ventus.grid-compute-receipt.v1';
const copy = value => JSON.parse(JSON.stringify(value));
const finite = value => typeof value === 'number' && Number.isFinite(value);
const located = point => point && finite(point.lon) && finite(point.lat)
&& Math.abs(point.lon) <= 180 && Math.abs(point.lat) <= 90;
const sameLocation = (a, b) => located(a) && located(b) && a.lon === b.lon && a.lat === b.lat;
const sameEntity = (a, b) => a && b && a.kind === b.kind && String(a.id) === String(b.id);
/**
* Create one observer per selection surface, not one per project. Every request
* invalidates the previous selection for assessment, including repeated IDs.
* Receipts are evidence about the supplied callback, not proof that a renderer
* used this module. Attach run() at the real calculation call site.
*/
function createComputeObserver({ onEvent = () => {}, now = () => Date.now() } = {}) {
const attempts = new Map();
let sequence = 0;
let latest = null;
const publish = (attempt, status, extra = {}) => {
Object.assign(attempt, extra, { status, sequence: ++sequence, updated_at_ms: now() });
attempt.events.push({ status, sequence: attempt.sequence, at_ms: attempt.updated_at_ms });
// A broken logging consumer must never break the grid calculation itself.
try { onEvent(copy(attempt)); } catch { /* receipt remains queryable */ }
return copy(attempt);
};
const get = id => {
const attempt = attempts.get(id);
if (!attempt) throw new Error('Unknown computation attempt: ' + id);
return attempt;
};
return {
request({ entity, location = null, operation = 'nearest-grid', dataset = null }) {
if (!entity || typeof entity.kind !== 'string' || !entity.kind.trim()
|| entity.id == null || !String(entity.id).trim()) {
throw new TypeError('A computation request requires an entity kind and ID');
}
const id = 'compute-' + (sequence + 1);
const attempt = {
schema, id, entity: { kind: entity.kind, id: String(entity.id) },
location: located(location) ? { lon: location.lon, lat: location.lat } : null,
operation, dataset, requested_at_ms: now(), events: []
};
attempts.set(id, attempt);
latest = id;
publish(attempt, 'requested');
return id;
},
unsupported(id, reason) {
const attempt = get(id);
if (attempt.status !== 'requested') throw new Error('Attempt already invoked or terminal');
return publish(attempt, 'unsupported', { reason: String(reason || 'Unsupported input') });
},
async run(id, compute) {
const attempt = get(id);
if (attempt.status !== 'requested') throw new Error('Attempt already invoked or terminal');
if (!attempt.location) return publish(attempt, 'unsupported', { reason: 'No valid project location' });
if (typeof compute !== 'function') return publish(attempt, 'failed', { reason: 'No computation callback' });
publish(attempt, 'started');
try {
const result = await compute(copy(attempt));
if (!sameLocation(result?.origin, attempt.location)) throw new Error('Result origin does not match this request');
if (!sameEntity(result?.entity, attempt.entity)) throw new Error('Result entity does not match this request');
if (!Array.isArray(result.measurements)) throw new Error('Computation returned no measurements array');
if (result.measurements.length === 0) {
if (result.search_completed !== true || !Number.isInteger(result.scanned_count) || result.scanned_count < 0) {
throw new Error('Empty result lacks completed-search and scanned-count evidence');
}
return publish(attempt, 'completed_empty', { measurements: [],
summary: { measured_count: 0, scanned_count: result.scanned_count, nearest_km: null } });
}
const measurements = result.measurements.map(row => {
if (!row || row.node_id == null || !String(row.node_id).trim()
|| !located(row) || !finite(row.km) || row.km < 0) {
throw new Error('Computation returned an invalid grid measurement');
}
const expected = distanceKm(attempt.location.lon, attempt.location.lat, row.lon, row.lat);
// Receipts carry unrounded values from the shared geodesy, not UI text.
if (Math.abs(expected - row.km) > Math.max(1e-6, expected * 1e-9)) {
throw new Error('Grid distance does not match the request and measured node');
}
return { node_id: String(row.node_id), lon: row.lon, lat: row.lat, km: row.km };
});
return publish(attempt, 'completed', { measurements,
summary: { measured_count: measurements.length, nearest_km: Math.min(...measurements.map(row => row.km)) } });
} catch (error) {
return publish(attempt, 'failed', { reason: String(error?.message || error) });
}
},
snapshot(id = latest) { return id == null ? null : copy(get(id)); },
assess(id, expected) {
if (!attempts.has(id)) return { passed: false, reason: 'never-requested' };
const attempt = get(id);
if (id !== latest) return { passed: false, reason: 'stale-attempt' };
if (!sameEntity(attempt.entity, expected?.entity) || !sameLocation(attempt.location, expected?.location)) {
return { passed: false, reason: 'selection-mismatch' };
}
return { passed: attempt.status === 'completed', reason: attempt.status };
}
};
}
/** Honest UI projection of computation receipts. No inference from a URL. */
function describeComputeReceipt(receipt) {
const status = receipt?.status || 'not_requested';
const summary = receipt?.summary;
const nearest = summary?.nearest_km;
const labels = {
not_requested: 'Grid calculation not requested', requested: 'Grid calculation queued',
started: 'Calculating nearest mapped substations', completed_empty: 'Search completed: no mapped substations returned',
unsupported: 'Grid calculation unavailable', failed: 'Grid calculation failed',
};
if (status === 'completed' && Number.isFinite(nearest) && nearest >= 0) {
return { status, text: `Nearest mapped substation: ${nearest.toFixed(2)} km`,
distance_km: nearest, unit: 'km', scope: 'Geometric screening only; not an electrical connection, capacity or offer.' };
}
return { status, text: labels[status] || 'Grid calculation result unavailable',
reason: receipt?.reason || null, distance_km: null, unit: null,
scope: 'Geometric screening only; not an electrical connection, capacity or offer.' };
}
globalThis.VentusGridCompute = Object.freeze({ schema, distanceKm, createComputeObserver, describeComputeReceipt });
})();
/**
* CARRIED FORWARD AND EDITED, NOT ASSEMBLED. The notice below was true at generation 202609050354. Every generation
* since has been cut by copying the previous cartridge and editing the copy; the parts it names were not touched again
* and no longer reproduce this file (they build 363 KB; this is over 420 KB). Do NOT rebuild this cartridge from those
* parts: that would silently discard everything added since 5 September. Said here at 202609200022 because a header
* that misdescribes how a file is made is the kind of false record this estate keeps finding.
*
* sld-sandbox-v9-8, generation 202609050354 (UTC).
*
* ASSEMBLED by tools/build-cartridge.mjs from the parts below. Do not edit
* this file: edit a part and rebuild under a new generation. Each part is
* hashed in manifests/202609050354-sld-sandbox-v9-8-parts.json.
*
* module atlas/modules/202609012040-grid-scope.js
* module atlas/modules/202609012217-source-registry.js
* module atlas/modules/202609012128-declared-connections.js
* module atlas/modules/202609012205-sizing-arithmetic.js
* module atlas/modules/202609031310-technology-coverage.js
* part atlas/parts/202609041234-sld-sandbox-technology-buckets.js
*/
/**
* Module: grid-scope
*
* "When you click on a blank space, the user should be able to see grid in
* the vicinity. Call it the GRID FINDING SCOPE — analysis of what is
* there, NOT indicative of capacity." — Vikram, 2026-09-01.
*
* So this answers exactly one question: WHAT IS MAPPED HERE. It counts
* what the served payload contains around a point, by voltage class and
* by distance band, and names the nearest few. It is a census of the map,
* not a study of the network.
*
* WHAT IT WILL NOT DO, EVER
* It does not say whether a connection is available, likely, cheap or
* possible. Nothing in a payload of substation positions can support any
* of that: capacity depends on queue position, committed connections,
* thermal and fault headroom, consent and commercial terms, and none of
* those is a distance. A scope that counted substations and implied
* opportunity would be the most dangerous thing this estate could ship,
* because it would look like analysis.
*
* Pure. No DOM, no network, no state. Depends on: geodesy.
*/
(() => {
'use strict';
const NS = (window.__GRIDATLAS_MODULES__ = window.__GRIDATLAS_MODULES__ || {});
if (NS.gridScope) return;
const geodesy = NS.geodesy;
if (!geodesy) throw new Error('grid-scope requires the geodesy module');
/* Bands, not a single radius. A reader asking "what is around here"
wants the shape of the answer - is the nearest thing on top of me or
twenty kilometres away - and one number hides that. */
const DEFAULT_BANDS_KM = [2, 5, 10, 25];
const CLASSES_KV = [400, 275, 220, 132, 66, 33];
/* A voltage is classified ONLY as a class it actually is.
------------------------------------------------------------------
The first version walked the classes and returned the first one the
value exceeded, so it labelled 750 kV as 400, 110 kV as 66 and 50 kV
as 33 - a false label on anything the list does not contain, which is
exactly the sort of quiet relabelling this estate exists to avoid.
Codex caught it on the committed module before it reached a card
(stop-ship 202609012025).
Now: membership, within a tolerance for the fractions OSM carries.
Anything else is UNCLASSIFIED and counted as such, because a voltage
the standard classes do not contain is a fact about the data, not a
value to be rounded into the nearest familiar number. */
const CLASS_TOLERANCE_KV = 0.5;
function classOf(kv) {
if (!Number.isFinite(kv)) return null;
for (const known of CLASSES_KV) {
if (Math.abs(kv - known) <= CLASS_TOLERANCE_KV) return known;
}
return null;
}
/**
* @param origin [lon, lat]
* @param substations [{ at:[lon,lat], kv:[numbers], name, operator }]
* @param options { bandsKm, minimumKv, nearestCount }
*/
function scope(origin, substations, options) {
const bandsKm = (options && options.bandsKm) || DEFAULT_BANDS_KM;
const minimumKv = (options && options.minimumKv) || 0;
const nearestCount = (options && options.nearestCount) || 5;
const maximumKm = bandsKm[bandsKm.length - 1];
const within = [];
for (const substation of substations || []) {
if (!substation || !Array.isArray(substation.at)) continue;
const voltages = (Array.isArray(substation.kv) ? substation.kv : [])
.filter(Number.isFinite);
/* Non-finite voltages are dropped BEFORE the maximum.
----------------------------------------------------------------
Codex, 202609012055: Math.max over a NaN gives NaN, and NaN < floor
is false, so a substation whose voltage did not parse survived a
132 kV floor and was censused as though it qualified. A voltage
that is not a number is not a voltage above the floor. */
const top = voltages.length ? Math.max(...voltages) : 0;
if (top < minimumKv) continue;
const km = geodesy.distanceKm(origin[0], origin[1],
substation.at[0], substation.at[1]);
if (km > maximumKm) continue;
within.push({
name: substation.name || '',
operator: substation.operator || '',
kv: top,
class_kv: classOf(top),
km,
at: substation.at
});
}
within.sort((a, b) => a.km - b.km);
const bands = bandsKm.map((band) => {
const inBand = within.filter(entry => entry.km <= band);
const counts = {};
let unclassified = 0;
const unclassifiedKv = [];
for (const entry of inBand) {
if (entry.class_kv == null) {
// Counted, never folded into a class it is not.
unclassified += 1;
if (Number.isFinite(entry.kv) && !unclassifiedKv.includes(entry.kv)) {
unclassifiedKv.push(entry.kv);
}
continue;
}
counts[entry.class_kv] = (counts[entry.class_kv] || 0) + 1;
}
const highest = inBand.reduce(
(best, entry) => (entry.class_kv != null && (best == null || entry.class_kv > best)
? entry.class_kv : best), null);
return {
within_km: band,
substations: inBand.length,
by_class_kv: counts,
highest_class_kv: highest,
unclassified_voltage: unclassified,
unclassified_kv: unclassifiedKv.sort((a, b) => b - a)
};
});
/* Named first, because an unnamed OSM node is a fact about the map
rather than a place anyone can look up. Both are reported: the
nearest thing, and the nearest thing with an identity. */
const named = within.filter(entry => entry.name);
return {
schema: 'gridatlas.grid-scope.v1',
origin: [origin[0], origin[1]],
radius_km: maximumKm,
minimum_kv: minimumKv,
counted: within.length,
bands,
nearest: within.slice(0, nearestCount),
nearest_named: named.slice(0, nearestCount),
nearest_transmission: within.find(entry => entry.kv >= 275 - 0.5) || null,
/* Carried in the result itself so it cannot be separated from the
numbers by a renderer, a screenshot or a quote. */
what_this_is: 'A census of the substations in the served map payload '
+ 'around this point, by voltage class and distance band.',
what_this_is_not: 'Not a statement about capacity, headroom, '
+ 'availability or the cost of connecting here. Distance is not '
+ 'capacity: queue position, committed connections, thermal and '
+ 'fault headroom, consent and commercial terms decide that, and '
+ 'none of them is in this payload.',
method: 'haversine on a single Earth radius of '
+ geodesy.EARTH_RADIUS_KM + ' km, straight line to mapped geometry'
};
}
NS.gridScope = Object.freeze({
schema: 'gridatlas.module.grid-scope.v2',
CLASS_TOLERANCE_KV,
DEFAULT_BANDS_KM,
CLASSES_KV,
classOf,
scope
});
})();
/**
* Module: source-registry
*
* "Click anywhere on a map and the neons that already work via Pipeline News
* look for cartridges and code." — Vikram, 2026-09-01.
*
* The looking is this module. The Atlas is a composition of cartridges that
* find each other through `window.__GRIDATLAS_*` globals, and the deep scan
* of 1 Sep 2026 found fifteen such surfaces ever registered, thirteen live,
* and nothing anywhere that documents them. Every consumer therefore does
* its own `window.__GRIDATLAS_NETWORK__?.something` and quietly does less
* when the answer is undefined. That is how a click on blank space came to
* report only what OpenStreetMap has mapped, while the cartridge holding
* NESO's 886 published connection points sat loaded in the same page.
*
* So: one registry, declared once, that answers three questions.
*
* WHAT COULD ANSWER the sources this estate knows about, each with
* what it contributes and whether it is required.
* WHAT IS ANSWERING NOW probed live, by looking for the surface AND the
* specific capability, because a cartridge that
* has loaded but not yet fetched is present and
* not yet useful, and those are different states.
* WHAT DID NOT named, with the reason, in the result itself.
*
* The third is the point. A reader who is told "3 of 4 sources answered;
* NESO's published network did not, because its payload had not loaded" can
* judge the answer. A reader shown a shorter answer cannot, and will
* reasonably assume the map has told them everything it knows.
*
* It reads. It never fetches, never renders, and never decides what a
* finding means.
*
* Successor to 202609012135 at generation 202609012217: every source that
* fetches a product declares what it REQUIRES (repository, product, schema)
* and the survey carries that in every state, because a contract stated
* only once the load has succeeded is no help to the reader of a failure.
* The GB price rollup, fetched since v9.41 without a row here, is
* registered with the loader state the sandbox now publishes.
*
* Depends on: nothing.
*/
(() => {
'use strict';
const NS = (window.__GRIDATLAS_MODULES__ = window.__GRIDATLAS_MODULES__ || {});
if (NS.sourceRegistry) return;
/* The registry is DECLARED, not discovered by scanning window.
----------------------------------------------------------------------
Enumerating every __GRIDATLAS_* global would report whatever happens to
be there, including surfaces this estate has never agreed to consume,
and would silently start using a new one the day someone adds it. A
declared list is a contract: adding a source is an edit here, with a
reason, and a proof that the probe actually works. */
const SOURCES = [
{
id: 'map',
surface: '__GRIDATLAS_V9_MAP__',
contributes: 'the map itself: where the click happened, and what is drawn',