In this section
- Single-Line Diagram (SLD) Sandbox Proof electrical · gridatlas / tools/proofs/202611222130-sld-sandbox.proof.mjs lines 1–42
- UKPN Paired Browser energy-data · gridatlas / tools/proofs/202612010912-ukpn-paired.browser.mjs lines 1–82
- UKPN Secondary Browser energy-data · gridatlas / tools/proofs/202612010912-ukpn-secondary.browser.mjs lines 1–119
- Substation Intelligence Proof electrical · gridatlas / tools/proofs/202612012117-substation-intelligence.proof.mjs lines 1–2
- UKPN Secondary Card Proof energy-data · gridatlas / tools/proofs/202612012117-ukpn-secondary-card.proof.mjs lines 1–2
- UKPN Secondary Substations Proof energy-data · gridatlas / tools/proofs/202612012117-ukpn-secondary-substations.proof.mjs lines 1–2
- Network Topology Proof render · gridatlas / tools/proofs/modules/202609012145-network-topology.proof.mjs lines 1–269
- Map Click Network Proof render · gridatlas / tools/proofs/modules/202609012230-map-click-network.proof.mjs lines 1–81
- Audit UKPN energy-data · gridatlas / tools/secondary/audit_ukpn.py lines 1–84
Single-Line Diagram (SLD) Sandbox Proof
A JavaScript module in the proofs folder of GridAtlas that reads composition, using SHA-256.
electricalgridatlas / tools/proofs/202611222130-sld-sandbox.proof.mjs · lines 1–42 of 42 · version 2026-11-22 21:30 · Entry point
- What it does
- It loads composition. Defines read. Uses libraries node:fs, node:path, node:assert/strict, node:crypto, node:vm. Side effects: changes the web page (DOM); reads or writes files.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Inputs & outputs
- In: JSON file 202611222130-composition.json; JSON file current.json.
- Downstream impact
- Used directly by 1 file: GridAtlas PR File Size Guard Workflow (gridatlas).
- What it achieves
- Defines `read`. It reads `atlas/manifests/202611222130-composition.json`.
- Why it matters
- Run by GridAtlas PR File Size Guard Workflow.
- Application
- gridatlas · tools/proofs · JavaScript module
- Uses
- Single-Line Diagram (SLD) Retire GridAtlas Layout (import), node:fs, node:path, node:assert/strict, node:crypto, node:vm
- Used by
- run by GridAtlas PR File Size Guard Workflow (workflow run)
- Produces
- read
- Defines here
- read
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/proofs/202611222130-sld-sandbox.proof.mjs:1-42 · blob 340407139233054b22435dcc44a85d38cce0736a · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom, filesystem · domain stage: experimental · users: none · canonical: production_core
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import crypto from 'node:crypto';
import vm from 'node:vm';
import {retireLayout,sourcePath,outputPath} from '../sld/retire-gridatlas-layout.mjs';
const root=path.resolve(import.meta.dirname,'../..');
const read=x=>fs.readFileSync(path.join(root,x),'utf8');
const manifest=JSON.parse(read('atlas/manifests/202611222130-composition.json'));
const preview=JSON.parse(read('atlas/v/202611222130/current.json'));
const live=JSON.parse(read('atlas/current.json'));
assert.ok(['202611222000','202611222130','202611222325','202611222343','202611280016','202612010912'].includes(live.generation),'live must be V9.194 or verified V9.195');
if(live.generation==='202611222130')for(const c of manifest.cartridges){
const active=live.cartridges.find(x=>x.id===c.id);
assert.ok(active&&active.sha256===c.sha256,'promoted '+c.id+' must match the accepted source pin');
}
assert.equal(manifest.generation,'202611222130');
assert.equal(manifest.previous_generation,'202611222000','immutable V9.194 predecessor must remain fixed before and after publication');
assert.equal(manifest.acceptance?.full_application_copies_created,0);
assert.equal(manifest.composition_manifest,'./manifests/202611222130-composition.json');
for(const key of ['parent_generation','version','cut_at_utc','note','acceptance','candidate_status'])delete manifest[key];
const canonical=JSON.stringify(manifest,null,1)+'\n';
const expectedPreview=canonical.replace(/": "(\.\/|\.\.\/)/g,'": "../../');
assert.equal(read('atlas/v/202611222130/current.json'),expectedPreview,'preview must be the exact live pointer re-rooted');
const sld=manifest.cartridges.find(c=>c.id==='sld-sandbox');
assert.equal(sld.generation,'202611222130');
assert.equal(sld.path,'./modules/202611222130-sld-without-layout.js');
const original=read(sourcePath),derived=read(outputPath);
assert.equal(derived,retireLayout(original),'exact minimal layout-only change');
assert.ok(Buffer.byteLength(derived)>445000,'carrier must not be truncated');
assert.equal(crypto.createHash('sha256').update(derived).digest('hex'),sld.sha256);
assert.equal(Buffer.byteLength(derived),sld.bytes);
new vm.Script(derived);
assert.ok(!derived.includes(' + `<button class="neon-layout"'));
assert.ok(derived.includes("return false; // retired: no substation-triggered layout"));
assert.ok(derived.includes("return false; // retired: no project-triggered layout"));
assert.ok(derived.includes('function enableSubstationLayer()'));
assert.ok(derived.includes('window.__GRIDATLAS_NEON_LINKS__'));
assert.ok(derived.includes('keepLayersInFullscreen();'));
assert.ok(derived.includes('armCorridorGestures(map);'));
assert.deepEqual(preview.cartridge_order,manifest.cartridge_order);
console.log('PASS release V9.195: no SLD UI, untouched source, full Grid Engine and release/preview byte parity');UKPN Paired Browser
A JavaScript module in the proofs folder of GridAtlas that reads grid UKPN secondary and UKPN transformers. It is built from the memory step (`memory`).
energy-datagridatlas / tools/proofs/202612010912-ukpn-paired.browser.mjs · lines 1–82 of 82 · version 2026-12-01 09:12 · Entry point · pattern memory (shared by 3 files)
- What it does
- It loads grid UKPN secondary and UKPN transformers. Defines memory. Uses libraries node:assert/strict, node:fs, playwright. Side effects: changes the web page (DOM); reads or writes files; uses storage (browser storage, DuckDB or Parquet).
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'ukpn'): 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: Parquet file grid_ukpn_secondary.parquet; Parquet file ukpn_transformers.parquet.
- Downstream impact
- Used directly by 1 file: GridAtlas PR File Size Guard Workflow (gridatlas).
- What it achieves
- Identical harness copied into the pinned ZIP worktree and run on the same runner as Parquet.
- Why it matters
- Run by GridAtlas PR File Size Guard Workflow.
- Application
- gridatlas · tools/proofs · JavaScript module
- Uses
- Serve (import), node:assert/strict, node:fs, playwright
- Used by
- run by GridAtlas PR File Size Guard Workflow (workflow run)
- Produces
- memory
- Defines here
- memory
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/proofs/202612010912-ukpn-paired.browser.mjs:1-82 · blob ae8300b608d08c5747f53c92183f71aae1b4115f · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, storage · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
import assert from 'node:assert/strict';
import fs from 'node:fs';
import {chromium,webkit} from 'playwright';
import {createPreviewServer} from '../journey/serve.mjs';
// Identical harness copied into the pinned ZIP worktree and run on the same
// runner as Parquet. Cold = fresh browser context; warm = reload of that
// context (cache eligible, not proof of a cache hit). No production writes.
const engine=process.env.UKPN_BROWSER==='webkit'?'webkit':'chromium';
const mode=process.env.UKPN_BENCH_MODE;
assert.ok(['zip','parquet'].includes(mode));
const output=process.env.UKPN_BENCH_OUTPUT;
assert.ok(output);
const server=await createPreviewServer();
const browser=await (engine==='webkit'?webkit:chromium).launch({headless:true,...(engine==='chromium'?{args:['--use-gl=angle','--use-angle=swiftshader','--enable-webgl','--ignore-gpu-blocklist']}: {})});
const rows=[];
const url='http://127.0.0.1:'+server.address().port+'/atlas/v/202612010912/';
try {
for(const viewport of [{width:393,height:852},{width:852,height:393}]){
const context=await browser.newContext({viewport,isMobile:true,hasTouch:true,reducedMotion:'reduce'});
try {
const page=await context.newPage();
const cdp=engine==='chromium'?await context.newCDPSession(page):null;
const memory=async()=>cdp?await cdp.send('Runtime.getHeapUsage'):null;
let requests=[];
page.on('request',req=>{
const p=new URL(req.url()).pathname;
if(/(?:ukpn-secondary-site-transformers\.zip|grid_ukpn_secondary\.parquet|ukpn_transformers\.parquet)$/.test(p))requests.push(p.split('/').at(-1));
});
for(const cache of ['cold-context','same-context-reload']){
requests=[];
const start=performance.now();
if(cache==='cold-context')await page.goto(url,{waitUntil:'domcontentloaded',timeout:90000});
else await page.reload({waitUntil:'domcontentloaded',timeout:90000});
await page.waitForFunction(()=>window.__GRIDATLAS_V9_MAP__?.getLayer('l-ukpn_secondary')&&document.querySelector('#scada-ui-container input[data-layer-id="ukpn_secondary"]')&&window.__GRIDATLAS_V9_MAP__.getSource('src-400')&&window.__GRIDATLAS_V9_MAP__.isSourceLoaded('src-400'),null,{timeout:120000});
const startupMs=performance.now()-start;
const heapStartup=await memory();
assert.deepEqual(requests,[],'UKPN acquired before opt-in');
await page.evaluate(()=>window.__GRIDATLAS_V9_MAP__.jumpTo({center:[-0.1276,51.5072],zoom:14}));
const activated=performance.now();
await page.locator('#scada-ui-container input[data-layer-id="ukpn_secondary"]').evaluate(el=>el.click());
await page.waitForFunction(()=>window.__GRIDATLAS_V9_MAP__.getSource('src-ukpn_secondary')?.serialize().data?.features?.length===54558,null,{timeout:120000});
const hydrationMs=performance.now()-activated;
const heapHydrated=await memory();
const expected=mode==='zip'?'ukpn-secondary-site-transformers.zip':'grid_ukpn_secondary.parquet';
assert.deepEqual(requests,[expected]);
const site=await page.evaluate(()=>{
const map=window.__GRIDATLAS_V9_MAP__, f=map.getSource('src-ukpn_secondary').serialize().data.features[0];
map.jumpTo({center:f.geometry.coordinates,zoom:16});
return f.id;
});
await page.waitForFunction(()=>window.__GRIDATLAS_V9_MAP__.queryRenderedFeatures({layers:['l-ukpn_secondary']}).length>0,null,{timeout:60000});
const click=await page.evaluate(()=>{
const map=window.__GRIDATLAS_V9_MAP__, f=map.queryRenderedFeatures({layers:['l-ukpn_secondary']})[0];
const p=map.project(f.geometry.coordinates),r=map.getCanvas().getBoundingClientRect();
return {x:r.left+p.x,y:r.top+p.y};
});
const selected=performance.now();
await page.mouse.click(click.x,click.y);
await page.waitForFunction(()=>document.querySelector('[data-ukpn-detail][data-level="full"]')?.textContent.includes('ONAN rating'),null,{timeout:60000});
const detailsMs=performance.now()-selected;
const selectedSite=await page.locator('[data-ukpn-detail]').getAttribute('data-site');
const heapDetails=await memory();
assert.deepEqual(requests,mode==='zip'?[expected]:[expected,'ukpn_transformers.parquet']);
for(const zoom of [6,11,13,14,15,16,18,6,14,16,18,13,16]){
await page.evaluate(z=>window.__GRIDATLAS_V9_MAP__.jumpTo({zoom:z}),zoom);
if(zoom<14)await page.waitForFunction(()=>window.__GRIDATLAS_V9_MAP__.queryRenderedFeatures({layers:['l-ukpn_secondary']}).length===0);
}
assert.deepEqual(requests,mode==='zip'?[expected]:[expected,'ukpn_transformers.parquet']);
const heapAfterCycles=await memory();
const dataPlane=await page.evaluate(()=>window.__GRIDATLAS_UKPN_DATA__??null);
rows.push({engine,mode,viewport,cache,site,selectedSite,startupMs,hydrationMs,detailsMs,heapStartup,heapHydrated,heapDetails,heapAfterCycles,dataPlane,requests:[...requests],mapPayloadBytes:mode==='zip'?2068796:870439,detailPayloadBytes:mode==='zip'?0:3930813,physicalSafari:false});
console.log('UKPN PAIRED SAMPLE '+JSON.stringify(rows.at(-1)));
}
}finally{await context.close();}
}
}finally{
fs.writeFileSync(output,JSON.stringify(rows,null,2)+'\n');
await browser.close();
await new Promise(resolve=>server.close(resolve));
}
assert.equal(rows.length,4);UKPN Secondary Browser
A JavaScript module in the proofs folder of GridAtlas that reads grid UKPN secondary, UKPN transformers and 11kV. It is built from the zoom to helper (`zoomTo`).
energy-datagridatlas / tools/proofs/202612010912-ukpn-secondary.browser.mjs · lines 1–119 of 119 · version 2026-12-01 09:12 · Entry point · pattern memory (shared by 3 files)
- What it does
- It loads grid UKPN secondary, UKPN transformers and 11kV. Defines memory, zoomTo. Uses libraries node:assert/strict, node:fs, playwright. Side effects: changes the web page (DOM); reads or writes files; uses storage (browser storage, DuckDB or Parquet).
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'ukpn'): 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: 11kV.
- Inputs & outputs
- In: Parquet file grid_ukpn_secondary.parquet; Parquet file ukpn_transformers.parquet. Out: JSON file receipt.json. Voltage levels named: 11kV.
- Downstream impact
- Used directly by 1 file: GridAtlas PR File Size Guard Workflow (gridatlas).
- What it achieves
- Defines `memory` and `zoomTo`. It writes `/receipt.json`.
- Why it matters
- Run by GridAtlas PR File Size Guard Workflow.
- Application
- gridatlas · tools/proofs · JavaScript module
- Uses
- Serve (import), node:assert/strict, node:fs, playwright
- Used by
- run by GridAtlas PR File Size Guard Workflow (workflow run)
- Produces
- memory, zoomTo
- Defines here
- memory, zoomTo
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/proofs/202612010912-ukpn-secondary.browser.mjs:1-119 · blob c8827c213a6991bac24cf4e8d157314c8c1192f9 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom, filesystem, storage · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
import assert from 'node:assert/strict';
import fs from 'node:fs';
import {chromium,webkit} from 'playwright';
import {createPreviewServer} from '../journey/serve.mjs';
const engine=process.env.UKPN_BROWSER==='webkit'?'webkit':'chromium';
const browser=await (engine==='webkit'?webkit:chromium).launch({headless:true,...(engine==='chromium'?{args:['--use-gl=angle','--use-angle=swiftshader','--enable-webgl','--ignore-gpu-blocklist']}: {})});
const server=await createPreviewServer();
const out='work/ukpn-'+engine;
fs.mkdirSync(out,{recursive:true});
const receipts=[];
const archive='/grid_ukpn_secondary.parquet';
const transformer='/ukpn_transformers.parquet';
const oldArchive='/ukpn-secondary-site-transformers.zip';
try {
for(const viewport of [{width:393,height:852},{width:852,height:393}]){
const context=await browser.newContext({viewport,isMobile:true,hasTouch:true,reducedMotion:'reduce'});
const page=await context.newPage();
let downloads=0, bytes=0, detailDownloads=0, zipDownloads=0;
page.on('request',r=>{const p=new URL(r.url()).pathname;if(p.endsWith(archive)) downloads++;if(p.endsWith(transformer))detailDownloads++;if(p.endsWith(oldArchive))zipDownloads++;});
const cdp=engine==='chromium'?await context.newCDPSession(page):null;
const memory=async()=>cdp?await cdp.send('Runtime.getHeapUsage'):null;
page.on('response',r=>{if(new URL(r.url()).pathname.endsWith(archive)) bytes=Number(r.headers()['content-length'])||0;});
const began=Date.now();
await page.goto('http://127.0.0.1:'+server.address().port+'/atlas/v/202612010912/',{waitUntil:'domcontentloaded',timeout:90000});
await page.waitForFunction(()=>window.__GRIDATLAS_V9_MAP__?.getLayer('l-ukpn_secondary')&&document.querySelector('#scada-ui-container input[data-layer-id="ukpn_secondary"]')&&document.querySelector('#fs-curtain-keys input[data-layer-id="ukpn_secondary"]'),null,{timeout:120000});
await page.waitForFunction(()=>window.__GRIDATLAS_V9_MAP__?.getSource('src-400')&&window.__GRIDATLAS_V9_MAP__.isSourceLoaded('src-400'),null,{timeout:120000});
const startupMs=Date.now()-began;
const heapStartup=await memory();
assert.equal(detailDownloads,0);assert.equal(zipDownloads,0);
const normal=page.locator('#scada-ui-container input[data-layer-id="ukpn_secondary"]');
const full=page.locator('#fs-curtain-keys input[data-layer-id="ukpn_secondary"]');
assert.equal(await normal.isChecked(),false);
assert.equal(await full.isChecked(),false);
assert.equal(downloads,0,'secondary data must not be fetched at startup');
assert.equal(await page.evaluate(()=>window.__GRIDATLAS_V9_MAP__.getLayer('l-ukpn_secondary').minzoom),14);
const zoomTo=zoom=>page.evaluate(z=>window.__GRIDATLAS_V9_MAP__.jumpTo({zoom:z}),zoom);
assert.equal(await page.evaluate(()=>window.__GRIDATLAS_V9_MAP__.getLayer('l-11kv').minzoom),13);
assert.equal(await page.locator('#scada-ui-container input[data-layer-id="11kv"]').isDisabled(),true);
await zoomTo(13.99);
await normal.evaluate(el=>el.click());
assert.equal(await full.isChecked(),true,'deferred mirrored control');
await page.waitForFunction(()=>document.querySelector('#scada-ui-container [data-ukpn-zoom-hint]') && [...document.querySelectorAll('#scada-ui-container [data-ukpn-zoom-hint]')].some(x=>x.textContent.includes('Zoom in to view')));
await page.waitForTimeout(350);
assert.equal(downloads,0,'enabled below threshold must not fetch');
await normal.evaluate(el=>el.click());
await zoomTo(14);
await page.waitForTimeout(350);
assert.equal(downloads,0,'disabled layer must not fetch upon reaching threshold');
await zoomTo(13.99);
await full.evaluate(el=>el.click());
assert.equal(await normal.isChecked(),true,'deferred fullscreen mirrored control');
assert.equal(downloads,0);
const activated=Date.now();
await zoomTo(14);
await page.waitForFunction(()=>window.__GRIDATLAS_V9_MAP__.getSource('src-ukpn_secondary').serialize().data?.features?.length===54558,null,{timeout:120000});
const hydrationMs=Date.now()-activated;
const heapHydrated=await memory();
assert.equal(downloads,1);assert.equal(detailDownloads,0);assert.equal(zipDownloads,0);
assert.equal(await page.evaluate(()=>window.__GRIDATLAS_UKPN_DATA__.sharedRuntime),true);
await page.evaluate(()=>{
const map=window.__GRIDATLAS_V9_MAP__;
const first=map.getSource('src-ukpn_secondary').serialize().data.features[0];
map.jumpTo({center:first.geometry.coordinates,zoom:16});
});
await page.waitForFunction(()=>window.__GRIDATLAS_V9_MAP__.queryRenderedFeatures({layers:['l-ukpn_secondary']}).length>0,null,{timeout:60000});
// Click a real rendered feature through the browser, not through a DOM toggle.
const click=await page.evaluate(()=>{
const map=window.__GRIDATLAS_V9_MAP__, f=map.queryRenderedFeatures({layers:['l-ukpn_secondary']})[0];
const p=map.project(f.geometry.coordinates), rect=map.getCanvas().getBoundingClientRect();
return {x:rect.left+p.x,y:rect.top+p.y};
});
await page.mouse.click(click.x,click.y);
await page.waitForFunction(()=>document.querySelector('[data-ukpn-detail][data-level="full"]'),null,{timeout:15000});
const detail=page.locator('[data-ukpn-detail]');
assert.match(await detail.innerText(),/Transformer count/);
await page.waitForFunction(()=>document.querySelector('[data-ukpn-detail]')?.textContent.includes('ONAN rating'),null,{timeout:60000});
assert.match(await detail.innerText(),/ONAN rating/);
assert.equal(detailDownloads,1);assert.equal(zipDownloads,0);
const heapDetails=await memory();
assert.match(await detail.innerText(),/CC BY 4.0/);
await zoomTo(15);
await page.waitForFunction(()=>document.querySelector('[data-ukpn-detail][data-level="summary"]'));
assert.doesNotMatch(await detail.innerText(),/ONAN rating/);
await zoomTo(13.99);
await page.waitForFunction(()=>!document.querySelector('[data-ukpn-detail]'));
await page.waitForFunction(()=>window.__GRIDATLAS_V9_MAP__.queryRenderedFeatures({layers:['l-ukpn_secondary']}).length===0);
assert.equal(downloads,1);
await zoomTo(16);
await page.waitForFunction(()=>window.__GRIDATLAS_V9_MAP__.queryRenderedFeatures({layers:['l-ukpn_secondary']}).length>0);
assert.equal(downloads,1,'zoom revisit must reuse validated native source');
for(const z of [6,11,13,14,15,16,18,6,14,16,18,13,16]){
await zoomTo(z);
if(z<14)await page.waitForFunction(()=>window.__GRIDATLAS_V9_MAP__.queryRenderedFeatures({layers:['l-ukpn_secondary']}).length===0);
assert.equal(downloads,1,'zoom cycle must not reacquire archive');
}
await page.evaluate(()=>window.enterFullscreen());
await page.waitForFunction(()=>document.body.classList.contains('fs-active'));
await page.evaluate(()=>document.getElementById('fs-curtain-tab').click());
await full.evaluate(el=>el.click());
assert.equal(await normal.isChecked(),false);
assert.equal(await page.evaluate(()=>window.__GRIDATLAS_V9_MAP__.getLayoutProperty('l-ukpn_secondary','visibility')),'none');
await full.evaluate(el=>el.click());
assert.equal(await normal.isChecked(),true);
assert.equal(downloads,1,'repeat activation must not reacquire archive');
assert.equal(await page.evaluate(()=>window.__GRIDATLAS_V9_MAP__.getLayoutProperty('l-ukpn_secondary','visibility')),'visible');
await page.screenshot({path:out+'/'+viewport.width+'.png'});
assert.equal(detailDownloads,1);assert.equal(zipDownloads,0);
const heapAfterCycles=await memory();
const dataPlane=await page.evaluate(()=>window.__GRIDATLAS_UKPN_DATA__);
receipts.push({viewport,startupMs,hydrationMs,downloads,parquetContentLength:bytes,detailDownloads,zipDownloads,dataPlane,heapStartup,heapHydrated,heapDetails,heapAfterCycles,memoryScope:cdp?'Chromium page JS/V8 heap only; excludes complete worker/GPU/OS footprint':'Unavailable in WebKit',rendered:true,mirroredControls:true,transformerCard:true,zoomCycle:true,physicalSafari:false});
await context.close();
}
console.log('UKPN browser PASS '+JSON.stringify(receipts));
} finally {
fs.writeFileSync(out+'/receipt.json',JSON.stringify(receipts,null,2));
await browser.close();
await new Promise(resolve=>server.close(resolve));
}Substation Intelligence Proof
A JavaScript module in the proofs folder of GridAtlas covering substations.
electricalgridatlas / tools/proofs/202612012117-substation-intelligence.proof.mjs · lines 1–2 of 2 · version 2026-12-01 21:17 · Not reached from any entry point (candidate for review)
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'substation'): 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: substations.
- 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
- gridatlas · tools/proofs · JavaScript module
- Uses
- Owner Test Proof (import)
- 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
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/proofs/202612012117-substation-intelligence.proof.mjs:1-2 · blob d272f1b5263a4d7d9276b343ec3303abaac9177c · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: unknown · effects: none found · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
import {prove} from '../secondary/owner-test-proof.mjs';
prove('202612012117','substation-intelligence');UKPN Secondary Card Proof
A JavaScript module in the proofs folder of GridAtlas.
energy-datagridatlas / tools/proofs/202612012117-ukpn-secondary-card.proof.mjs · lines 1–2 of 2 · version 2026-12-01 21:17 · Not reached from any entry point (candidate for review)
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'ukpn'): 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. README: "Added real rendered UKPN card selection, ranked Grid Engine transfer, poor-fix rejection, exact endpoint and GPS-watch preservation, and secondary Vicinity identity assertions to the existing combined browser gate."
- What it achieves
- The README says: Added real rendered UKPN card selection, ranked Grid Engine transfer, poor-fix rejection, exact endpoint and GPS-watch preservation, and secondary Vicinity identity assertions to the existing combined browser gate.
- Why it matters
- No other file in the estate was found to import it.
- Application
- gridatlas · tools/proofs · JavaScript module
- Uses
- Owner Test Proof (import)
- 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
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/proofs/202612012117-ukpn-secondary-card.proof.mjs:1-2 · blob 9c5ba7e73378de697b8d092adb8874353a107103 · 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: unreached_review
import {prove} from '../secondary/owner-test-proof.mjs';
prove('202612012117','ukpn-secondary-card');UKPN Secondary Substations Proof
A JavaScript module in the proofs folder of GridAtlas covering substations.
energy-datagridatlas / tools/proofs/202612012117-ukpn-secondary-substations.proof.mjs · lines 1–2 of 2 · version 2026-12-01 21:17 · Not reached from any entry point (candidate for review)
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'substations'): 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: substations.
- 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
- gridatlas · tools/proofs · JavaScript module
- Uses
- Owner Test Proof (import)
- 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
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/proofs/202612012117-ukpn-secondary-substations.proof.mjs:1-2 · blob fa3a883d3d46a69e66909028bd87e80f96447634 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: unknown · effects: none found · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
import {prove} from '../secondary/owner-test-proof.mjs';
prove('202612012117','ukpn-secondary-substations');Network Topology Proof
A JavaScript module in the proofs folder of GridAtlas that reads GB transmission network, transformers, 400kV and 132kV, using haversine. It is built from the check step (`check`).
rendergridatlas / tools/proofs/modules/202609012145-network-topology.proof.mjs · lines 1–269 of 269 · version 2026-09-01 21:45 · Not reached from any entry point (candidate for review)
- What it does
- It loads GB transmission network, transformers, 400kV and 132kV. Defines check. Uses libraries node:fs/promises, node:fs, node:path, node:url, node:vm. Side effects: changes the web page (DOM); reads or writes files; starts processes.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'topology'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: transformers, 400kV, 132kV.
- Inputs & outputs
- In: JSON file gb-transmission-network.v1.json. Voltage levels named: 400kV, 132kV.
- Downstream impact
- Used directly by 1 file: Local CI (gridatlas).
- What it achieves
- Run against the REAL product, not a fixture. Its code works with 400 kV, 132 kV and 100 MVA.
- Why it matters
- Run by Local CI.
- Application
- gridatlas · tools/proofs/modules · JavaScript module
- Uses
- node:fs/promises, node:fs, node:path, node:url, node:vm
- Used by
- run by Local CI (script call)
- Produces
- check
- Defines here
- check
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/proofs/modules/202609012145-network-topology.proof.mjs:1-269 · blob 3aa9ae712cbb40f91e773a7617e5e6b0397be134 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, process · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
/**
* Proof for the network-topology module.
*
* Run against the REAL product, not a fixture. A fixture proves the code
* agrees with a shape I wrote; the whole class of defect this estate keeps
* finding is the code agreeing with itself. The West Burton numbers below
* are checked against the published payload on disk, and the arithmetic-free
* disciplines - never mix a voltage, never decode a voltage, never compute
* with an impedance - are checked by construction on fixtures where the
* hostile case can actually be built.
*
* node tools/proofs/modules/202609012145-network-topology.proof.mjs
*/
import { readFile, access } from 'node:fs/promises';
import { constants, existsSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import vm from 'node:vm';
const HERE = dirname(fileURLToPath(import.meta.url));
const REPO = resolve(HERE, '..', '..', '..');
const REPO_PARENT = resolve(REPO, '..');
const ESTATE = existsSync(resolve(REPO_PARENT, 'data-grid-gb'))
? REPO_PARENT
: resolve(REPO, '..', '..');
const PRODUCT = resolve(ESTATE, 'data-grid-gb', 'derived',
'gb-transmission-network.v1.json');
let passed = 0;
const failures = [];
function check(label, condition, detail) {
if (condition) { passed += 1; console.log(' [PASS] ' + label); }
else {
failures.push(label + (detail ? ` — ${detail}` : ''));
console.log(' [FAIL] ' + label + (detail ? ` — ${detail}` : ''));
}
}
const box = { window: {}, console, Math, JSON, Number, String, Array, Object,
Map, Set, Boolean, Error, RegExp };
box.window.window = box.window;
vm.createContext(box);
const source = await readFile(
join(REPO, 'atlas', 'modules', '202609012145-network-topology.js'), 'utf8');
vm.runInContext(source, box, { filename: 'network-topology.js' });
const topology = box.window.__GRIDATLAS_MODULES__.networkTopology;
console.log('\nit fails closed on a shape it does not know\n');
check('the module loaded and froze its surface',
!!topology && Object.isFrozen(topology));
check('it names the one product it reads',
topology.accepts === 'data-grid-gb.transmission-network.v1');
check('an unrecognised schema yields no index at all',
topology.index({ schema: 'something.else.v9', nodes: [], sites: [] }) === null);
check('a v2 of the same product is still refused until it is read for',
topology.index({ schema: 'data-grid-gb.transmission-network.v2' }) === null);
check('null and undefined are refused, not defaulted',
topology.index(null) === null && topology.index(undefined) === null);
check('the refusal to assess is on the module itself',
/queue position/.test(topology.not_an_assessment)
&& /committed connections/.test(topology.not_an_assessment));
check('the impedance basis says what it is and is not',
/100 MVA base/.test(topology.impedance_basis)
&& /not a solved power flow/.test(topology.impedance_basis));
console.log('\nit never decodes a voltage, and never mixes two\n');
/* Hostile fixture. WBUR-shaped, but with one node the site does not
declare - the 726-node case the product warns about - and one 132 kV
and one 400 kV node, so a module that pooled them would be caught. */
const hostile = topology.index({
schema: 'data-grid-gb.transmission-network.v1',
sites: [
{ code: 'TEST', name: 'TEST SITE', transmission_owner: 'NGET', voltages_kv: [400, 132] },
{ code: 'FARA', name: 'FAR A', transmission_owner: 'NGET', voltages_kv: [400] },
{ code: 'FARB', name: 'FAR B', transmission_owner: 'NGET', voltages_kv: [132] }
],
nodes: [
{ node: 'TEST41', site_code: 'TEST', voltage_kv: 400, voltage_consistent_with_site: true },
{ node: 'TEST11', site_code: 'TEST', voltage_kv: 132, voltage_consistent_with_site: true },
// The product could not confirm this one against its site's declaration.
{ node: 'TEST31', site_code: 'TEST', voltage_kv: 275, voltage_consistent_with_site: false },
{ node: 'FARA41', site_code: 'FARA', voltage_kv: 400, voltage_consistent_with_site: true },
{ node: 'FARB11', site_code: 'FARB', voltage_kv: 132, voltage_consistent_with_site: true }
],
circuits: [
{ node_1: 'TEST41', node_2: 'FARA41', circuit_type: 'OHL', ohl_km: 20,
r_pct_100mva: 0.1, x_pct_100mva: 1.5, b_pct_100mva: 9, winter_mva: 3000 },
{ node_1: 'TEST11', node_2: 'FARB11', circuit_type: 'Cable', cable_km: 5,
r_pct_100mva: 2, x_pct_100mva: 8, b_pct_100mva: 1, winter_mva: 200 },
{ node_1: 'TEST31', node_2: 'FARA41', circuit_type: 'OHL', ohl_km: 3, winter_mva: 999 },
// Internal: both ends at this site. Not a neighbour.
{ node_1: 'TEST41', node_2: 'TEST11', circuit_type: 'OHL', ohl_km: 0.1, winter_mva: 100 }
],
transformers: [
{ node_1: 'TEST41', node_2: 'TEST11', rating_mva: 240, x_pct_100mva: 6 }
],
planned_changes: [
{ node_1: 'TEST41', node_2: 'FARA41', year: '2029/30', status: 'Planned', asset: 'Circuit' }
]
});
check('a known schema yields an index', !!hostile);
const all = hostile.at('TEST');
check('the site resolves by its code', all && all.site.code === 'TEST');
check('and by its exact published name', !!hostile.at('TEST SITE'));
check('a name that is not published resolves to nothing',
hostile.at('TEST SUBSTATION') === null && hostile.at('') === null);
const bands = Object.fromEntries(all.by_voltage.map(b => [String(b.voltage_kv), b]));
check('answers are grouped by voltage, never pooled',
all.by_voltage.length === 3 && '400' in bands && '132' in bands && 'null' in bands);
check('the highest voltage is first and the undeclared band is last',
all.by_voltage[0].voltage_kv === 400
&& all.by_voltage[all.by_voltage.length - 1].voltage_kv === null);
check('a node whose voltage its site does not declare is undeclared, not decoded',
bands.null.voltage_kv === null
&& all.nodes.find(n => n.node === 'TEST31').voltage_kv === null,
'TEST31 carries voltage_kv 275 and a false consistency flag');
check('nothing in the result carries a site-wide range',
!JSON.stringify(all).includes('min') && !JSON.stringify(all).includes('max'));
console.log('\nasking for one voltage returns only that voltage\n');
const only400 = hostile.at('TEST', { voltageKv: 400 });
check('one band comes back', only400.by_voltage.length === 1
&& only400.by_voltage[0].voltage_kv === 400);
check('the request is recorded in the answer', only400.requested_voltage_kv === 400);
check('no 132 kV circuit appears anywhere in it',
!JSON.stringify(only400).includes('FARB'));
check('and the unrestricted answer records that it restricted nothing',
all.requested_voltage_kv === null);
console.log('\nwhat is a neighbour, and what is not\n');
const neighbours = Object.fromEntries(all.neighbours.map(n => [n.site_code, n.circuits]));
check('a circuit to another site makes it a neighbour',
neighbours.FARA === 2 && neighbours.FARB === 1);
/* FARA is reached twice: once from TEST41 and once from TEST31, whose
voltage the site does not declare. I first expected 1 here and the
module was right - not knowing a node's voltage is not a reason to
forget that its circuit exists. The undeclared node is reported under
the undeclared band and still reaches the site it reaches. */
check('a node with an undeclared voltage still reaches the site it reaches',
bands.null.circuits.some(c => c.to_site_code === 'FARA')
&& bands.null.circuits.every(c => c.parameters_pct_100mva === null
|| typeof c.parameters_pct_100mva === 'object'));
check('a circuit with both ends at this site is not a neighbour',
!('TEST' in neighbours));
check('an internal circuit is still reported, flagged as internal',
bands['400'].circuits.some(c => c.within_this_site === true));
check('a transformer is not a neighbour either',
all.neighbours.length === 2);
check('a PLANNED change is not a neighbour: it is not built',
all.counts.planned_changes === 1 && all.neighbours.length === 2);
check('a planned change keeps its year and status',
bands['400'].planned_changes[0].year === '2029/30'
&& bands['400'].planned_changes[0].status === 'Planned');
console.log('\nit publishes parameters and computes nothing from them\n');
const circuit400 = bands['400'].circuits.find(c => c.to_site_code === 'FARA');
check('R, X and B travel as published percentages',
circuit400.parameters_pct_100mva.r_pct === 0.1
&& circuit400.parameters_pct_100mva.x_pct === 1.5
&& circuit400.parameters_pct_100mva.b_pct === 9);
check('seasonal ratings travel per season, never as one number',
circuit400.ratings_mva.winter === 3000
&& !('min' in circuit400.ratings_mva) && !('max' in circuit400.ratings_mva));
check('a circuit with no published parameters says so rather than guessing',
bands.null.circuits[0].parameters_pct_100mva === null);
check('a transformer carries its own rating, not a seasonal set',
bands['400'].transformers[0].rating_mva === 240
&& bands['400'].transformers[0].ratings_mva === undefined);
check('the module contains no impedance arithmetic at all',
!/x_pct[^\n]*[+*/-]\s*x_pct/.test(source)
&& !/Math\.(sqrt|atan|hypot)/.test(source),
'carrying a parameter is publishing; solving with it is a load flow');
check('the module never measures a distance',
!/distanceKm|haversine|6378|6371/.test(source));
console.log('\nthe refusal travels inside the answer\n');
check('every answer carries what it cannot tell you',
/queue position/.test(all.not_an_assessment)
&& /queue position/.test(only400.not_an_assessment));
check('every answer carries the impedance basis',
/100 MVA base/.test(all.impedance_basis));
check('no grading language anywhere in the module',
!/\b(strong|weak|good|poor|excellent|favourable|well[- ]placed|remote)\b/i
.test(source.replace(/remote/gi, '')));
let productPresent = true;
try { await access(PRODUCT, constants.R_OK); } catch { productPresent = false; }
/* A SKIP IS NOT A PASS.
------------------------------------------------------------------------
Codex, 202609012230: this pass silently skipped every real-payload
assertion when the sibling data-grid-gb checkout was absent - which is
the normal condition on an isolated CI checkout, i.e. exactly where the
proof would report green having tested nothing that matters.
The product is a hard requirement. Absent, this FAILS and says how to
satisfy it. An environment that genuinely cannot provide it must say so
out loud with GRIDATLAS_ALLOW_MISSING_PRODUCT=1, and that concession is
itself a check, so it appears in the output rather than being inferred
from a shorter list. */
const concession = process.env.GRIDATLAS_ALLOW_MISSING_PRODUCT === '1';
check('the published product this module reads is available',
productPresent || concession,
productPresent ? '' : `not found at ${PRODUCT} - clone Ventusltd/data-grid-gb `
+ 'beside this repository, or set GRIDATLAS_ALLOW_MISSING_PRODUCT=1 to '
+ 'accept an unverified run');
if (!productPresent) {
console.log('\n [concession] running without the published product by '
+ 'explicit opt-in; the real-payload assertions did NOT run and this '
+ 'result does not attest them');
} else {
console.log('\nand it answers correctly on the published payload\n');
const product = JSON.parse(await readFile(PRODUCT, 'utf8'));
const gb = topology.index(product);
check('the real product indexes', !!gb);
check('it indexes every published site and node',
gb.counts.sites === (product.sites || []).length
&& gb.counts.nodes === (product.nodes || []).length);
const wbur = gb.at('WBUR');
check('West Burton resolves and is NGET at 400 and 132 kV',
wbur.site.name === 'WEST BURTON' && wbur.site.transmission_owner === 'NGET'
&& wbur.site.voltages_kv.includes(400) && wbur.site.voltages_kv.includes(132));
check('its four published nodes are two at 400 kV and two at 132 kV',
wbur.nodes.length === 4
&& wbur.nodes.filter(n => n.voltage_kv === 400).length === 2
&& wbur.nodes.filter(n => n.voltage_kv === 132).length === 2);
check('every band it reports is a voltage the site declares',
wbur.by_voltage.every(b => b.voltage_kv === null
|| wbur.site.voltages_kv.includes(b.voltage_kv)));
const wbur400 = gb.at('WBUR', { voltageKv: 400 });
check('asking at 400 kV returns only the 400 kV band',
wbur400.by_voltage.length === 1 && wbur400.by_voltage[0].voltage_kv === 400);
check('the 400 kV band is a strict subset of the whole site',
wbur400.counts.circuits <= wbur.counts.circuits
&& wbur400.counts.circuits > 0);
console.log(` West Burton: ${wbur.counts.circuits} circuit landings, `
+ `${wbur.counts.transformers} transformer landings, `
+ `${wbur.counts.planned_changes} planned changes, `
+ `${wbur.counts.neighbour_sites} neighbouring sites`);
console.log(` at 400 kV: ${wbur400.counts.circuits} circuit landings, `
+ `${wbur400.counts.neighbour_sites} neighbouring sites`);
check('a neighbour is a real site with a real name',
wbur.neighbours.length > 0
&& wbur.neighbours.every(n => n.site_code && n.circuits > 0));
check('no neighbour is West Burton itself',
!wbur.neighbours.some(n => n.site_code === 'WBUR'));
const cottam = gb.at('COTT');
check('Cottam resolves too, and reports its published changes',
!!cottam && cottam.counts.planned_changes > 0);
check('a site that does not exist returns nothing rather than an empty shell',
gb.at('NOTASITE') === null);
}
console.log(`\n${passed}/${passed + failures.length} checks passed`);
if (failures.length) {
console.error('\nFAILURES');
for (const failure of failures) console.error(' ' + failure);
process.exit(1);
}
console.log('the topology module reports what is published, per voltage, '
+ 'and refuses to imply what it cannot know.');Map Click Network Proof
A JavaScript module in the proofs folder of GridAtlas that uses haversine.
rendergridatlas / tools/proofs/modules/202609012230-map-click-network.proof.mjs · lines 1–81 of 81 · version 2026-09-01 22:30 · Not reached from any entry point (candidate for review)
- What it does
- It loads data. Defines check. Uses libraries node:fs/promises, node:path, node:url, node:vm. Side effects: changes the web page (DOM); reads or writes files; starts processes.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (repository name word 'gridatlas'): 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: 400kV.
- Inputs & outputs
- Voltage levels named: 400kV.
- Downstream impact
- Used directly by 1 file: Local CI (gridatlas).
- What it achieves
- Defines `check`. Its code works with 400 kV.
- Why it matters
- Run by Local CI.
- Application
- gridatlas · tools/proofs/modules · JavaScript module
- Uses
- node:fs/promises, node:path, node:url, node:vm
- Used by
- run by Local CI (script call)
- Produces
- check
- Defines here
- check
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/proofs/modules/202609012230-map-click-network.proof.mjs:1-81 · blob 854c76757d53116aeb7e4c5cebec5faea981df65 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom, filesystem, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
import { readFile } from 'node:fs/promises';
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import vm from 'node:vm';
const REPO = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
const source = await readFile(join(REPO, 'atlas/modules/202609012230-map-click-network.js'), 'utf8');
const box = { window: {}, console, Map, Object, Array, String, Number };
vm.createContext(box);
vm.runInContext(source, box);
const module = box.window.__GRIDATLAS_MODULES__.mapClickNetwork;
let passed = 0;
const failures = [];
function check(label, condition) {
if (condition) { passed += 1; console.log(` [PASS] ${label}`); }
else { failures.push(label); console.log(` [FAIL] ${label}`); }
}
check('the module loads frozen and names its exact owner schema', Object.isFrozen(module)
&& module.accepts === 'data-grid-gb.map-click-network.v1');
check('unknown, missing and future schemas fail closed',
module.index(null) === null && module.index({ schema: 'data-grid-gb.map-click-network.v2' }) === null);
const fixture = {
schema: 'data-grid-gb.map-click-network.v1',
connection_points: [{
site_code: 'COTT', name: 'COTTAM', transmission_owner: 'NGET', voltages_kv: [400],
location: { lat: 53.300747, lon: -0.781375, matched_by: 'exact_name_highest_voltage' },
fault_current_by_voltage: {
'400': { peak: { voltages_kv: [400], metrics: {
three_phase_rms_break_current_ka: { min: 38.13, max: 50.61, unit: 'kA' }
} } }
},
existing_circuits: [
{ local_node: 'COTT41', remote_node: 'WBUR42', local_voltage_kv: 400,
remote_voltage_kv: 400, impedance_pct_100mva: { r: 0.1, x: 1, b: 8 },
seasonal_rating_mva: { winter: 3326, spring: 3000, summer: 2500, autumn: 3000 } },
{ local_node: 'COTT31', remote_node: 'UNKNOWN', local_voltage_kv: null,
remote_voltage_kv: null, impedance_pct_100mva: { r: 1, x: 2, b: 3 },
seasonal_rating_mva: { winter: 100, spring: null, summer: null, autumn: null } }
],
planned_changes: [{ local_node: 'COTT41', remote_node: 'MARH4B',
local_voltage_kv: 400, remote_voltage_kv: 400, year: '2028', status: 'Change' }],
transformers: [], reactive_compensation: [{ connection_kv: 400, type: 'Reactor' }],
interconnectors: [], projection_reconciliation: {
planned_changes_published: 17, planned_change_appearances: 16,
unresolved_planned_change_appearances: 1
}
}]
};
const index = module.index(fixture);
check('a recognised product indexes', index?.points === 1);
check('unknown and empty identities return null', index.at('NOPE') === null && index.at('') === null);
const noVoltage = index.at('COTT');
check('no declared voltage means no mixed electrical rows are returned',
noVoltage.connection_voltage_kv === null && noVoltage.fault_current === null
&& noVoltage.existing_circuits.length === 0 && noVoltage.planned_changes.length === 0);
const cottam = index.at('COTT', { connectionKv: 400 });
check('the declared 400 kV voltage selects only its published fault scope',
cottam.fault_current.peak.voltages_kv.length === 1
&& cottam.fault_current.peak.voltages_kv[0] === 400);
check('the undeclared-voltage circuit is refused rather than decoded from COTT31',
cottam.existing_circuits.length === 1 && cottam.existing_circuits[0].local_node === 'COTT41');
check('planned changes are filtered by explicit local voltage too',
cottam.planned_changes.length === 1 && cottam.planned_changes[0].local_voltage_kv === 400);
check('reactive equipment uses its explicit connection voltage',
cottam.reactive_compensation.length === 1);
check('reconciliation gaps travel with the useful answer',
cottam.reconciliation.unresolved_planned_change_appearances === 1);
check('the refusal travels beside every answer', /not solved power flow/.test(cottam.not_an_assessment)
&& /available headroom/.test(cottam.not_an_assessment)
&& /connection assessment/.test(cottam.not_an_assessment));
check('the module contains no voltage decoder or impedance arithmetic',
!/slice\(|substring\(|charAt\(|parseInt\(/.test(source)
&& !/Math\.(sqrt|hypot|atan|asin)/.test(source));
check('the module does not fetch, render or measure',
!/fetch\(|innerHTML|distanceKm|haversine|6378|6371/.test(source));
console.log(`\n${passed}/${passed + failures.length} checks passed`);
if (failures.length) process.exit(1);
console.log('the click consumer selects explicit voltage-scoped published facts and refuses inference.');Audit UKPN
A Python command-line tool in the secondary folder of GridAtlas that fetches grid 11kV UKPN, historical, UKPN transformers and UKPN sites, using SHA-256 from the data-grid-GB and data-GridAtlas repositories.
energy-datagridatlas / tools/secondary/audit_ukpn.py · lines 1–84 of 84 · Entry point · pattern acquire (shared by 10 files)
- What it does
- It fetches grid 11kV UKPN, historical, UKPN transformers and UKPN sites. Defines acquire, main. Uses libraries argparse, hashlib, json, subprocess, sys. Side effects: 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 (path word 'ukpn'): 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: data source: data-grid-gb data; data source: data-gridatlas data; Parquet file grid_11kv_ukpn.parquet; Parquet file historical.parquet; Parquet file ukpn_transformers.parquet; Parquet file ukpn_sites.parquet; DuckDB queries; command-line arguments. Out: JSON file audit.json.
- Downstream impact
- It is itself an entry point (Python CLI); no other file was found loading it.
- What it achieves
- It is built from the acquire step (`acquire`). Real-source network twin: two builds, independent SQL and legacy comparison. It accepts `--work`.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- gridatlas · tools/secondary · Python CLI
- Uses
- Import UKPN (script call), argparse, hashlib, json, subprocess, sys, time, urllib.request, pathlib
- Used by
- none found
- Produces
- acquire, main
- Defines here
- acquire, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/secondary/audit_ukpn.py:1-84 · blob 2a1a755bfaa392e15a9f8f16f8e67d84aa70edeb · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: filesystem, network, process, storage · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
"""Real-source network twin: two builds, independent SQL and legacy comparison.
Outputs are temporary, not production publication.
"""
import argparse
import hashlib
import json
import subprocess
import sys
import time
import urllib.request
from pathlib import Path
import duckdb
ARCHIVE = 'https://raw.githubusercontent.com/Ventusltd/data-grid-gb/2502549fed826106c70865047a540a170dd68919/ukpn-secondary/ukpn-secondary-site-transformers.zip'
OLD = 'https://raw.githubusercontent.com/Ventusltd/data-gridatlas/8bf88da9e210ce9f61dc0398869d3369f3fa2445/202608291237-data-gridatlas/data/partitions/grid_11kv_ukpn.parquet'
def acquire(url, dest, size, sha):
start=time.monotonic()
with urllib.request.urlopen(url,timeout=60) as response:
data=response.read(size+1)
if len(data)!=size or hashlib.sha256(data).hexdigest()!=sha:
raise ValueError('Pinned input size or hash mismatch')
dest.write_bytes(data)
return round(time.monotonic()-start,3)
def main():
parser=argparse.ArgumentParser()
parser.add_argument('--work',type=Path,required=True)
work=parser.parse_args().work.resolve()
work.mkdir(parents=True,exist_ok=True)
archive=work/'source.zip'
old=work/'historical.parquet'
download_seconds=acquire(ARCHIVE,archive,2068796,'c75933d86f4872a5f54712c0a945c283bb9038323a2ae9567df51ba3ce1b75c5')
acquire(OLD,old,1738387,'dc6af1cce4c78a211c634ceb6928d9179e2a787e1e43714b6528ac1987b79fef')
compiler=Path(__file__).with_name('import_ukpn.py')
builds=[]
timings=[]
for name in ('build-a','build-b'):
out=work/name
start=time.monotonic()
subprocess.run([sys.executable,str(compiler),str(archive),'--output',str(out)],check=True)
timings.append(round(time.monotonic()-start,3))
builds.append(out)
files=sorted(p.name for p in builds[0].iterdir())
assert files==sorted(p.name for p in builds[1].iterdir())
for name in files:
assert (builds[0]/name).read_bytes()==(builds[1]/name).read_bytes(), name
db=duckdb.connect()
for table,file in [('tx',builds[0]/'ukpn_transformers.parquet'),('sites',builds[0]/'ukpn_sites.parquet'),('legacy',old)]:
db.execute("CREATE TABLE "+table+" AS SELECT * FROM read_parquet(?)",[str(file)])
assert db.execute('SELECT count(*),count(DISTINCT transformer_id),count(DISTINCT site_id),count(longitude) FROM tx').fetchone()==(74719,74712,56309,56685)
assert db.execute('SELECT count(*),count(longitude) FROM sites').fetchone()==(56309,54558)
dup=db.execute("""SELECT count(*), coalesce(sum(n-1),0),
count(*) FILTER (WHERE sites>1),count(*) FILTER (WHERE variants>1)
FROM (SELECT transformer_id,count(*) n,count(DISTINCT site_id) sites,
count(DISTINCT feature_json) variants FROM tx GROUP BY transformer_id HAVING count(*)>1)""").fetchone()
assert dup[1]==7
old_count=db.execute('SELECT count(*) FROM legacy').fetchone()[0]
assert old_count==15126
db.execute("""CREATE TABLE legacy_points AS SELECT
feature_id, json_extract_string(properties_json,'$.name') AS name,
json_extract_string(properties_json,'$.operator') AS operator,
json_extract_string(properties_json,'$.voltage') AS voltage,
try_cast(json_extract(geometry_json,'$.coordinates[0]') AS DOUBLE) AS lon,
try_cast(json_extract(geometry_json,'$.coordinates[1]') AS DOUBLE) AS lat
FROM legacy""")
matches=db.execute("""SELECT count(*) FROM legacy_points l WHERE EXISTS
(SELECT 1 FROM sites s WHERE round(l.lon,6)=round(s.longitude,6)
AND round(l.lat,6)=round(s.latitude,6))""").fetchone()[0]
id_matches=db.execute("""SELECT count(*) FROM legacy_points l WHERE EXISTS
(SELECT 1 FROM sites s WHERE l.feature_id=s.site_id OR l.name=s.site_id)""").fetchone()[0]
estimates=db.execute("""SELECT count(*) FILTER (WHERE lower(coalesce(operator,'')) LIKE '%est%'),
count(*) FILTER (WHERE lower(coalesce(voltage,'')) LIKE '%est%'),
count(*) FILTER (WHERE feature_id IS NULL) FROM legacy_points""").fetchone()
receipt=dict(source_download_seconds=download_seconds, compiler_seconds=timings,
deterministic_files=files, duplicate_identifier_groups=dup[0], excess_rows=int(dup[1]),
duplicate_groups_crossing_sites=dup[2], duplicate_groups_with_distinct_records=dup[3],
legacy_rows=old_count, legacy_coordinate_matches_6dp=matches, legacy_exact_identity_matches=id_matches,
legacy_estimated_operator_rows=estimates[0],legacy_estimated_voltage_rows=estimates[1],
legacy_missing_feature_id_rows=estimates[2],
interpretation='Coordinate coincidence is not proof of identity. Historical partition remains quarantined.')
(work/'audit.json').write_text(json.dumps(receipt,indent=2)+'\n',encoding='utf-8')
print('UKPN DATA AUDIT '+json.dumps(receipt,sort_keys=True))
if __name__=='__main__':
main()