GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Electricity markets and data pipelines / globalgrid2050 / uk_renewables_pipeline/202611132345/scripts/data

Build V9 1 Spine and 4 more files

A Python command-line tool in the data folder of GlobalGrid2050 that reads projects, solar and battery storage (BESS), using SHA-256 and Helmert.

678 lines of Shell and JavaScript and Python from globalgrid2050, in 5 files. Topic: Electricity markets and data pipelines. Section 935 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. Build V9 1 Spine ingest · globalgrid2050 / uk_renewables_pipeline/202611132345/scripts/data/build_v9_1_spine.py lines 1–193
  2. Check V9 12 test · globalgrid2050 / uk_renewables_pipeline/202611132345/tests/check_v9_12.mjs lines 1–105
  3. Run V9 12 test · globalgrid2050 / uk_renewables_pipeline/202611132345/tests/run_v9_12.sh lines 1–129
  4. Check V9 13 test · globalgrid2050 / uk_renewables_pipeline/202611140058/tests/check_v9_13.mjs lines 1–114
  5. Run V9 13 test · globalgrid2050 / uk_renewables_pipeline/202611140058/tests/run_v9_13.sh lines 1–137

Build V9 1 Spine

A Python command-line tool in the data folder of GlobalGrid2050 that reads projects, solar and battery storage (BESS), using SHA-256 and Helmert.

ingestglobalgrid2050 / uk_renewables_pipeline/202611132345/scripts/data/build_v9_1_spine.py · lines 1–193 of 193 · version 2026-11-13 23:45 · Entry point

What it does
It loads projects, solar and battery storage (BESS). Defines main. Uses libraries __future__, json, collections, pathlib. 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: solar, battery storage (BESS).
Inputs & outputs
In: JSON file release.v9.1.json; JSON file projects.json; GeoJSON file projects.geojson; JSON file build_manifest.json. Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid), WGS84 / EPSG:4326.
Downstream impact
It is itself an entry point (Python CLI); no other file was found loading it.
What it achieves
Its name says it builds spine.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
globalgrid2050 · uk_renewables_pipeline/202611132345/scripts/data · Python CLI
Uses
Build V7 2 Spine (import), __future__, json, collections, pathlib
Used by
none found
Produces
main
Defines here
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/202611132345/scripts/data/build_v9_1_spine.py:1-193 · blob 49746ec3741e48db31bdbff396c334d6bb0c6e93 · 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: production_core
#!/usr/bin/env python3
from __future__ import annotations

import json
from collections import Counter
from pathlib import Path

from build_v7_2_spine import atomic_write_json, canonical_sha, resolve_geometry, sha256


ROOT = Path(__file__).resolve().parents[4]
V9 = Path(__file__).resolve().parents[2]  # this release folder, never uk_renewables_pipeline/v9
CONTRACT_PATH = V9 / "contracts/release.v9.1.json"
OUTPUT_DIR = V9 / "data/v9.1"

TECHNOLOGY_MAP = {
    "Solar Photovoltaics": "solar",
    "Battery": "bess",
    "Wind Onshore": "wind_onshore",
    "Wind Offshore": "wind_offshore",
}


def main() -> None:
    contract = json.loads(CONTRACT_PATH.read_text(encoding="utf-8"))
    identity_path = ROOT / contract["source"]["identity_fixture"]
    coordinate_path = ROOT / contract["source"]["coordinate_fixture"]
    if sha256(identity_path) != contract["source"]["identity_fixture_sha256"]:
        raise RuntimeError("V9.1 identity fixture hash mismatch")
    if sha256(coordinate_path) != contract["source"]["coordinate_fixture_sha256"]:
        raise RuntimeError("V9.1 coordinate fixture hash mismatch")

    identity_payload = json.loads(identity_path.read_text(encoding="utf-8"))
    coordinate_payload = json.loads(coordinate_path.read_text(encoding="utf-8"))
    if coordinate_payload["source_workbook_sha256"] != contract["source"]["workbook_sha256"]:
        raise RuntimeError("V9.1 coordinate workbook hash mismatch")

    coordinates = {row["repd_ref"]: row for row in coordinate_payload["records"]}
    minimum = float(contract["scope"]["capacity_mw_inclusive_minimum"])
    selected = [
        record for record in identity_payload["records"]
        if record.get("capacity_known") is True
        and record.get("technology") in TECHNOLOGY_MAP
        and float(record["capacity_mw"]) >= minimum
    ]

    projects = []
    for record in selected:
        coordinate = coordinates.get(record["repd_ref"], {})
        easting, northing = coordinate.get("easting"), coordinate.get("northing")
        geometry_status, longitude, latitude = resolve_geometry(easting, northing)
        projects.append({
            "gg_project_id": record["gg_project_id"],
            "gg_development_id": record["gg_development_id"],
            "identity_status": record["identity_status"],
            "identity_confidence": record["identity_confidence"],
            "repd_ref": record["repd_ref"],
            "repd_old_ref": record["repd_old_ref"],
            "repd_record_updated": record["repd_record_updated"],
            "name": record["site_name"],
            "technology": TECHNOLOGY_MAP[record["technology"]],
            "repd_technology": record["technology"],
            "capacity_mw": record["capacity_mw"],
            "capacity_known": True,
            "status": record["status"],
            "lifecycle": record["lifecycle"],
            "operator": record["operator"],
            "county": record["county"],
            "region": record["region"],
            "country": record["country"],
            "planning_authority": record["planning_authority"],
            "planning_application_reference": record["planning_application_reference"],
            "planning_application_submitted": record["planning_application_submitted"],
            "planning_application_withdrawn": record["planning_application_withdrawn"],
            "planning_permission_refused": record["planning_permission_refused"],
            "planning_permission_granted": record["planning_permission_granted"],
            "planning_permission_expired": record["planning_permission_expired"],
            "under_construction": record["under_construction"],
            "operational": record["operational"],
            "relationships": record["relationships"],
            "direct_related_repd_refs": record["direct_related_repd_refs"],
            "planning_sibling_repd_refs": record["planning_sibling_repd_refs"],
            "development_repd_refs": record["development_repd_refs"],
            "source_row": record["source_row"],
            "geometry_status": geometry_status,
            "easting": easting,
            "northing": northing,
            "longitude": longitude,
            "latitude": latitude,
            "coordinate_source": "documented OSGB36-to-WGS84 seven-parameter Helmert approximation" if geometry_status == "valid" else None,
        })

    projects.sort(key=lambda row: (-float(row["capacity_mw"]), row["name"].casefold(), row["repd_ref"]))
    features = [{
        "type": "Feature",
        "id": project["gg_project_id"],
        "geometry": {"type": "Point", "coordinates": [project["longitude"], project["latitude"]]},
        "properties": {
            "repd_ref": project["repd_ref"],
            "gg_project_id": project["gg_project_id"],
            "name": project["name"],
            "technology": project["technology"],
            "repd_technology": project["repd_technology"],
            "capacity_mw": project["capacity_mw"],
            "status": project["status"],
            "operator": project["operator"],
        },
    } for project in projects if project["geometry_status"] == "valid"]
    counts = Counter(project["technology"] for project in projects)
    total_capacity = round(sum(float(project["capacity_mw"]) for project in projects), 2)
    expected = contract["expected"]
    actual = {
        "project_count": len(projects),
        "capacity_mw": total_capacity,
        "largest_mw": max(float(project["capacity_mw"]) for project in projects),
        "solar_count": counts["solar"],
        "bess_count": counts["bess"],
        "wind_onshore_count": counts["wind_onshore"],
        "wind_offshore_count": counts["wind_offshore"],
    }
    if actual != expected:
        raise RuntimeError(f"V9.1 acceptance mismatch: {actual!r}")

    common = {
        "release": "9.1",
        "source_dataset": contract["source"]["dataset"],
        "source_record_count": identity_payload["raw_record_count"],
        "source_identity_sha256": sha256(identity_path),
        "source_coordinate_fixture_sha256": sha256(coordinate_path),
        "source_workbook_sha256": coordinate_payload["source_workbook_sha256"],
        "scope": contract["scope"],
    }
    OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
    projects_dir = OUTPUT_DIR / "projects"
    atlas_dir = OUTPUT_DIR / "atlas"
    projects_dir.mkdir(exist_ok=True)
    atlas_dir.mkdir(exist_ok=True)
    for stale in [OUTPUT_DIR / "projects.json", OUTPUT_DIR / "projects.geojson"]:
        stale.unlink(missing_ok=True)
    for stale in [*projects_dir.glob("part-*.json"), *atlas_dir.glob("*.geojson")]:
        stale.unlink()

    project_partitions = []
    partition_size = 500
    for index, start in enumerate(range(0, len(projects), partition_size), 1):
        path = projects_dir / f"part-{index:03d}.json"
        partition = projects[start:start + partition_size]
        atomic_write_json(path, {
            "schema": "globalgrid2050.v9.project-partition.v9.1",
            "release": "9.1",
            "partition": index,
            "record_count": len(partition),
            "projects": partition,
        })
        project_partitions.append({"path": f"data/v9.1/projects/{path.name}", "record_count": len(partition), "sha256": sha256(path)})

    atlas_partitions = []
    atlas_partition_size = 500
    for technology in TECHNOLOGY_MAP.values():
        technology_features = [feature for feature in features if feature["properties"]["technology"] == technology]
        for index, start in enumerate(range(0, len(technology_features), atlas_partition_size), 1):
            path = atlas_dir / f"{technology}-part-{index:03d}.geojson"
            partition = technology_features[start:start + atlas_partition_size]
            atomic_write_json(path, {
                "type": "FeatureCollection",
                "schema": "globalgrid2050.v9.atlas-projects.v9.1",
                "release": "9.1",
                "technology": technology,
                "partition": index,
                "feature_count": len(partition),
                "features": partition,
            })
            atlas_partitions.append({"path": f"data/v9.1/atlas/{path.name}", "technology": technology, "feature_count": len(partition), "sha256": sha256(path)})

    projects_sha256 = canonical_sha(projects)
    features_sha256 = canonical_sha(features)
    manifest_path = OUTPUT_DIR / "build_manifest.json"
    atomic_write_json(manifest_path, {
        "schema": "globalgrid2050.v9.project-spine-build.v9.1",
        **common,
        **actual,
        "geometry_count": len(features),
        "missing_geometry_count": len(projects) - len(features),
        "projects_sha256": projects_sha256,
        "features_sha256": features_sha256,
        "project_partitions": project_partitions,
        "atlas_partitions": atlas_partitions,
    }, indent=2)
    print(f"V9.1 spine built: {len(projects)} records, {total_capacity:,.2f} MW, {len(features)} geometries")


if __name__ == "__main__":
    main()

Check V9 12

A JavaScript module in the tests folder of GlobalGrid2050 that tests major project news, interconnectors and the Renewable Energy Planning Database (REPD) register, using SHA-256.

testglobalgrid2050 / uk_renewables_pipeline/202611132345/tests/check_v9_12.mjs · lines 1–105 of 105 · version 2026-11-13 23:45

What it does
It tests major project news, interconnectors and the REPD register. Defines text, json, sha256, fmt. Uses libraries node:assert/strict, node:crypto, node:fs/promises, node:url, node:path. 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: interconnectors, the REPD register.
Inputs & outputs
In: JSON file release.v9.1.json; JSON file release.v9.5.1.json; JSON file build_manifest.json; JSON file major_project_news_v9_5_1.json; JSON file interconnectors.v9.8.json; JSON file interconnectors.json; JSON file interconnectors_manifest.json.
Downstream impact
Used directly by 1 file: Run V9 12 (globalgrid2050). Reached from 1 other entry point, including GlobalGrid2050 Verify Pipeline Workflow (globalgrid2050).
What it achieves
It is built from the text step (`text`), the JSON step (`json`) and the sha256 step (`sha256`). The REPD Q3 2026 (October 2026) data refresh, proven from the bytes and through the page's OWN loaders.
Why it matters
Checked by Run V9 12.
Application
globalgrid2050 · uk_renewables_pipeline/202611132345/tests · JavaScript module
Uses
Canonical Projects V9 5 1 (new URL import.meta.url), node:assert/strict, node:crypto, node:fs/promises, node:url, node:path
Used by
run by Run V9 12 (script call)
Produces
text, json, sha256, fmt
Defines here
text, json, sha256, fmt
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/202611132345/tests/check_v9_12.mjs:1-105 · blob a0db827523a0fb55f1fd71fe341b985d93d2de27 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
/* check_v9_12.mjs - the REPD Q3 2026 (October 2026) data refresh, proven from
 * the bytes and through the page's OWN loaders.
 *
 *   1. The contracts bind the new fixtures by sha256, and the fixtures on disk
 *      are those bytes.
 *   2. The page's own loader chain - canonical-projects-v9-5-1.js, which runs
 *      canonical-projects-v9-1.js - is imported unmodified and executed against
 *      the files in this folder through a same-origin fetch shim. Every
 *      invariant the browser asserts is therefore asserted here, over all rows.
 *   3. The spine partitions are what the manifest says (sha256 and counts).
 *   4. The UK newspaper is still the repo-root Q2 feed, byte for byte, and the
 *      refs it binds to all resolve in the new spine (the page tolerates
 *      unknown refs, but none are lost in this refresh).
 *   5. The interconnector product and contract are the parent's, byte for byte.
 *   6. The page states its own identity and the new register figures.
 *
 * Run: node tests/check_v9_12.mjs
 */
import assert from "node:assert/strict";
import { createHash } from "node:crypto";
import { readFile } from "node:fs/promises";
import { fileURLToPath } from "node:url";
import { basename, dirname, join } from "node:path";

const HERE = dirname(fileURLToPath(import.meta.url));
const RELEASE = join(HERE, "..");
const ID = basename(RELEASE);
const ROOT = join(RELEASE, "..", "..");
const PARENT = join(RELEASE, "..", "202609082224");
const text = (p) => readFile(p, "utf8");
const json = async (p) => JSON.parse(await text(p));
const sha256 = (b) => createHash("sha256").update(b).digest("hex");

const NEWS_FEED_SHA256 = "cea104c3e9cfc07971680afdf5f64073e1d4825b63bfaf4e969266df8386ebbd";

// 1. contracts bind fixtures
const c91 = await json(join(RELEASE, "contracts", "release.v9.1.json"));
const c951 = await json(join(RELEASE, "contracts", "release.v9.5.1.json"));
assert.equal(c91.source.dataset, "DESNZ Renewable Energy Planning Database Q3 2026");
for (const [pathKey, shaKey] of [["identity_fixture", "identity_fixture_sha256"], ["coordinate_fixture", "coordinate_fixture_sha256"]]) {
  const rel = c91.source[pathKey];
  assert.ok(rel.startsWith(`uk_renewables_pipeline/${ID}/fixtures/`), `${pathKey} must live in this release: ${rel}`);
  assert.equal(sha256(await readFile(join(ROOT, rel))), c91.source[shaKey], `${pathKey} bytes`);
}
const coords = await json(join(ROOT, c91.source.coordinate_fixture));
assert.equal(coords.source_workbook_sha256, c91.source.workbook_sha256, "coordinate fixture names the contract workbook");
const identity = await json(join(ROOT, c91.source.identity_fixture));
assert.equal(identity.schema, "globalgrid2050.project-identity.v6");
assert.equal(identity.records.length, identity.raw_record_count);
assert.equal(coords.source_records, identity.raw_record_count, "workbook and identity hold the same refs");

// 2. the page's own loader, unmodified, against these bytes
const ORIGIN = "http://release.invalid";
const BASE = `${ORIGIN}/uk_renewables_pipeline/${ID}/`;
globalThis.window = { location: { origin: ORIGIN, href: BASE } };
globalThis.fetch = async (path) => {
  const url = new URL(path, BASE);
  assert.ok(url.pathname.startsWith(`/uk_renewables_pipeline/${ID}/`), `loader fetched outside the release: ${url}`);
  const file = join(RELEASE, decodeURIComponent(url.pathname.slice(`/uk_renewables_pipeline/${ID}/`.length)));
  const body = await text(file);
  return { ok: true, status: 200, url: url.href, json: async () => JSON.parse(body) };
};
const loader = await import(new URL("../scripts/data/canonical-projects-v9-5-1.js", import.meta.url).href);
const model = await loader.loadCanonicalProjectsV9_5_1();
assert.equal(model.projects.length, c951.expected.project_count);
assert.equal(Math.round(model.metadata.capacity_mw), c951.expected.displayed_capacity_mw);

// 3. partitions are the manifest's bytes
const manifest = await json(join(RELEASE, "data", "v9.1", "build_manifest.json"));
for (const part of [...manifest.project_partitions, ...manifest.atlas_partitions]) {
  assert.equal(sha256(await readFile(join(RELEASE, part.path))), part.sha256, `${part.path} hash`);
}
const atlasFeatures = manifest.atlas_partitions.reduce((n, p) => n + p.feature_count, 0);
assert.equal(atlasFeatures, manifest.geometry_count, "atlas features = valid geometries");
for (const key of Object.keys(c91.expected)) assert.equal(manifest[key], c91.expected[key], `manifest ${key}`);
assert.equal(manifest.source_dataset, c91.source.dataset);
assert.equal(manifest.source_record_count, identity.raw_record_count);

// 4. the newspaper: unchanged Q2 feed, every bound ref still resolves
const feedBytes = await readFile(join(ROOT, "dist", "major_project_news_v9_5_1.json"));
assert.equal(sha256(feedBytes), NEWS_FEED_SHA256, "dist/major_project_news_v9_5_1.json must not be rebuilt by this release");
const feed = JSON.parse(feedBytes);
const byRef = new Map(model.projects.map((p) => [p.repd_ref, p]));
const boundRefs = new Set(feed.canonical_items.map((item) => String(item.repd_ref)));
const unresolved = [...boundRefs].filter((ref) => !byRef.has(ref));
const beacon = byRef.get(feed.beacon_fen_contract.repd_ref);
assert.ok(beacon, "Beacon Fen must be in the spine");
assert.equal(beacon.capacity_mw, feed.beacon_fen_contract.official_capacity_mw, "Beacon Fen official capacity");

// 5. interconnectors are the parent's
for (const rel of ["contracts/interconnectors.v9.8.json", "data/v9.8/interconnectors.json", "data/v9.8/interconnectors_manifest.json"]) {
  assert.equal(sha256(await readFile(join(RELEASE, rel))), sha256(await readFile(join(PARENT, rel))), `${rel} is the parent's`);
}

// 6. page identity
const fmt = (n) => n.toLocaleString("en-GB");
const html = await text(join(RELEASE, "index.html"));
assert.ok(html.includes(`UK RENEWABLES PIPELINE ${ID}`), "index.html h1 names this release");
assert.ok(new RegExp(`Canonical DESNZ REPD Q3 2026[^<]*${fmt(manifest.project_count)} solar, BESS and wind records`).test(html), "index.html states the Q3 register count");
assert.ok(!html.includes("REPD Q2 2026: 7,680"), "index.html must not claim the Q2 register");
assert.ok(html.includes("scripts/app-v9-8.js"), "index.html loads the v9.8 app");

console.log(`check_v9_12: ${ID} loader PASS - ${fmt(model.projects.length)} records, ${model.metadata.capacity_mw.toLocaleString("en-GB", { minimumFractionDigits: 2 })} MW, `
  + `${manifest.geometry_count} with geometry / ${manifest.missing_geometry_count} without; news feed unchanged, `
  + `${boundRefs.size - unresolved.length}/${boundRefs.size} bound refs resolve${unresolved.length ? ` (unresolved: ${unresolved.join(", ")})` : ""}`);

Run V9 12

A shell script in the tests folder of GlobalGrid2050 that tests rebuilt coordinates, the Renewable Energy Planning Database (REPD) register and interconnectors, using SHA-256.

testglobalgrid2050 / uk_renewables_pipeline/202611132345/tests/run_v9_12.sh · lines 1–129 of 129 · version 2026-11-13 23:45 · Entry point · pattern is_listed (shared by 38 files)

What it does
It tests rebuilt coordinates, the REPD register and interconnectors. Defines is_listed, walk. 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. Domain terms in the code: the REPD register, interconnectors. README: "Every other byte - JavaScript, styles, newspaper, the v9.8 interconnector product - is the parent's, proven so by `tests/run_v9_12.sh`."
Inputs & outputs
In: JSON file release.v9.1.json; JSON file rebuilt_coordinates.json; JSON file build_manifest.json; command-line arguments.
Downstream impact
Used directly by 1 file: GlobalGrid2050 Verify Pipeline Workflow (globalgrid2050).
What it achieves
It is built from the is listed helper (`is_listed`) and the walk step (`walk`). The README says: Every other byte - JavaScript, styles, newspaper, the v9.8 interconnector product - is the parent's, proven so by `tests/run_v9_12.sh`.
Why it matters
Run by GlobalGrid2050 Verify Pipeline Workflow.
Application
globalgrid2050 · uk_renewables_pipeline/202611132345/tests · shell script
Uses
Check V9 12 (script call)
Used by
run by GlobalGrid2050 Verify Pipeline Workflow (workflow run)
Produces
is_listed, walk
Defines here
is_listed, walk
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/202611132345/tests/run_v9_12.sh:1-129 · blob c105b1dd23b1da311cd858cca73ef85da60ec053 · GitHub at these lines
State
achieves: readme · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env bash
# run_v9_12.sh - REPD Q3 2026 (October 2026) data refresh of the operative
# Pipeline News release. Runs offline, in a git checkout or a plain copy.
set -euo pipefail

HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
RELEASE="$(cd "$HERE/.." && pwd)"
ID="$(basename "$RELEASE")"
PARENT_ID="202609082224"
PARENT="$(cd "$RELEASE/../$PARENT_ID" && pwd)"
ROOT="$(cd "$RELEASE/../.." && pwd)"
PARENT_TREE="6247a0c3c00e8e88324d9ea55b22d67dbbb1be90"

# The frozen parent, by git tree of the bytes ON DISK (not of HEAD), computed in
# a throwaway object store so this also works in a plain copy. If the parent
# changes under this release, this release's claims about what it inherited are void.
SCRATCH="$(mktemp -d)"
trap 'rm -rf "$SCRATCH"' EXIT
git init -q --bare "$SCRATCH/objects.git"
(cd "$ROOT" && find "uk_renewables_pipeline/$PARENT_ID" -type f -not -path '*/__pycache__/*' -not -name '*.pyc' -not -path '*/node_modules/*' | sort) \
  | GIT_DIR="$SCRATCH/objects.git" GIT_WORK_TREE="$ROOT" GIT_INDEX_FILE="$SCRATCH/index" \
    git -C "$ROOT" -c core.autocrlf=false update-index --add --stdin
actual_tree="$(GIT_DIR="$SCRATCH/objects.git" GIT_INDEX_FILE="$SCRATCH/index" git write-tree --prefix="uk_renewables_pipeline/$PARENT_ID/")"
test "$actual_tree" = "$PARENT_TREE" || { echo "parent $PARENT_ID tree is $actual_tree, expected $PARENT_TREE" >&2; exit 1; }

# WHAT THIS RELEASE CHANGES FROM ITS FROZEN PARENT, NAMED ONE FILE AT A TIME.
CHANGED_FROM_PARENT=(
  index.html
  README.md
  CHANGES.md
  contracts/release.v9.1.json
  contracts/release.v9.5.1.json
  scripts/data/build_v9_1_spine.py
  scripts/plugins/projects-v9-8.js
  tests/run_v9_12.sh
  tests/check_v9_12.mjs
  fixtures/2026q3/project_identity_2026q3.json
  fixtures/2026q3/repd_2026q3_coordinates.json
)
# data/v9.1 is REBUILT, not edited: every file there is proven below by a
# rebuild from the fixtures, so it is listed as a whole.
REBUILT_DIR="data/v9.1"
REMOVED_FROM_PARENT=(
  tests/run_v9_10.sh
  tests/check_v9_10.mjs
)
is_listed() {
  local needle="$1"; shift
  for entry in "$@"; do [[ "$entry" == "$needle" ]] && return 0; done
  return 1
}
walk() { find "$1" -type f -not -path '*/__pycache__/*' -not -name '*.pyc' -not -path '*/node_modules/*' | sort; }

# Everything the parent has, this release has byte for byte, unless named above.
while IFS= read -r file; do
  relative="${file#$PARENT/}"
  [[ "$relative" == "$REBUILT_DIR/"* ]] && continue
  is_listed "$relative" "${CHANGED_FROM_PARENT[@]}" && continue
  if is_listed "$relative" "${REMOVED_FROM_PARENT[@]}"; then
    test ! -e "$RELEASE/$relative"
    continue
  fi
  cmp -s "$file" "$RELEASE/$relative" || { echo "inherited file differs from parent: $relative" >&2; exit 1; }
done < <(walk "$PARENT")
# And nothing this release ships is unnamed.
while IFS= read -r file; do
  relative="${file#$RELEASE/}"
  [[ "$relative" == "$REBUILT_DIR/"* ]] && continue
  is_listed "$relative" "${CHANGED_FROM_PARENT[@]}" && continue
  test -e "$PARENT/$relative" || { echo "unlisted new file: $relative" >&2; exit 1; }
done < <(walk "$RELEASE")
for relative in "${CHANGED_FROM_PARENT[@]}"; do
  test -f "$RELEASE/$relative"
  if [[ -f "$PARENT/$relative" ]]; then
    ! cmp -s "$PARENT/$relative" "$RELEASE/$relative"
  fi
done

# The spine builder reads and writes THIS folder (one line differs from the parent's).
diff <(grep -v '^V9 = ' "$PARENT/scripts/data/build_v9_1_spine.py") <(grep -v '^V9 = ' "$RELEASE/scripts/data/build_v9_1_spine.py")
grep -q '^V9 = Path(__file__).resolve().parents\[2\]' "$RELEASE/scripts/data/build_v9_1_spine.py"

# The spine and the interconnector product are rebuilt in a scratch copy of this
# release and must reproduce the committed bytes. Nothing outside the scratch copy
# is written, so this gate is not vacuous and cannot dirty uk_renewables_pipeline/v9.
COPY="$SCRATCH/root/uk_renewables_pipeline/$ID"
mkdir -p "$(dirname "$COPY")"
cp -a "$RELEASE" "$COPY"
rm -rf "$COPY/data/v9.1"
PYTHONDONTWRITEBYTECODE=1 python3 "$COPY/scripts/data/build_v9_1_spine.py"
diff -r "$RELEASE/data/v9.1" "$COPY/data/v9.1"
node "$COPY/scripts/build/interconnectors-v9-8.mjs" >/dev/null
diff -r "$RELEASE/data/v9.8" "$COPY/data/v9.8"
test ! -e "$SCRATCH/root/uk_renewables_pipeline/v9"

# Optional: rebuild the coordinate fixture from the official workbook.
if [[ -n "${REPD_XLSX:-}" ]]; then
  python3 - "$RELEASE" "$COPY" "$REPD_XLSX" <<'PY'
import json, subprocess, sys
from pathlib import Path
release, copy, xlsx = map(Path, sys.argv[1:])
c = json.loads((release / "contracts/release.v9.1.json").read_text())
root = release.parents[1]
sys.path.insert(0, str(copy / "scripts/data"))
import build_v7_2_spine as b
ident = json.loads((root / c["source"]["identity_fixture"]).read_text())["records"]
out = copy / "fixtures/2026q3/rebuilt_coordinates.json"
b.build_coordinate_fixture(xlsx, ident, out)
assert b.sha256(out) == c["source"]["coordinate_fixture_sha256"], "coordinate fixture does not rebuild byte-for-byte"
print("coordinate fixture rebuilt byte-for-byte from", xlsx.name)
PY
fi

# The CSV export must not carry the Q2 reconciliation count (it is read from
# the build manifest now), and nothing else in the served plugins may either.
if grep -n '14657/14657' "$RELEASE/scripts/plugins/projects-v9-8.js"; then
  echo "projects-v9-8.js still carries the Q2 reconciliation count" >&2; exit 1
fi
python3 -c 'import json,sys; m=json.load(open(sys.argv[1])); assert m["source_record_count"]==14967, m["source_record_count"]' "$RELEASE/data/v9.1/build_manifest.json"

node "$HERE/check_v9_12.mjs"
# Every REPD MAP button, not a sample: every href with the page's own function.
node "$HERE/check_map_contract_all_rows.mjs"

while IFS= read -r source; do
  node --check "$source"
done < <(find "$RELEASE/scripts" -type f \( -name '*.js' -o -name '*.mjs' \) -print | sort)

echo "V9.12 ($ID) validation suite: PASS ($ROOT)"

Check V9 13

A JavaScript module in the tests folder of GlobalGrid2050 that tests major project news, interconnectors and the Renewable Energy Planning Database (REPD) register, using SHA-256.

testglobalgrid2050 / uk_renewables_pipeline/202611140058/tests/check_v9_13.mjs · lines 1–114 of 114 · version 2026-11-14 00:58

What it does
It tests major project news, interconnectors and the REPD register. Defines text, json, sha256, fmt. Uses libraries node:assert/strict, node:crypto, node:fs/promises, node:url, node:path. 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: interconnectors, the REPD register.
Inputs & outputs
In: JSON file release.v9.1.json; JSON file release.v9.5.1.json; JSON file build_manifest.json; JSON file major_project_news_v9_5_1.json; JSON file interconnectors.v9.8.json; JSON file interconnectors.json; JSON file interconnectors_manifest.json.
Downstream impact
Used directly by 1 file: Run V9 13 (globalgrid2050). Reached from 1 other entry point, including GlobalGrid2050 Verify Pipeline Workflow (globalgrid2050).
What it achieves
It is built from the text step (`text`), the JSON step (`json`) and the sha256 step (`sha256`). The REPD Q3 2026 (October 2026) release, proven from the bytes and through the page's OWN loaders.
Why it matters
Checked by Run V9 13.
Application
globalgrid2050 · uk_renewables_pipeline/202611140058/tests · JavaScript module
Uses
Canonical Projects V9 5 1 (new URL import.meta.url), node:assert/strict, node:crypto, node:fs/promises, node:url, node:path
Used by
run by Run V9 13 (script call)
Produces
text, json, sha256, fmt
Defines here
text, json, sha256, fmt
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/202611140058/tests/check_v9_13.mjs:1-114 · blob 56b0140937433f51f431bca3f0f7a45a00bfe9dd · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
/* check_v9_13.mjs - the REPD Q3 2026 (October 2026) release, proven from the
 * bytes and through the page's OWN loaders.
 *
 *   1. The contracts bind the PARENT's (202611132345) fixtures by path and
 *      sha256, and the fixtures on disk there are those bytes.
 *   2. The page's own loader chain - canonical-projects-v9-5-1.js, which runs
 *      canonical-projects-v9-1.js - is imported unmodified and executed against
 *      the files in this folder through a same-origin fetch shim. Every
 *      invariant the browser asserts is therefore asserted here, over all rows.
 *   3. The spine partitions are what the manifest says (sha256 and counts).
 *   4. The UK newspaper is still the repo-root Q2 feed, byte for byte, and the
 *      refs it binds to all resolve in the new spine (the page tolerates
 *      unknown refs, but none are lost in this refresh).
 *   5. The interconnector product and contract are the parent's, byte for byte.
 *   6. The page states its own identity, a release label (no candidate label)
 *      and the register figures.
 *
 * Run: node tests/check_v9_13.mjs
 */
import assert from "node:assert/strict";
import { createHash } from "node:crypto";
import { readFile } from "node:fs/promises";
import { fileURLToPath } from "node:url";
import { basename, dirname, join } from "node:path";

const HERE = dirname(fileURLToPath(import.meta.url));
const RELEASE = join(HERE, "..");
const ID = basename(RELEASE);
const ROOT = join(RELEASE, "..", "..");
const PARENT_ID = "202611132345";
const PARENT = join(RELEASE, "..", PARENT_ID);
const text = (p) => readFile(p, "utf8");
const json = async (p) => JSON.parse(await text(p));
const sha256 = (b) => createHash("sha256").update(b).digest("hex");

const NEWS_FEED_SHA256 = "cea104c3e9cfc07971680afdf5f64073e1d4825b63bfaf4e969266df8386ebbd";

// 1. contracts bind fixtures
const c91 = await json(join(RELEASE, "contracts", "release.v9.1.json"));
const c951 = await json(join(RELEASE, "contracts", "release.v9.5.1.json"));
assert.equal(c91.source.dataset, "DESNZ Renewable Energy Planning Database Q3 2026");
for (const [pathKey, shaKey] of [["identity_fixture", "identity_fixture_sha256"], ["coordinate_fixture", "coordinate_fixture_sha256"]]) {
  const rel = c91.source[pathKey];
  assert.ok(rel.startsWith(`uk_renewables_pipeline/${PARENT_ID}/fixtures/`), `${pathKey} must be the parent's fixture: ${rel}`);
  assert.equal(sha256(await readFile(join(ROOT, rel))), c91.source[shaKey], `${pathKey} bytes`);
}
const coords = await json(join(ROOT, c91.source.coordinate_fixture));
assert.equal(coords.source_workbook_sha256, c91.source.workbook_sha256, "coordinate fixture names the contract workbook");
const identity = await json(join(ROOT, c91.source.identity_fixture));
assert.equal(identity.schema, "globalgrid2050.project-identity.v6");
assert.equal(identity.records.length, identity.raw_record_count);
assert.equal(coords.source_records, identity.raw_record_count, "workbook and identity hold the same refs");

// 2. the page's own loader, unmodified, against these bytes
const ORIGIN = "http://release.invalid";
const BASE = `${ORIGIN}/uk_renewables_pipeline/${ID}/`;
globalThis.window = { location: { origin: ORIGIN, href: BASE } };
globalThis.fetch = async (path) => {
  const url = new URL(path, BASE);
  assert.ok(url.pathname.startsWith(`/uk_renewables_pipeline/${ID}/`), `loader fetched outside the release: ${url}`);
  const file = join(RELEASE, decodeURIComponent(url.pathname.slice(`/uk_renewables_pipeline/${ID}/`.length)));
  const body = await text(file);
  return { ok: true, status: 200, url: url.href, json: async () => JSON.parse(body) };
};
const loader = await import(new URL("../scripts/data/canonical-projects-v9-5-1.js", import.meta.url).href);
const model = await loader.loadCanonicalProjectsV9_5_1();
assert.equal(model.projects.length, c951.expected.project_count);
assert.equal(Math.round(model.metadata.capacity_mw), c951.expected.displayed_capacity_mw);

// 3. partitions are the manifest's bytes
const manifest = await json(join(RELEASE, "data", "v9.1", "build_manifest.json"));
for (const part of [...manifest.project_partitions, ...manifest.atlas_partitions]) {
  assert.equal(sha256(await readFile(join(RELEASE, part.path))), part.sha256, `${part.path} hash`);
}
const atlasFeatures = manifest.atlas_partitions.reduce((n, p) => n + p.feature_count, 0);
assert.equal(atlasFeatures, manifest.geometry_count, "atlas features = valid geometries");
for (const key of Object.keys(c91.expected)) assert.equal(manifest[key], c91.expected[key], `manifest ${key}`);
assert.equal(manifest.source_dataset, c91.source.dataset);
assert.equal(manifest.source_record_count, identity.raw_record_count);

// 4. the newspaper: unchanged Q2 feed, every bound ref still resolves
const feedBytes = await readFile(join(ROOT, "dist", "major_project_news_v9_5_1.json"));
assert.equal(sha256(feedBytes), NEWS_FEED_SHA256, "dist/major_project_news_v9_5_1.json must not be rebuilt by this release");
const feed = JSON.parse(feedBytes);
const byRef = new Map(model.projects.map((p) => [p.repd_ref, p]));
const boundRefs = new Set(feed.canonical_items.map((item) => String(item.repd_ref)));
const unresolved = [...boundRefs].filter((ref) => !byRef.has(ref));
const beacon = byRef.get(feed.beacon_fen_contract.repd_ref);
assert.ok(beacon, "Beacon Fen must be in the spine");
assert.equal(beacon.capacity_mw, feed.beacon_fen_contract.official_capacity_mw, "Beacon Fen official capacity");

// 5. interconnectors are the parent's
for (const rel of ["contracts/interconnectors.v9.8.json", "data/v9.8/interconnectors.json", "data/v9.8/interconnectors_manifest.json"]) {
  assert.equal(sha256(await readFile(join(RELEASE, rel))), sha256(await readFile(join(PARENT, rel))), `${rel} is the parent's`);
}

// 6. page identity
const fmt = (n) => n.toLocaleString("en-GB");
const html = await text(join(RELEASE, "index.html"));
assert.ok(html.includes(`UK RENEWABLES PIPELINE ${ID}`), "index.html h1 names this release");
assert.ok(new RegExp(`Canonical DESNZ REPD Q3 2026[^<]*${fmt(manifest.project_count)} solar, BESS and wind records`).test(html), "index.html states the Q3 register count");
assert.ok(!html.includes("REPD Q2 2026: 7,680"), "index.html must not claim the Q2 register");
assert.ok(html.includes("scripts/app-v9-8.js"), "index.html loads the v9.8 app");
const label = html.slice(html.indexOf("<body>"), html.indexOf('<section class="newspaper">'));
assert.ok(!/CANDIDATE/.test(label), "brand, nav, h1 and meta carry no candidate label");
assert.ok(label.includes('<small>UK RENEWABLES PIPELINE · V9.13</small>'), "brand names V9.13");
assert.ok(label.includes('<a class="active" href="#">V9.13 RELEASE · REPD Q3 2026</a>'), "nav names the release");
assert.ok(label.includes(`<a href="../${PARENT_ID}/">`), "nav links back to the parent");
assert.ok(/<strong>V9\.13 · REPD OCTOBER 2026 \(Q3\) DATA REFRESH · RELEASE · 14 November 2026<\/strong>/.test(label), "meta line in the 202609082224 shape");
assert.ok(html.includes(`<title>GlobalGrid2050 | UK Renewables Pipeline ${ID}</title>`), "title names this release");

console.log(`check_v9_13: ${ID} loader PASS - ${fmt(model.projects.length)} records, ${model.metadata.capacity_mw.toLocaleString("en-GB", { minimumFractionDigits: 2 })} MW, `
  + `${manifest.geometry_count} with geometry / ${manifest.missing_geometry_count} without; news feed unchanged, `
  + `${boundRefs.size - unresolved.length}/${boundRefs.size} bound refs resolve${unresolved.length ? ` (unresolved: ${unresolved.join(", ")})` : ""}`);

Run V9 13

A shell script in the tests folder of GlobalGrid2050 that tests rebuilt coordinates and interconnectors, using SHA-256.

testglobalgrid2050 / uk_renewables_pipeline/202611140058/tests/run_v9_13.sh · lines 1–137 of 137 · version 2026-11-14 00:58 · Entry point · pattern is_listed (shared by 38 files)

What it does
It tests rebuilt coordinates and interconnectors. Defines is_listed, walk. 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. Domain terms in the code: interconnectors. README: "Everything is proven by `tests/run_v9_13.sh`."
Inputs & outputs
In: JSON file release.v9.1.json; JSON file build_manifest.json; JSON file rebuilt_coordinates.json; command-line arguments.
Downstream impact
Used directly by 1 file: GlobalGrid2050 Verify Pipeline Workflow (globalgrid2050).
What it achieves
It is built from the is listed helper (`is_listed`) and the walk step (`walk`). The README says: Everything is proven by `tests/run_v9_13.sh`.
Why it matters
Run by GlobalGrid2050 Verify Pipeline Workflow.
Application
globalgrid2050 · uk_renewables_pipeline/202611140058/tests · shell script
Uses
Check V9 13 (script call)
Used by
run by GlobalGrid2050 Verify Pipeline Workflow (workflow run)
Produces
is_listed, walk
Defines here
is_listed, walk
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/202611140058/tests/run_v9_13.sh:1-137 · blob aa98ad29f194afce347ba02e1211dfa646931e62 · GitHub at these lines
State
achieves: readme · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env bash
# run_v9_13.sh - REPD October 2026 (Q3 2026) release: the V9.12 candidate's register
# under a release label, with the CSV source-count fix. Offline, in a git checkout
# or a plain copy.
set -euo pipefail

HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
RELEASE="$(cd "$HERE/.." && pwd)"
ID="$(basename "$RELEASE")"
PARENT_ID="202611132345"
PARENT="$(cd "$RELEASE/../$PARENT_ID" && pwd)"
ROOT="$(cd "$RELEASE/../.." && pwd)"
# The parent by git tree of the bytes ON DISK. Two trees are accepted, both named:
#   a3f76f61... = globalgrid2050 f9ccd703, the bytes served and hash-verified when the
#                 homepage was first pointed at 202611132345;
#   0c7a4ed5... = the same folder after PR #63 (d5de5a03) changed CHANGES.md,
#                 scripts/plugins/projects-v9-8.js and tests/run_v9_12.sh in place.
# Restoring those three files returns the parent to the first tree; either way the
# data and the fixtures this release binds are the same bytes.
PARENT_TREES=(a3f76f610dff9da15090df56181fdbccc2e210fa 0c7a4ed5ea369e4a4e71a45cfa6fe9c186fae773)

SCRATCH="$(mktemp -d)"
trap 'rm -rf "$SCRATCH"' EXIT
git init -q --bare "$SCRATCH/objects.git"
(cd "$ROOT" && find "uk_renewables_pipeline/$PARENT_ID" -type f -not -path '*/__pycache__/*' -not -name '*.pyc' -not -path '*/node_modules/*' | sort) \
  | GIT_DIR="$SCRATCH/objects.git" GIT_WORK_TREE="$ROOT" GIT_INDEX_FILE="$SCRATCH/index" \
    git -C "$ROOT" -c core.autocrlf=false update-index --add --stdin
actual_tree="$(GIT_DIR="$SCRATCH/objects.git" GIT_INDEX_FILE="$SCRATCH/index" git write-tree --prefix="uk_renewables_pipeline/$PARENT_ID/")"
tree_ok=0
for tree in "${PARENT_TREES[@]}"; do [[ "$actual_tree" == "$tree" ]] && tree_ok=1; done
test "$tree_ok" = 1 || { echo "parent $PARENT_ID tree is $actual_tree, expected one of ${PARENT_TREES[*]}" >&2; exit 1; }

# WHAT THIS RELEASE CHANGES FROM ITS PARENT, NAMED ONE FILE AT A TIME.
CHANGED_FROM_PARENT=(
  index.html
  README.md
  CHANGES.md
  tests/run_v9_13.sh
  tests/check_v9_13.mjs
)
# Pinned by content, not by parity: the parent holds either the pre-fix or the
# fixed bytes of this file (see PARENT_TREES); this release always holds the fix.
PINNED_FILES=(scripts/plugins/projects-v9-8.js)
PINNED_SHA256=(f4174d3af1b867a911ec49d3cfdfdd7823225384e25e8e1cb711ff07c7fe90d6)
REMOVED_FROM_PARENT=(
  tests/run_v9_12.sh
  tests/check_v9_12.mjs
  fixtures/2026q3/project_identity_2026q3.json
  fixtures/2026q3/repd_2026q3_coordinates.json
)
is_listed() {
  local needle="$1"; shift
  for entry in "$@"; do [[ "$entry" == "$needle" ]] && return 0; done
  return 1
}
walk() { find "$1" -type f -not -path '*/__pycache__/*' -not -name '*.pyc' -not -path '*/node_modules/*' | sort; }

while IFS= read -r file; do
  relative="${file#$PARENT/}"
  is_listed "$relative" "${CHANGED_FROM_PARENT[@]}" && continue
  is_listed "$relative" "${PINNED_FILES[@]}" && continue
  if is_listed "$relative" "${REMOVED_FROM_PARENT[@]}"; then
    test ! -e "$RELEASE/$relative" || { echo "should not be copied: $relative" >&2; exit 1; }
    continue
  fi
  cmp -s "$file" "$RELEASE/$relative" || { echo "inherited file differs from parent: $relative" >&2; exit 1; }
done < <(walk "$PARENT")
while IFS= read -r file; do
  relative="${file#$RELEASE/}"
  is_listed "$relative" "${CHANGED_FROM_PARENT[@]}" && continue
  test -e "$PARENT/$relative" || { echo "unlisted new file: $relative" >&2; exit 1; }
done < <(walk "$RELEASE")
for relative in "${CHANGED_FROM_PARENT[@]}"; do
  test -f "$RELEASE/$relative"
  if [[ -f "$PARENT/$relative" ]] && cmp -s "$PARENT/$relative" "$RELEASE/$relative"; then
    echo "listed as changed but identical to parent: $relative" >&2; exit 1
  fi
done
for i in "${!PINNED_FILES[@]}"; do
  got="$(sha256sum "$RELEASE/${PINNED_FILES[$i]}" | cut -d' ' -f1)"
  test "$got" = "${PINNED_SHA256[$i]}" || { echo "${PINNED_FILES[$i]} is $got, expected ${PINNED_SHA256[$i]}" >&2; exit 1; }
done

# The fixtures are the parent's: the contract is the parent's byte for byte and
# names them under uk_renewables_pipeline/$PARENT_ID/fixtures/ with their sha256.
cmp -s "$PARENT/contracts/release.v9.1.json" "$RELEASE/contracts/release.v9.1.json"
grep -q "\"identity_fixture\": \"uk_renewables_pipeline/$PARENT_ID/fixtures/2026q3/project_identity_2026q3.json\"" "$RELEASE/contracts/release.v9.1.json"
grep -q '^V9 = Path(__file__).resolve().parents\[2\]' "$RELEASE/scripts/data/build_v9_1_spine.py"

# CSV text: the "Source Reconciliation" column comes from the build manifest, never
# from the Q2 literal.
if grep -n '14657/14657' "$RELEASE/scripts/plugins/projects-v9-8.js"; then
  echo "projects-v9-8.js carries the Q2 reconciliation count" >&2; exit 1
fi
grep -q 'reconciliationNote()' "$RELEASE/scripts/plugins/projects-v9-8.js"
python3 -c 'import json,sys; m=json.load(open(sys.argv[1])); assert m["source_record_count"]==14967, m["source_record_count"]' "$RELEASE/data/v9.1/build_manifest.json"

# Spine and interconnector product rebuilt in a scratch root that holds this release
# and, at the parent's path, only the two fixtures the contract binds. They must
# reproduce the committed bytes.
SROOT="$SCRATCH/root"
COPY="$SROOT/uk_renewables_pipeline/$ID"
mkdir -p "$SROOT/uk_renewables_pipeline/$PARENT_ID/fixtures"
cp -a "$PARENT/fixtures/2026q3" "$SROOT/uk_renewables_pipeline/$PARENT_ID/fixtures/"
cp -a "$RELEASE" "$COPY"
rm -rf "$COPY/data/v9.1"
PYTHONDONTWRITEBYTECODE=1 python3 "$COPY/scripts/data/build_v9_1_spine.py"
diff -r "$RELEASE/data/v9.1" "$COPY/data/v9.1"
node "$COPY/scripts/build/interconnectors-v9-8.mjs" >/dev/null
diff -r "$RELEASE/data/v9.8" "$COPY/data/v9.8"
test ! -e "$SROOT/uk_renewables_pipeline/v9"

if [[ -n "${REPD_XLSX:-}" ]]; then
  python3 - "$RELEASE" "$COPY" "$REPD_XLSX" <<'PY'
import json, sys
from pathlib import Path
release, copy, xlsx = map(Path, sys.argv[1:])
c = json.loads((release / "contracts/release.v9.1.json").read_text())
root = release.parents[1]
sys.path.insert(0, str(copy / "scripts/data"))
import build_v7_2_spine as b
ident = json.loads((root / c["source"]["identity_fixture"]).read_text())["records"]
out = copy.parent / "rebuilt_coordinates.json"
b.build_coordinate_fixture(xlsx, ident, out)
assert b.sha256(out) == c["source"]["coordinate_fixture_sha256"], "coordinate fixture does not rebuild byte-for-byte"
print("coordinate fixture rebuilt byte-for-byte from", xlsx.name)
PY
fi

node "$HERE/check_v9_13.mjs"
node "$HERE/check_map_contract_all_rows.mjs"

while IFS= read -r source; do
  node --check "$source"
done < <(find "$RELEASE/scripts" -type f \( -name '*.js' -o -name '*.mjs' \) -print | sort)

echo "V9.13 ($ID) validation suite: PASS ($ROOT)"