In this section
- Cockpit Facets Test test · globalgrid2050 / automation/repd_reporting/v2/tests/cockpit-facets.test.mjs lines 1–108
- Cockpit Skin Test test · globalgrid2050 / automation/repd_reporting/v2/tests/cockpit-skin.test.mjs lines 1–68
- V974 Cockpit Browser test · globalgrid2050 / automation/repd_reporting/v2/tests/v974-cockpit-browser.mjs lines 1–122
- Browser V975 render · globalgrid2050 / automation/repd_reporting/v3/browser_v975.mjs lines 1–81
- Build V975 interaction · globalgrid2050 / automation/repd_reporting/v3/build_v975.py lines 1–253
- Operator Aliases transform · globalgrid2050 / automation/repd_reporting/v3/operator-aliases.mjs lines 1–14
- Operator Aliases Test test · globalgrid2050 / automation/repd_reporting/v3/operator-aliases.test.mjs lines 1–27
Cockpit Facets Test
A test in the tests folder of GlobalGrid2050 that checks Cockpit Facets.
testglobalgrid2050 / automation/repd_reporting/v2/tests/cockpit-facets.test.mjs · lines 1–108 of 108 · Entry point
- What it does
- It tests solar, interconnectors, the REPD register and battery storage (BESS). Defines p, opts. Uses libraries node:test, node:assert/strict.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'repd'): 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, interconnectors, the REPD register, battery storage (BESS).
- Downstream impact
- Used directly by 2 files: GlobalGrid2050 Pn V974 Cockpit Integration Workflow (globalgrid2050); GlobalGrid2050 Renewable Energy Planning Database (REPD) Cockpit V2 Workflow (globalgrid2050).
- What it achieves
- Defines `opts`.
- Why it matters
- Run by GlobalGrid2050 Pn V974 Cockpit Integration Workflow and GlobalGrid2050 Renewable Energy Planning Database (REPD) Cockpit V2 Workflow.
- Application
- globalgrid2050 · automation/repd_reporting/v2/tests · test
- Uses
- Cockpit Facets (import), node:test, node:assert/strict
- Used by
- run by GlobalGrid2050 Pn V974 Cockpit Integration Workflow (workflow run), run by GlobalGrid2050 Renewable Energy Planning Database (REPD) Cockpit V2 Workflow (workflow run)
- Produces
- p, opts
- Defines here
- p, opts
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 automation/repd_reporting/v2/tests/cockpit-facets.test.mjs:1-108 · blob d47bde92d4b050d3ab6fa088077df9bb89ed033c · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
import test from "node:test";
import assert from "node:assert/strict";
import {
buildCockpitReport, cockpitSelection, verifyInventory,
SOURCE_UNAVAILABLE
} from "../cockpit-facets.mjs";
const p = (repd_ref, technology, status, operator, region, capacity_mw, capacity_unit) =>
({ repd_ref: String(repd_ref), technology, status, operator, region, capacity_mw, capacity_unit });
const rows = [
p(1, "solar", "Operational", "A Solar", "South East", 30, "MWp"),
p(2, "solar", "Application Refused", "A Solar", "Wales", 20, "MWp"),
p(3, "solar", "Application Submitted", "B Solar", "Wales", 5, "MWp"),
p(4, "bess", "Operational", "B Storage", "Wales", 60, "MW"),
p(5, "bess", "Withdrawn", "A Solar", "South East", 15, "MW"),
p(6, "wind_onshore", "Operational", "Wind Co", "Scotland", 85, "MW"),
p(7, "wind_offshore", "Under Construction", "Wind Co", "Offshore", 250, "MW"),
p(8, "solar", "", "", "", null, "MWp"),
];
const opts = (dimension, filters = {}) => buildCockpitReport(rows, { dimension, filters });
test("all REPD records remain present by default; statuses never silently excluded", () => {
const report = opts("status");
assert.equal(report.sourceProjects, 8);
assert.equal(report.matchingProjects, 8);
assert.deepEqual(report.groups.map(g => g.label).sort(), [
"Application Refused", "Application Submitted", "Not reported",
"Operational", "Under Construction", "Withdrawn"
].sort());
assert.equal(report.totals.missingCapacity, 1);
assert.equal(report.groups.reduce((n, g) => n + g.projects, 0), 8);
});
test("solar cockpit filters operators; changing status further intersects without reset", () => {
const solar = opts("operator", { technology: "solar" });
assert.equal(solar.matchingProjects, 4);
assert.deepEqual(solar.groups.map(g => g.label).sort(), ["A Solar", "B Solar", "Not reported"].sort());
assert.equal(solar.totals.solarMwp, 55);
assert.equal(solar.totals.otherMw, 0);
const refused = opts("operator", { technology: "solar", status: "Application Refused" });
assert.deepEqual(refused.ids, ["2"]);
assert.equal(refused.groups[0].label, "A Solar");
const byRegion = opts("region", refused.selection);
assert.deepEqual(byRegion.ids, ["2"]);
assert.equal(byRegion.groups[0].label, "Wales");
});
test("BESS, onshore and offshore never mix, and official refused/withdrawn status survives", () => {
assert.deepEqual(opts("status", { technology: "bess" }).groups.map(g => g.label).sort(),
["Operational", "Withdrawn"]);
assert.equal(opts("operator", { technology: "wind_onshore" }).totals.otherMw, 85);
assert.equal(opts("operator", { technology: "wind_offshore" }).totals.otherMw, 250);
assert.equal(opts("operator", { technology: "wind_offshore" }).totals.solarMwp, 0);
});
test("all three main report dimensions reconcile to same precise selected denominator", () => {
const filters = { technology: "bess", status: "Withdrawn" };
for (const dimension of ["operator", "status", "region", "technology"]) {
const report = opts(dimension, filters);
assert.equal(report.matchingProjects, 1);
assert.equal(report.totals.recordedMixed, 15);
assert.deepEqual(report.ids, ["5"]);
assert.deepEqual(report.groups[0].ids, ["5"]);
}
});
test("facet choices remain independently discoverable while retaining applied filters", () => {
const report = opts("operator", { technology: "solar", status: "Operational" });
assert.equal(report.matchingProjects, 1);
assert.ok(report.facets.status.some(x => x.value === "Application Refused"));
assert.ok(report.facets.operator.some(x => x.value === "A Solar"));
assert.deepEqual(report.selection, {
technology: "solar", status: "Operational", operator: "All", region: "All"
});
});
test("interconnectors are separately sourced, never treated as REPD or returned as fake zero", () => {
const unavailable = opts("operator", { technology: "interconnector" });
assert.equal(unavailable.availability, SOURCE_UNAVAILABLE);
assert.equal(unavailable.sourceProjects, null);
const interconnectors = [
{ asset_id: "IC-A", technology: "interconnector", status: "Operational",
operator: "Cable Co", region: "East", capacity_mw: 750, capacity_unit: "MW" }
];
const report = buildCockpitReport(rows, {
dimension: "operator", filters: { technology: "interconnector" }, interconnectors
});
assert.equal(report.sourceProjects, 1);
assert.equal(report.matchingProjects, 1);
assert.deepEqual(report.ids, ["IC-A"]);
assert.equal(report.totals.recordedByUnit.MW, 750);
assert.equal(report.source, "interconnector");
});
test("grid is a reserved distinct inventory until its source contract is verified", () => {
const report = opts("operator", { technology: "grid" });
assert.equal(report.availability, SOURCE_UNAVAILABLE);
assert.equal(report.matchingProjects, null);
});
test("missing/duplicate REPD identity and accidental interconnector contamination fail closed", () => {
assert.throws(() => verifyInventory([rows[0], { ...rows[0] }]), /Duplicate repd identity/);
assert.throws(() => verifyInventory([p("", "solar", "Operational", "X", "Y", 1)]), /Missing or invalid/);
assert.throws(() => verifyInventory([p(90, "interconnector", "Operational", "X", "Y", 1)]), /inside REPD/);
});
test("same underlying REPD rows; no mutation or invented capacity for missing inputs", () => {
const original = JSON.stringify(rows);
const report = opts("technology");
assert.equal(JSON.stringify(rows), original);
assert.equal(report.totals.recordedByUnit.MWp, 55);
assert.equal(report.totals.recordedByUnit.MW, 410);
assert.equal(report.totals.recordedMixed, 465);
assert.match(report.totals.mixedUnitWarning, /not a physically comparable capacity/);
assert.equal(cockpitSelection({ technology: "solar", status: "Withdrawn" }).status, "Withdrawn");
});Cockpit Skin Test
A test in the tests folder of GlobalGrid2050 that checks Cockpit Skin.
testglobalgrid2050 / automation/repd_reporting/v2/tests/cockpit-skin.test.mjs · lines 1–68 of 68 · Entry point · pattern fixture (shared by 30 files)
- What it does
- It tests solar, battery storage (BESS) and the REPD register. Defines fixture. Uses libraries node:test, node:assert/strict. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'repd'): 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), the REPD register.
- Downstream impact
- Used directly by 2 files: GlobalGrid2050 Pn V974 Cockpit Integration Workflow (globalgrid2050); GlobalGrid2050 Renewable Energy Planning Database (REPD) Cockpit V2 Workflow (globalgrid2050).
- What it achieves
- Defines `fixture`.
- Why it matters
- Run by GlobalGrid2050 Pn V974 Cockpit Integration Workflow and GlobalGrid2050 Renewable Energy Planning Database (REPD) Cockpit V2 Workflow.
- Application
- globalgrid2050 · automation/repd_reporting/v2/tests · test
- Uses
- Cockpit Skin (import), node:test, node:assert/strict
- Used by
- run by GlobalGrid2050 Pn V974 Cockpit Integration Workflow (workflow run), run by GlobalGrid2050 Renewable Energy Planning Database (REPD) Cockpit V2 Workflow (workflow run)
- Produces
- fixture
- Defines here
- fixture
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 automation/repd_reporting/v2/tests/cockpit-skin.test.mjs:1-68 · blob 8b0c7797da8a12795aa0c30ca77f29c1e81f5e39 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
import test from "node:test";
import assert from "node:assert/strict";
import {
REPD_ROOT_TOKENS, REPD_V973_REFERENCE, REPD_TECH_BADGE_TOKENS,
readRepdSkin, verifyRepdSkin, applyRepdCockpitSkin
} from "../cockpit-skin.mjs";
function fixture(tokens = REPD_V973_REFERENCE) {
const documentRef = {
documentElement: { tag: "html" },
getElementById: (id) => id === "repdPanel" ? { id } : null,
};
const windowRef = {
getComputedStyle(node) {
assert.equal(node, documentRef.documentElement);
return { getPropertyValue: name => tokens[name] || "" };
},
};
const touched = new Map();
const host = { style: { setProperty: (key, value) => touched.set(key, value) } };
return { documentRef, windowRef, host, touched };
}
test("palette is exactly the source V9.73 REPD root scheme (no alternative colours)", () => {
const env = fixture();
assert.deepEqual(readRepdSkin(env.documentRef, env.windowRef), REPD_V973_REFERENCE);
const receipt = applyRepdCockpitSkin(env.host, env);
assert.equal(receipt.matchesV973, true);
assert.deepEqual(receipt.differences, []);
assert.equal(env.touched.get("--pn-cockpit-solar"), "#ffff00");
assert.equal(env.touched.get("--pn-cockpit-bess"), "#ffae00");
assert.equal(env.touched.get("--pn-cockpit-onshore"), "#00ffff");
assert.equal(env.touched.get("--pn-cockpit-offshore"), "#0066ff");
assert.equal(env.touched.get("--pn-cockpit-mw"), "#00ff88");
assert.equal(env.touched.get("--pn-cockpit-bg"), "#000");
assert.equal(env.touched.size, REPD_ROOT_TOKENS.length + 1);
assert.deepEqual(REPD_TECH_BADGE_TOKENS, {
solar: "--solar", bess: "--bess", wind_onshore: "--accent",
wind_offshore: "--off", interconnector: "--off",
});
});
test("source palette drift is observed, never silently replaced", () => {
const altered = { ...REPD_V973_REFERENCE, "--solar": "#123456" };
const env = fixture(altered);
const receipt = applyRepdCockpitSkin(env.host, env);
assert.equal(receipt.matchesV973, false);
assert.deepEqual(receipt.differences, [
{ name: "--solar", expected: "#ffff00", actual: "#123456" },
]);
// Observe new source values, but integration must explicitly review drift.
assert.equal(env.touched.get("--pn-cockpit-solar"), "#123456");
});
test("fail closed without canonical REPD source, instead of drawing invented colours", () => {
const env = fixture();
env.documentRef.getElementById = () => null;
assert.throws(() => readRepdSkin(env.documentRef, env.windowRef), /source panel is missing/);
assert.throws(() => applyRepdCockpitSkin(null, env), /host element/);
});
test("missing required theme tokens cannot be silently guessed", () => {
const env = fixture({ ...REPD_V973_REFERENCE, "--bess": "" });
assert.throws(() => readRepdSkin(env.documentRef, env.windowRef), /Missing official REPD skin token --bess/);
assert.equal(verifyRepdSkin({ ...REPD_V973_REFERENCE, "--bess": "" }).matchesV973, false);
});
test("new CSS uses only scoped custom properties and never restyles existing table", () => {
// The Spider audit additionally checks the exact full CSS file for forbidden
// global style selectors; this checks semantic token coverage.
assert.ok(REPD_ROOT_TOKENS.includes("--accent"));
assert.ok(REPD_ROOT_TOKENS.includes("--ok"));
});V974 Cockpit Browser
A JavaScript module in the tests folder of GlobalGrid2050 that tests the Renewable Energy Planning Database (REPD) register, solar and battery storage (BESS), and uses data from the GridAtlas repository.
testglobalgrid2050 / automation/repd_reporting/v2/tests/v974-cockpit-browser.mjs · lines 1–122 of 122 · Entry point
- What it does
- It tests the REPD register, solar and battery storage (BESS). Uses libraries node:assert/strict, playwright. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'repd'): 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).
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 Pn V974 Cockpit Integration Workflow (globalgrid2050).
- What it achieves
- Real 7,775-record edition, not a fixture HTML model.
- Why it matters
- Run by GlobalGrid2050 Pn V974 Cockpit Integration Workflow.
- Application
- globalgrid2050 · automation/repd_reporting/v2/tests · JavaScript module
- Uses
- GridAtlas — Atlas Page (estate URL), node:assert/strict, playwright
- Used by
- run by GlobalGrid2050 Pn V974 Cockpit Integration Workflow (workflow run)
- Produces
- none declared
- 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
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 automation/repd_reporting/v2/tests/v974-cockpit-browser.mjs:1-122 · blob baf0d965680087703fde6645324acff04b79a59e · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
import assert from "node:assert/strict";
import { chromium, webkit } from "playwright";
// Real 7,775-record edition, not a fixture HTML model. Run from repo root
// after the immutable composer and python3 -m http.server 8765.
const origin = "http://127.0.0.1:8765/uk_renewables_pipeline/202611231400/";
const viewports = [
{width:393,height:852, mobile:true},
{width:852,height:393, mobile:true},
{width:1280,height:800, mobile:false}
];
for (const [engineName, engine] of [["chromium",chromium],["webkit",webkit]]) {
const browser = await engine.launch({headless:true});
try {
for (const vp of viewports) {
const context = await browser.newContext({
viewport:{width:vp.width,height:vp.height},
isMobile:vp.mobile, hasTouch:vp.mobile,reducedMotion:"reduce"
});
const page = await context.newPage();
const errors = [];
page.on("pageerror", e=>errors.push(e.message));
page.on("console", m=>{if(m.type()==="error" && /cockpit|repd-reports/i.test(m.text()))errors.push(m.text());});
await page.route("https://raw.githubusercontent.com/**", route=>route.abort());
try {
await page.goto(origin,{waitUntil:"domcontentloaded",timeout:90000});
await page.waitForFunction(() =>
document.querySelectorAll("#tbody tr[id^=repd-]").length >= 50 &&
document.querySelector('[data-technology="solar"][aria-pressed="true"]'),
{timeout:90000});
const baseline = await page.evaluate(()=>({
theme:Object.fromEntries(["--solar","--bess","--ok","--accent","--off"]
.map(k=>[k,getComputedStyle(document.documentElement).getPropertyValue(k).trim()])),
charts:[...document.querySelectorAll("#repdPanel .hud-gauges canvas")].length,
news:!!document.querySelector("#headlineTicker"),
nativeMap:document.querySelector("#tbody .atlaslink[href]")?.getAttribute("href"),
}));
assert.deepEqual(baseline.theme,{
"--solar":"#ffff00","--bess":"#ffae00","--ok":"#00ff88",
"--accent":"#00ffff","--off":"#0066ff"
});
assert.equal(baseline.charts,3);
assert.equal(baseline.news,true);
// The ONLY existing OPERATOR MW button is reused.
assert.equal(await page.locator('[data-repd-report="operator"]').count(),1);
await page.locator('[data-repd-report="operator"]').click();
await page.locator("#repdReportsPanel").waitFor({state:"visible"});
await page.waitForFunction(() =>
/SOLAR/.test(document.querySelector("#repdReportsSummary")?.textContent||"") &&
Number((document.querySelector("#repdReportsSummary")?.textContent||"").match(/SELECTED ([0-9,]+)/)?.[1].replaceAll(",",""))>0);
const solarSummary=await page.locator("#repdReportsSummary").textContent();
assert.match(solarSummary,/SOLAR/);
const solarMatches=Number(solarSummary.match(/SELECTED ([0-9,]+)/)[1].replaceAll(",",""));
assert.ok(solarMatches<7775 && solarMatches>100);
assert.equal(await page.locator("#repdReportsBody .repd-report-group").count()>2,true);
const first=page.locator("#repdReportsBody .repd-report-group").first();
assert.match(await first.locator(".repd-report-name").textContent(),/^#1 /);
await first.locator("summary").click();
await first.locator(".repd-report-project").first().waitFor({state:"visible"});
const link=await first.locator(".repd-report-project a").first().getAttribute("href");
assert.equal(new URL(link).searchParams.get("technology"),"solar");
assert.ok(new URL(link).searchParams.get("q"));
const map=first.locator(".repd-report-map").first();
if(await map.count()){
const mapLink=new URL(await map.getAttribute("href"));
assert.equal(mapLink.origin+mapLink.pathname,"https://ventusltd.github.io/gridatlas/atlas/");
assert.ok(mapLink.searchParams.get("repd_ref"));
}
await page.locator("#repdFacetStatus").selectOption("Operational");
await page.waitForFunction(()=>document.querySelector("#repdReportsSummary")?.textContent?.includes("Operational"));
const selectedOperator=await page.locator("#repdFacetOperator option").evaluateAll(
opts=>opts.find(x=>x.value!=="All")?.value);
assert.ok(selectedOperator);
await page.locator("#repdFacetOperator").selectOption(selectedOperator);
const selectedRegion=await page.locator("#repdFacetRegion option").evaluateAll(
opts=>opts.find(x=>x.value!=="All")?.value);
if(selectedRegion)await page.locator("#repdFacetRegion").selectOption(selectedRegion);
for(const view of ["status","region","operator"]){
await page.locator('[data-repd-report="'+view+'"]').click();
assert.equal(await page.locator("#repdFacetOperator").inputValue(),selectedOperator);
assert.equal(await page.locator("#repdFacetStatus").inputValue(),"Operational");
if(selectedRegion)assert.equal(await page.locator("#repdFacetRegion").inputValue(),selectedRegion);
assert.match(await page.locator("#repdReportsSummary").textContent(),/SOLAR/);
}
// Restore ALL report facets, then inspect top-level BESS tab and wind buttons.
await page.locator("#repdFacetOperator").selectOption("All");
await page.locator("#repdFacetRegion").selectOption("All");
await page.locator("#repdFacetStatus").selectOption("FOLLOW");
await page.locator("#bessTab").click();
await page.waitForFunction(() => document.querySelector('#tech [data-technology="bess"]')?.getAttribute("aria-pressed")==="true"
&& /BESS/.test(document.querySelector("#repdReportsSummary")?.textContent||""));
assert.match(await page.locator("#repdReportsSummary").textContent(),/BESS/);
assert.ok(await page.locator("#repdReportsBody .repd-report-group").count()>1);
const details=page.locator("details.compact-register-filters");
await details.locator("summary").click();
for (const category of ["wind_onshore","wind_offshore","solar"]) {
await page.locator('#tech [data-technology="'+category+'"]').click();
await page.waitForFunction(cat => {
const selected=document.querySelector("#tech [data-technology][aria-pressed=true]");
return selected?.dataset.technology===cat;
},category);
assert.match((await page.locator("#repdReportsSummary").textContent()).toUpperCase(),
new RegExp(category.replace("_"," ").toUpperCase()));
}
// Facet must not rewrite the source palette nor the original MAP or A4.
const after=await page.evaluate(()=>({
theme:Object.fromEntries(["--solar","--bess","--ok","--accent","--off"]
.map(k=>[k,getComputedStyle(document.documentElement).getPropertyValue(k).trim()])),
charts:[...document.querySelectorAll("#repdPanel .hud-gauges canvas")].length,
news:!!document.querySelector("#headlineTicker"),
a4:!!document.querySelector('script[src="report-a4.mjs"]')
}));
assert.deepEqual(after.theme,baseline.theme);
assert.equal(after.charts,3);
assert.ok(after.news && after.a4);
assert.deepEqual(errors,[]);
console.log("PASS V9.74",engineName,vp.width+"x"+vp.height,
"solar operator ranking, status/operator/region facets, BESS, both winds, MAP, A4 and palette");
} finally {await context.close();}
}
} finally {await browser.close();}
}Browser V975
A JavaScript module in the REPD reporting folder of GlobalGrid2050 that reads inputs for Renewable Energy Planning Database (REPD) native region, covering the REPD register and battery storage (BESS).
renderglobalgrid2050 / automation/repd_reporting/v3/browser_v975.mjs · lines 1–81 of 81 · Not reached from any entry point (candidate for review)
- What it does
- Uses libraries node:assert/strict, playwright. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'repd'): 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, battery storage (BESS).
- What it achieves
- No statement of purpose was found in the file, a README line naming it, or its name.
- Why it matters
- No other file in the estate was found to import it.
- Application
- globalgrid2050 · automation/repd_reporting/v3 · JavaScript module
- Uses
- node:assert/strict, playwright
- Used by
- none found
- Produces
- none declared
- 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
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 automation/repd_reporting/v3/browser_v975.mjs:1-81 · blob 27e309ea441f8beb673eb89e4ca0946967ef1328 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
import assert from "node:assert/strict";
import {chromium,webkit} from "playwright";
const root="http://127.0.0.1:8765/uk_renewables_pipeline/202611231600/";
const viewports=[{width:393,height:852},{width:852,height:393},{width:1280,height:800}];
for(const [engineName,engine] of [["chromium",chromium],["webkit",webkit]]) {
const browser=await engine.launch({headless:true});
try {
for(const viewport of viewports) {
const page=await browser.newPage({viewport});
const errors=[];
page.on("pageerror",err=>errors.push(String(err)));
page.on("response",r=>{if(r.status()>=400 && /repd-reports|operator-aliases|projects-v9-8/.test(r.url()))errors.push("HTTP "+r.status()+" "+r.url());});
try {
await page.goto(root,{waitUntil:"domcontentloaded",timeout:60000});
await page.waitForFunction(()=>{
const v=Number((document.getElementById("v2")?.textContent||"0").replaceAll(",",""));
return v===3604;
},null,{timeout:60000});
assert.equal(await page.locator("#status").count(),1);
assert.equal(await page.locator("#repdNativeStatus").count(),1);
assert.equal(await page.locator("#repdNativeOperator").count(),1);
assert.equal(await page.locator("#repdNativeRegion").count(),1);
assert.ok(await page.locator("#repdNativeStatus option").count()>5);
assert.ok(await page.locator("#repdNativeOperator option").count()>20);
assert.equal(await page.locator("#repdReportScope").count(),0);
assert.equal(await page.getByText(/COCKPIT/i).count(),0);
assert.equal(await page.locator('[data-repd-report="operator"]').count(),1);
await page.locator('[data-repd-report="operator"]').click();
await page.locator("#repdReportsPanel").waitFor({state:"visible"});
await page.locator("#repdReportsBody table").waitFor({state:"visible"});
assert.ok(await page.locator("#repdReportsBody tbody tr").count()>10);
const first=await page.evaluate(()=>({
report:getComputedStyle(document.querySelector("#repdReportsBody th")).color,
original:getComputedStyle(document.querySelector("#repdScroll th")).color
}));
assert.equal(first.report,first.original,"Native REPD header colour");
let summary=await page.locator("#repdReportsSummary").textContent();
assert.match(summary,/SELECTED 3,604/);
await page.locator("#repdNativeStatus").selectOption("Operational");
await page.waitForFunction(()=>{
const v=Number((document.getElementById("v2")?.textContent||"0").replaceAll(",",""));
const r=document.querySelector("#repdReportsSummary")?.textContent||"";
const t=Number(document.querySelector("#tbody")?.dataset.total||0);
return v>0&&v<3604&&t===v&&r.includes("SELECTED "+v.toLocaleString("en-GB"));
},null,{timeout:15000});
assert.equal(await page.locator("#repdNativeStatus").inputValue(),"Operational");
await page.locator("#repdNativeStatus").selectOption("All");
assert.ok((await page.locator("#repdNativeOperator option").allTextContents()).includes("Low Carbon"));
await page.locator("#repdNativeOperator").selectOption("Low Carbon");
await page.waitForFunction(()=>{
const n=Number((document.getElementById("v2")?.textContent||"0").replaceAll(",",""));
return n>0&&n<3604&&Number(document.querySelector("#tbody")?.dataset.total||0)===n;
},null,{timeout:15000});
const aliasRows=await page.locator("#tbody tr").count();
assert.ok(aliasRows>0,"Alias selection returns original REPD project rows");
await page.locator("#repdNativeOperator").selectOption("All");
await page.locator('[data-repd-report="region"]').click();
assert.equal(await page.locator("#repdReportsBody th").count(),5);
const region=await page.locator("#repdNativeRegion option").nth(1).getAttribute("value");
if(region) {
await page.locator("#repdNativeRegion").selectOption(region);
await page.waitForFunction(()=>document.querySelector("#repdNativeRegion").value!=="All");
const n=Number((await page.locator("#v2").textContent()).replaceAll(",",""));
assert.equal(Number(await page.locator("#tbody").getAttribute("data-total")),n);
}
await page.locator("#repdNativeRegion").selectOption("All");
await page.locator('details.compact-register-filters > summary').click();
await page.locator('#tech [data-technology="bess"]').click();
await page.waitForFunction(()=>document.querySelector('#tech [data-technology="bess"]')?.getAttribute("aria-pressed")==="true");
const bessCount=Number((await page.locator("#v2").textContent()).replaceAll(",",""));
assert.ok(bessCount>0&&bessCount!==3604);
assert.match((await page.locator("#repdReportsSummary").textContent()).toUpperCase(),/BESS/);
assert.ok(await page.locator('script[src="report-a4.mjs"]').count()===1);
assert.ok(await page.locator('script[src="map-entry.mjs"]').count()===1);
assert.equal(errors.length,0,errors.join("\n"));
console.log("PASS",engineName,viewport.width+"x"+viewport.height,
"V9.75 3604 solar, unified status/operator/region, original table colours, BESS, MAP/A4");
} finally {await page.close();}
}
} finally {await browser.close();}
}Build V975
A Python command-line tool in the REPD reporting folder of GlobalGrid2050 that reads the Renewable Energy Planning Database (REPD) register, interconnectors and solar.
interactionglobalgrid2050 / automation/repd_reporting/v3/build_v975.py · lines 1–253 of 253 · Entry point · pattern replace (shared by 7 files)
- What it does
- It loads the REPD register, interconnectors and solar. Defines 9 functions or classes, including replace, between, patch, html_patch, project_patch. Uses libraries pathlib, re. Side effects: changes the web page (DOM); reads or writes files.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'repd'): 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, solar.
- Inputs & outputs
- In: form fields (user input).
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 Renewable Energy Planning Database (REPD) Native V975 Workflow (globalgrid2050).
- What it achieves
- It scans patch (`scan_patch`) and is built from the replace step (`replace`) and the between step (`between`). Build PipelineNews V9.75 from V9.74 without touching historical `release/data/colours`.
- Why it matters
- Run by GlobalGrid2050 Renewable Energy Planning Database (REPD) Native V975 Workflow.
- Application
- globalgrid2050 · automation/repd_reporting/v3 · Python CLI
- Uses
- pathlib, re
- Used by
- run by GlobalGrid2050 Renewable Energy Planning Database (REPD) Native V975 Workflow (workflow run)
- Produces
- replace, between, patch, html_patch, project_patch, scan_patch, model_patch, report_patch, main
- Defines here
- replace, between, patch, html_patch, project_patch, scan_patch, model_patch, report_patch, 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 automation/repd_reporting/v3/build_v975.py:1-253 · blob 80db4976e994416f6cc605fe097fdd2460d6c42e · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
"""Build PipelineNews V9.75 from V9.74 without touching historical release/data/colours.
Pure stdlib deterministic, fail-closed Python patcher. Repeated CI build is idempotent.
The matching full Git tree is staged by the GitHub Git Tree API, not a partial copy.
"""
from pathlib import Path
import re
ROOT=Path(__file__).resolve().parents[3]
OLD=ROOT/"uk_renewables_pipeline/202611231400"
NEW=ROOT/"uk_renewables_pipeline/202611231600"
def replace(text, before, after, label, expected=1):
count=text.count(before)
if count != expected:
raise AssertionError(f"{label}: expected {expected} anchors, found {count}")
return text.replace(before, after, 1)
def between(text, beginning, ending, replacement, label):
assert text.count(beginning)==1, f"{label}: beginning"
i=text.index(beginning); j=text.find(ending,i+len(beginning))
assert j>=0, f"{label}: ending"
return text[:i]+replacement+text[j:]
def patch(path, f):
target=NEW/path
old=target.read_text()
new=f(old)
assert len(new)>200 and new!=old, f"{path}: no change or truncation"
target.write_text(new)
print("PATCH",path,len(old),"->",len(new))
def html_patch(s):
s=replace(s,"Pipeline News V9.74 · 202611231400","Pipeline News V9.75 · 202611231600","version")
status='''<div class="filters" id="status">
<button class="btn active" data-official-status="All" aria-pressed="true">ALL STATUS</button>
<button class="btn" data-official-status="Operational" aria-pressed="false">OPERATIONAL</button>
<button class="btn" data-official-status="Under Construction" aria-pressed="false">CONSTRUCTING</button>
<button class="btn" data-official-status="Awaiting Construction" aria-pressed="false">AWAITING</button>
<button class="btn" data-official-status="Application Submitted" aria-pressed="false">SUBMITTED</button>
</div>'''
s=replace(s,status,"","move native status above reports")
filters='''<div class="filters" id="repdNativeFilters" aria-label="REPD source table filters">
<label for="repdNativeStatus">STATUS <select id="repdNativeStatus" aria-label="Filter official REPD status"><option value="All">ALL OFFICIAL STATUSES</option></select></label>
<label for="repdNativeOperator">OPERATOR <select id="repdNativeOperator" aria-label="Filter original REPD table by operator"><option value="All">ALL OPERATORS</option></select></label>
<label for="repdNativeRegion">REGION <select id="repdNativeRegion" aria-label="Filter original REPD table by region"><option value="All">ALL REGIONS</option></select></label>
</div>
'''+status+"\n"
s=replace(s,'<div class="repd-report-launch" role="group" aria-label="REPD capacity reports">',filters+'<div class="repd-report-launch" role="group" aria-label="REPD capacity reports">',"native filters at top")
s=replace(s,'''<label for="repdReportScope">REPORT DATA <select id="repdReportScope" aria-label="Report project scope">
<option value="all">ALL OFFICIAL REPD STATUSES</option>
<option value="filtered">CURRENT TABLE FILTERS</option>
</select></label>''','<span class="repd-report-context">CURRENT REPD TABLE FILTERS</span>',"remove report-specific scope")
s=replace(s,"Operator entities are not inferred.","Conservative operator spelling variants are grouped for reporting only; source labels remain unchanged.","alias integrity")
s=replace(s,'<label class="pn-scan-status" for="pnScanStatus">Status','<label class="pn-scan-status" for="pnScanStatus" hidden style="display:none" aria-hidden="true">Status',"hide duplicate status selector")
assert "Cockpit" not in s and "COCKPIT" not in s
return s
def project_patch(s):
s=replace(s,'import { state } from "../core/state.js";','import { state } from "../core/state.js";\nimport { canonicalOperator } from "../../../../automation/repd_reporting/v3/operator-aliases.mjs";',"import explicit operator aliases")
s=replace(s,'let county = "All";\nlet query = "";','let county = "All";\nlet operatorFilter = "All", regionFilter = "All";\nlet query = "";',"source filters")
s=replace(s,'["technology", "status", "county", "q", "sort",','["technology", "status", "county", "operator", "region", "q", "sort",',"url clear")
s=replace(s,'if (county !== "All") url.searchParams.set("county", county);','if (county !== "All") url.searchParams.set("county", county);\nif (operatorFilter !== "All") url.searchParams.set("operator", operatorFilter);\nif (regionFilter !== "All") url.searchParams.set("region", regionFilter);',"url set")
s=replace(s,'county,\ntokens,\n}, searchIndex.get(project.repd_ref)) && matchesYear','county,\ntokens,\n}, searchIndex.get(project.repd_ref)) && (status === "All" || (String(project.status || "").trim() || "Not reported") === status) && (operatorFilter === "All" || canonicalOperator(project.operator) === operatorFilter) && (regionFilter === "All" || (String(project.region || "").trim() || "Not … [line shortened here: 488 characters; full line on GitHub]
s=replace(s,'technology,\nstatus,\ncounty,\ntokens,\n}, searchIndex.get(project.repd_ref))','technology,\nstatus: "All",\ncounty,\ntokens,\n}, searchIndex.get(project.repd_ref))',"include official missing statuses")
funcs='''function populateNativeFilters() {
const inventory = [...all, ...interconnectors];
const labels = key => [...new Set(inventory.map(row=>String(row[key]||"").trim()||"Not reported"))]
.sort((a,b)=>a.localeCompare(b,"en-GB"));
const statuses=labels("status");
for(const value of statuses) ALLOWED_STATUSES.add(value);
for(const [id, values, title] of [
["repdNativeStatus", statuses, "ALL OFFICIAL STATUSES"],
["repdNativeOperator", [...new Set(inventory.map(row=>canonicalOperator(row.operator)))].sort((a,b)=>a.localeCompare(b,"en-GB")), "ALL OPERATORS"],
["repdNativeRegion", labels("region"), "ALL REGIONS"]
]) {
const select=document.getElementById(id);
select.replaceChildren(new Option(title,"All"),...values.filter(v=>v!=="All").map(v=>new Option(v,v)));
}
const scan=document.getElementById("pnScanStatus");
if(scan) for(const value of statuses) {
if(![...scan.options].some(o=>o.value===value)) scan.add(new Option(value,value));
}
}
function syncNativeFilters() {
for(const [id,value] of [["repdNativeStatus",status],["repdNativeOperator",operatorFilter],["repdNativeRegion",regionFilter],["pnScanStatus",status]]) {
const select=document.getElementById(id);
if(select && [...select.options].some(o=>o.value===value)) select.value=value;
}
}
'''
s=replace(s,"function populateCounties() {",funcs+"function populateCounties() {","populate native selector")
s=replace(s,'const requestedCounty = parameters.get("county") || "All";','const requestedCounty = parameters.get("county") || "All";\nconst requestedOperator = parameters.get("operator") || "All";\nconst requestedRegion = parameters.get("region") || "All";',"URL hydrate selectors")
s=replace(s,'query = parameters.get("q") || "";','operatorFilter = [...document.getElementById("repdNativeOperator").options].some(o=>o.value===requestedOperator) ? requestedOperator : "All";\nregionFilter = [...document.getElementById("repdNativeRegion").options].some(o=>o.value===requestedRegion) ? requestedRegion : "All";\nquery = parameters.get("q") || "";',"URL hydrate names")
start=s.index("function hydrateFiltersFromUrl()")
end=s.index("function csvCell(",start)
head=s[start:end]
head=replace(head,'setButtonState("#status", "officialStatus", status);\ndocument.getElementById("county").value = county;','setButtonState("#status", "officialStatus", status);\nsyncNativeFilters();\ndocument.getElementById("county").value = county;',"hydrate sync")
s=s[:start]+head+s[end:]
s=replace(s,'county = "All";\nsubmittedYear = updatedYear = operationalYear = "All";','county = "All";\noperatorFilter = "All"; regionFilter = "All";\nsubmittedYear = updatedYear = operationalYear = "All";',"clear native filters")
start=s.index("function clearFilters(");end=s.index("async function copyProjectId(",start)
head=s[start:end]
head=replace(head,'setButtonState("#status", "officialStatus", status);\ndocument.getElementById("county").value = county;','setButtonState("#status", "officialStatus", status);\nsyncNativeFilters();\ndocument.getElementById("county").value = county;',"clear sync")
s=s[:start]+head+s[end:]
s=replace(s,"populateCounties();\npopulateDateYears();","populateCounties();\npopulateNativeFilters();\npopulateDateYears();","initial selection inventory")
s=replace(s,'status = button.dataset.officialStatus;\nsetButtonState("#status", "officialStatus", status);\napply();','status = button.dataset.officialStatus;\nsetButtonState("#status", "officialStatus", status);\nsyncNativeFilters();\napply();',"native buttons")
s=replace(s,'document.getElementById("county").onchange = (event) => { county = event.target.value; apply(); };','''document.getElementById("repdNativeStatus").onchange = event => { status=event.target.value;setButtonState("#status","officialStatus",status);syncNativeFilters();apply(); };
document.getElementById("repdNativeOperator").onchange = event => { operatorFilter=event.target.value;apply(); };
document.getElementById("repdNativeRegion").onchange = event => { regionFilter=event.target.value;apply(); };
document.getElementById("county").onchange = (event) => { county = event.target.value; apply(); };''',"bind original REPD source handler")
return s
def scan_patch(s):
s=replace(s,"if(selected)selected.click();",'''if(selected)selected.click();
else { const native=document.getElementById("repdNativeStatus"); if(native) {native.value=statusSelect.value;native.dispatchEvent(new Event("change",{bubbles:true}));} }''',"mobile scan to native status")
s=replace(s,'if(active&&statusSelect.value!==active.dataset.officialStatus)statusSelect.value=active.dataset.officialStatus;','''const native=document.getElementById("repdNativeStatus");
const current=native?.value || active?.dataset.officialStatus || "All";
if(statusSelect.value!==current)statusSelect.value=current;''',"mobile scan sync")
return s
def model_patch(s):
s=replace(s,'export const REPORT_DIMENSIONS =','import { canonicalOperator } from "../../automation/repd_reporting/v3/operator-aliases.mjs";\nexport const REPORT_DIMENSIONS =',"report alias model")
return replace(s,'const name = label(project[dimension]);','const name = dimension === "operator" ? canonicalOperator(project.operator) : label(project[dimension]);',"report-only canonical grouping")
def report_patch(s):
s=replace(s,'// PipelineNews V9.74 candidate: same REPD cockpit with source-faithful cross-filters; original visual styles untouched.','// PipelineNews V9.75: reports use the existing filtered REPD table and gauges.',"report banner")
s=replace(s,'import { buildCockpitReport, SOURCE_UNAVAILABLE } from "../../automation/repd_reporting/v2/cockpit-facets.mjs";\n',"","remove parallel report filter")
s=replace(s,'const reportScope = document.getElementById("repdReportScope");\n',"","remove report scope DOM")
s=between(s,'// All facets live inside the existing REPD report tablet, never a second dashboard.','function buildInterconnectorCapacityReport','''function nativeTechnology() {
return document.querySelector('#tech [data-technology][aria-pressed="true"]')?.dataset.technology||"all";
}
function chosenFilter() {
return {technology:nativeTechnology(),
status:document.getElementById("repdNativeStatus")?.value||"All",
operator:document.getElementById("repdNativeOperator")?.value||"All",
region:document.getElementById("repdNativeRegion")?.value||"All"};
}
''',"native read only")
summary='''function sourceRows() {
if(!Array.isArray(state.all)||!state.all.length)return null;
lastSelection=chosenFilter();
const ic=lastSelection.technology==="interconnector";
const rows=state.filtered||[];
lastSnapshot={source:ic?"interconnector":"repd",
sourceProjects:ic?(state.interconnectors||[]).length:state.all.length,
matchingProjects:rows.length};
return rows;
}
function renderNativeSummary(report) {
const wrap=el("div","tablewrap"), table=el("table","repd-native-report-table");
wrap.setAttribute("aria-label","Ranked grouping of the original REPD table filters");
const head=el("thead"),heading=el("tr");
for(const name of ["Group","Projects","Solar MWp","Other MW","Recorded MW/MWp"])
heading.append(el("th","",name));
head.append(heading);
const body=el("tbody");
for(const group of report.groups) {
const row=el("tr"),name=el("td","site"),action=el("button","btn",group.name);
action.type="button";
action.title="Apply this exact group to the original REPD table and gauges";
action.addEventListener("click",()=>{
const id=active==="operator"?"repdNativeOperator":active==="status"?"repdNativeStatus":"repdNativeRegion";
const select=document.getElementById(id);
if(!select||![...select.options].some(o=>o.value===group.name)) {
reportSummary.textContent="No matching source filter for "+group.name;return;
}
select.value=group.name;
select.dispatchEvent(new Event("change",{bubbles:true}));
document.getElementById("repdScroll")?.scrollIntoView({block:"nearest"});
});
name.append(action);row.append(name);
for(const [value,css] of [[group.count,""],[group.solarMwp,"mw"],[group.otherMw,"mw"],[group.recordedCapacity,"mw"]])
row.append(el("td",css,css?formatCapacity(value):formatCount(value)));
body.append(row);
}
table.append(head,body);wrap.append(table);reportBody.append(wrap);
}
'''
s=between(s,"function sourceRows() {","function render() {",summary,"source authority")
renderer='''function render() {
if(!active||panel.hidden)return;
reportBody.replaceChildren();
try {
const rows=sourceRows();
if(!rows){lastReport=null;reportSummary.textContent="Loading original REPD register…";return;}
const ic=lastSnapshot.source==="interconnector";
const report=ic?buildInterconnectorCapacityReport(rows,active):buildRepdCapacityReport(rows,active);
lastReport=report;
const selection=lastSelection;
const tech=selection.technology==="all"?"ALL REPD TECHNOLOGIES":selection.technology.replaceAll("_"," ").toUpperCase();
reportSummary.textContent=titles[active]+" · "+tech+" · "+selection.status+
" · CURRENT REPD TABLE FILTERS · SOURCE "+formatCount(lastSnapshot.sourceProjects)+
" · SELECTED "+formatCount(rows.length)+" · "+formatCount(report.groups.length)+
" groups · "+capacityDescription(report.total)+
(ic?" · Separate interconnector inventory, not REPD":" · Select a group to filter the original table and gauges");
if(ic) {
const heading=el("div","repd-report-row repd-report-columns");
for(const name of ["Group","Recorded MW","Solar MWp","Other MW","Projects"])heading.append(el("span","",name));
heading.append(el("span","",""));
reportBody.append(heading);
const maximum=report.groups.length?report.groups[0].recordedCapacity:0;
for(const [index,group] of report.groups.entries())reportBody.append(makeGroup(group,maximum,index));
} else renderNativeSummary(report);
if(!report.groups.length)reportBody.append(el("p","","No matching projects in the original REPD table."));
} catch(error){
lastReport=null;lastSnapshot=null;
reportSummary.textContent="Report validation failed: "+String(error?.message||error);
}
}
'''
s=between(s,"function render() {","function selectReport(dimension) {",renderer,"native report table")
s=replace(s,"if (panel && reportScope && reportSummary && reportBody) {","if (panel && reportSummary && reportBody) {","panel guard")
s=replace(s,' reportScope.addEventListener("change", render);\n',"","no second selector")
assert not any(word in s for word in ["makeFacet(","reportScope","buildCockpitReport","COCKPIT"])
return s
def main():
assert OLD.is_dir() and NEW.is_dir()
original={str(p.relative_to(OLD)):p.read_bytes() for p in OLD.rglob("*") if p.is_file()}
staged={str(p.relative_to(NEW)):p.read_bytes() for p in NEW.rglob("*") if p.is_file()}
if (NEW/"README.md").read_text().startswith("# PipelineNews V9.75"):
assert set(original).issubset(set(staged)) and set(staged)-set(original)=={"tests/v975-native-browser.mjs"}, "Already-built successor lost source files or gained unapproved files"
assert all(original[p]==staged[p] for p in original if p.startswith(("styles/","data/")) or p in ("map-entry.mjs","report-a4.mjs","report-pdf.mjs","repd-expanded.mjs")), "Immutable source/colour/Atlas changed"
assert "repdNativeOperator" in (NEW/"index.html").read_text()
print("V9.75 existing successor: source, CSS, MAP/A4/PDF closure PASS")
return
assert len(original)>300 and original==staged, "Unsafe or incomplete cloned V9.75 tree"
for path,fn in [
("index.html",html_patch),("scripts/plugins/projects-v9-8.js",project_patch),
("repd-scan.mjs",scan_patch),("repd-reports-model.mjs",model_patch),
("repd-reports.mjs",report_patch)]:
patch(path,fn)
(NEW/"tests/v975-native-browser.mjs").write_text((ROOT/"automation/repd_reporting/v3/browser_v975.mjs").read_text())
(NEW/"README.md").write_text("""# PipelineNews V9.75 — REPD native filters and ranked reports
Single source filtered REPD register drives gauges, project table, CSV and reports.
Native status buttons near gauges; all official statuses, operator, region exposed above.
Exact alias grouping only: Low Carbon / Low Carbon Ltd / Low Carbon Limited.
Never infer ownership or change REPD refs, operator source, MWp/MW or historical data.
Original CSS/SCADA palette, MAP/A4/PDF/VICINITY, ticker and snapshots unchanged.
Full Python/Playwright/served-SHA verification required before live promotion.
""")
(NEW/"CHANGES.md").write_text("""# V9.75
- Removed report-specific duplicate filters and user-facing prior naming.
- Retained and moved source-native status buttons above existing grouped reports.
- Operator and region selectors now filter original REPD table, gauges, CSV and reports.
- Report ranking uses the original HTML table style, group click filters source table.
- Explicit report-only alias list, no project/data/colour/old release changes.
""")
print("V9.75 patch composed safely; original",len(original),"files retained")
if __name__=="__main__":
main()Operator Aliases
A JavaScript module in the REPD reporting folder of GlobalGrid2050 that works with the Renewable Energy Planning Database (REPD) register. It is built from the canonical operator helper (`canonicalOperator`).
transformglobalgrid2050 / automation/repd_reporting/v3/operator-aliases.mjs · lines 1–14 of 14 · Entry point
- What it does
- It calculates the REPD register. Defines canonicalOperator.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'repd'): 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. README: "Operator grouping: exact reviewed spellings only, in `operator-aliases.mjs`."
- Downstream impact
- Used directly by 5 files: Operator Aliases Test (globalgrid2050); Real V975 Test (globalgrid2050); Renewable Energy Planning Database (REPD) Reports Model (globalgrid2050); Projects V9 8 (globalgrid2050); and 1 more. Reached from 13 other entry points, including GlobalGrid2050 — UK Renewables Pipeline Page (globalgrid2050, https://globalgrid2050.com/uk_renewables_pipeline/202611280922/); GlobalGrid2050 Pipeline Legal Evidence Workflow (globalgrid2050); GlobalGrid2050 Pn V973 Capacity Reports Workflow (globalgrid2050).
- What it achieves
- Conservative, report-only spelling aliases. NOT a corporate ownership assertion.
- Why it matters
- Imported by Renewable Energy Planning Database (REPD) Reports Model and Projects V9 8. Run by GlobalGrid2050 Renewable Energy Planning Database (REPD) Native V975 Workflow. Checked by 2 tests, including Operator Aliases Test.
- Application
- globalgrid2050 · automation/repd_reporting/v3 · JavaScript module
- Uses
- none found
- Used by
- imported by Operator Aliases Test (import), imported by Real V975 Test (import), imported by Renewable Energy Planning Database (REPD) Reports Model (import), imported by Projects V9 8 (import), run by GlobalGrid2050 Renewable Energy Planning Database (REPD) Native V975 Workflow (workflow run)
- Produces
- OPERATOR_ALIASES_V1, canonicalOperator
- Defines here
- canonicalOperator
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 automation/repd_reporting/v3/operator-aliases.mjs:1-14 · blob 9b9213706b40141806f43701256b5a04f0261e7f · 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
/** Conservative, report-only spelling aliases. NOT a corporate ownership assertion.
* Never rewrite original REPD operator strings or group unrelated subsidiaries.
*/
export const OPERATOR_ALIASES_V1=Object.freeze({
"low carbon":"Low Carbon",
"low carbon ltd":"Low Carbon",
"low carbon limited":"Low Carbon"
});
export function canonicalOperator(raw) {
const source=String(raw??"").normalize("NFKC").replace(/\s+/g," ").trim();
if(!source)return "Not reported";
const key=source.toLocaleLowerCase("en-GB").replace(/[.,]+$/g,"").replace(/\s+/g," ");
return OPERATOR_ALIASES_V1[key]||source;
}Operator Aliases Test
A test in the REPD reporting folder of GlobalGrid2050 that checks Operator Aliases and Renewable Energy Planning Database (REPD) Reports Model.
testglobalgrid2050 / automation/repd_reporting/v3/operator-aliases.test.mjs · lines 1–27 of 27 · Entry point
- What it does
- It tests the REPD register and solar. Uses libraries node:test, node:assert/strict.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'repd'): 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. README: "Operator grouping: exact reviewed spellings only, in `operator-aliases.mjs`."
- Downstream impact
- Used directly by 2 files: GlobalGrid2050 Renewable Energy Planning Database (REPD) Mobile V976 Workflow (globalgrid2050); GlobalGrid2050 Renewable Energy Planning Database (REPD) Native V975 Workflow (globalgrid2050).
- What it achieves
- The README says: Operator grouping: exact reviewed spellings only, in `operator-aliases.mjs`.
- Why it matters
- Run by GlobalGrid2050 Renewable Energy Planning Database (REPD) Mobile V976 Workflow and GlobalGrid2050 Renewable Energy Planning Database (REPD) Native V975 Workflow.
- Application
- globalgrid2050 · automation/repd_reporting/v3 · test
- Uses
- Operator Aliases (import), Renewable Energy Planning Database (REPD) Reports Model (import), node:test, node:assert/strict
- Used by
- run by GlobalGrid2050 Renewable Energy Planning Database (REPD) Mobile V976 Workflow (workflow run), run by GlobalGrid2050 Renewable Energy Planning Database (REPD) Native V975 Workflow (workflow run)
- Produces
- none declared
- 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
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 automation/repd_reporting/v3/operator-aliases.test.mjs:1-27 · blob c0a41b4c665e366f04ba1a4eeb7b76a8afa536ef · GitHub at these lines
- State
- achieves: readme · context: readme_derived · stage: unknown · effects: none found · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
import test from "node:test";
import assert from "node:assert/strict";
import {canonicalOperator,OPERATOR_ALIASES_V1} from "./operator-aliases.mjs";
import {buildRepdCapacityReport} from "../../../uk_renewables_pipeline/202611231600/repd-reports-model.mjs";
test("Only explicit Low Carbon spelling aliases, no blind parent inference",()=>{
for(const x of ["Low Carbon","LOW CARBON","Low Carbon Ltd","Low Carbon Limited"," low carbon limited "])
assert.equal(canonicalOperator(x),"Low Carbon");
for(const x of ["Low Carbon Energy","Low Carbon Group","Low Carbon Solar UK","Carbon Low Ltd"])
assert.equal(canonicalOperator(x),x);
assert.equal(canonicalOperator(""),"Not reported");
assert.equal(canonicalOperator(null),"Not reported");
assert.equal(Object.keys(OPERATOR_ALIASES_V1).length,3);
});
test("Alias grouping retains every original REPD ref and unit",()=>{
const data=[
{repd_ref:"101",operator:"Low Carbon Limited",capacity_mw:15,technology:"solar",status:"Operational"},
{repd_ref:"102",operator:"low carbon ltd",capacity_mw:20,technology:"solar",status:"Application Submitted"},
{repd_ref:"103",operator:"Low Carbon Group",capacity_mw:2,technology:"bess",status:"Operational"}
];
const result=buildRepdCapacityReport(data,"operator");
assert.equal(result.uniqueRefs,3);
assert.equal(result.groups.length,2);
const low=result.groups.find(g=>g.name==="Low Carbon");
assert.equal(low.count,2); assert.equal(low.solarMwp,35); assert.equal(low.otherMw,0);
assert.equal(data[0].operator,"Low Carbon Limited");
assert.equal(data[1].operator,"low carbon ltd");
});