GLOBALGRID2050 / EXPLORE CODE

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

Projects V9 5 1 and 1 more file (part 1)

A JavaScript module in the plugins folder of GlobalGrid2050 that compares project updates v9, updates sort header, projects row and reads inputs for county and sort projects.

676 lines of JavaScript from globalgrid2050, in 2 files. Topic: Electricity markets and data pipelines. Section 930 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. Projects V9 5 1 energy-data · globalgrid2050 / uk_renewables_pipeline/202609061149/scripts/plugins/projects-v9-5-1.js lines 1–523
  2. Check V9 7 test · globalgrid2050 / uk_renewables_pipeline/202609061149/tests/check_v9_7.mjs lines 1–153

Projects V9 5 1

A JavaScript module in the plugins folder of GlobalGrid2050 that compares project updates v9, updates sort header, projects row and reads inputs for county and sort projects.

energy-dataglobalgrid2050 / uk_renewables_pipeline/202609061149/scripts/plugins/projects-v9-5-1.js · lines 1–523 of 523 · version 2026-09-06 11:49 · pattern projectRowHtml (shared by 3 files)

What it does
It draws the REPD register, solar, battery storage (BESS) and wind. Defines 27 functions or classes, including atlasUrlV9_5_1, displayDate, repdUpdatedTimestamp, compareProjectUpdatesV9_5_1, updateSortHeader. 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, solar, battery storage (BESS), wind.
Inputs & outputs
Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid), WGS84 / EPSG:4326.
Downstream impact
Used directly by 1 file: Check V9 5 1 (globalgrid2050). Reached from 1 other entry point, including Run V9 5 1 (globalgrid2050).
What it achieves
It compares project updates v9 (`compareProjectUpdatesV9_5_1`), updates sort header (`updateSortHeader`) and maps action HTML v9 (`mapActionHtmlV9_5_1`). Its `downloadCsv` function gives CSV download or refusal from active table owner, filtered register rows and official detail partitions (VEDIC: export filtered projects). It responds to click events.
Why it matters
Checked by Check V9 5 1.
Application
globalgrid2050 · uk_renewables_pipeline/202609061149/scripts/plugins · JavaScript module
VEDIC
EXPORT FILTERED PROJECTS (GG2050-VEDIC-000060): Pipeline News · Renewable project register. active_table_owner, filtered_register_rows, official_detail_partitions → csv_download_or_refusal
Uses
Testcode — Pipeline (import), Atlas Receiver V9 7 (import), State (import), Project Filter V9 2 (import), Canonical Projects V9 5 1 (import), Gauges V9 2 (import), Newspaper V9 5 1 (import)
Used by
run by Check V9 5 1 (script call)
Produces
atlasUrlV9_5_1, compareProjectUpdatesV9_5_1, loadProjectsV9_5_1, refreshProjectsV9_5_1, bindProjectControlsV9_5_1
Defines here
atlasUrlV9_5_1, displayDate, repdUpdatedTimestamp, compareProjectUpdatesV9_5_1, updateSortHeader, relationshipSummary, mapActionHtmlV9_5_1, schedule, projectRowHtml, pageCount, pagerElement, renderPager, renderTable, updateResultSummary, syncFilterUrl, apply, populateCounties, setButtonState, hydrateFiltersFromUrl, csvCell, downloadCsv, clearFilters, copyProjectId, loadProjectsV9_5_1, refreshProjectsV9_5_1, bindProjectControlsV9_5_1, syncMapAtlasNavV9_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/202609061149/scripts/plugins/projects-v9-5-1.js:1-523 · blob 3777093365bf2c61354ac61658a361aad07beecb · GitHub at these lines
State
achieves: code · context: readme_derived · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
import { escapeHtml } from "../core/utils.js";
import {
  atlasCentresOnRepdPointV9_7,
  atlasReceiverV9_7,
  atlasUnavailableReasonV9_7,
  buildAtlasDeepLinkV9_7,
  verifyAtlasReceiverV9_7,
} from "../core/atlas-receiver-v9-7.js";
import { state } from "../core/state.js";
import {
  buildProjectSearchTextV9_2,
  projectMatchesV9_2,
  summariseProjectsV9_2,
  tokeniseSearchV9_2,
} from "../core/project-filter-v9-2.js";
import { loadCanonicalProjectsV9_5_1 } from "../data/canonical-projects-v9-5-1.js";
import {
  formatCapacityV9_2,
  formatLargestV9_2,
  setGaugeUniverseV9_2,
  updateGaugesV9_2,
} from "./gauges-v9-2.js";
import { signalForProjectV9_5_1 } from "./newspaper-v9-5-1.js";

const LABELS = Object.freeze({
  solar: "Solar",
  bess: "Battery Storage",
  wind_onshore: "Onshore Wind",
  wind_offshore: "Offshore Wind",
});
const COLOURS = Object.freeze({ solar: "#ffff00", bess: "#ffae00", wind_onshore: "#00ffff", wind_offshore: "#0066ff" });
const UNITS = Object.freeze({ solar: "MWp", bess: "MW", wind_onshore: "MW", wind_offshore: "MW" });
const ALLOWED_TECHNOLOGIES = new Set(["all", "solar", "bess", "wind_onshore", "wind_offshore"]);
const ALLOWED_STATUSES = new Set(["All", "Operational", "Under Construction", "Awaiting Construction", "Application Submitted"]);
const ALLOWED_SORTS = new Set(["capacity_desc", "updated_desc", "updated_asc"]);

let all = [];
let filtered = [];
let page = 0;
let metadata = null;
let release = null;
let searchIndex = new Map();
let technology = "all";
let status = "All";
let county = "All";
let query = "";
let sortMode = "capacity_desc";
let controlsBound = false;

export function atlasUrlV9_5_1(project) {
  // The receiver is not named here. It is read from the deep-link contract the
  // engine publishes -- see ../core/atlas-receiver-v9-7.js for the measurement
  // that made this necessary. Seven files in this directory each held their own
  // copy of a route that had quietly stopped carrying the engine.
  return buildAtlasDeepLinkV9_7(project);
}

function displayDate(value) {
  if (!value) return "not supplied by REPD";
  const [year, month, day] = String(value).split("-");
  return year && month && day ? `${day}/${month}/${year}` : String(value);
}

function repdUpdatedTimestamp(project) {
  if (!project.repd_record_updated) return null;
  const value = Date.parse(`${project.repd_record_updated}T00:00:00Z`);
  return Number.isFinite(value) ? value : null;
}

export function compareProjectUpdatesV9_5_1(left, right, direction = "desc") {
  const leftTime = repdUpdatedTimestamp(left);
  const rightTime = repdUpdatedTimestamp(right);
  if (leftTime === null && rightTime === null) return 0;
  if (leftTime === null) return 1;
  if (rightTime === null) return -1;
  return direction === "asc" ? leftTime - rightTime : rightTime - leftTime;
}

function updateSortHeader() {
  const header = document.getElementById("repdUpdatedHeader");
  const button = document.getElementById("sortUpdated");
  const indicator = document.getElementById("updatedSortIndicator");
  if (!header || !button || !indicator) return;
  if (sortMode === "updated_desc") {
    header.setAttribute("aria-sort", "descending");
    indicator.textContent = "▼";
    button.setAttribute("aria-label", "REPD updated date sorted newest first; click for oldest first");
    button.title = "Newest first — click for oldest first";
    return;
  }
  if (sortMode === "updated_asc") {
    header.setAttribute("aria-sort", "ascending");
    indicator.textContent = "▲";
    button.setAttribute("aria-label", "REPD updated date sorted oldest first; click for newest first");
    button.title = "Oldest first — click for newest first";
    return;
  }
  header.setAttribute("aria-sort", "none");
  indicator.textContent = "↕";
  button.setAttribute("aria-label", "Sort by REPD updated date, newest first");
  button.title = "Click for newest first";
}

function relationshipSummary(project) {
  const development = Array.isArray(project.development_repd_refs) ? project.development_repd_refs.length : 0;
  const direct = Array.isArray(project.direct_related_repd_refs) ? project.direct_related_repd_refs.length : 0;
  const siblings = Array.isArray(project.planning_sibling_repd_refs) ? project.planning_sibling_repd_refs.length : 0;
  return `${development} development · ${direct} direct · ${siblings} planning sibling record(s)`;
}

/* WHAT THE MAP CELL SAYS, AND WHY IT SAYS IT IN THE CELL.

   This used to be a link or the two words NO MAP with its reason in a title
   attribute. A phone reports hover: none, so on a phone the reason could not be
   reached at all -- and 28 of these 7,680 records got the silent version.

   Those 28 are no longer denied a link. The contract requires only repd_ref;
   latitude and longitude are optional, and the canonical receiver resolves the
   project from its REPD reference and centres on its own geometry. Measured on
   REPD 13429 (Ossian), which has no REPD coordinate: the arrival names the
   project, its capacity and its reference. So they get a MAP button and a
   sentence saying whose coordinate the map is using -- which is the honest
   answer, and the opposite of a button that quietly does nothing. */
function mapActionHtmlV9_5_1(project) {
  const href = atlasUrlV9_5_1(project);
  if (!href) {
    return `<span class="action-disabled">NO MAP</span>`
      + `<div class="map-note">${escapeHtml(atlasUnavailableReasonV9_7(project))}</div>`;
  }
  const link = `<a class="action-link atlaslink" target="_blank" rel="noopener" href="${escapeHtml(href)}">MAP ↗</a>`;
  if (atlasCentresOnRepdPointV9_7(project)) return link;
  return `${link}<div class="map-note">REPD published no coordinate for this record. `
    + `The Atlas resolves it from REPD ${escapeHtml(project.repd_ref)} and centres on its own geometry.</div>`;
}

/* PROGRESSIVE RENDER — measured, not guessed.
   The unfiltered view is 7,680 rows at 42 elements each: 323,802 DOM elements
   built from 13.7 MB of markup in a single synchronous innerHTML assignment.
   Measured on a desktop on 2026-09-06, that assignment blocks the main thread
   for 3.6 to 4.4 seconds. An iPhone is several times slower again, which is
   the freeze where nothing responds to a tap.

   The fetch is NOT the problem and was measured before being blamed: the first
   partition lands in about 80 ms and all sixteen in 458-571 ms at any
   concurrency between 4 and 16. Only the render is slow.

   So the first rows are painted at once and the remainder is appended a chunk
   per animation frame. Nothing is hidden and nothing is paginated: `all` and
   `filtered` are untouched, so search, the counts and the CSV export continue
   to see every record — which is the trap a pagination that slices the data
   rather than the view walks into.

   A render in flight is cancelled by the next one through renderToken, or
   changing a filter mid-render would append rows from the previous result on
   top of the new one. */
const FIRST_PAINT_ROWS = 100;
const CHUNK_ROWS = 300;
let renderToken = 0;

/* requestAnimationFrame does not fire in a background tab, so a reader who
   opens this in a second tab and comes back would find the table still holding
   only its first hundred rows. A timeout does fire there, throttled, so the
   table finishes either way: frames while the reader is looking, timeouts while
   they are not. */
function schedule(step) {
  if (document.visibilityState === "visible" && typeof requestAnimationFrame === "function") {
    requestAnimationFrame(step);
  } else {
    setTimeout(step, 0);
  }
}

function projectRowHtml(project) {
  const label = LABELS[project.technology];
    const unit = UNITS[project.technology];
    const location = [project.county, project.region].filter(Boolean).join(" · ");
    const signal = signalForProjectV9_5_1(project);
    const news = new URL("https://www.google.com/search");
    news.searchParams.set("q", `${project.name} ${label} UK`);
    news.searchParams.set("tbm", "nws");
    const mapAction = mapActionHtmlV9_5_1(project);
    const planning = project.planning_application_reference || "not supplied by REPD";
    const authority = project.planning_authority || "not supplied by REPD";
    const developmentId = project.gg_development_id || "not assigned";
    const updated = displayDate(project.repd_record_updated);
    return `<tr id="repd-${escapeHtml(project.repd_ref)}" data-repd-updated="${escapeHtml(project.repd_record_updated || "")}"><td class="site">${escapeHtml(project.name)}<div class="project-meta">REPD ${escapeHtml(project.repd_ref)} · ${escapeHtml(project.gg_project_id)} · UPDATED ${escapeHtml(updated)}</div><div class="mobile-extra">${escapeHtml([location, project.operator].filter(Boolean).join(  … [line shortened here: 2,120 characters; full line on GitHub]
}

/* TWENTY ROWS, AND THE REST BEHIND PAGES AND SEARCH.
 *
 * The previous build painted the first hundred rows and then streamed the
 * remaining seven and a half thousand into the DOM in chunks. That stopped the
 * page freezing, but it still built 7,680 table rows on a phone for a reader
 * who was going to look at the top of the list.
 *
 * So the VIEW is now a page of twenty, largest capacity first. The DATA is
 * untouched: `all` still holds every qualifying record, `filtered` still holds
 * every record matching the current tabs and search, the CSV still exports the
 * filtered set in full, and the count line still states both numbers. Nothing
 * is dropped from the pipeline - the reader is simply not made to render it.
 *
 * The tabs and the search box do the narrowing. Paging is for what is left. */
const PAGE_ROWS = 20;

function pageCount() {
  return Math.max(1, Math.ceil(filtered.length / PAGE_ROWS));
}

function pagerElement() {
  let el = document.getElementById("projectPager");
  if (!el) {
    el = document.createElement("nav");
    el.id = "projectPager";
    el.className = "pager";
    el.setAttribute("aria-label", "Project pages");
    const table = document.getElementById("tbody");
    const anchor = table ? table.closest("table") : null;
    if (anchor && anchor.parentNode) anchor.parentNode.insertBefore(el, anchor.nextSibling);
    else if (table) table.parentNode.appendChild(el);
  }
  return el;
}

function renderPager() {
  const el = pagerElement();
  const pages = pageCount();
  const total = filtered.length;
  if (!total) {
    el.innerHTML = '<span class="pager-meta">no records match the current filters</span>';
    return;
  }
  const from = page * PAGE_ROWS + 1;
  const to = Math.min(total, (page + 1) * PAGE_ROWS);
  el.innerHTML =
    '<button type="button" class="pager-btn" data-page-step="-1"' + (page === 0 ? ' disabled' : '') + '>&larr; PREV</button>' +
    '<span class="pager-meta">' + from.toLocaleString("en-GB") + '&ndash;' + to.toLocaleString("en-GB") +
      ' of ' + total.toLocaleString("en-GB") + ' &middot; page ' + (page + 1) + ' of ' + pages + '</span>' +
    '<button type="button" class="pager-btn" data-page-step="1"' + (page + 1 >= pages ? ' disabled' : '') + '>NEXT &rarr;</button>';
  el.dataset.page = String(page + 1);
  el.dataset.pages = String(pages);
  el.dataset.from = String(from);
  el.dataset.to = String(to);
}

function renderTable() {
  const body = document.getElementById("tbody");
  const total = filtered.length;
  const pages = pageCount();
  if (page > pages - 1) page = pages - 1;
  if (page < 0) page = 0;
  const from = page * PAGE_ROWS;
  const slice = filtered.slice(from, from + PAGE_ROWS);
  body.innerHTML = slice.map(projectRowHtml).join("");
  body.dataset.rendered = String(slice.length);
  body.dataset.total = String(total);
  body.dataset.page = String(page + 1);
  body.dataset.pages = String(pages);
  body.dataset.complete = "true";
  renderPager();
}

function updateResultSummary() {
  const summary = summariseProjectsV9_2(filtered);
  const element = document.getElementById("resultsMeta");
  element.textContent = `${summary.count.toLocaleString("en-GB")} of ${all.length.toLocaleString("en-GB")} records · ${formatCapacityV9_2(summary.capacity_mw)} MW · largest ${formatLargestV9_2(summary.largest_mw)} MW`;
  element.classList.toggle("is-filtered", summary.count !== all.length);
  element.dataset.filteredCount = String(summary.count);
  element.dataset.totalCount = String(all.length);
}

function syncFilterUrl() {
  const url = new URL(window.location.href);
  for (const parameter of ["technology", "status", "county", "q", "sort"]) url.searchParams.delete(parameter);
  if (technology !== "all") url.searchParams.set("technology", technology);
  if (status !== "All") url.searchParams.set("status", status);
  if (county !== "All") url.searchParams.set("county", county);
  if (query) url.searchParams.set("q", query);
  if (sortMode !== "capacity_desc") url.searchParams.set("sort", sortMode);
  history.replaceState(null, "", url);
}

function apply({ syncUrl = true } = {}) {
  const tokens = tokeniseSearchV9_2(query);
  filtered = all.filter((project) => projectMatchesV9_2(project, {
    technology,
    status,
    county,
    tokens,
  }, searchIndex.get(project.repd_ref)));
  if (sortMode === "updated_desc") filtered.sort((left, right) => compareProjectUpdatesV9_5_1(left, right, "desc"));
  if (sortMode === "updated_asc") filtered.sort((left, right) => compareProjectUpdatesV9_5_1(left, right, "asc"));
  state.filtered = filtered;
  page = 0;
  updateGaugesV9_2(filtered);
  renderTable();
  updateResultSummary();
  updateSortHeader();
  if (syncUrl) syncFilterUrl();
}

function populateCounties() {
  const select = document.getElementById("county");
  select.replaceChildren(new Option("🌍 ALL COUNTIES", "All"));
  [...new Set(all.map((project) => project.county).filter(Boolean))]
    .sort((left, right) => left.localeCompare(right, "en-GB"))
    .forEach((value) => select.add(new Option(`📍 ${value}`, value)));
}

function setButtonState(container, dataKey, selected) {
  document.querySelectorAll(`${container} .btn`).forEach((button) => {
    const active = button.dataset[dataKey] === selected;
    button.classList.toggle("active", active);
    button.setAttribute("aria-pressed", String(active));
  });
}

function hydrateFiltersFromUrl() {
  const parameters = new URLSearchParams(window.location.search);
  const requestedTechnology = parameters.get("technology") || "all";
  const requestedStatus = parameters.get("status") || "All";
  const requestedCounty = parameters.get("county") || "All";
  const requestedSort = parameters.get("sort") || "capacity_desc";
  technology = ALLOWED_TECHNOLOGIES.has(requestedTechnology) ? requestedTechnology : "all";
  status = ALLOWED_STATUSES.has(requestedStatus) ? requestedStatus : "All";
  county = [...document.getElementById("county").options].some((option) => option.value === requestedCounty)
    ? requestedCounty
    : "All";
  query = parameters.get("q") || "";
  sortMode = ALLOWED_SORTS.has(requestedSort) ? requestedSort : "capacity_desc";
  setButtonState("#tech", "technology", technology);
  setButtonState("#status", "officialStatus", status);
  document.getElementById("county").value = county;
  document.getElementById("search").value = query;
  document.getElementById("sortProjects").value = sortMode;
}

function csvCell(value) {
  let text = value === null || value === undefined ? "" : String(value);
  if (/^(?:[=+\-@]|\s+[=+\-@]|\t|\r|\n)/u.test(text)) text = `'${text}`;
  return `"${text.replaceAll('"', '""')}"`;
}

function downloadCsv(event) {
  event.preventDefault();
  const headers = ["Site Name", "REPD Ref", "GlobalGrid Project ID", "GlobalGrid Development ID", "Identity Status", "Identity Confidence", "Technology", "Official REPD Technology", "Official REPD Capacity", "Capacity Unit", "Official REPD Status", "Derived Lifecycle", "Operator or Applicant", "County", "Region", "Country", "Planning Authority", "Planning Application Reference", "REPD Record Updat  … [line shortened here: 1,130 characters; full line on GitHub]
  const rows = filtered.map((project) => {
    const signal = signalForProjectV9_5_1(project);
    return [project.name, project.repd_ref, project.gg_project_id, project.gg_development_id, project.identity_status, project.identity_confidence, LABELS[project.technology], project.repd_technology, project.capacity_mw, UNITS[project.technology], project.status, project.lifecycle, project.operator, project.county, project.region, project.country, project.planning_authority, project.planning_appl  … [line shortened here: 1,392 characters; full line on GitHub]
  });
  const content = `\ufeff${[headers, ...rows].map((row) => row.map(csvCell).join(",")).join("\r\n")}`;
  const url = URL.createObjectURL(new Blob([content], { type: "text/csv;charset=utf-8" }));
  const anchor = document.createElement("a");
  anchor.href = url;
  anchor.download = `globalgrid2050_uk_renewables_pipeline_v9_5_1_${new Date().toISOString().slice(0, 10)}.csv`;
  anchor.click();
  URL.revokeObjectURL(url);
  document.getElementById("exportMeta").textContent = `${filtered.length.toLocaleString("en-GB")} filtered records exported`;
}

function clearFilters(event) {
  event.preventDefault();
  technology = "all";
  status = "All";
  county = "All";
  query = "";
  sortMode = "capacity_desc";
  setButtonState("#tech", "technology", technology);
  setButtonState("#status", "officialStatus", status);
  document.getElementById("county").value = county;
  document.getElementById("search").value = "";
  document.getElementById("sortProjects").value = sortMode;
  apply();
}

async function copyProjectId(button) {
  const value = button.dataset.copyId;
  try {
    await navigator.clipboard.writeText(value);
  } catch {
    const field = document.createElement("textarea");
    field.value = value;
    field.setAttribute("readonly", "");
    field.style.position = "fixed";
    field.style.opacity = "0";
    document.body.appendChild(field);
    field.select();
    document.execCommand("copy");
    field.remove();
  }
  const original = button.textContent;
  button.textContent = "COPIED";
  button.classList.add("copied");
  setTimeout(() => {
    button.textContent = original;
    button.classList.remove("copied");
  }, 1200);
}

export async function loadProjectsV9_5_1() {
  try {
    /* NOTHING CROSS-ORIGIN GATES THE FIRST ROW.

       This was a Promise.all of the project payload AND a fetch to
       ventusltd.github.io, because atlasUrlV9_5_1() is synchronous and
       renderTable() calls it once per row, so the receiver had to be known
       before the first paint. The consequence, measured 2026-09-05 at a phone
       viewport: not one of 7,680 rows could appear until a request to a SECOND
       ORIGIN had done DNS, TCP, TLS and a round trip — 59 ms on a wired link,
       which is why every desktop check passed, and a cold-radio handshake on
       the device the complaint came from. index.html:157 paints an empty
       <tbody> with no placeholder, so the reader saw nothing at all for the
       duration.

       The receiver is now known at import (see core/atlas-receiver-v9-7.js),
       so this awaits the payload alone. The contract is still read — fired
       here, awaited by nobody — and the only thing it can do is change or
       withdraw the links, which re-renders. On a correct estate it never
       does, because the compiled contract is pinned to the published one by
       testcode/drivers/link-targets.mjs. */
    const verifying = verifyAtlasReceiverV9_7();
    const model = await loadCanonicalProjectsV9_5_1();
    all = [...model.projects];
    filtered = all;
    metadata = model.metadata;
    release = model.release;
    searchIndex = new Map(all.map((project) => [project.repd_ref, buildProjectSearchTextV9_2(project)]));
    state.all = all;
    state.filtered = filtered;
    state.canonicalModel = model;
    setGaugeUniverseV9_2(all);
    populateCounties();
    hydrateFiltersFromUrl();
    apply({ syncUrl: false });
    document.getElementById("releaseMeta").textContent = `V9.5.1 interface · V${release.data_parent.release} canonical data spine · all ${all.length.toLocaleString("en-GB")} qualifying records loaded`;

    /* Re-render only if the engine's published contract disagrees with the one
       compiled in — a different canonical receiver, or this one retired. Not
       awaited, so a slow or dead contract costs the reader nothing, and on the
       normal path `changed` is false and this does no work at all. */
    verifying.then((result) => {
      if (result.changed) refreshProjectsV9_5_1();
      syncMapAtlasNavV9_7();
      if (!result.verified) console.warn(`V9.5.1 MAP: ${result.reason}`);
    });
  } catch (error) {
    console.error(error);
    document.getElementById("tbody").innerHTML = '<tr><td colspan="11" style="text-align:center;color:#ff6666">Canonical Q2 REPD data unavailable. V9.5.1 has failed closed.</td></tr>';
    document.getElementById("resultsMeta").textContent = "canonical data unavailable";
  }
}

export function refreshProjectsV9_5_1() {
  if (metadata) renderTable();
}

export function bindProjectControlsV9_5_1() {
  if (controlsBound) return;
  controlsBound = true;
  document.querySelectorAll("#tech .btn").forEach((button) => {
    button.onclick = () => {
      technology = button.dataset.technology;
      setButtonState("#tech", "technology", technology);
      apply();
    };
  });
  document.querySelectorAll("#status .btn").forEach((button) => {
    button.onclick = () => {
      status = button.dataset.officialStatus;
      setButtonState("#status", "officialStatus", status);
      apply();
    };
  });
  document.getElementById("county").onchange = (event) => { county = event.target.value; apply(); };
  document.getElementById("sortProjects").onchange = (event) => { sortMode = event.target.value; apply(); };
  document.getElementById("sortUpdated").onclick = () => {
    sortMode = sortMode === "updated_desc" ? "updated_asc" : "updated_desc";
    document.getElementById("sortProjects").value = sortMode;
    apply();
  };
  document.getElementById("search").oninput = (event) => { query = event.target.value.trim(); apply(); };
  /* Delegated, because the pager is rebuilt on every render. Paging moves the
     WINDOW over `filtered`; it never re-filters and never re-fetches. */
  document.addEventListener("click", (event) => {
    const button = event.target.closest ? event.target.closest("[data-page-step]") : null;
    if (!button || !document.getElementById("projectPager")) return;
    const step = Number(button.getAttribute("data-page-step"));
    if (!Number.isFinite(step)) return;
    const pages = pageCount();
    const next = Math.min(pages - 1, Math.max(0, page + step));
    if (next === page) return;
    page = next;
    renderTable();
    const table = document.getElementById("tbody");
    if (table && table.closest("table")) table.closest("table").scrollIntoView({ block: "start" });
  });

  document.getElementById("export").onclick = downloadCsv;
  document.getElementById("exportInline").onclick = downloadCsv;
  document.getElementById("clearFilters").onclick = clearFilters;
  document.getElementById("tbody").addEventListener("click", (event) => {
    const button = event.target.closest(".copy-id");
    if (button) copyProjectId(button);
  });
}

/* The MAP ATLAS nav button is static HTML, so it cannot follow the receiver the
   way a row's MAP cell does - and until 2026-09-05 it pointed at the retired V8
   Atlas while every row pointed at the canonical one. The href in index.html is
   now the compiled canonical route, which is correct before any network exists;
   this re-points it only if the live contract disagrees, and hides it if the
   contract withdraws the receiver entirely. Same signal, same moment, as the
   table's own re-render. */
function syncMapAtlasNavV9_7() {
  const nav = document.getElementById("mapAtlasNav");
  if (!nav) return;
  const route = atlasReceiverV9_7();
  if (!route) {
    nav.hidden = true;
    return;
  }
  nav.hidden = false;
  nav.href = route;
}

Check V9 7

A JavaScript module in the tests folder of GlobalGrid2050 that tests regional news sources, news module registry, regional decisions and major project news, using SHA-256.

testglobalgrid2050 / uk_renewables_pipeline/202609061149/tests/check_v9_7.mjs · lines 1–153 of 153 · version 2026-09-06 11:49 · Not reached from any entry point (candidate for review) · pattern gitTree (shared by 16 files)

What it does
It tests regional news sources, news module registry, regional decisions and major project news. Defines text, json, hash, gitTree. Uses libraries node:assert/strict, node:crypto, node:child_process, node:fs/promises, node:url. 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 release.v9.7.json; JSON file regional-news-sources.v9.7.json; JSON file news-module-registry.v9.7.json; JSON file regional_news.json; JSON file regional_decisions.json; JSON file regional_manifest.json; JSON file major_project_news_v9_5_1.json; JSON file major_project_news.json.
What it achieves
It is built from the git tree helper (`gitTree`). Defines `text`, `json`, `hash` and 1 more. Its code works with 160 MWh.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · uk_renewables_pipeline/202609061149/tests · JavaScript module
Uses
Classifier V9 7 (import), node:assert/strict, node:crypto, node:child_process, node:fs/promises, node:url, ../scripts/build/regional-news-v9-7.mjs
Used by
none found
Produces
text, json, hash, gitTree
Defines here
text, json, hash, gitTree
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/202609061149/tests/check_v9_7.mjs:1-153 · blob 287d4584041a05288e6aca56039ad9e58c48bdb1 · 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: duplicate_candidate
import assert from "node:assert/strict";
import { createHash } from "node:crypto";
import { execFileSync } from "node:child_process";
import { readFile } from "node:fs/promises";
import { fileURLToPath } from "node:url";
import { pinnedInputObjectV9_7, readPinnedInputV9_7 } from "../scripts/build/regional-news-v9-7.mjs";
import { classifyRegionalV9_7 } from "../scripts/news/classifier-v9-7.mjs";

const base = new URL("../", import.meta.url);
const root = new URL("../../../", import.meta.url);
const rootPath = fileURLToPath(root);
const text = (url) => readFile(url, "utf8");
const json = async (url) => JSON.parse(await text(url));
const hash = (value) => createHash("sha256").update(value).digest("hex");
const gitTree = (revisionPath) => execFileSync(
  "git", ["-C", rootPath, "rev-parse", revisionPath], { encoding: "utf8" },
).trim();

assert.equal(
  gitTree("HEAD:uk_renewables_pipeline/v9.6.2"),
  "d978c215bceaab6666e4bf17af782191d8fab49e",
  "the validated V9.6.2 parent subtree changed",
);

const [contract, sourceContractText, moduleRegistry, html, packageJson, regionalText, ledgerText, manifest] = await Promise.all([
  json(new URL("contracts/release.v9.7.json", base)),
  text(new URL("contracts/regional-news-sources.v9.7.json", base)),
  json(new URL("contracts/news-module-registry.v9.7.json", base)),
  text(new URL("index.html", base)),
  json(new URL("package.json", base)),
  text(new URL("data/v9.7/regional_news.json", base)),
  text(new URL("data/v9.7/regional_decisions.json", base)),
  json(new URL("data/v9.7/regional_manifest.json", base)),
]);
const sourceContract = JSON.parse(sourceContractText);
const sourceMeta = sourceContract.adapters.find((adapter) => adapter.enabled);
const inputBytes = await readPinnedInputV9_7(rootPath, sourceMeta);
const inputText = inputBytes.toString("utf8");
const feed = JSON.parse(inputText);
const regional = JSON.parse(regionalText);
const ledger = JSON.parse(ledgerText);
const moduleRegistryText = await text(new URL("contracts/news-module-registry.v9.7.json", base));

assert.equal(contract.release, "9.7");
assert.equal(contract.status, "CANDIDATE");
assert.equal(contract.frozen_parent.subtree, "d978c215bceaab6666e4bf17af782191d8fab49e");
assert.equal(contract.runtime.project_data_changed, false);
assert.equal(contract.runtime.project_javascript_changed, false);
assert.equal(contract.runtime.project_styles_changed, false);
assert.equal(contract.runtime.mobile_interface_changed, false);
assert.equal(contract.runtime.regional_project_signal_eligible, false);
assert.equal(packageJson.version, "9.7.0");
assert.equal(sourceContract.adapters.filter((adapter) => adapter.enabled).length, 1);
assert.equal(sourceContract.adapters[0].independent_of_repd_signals, true);
assert.equal(sourceMeta.input_commit, "91e948338115b8f523f049e8cdc5369296d9451e");
assert.equal(
  pinnedInputObjectV9_7(sourceMeta),
  "91e948338115b8f523f049e8cdc5369296d9451e:dist/major_project_news_v9_5_1.json",
);
assert.throws(
  () => pinnedInputObjectV9_7({ ...sourceMeta, input_commit: "main" }),
  /full lowercase Git commit SHA/,
);
assert.throws(
  () => pinnedInputObjectV9_7({ ...sourceMeta, input: "../major_project_news.json" }),
  /safe repository-relative path/,
);
await assert.rejects(
  readPinnedInputV9_7(rootPath, { ...sourceMeta, input_commit: "0000000000000000000000000000000000000000" }),
  /could not read pinned input/,
);
assert.equal(moduleRegistry.modules.length, 7);
assert.equal(new Set(moduleRegistry.modules.map((item) => item.role)).size, 7);
assert.equal(new Set(moduleRegistry.modules.map((item) => item.id)).size, moduleRegistry.modules.length);
assert.equal(new Set(moduleRegistry.modules.map((item) => item.path)).size, moduleRegistry.modules.length);
assert.equal(contract.regional_pipeline.modules_are_independently_extensible, true);
for (const item of moduleRegistry.modules) {
  await readFile(new URL(item.path, base), "utf8");
}

/* A release must say which release it is. 202609061004 was cut by copying
   202609051156 and its title was never changed, so the live page announced the
   wrong build and there was no way to tell from the screen which version you
   were looking at. This asserts the directory name and the banner agree. */
const releaseStamp = new URL("..", import.meta.url).pathname.replace(/\/$/, "").split("/").pop();
assert.match(html, new RegExp("UK RENEWABLES PIPELINE " + releaseStamp));
assert.match(html, new RegExp("<title>[^<]*" + releaseStamp + "</title>"));
assert.match(html, /V9\.7 CANDIDATE/);
assert.match(html, /scripts\/app-v9-7\.js\?v=9\.7/);
assert.doesNotMatch(html, /scripts\/app-v9-6-2\.js/);
assert.equal((html.match(/<th(?:\s|>)/g) || []).length, 11);
for (const mode of ["UK", "INTERNATIONAL", "US", "EUROPE"]) {
  assert.match(html, new RegExp(`data-news="${mode}"`));
}

assert.equal(feed.all_items.length, 133);
assert.equal(feed.canonical_items.length, 45);
assert.equal(regional.release, "9.7");
assert.equal(regional.articles.length, 19);
assert.equal(ledger.decisions.length, 133);
assert.equal(new Set(ledger.decisions.map((item) => item.article_id)).size, 133);
assert.deepEqual(manifest.telemetry.by_region, { US: 4, EUROPE: 9, INTERNATIONAL_OTHER: 6 });
assert.equal(manifest.telemetry.by_decision.UK_CANONICAL, 45);
assert.equal(manifest.telemetry.accepted_count, 19);
assert.equal(manifest.telemetry.last_known_good, true);
assert.deepEqual(manifest.source_adapter, sourceMeta);
assert.deepEqual(manifest.modules, moduleRegistry.modules);
assert.equal(manifest.hashes.source_contract_sha256, hash(sourceContractText));
assert.equal(manifest.hashes.module_registry_sha256, hash(moduleRegistryText));
assert.equal(manifest.hashes.input_sha256, hash(inputBytes));
assert.equal(manifest.hashes.input_sha256, "cea104c3e9cfc07971680afdf5f64073e1d4825b63bfaf4e969266df8386ebbd");
assert.equal(manifest.hashes.regional_news_sha256, hash(regionalText));
assert.equal(manifest.hashes.decision_ledger_sha256, hash(ledgerText));

const forbidden = ["project", "project_id", "repd_ref", "gg_project_id", "operator", "county", "capacity_mw", "eligible_for_news_signal"];
for (const item of regional.articles) {
  assert.equal(item.project_signal_eligible, false);
  assert.equal(item.canonical_identity, false);
  assert.ok(["US", "EUROPE", "INTERNATIONAL_OTHER"].includes(item.region));
  assert.ok(["SOLAR", "BESS", "SOLAR + BESS"].includes(item.technology));
  for (const key of forbidden) assert.equal(Object.hasOwn(item, key), false, `regional article leaked ${key}`);
}

const hostile = [
  ["Battery storage helps us cut emissions at a utility-scale project", "ABSTAIN_NO_EXPLICIT_GEOGRAPHY"],
  ["American Battery Technology announces quarterly earnings", "ABSTAIN_NO_UTILITY_CONTEXT"],
  ["Canadian Solar says patent dispute is formally terminated", "ABSTAIN_NO_UTILITY_CONTEXT"],
  ["Utility-scale battery project opens in South Korea", "ACCEPT_REGIONAL"],
  ["U.S. utility commissions a grid-scale battery project", "ACCEPT_REGIONAL"],
  ["Developer finances US$100 million battery project", "ABSTAIN_NO_EXPLICIT_GEOGRAPHY"],
];
for (const [headline, decision] of hostile) {
  assert.equal(classifyRegionalV9_7({ headline }).decision, decision, headline);
}
assert.equal(classifyRegionalV9_7({
  headline: "EDF to optimise Chinese supplier's 160MWh Kintore battery storage system",
  project: "Kintore Battery Storage",
  county: "Scotland",
}).decision, "REJECT_UK_EVIDENCE");
assert.equal(classifyRegionalV9_7({
  headline: "Beacon Fen Energy Park development consent decision announced",
  canonical_relevant: true,
}).decision, "UK_CANONICAL");

const runtime = await text(new URL("scripts/plugins/newspaper-v9-7.js", base));
const writer = await text(new URL("scripts/build/regional-news-v9-7.mjs", base));
assert.match(runtime, /data\/v9\.7\/regional_news\.json/);
assert.doesNotMatch(runtime, /classifyRegional|classifyInternational|news-regions-v9-6-2/);
assert.match(runtime, /project_signal_eligible === false/);
assert.doesNotMatch(writer, /const (?:SOLAR|BESS|UK|LOCATION_RULES|UTILITY_CONTEXT)/);
assert.match(writer, /buildRegionalArtifactsV9_7/);

console.log("V9.7 static gate: PASS (133 ledger decisions; 19 sanitized regional articles; 45 UK frozen)");