In this section
- Check V7 2 Project Table Export test · globalgrid2050 / uk_renewables_pipeline/202609051156/tests/check_v7_2_project_table_export.mjs lines 1–217
- Check V8 1 Mvp test · globalgrid2050 / uk_renewables_pipeline/202609051156/tests/check_v8_1_mvp.mjs lines 1–104
- Check V8 Baseline test · globalgrid2050 / uk_renewables_pipeline/202609051156/tests/check_v8_baseline.py lines 1–79
- Check V9 0 test · globalgrid2050 / uk_renewables_pipeline/202609051156/tests/check_v9_0.mjs lines 1–135
- Check V9 1 test · globalgrid2050 / uk_renewables_pipeline/202609051156/tests/check_v9_1.mjs lines 1–70
Check V7 2 Project Table Export
A JavaScript module in the tests folder of GlobalGrid2050 that tests projects plugin, the Renewable Energy Planning Database (REPD) register and solar, using SHA-256.
testglobalgrid2050 / uk_renewables_pipeline/202609051156/tests/check_v7_2_project_table_export.mjs · lines 1–217 of 217 · version 2026-09-05 11:56 · Not reached from any entry point (candidate for review) · pattern parseCsv (shared by 8 files)
- What it does
- It tests projects plugin, the REPD register and solar. Defines readyState, parseCsv. Uses libraries node:assert/strict, node:fs/promises. Side effects: 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: the REPD register, solar.
- Inputs & outputs
- In: JSON file projects-plugin.v7.2.json; JSON file projects.json; CSV file globalgrid2050_uk_renewables_pipeline_v7_2_2026-08-23.csv.
- What it achieves
- It parses CSV (`parseCsv`) and is built from the ready state helper (`readyState`). Its name says it checks project table export. Defines `readyState` and `parseCsv`. Its code works with 350 MW. It reads `contracts/projects-plugin.v7.2.json`.
- Why it matters
- No other file in the estate was found to import it.
- Application
- globalgrid2050 · uk_renewables_pipeline/202609051156/tests · JavaScript module
- Uses
- Canonical Projects (import), Project State (import), Canonical Project Table (import), Canonical Project Export (import), node:assert/strict, node:fs/promises
- Used by
- mentioned in Standalone (comment link)
- Produces
- readyState, parseCsv
- Defines here
- readyState, parseCsv
- 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/202609051156/tests/check_v7_2_project_table_export.mjs:1-217 · blob 8c62774e76c111866922d3c8200a3fc1f515da53 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { buildCanonicalProjectModel } from "../scripts/data/canonical-projects.js";
import {
commitCanonicalProjectModel,
createCanonicalProjectState,
failCanonicalProjectLoad,
setCanonicalProjectFilter,
} from "../scripts/core/project-state.js";
import {
buildCanonicalNewsSearchUrl,
buildCanonicalProjectTableView,
} from "../scripts/plugins/canonical-project-table.js";
import {
buildCanonicalProjectCsv,
neutraliseSpreadsheetFormula,
quoteCsvCell,
} from "../scripts/plugins/canonical-project-export.js";
const v7Url = new URL("../", import.meta.url);
const contract = JSON.parse(await readFile(new URL("contracts/projects-plugin.v7.2.json", v7Url), "utf8"));
const payload = JSON.parse(await readFile(new URL("data/v7.2/projects.json", v7Url), "utf8"));
const model = buildCanonicalProjectModel(payload, contract);
function readyState() {
const state = createCanonicalProjectState();
commitCanonicalProjectModel(state, model);
return state;
}
function parseCsv(content) {
const text = content.startsWith("\ufeff") ? content.slice(1) : content;
const rows = [];
let row = [];
let cell = "";
let quoted = false;
for (let index = 0; index < text.length; index += 1) {
const character = text[index];
if (quoted && character === '"' && text[index + 1] === '"') {
cell += '"';
index += 1;
} else if (character === '"') {
quoted = !quoted;
} else if (!quoted && character === ",") {
row.push(cell);
cell = "";
} else if (!quoted && character === "\r" && text[index + 1] === "\n") {
row.push(cell);
rows.push(row);
row = [];
cell = "";
index += 1;
} else {
cell += character;
}
}
row.push(cell);
rows.push(row);
return rows;
}
const state = readyState();
const table = buildCanonicalProjectTableView(state);
assert.equal(table.available, true);
assert.equal(table.rowCount, 766);
assert.equal(table.columns.length, 11);
assert.deepEqual(table.columns.map((column) => column.label), contract.interface.primary_table_columns);
assert.equal(table.rows[0].key, "GG2050-REPD-12453");
assert.equal(table.rows[0].primary.capacity.display, "1,450 MW");
assert.equal(table.rows[0].evidence.relationships.items.some((item) => (
item.repdRef === "8470" && item.targetInCurrentUniverse === false
)), true);
assert.equal(table.rows.some((row) => row.key === "GG2050-REPD-8470"), false);
assert.equal(table.rows.filter((row) => ["GG2050-REPD-13599", "GG2050-REPD-13600"].includes(row.key)).length, 2);
assert.equal(Object.isFrozen(table), true);
assert.equal(Object.isFrozen(table.rows), true);
assert.equal(Object.isFrozen(table.rows[0]), true);
assert.equal(Object.isFrozen(table.rows[0].evidence), true);
assert.equal(Object.isFrozen(table.rows[0].evidence.officialPlanning.milestones), true);
assert.equal(Object.isFrozen(table.rows[0].evidence.relationships.items), true);
assert.equal(Object.isFrozen(table.rows[0].evidence.provenance), true);
const byId = new Map(table.rows.map((row) => [row.key, row]));
const hamsHall = byId.get("GG2050-REPD-9427");
assert.equal(hamsHall.primary.capacity.value, 400);
assert.equal(hamsHall.primary.capacity.unit, "MW");
assert.equal(hamsHall.evidence.officialPlanning.milestones.planning_permission_granted.value, "2022-03-04");
assert.equal(hamsHall.evidence.officialPlanning.milestones.operational.display, "not supplied by REPD");
assert.equal(byId.get("GG2050-REPD-16393").primary.planningReference, "not supplied by REPD");
assert.equal(byId.get("GG2050-REPD-20966").evidence.officialPlanning.repdRecordUpdated.display, "not supplied by REPD");
assert.equal(byId.get("GG2050-REPD-13599").evidence.identity.ggDevelopmentId, "GG2050-DEV-E13842D4D80DEC");
assert.equal(byId.get("GG2050-REPD-13599").evidence.provenance.projectsSha256, payload.projects_sha256);
assert.equal(byId.get("GG2050-REPD-13599").evidence.provenance.dataset, payload.source_provenance.dataset);
assert.equal(byId.get("GG2050-REPD-13599").primary.legacyNews.verified, false);
assert.equal(byId.get("GG2050-REPD-13599").primary.legacyNews.authority, "external legacy intelligence — unverified");
assert.equal(byId.get("GG2050-REPD-13599").primary.legacyNews.label, "not evaluated");
const withLegacySignal = buildCanonicalProjectTableView(state, {
legacySignalResolver(project) {
return project.repd_ref === "9427"
? { label: "350 MW article claim", note: "unverified inherited V5 match" }
: null;
},
});
assert.equal(withLegacySignal.rows.find((row) => row.key === "GG2050-REPD-9427").primary.capacity.value, 400);
assert.equal(withLegacySignal.rows.find((row) => row.key === "GG2050-REPD-9427").primary.legacyNews.label, "350 MW article claim");
const legacyFailure = buildCanonicalProjectTableView(state, {
legacySignalResolver() { throw new Error("legacy feed offline"); },
});
assert.equal(legacyFailure.rowCount, 766);
assert.equal(legacyFailure.rows[0].primary.legacyNews.status, "legacy_news_unavailable");
assert.equal(legacyFailure.rows[0].primary.legacyNews.note, "Legacy news resolver failed");
const maliciousName = ' =HYPERLINK("https://evil.example"), Café\nsecond line';
const maliciousUrl = new URL(buildCanonicalNewsSearchUrl({
name: maliciousName,
technology_label: "Solar",
}));
assert.equal(maliciousUrl.origin, "https://www.google.com");
assert.equal(maliciousUrl.pathname, "/search");
assert.equal(maliciousUrl.searchParams.get("tbm"), "nws");
const forgedState = { ...state, filtered: [{ ...state.filtered[0], name: "FORGED PROJECT", capacity_mw: 999999 }] };
assert.throws(() => buildCanonicalProjectTableView(forgedState), /not exact canonical project objects/);
assert.throws(() => buildCanonicalProjectCsv(forgedState), /not exact canonical project objects/);
const duplicateState = { ...state, filtered: [state.filtered[0], state.filtered[0]] };
assert.throws(() => buildCanonicalProjectTableView(duplicateState), /duplicate canonical project/);
const toctouState = readyState();
let mutatedDuringResolve = false;
assert.throws(
() => buildCanonicalProjectCsv(toctouState, {
date: "2026-08-23",
legacySignalResolver() {
if (!mutatedDuringResolve) {
mutatedDuringResolve = true;
toctouState.filtered = toctouState.filtered.map((project) => ({ ...project, name: "FORGED AFTER VALIDATION" }));
toctouState.metadata = { ...toctouState.metadata, projects_sha256: "FORGED" };
}
return null;
},
}),
/canonical state changed while the table view was being built/,
);
const fullExport = buildCanonicalProjectCsv(state, { date: "2026-08-23" });
assert.equal(fullExport.filename, "globalgrid2050_uk_renewables_pipeline_v7_2_2026-08-23.csv");
assert.equal(fullExport.mimeType, "text/csv;charset=utf-8");
assert.equal(fullExport.rowCount, 766);
assert.equal(fullExport.columnCount, contract.interface.export.columns.length);
assert.deepEqual([...Buffer.from(fullExport.content).subarray(0, 3)], [0xef, 0xbb, 0xbf]);
assert.equal(fullExport.content.includes("\r\n"), true);
const fullRows = parseCsv(fullExport.content);
assert.equal(fullRows.length, 767);
assert.deepEqual(fullRows[0], contract.interface.export.columns.map((column) => column.label));
const headerIndex = new Map(fullRows[0].map((label, index) => [label, index]));
assert.equal(fullRows[1][headerIndex.get("REPD Ref")], "12453");
assert.equal(fullRows[1][headerIndex.get("Official REPD Capacity")], "1450");
assert.equal(fullRows[1][headerIndex.get("Capacity Unit")], "MW");
assert.equal(fullRows[1][headerIndex.get("Projects Array SHA-256")], payload.projects_sha256);
assert.equal(fullRows.some((row) => row[headerIndex.get("Site Name")] === "Alaw Môn Solar Farm - Solar Farm & Energy Storage Facility"), true);
const beaconState = readyState();
setCanonicalProjectFilter(beaconState, "query", "13599");
const beaconExport = buildCanonicalProjectCsv(beaconState, { date: "2026-08-23" });
const beaconRows = parseCsv(beaconExport.content);
assert.equal(beaconExport.rowCount, 1);
assert.equal(beaconRows.length, 2);
assert.equal(beaconRows[1][headerIndex.get("REPD Ref")], "13599");
assert.equal(beaconRows[1][headerIndex.get("Technology")], "Solar");
assert.equal(beaconRows[1][headerIndex.get("Capacity Unit")], "MWp");
const zeroState = readyState();
setCanonicalProjectFilter(zeroState, "officialStatus", "No such official status");
assert.equal(zeroState.filtered.length, 0);
const zeroExport = buildCanonicalProjectCsv(zeroState, { date: "2026-08-23" });
assert.equal(zeroExport.rowCount, 0);
assert.equal(parseCsv(zeroExport.content).length, 1);
assert.equal(zeroExport.content.includes("\r\n"), false);
const emptyState = createCanonicalProjectState();
assert.equal(buildCanonicalProjectTableView(emptyState).available, false);
assert.throws(() => buildCanonicalProjectCsv(emptyState), /validated canonical project model is unavailable/);
const staleState = readyState();
failCanonicalProjectLoad(staleState, "refresh unavailable");
assert.equal(buildCanonicalProjectTableView(staleState).rowCount, 766);
assert.equal(buildCanonicalProjectCsv(staleState, { date: "2026-08-23" }).rowCount, 766);
assert.equal(neutraliseSpreadsheetFormula("=1+1"), "'=1+1");
assert.equal(neutraliseSpreadsheetFormula(" @SUM(A1:A2)"), "' @SUM(A1:A2)");
assert.equal(neutraliseSpreadsheetFormula("\tformula"), "'\tformula");
assert.equal(neutraliseSpreadsheetFormula(-1.0850616), -1.0850616);
assert.equal(quoteCsvCell('comma, quote " and\nnewline'), '"comma, quote "" and\nnewline"');
assert.equal(quoteCsvCell("Café"), '"Café"');
assert.throws(() => buildCanonicalProjectCsv(state, { date: "23-08-2026" }), /YYYY-MM-DD/);
assert.throws(() => buildCanonicalProjectCsv(state, { date: "2026-99-99" }), /valid YYYY-MM-DD/);
const badMetadataState = readyState();
badMetadataState.metadata = { ...badMetadataState.metadata, projects_sha256: "0".repeat(64) };
assert.throws(() => buildCanonicalProjectTableView(badMetadataState), /projects_sha256/);
const badPayload = structuredClone(payload);
badPayload.source_identity_sha256 = "0".repeat(64);
assert.throws(() => buildCanonicalProjectModel(badPayload, contract), /source_identity_sha256/);
for (const livePath of [
"index.html",
"scripts/app.js",
"scripts/plugins/project-table.js",
"scripts/plugins/project-export.js",
"scripts/plugins/projects.js",
]) {
const source = await readFile(new URL(livePath, v7Url), "utf8");
assert.equal(source.includes("canonical-project-table"), false, `${livePath} imports the isolated table`);
assert.equal(source.includes("canonical-project-export"), false, `${livePath} imports the isolated export`);
}
console.log("V7.2 canonical table/evidence/export: PASS (766 rows, filtered-only CSV, isolated from live V7.1)");Check V8 1 Mvp
A JavaScript module in the tests folder of GlobalGrid2050 that tests plugin, major project news and solar, using SHA-256. It reads text (`readText`) and reads JSON (`readJson`).
testglobalgrid2050 / uk_renewables_pipeline/202609051156/tests/check_v8_1_mvp.mjs · lines 1–104 of 104 · version 2026-09-05 11:56 · Not reached from any entry point (candidate for review) · pattern readText (shared by 28 files)
- What it does
- It tests plugin, major project news and solar. Defines readText, readJson, sha256, refs. Uses libraries node:assert/strict, node:crypto, node:fs/promises. 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: solar.
- Inputs & outputs
- In: JSON file mvp.v8.1.json; CSV file globalgrid2050_uk_renewables_pipeline_v7_2_2026-08-23.csv; JSON file plugin_manifest.json; JSON file major_project_news_v5.json.
- What it achieves
- Its name says it checks mvp. Defines `readText`, `readJson`, `sha256` and 1 more. It reads `contracts/mvp.v8.1.json`.
- Why it matters
- No other file in the estate was found to import it.
- Application
- globalgrid2050 · uk_renewables_pipeline/202609051156/tests · JavaScript module
- Uses
- Canonical Projects (import), Project State (import), Canonical Project Export (import), Canonical Project Table (import), node:assert/strict, node:crypto, node:fs/promises
- Used by
- none found
- Produces
- readText, readJson, sha256, refs
- Defines here
- readText, readJson, sha256, refs
- 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/202609051156/tests/check_v8_1_mvp.mjs:1-104 · blob a618d59d59334cf328b6de689ede73e51faa8475 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom, filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
import assert from "node:assert/strict";
import { createHash } from "node:crypto";
import { readFile } from "node:fs/promises";
import {
buildCanonicalProjectModel,
searchCanonicalProjects,
} from "../scripts/data/canonical-projects.js";
import {
commitCanonicalProjectModel,
createCanonicalProjectState,
resetCanonicalProjectFilters,
setCanonicalProjectFilter,
} from "../scripts/core/project-state.js";
import { buildCanonicalProjectCsv } from "../scripts/plugins/canonical-project-export.js";
import { buildCanonicalProjectTableView } from "../scripts/plugins/canonical-project-table.js";
const v8Url = new URL("../", import.meta.url);
const repoUrl = new URL("../../../", import.meta.url);
const readText = (path) => readFile(new URL(path, v8Url), "utf8");
const readJson = async (path) => JSON.parse(await readText(path));
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
const mvp = await readJson("contracts/mvp.v8.1.json");
const projectContract = await readJson(mvp.projects.contract);
const projectPayloadBytes = await readFile(new URL(mvp.projects.source, v8Url));
const projectPayload = JSON.parse(projectPayloadBytes.toString("utf8"));
const model = buildCanonicalProjectModel(projectPayload, projectContract);
assert.equal(mvp.schema, "globalgrid2050.v8.mvp-contract.v1");
assert.equal(mvp.release, "8.1");
assert.equal(mvp.status, "LIVE_VALIDATED");
assert.equal(sha256(projectPayloadBytes), mvp.projects.source_sha256);
assert.equal(model.projects.length, mvp.projects.expected.project_count);
assert.equal(new Set(model.projects.map((project) => project.gg_development_id)).size, 718);
assert.equal(model.projects.filter((project) => project.technology === "solar").length, 384);
assert.equal(model.projects.filter((project) => project.technology === "bess").length, 382);
assert.equal(model.projects.filter((project) => !["solar", "bess"].includes(project.technology)).length, 0);
assert.equal(model.metrics.solar_mwp, 34073.49);
assert.equal(model.metrics.bess_mw, 106338.18);
assert.equal(model.metrics.largest_project.capacity_mw, 1450);
const fields = projectContract.interface.search_fields;
const refs = (query) => searchCanonicalProjects(model.projects, query, fields)
.map((project) => project.repd_ref)
.sort();
assert.deepEqual(refs("13599"), ["13599"]);
assert.deepEqual(refs("GG2050-REPD-13599"), ["13599"]);
assert.deepEqual(refs("GG2050-DEV-E13842D4D80DEC"), ["13599", "13600"]);
assert.deepEqual(refs("EN010151"), ["13599", "13600"]);
assert.deepEqual(refs("Beacon Fen"), ["13599", "13600"]);
const state = createCanonicalProjectState();
commitCanonicalProjectModel(state, model);
const table = buildCanonicalProjectTableView(state);
assert.equal(table.rowCount, 766);
assert.equal(table.columns.length, 11);
assert.equal(table.rows.every((row) => row.primary.repdRef && row.primary.ggProjectId), true);
assert.equal(table.rows.every((row) => row.primary.legacyNews.verified === false), true);
setCanonicalProjectFilter(state, "technology", "solar");
assert.equal(state.filtered.length, 384);
assert.equal(state.metrics.solar_mwp, 34073.49);
assert.equal(state.metrics.bess_mw, 0);
setCanonicalProjectFilter(state, "technology", "bess");
assert.equal(state.filtered.length, 382);
assert.equal(state.metrics.solar_mwp, 0);
assert.equal(state.metrics.bess_mw, 106338.18);
resetCanonicalProjectFilters(state);
setCanonicalProjectFilter(state, "query", "no-project-can-match-this-v8-1-gate");
const emptyCsv = buildCanonicalProjectCsv(state, { date: "2026-08-23" });
assert.equal(emptyCsv.rowCount, 0);
assert.equal(emptyCsv.content.split("\r\n").length, 1);
assert.equal(emptyCsv.filename, "globalgrid2050_uk_renewables_pipeline_v7_2_2026-08-23.csv");
const newsBytes = await readFile(new URL(mvp.newspaper.fixture, v8Url));
const news = JSON.parse(newsBytes.toString("utf8"));
assert.equal(sha256(newsBytes), mvp.newspaper.fixture_sha256);
assert.equal(news.headline_count, 125);
assert.equal(news.items.length, 125);
const html = await readText("index.html");
const projectsSource = await readText("scripts/plugins/projects.js");
const stateSource = await readText("scripts/core/state.js");
const newspaperSource = await readText("scripts/plugins/newspaper.js");
const pluginManifest = await readJson("data/plugin_manifest.json");
const rootIndex = await readFile(new URL("index.html", repoUrl), "utf8");
assert.match(html, /V8\.1 MVP/);
assert.match(html, /legacy V5 newspaper · project bindings unverified/i);
assert.equal((html.match(/<canvas id="g[1-4]"/g) || []).length, 4);
assert.equal((html.match(/<th(?:\s[^>]*)?>/g) || []).length, 11);
assert.equal(/data-technology="[^"]*wind/i.test(html), false);
assert.match(html, /data-technology="solar"/);
assert.match(html, /data-technology="bess"/);
assert.match(projectsSource, /loadCanonicalProjectModel/);
assert.match(projectsSource, /buildCanonicalProjectCsv/);
assert.equal(stateSource.includes("assets.publishing.service.gov.uk"), false);
assert.equal(newspaperSource.includes("major_project_news_v5.json"), false);
assert.equal(pluginManifest.version, "8.1");
assert.equal(pluginManifest.plugins.find((plugin) => plugin.id === "gauges").owns.includes("g4"), true);
assert.match(rootIndex, /V8\.1 MVP · canonical 766-project utility pipeline/);
console.log("V8.1 MVP contract: PASS (766 canonical projects, 125 legacy headlines)");Check V8 Baseline
A Python command-line tool in the tests folder of GlobalGrid2050 that tests fallback, projects and Renewable Energy Planning Database (REPD) q2 coordinates, using SHA-256.
testglobalgrid2050 / uk_renewables_pipeline/202609051156/tests/check_v8_baseline.py · lines 1–79 of 79 · version 2026-09-05 11:56 · Entry point
- What it does
- It tests fallback, projects and REPD q2 coordinates. Defines sha256, git, main. Uses libraries __future__, hashlib, json, subprocess, pathlib. Side effects: reads or writes files; starts processes.
- 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.
- Inputs & outputs
- In: JSON file fallback.v8.0.json; JSON file projects.json; GeoJSON file projects.geojson; JSON file repd_q2_coordinates.json.
- Downstream impact
- It is itself an entry point (Python CLI); no other file was found loading it.
- What it achieves
- Its name says it checks baseline. Defines `sha256` and `git`.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- globalgrid2050 · uk_renewables_pipeline/202609051156/tests · Python CLI
- Uses
- __future__, hashlib, json, subprocess, pathlib
- Used by
- none found
- Produces
- sha256, git, main
- Defines here
- sha256, git, main
- 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/202609051156/tests/check_v8_baseline.py:1-79 · blob a942b8b09645f93a166e8fa22fbf3538f26c6b80 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
from __future__ import annotations
import hashlib
import json
import subprocess
from pathlib import Path
V8 = Path(__file__).resolve().parents[1]
ROOT = V8.parents[1]
V7 = ROOT / "uk_renewables_pipeline/v7"
def sha256(path: Path) -> str:
return hashlib.sha256(path.read_bytes()).hexdigest()
def git(*args: str) -> str:
return subprocess.check_output(["git", *args], cwd=ROOT, text=True).strip()
def main() -> int:
contract = json.loads((V8 / "contracts/fallback.v8.0.json").read_text(encoding="utf-8"))
source = contract["source"]
source_tree = git("rev-parse", f"{source['commit']}:uk_renewables_pipeline/v7")
assert source_tree == source["v7_tree"], (source_tree, source["v7_tree"])
assert subprocess.run(
["git", "diff", "--quiet", "HEAD", "--", "uk_renewables_pipeline/v7"],
cwd=ROOT,
check=False,
).returncode == 0, "V7 working tree changed"
allowed = set(contract["allowed_inherited_differences"])
tracked = git(
"ls-tree",
"-r",
"--name-only",
f"{source['commit']}:uk_renewables_pipeline/v7",
).splitlines()
compared = 0
for relative in tracked:
if relative in allowed:
continue
old = V7 / relative
new = V8 / relative
assert new.is_file(), f"missing inherited V8 file: {relative}"
assert sha256(new) == sha256(old), f"unexpected V8.0 divergence: {relative}"
compared += 1
index = (V8 / "index.html").read_text(encoding="utf-8")
root_index = (ROOT / "index.html").read_text(encoding="utf-8")
assert "V8.0 TEST" in index
assert 'href="../v7/"' in index
assert 'url:"./uk_renewables_pipeline/v8/"' in root_index
projects = json.loads((V8 / "data/v7.2/projects.json").read_text(encoding="utf-8"))
geojson = json.loads((V8 / "data/v7.2/projects.geojson").read_text(encoding="utf-8"))
coordinates = json.loads((V8 / "fixtures/v7.2/repd_q2_coordinates.json").read_text(encoding="utf-8"))
expected = contract["canonical_checkpoint"]
assert projects["project_count"] == expected["project_count"] == len(projects["projects"])
assert projects["solar_count"] == expected["solar_count"]
assert projects["bess_count"] == expected["bess_count"]
assert projects["development_count"] == expected["development_count"]
assert projects["geometry_count"] == expected["geometry_count"] == len(geojson["features"])
assert len(coordinates["records"]) == expected["coordinate_record_count"]
assert all(project.get("geometry_status") for project in projects["projects"])
print(
"V8.0 baseline: PASS "
f"({compared} inherited files, {projects['project_count']} projects, "
f"{len(geojson['features'])} geometries, V7 fallback unchanged)"
)
return 0
if __name__ == "__main__":
raise SystemExit(main())Check V9 0
A JavaScript module in the tests folder of GlobalGrid2050 that tests projects plugin and major project news, and uses data from the GridAtlas repository.
testglobalgrid2050 / uk_renewables_pipeline/202609051156/tests/check_v9_0.mjs · lines 1–135 of 135 · version 2026-09-05 11:56 · Not reached from any entry point (candidate for review) · pattern readText (shared by 28 files)
- What it does
- It tests projects plugin, major project news and the REPD register. Defines readText, readJson. Uses libraries node:assert/strict, node:fs/promises. Side effects: 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: the REPD register.
- Inputs & outputs
- In: data source: gridatlas data; JSON file release.v9.0.json; JSON file projects-plugin.v7.2.json; JSON file projects.json; JSON file major_project_news_v5.json; CSV file globalgrid2050_uk_renewables_pipeline_v9_0_2026-08-23.csv.
- What it achieves
- It reads text (`readText`) and reads JSON (`readJson`). Defines `readText` and `readJson`. Its code works with 500 MW. It reads `contracts/release.v9.0.json`.
- Why it matters
- No other file in the estate was found to import it.
- Application
- globalgrid2050 · uk_renewables_pipeline/202609051156/tests · JavaScript module
- Uses
- Canonical Projects (import), Project State (import), Canonical Project Export (import), Canonical Project Table (import), Atlas Receiver V9 7 (import), GridAtlas — Atlas Page (estate URL), node:assert/strict, node:fs/promises
- Used by
- none found
- Produces
- readText, readJson
- Defines here
- readText, readJson
- 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/202609051156/tests/check_v9_0.mjs:1-135 · blob cf2fd4e40aca1c74e304cb5962ca9b6b8f1b6883 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { buildCanonicalProjectModel } from "../scripts/data/canonical-projects.js";
import {
commitCanonicalProjectModel,
createCanonicalProjectState,
resetCanonicalProjectFilters,
setCanonicalProjectFilter,
} from "../scripts/core/project-state.js";
import { buildCanonicalProjectCsv } from "../scripts/plugins/canonical-project-export.js";
import { buildCanonicalProjectTableView } from "../scripts/plugins/canonical-project-table.js";
import { primeAtlasReceiverV9_7 } from "../scripts/core/atlas-receiver-v9-7.js";
/* The deep-link contract, as the engine publishes it. Held here as the test's
own input so every branch runs with no network; the live file is audited
separately by Ventusltd/testcode drivers/link-targets.mjs, which reads
ventus-grid-engine/deeplink/receivers.json rather than restating it. */
const RECEIVER_CONTRACT = {
schema: "ventus.grid-engine.deeplink-receivers.v1",
canonical: { id: "gridatlas-v9", route: "https://ventusltd.github.io/gridatlas/atlas/", carries_engine: true },
/* A synthetic retired route. This fixture only needs SOMETHING retired to
exercise the refusal branch, and naming the estate's real dead route in a
test keeps a copy of it alive for the next person to copy. */
retired: [{ id: "synthetic-retired-receiver", route: "https://retired.invalid/no-engine/", carries_engine: false }],
};
/* Primed before the first table view: buildAtlasV8Url() is synchronous and the
view builds a link per row, so the contract must be in place first. Without
it the link is empty by design -- there is no fallback to a retired route. */
assert.equal(primeAtlasReceiverV9_7(RECEIVER_CONTRACT), RECEIVER_CONTRACT.canonical.route);
const v9Url = new URL("../", import.meta.url);
const repoUrl = new URL("../../../", import.meta.url);
const readText = (path) => readFile(new URL(path, v9Url), "utf8");
const readJson = async (path) => JSON.parse(await readText(path));
const release = await readJson("contracts/release.v9.0.json");
const contract = await readJson("contracts/projects-plugin.v7.2.json");
const payload = await readJson("data/v7.2/projects.json");
const news = await readJson("fixtures/v5/major_project_news_v5.json");
const model = buildCanonicalProjectModel(payload, contract);
assert.equal(release.release, "9.0");
assert.equal(release.canonical_projects.project_count, 766);
assert.equal(model.projects.length, 766);
assert.equal(model.projects.filter((project) => project.technology === "solar").length, 384);
assert.equal(model.projects.filter((project) => project.technology === "bess").length, 382);
assert.equal(model.projects.filter((project) => !["solar", "bess"].includes(project.technology)).length, 0);
assert.equal(news.items.length, 125);
const state = createCanonicalProjectState();
commitCanonicalProjectModel(state, model);
const table = buildCanonicalProjectTableView(state);
assert.equal(table.rowCount, 766);
assert.equal(table.columns.length, 13);
const thorpeMarsh = table.rows.find((row) => row.primary.repdRef === "12453");
assert.ok(thorpeMarsh);
assert.equal(thorpeMarsh.primary.repdRecordUpdated.value, "2025-11-04");
assert.equal(thorpeMarsh.primary.repdRecordUpdated.display, "04/11/2025");
assert.equal(thorpeMarsh.primary.atlas.exactFocusSupported, true);
const atlas = new URL(thorpeMarsh.primary.atlas.url);
/* Was: the origin and pathname of the retired V8 overlay. The engine
retired that route on 2026-09-05 for carrying no cartridges, so the old
assertion pinned the defect. */
assert.equal(atlas.origin, "https://ventusltd.github.io");
assert.equal(atlas.pathname, "/gridatlas/atlas/");
assert.equal(atlas.searchParams.get("repd_ref"), "12453");
assert.equal(atlas.searchParams.get("technology"), "bess");
assert.equal(atlas.searchParams.get("latitude"), "53.5802575");
assert.equal(atlas.searchParams.get("longitude"), "-1.0850616");
/* `project` and `capacity_mw` are deliberately no longer sent. The engine's
deep-link contract names five parameters -- repd_ref, technology, latitude,
longitude, zoom -- and the canonical receiver resolves the project's name,
capacity, postcode and status from the REPD reference itself. Measured live
on REPD 8162: the arrival reads "Longfield solar 500 MW ... CM3 3AS - Essex
REPD 8162 - awaiting construction" with none of it carried in the link.
Sending them again would be a second source for a fact the receiver already
holds, which is the shape of fault this whole change is removing. */
assert.equal(atlas.searchParams.get("capacity_mw"), null);
assert.equal(atlas.searchParams.get("project"), null);
const missingDate = table.rows.find((row) => row.primary.repdRecordUpdated.value === null);
assert.ok(missingDate);
assert.equal(missingDate.primary.repdRecordUpdated.display, "not supplied by REPD");
setCanonicalProjectFilter(state, "technology", "solar");
const solarCsv = buildCanonicalProjectCsv(state, { date: "2026-08-23" });
assert.equal(solarCsv.rowCount, 384);
assert.equal(solarCsv.filename, "globalgrid2050_uk_renewables_pipeline_v9_0_2026-08-23.csv");
assert.equal(solarCsv.content.split("\r\n").length, 385);
assert.match(solarCsv.content.split("\r\n")[0], /"REPD Record Updated"/);
assert.match(solarCsv.content.split("\r\n")[0], /"Atlas V8 URL"/);
/* Was: assert the CSV contains the retired V8 overlay route.
That route was retired by the engine on 2026-09-05 for carrying no
cartridges, so the old assertion pinned the defect. It now asserts the
canonical receiver is present and the retired one is absent -- the same
check, made specific about which receiver is right and why.
The CSV column is still headed "Atlas V8 URL". That label is a published
contract, pinned above and in contracts/projects-plugin.v7.2.json;
renaming it is a separate governed decision and is recorded as an
erratum rather than taken here. */
const csvAtlasUrls = [...solarCsv.content.matchAll(/https:\/\/[^",\s]+/g)].map((m) => m[0])
.filter((href) => /atlas|repd_grid/i.test(href));
assert.ok(csvAtlasUrls.length > 0, "the CSV carries no Atlas URL at all");
assert.ok(
csvAtlasUrls.every((href) => href.startsWith(RECEIVER_CONTRACT.canonical.route)),
`CSV Atlas URLs are not all the canonical receiver: ${[...new Set(csvAtlasUrls)].slice(0, 3).join(" | ")}`,
);
resetCanonicalProjectFilters(state);
setCanonicalProjectFilter(state, "query", "no-v9-project-can-match-this-value");
const emptyCsv = buildCanonicalProjectCsv(state, { date: "2026-08-23" });
assert.equal(emptyCsv.rowCount, 0);
assert.equal(emptyCsv.content.split("\r\n").length, 1);
const html = await readText("index.html");
const readme = await readText("README.md");
const rootIndex = await readFile(new URL("index.html", repoUrl), "utf8");
assert.match(html, /V9\.0 INTERIM/);
assert.equal((html.match(/<th(?:\s[^>]*)?>/g) || []).length, 13);
assert.match(html, /id="exportInline"/);
assert.match(html, /REPD RECORD UPDATED/);
assert.match(html, /flies to the exact V9 project coordinate/);
assert.match(readme, /independently of a new chat, context truncation or model replacement/);
assert.match(readme, /exact canonical focus/i);
const atlasEngine = await readFile(new URL("repd_grid_atlasv8/ventus-corev8engine.js", repoUrl), "utf8");
assert.match(atlasEngine, /focusCanonicalProjectDeepLink/);
assert.match(atlasEngine, /data\/v7\.2\/projects\.geojson/);
assert.match(rootIndex, /UK Solar \+ Storage Daily V9/);
console.log("V9.0 interim release: PASS (dates, filtered CSV, Atlas links, 766 projects)");Check V9 1
A JavaScript module in the tests folder of GlobalGrid2050 that tests Renewable Energy Planning Database (REPD) master, solar and battery storage (BESS).
testglobalgrid2050 / uk_renewables_pipeline/202609051156/tests/check_v9_1.mjs · lines 1–70 of 70 · version 2026-09-05 11:56 · pattern readText (shared by 28 files)
- What it does
- It tests REPD master, solar and battery storage (BESS). Defines readText, readJson, classifyLegacy. Uses libraries node:assert/strict, node:fs/promises. 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: solar, battery storage (BESS).
- Inputs & outputs
- In: JSON file release.v9.1.json; JSON file build_manifest.json; JSON file repd_master.json.
- Downstream impact
- Used directly by 1 file: Run V9 1 (globalgrid2050).
- What it achieves
- It reads text (`readText`), reads JSON (`readJson`) and classifies legacy (`classifyLegacy`). Defines `readText`, `readJson` and `classifyLegacy`. Its code works with 1 MW. It reads `contracts/release.v9.1.json`.
- Why it matters
- Checked by Run V9 1.
- Application
- globalgrid2050 · uk_renewables_pipeline/202609051156/tests · JavaScript module
- Uses
- node:assert/strict, node:fs/promises
- Used by
- run by Run V9 1 (script call), mentioned in Standalone (comment link)
- Produces
- readText, readJson, classifyLegacy
- Defines here
- readText, readJson, classifyLegacy
- 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/202609051156/tests/check_v9_1.mjs:1-70 · blob 41fdaf1be2d7dd6b90ab2981ccf81f58de6180bf · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom, filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
const base = new URL("../", import.meta.url);
const root = new URL("../../../", import.meta.url);
const readText = (path) => readFile(new URL(path, base), "utf8");
const readJson = async (path) => JSON.parse(await readText(path));
const contract = await readJson("contracts/release.v9.1.json");
const payload = await readJson("data/v9.1/build_manifest.json");
const projectParts = await Promise.all(payload.project_partitions.map(({ path }) => readJson(path.replace(/^data\/v9\.1\//, "data/v9.1/"))));
const projects = projectParts.flatMap((part) => part.projects);
const atlasParts = await Promise.all(payload.atlas_partitions.map(({ path }) => readJson(path.replace(/^data\/v9\.1\//, "data/v9.1/"))));
const legacy = await readJson("fixtures/v5/repd_master.json");
assert.equal(contract.release, "9.1");
assert.equal(contract.frozen_parent.commit, "50a6df6c4bd54ff4c113aaf0df4f230b7c9544d2");
assert.equal(contract.frozen_parent.tree, "60b72b3665e6b65a397541b221c4bca75aa402c9");
assert.equal(payload.schema, "globalgrid2050.v9.project-spine-build.v9.1");
assert.equal(payload.project_count, 7680);
assert.equal(payload.capacity_mw, 356474.09);
assert.equal(payload.largest_mw, 4100);
assert.equal(payload.solar_count, 3563);
assert.equal(payload.bess_count, 1609);
assert.equal(payload.wind_onshore_count, 2399);
assert.equal(payload.wind_offshore_count, 109);
assert.equal(projects.length, 7680);
assert.equal(new Set(projects.map((project) => project.repd_ref)).size, 7680);
assert.equal(new Set(projects.map((project) => project.gg_project_id)).size, 7680);
assert.ok(projects.every((project) => project.capacity_mw >= 1));
assert.ok(projects.every((project) => ["solar", "bess", "wind_onshore", "wind_offshore"].includes(project.technology)));
assert.equal(atlasParts.reduce((sum, part) => sum + part.feature_count, 0), 7652);
assert.equal(payload.missing_geometry_count, 28);
const classifyLegacy = (properties) => {
const raw = String(properties.raw_tech || "").toLowerCase();
if (properties.tech === "solar" || properties.tech === "solar_roof") return "solar";
if (properties.tech === "bess") return "bess";
if (properties.tech === "wind") return raw.includes("offshore") ? "wind_offshore" : "wind_onshore";
return null;
};
const legacyProjects = legacy.features.map((feature) => ({ ...feature.properties, technology: classifyLegacy(feature.properties) }))
.filter((project) => project.technology && Number(project.capacity) >= 1);
assert.equal(legacyProjects.length, 5210);
assert.equal(Math.round(legacyProjects.reduce((sum, project) => sum + Number(project.capacity), 0) * 100) / 100, 262396.8);
assert.equal(Math.max(...legacyProjects.map((project) => Number(project.capacity))), 4100);
const html = await readText("index.html");
assert.match(html, /UK RENEWABLES PIPELINE V9\.1/);
assert.equal((html.match(/<canvas id="g[1-3]"/g) || []).length, 3);
assert.doesNotMatch(html, /id="g4"/);
for (const technology of ["all", "solar", "bess", "wind_onshore", "wind_offshore"]) {
assert.match(html, new RegExp(`data-technology="${technology}"`));
}
assert.match(html, /REPD REF/);
assert.match(html, /GLOBALGRID ID/);
assert.match(html, /REPD RECORD UPDATED/);
assert.match(html, /ATLAS V8/);
assert.match(html, /LEGACY NEWS SIGNAL/);
const app = await readText("scripts/app.js");
assert.match(app, /gauges-v9-1\.js/);
assert.match(app, /projects-v9-1\.js/);
const atlasEngine = await readFile(new URL("repd_grid_atlasv8/ventus-corev8engine.js", root), "utf8");
assert.match(atlasEngine, /data\/v9\.1\/build_manifest\.json/);
assert.match(atlasEngine, /atlas_partitions/);
const rootIndex = await readFile(new URL("index.html", root), "utf8");
assert.match(rootIndex, /UK Renewables Pipeline V9/);
console.log("V9.1: PASS (V1–V5 UI contract, 7,680 canonical ≥1 MW records, IDs/news/map/export retained)");