In this section
- Browser Real Map to Engine Agent7 test · globalgrid2050 / uk_renewables_pipeline/202611160020/tests/browser_real_map_to_engine_agent7.mjs lines 1–260
- Atlas Receiver V9 7 ingest · globalgrid2050 / uk_renewables_pipeline/202611171507/scripts/core/atlas-receiver-v9-7.js lines 1–265
- GridAtlas State render · globalgrid2050 / uk_renewables_pipeline/202611171550/scripts/plugins/gridatlas-state.js lines 1–68
- Map Entry interaction · globalgrid2050 / uk_renewables_pipeline/202611181019/map-entry.mjs lines 1–89
Browser Real Map to Engine Agent7
A JavaScript module in the tests folder of GlobalGrid2050 that tests substations and solar, and uses data from the GridAtlas repository. It is built from the located step (`located`).
testglobalgrid2050 / uk_renewables_pipeline/202611160020/tests/browser_real_map_to_engine_agent7.mjs · lines 1–260 of 260 · version 2026-11-16 00:20 · Entry point · pattern located (shared by 9 files)
- What it does
- It tests substations and solar. Defines located. Uses libraries node:assert/strict, node:fs/promises, node:path, node:url, node:module. Side effects: changes the web page (DOM); reads or writes files.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'renewables'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: substations, solar.
- Inputs & outputs
- In: data source: gridatlas data; JSON file build_manifest.json.
- Downstream impact
- Used directly by 3 files: GlobalGrid2050 Agent7 V922 CI Workflow (globalgrid2050); GlobalGrid2050 Deploy Pages Workflow (globalgrid2050); GlobalGrid2050 V923 GridAtlas Real Map QA Workflow (globalgrid2050).
- What it achieves
- Live GridAtlas deep-link proof. Unlike URL-only tests, physically clicks a Pipeline News MAP anchor, opens its actual external page, and demands a composed receiver, a terminal no-error technology layer and visible nearest substation result.
- Why it matters
- Run by GlobalGrid2050 Agent7 V922 CI Workflow, GlobalGrid2050 Deploy Pages Workflow and GlobalGrid2050 V923 GridAtlas Real Map QA Workflow.
- Application
- globalgrid2050 · uk_renewables_pipeline/202611160020/tests · JavaScript module
- Uses
- GridAtlas — Atlas Page (estate URL), node:assert/strict, node:fs/promises, node:path, node:url, node:module, playwright
- Used by
- run by GlobalGrid2050 Agent7 V922 CI Workflow (workflow run), run by GlobalGrid2050 Deploy Pages Workflow (workflow run), run by GlobalGrid2050 V923 GridAtlas Real Map QA Workflow (workflow run)
- Produces
- located
- Defines here
- located
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 uk_renewables_pipeline/202611160020/tests/browser_real_map_to_engine_agent7.mjs:1-260 · blob 8057f56e0ec558d7127b2580c358f47a08810db3 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
/* Live GridAtlas deep-link proof. Unlike URL-only tests, physically clicks a
* Pipeline News MAP anchor, opens its actual external page, and demands a
* composed receiver, a terminal no-error technology layer and visible nearest
* substation result. Real network and engine; no destination mocks or fake flags.
* Reports each attempt including failures; a retry never erases initial red.
* This is a DIAGNOSTIC SUBSET, never evidence of all 7,775 executions or
* independent reviewer acceptance. 15 November 2026.
*/
import assert from 'node:assert/strict';
import { readFile, mkdir, writeFile } from 'node:fs/promises';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { createRequire } from 'node:module';
const require = createRequire(new URL('../package.json', import.meta.url));
const { chromium } = require('playwright');
const HERE = dirname(fileURLToPath(import.meta.url));
const ROOT = join(HERE, '..');
const OUTPUT = process.env.AGENT7_ENGINE_REPORT_DIR || '/tmp/agent7-engine';
const CANDIDATE = process.env.AGENT7_PIPELINE_SOURCE
|| 'http://127.0.0.1:8765/uk_renewables_pipeline/202611151300/';
const MODE = process.env.AGENT7_ENGINE_MODE || 'local';
const WIDTH = Number(process.env.AGENT7_ENGINE_WIDTH || 1440);
const SAMPLE_LIMIT = Number(process.env.AGENT7_ENGINE_SAMPLE_LIMIT || 2);
const MAX_MS = Number(process.env.AGENT7_ENGINE_WAIT_MS || 85000);
assert.ok([390, 1440].includes(WIDTH), 'unknown test viewport');
assert.ok(SAMPLE_LIMIT >= 1 && SAMPLE_LIMIT <= 6, 'limited honest runtime matrix');
const manifest = JSON.parse(await readFile(join(ROOT, 'data/v9.1/build_manifest.json'), 'utf8'));
const rows = [];
for (const part of manifest.project_partitions) {
const d = JSON.parse(await readFile(join(ROOT, part.path), 'utf8'));
rows.push(...d.projects);
}
assert.equal(rows.length, 7775);
function located(row) {
return Number.isFinite(Number(row.latitude))
&& Number.isFinite(Number(row.longitude))
&& Number(row.latitude) >= 50 && Number(row.latitude) <= 59
&& Number(row.longitude) >= -6 && Number(row.longitude) <= 1;
}
const classes = ['solar', 'bess', 'wind_onshore'];
const chosen = classes.map(tech => rows.find(row => row.technology === tech && located(row)
&& String(row.repd_ref).match(/^\d+$/))).filter(Boolean).slice(0, SAMPLE_LIMIT);
assert.equal(chosen.length, SAMPLE_LIMIT,
'not enough distinct solar/battery/onshore samples to claim this matrix');
await mkdir(OUTPUT, { recursive: true });
const receipts = [];
const browser = await chromium.launch({ headless: true });
let fatal = false;
try {
for (const record of chosen) {
const receipt = {
source: CANDIDATE, mode: MODE, width: WIDTH,
repd_ref: String(record.repd_ref), technology: record.technology,
expected_coordinates: { latitude: Number(record.latitude), longitude: Number(record.longitude) },
source_head: process.env.GITHUB_SHA || 'UNKNOWN',
status: 'FAIL',
start_utc: new Date().toISOString(),
phases: {},
page_errors: [], console_errors: [], request_failures: []
};
receipts.push(receipt);
const context = await browser.newContext({
viewport: { width: WIDTH, height: 900 }, isMobile: WIDTH === 390,
hasTouch: WIDTH === 390, acceptDownloads: true
});
const page = await context.newPage();
let arrival;
try {
// Stub only optional library on SOURCE; never mock receiver, cartridges,
// basemap, data, computation or network on the destination page.
await page.addInitScript(() => {
window.Chart = class ChartStub { constructor(_c, c) { this.data = c.data; } update() {} };
});
await page.route('https://cdn.jsdelivr.net/**',
route => route.fulfill({ status: 200, contentType: 'application/javascript', body: '' }));
if (MODE === 'local') {
// Allows an honest no-headlines state without relying on a live RSS file
// for a separate MAP test. Does NOT affect the destination GridAtlas.
await page.route('https://raw.githubusercontent.com/Ventusltd/globalgrid2050/pipeline-news-data/**',
route => route.fulfill({
status: 200, contentType: 'application/json',
headers: { 'access-control-allow-origin': '*' },
body: JSON.stringify({ schema: 'globalgrid2050.news.pipeline-headlines.v1',
generated_at: new Date().toISOString(), status: 'ok',
items: [], counts: { feeds_ok: 0, feeds_failed: 0 } })
}));
}
await page.goto(CANDIDATE, { waitUntil: 'domcontentloaded', timeout: 60000 });
await page.waitForFunction(() => document.getElementById('tbody')?.dataset.total === '7775',
null, { timeout: 70000 });
const search = page.locator('#search');
await search.fill(String(record.repd_ref));
const target = page.locator('#tbody a.atlaslink[href*="repd_ref=' + record.repd_ref + '"]').first();
await target.waitFor({ state: 'visible', timeout: 35000 });
await target.scrollIntoViewIfNeeded();
const hit = await target.evaluate(a => {
const b = a.getBoundingClientRect();
const el = document.elementFromPoint(b.left + b.width / 2, b.top + b.height / 2);
return { width: b.width, height: b.height, left: b.left, right: b.right,
viewport: document.documentElement.clientWidth, reachable: el === a || a.contains(el),
href: a.href };
});
receipt.phases.map_hit = hit;
assert.ok(hit.reachable && hit.left >= 0 && hit.right <= hit.viewport + 1
&& hit.width >= 44 && hit.height >= 44, 'MAP not physically clickable');
const href = new URL(hit.href);
assert.equal(href.origin + href.pathname, 'https://ventusltd.github.io/gridatlas/atlas/');
assert.equal(href.searchParams.get('repd_ref'), receipt.repd_ref);
assert.equal(href.searchParams.get('technology'), record.technology);
assert.equal(Number(href.searchParams.get('latitude')), Number(record.latitude));
assert.equal(Number(href.searchParams.get('longitude')), Number(record.longitude));
const popup = context.waitForEvent('page', { timeout: 20000 });
await target.click({ timeout: 20000 });
arrival = await popup;
const arrived = new URL(arrival.url());
receipt.phases.actual_clicked_url = arrived.href;
assert.equal(arrived.origin + arrived.pathname, href.origin + href.pathname);
assert.equal(arrived.searchParams.get('repd_ref'), receipt.repd_ref);
receipt.phases.popup_created = true;
arrival.on('pageerror', e => receipt.page_errors.push(String(e.message || e).slice(0,240)));
arrival.on('console', m => {
if (m.type() === 'error') receipt.console_errors.push(m.text().slice(0,240));
});
arrival.on('requestfailed', req => {
receipt.request_failures.push({ url: req.url().slice(0,200),
why: req.failure()?.errorText || 'request failed' });
});
await arrival.waitForLoadState('domcontentloaded', { timeout: 60000 });
// Real engine state first. A phone intentionally collapses the project
// card on arrival; looking only at document.body.innerText before the
// user expands it would falsely report a failed calculation.
await arrival.waitForFunction(() => {
const runtime = window.__GRIDATLAS_NEON_LINKS__;
const atlas = window.__GRIDATLAS_ATLAS__;
return !!atlas && !!runtime
&& Array.isArray(runtime.failures) && runtime.failures.length === 0
&& !!document.documentElement.dataset.gridatlasGeneration
&& runtime.technology_layer?.enabled === true
&& !!runtime.project_layer_enabled;
}, null, { timeout: MAX_MS });
const initialCard = await arrival.evaluate(() => {
const popup = document.querySelector('.maplibregl-popup');
const hidden = document.body?.textContent || '';
const visible = document.body?.innerText || '';
const button = popup?.querySelector('.gridatlas-card-bar button.min');
return {
popup_found: !!popup,
minimized: popup?.classList.contains('gridatlas-min') || false,
control_exists: !!button,
control_text: button?.textContent?.trim() || null,
nearest_in_hidden_dom: /Nearest\s+\d+\s*kV\s+substation\s*:/i.test(hidden),
nearest_visible: /Nearest\s+\d+\s*kV\s+substation\s*:/i.test(visible),
viewport_visibility: document.visibilityState
};
});
receipt.phases.card_on_arrival = initialCard;
if (initialCard.minimized) {
// Simulate the reader explicitly restoring the mobile measurement card.
// This is NOT a fake engine result: only an actual user-operable click
// may expose the real computed nearest and source-identity evidence.
assert.ok(initialCard.control_exists, 'mobile project card minimised with no restore button');
const restore = arrival.locator('.maplibregl-popup.gridatlas-min .gridatlas-card-bar button.min').first();
await restore.click({ timeout: 15000 });
receipt.phases.card_restored_by_real_click = true;
}
try {
await arrival.waitForFunction(() =>
/Nearest\s+\d+\s*kV\s+substation\s*:/i.test(document.body?.innerText || ''),
null, { timeout: 35000 });
} catch (e) {
receipt.phases.visible_nearest_timeout = String(e.message).slice(0,180);
}
// Recheck at 1.7 s, 5.7 s (past the known 5.3 s reset) and 10.1 s.
// A computed-but-hidden result or a card that re-minimises is a FAIL.
const visibilityStability = [];
let elapsedMs = 0;
for (const deltaMs of [1700, 4000, 4400]) {
await arrival.waitForTimeout(deltaMs);
elapsedMs += deltaMs;
const sample = await arrival.evaluate(() => {
const body = document.body?.innerText || '';
return {
nearest_visible: /Nearest\s+\d+\s*kV\s+substation\s*:/i.test(body),
minimised: !!document.querySelector('.maplibregl-popup.gridatlas-min')
};
});
visibilityStability.push({ elapsed_ms: elapsedMs, ...sample });
}
receipt.phases.visibility_stability = visibilityStability;
const state = await arrival.evaluate(() => {
const a = window.__GRIDATLAS_ATLAS__ || null;
const x = window.__GRIDATLAS_NEON_LINKS__ || null;
const body = document.body?.innerText || '';
return {
router_state: document.body?.dataset.gridatlasRouter || null,
generation: document.documentElement.dataset.gridatlasGeneration || null,
atlas_schema: a?.schema || null, composition_generation: a?.generation || null,
cartridge_count: a?.loaded_cartridges?.length ?? null,
technology_layer: x?.technology_layer || null,
project_layer_enabled: x?.project_layer_enabled ?? null,
failures: x?.failures || null,
nearest_excerpt: (body.match(/Nearest\s+\d+\s*kV\s+substation\s*:[^\n]{0,150}/i) || [])[0] || null,
still_minimised: !!document.querySelector('.maplibregl-popup.gridatlas-min'),
nearest_in_dom_even_if_hidden: /Nearest\s+\d+\s*kV\s+substation\s*:/i.test(document.body?.textContent || ''),
has_loading_spinner: /GRIDATLAS COMPOSITION FAILED|verifying immutable shell and cartridges/i.test(body),
headline: body.slice(0, 360)
};
});
receipt.phases.runtime = state;
await arrival.screenshot({
path: join(OUTPUT, 'engine-' + WIDTH + '-' + record.repd_ref + '.png'),
fullPage: false, timeout: 18000
}).catch(e => { receipt.phases.screenshot_error = e.message.slice(0,160); });
assert.ok(state.generation && state.generation === state.composition_generation,
'composed generation mismatch/absent');
assert.ok(state.cartridge_count >= 4, 'no verified cartridge composition receipt');
assert.ok(state.router_state !== 'failed', 'GridAtlas composer failed');
assert.deepEqual(state.failures, [], 'GridAtlas runtime failures not empty');
assert.equal(state.technology_layer?.enabled, true, 'technology layer not enabled');
assert.ok(state.project_layer_enabled, 'project layer not enabled');
assert.ok(state.nearest_excerpt, 'NO real nearest-substation output observed');
assert.ok(visibilityStability.length === 3
&& visibilityStability.every(s => s.nearest_visible && !s.minimised),
'Mobile nearest result not continuously user-visible after manual restore at 1.7/5.7/10.1 s');
assert.equal(receipt.page_errors.length, 0, 'destination page exceptions');
receipt.status = 'PASS';
} catch (error) {
receipt.why = String(error?.message || error).slice(0,800);
fatal = true;
} finally {
receipt.ended_utc = new Date().toISOString();
console.log(JSON.stringify({ repd_ref: receipt.repd_ref, tech: receipt.technology,
width: receipt.width, mode: receipt.mode, status: receipt.status,
why: receipt.why || null, output: receipt.phases.runtime?.nearest_excerpt || null }));
await context.close().catch(() => {});
}
}
} finally {
await browser.close();
const path = join(OUTPUT, 'real-map-engine-receipts-' + MODE + '-' + WIDTH + '.json');
await writeFile(path, JSON.stringify({
schema: 'globalgrid2050.agent7.real-map-engine-receipts.v1',
generated_at: new Date().toISOString(),
sampled_rows: chosen.length,
full_population: rows.length,
coverage: 'PARTIAL_SAMPLE_ONLY',
note: 'Real browser click and external engine. This does not certify all onshore/nearshore or legal rights.',
receipts
}, null, 2) + '\n');
}
if (fatal) {
console.error('Real MAP→GridAtlas→Engine subset FAILED / partial. See per-REPD receipts.');
process.exitCode = 1;
} else {
console.log('Real MAP→GridAtlas→Engine diagnostic subset passed; global coverage PARTIAL ONLY');
}Atlas Receiver V9 7
A JavaScript module in the core folder of GlobalGrid2050 that fetches receivers and the Renewable Energy Planning Database (REPD) register from the ventus-grid-engine and GridAtlas repositories.
ingestglobalgrid2050 / uk_renewables_pipeline/202611171507/scripts/core/atlas-receiver-v9-7.js · lines 1–265 of 265 · version 2026-11-17 15:07 · pattern verifyAtlasReceiver (shared by 2 files)
- What it does
- It fetches receivers and the REPD register. Defines 10 functions or classes, including stripTrailingSlash, isRetiredReceiverV9_7, atlasReceiverV9_7, atlasReceiverFailureV9_7, primeAtlasReceiverV9_7. Side effects: 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: the REPD register.
- Inputs & outputs
- In: data source: ventus-grid-engine data; data source: gridatlas data; JSON file receivers.json.
- Downstream impact
- Used directly by 13 files: Atlas Interconnector Link V9 8 (globalgrid2050); Browser Map Reachability V9 7 (globalgrid2050); Check Map Contract All Rows (globalgrid2050); Check V9 0 (globalgrid2050); and 9 more. Reached from 17 other entry points, including GlobalGrid2050 — UK Renewables Pipeline Page (globalgrid2050, https://globalgrid2050.com/uk_renewables_pipeline/202611280922/); GlobalGrid2050 Pipeline Legal Evidence Workflow (globalgrid2050); GlobalGrid2050 Pn V973 Capacity Reports Workflow (globalgrid2050).
- What it achieves
- It verifies atlas receiver v9 (`verifyAtlasReceiverV9_7`), loads atlas receiver v9 (`loadAtlasReceiverV9_7`) and builds atlas deep link v9 (`buildAtlasDeepLinkV9_7`). Receiver provenance and original diagnostics: immutable parent V9.35 `atlas-receiver-v9-7.js`.
- Why it matters
- Imported by 4 files, including Atlas Interconnector Link V9 8, Projects V9 5 1 and Projects V9 9. Checked by 9 tests, including Browser Map Reachability V9 7.
- Application
- globalgrid2050 · uk_renewables_pipeline/202611171507/scripts/core · JavaScript module
- Uses
- GridAtlas — Atlas Page (estate URL), GlobalGrid2050 — Renewable Energy Planning Database (REPD) Grid Atlas v8 Page (estate URL)
- Used by
- imported by Atlas Interconnector Link V9 8 (import), referenced by Browser Map Reachability V9 7 (new URL import.meta.url), referenced by Check Map Contract All Rows (new URL import.meta.url), imported by Check V9 0 (import), run by Check V9 5 1 (script call), referenced by Contract Failure Semantics V9 7 (new URL import.meta.url), imported by Projects V9 5 1 (import), referenced by Check V9 8 (new URL import.meta.url), and 5 more
- Produces
- isRetiredReceiverV9_7, atlasReceiverV9_7, atlasReceiverFailureV9_7, primeAtlasReceiverV9_7, verifyAtlasReceiverV9_7, loadAtlasReceiverV9_7, atlasCentresOnRepdPointV9_7, buildAtlasDeepLinkV9_7, atlasUnavailableReasonV9_7
- Defines here
- stripTrailingSlash, isRetiredReceiverV9_7, atlasReceiverV9_7, atlasReceiverFailureV9_7, primeAtlasReceiverV9_7, verifyAtlasReceiverV9_7, loadAtlasReceiverV9_7, atlasCentresOnRepdPointV9_7, buildAtlasDeepLinkV9_7, atlasUnavailableReasonV9_7
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 uk_renewables_pipeline/202611171507/scripts/core/atlas-receiver-v9-7.js:1-265 · blob df95b5d3932864a0b0f4f1b9ad72a5b793ef5c3f · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: ingest · effects: network · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
/* Receiver provenance and original diagnostics: immutable parent V9.35 atlas-receiver-v9-7.js. */
const RECEIVERS_URL = "https://ventusltd.github.io/ventus-grid-engine/deeplink/receivers.json";
const RECEIVERS_SCHEMA = "ventus.grid-engine.deeplink-receivers.v1";
/* The parameters the deep-link contract names, in its own order. `project` and
* `capacity_mw` are deliberately NOT sent: the contract's PARAMS does not carry
* them, and the canonical receiver resolves the project's identity, name,
* capacity, postcode and status from the REPD reference on its own — verified
* live on REPD 8162 and on REPD 13429, which has no REPD coordinate at all. */
const CONTRACT_PARAMS = Object.freeze(["repd_ref", "technology", "latitude", "longitude", "zoom"]);
/* How long a stalled socket may hold the verification open. Nothing waits on
* it any more, so this is only about not leaking a request for ever; iOS
* Safari's own ceiling is of the order of 60-75 s, which is not a bound. */
const VERIFY_TIMEOUT_MS = 5000;
/* ── THE COMPILED-IN CONTRACT, AND WHY IT IS NOT THE OLD MISTAKE ────────────
*
* The version of this module shipped at 202609050353 held no route at all and
* built no link until a cross-origin fetch to ventusltd.github.io resolved.
* Measured 2026-09-05 that fetch sat inside the same Promise.all that gates the
* first table paint, so not one of 7,680 rows could appear until a request to a
* SECOND ORIGIN completed — a full DNS + TCP + TLS handshake before the first
* row, on a cold mobile radio, on a page with an empty <tbody> and no
* placeholder. 59 ms on a wired link, which is why it was invisible on desktop.
* And it had no fallback: had that request failed, every row would have
* rendered NO MAP plus an explanatory paragraph. 7,680 dead cells.
*
* WHAT MAKES A DEFAULT SAFE THIS TIME. The original defect was seven copies of
* a route in seven plugins, none of which the engine could correct. This is one
* copy, in one module, of the engine's own published document — and it is
* PINNED to that document by a gate that reads both:
*
* testcode/drivers/link-targets.mjs
* "the compiled-in receiver contract matches the engine's published one"
*
* If ventus-grid-engine/deeplink/receivers.json ever names a different
* canonical route, or retires this one, that driver goes red offline, in the
* estate's own instrument, before anything ships. A hard-coded route the estate
* cannot notice drifting is the fault; a hard-coded route the estate checks
* every run is a cache. The difference is the gate, and the gate exists.
*
* AND THE LIVE DOCUMENT STILL WINS. verifyAtlasReceiverV9_7() fetches it after
* the table has painted. If it names a different canonical route, that route
* replaces this one and the MAP cells re-render. If it names THIS route as
* retired, the links are withdrawn and the cells say so — the engine keeps the
* power to retire a receiver once, in the place that knows. What it no longer
* has is the power to leave the page with no links at all because a handshake
* was slow. */
const COMPILED_CONTRACT = Object.freeze({
schema: RECEIVERS_SCHEMA,
canonical: Object.freeze({
id: "gridatlas-v9",
route: "https://ventusltd.github.io/gridatlas/atlas/",
carries_engine: true,
}),
retired: Object.freeze([Object.freeze({
id: "repd-grid-atlas-v8",
route: "https://globalgrid2050.com/repd_grid_atlasv8/",
carries_engine: false,
})]),
compiled_from: "ventus-grid-engine/deeplink/receivers.json",
compiled_utc: "202609051100",
});
let canonicalRoute = "";
let retiredRoutes = [];
let failureReason = "the deep-link contract has not been read yet";
/* WHY a prime failed, not just that it did. "unusable" means the document could
not be understood - a schema this build does not know, or a contract that
contradicts itself. "withdrawn" means a document this build DID understand
instructed it that there is no receiver to link to. Only the second is the
engine exercising its power to retire a receiver; the first is a document
this page is in no position to act on, and acting on it is how a schema bump
in a file on another origin silently stripped every MAP link from the page. */
let failureKind = "unusable";
let pending = null;
let verification = null;
const stripTrailingSlash = (route) => String(route || "").replace(/\/+$/u, "");
export function isRetiredReceiverV9_7(route) {
return retiredRoutes.includes(stripTrailingSlash(route));
}
export function atlasReceiverV9_7() {
return canonicalRoute;
}
export function atlasReceiverFailureV9_7() {
return canonicalRoute ? "" : failureReason;
}
/* Exposed so a test can drive every branch of this module without a network —
* a check that can only run online is a check that quietly stops running. It
* takes the contract DOCUMENT, never a bare route, so there is still no way to
* name a receiver by hand and have this module believe it. */
export function primeAtlasReceiverV9_7(document_) {
canonicalRoute = "";
retiredRoutes = [];
failureReason = "";
pending = null;
if (!document_ || document_.schema !== RECEIVERS_SCHEMA) {
failureReason = `deep-link contract schema is ${document_ && document_.schema}, expected ${RECEIVERS_SCHEMA}`;
failureKind = "unusable";
return "";
}
const route = document_.canonical && document_.canonical.route;
if (!route) {
failureReason = "the deep-link contract names no canonical receiver";
failureKind = "withdrawn";
return "";
}
if (document_.canonical.carries_engine !== true) {
failureReason = "the deep-link contract's canonical receiver does not claim to carry the engine";
failureKind = "withdrawn";
return "";
}
retiredRoutes = (Array.isArray(document_.retired) ? document_.retired : [])
.map((entry) => stripTrailingSlash(entry && entry.route))
.filter(Boolean);
if (isRetiredReceiverV9_7(route)) {
// The contract contradicting itself must fail loudly, not resolve itself.
retiredRoutes = [];
failureReason = "the deep-link contract names its own canonical receiver as retired";
failureKind = "unusable";
return "";
}
canonicalRoute = route;
failureKind = "";
return canonicalRoute;
}
/* The receiver is known at import, from the compiled-in contract above, before
* any network exists. Every branch of primeAtlasReceiverV9_7() still applies to
* it — a compiled contract that failed its own schema or named its canonical
* route as retired would leave canonicalRoute empty here exactly as a fetched
* one would, and the drift gate would already have gone red. */
primeAtlasReceiverV9_7(COMPILED_CONTRACT);
/* VERIFICATION, NOT PRECONDITION. Nothing awaits this before painting. It is
* fired beside the project payload, resolves whenever it resolves, and reports
* whether the page's links have to change. `changed` is the only reason to
* re-render, and on a correct estate it is always false — the compiled contract
* is pinned to the published one by a gate, so a re-render is the signal that
* something drifted, not a routine cost every reader pays.
*
* It cannot make things worse: a failure, a timeout, a malformed document or a
* schema bump all leave the compiled-in route standing and record why. The one
* thing it CAN do is withdraw the links, and only on the engine's explicit
* instruction — a document this build understood that names no usable canonical
* receiver.
*
* That paragraph was false when it was written. Until 2026-09-05 every prime
* failure took the same branch, so a schema this build did not recognise was
* treated as an instruction and stripped the links, returning verified:true.
* The difference is now carried by failureKind, and `withdrawn` reports it
* separately from `verified` so a caller cannot read "the document was read"
* as "the links are correct". */
export async function verifyAtlasReceiverV9_7() {
if (verification) return verification;
const before = canonicalRoute;
verification = (async () => {
try {
/* `cache: "no-store"` was here. It discarded the response and refused the
HTTP cache, so every load made a fresh cross-origin round trip for a
document the server itself publishes as cacheable for ten minutes
(Cache-Control: max-age=600, Access-Control-Allow-Origin: *).
AbortSignal.timeout bounds a stalled socket, which nothing did. */
const response = await fetch(RECEIVERS_URL, {
mode: "cors",
signal: AbortSignal.timeout(VERIFY_TIMEOUT_MS),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const live = await response.json();
const route = primeAtlasReceiverV9_7(live);
if (!route) {
const reason = atlasReceiverFailureV9_7();
if (failureKind === "unusable") {
/* The document arrived but this build cannot read it — an unknown
schema, or a contract that names its own canonical route retired.
That is not an instruction, it is a document we are in no position
to act on, and the comment above has always said so. Measured on
2026-09-05: it did the opposite. A schema bump on a file hosted on
a SECOND ORIGIN removed every MAP link from this page and reported
verified:true while doing it. Stand on the compiled contract, which
is pinned to the published one by a gate, and say why. */
primeAtlasReceiverV9_7(COMPILED_CONTRACT);
return { route: canonicalRoute, changed: false, verified: false, withdrawn: false, reason };
}
/* A document this build DID understand, instructing that there is no
receiver to link to. This is the engine retiring a receiver once, in
the place that knows, and it is the whole reason the contract is read
at all. verified:true says the document was read and honoured; it is
`withdrawn` that says the links are gone, so the two are no longer
conflated in one flag. */
return { route: "", changed: before !== "", verified: true, withdrawn: true, reason };
}
return { route, changed: route !== before, verified: true, withdrawn: false, reason: "" };
} catch (error) {
/* Keep the compiled-in contract. It is pinned to the published one by
testcode/drivers/link-targets.mjs, so standing on it is standing on the
last verified reading of the engine's own document, not on a guess. */
primeAtlasReceiverV9_7(COMPILED_CONTRACT);
return {
route: canonicalRoute,
changed: false,
verified: false,
withdrawn: false,
reason: `the deep-link contract at ${RECEIVERS_URL} could not be read (${(error && error.message) || error}); the compiled-in contract of ${COMPILED_CONTRACT.compiled_utc} still applies`,
};
}
})();
return verification;
}
/* Kept so nothing that imported the old name breaks, and so a caller that only
* wants the route still gets one. It no longer gates anything: the route is
* already there when this is called. */
export async function loadAtlasReceiverV9_7() {
if (!pending) pending = verifyAtlasReceiverV9_7().then((result) => result.route);
return pending;
}
/* True when this record carries a REPD coordinate the map can centre on. The
* 28 records that do not are still linkable: the receiver resolves them from
* the REPD reference and centres on its own geometry, which was measured on
* REPD 13429 (Ossian) — it arrives and names the project. They are labelled
* rather than denied a button, because a button that silently does nothing is
* exactly what hid this defect. */
export function atlasCentresOnRepdPointV9_7(project) {
return Boolean(project) && project.geometry_status === "valid";
}
export function buildAtlasDeepLinkV9_7(project) {
if (!canonicalRoute) return "";
if (!project || project.repd_ref === undefined || project.repd_ref === null || project.repd_ref === "") return "";
const values = {
repd_ref: project.repd_ref,
technology: project.technology,
};
if (atlasCentresOnRepdPointV9_7(project)) {
values.latitude = project.latitude;
values.longitude = project.longitude;
values.zoom = "12";
}
const url = new URL(canonicalRoute);
for (const key of CONTRACT_PARAMS) {
const value = values[key];
if (value === undefined || value === null || value === "") continue;
url.searchParams.set(key, String(value));
}
return url.href;
}
/* What the cell says when there is no link. One sentence, in the row, because
* a title attribute is unreachable on a phone and unreachable is how this hid. */
export function atlasUnavailableReasonV9_7(project) {
if (!canonicalRoute) return `MAP unavailable: ${atlasReceiverFailureV9_7()}`;
if (!project || project.repd_ref === undefined || project.repd_ref === null || project.repd_ref === "") {
return "MAP unavailable: this record carries no REPD reference to resolve";
}
return "";
}GridAtlas State
A JavaScript file in the plugins folder of GlobalGrid2050 that draws map link state and the Renewable Energy Planning Database (REPD) register, and uses data from the GridAtlas repository.
renderglobalgrid2050 / uk_renewables_pipeline/202611171550/scripts/plugins/gridatlas-state.js · lines 1–68 of 68 · version 2026-11-17 15:50 · Entry point · pattern annotate (shared by 5 files)
- What it does
- It draws map link state and the REPD register. Defines getJson, annotate, summary, start. Side effects: changes the web page (DOM); makes network requests.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'gridatlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: the REPD register.
- Inputs & outputs
- In: data source: gridatlas data; JSON file map_link_state.json; JSON file current.json.
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 — UK Renewables Pipeline Page (globalgrid2050, https://globalgrid2050.com/uk_renewables_pipeline/202611280922/). Reached from 4 other entry points, including GlobalGrid2050 Pipeline Legal Evidence Workflow (globalgrid2050); V923 Public Readback Workflow (neural-link-between-agents); A4 Legal Model (globalgrid2050).
- What it achieves
- It gets JSON (`getJson`) and is built from the start step (`start`). Defines `getJson`, `annotate`, `summary` and 1 more. It responds to DOMContentLoaded events.
- Why it matters
- Loaded by the UK Renewables Pipeline page at https://globalgrid2050.com/uk_renewables_pipeline/202611280922/.
- Application
- globalgrid2050 · uk_renewables_pipeline/202611171550/scripts/plugins · script
- Uses
- none found
- Used by
- loaded by GlobalGrid2050 — UK Renewables Pipeline Page (script src)
- Produces
- getJson, annotate, summary, start
- Defines here
- getJson, annotate, summary, start
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 uk_renewables_pipeline/202611171550/scripts/plugins/gridatlas-state.js:1-68 · blob 31d0b3a2726ac63c3b6b695f90374981d8152802 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom, network · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
(function () {
'use strict';
var STATE_URL = 'gridatlas/map_link_state.json';
var COMPOSITION_URL = 'https://ventusltd.github.io/gridatlas/atlas/current.json';
var refs = null;
var fallback = 'GRIDATLAS: MAP OPENS ON THE PROJECT POINT · NO PROJECT CARD THERE';
function getJson(url) {
var ctl = typeof AbortController === 'function' ? new AbortController() : null;
var timer = setTimeout(function () { if (ctl) ctl.abort(); }, 6000);
return fetch(url, { cache: 'no-cache', signal: ctl ? ctl.signal : undefined })
.then(function (r) { clearTimeout(timer); if (!r.ok) throw new Error(r.status); return r.json(); },
function (e) { clearTimeout(timer); throw e; });
}
function annotate() {
if (!refs) return;
var rows = document.querySelectorAll('#tbody tr[id^="repd-"]');
Array.prototype.forEach.call(rows, function (tr) {
var text = refs[tr.id.slice(5)];
if (!text || tr.querySelector('.ga-state')) return;
var actions = tr.querySelector('.project-actions');
if (!actions || !actions.parentNode) return;
var note = document.createElement('div');
note.className = 'map-note ga-state';
note.setAttribute('data-feature', 'gridatlas-state');
note.textContent = text;
actions.parentNode.appendChild(note);
});
}
function summary(state, checkedLive) {
var host = document.getElementById('gaStateSummary');
if (!host) return;
var b = document.createElement('b');
b.textContent = 'GRIDATLAS DATA: ';
host.appendChild(b);
host.appendChild(document.createTextNode(
'GridAtlas holds the ' + state.gridatlas_register.dataset + ' register. Of ' + state.active_rows.toLocaleString('en-GB') +
' projects here with an active REPD status, ' + state.active_resolved.toLocaleString('en-GB') + ' open with their project card there and ' +
state.active_not_resolved + ' do not: their MAP link opens the map on the project point only, and each is marked in its row with the reason. ' +
'Projects with any other status are outside the register GridAtlas keeps. Measured ' + state.measured_at.slice(0, 10) +
(checkedLive ? '; GridAtlas data generation confirmed when this page loaded.' : '.')));
host.hidden = false;
}
function start() {
if (typeof fetch !== 'function') return;
getJson(STATE_URL).then(function (state) {
if (!state || state.schema !== 'globalgrid2050.pipeline-news.gridatlas-map-link-state.v1') return;
return getJson(COMPOSITION_URL).then(function (composition) {
var search = (composition.cartridges || []).filter(function (c) { return c.id === state.gridatlas_project_search.cartridge; })[0];
return !!search && String(search.generation) === String(state.gridatlas_project_search.generation);
}).then(function (stillApplies) {
if (!stillApplies) return;
refs = {};
state.active_not_resolved_refs.forEach(function (r) { refs[String(r.repd_ref)] = r.page_note || fallback; });
summary(state, true);
annotate();
var body = document.getElementById('tbody');
if (body && typeof MutationObserver === 'function') new MutationObserver(annotate).observe(body, { childList: true, subtree: true });
}, function () { /* GridAtlas composition unreadable: state unknown, show nothing */ });
}, function () { /* no state file: show nothing */ });
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start);
else start();
})();Map Entry
A JavaScript module in the UK renewables pipeline folder of GlobalGrid2050 covering the Renewable Energy Planning Database (REPD) register and uses data from the GridAtlas repository.
interactionglobalgrid2050 / uk_renewables_pipeline/202611181019/map-entry.mjs · lines 1–89 of 89 · version 2026-11-18 10:19 · Entry point · pattern rememberCategory (shared by 2 files)
- What it does
- It draws the REPD register. Defines action, refresh, rememberCategory, restore, dcRestore. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'renewables'): 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: the REPD register.
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 — UK Renewables Pipeline Page (globalgrid2050, https://globalgrid2050.com/uk_renewables_pipeline/202611280922/). Reached from 4 other entry points, including GlobalGrid2050 Pipeline Legal Evidence Workflow (globalgrid2050); V923 Public Readback Workflow (neural-link-between-agents); A4 Legal Model (globalgrid2050).
- What it achieves
- It is built from the remember category helper (`rememberCategory`), the restore step (`restore`) and the dc restore helper (`dcRestore`). Defines `action`, `refresh`, `rememberCategory` and 2 more. It responds to click and pipeline events.
- Why it matters
- Loaded by the UK Renewables Pipeline page at https://globalgrid2050.com/uk_renewables_pipeline/202611280922/.
- Application
- globalgrid2050 · uk_renewables_pipeline/202611181019 · JavaScript module
- Uses
- Model (import), GridAtlas — Atlas Page (estate URL)
- Used by
- loaded by GlobalGrid2050 — UK Renewables Pipeline Page (script src)
- Produces
- action, refresh, rememberCategory, restore, dcRestore
- Defines here
- action, refresh, rememberCategory, restore, dcRestore
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 uk_renewables_pipeline/202611181019/map-entry.mjs:1-89 · blob a0efbe311201f787d7ad4de1f34372483ed0a696 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
import {buildJourneyUrl,mapOrigin,checkedNewsContextBase} from '../../automation/journey_entry_ui/20261118/model.mjs';
const document=globalThis.document;
const canonical='https://ventusltd.github.io/gridatlas/atlas/';
const stateKey='pipelineJourneyReturn';
const origins=new WeakMap();
let newsContextUrl;
function action(map,identity,parent){
const existing=parent.querySelector(':scope > .pn-journey-action');
const origin=map?mapOrigin(map.href,identity):null;
const href=origin?buildJourneyUrl(map.href,origin,{newsContextUrl}):null;
const signature=JSON.stringify([identity.origin_type,identity.origin_id,href]);
if(existing?.dataset.signature===signature){if(href)origins.set(existing,origin);return}
existing?.remove();
const element=document.createElement(href?'a':'span');element.className='pn-journey-action';element.dataset.signature=signature;
if(href){
element.classList.add('action-link','atlaslink','pn-journey-link');element.href=href;element.target='_blank';element.rel='noopener noreferrer';element.textContent='MAP';
element.title='Explore nearby assets and documented network connectivity; not a connection assessment';origins.set(element,origin);
}else{
element.classList.add('pn-journey-unavailable');element.textContent='NO MAP';
}
if(map?.parentElement===parent){map.after(element);map.hidden=true;map.style.setProperty('display','none','important');}else parent.append(element);
}
function refresh(){
for(const map of document.querySelectorAll('#tbody a.atlaslink:not(.pn-journey-link)')){
const url=new URL(map.href),ref=url.searchParams.get('repd_ref');if(!/^[1-9]\d*$/.test(ref||''))continue;
const row=map.closest('tr'),name=row?.querySelector('.site')?.firstChild?.textContent?.trim();
action(map,{origin_type:'repd',origin_id:'repd:'+ref,name},map.parentElement);
}
for(const row of document.querySelectorAll('#gridLayerHost tr[data-source-id]')){
const map=[...row.querySelectorAll('a:not(.pn-journey-link)')].find(a=>a.href.startsWith(canonical));
if(!map)continue;
action(map,{origin_type:'substation',origin_id:row.dataset.sourceId,name:row.querySelector('strong')?.textContent},map.parentElement);
}
for(const row of document.querySelectorAll('#datacentreHost .ggdc-table tbody tr')){
const id=row.querySelector('.ggdc-id')?.textContent?.trim();if(!/^DC-WD-Q[1-9]\d*$/.test(id||''))continue;
const actions=row.querySelector('.ggdc-location-actions');
const map=actions&&[...actions.querySelectorAll('a:not(.pn-journey-link)')].find(a=>a.href.startsWith(canonical));
const parent=actions||row.lastElementChild;if(!parent)continue;
// A late source-backed location replaces the unavailable placeholder.
if(actions)row.querySelector('td > .pn-journey-unavailable')?.remove();
action(map,{origin_type:'datacentre',origin_id:id,name:row.querySelector('.ggdc-identity')?.firstChild?.textContent},parent);
}
// The existing general MAP ATLAS navigation is unchanged.
}
let queued=false;
new MutationObserver(()=>{if(!queued){queued=true;queueMicrotask(()=>{queued=false;refresh()})}}).observe(document.body,{childList:true,subtree:true});
refresh();
// Only a later accepted news-context component opts into this metadata. The
// entry release never points to an unpublished or arbitrary return destination.
window.pipelineJourneyEntry=Object.freeze({schema:'pipeline.journey-entry.v1',setNewsContextUrl(value){
const base=checkedNewsContextBase(value);if(!base)throw Error('Invalid immutable news context base');
newsContextUrl=base;refresh();
}});
window.dispatchEvent(new Event('pipeline-journey-ready'));
function rememberCategory(){
const category=document.querySelector('.pipeline-tabs [aria-selected="true"]')?.dataset.view;
const dc=document.getElementById('datacentreHost');
const state={category,x:scrollX,y:scrollY,
dcQuery:dc?.querySelector('input[type="search"]')?.value,
dcKind:dc?.querySelector('[data-kind][aria-pressed="true"]')?.dataset.kind,
dcCountry:dc?.querySelector('select[aria-label="Country"]')?.value};
try{history.replaceState({...history.state,[stateKey]:state},'')}catch{/* Native link remains usable. */}
}
document.addEventListener('click',event=>{
const a=event.target.closest?.('.pn-journey-link');if(!a)return;
// V9.42's existing atlaslink handler owns native target and filter recovery.
rememberCategory();
const origin=origins.get(a);if(origin)window.dispatchEvent(new CustomEvent('pipeline-journey-origin',{detail:origin}));
},true);
// Restore the existing category controls only after the original app finishes
// its default-category initialization. BFCache keeps its live nodes unchanged.
const saved=history.state?.[stateKey];
if(saved&&['solar','bess','grid','datacentre','offtakers','prices'].includes(saved.category)){
let restored=false;
const restore=()=>{if(restored)return;restored=true;queueMicrotask(()=>{
document.querySelector('.pipeline-tabs [data-view="'+saved.category+'"]')?.click();
if(saved.category!=='datacentre'){scrollTo(saved.x,saved.y);return}
const dcRestore=()=>{
const dc=document.getElementById('datacentreHost'),input=dc?.querySelector('input[type="search"]');if(!input)return;
if(['uk','global'].includes(saved.dcKind))dc.querySelector('[data-kind="'+saved.dcKind+'"]')?.click();
input.value=saved.dcQuery||'';input.dispatchEvent(new Event('input',{bubbles:true}));
const country=dc.querySelector('select[aria-label="Country"]');if(country&&[...country.options].some(o=>o.value===saved.dcCountry)){country.value=saved.dcCountry;country.dispatchEvent(new Event('change',{bubbles:true}))}
scrollTo(saved.x,saved.y);
};
window.addEventListener('pipeline-datacentre-ready',dcRestore,{once:true});dcRestore();
})};
window.addEventListener('pipeline-projects-rendered',restore,{once:true});
if(document.getElementById('tbody')?.dataset.complete==='true')restore();
}