In this section
- Proof render · pipelinenews / tools/intelligence/cartridges/table-locality-sort/proof.mjs lines 410–453
- Make Cartridge ingest · pipelinenews / tools/intelligence/cartridges/transmission-is-answerable/make_cartridge.py lines 1–145
- Make Cartridge ingest · pipelinenews / tools/intelligence/cartridges/unbound-carries-nothing/make_cartridge.py lines 1–98
- Wider Fleet render · pipelinenews / tools/intelligence/cartridges/wider-fleet/assets/{GEN}-wider-fleet.mjs lines 1–243
Proof
A JavaScript module in the table locality sort folder of PipelineNews that fetches postcodes and the Renewable Energy Planning Database (REPD) register.
renderpipelinenews / tools/intelligence/cartridges/table-locality-sort/proof.mjs · lines 410–453 of 453 (continued from section 1045) · Not reached from any entry point (candidate for review) · pattern clickAndRead (shared by 2 files)
- What it does
- It fetches postcodes and the REPD register. Defines 13 functions or classes, including check, $, rowsOf, cellsOf, refOf. Uses libraries node:fs/promises, node:path, node:url, node:crypto, jsdom. Side effects: changes the web page (DOM); reads or writes files; makes network requests; starts processes; uses storage (browser storage, DuckDB or Parquet).
- Why it exists in the grid workflow
- Domain stage upstream_foresight (repository name word 'pipelinenews'): 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: postcodes, the REPD register.
- Inputs & outputs
- In: JSON file 202608270055-8ab1807551bc-v8-fast-projects.json; command-line arguments.
- What it achieves
- It runs search (`runSearch`) and is built from the check step (`check`) and the rows of helper (`rowsOf`). Table-locality-sort render proof.
- Why it matters
- No other file in the estate was found to import it.
- Application
- pipelinenews · tools/intelligence/cartridges/table-locality-sort · JavaScript module
- Uses
- node:fs/promises, node:path, node:url, node:crypto, jsdom
- Used by
- none found
- Produces
- check, $, rowsOf, cellsOf, refOf, townOf, postcodeOf, countyOf, clickAndRead, expected, settle, runSearch
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 tools/intelligence/cartridges/table-locality-sort/proof.mjs:410-453 · blob 98ded15d48c2376c0e2ce8a6ac90ca90cdde7f44 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, network, process, storage · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
`wanted ${sampleRefs.join(",")} got ${townHits.map((tr) => tr.id.replace(/^repd-/, "")).join(",")}`);
// The bar is one bar: a hit may match on name or operator rather than town.
// What must never happen is a hit that matches nothing at all.
check("every town-search hit matches the term somewhere",
townHits.every((tr) => {
const ref = tr.id.replace(/^repd-/, "");
const place = locality.locality[ref] || {};
const row = projects.rows.find((r) => refOf(r) === ref) || [];
const haystack = [place.town, place.postcode, place.authority,
row[F.name], row[F.operator],
projects.dictionaries.county[row[F.county]],
projects.dictionaries.operator[row[F.operator]]]
.filter(Boolean).join(" ").toLowerCase();
return haystack.includes(sampleTown.toLowerCase());
}), townsOfRows(townHits).slice(0, 4).join(" | "));
const samplePostcode = Object.values(locality.locality)
.find((p) => p.postcode && p.postcode.includes(" ")).postcode;
const pcHits = await runSearch(samplePostcode);
check(`postcode search finds the row ("${samplePostcode}")`, pcHits.length > 0, `${pcHits.length} rows`);
check("every postcode hit really carries that postcode",
pcHits.every((tr) =>
(locality.locality[tr.id.replace(/^repd-/, "")]?.postcode || "") === samplePostcode));
check("postcode search works without the space too",
(await runSearch(samplePostcode.replace(/\s+/g, ""))).length === pcHits.length,
samplePostcode.replace(/\s+/g, ""));
const outcode = samplePostcode.split(" ")[0];
const outHits = await runSearch(outcode);
check(`outcode search widens the answer ("${outcode}")`,
outHits.length >= pcHits.length, `${outHits.length} vs ${pcHits.length}`);
const sampleCounty = projects.dictionaries.county.find((c) => /^[A-Za-z ]{6,20}$/.test(c));
const countyHits = await runSearch(sampleCounty);
check(`county search finds rows ("${sampleCounty}")`, countyHits.length > 0, `${countyHits.length} rows`);
await runSearch("");
// ------------------------------------------------------------------ report --
console.log(`\n${passed}/${passed + failures.length} checks passed`);
if (failures.length) {
console.log("\nFAILED:");
for (const line of failures) console.log(" " + line);
process.exit(1);
}
console.log("table-locality-sort proven against " + root + "\n");Make Cartridge
A Python command-line tool in the cartridges folder of PipelineNews covering GB transmission network, cables and transformers. It is built from the read step (`read`) and the anchor step (`anchor`).
ingestpipelinenews / tools/intelligence/cartridges/transmission-is-answerable/make_cartridge.py · lines 1–145 of 145 · Entry point · pattern anchor (shared by 16 files)
- What it does
- Defines read, anchor, main. Uses libraries argparse, io, json, os.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'transmission'): 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: cables, transformers.
- Inputs & outputs
- In: JSON file gb-transmission-network.v1.json; JSON file cartridge.json; command-line arguments.
- Downstream impact
- It is itself an entry point (Python CLI); no other file was found loading it.
- What it achieves
- Generate `cartridge.json`: the strip stops ending on what cannot be answered. Its code works with 100 MVA. It accepts `--parent`.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- pipelinenews · tools/intelligence/cartridges/transmission-is-answerable · Python CLI
- Uses
- argparse, io, json, os
- Used by
- none found
- Produces
- read, anchor, main
- Defines here
- read, anchor, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 tools/intelligence/cartridges/transmission-is-answerable/make_cartridge.py:1-145 · blob 4814775e66946cd2d19466781e13ec6e9a8edcfc · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
"""Generate cartridge.json: the strip stops ending on what cannot be answered.
The GRID + SUB strip has ended, correctly, on a refusal:
not a cable route, and not headroom - fault level and thermal headroom
need DNO network data such as source impedance and a connection study
Every word of that is still true and none of it is removed. But it was the
LAST thing the reader was told, and on 1 September 2026 it stopped being the
whole story. The Atlas now reads NESO's published transmission network
(Electricity Ten Year Statement 2025, Appendix B) and can answer, for the
site a project declares:
- the circuits and transformers that actually land there, per voltage;
- their published ratings in every season the operator publishes, never
added together, because the sum of a site's circuit ratings is not a
quantity that exists in the network;
- how many published circuits away a neighbouring site is - which is a
different question from how many kilometres, and the one that decides
whether two sites are connected at all;
- and where this project's own output would flow, on a declared DC model
that states its equations, its 100 MVA base, its named slack and every
assumption it makes.
So the strip gains one clause naming what MAP now opens. The refusal keeps
its place: distance is still not a route, a rating is still not headroom,
and the DC model is still not a loading, because what is already flowing on
those circuits is published nowhere.
This cartridge changes one string in one file. It adds no payload, makes no
network call at render time, and touches no other surface.
python tools/intelligence/cartridges/transmission-is-answerable/make_cartridge.py \
--parent 202608312339-pipelinenews
"""
import argparse
import io
import json
import os
HERE = os.path.dirname(os.path.abspath(__file__))
REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(HERE))))
RELEASES = os.path.join(REPO, "releases")
APP = "assets/202608291447-app.mjs"
def read(path):
return io.open(path, encoding="utf-8", newline="").read()
def anchor(text, needle, label):
"""A repair is an exact substitution, so the anchor must be unique.
Asserting the count here rather than at build time means a parent whose
text has moved fails while the cartridge is being written, with a name
attached, instead of failing inside the builder with a diff.
"""
n = text.count(needle)
if n != 1:
raise SystemExit("anchor %r occurs %d times, expected 1" % (label, n))
return needle
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--parent", default="202608312339-pipelinenews")
args = ap.parse_args()
parent = os.path.join(RELEASES, args.parent)
if not os.path.isdir(parent):
raise SystemExit("no such release: %s" % parent)
app = read(os.path.join(parent, APP))
# The literal source bytes, including the — escape as it is written
# in the file rather than the em dash it denotes.
tail = ("not a cable route, and not headroom \\u2014 fault level and "
"thermal headroom need DNO network data such as source impedance "
"and a connection study")
anchor(app, tail, "the GRID + SUB refusal")
added = (" \\u00b7 the published transmission network is now answerable: "
"MAP opens the circuits that land at the declared site, their "
"ratings in every season the operator publishes, how many "
"circuits away its neighbours are, and where this output would "
"flow on a declared DC model")
cartridge = {
"key": "transmission_is_answerable",
"summary": (
"The GRID + SUB strip keeps every refusal and stops ending on "
"one: it names what the Atlas can now answer from NESO's "
"published transmission network."
),
"modifies_existing_dashboard": True,
"modification_note": "Extends one strip caption. No payload, no render-time network call.",
"repairs": {
"app": [
{
"label": "the strip names what MAP can now answer, without dropping a caveat",
"from": tail,
"to": tail + added,
}
]
},
"registry_entry": {
"schema": "pipelinenews.transmission-is-answerable.v1",
"generation": "{GEN}",
"usage_context": "NON_COMMERCIAL_OPEN_SOURCE",
"usage_context_establishes_upstream_rights": False,
"activation": "render-time; no payload",
"additive_only": False,
"mutates_existing_dashboard": "extends the GRID + SUB strip caption",
"network_at_runtime": False,
"rule": (
"Distance is not a route and a rating is not headroom - both "
"refusals are kept verbatim. What is added is only what is "
"actually answerable from a published source: the circuits "
"and transformers at the declared site, their seasonal "
"ratings never summed, the count of circuits to a "
"neighbouring site, and a declared DC injection response. "
"The DC model is not a loading: what is already flowing on "
"those circuits is published nowhere."
),
"found_by": (
"Reading the strip after the Atlas gained the published "
"network on 1 September 2026. The sentence was accurate and "
"had become incomplete: it told the reader what could not be "
"answered and no longer mentioned what could."
),
"upstream": (
"NESO Electricity Ten Year Statement 2025, Appendix B, via "
"Ventusltd/data-grid-gb derived/gb-transmission-network.v1.json"
),
},
}
out = os.path.join(HERE, "cartridge.json")
io.open(out, "w", encoding="utf-8", newline="\n").write(
json.dumps(cartridge, indent=2, ensure_ascii=False) + "\n")
print("wrote %s (parent %s)" % (out, args.parent))
if __name__ == "__main__":
main()Make Cartridge
A Python command-line tool in the unbound carries nothing folder of PipelineNews covering battery storage (BESS). It is built from the read step (`read`) and the anchor step (`anchor`).
ingestpipelinenews / tools/intelligence/cartridges/unbound-carries-nothing/make_cartridge.py · lines 1–98 of 98 · Entry point · pattern anchor (shared by 16 files)
- What it does
- Defines read, anchor, main. Uses libraries argparse, io, json, os, sys. Side effects: starts processes.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (repository name word 'pipelinenews'): 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: battery storage (BESS).
- Inputs & outputs
- In: JSON file cartridge.json; command-line arguments.
- Downstream impact
- It is itself an entry point (Python CLI); no other file was found loading it.
- What it achieves
- Generate `cartridge.json`: an unbound story carries no project detail at all. Its code works with 104 MWh, 49.9 MW and 99.9 MW. It accepts `--parent`.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- pipelinenews · tools/intelligence/cartridges/unbound-carries-nothing · Python CLI
- Uses
- argparse, io, json, os, sys
- Used by
- none found
- Produces
- read, anchor, main
- Defines here
- read, anchor, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 tools/intelligence/cartridges/unbound-carries-nothing/make_cartridge.py:1-98 · blob 6a90adcf7fcb7fb219efce13391447e6548de073 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: unknown · effects: process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
"""Generate cartridge.json: an unbound story carries no project detail at all.
202608312109 blanked the project NAME when a story had no repd_ref. Looking at
the live page showed that was half a fix: the same template still printed the
capacity, the operator and the county from the same unbound row, so
"APA to build 104MWh battery storage system for Evolution Mining's Ernest
Henry operations in Australia" -> 99.9 MW - EVOLUTION POWER - Kent
"US utilities Appalachian Power and 3CE launch RFPS seeking BESS capacity in
Virginia, California" -> 49.9 MW - INFINIS SOLAR - Cleveland
An Australian mine story labelled Kent is the same false statement the name fix
was meant to end, wearing different fields. Bind or say nothing: with no
repd_ref there is no project, so there is no capacity, no operator and no county
to report either.
The sector strip also still advertised the withheld topics by name, including
the two geopolitical ones. It now names only what it shows.
"""
import argparse, io, json, os, sys
HERE = os.path.dirname(os.path.abspath(__file__))
REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(HERE))))
RELEASES = os.path.join(REPO, "releases")
APP = "assets/202608291447-app.mjs"
def read(p): return io.open(p, encoding="utf-8", newline="").read()
def anchor(text, needle, label):
n = text.count(needle)
if n != 1:
raise SystemExit("anchor %r occurs %d times, expected 1" % (label, n))
return needle
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--parent", default="202608312109-pipelinenews")
a = ap.parse_args()
parent = os.path.join(RELEASES, a.parent)
idx = read(os.path.join(parent, "index.html"))
app = read(os.path.join(parent, APP))
dot = "·"
old_caption = ('<p><span class="project">${escapeHtml(projectName)}${capacity ? ` %s '
'${capacity.toLocaleString("en-GB")} MW` : ""}</span>'
'${row[NEWS_FIELD.operator] ? ` %s ${escapeHtml(row[NEWS_FIELD.operator])}` : ""}'
'${row[NEWS_FIELD.county] ? ` %s ${escapeHtml(row[NEWS_FIELD.county])}` : ""}</p>'
% (dot, dot, dot))
new_caption = ('<p>${projectName ? `<span class="project">${escapeHtml(projectName)}'
'${capacity ? ` %s ${capacity.toLocaleString("en-GB")} MW` : ""}</span>'
'${row[NEWS_FIELD.operator] ? ` %s ${escapeHtml(row[NEWS_FIELD.operator])}` : ""}'
'${row[NEWS_FIELD.county] ? ` %s ${escapeHtml(row[NEWS_FIELD.county])}` : ""}` '
': `<span class="news-unbound">sector headline %s no project binding</span>`}</p>'
% (dot, dot, dot, dot))
ra = [{"label": "an unbound story carries no capacity, operator or county either",
"from": anchor(app, old_caption, "news caption"),
"to": new_caption}]
old_strip = ("Data centres %s inverter security/policy %s Strait of Hormuz %s Ukraine "
"%s Great Grid Upgrade %s worldwide PV %s MV/HV components." % ((dot,) * 6))
ri = [{"label": "the strip names only the topic that is shown",
"from": anchor(idx, old_strip, "sector strip"),
"to": ("Data centres. Six further topics are withheld: the collector returned a "
"generic government feed rather than results on those subjects.")}]
man = {
"key": "unbound_carries_nothing",
"summary": ("An unbound story carries no project name, capacity, operator or "
"county. The sector strip names only the topic it shows."),
"modifies_existing_dashboard": True,
"modification_note": "Rewrites the newspaper caption and the sector strip text.",
"repairs": {"index.html": ri, "app": ra},
"registry_entry": {
"schema": "pipelinenews.unbound-carries-nothing.v1",
"generation": "{GEN}",
"usage_context": "NON_COMMERCIAL_OPEN_SOURCE",
"usage_context_establishes_upstream_rights": False,
"activation": "render-time; no payload",
"additive_only": False,
"mutates_existing_dashboard": "removes project detail from unbound stories",
"network_at_runtime": False,
"rule": ("With no repd_ref there is no project, so no capacity, operator or "
"county is reported. Bind or say nothing."),
"found_by": ("Looking at the rendered page. A DOM read of the caption element "
"showed the name was blank and passed; the operator and county sat "
"in sibling text and still read 'Kent' under an Australian story."),
},
}
io.open(os.path.join(HERE, "cartridge.json"), "w", encoding="utf-8", newline="").write(
json.dumps(man, ensure_ascii=False, indent=2) + "\n")
print("wrote cartridge.json:", len(ri), "index repairs,", len(ra), "app repairs")
return 0
if __name__ == "__main__":
sys.exit(main())Wider Fleet
A JavaScript module in the assets folder of PipelineNews covering the Renewable Energy Planning Database (REPD) register, solar and wind, and uses data from the GridAtlas repository.
renderpipelinenews / tools/intelligence/cartridges/wider-fleet/assets/{GEN}-wider-fleet.mjs · lines 1–243 of 243 · Not reached from any entry point (candidate for review) · pattern renderWider (shared by 4 files)
- What it does
- It draws the REPD register, solar and wind. Defines 7 functions or classes, including esc, atlasLink, num, mountWiderFleet, visible. Side effects: changes the web page (DOM); makes network requests.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (repository name word 'pipelinenews'): 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, wind.
- Inputs & outputs
- In: data source: gridatlas data.
- What it achieves
- It renders wider (`renderWider`) and is built from the esc step (`esc`) and the atlas link helper (`atlasLink`). The REPD technology types the spine does not carry, as tabs in the product's own technology row. It responds to click events.
- Why it matters
- No other file in the estate was found to import it.
- Application
- pipelinenews · tools/intelligence/cartridges/wider-fleet/assets · JavaScript module
- Uses
- GridAtlas — Atlas Page (estate URL)
- Used by
- none found
- Produces
- WIDER_FLEET_CONTRACT, mountWiderFleet
- Defines here
- esc, atlasLink, num, mountWiderFleet, visible, clearWider, renderWider
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 tools/intelligence/cartridges/wider-fleet/assets/{GEN}-wider-fleet.mjs:1-243 · blob 5f1817bad6c00dc18c353b340a8d381fc63ca2c5 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/**
* WIDER FLEET — the REPD technology types the spine does not carry, as tabs
* in the product's own technology row.
*
* The DESNZ Renewable Energy Planning Database carries 24 technology types.
* The spine admits four — Solar Photovoltaics, Battery, Wind Onshore, Wind
* Offshore — and those four are its four tabs. This adds the other twenty to
* the SAME row, as more tabs, under the REPD's own names. Vikram, on the
* first attempt, which hid them behind a button in a panel of their own:
* "I dont see the options for other tech they are not on the UI like solar,
* BEss onshroe and offshore wind". They are on the UI now.
*
* HOW THIS STAYS ADDITIVE
* -----------------------
* The spine binds its technology handler once, at boot:
*
* document.querySelectorAll("#tech .btn").forEach(...)
*
* to the buttons present at that moment. Tabs appended afterwards therefore
* carry NO spine listener, and the spine's `technology` variable is never set
* to a value its TECHNOLOGIES whitelist would reject. The four original tabs
* keep their own handler, their own payload and their own render path,
* untouched and unwrapped.
*
* When a wider tab is chosen this renders its own rows into the product's
* table. When a spine tab is chosen the spine's own apply() runs and repaints
* from its own data, so going back is the spine restoring itself rather than
* this cartridge putting anything back.
*
* It reads no spine payload, binds no project and emits no news signal.
*/
export const WIDER_FLEET_CONTRACT = Object.freeze({
schema: "pipelinenews.wider-fleet-cartridge.v2",
generation: "{GEN}",
additive_only: true,
tabs_in_product_technology_row: true,
reads_spine_payload: false,
project_bindings: 0,
eligible_for_news_signal: false,
});
/* Engine layer colours, so a technology reads the same here as on the Atlas.
Keyed by the family the REPD updater already assigns — no second table. */
const FAMILY_COLOUR = Object.freeze({
biomass: "#39ff14", hydro: "#00aaff", hydrogen: "#ffffff", tidal: "#00bfff",
act: "#ff6600", caes: "#88aaff", geothermal: "#ff3300", flywheel: "#ff69b4",
other: "#888888",
});
const ATLAS = "https://ventusltd.github.io/gridatlas/atlas/";
const PAGE = 50;
const esc = (value) => String(value == null ? "" : value)
.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ }[c]));
/* The Atlas resolves an arrival by REPD ref and nothing else
(identity_rule: EXACT_REPD_REF_ONLY). Without one it reports status ABSENT
and its place-search cartridge returns before its own flyTo, so the card
opens and the measurement runs while the camera stays on the default UK
view -- which reads as "the map cannot find it". Watched live for Rainham
Phase II on 2026-09-02. A row that genuinely has no resolved ref still
links without one: the card and the measurement work, only the camera
does not move, and that is better than sending a guessed identity. */
function atlasLink(row) {
const query = new URLSearchParams();
if (row.ref) query.set("repd_ref", row.ref);
query.set("project", row.n);
query.set("technology", row.t);
query.set("capacity_mw", String(row.c));
query.set("latitude", String(row.ll[1]));
query.set("longitude", String(row.ll[0]));
query.set("zoom", "12");
return `${ATLAS}?${query.toString()}`;
}
const num = (value) => value.toLocaleString("en-GB", { maximumFractionDigits: 2 });
export async function mountWiderFleet({ host, payloadAsset }) {
const techRow = document.getElementById("tech");
const tableBody = document.querySelector(".tablewrap tbody");
const windowControls = document.getElementById("projectWindowControls");
if (!techRow || !tableBody) throw new Error("wider fleet: product controls not found");
if (!payloadAsset?.url) throw new Error("wider fleet: no payload asset");
let payloadRequests = 0;
const response = await fetch(payloadAsset.url, { cache: "force-cache" });
payloadRequests += 1;
if (!response.ok) throw new Error(`wider fleet: payload ${response.status}`);
const rows = await response.json();
if (!Array.isArray(rows) || rows.length === 0) {
throw new Error("wider fleet: payload carries no rows");
}
/* The REPD's own type names, ordered by how much of the register each is.
Derived from the payload, never listed in source: a hand-kept technology
list is exactly what left wind_onshore in this product and absent from
the engine's layer ids. A new REPD type gets a tab with no edit here. */
const counts = new Map();
for (const row of rows) counts.set(row.rt, (counts.get(row.rt) || 0) + 1);
const types = [...counts.keys()].sort((a, b) => counts.get(b) - counts.get(a));
/* The spine's own tabs, captured before anything is appended, so "restore
the product" never depends on knowing what they are. */
const spineTabs = [...techRow.querySelectorAll(".btn")];
const appended = types.map((type) => {
const button = document.createElement("button");
button.className = "btn";
button.type = "button";
// NOT data-technology: that attribute is the spine's, and a value outside
// its whitelist reaching its filter would empty the product's own table.
button.dataset.widerTechnology = type;
button.setAttribute("aria-pressed", "false");
button.textContent = type.toUpperCase();
techRow.appendChild(button);
return button;
});
let active = null;
let page = 0;
const visible = () => (active ? rows.filter((row) => row.rt === active) : []);
function clearWider() {
for (const button of appended) {
button.classList.remove("active");
button.setAttribute("aria-pressed", "false");
}
active = null;
if (host) { host.hidden = true; host.innerHTML = ""; }
}
function renderWider() {
const shown = visible();
let megawatts = 0;
let largest = 0;
for (const row of shown) {
megawatts += row.c;
if (row.c > largest) largest = row.c;
}
/* Set the product's own gauge values in place. Rewriting .gauges innerHTML
destroyed #v1/#v2/#v3 and the chart canvases the spine holds references
to, and the numbers then stayed on the wider tab's figures after
switching back to SOLAR -- caught on a click-through before publishing.
Writing the values leaves every node the spine owns intact, so its own
updateGauges() restores them on the next spine tab without this
cartridge putting anything back. The charts stay the spine's. */
const v1 = document.getElementById("v1");
const v2 = document.getElementById("v2");
const v3 = document.getElementById("v3");
if (v1) v1.textContent = num(Number(megawatts.toFixed(2)));
if (v2) v2.textContent = num(shown.length);
if (v3) v3.textContent = num(largest);
if (host) {
host.hidden = false;
host.innerHTML = `<span>${esc(active)} · ${num(shown.length)} projects · `
+ `${(megawatts / 1000).toFixed(2)} GW · a REPD technology type outside this `
+ `product's four. Capacity and status are the register's own fields. County, town, `
+ `postcode, REPD ref and the GlobalGrid reference are spine joins: this tab does not `
+ `read the spine, so they are withheld rather than guessed.</span>`;
}
const last = Math.max(0, Math.ceil(shown.length / PAGE) - 1);
if (page > last) page = last;
tableBody.innerHTML = shown.slice(page * PAGE, page * PAGE + PAGE).map((row) => `<tr>
<td class="site">${esc(row.n)}<div class="project-meta">${esc(row.rt)}</div><div class="mobile-extra">${esc(row.o || "")}</div></td>
<td class="hide-mobile">${esc(row.cty || "—")}</td>
<td class="hide-mobile town-cell">—</td>
<td class="hide-mobile reference-cell">${esc(row.pc || "—")}</td>
<td class="hide-mobile">${esc(row.o || "—")}</td>
<td><span class="badge" style="background:${FAMILY_COLOUR[row.t] || "#888"};color:#04080a">${esc(row.rt)}</span></td>
<td>${esc(row.s)}</td>
<td class="mw">${num(row.c)} MW</td>
<td class="hide-mobile reference-cell repd-ref">${esc(row.ref || "—")}</td>
<td class="hide-mobile reference-cell globalgrid-ref">${row.ref ? "GG2050-REPD-" + esc(row.ref) : "—"}</td>
<td class="hide-mobile reference-cell repd-updated">—</td>
<td><span class="signal none">—</span><div class="signal-note">no news binding on this tab</div></td>
<td><div class="project-actions"><a class="action-link" target="_blank" rel="noopener" href="${atlasLink(row)}">MAP ↗</a></div></td>
</tr>`).join("");
if (windowControls) {
const range = windowControls.querySelector("[data-window-range]");
const previous = windowControls.querySelector('[data-window="previous"]');
const next = windowControls.querySelector('[data-window="next"]');
if (range) {
range.textContent = shown.length
? `${page * PAGE + 1}–${Math.min(shown.length, page * PAGE + PAGE)} of ${num(shown.length)}`
: "0 of 0";
}
if (previous) previous.disabled = page <= 0;
if (next) next.disabled = page >= last;
}
}
for (const button of appended) {
button.addEventListener("click", () => {
// Drop the spine's active mark. Its own state is untouched: the next
// click on one of its tabs runs its handler and repaints from its data.
for (const tab of spineTabs) {
tab.classList.remove("active");
tab.setAttribute("aria-pressed", "false");
}
for (const other of appended) {
other.classList.remove("active");
other.setAttribute("aria-pressed", "false");
}
button.classList.add("active");
button.setAttribute("aria-pressed", "true");
active = button.dataset.widerTechnology;
page = 0;
renderWider();
});
}
/* A second listener on the spine's own tabs. It only lets go: the spine's
original handler still runs and repaints the product from the product's
own data, which is what restores it. */
for (const tab of spineTabs) {
tab.addEventListener("click", () => { clearWider(); page = 0; });
}
if (windowControls) {
windowControls.addEventListener("click", (event) => {
if (!active) return; // the spine owns its own paging
const button = event.target.closest("button");
if (!button || !button.dataset.window) return;
page += button.dataset.window === "next" ? 1 : -1;
renderWider();
}, true);
}
return {
payloadRequests,
projectBindings: 0,
tabsAdded: appended.length,
types: types.length,
projects: rows.length,
gigawatts: Number((rows.reduce((total, row) => total + row.c, 0) / 1000).toFixed(2)),
};
}