In this section
- Browser energy-data · globalgrid2050 / automation/v932_preview/browser.mjs lines 1–373
- Contracts Test test · globalgrid2050 / automation/v932_preview/contracts.test.mjs lines 1–137
- Invariants storage · globalgrid2050 / automation/v932_preview/invariants.mjs lines 1–135
Browser
A JavaScript module in the automation folder of GlobalGrid2050 that verifies primary (`verifyPrimary`) and locations (`verifyLocations`), resets price trace (`resetPriceTrace`) and draws on a canvas (units: MWh, MW), using SHA-256.
energy-dataglobalgrid2050 / automation/v932_preview/browser.mjs · lines 1–373 of 373 · Entry point · pattern existingBriefLinks (shared by 2 files)
- What it does
- It draws DC locations, primary notes, prices and the REPD register. Defines 25 functions or classes, including sha, priceBytes, urlFor, pass, download. Uses libraries node:assert/strict, node:http, node:crypto, node:child_process, node:fs. Side effects: changes the web page (DOM); reads or writes files; makes network requests; starts processes.
- Why it exists in the grid workflow
- Domain terms in the code: the REPD register.
- Inputs & outputs
- In: JSON file dc-locations.v930.json; JSON file primary-notes.v932.json; JSON file notes.json; JSON file build_manifest.json; JSON file prices.v931.json; JSON file index.json; JSON file 2026.json; JSON file 2025.json. Out: JSON file browser.json; canvas drawing.
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 V932 Preview Acceptance Workflow (globalgrid2050).
- What it achieves
- It verifies primary (`verifyPrimary`), verifies locations (`verifyLocations`) and resets price trace (`resetPriceTrace`). Real integrated V9.32 browser acceptance against exact source-byte fixtures. Its code works with 840 MW.
- Why it matters
- Run by GlobalGrid2050 V932 Preview Acceptance Workflow.
- Application
- globalgrid2050 · automation/v932_preview · JavaScript module
- Uses
- node:assert/strict, node:http, node:crypto, node:child_process, node:fs, node:path, node:os, node:url
- Used by
- run by GlobalGrid2050 V932 Preview Acceptance Workflow (workflow run)
- Produces
- sha, priceBytes, urlFor, pass, download, open, fullWidth, painted, settleTouch, touchTap, touchDrag, orientationScreenshot
- Defines here
- sha, priceBytes, urlFor, pass, download, open, fullWidth, painted, settleTouch, touchTap, touchDrag, orientationScreenshot, tab, allRepd, headlineHas, noteButton, existingBriefLinks, verifyPrimary, dcOriginalLinks, dcGlobal, verifyLocations, resetPriceTrace, priceRange, assertPriceDrawing, verifyPrices
- 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/v932_preview/browser.mjs:1-373 · blob 0a13a5ceaa2523f70f84707818fad1594877b85d · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, network, process · domain stage: unknown · users: none · canonical: production_core
/** Real integrated V9.32 browser acceptance against exact source-byte fixtures. */
import assert from 'node:assert/strict';
import {createServer} from 'node:http';
import {createHash} from 'node:crypto';
import {execFileSync} from 'node:child_process';
import {readFileSync,writeFileSync,mkdirSync,statSync,existsSync} from 'node:fs';
import {dirname,resolve,relative,extname,sep} from 'node:path';
import {tmpdir} from 'node:os';
import {fileURLToPath,pathToFileURL} from 'node:url';
const ROOT=resolve(dirname(fileURLToPath(import.meta.url)),'../..');
const EDITION=process.env.V932_CANDIDATE||'uk_renewables_pipeline/202611170324';
const candidate=resolve(ROOT,EDITION),baseline=resolve(ROOT,'uk_renewables_pipeline/202611170243');
const OUT=resolve(process.env.V932_OUT||resolve(tmpdir(),'gg2050-v932-preview'));
const {chromium}=process.env.V932_PLAYWRIGHT
? await import(pathToFileURL(resolve(process.env.V932_PLAYWRIGHT))) : await import('playwright');
const {catalogue}=await import(pathToFileURL(resolve(candidate,'scripts/layers/catalogue.mjs')));
const sha=b=>createHash('sha256').update(b).digest('hex');
mkdirSync(OUT,{recursive:true});
const receipt={status:'RUNNING',utc:new Date().toISOString(),head:execFileSync('git',['rev-parse','HEAD'],{cwd:ROOT,encoding:'utf8'}).trim(),edition:EDITION,index_sha256:sha(readFileSync(resolve(candidate,'index.html'))),checks:[],sources:[],blocked_external:[],limitations:[
'Local integrated browser proof; no deployment, public served-byte or native-phone acceptance.',
'Pinned GridAtlas source bytes are replayed exactly; no claim of fresh network-state data or typed substation arrival.',
'External feeds, Chart.js CDN and original V6 workspace navigation are blocked; saved news and the independently linked workspace are tested.',
'Prices are historical Elexon system-sell observations grouped by source-declared settlement date; complete source-day coverage does not certify stored UTC alignment.',
'Android UA, touch gestures and screen orientation are Chromium emulation on this host, not a native Android handset/browser process.',
'All-row MAP construction is checked separately; this browser suite does not execute the public GridAtlas receiver.']};
const sourceBytes=new Map();
const locationSpec=JSON.parse(readFileSync(resolve(candidate,'contracts/dc-locations.v930.json')));
let locationBytes;
if(process.env.V932_DATA_SOURCE)locationBytes=readFileSync(resolve(process.env.V932_DATA_SOURCE));
else{const response=await fetch(locationSpec.input.url,{redirect:'error',signal:AbortSignal.timeout(15000)});assert.ok(response.ok);locationBytes=Buffer.from(await response.arrayBuffer());}
assert.equal(locationBytes.length,183561);assert.equal(sha(locationBytes),'6f68e078d9b57057acdda679288730e638553f68df884dfd747c5049e56ea88e');
const locationData=JSON.parse(locationBytes),byId=new Map(locationData.features.map(f=>[f.id,f]));
sourceBytes.set(locationSpec.input.url,locationBytes);
receipt.sources.push({id:'dc-address-locations',url:locationSpec.input.url,sha256:sha(locationBytes),bytes:locationBytes.length,transport:process.env.V932_DATA_SOURCE?'explicit data-owner fixture, exact immutable bytes':'immutable HTTPS source'});
let baselineDCLinks,baselineDCCsv,baselineHeadlineHas,baselineNoteButtons={},baselineHeadlineLinks=[];
const primarySpec=JSON.parse(readFileSync(resolve(candidate,'contracts/primary-notes.v932.json')));
const primaryCache=resolve(ROOT,'automation/primary_note_ui',primarySpec.producer.commit),primaryData=JSON.parse(readFileSync(resolve(primaryCache,'notes.json'))),primaryNote=primaryData.notes[0];
const canonicalManifest=JSON.parse(readFileSync(resolve(candidate,'data/v9.1/build_manifest.json'))),canonicalRefs=canonicalManifest.project_partitions.flatMap(p=>JSON.parse(readFileSync(resolve(candidate,p.path))).projects.map(r=>r.repd_ref));
receipt.sources.push({id:'curated-primary-government-decision',producer:primarySpec.producer.commit,pdf_sha256:primaryNote.source.sha256,pdf_bytes:primaryNote.source.bytes,decision_date:primaryNote.claim.decision_date,retrieved_at:primaryNote.source.retrieved_at,transport:'exact local reviewed cartridge; no fresh PDF/terms request'});
const priceSpec=JSON.parse(readFileSync(resolve(candidate,'contracts/prices.v931.json')));
const priceModel=await import(pathToFileURL(resolve(ROOT,'automation/price_daily_ui',priceSpec.producer.commit,'model.mjs')));
async function priceBytes(name,pin){
let raw;if(process.env.V932_PRICE_SOURCE)raw=readFileSync(resolve(process.env.V932_PRICE_SOURCE,name));
else{const response=await fetch(priceSpec.input.base+name,{redirect:'error',signal:AbortSignal.timeout(15000)});assert.ok(response.ok);raw=Buffer.from(await response.arrayBuffer());}
assert.equal(raw.length,pin.bytes);assert.equal(sha(raw),pin.sha256);sourceBytes.set(priceSpec.input.base+name,raw);return raw;
}
const priceIndex=priceModel.validateIndex(JSON.parse(await priceBytes('index.json',priceSpec.input.index))),priceYears=new Map();
await Promise.all(priceIndex.parts.map(async part=>priceYears.set(part.year,{...JSON.parse(await priceBytes(part.path,part))})));
receipt.sources.push({id:'historical-daily-system-sell',repository:priceSpec.input.repository,commit:priceSpec.input.commit,index_sha256:priceSpec.input.index.sha256,index_bytes:priceSpec.input.index.bytes,annual_parts:priceIndex.parts.length,transport:process.env.V932_PRICE_SOURCE?'explicit existing owner bytes, every pin checked then replayed':'immutable HTTPS owner bytes, every pin checked then … [line shortened here: 413 characters; full line on GitHub]
for(const layer of catalogue.layers.filter(l=>l.data)){
let raw,transport;
try{const response=await fetch(layer.data.url,{signal:AbortSignal.timeout(12000),redirect:'error'});if(!response.ok)throw Error('HTTP '+response.status);raw=Buffer.from(await response.arrayBuffer());transport='immutable HTTPS URL';}
catch{
if(!process.env.GRIDATLAS_SOURCE)throw Error('Pinned source transport failed; set GRIDATLAS_SOURCE to an existing owner checkout for exact-byte replay.');
const rel=new URL(layer.data.url).pathname.split('/').slice(4).join('/');
raw=readFileSync(resolve(process.env.GRIDATLAS_SOURCE,rel));transport='existing owner checkout, exact pinned bytes';
}
assert.equal(sha(raw),layer.data.sha256,layer.id+' actual source SHA256');assert.ok(raw.length<=layer.data.maxBytes);
const doc=JSON.parse(raw);assert.equal(doc.features.length,layer.data.rows);
sourceBytes.set(layer.data.url,raw);receipt.sources.push({id:layer.id,url:layer.data.url,sha256:sha(raw),bytes:raw.length,rows:doc.features.length,transport});
}
const subs=JSON.parse(sourceBytes.get(catalogue.layers.find(l=>l.id==='substations').data.url));
const named=subs.features.filter(f=>typeof f.properties?.name==='string'&&f.properties.name.trim()).length;
assert.equal(named,4460);assert.equal(subs.features.length-named,1340);
const mime={'.html':'text/html','.mjs':'text/javascript','.js':'text/javascript','.css':'text/css','.json':'application/json','.geojson':'application/json','.svg':'image/svg+xml','.png':'image/png'};
const server=createServer((req,res)=>{try{let p=resolve(ROOT,'.'+decodeURIComponent(new URL(req.url,'http://local').pathname));if(!p.startsWith(ROOT+sep)){res.writeHead(403).end();return;}if(statSync(p).isDirectory())p=resolve(p,'index.html');res.writeHead(200,{'Content-Type':mime[extname(p)]||'application/octet-stream','Cache-Control':'no-store'});res.end(readFileSync(p));}catch{res.writeHead(404 … [line shortened here: 412 characters; full line on GitHub]
await new Promise(r=>server.listen(0,'127.0.0.1',r));const origin='http://127.0.0.1:'+server.address().port;
const urlFor=dir=>origin+'/'+relative(ROOT,dir).replaceAll('\\','/')+'/';
const pass=(name,details={})=>{receipt.checks.push({name,status:'PASS',...details});console.log('PASS:',name);};
function csv(text){const records=[];let row=[],cell='',quoted=false;text=text.replace(/^\ufeff/,'');for(let i=0;i<text.length;i++){const c=text[i];if(c==='"'&"ed&&text[i+1]==='"'){cell+='"';i++;}else if(c==='"')quoted=!quoted;else if(c===','&&!quoted){row.push(cell);cell='';}else if((c==='\n'||c==='\r')&&!quoted){if(c==='\r'&&text[i+1]==='\n')i++;row.push(cell);records.push(row);row=[];cell='' … [line shortened here: 514 characters; full line on GitHub]
async function download(page,button,name){const event=page.waitForEvent('download');await button.click();const d=await event,p=resolve(OUT,name);await d.saveAs(p);const raw=readFileSync(p);return{rows:csv(raw.toString('utf8')),sha256:sha(raw)};}
async function open(browser,width,folder,{corrupt=false,reducedMotion=false,mobile=false,height=1000}={}){
const context=await browser.newContext({viewport:{width,height},acceptDownloads:true,reducedMotion:reducedMotion?'reduce':'no-preference',
...(mobile?{isMobile:true,hasTouch:true,deviceScaleFactor:2.625,userAgent:'Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/159.0.0.0 Mobile Safari/537.36'}:{})}),page=await context.newPage(),errors=[],requests=[];
page.on('pageerror',e=>errors.push(e.message));
await context.route('**/*',route=>{const u=route.request().url();requests.push(u);
if(u.startsWith(origin+'/')){
const pathname=new URL(u).pathname;
const manifest=(corrupt==='dc-manifest'&&pathname.endsWith('/contracts/dc-locations.v930.json'))||(corrupt==='price-manifest'&&pathname.endsWith('/contracts/prices.v931.json'));
const module=(corrupt==='dc-module'&&pathname.endsWith('/automation/dc_location_ui/'+locationSpec.producer.commit+'/actions.mjs'))||(corrupt==='price-module'&&pathname.endsWith('/automation/price_daily_ui/'+priceSpec.producer.commit+'/view.mjs'));
const primaryManifest=corrupt==='primary-manifest'&&pathname.endsWith('/contracts/primary-notes.v932.json');
const primaryPaths={'primary-model':'model.mjs','primary-catalogue':'catalogue.mjs','primary-json':'notes.json','primary-mime':'notes.json'};
const primaryFile=primaryPaths[corrupt]&&pathname.endsWith('/automation/primary_note_ui/'+primarySpec.producer.commit+'/'+primaryPaths[corrupt]);
const primaryRenderer=corrupt==='primary-renderer'&&pathname.endsWith('/'+primarySpec.renderer.path);
if(primaryManifest||primaryFile||primaryRenderer){const raw=readFileSync(resolve(ROOT,'.'+pathname)),json=pathname.endsWith('.json');return route.fulfill({status:200,contentType:corrupt==='primary-mime'?'text/plain':json?'application/json':'text/javascript',body:corrupt==='primary-mime'?raw:Buffer.concat([raw,Buffer.from(' ')])});}
if(manifest||module){const raw=readFileSync(resolve(ROOT,'.'+pathname));return route.fulfill({status:200,contentType:module?'text/javascript':'application/json',body:Buffer.concat([raw,Buffer.from(' ')])});}
return route.continue();
}
if(sourceBytes.has(u)){let raw=sourceBytes.get(u);if((corrupt===true&&u===catalogue.layers.find(l=>l.id==='substations').data.url)||(corrupt==='dc-source'&&u===locationSpec.input.url)||(corrupt==='price-index'&&u===priceSpec.input.base+'index.json')||(corrupt==='price-year'&&u===priceSpec.input.base+'2026.json'))raw=Buffer.concat([raw,Buffer.from(' ')]);return route.fulfill({status:200,content … [line shortened here: 493 characters; full line on GitHub]
await context.addInitScript(()=>{
window.__pricePaths=[];window.__priceLabels=[];window.__priceHollow=0;const paths=new WeakMap(),arcs=new WeakMap();
for(const name of ['beginPath','moveTo','lineTo','stroke','fillText','arc','fill']){const original=CanvasRenderingContext2D.prototype[name];CanvasRenderingContext2D.prototype[name]=function(...args){
if(this.canvas.closest('.pn-daily-prices')){
if(name==='beginPath'){paths.set(this,[]);arcs.delete(this);}
if(name==='moveTo'||name==='lineTo'){const p=paths.get(this)||[];p.push({kind:name,x:args[0],y:args[1]});paths.set(this,p);}
if(name==='stroke'&&['#00ffff','#ffcc00','#ff3333'].includes(this.strokeStyle)&&(paths.get(this)||[]).length)window.__pricePaths.push({color:this.strokeStyle,points:paths.get(this).map(p=>({...p}))});
if(name==='fillText')window.__priceLabels.push(String(args[0]));
if(name==='arc')arcs.set(this,args[2]);
if(name==='fill'&&arcs.get(this)===3&&this.fillStyle==='#05070c')window.__priceHollow++;
}return original.apply(this,args);
};}
});
if(corrupt==='primary-evaluation')await context.addInitScript(()=>{const OriginalDate=Date;window.Date=class extends OriginalDate{constructor(...args){super(...(args.length?args:['2026-11-17T03:16:19.999Z']));}static now(){return new OriginalDate('2026-11-17T03:16:19.999Z').getTime();}};});
await page.goto(urlFor(folder),{waitUntil:'domcontentloaded'});await page.waitForFunction(()=>Number(document.getElementById('tbody')?.dataset.total)>0);
return{context,page,errors,requests};
}
async function fullWidth(page){
const layout=await page.evaluate(()=>{const main=document.querySelector('main'),r=main.getBoundingClientRect(),s=getComputedStyle(main),b=getComputedStyle(document.body),h=getComputedStyle(document.documentElement);return{viewport:innerWidth,mainLeft:r.left,mainWidth:r.width,mainMarginLeft:s.marginLeft,documentWidth:document.documentElement.scrollWidth,mainOverflowY:s.overflowY,bodyDisplay:b.dis … [line shortened here: 563 characters; full line on GitHub]
assert.equal(layout.asideCount,0,'removed sidebar has no visible or hidden DOM remnant');assert.ok(Math.abs(layout.mainLeft)<=1,'main begins at viewport left: '+JSON.stringify(layout));assert.ok(Math.abs(layout.mainWidth-layout.viewport)<=2,'main uses full viewport width: '+JSON.stringify(layout));assert.ok(layout.documentWidth<=layout.viewport+2,'document has no lateral overflow: '+JSON.stringi … [line shortened here: 589 characters; full line on GitHub]
return layout;
}
async function painted(page,selector){
const target=page.locator(selector).first();await target.scrollIntoViewIfNeeded();
const paint=await target.evaluate(n=>{
const r=n.getBoundingClientRect(),s=getComputedStyle(n);
let left=Math.max(0,r.left),right=Math.min(innerWidth,r.right),top=Math.max(0,r.top),bottom=Math.min(innerHeight,r.bottom);
// A wide table row may begin offscreen after native horizontal scrolling.
// Test the visible intersection, including the scroll container's borders.
for(let a=n.parentElement;a;a=a.parentElement){
if(a===document.documentElement)continue; // Root scrolling clips to the viewport above.
const style=getComputedStyle(a),box=a.getBoundingClientRect();
if(/auto|scroll|hidden|clip/.test(style.overflowX)){left=Math.max(left,box.left+a.clientLeft);right=Math.min(right,box.left+a.clientLeft+a.clientWidth);}
if(/auto|scroll|hidden|clip/.test(style.overflowY)){top=Math.max(top,box.top+a.clientTop);bottom=Math.min(bottom,box.top+a.clientTop+a.clientHeight);}
}
const x=(left+right)/2,y=(top+bottom)/2,hit=right>left&&bottom>top?document.elementFromPoint(x,y):null;
return{width:r.width,height:r.height,top:r.top,left:r.left,visible:{left,right,top,bottom},hitPoint:{x,y},display:s.display,visibility:s.visibility,opacity:s.opacity,text:n.textContent.trim().slice(0,120),hit:!!hit&&(n===hit||n.contains(hit)),viewport:{width:innerWidth,height:innerHeight}};
});
assert.ok(paint.width>0&&paint.height>0&&paint.display!=='none'&&paint.visibility==='visible'&&Number(paint.opacity)>0&&paint.text.length>0&&paint.hit,'visible painted target '+selector+': '+JSON.stringify(paint));return paint;
}
async function settleTouch(page){await page.evaluate(async()=>{let previous='',stable=0;const end=performance.now()+2500;while(performance.now()<end){await new Promise(requestAnimationFrame);const state=[scrollY,visualViewport.pageTop,...[...document.querySelectorAll('.tablewrap')].map(n=>n.scrollLeft)].join('|');if(state===previous)stable++;else stable=0;previous=state;if(stable>=8)return;}});}
async function touchTap(page,selector){await settleTouch(page);await page.locator(selector).first().tap();}
async function touchDrag(session,{x,y,dx=0,dy=0}){
await session.send('Input.dispatchTouchEvent',{type:'touchStart',touchPoints:[{x,y,id:1,radiusX:2,radiusY:2,force:1}]});
for(let step=1;step<=10;step++){await session.send('Input.dispatchTouchEvent',{type:'touchMove',touchPoints:[{x:x+dx*step/10,y:y+dy*step/10,id:1,radiusX:2,radiusY:2,force:1}]});await new Promise(r=>setTimeout(r,16));}
await session.send('Input.dispatchTouchEvent',{type:'touchEnd',touchPoints:[]});
}
async function orientationScreenshot(session,name,size){
// Playwright's screenshot helper restores its cached context viewport. Capture
// directly through CDP so synthetic landscape metrics remain unchanged.
const result=await session.send('Page.captureScreenshot',{format:'png',fromSurface:true,captureBeyondViewport:false});
const png=Buffer.from(result.data,'base64'),width=png.readUInt32BE(16),height=png.readUInt32BE(20);
assert.ok(Math.abs(width/height-size.width/size.height)<.005,'PNG must match actual requested orientation: '+JSON.stringify({name,width,height,requested:size}));
writeFileSync(resolve(OUT,name),png);return{file:name,width,height,sha256:sha(png)};
}
async function tab(page,id){await page.locator('#'+id).click();await page.waitForFunction(id=>document.getElementById(id)?.getAttribute('aria-selected')==='true',id);const panel=await page.locator('#'+id).getAttribute('aria-controls');assert.equal(await page.locator('#'+panel).isVisible(),true);}
async function allRepd(page){await tab(page,'solarTab');await page.locator('#clearFilters').click();await page.waitForFunction(()=>document.getElementById('tbody')?.dataset.total==='7775');}
async function headlineHas(page){return page.evaluate(refs=>Object.fromEntries(refs.map(ref=>[ref,window.pipelineMachineNotes.has(ref)])),canonicalRefs);}
async function noteButton(page,ref){
await page.locator('#search').fill(ref);await page.waitForFunction(ref=>!!document.getElementById('repd-'+ref),ref);
const selector='#repd-'+ref+' .machine-note-button:visible',button=page.locator(selector).first();await painted(page,selector);return button;
}
async function existingBriefLinks(page){return page.locator('.machine-note-dialog .machine-note-source a').evaluateAll(nodes=>nodes.map(n=>({href:n.href,text:n.textContent})));}
async function verifyPrimary(page,width,requests){
await page.waitForFunction(()=>document.documentElement.dataset.primaryNotesState==='available');assert.deepEqual(await headlineHas(page),baselineHeadlineHas,'primary source does not alter any of7775 legacy headline.has booleans');
const requestsBefore=requests.filter(u=>u.includes('/data/v9.1/projects/')).length;
await allRepd(page);const button=await noteButton(page,'12588'),map=await page.locator('#repd-12588 .atlaslink').getAttribute('href');assert.match(await button.innerText(),/PROVISIONAL.*GOVERNMENT DECISION.*10 NOV 2026/s);
assert.deepEqual(await page.locator('[data-note-primary]').evaluateAll(nodes=>[...new Set(nodes.map(n=>n.dataset.noteRef))]),['12588']);await button.click();
const dialog=page.locator('.machine-note-dialog[open]');assert.equal(await dialog.count(),1);assert.equal(await dialog.locator('.machine-note-primary').count(),1);assert.equal(await page.locator('main > section').count(),2);
const text=await dialog.innerText();assert.match(text,/PRIMARY GOVERNMENT SOURCE - PROVISIONAL PROJECT ASSOCIATION/);assert.match(text,/OFFICIAL SOURCE STATUS \(FROZEN REPD\).*Application Submitted/);assert.match(text,/Primary government decision/);assert.match(text,/10 Nov 2026/);assert.match(text,/11 November|2026-11-11/);
const primary=dialog.locator('.machine-note-primary');assert.equal(await primary.getByRole('link',{name:'Open the government decision letter',exact:true}).getAttribute('href'),primaryNote.source.url);assert.deepEqual(await dialog.locator('.machine-note-source:not(.machine-note-primary) a').evaluateAll(nodes=>nodes.map(n=>({href:n.href,text:n.textContent}))),baselineHeadlineLinks);
const details=primary.locator('details');assert.equal(await details.getAttribute('open'),null);await details.locator('summary').click();const qualified=await primary.innerText();
for(const expected of ['Application Submitted','14 Nov 2024','15 Nov 2024','840 MW','final reduced capacity is not established','judicial review status remain unknown',primaryNote.source.retrieved_at,primaryNote.source.sha256,'1,247,918 bytes',primaryNote.rights.attribution,'government-authored decision facts','third-party','No official endorsement'])assert.ok(qualified.includes(expected),expect … [line shortened here: 442 characters; full line on GitHub]
assert.equal(await primary.getByRole('link',{name:'Open Government Licence v3.0',exact:true}).getAttribute('href'),primaryNote.rights.licence_url);assert.doesNotMatch(await primary.innerText(),/VERIFIED association|final (?:reduced )?capacity (?:is|of) 840/i);
await page.screenshot({path:resolve(OUT,`v932-primary-brief-${width}.png`)});await page.keyboard.press('Escape');assert.equal(await page.locator('.machine-note-dialog[open]').count(),0);assert.equal(await button.evaluate(n=>n===document.activeElement),true,'native dialog restores opener focus');assert.equal(await page.locator('#repd-12588 .atlaslink').getAttribute('href'),map);
for(const ref of ['10529','18174']){const other=await noteButton(page,ref);assert.equal(await other.getAttribute('data-note-primary'),null);assert.equal(await other.innerText(),baselineNoteButtons[ref]);}
await allRepd(page);await page.locator('.pager-btn[data-page-step="1"]').click();await page.waitForFunction(()=>document.querySelector('.pager-meta')?.textContent.includes('21'));assert.equal(await page.locator('#tbody').getAttribute('data-total'),'7775');
const again=await noteButton(page,'12588');assert.equal(await again.getAttribute('data-note-primary'),'provisional');assert.equal(requests.filter(u=>u.includes('/data/v9.1/projects/')).length,requestsBefore,'opening/filtering primary notes does not refetch canonical partitions');
await allRepd(page);pass('unique12588 provisional primary brief preserves7775 headline.has states, original headline links, frozen status, dates/rights/nulls, MAP, keyboard focus and rerenders',{width});
}
async function dcOriginalLinks(page){return page.locator('#datacentreHost tbody tr').evaluateAll(rows=>Object.fromEntries(rows.map(row=>[row.querySelector('.ggdc-id')?.textContent.trim(),[...row.querySelectorAll('a')].filter(a=>!a.closest('.ggdc-location-actions')).map(a=>a.href)])));}
async function dcGlobal(page){await page.locator('#datacentreHost').getByRole('button',{name:/^Global leads/}).click();await page.waitForFunction(()=>document.querySelectorAll('#datacentreHost tbody tr').length===100);}
async function verifyLocations(page,width){
await page.waitForFunction(()=>document.getElementById('datacentreHost')?.dataset.locationsState==='available');
assert.equal(await page.locator('#datacentreHost .ggdc-screen-actions').count(),34);
await dcGlobal(page);await page.waitForFunction(()=>document.querySelectorAll('#datacentreHost .ggdc-reported-address').length===38);
assert.equal(await page.locator('#datacentreHost .ggdc-reported-address > p').count(),39);
const actual=await page.locator('#datacentreHost tbody tr').evaluateAll(rows=>rows.map(row=>({id:row.querySelector('.ggdc-id')?.textContent.trim(),addresses:[...row.querySelectorAll('.ggdc-reported-address > p')].map(n=>n.textContent),screen:!!row.querySelector('.ggdc-screen-actions')})));
for(const row of actual){const feature=byId.get(row.id);assert.ok(feature,'exact original ID');assert.deepEqual(row.addresses,feature.properties.addresses.map(a=>a.text));assert.equal(row.screen,!!feature.geometry&&feature.properties.country.code==='GB');}
assert.equal(actual.filter(x=>x.screen).length,34);assert.deepEqual(await dcOriginalLinks(page),baselineDCLinks);
assert.equal(await page.locator('#datacentreHost .ggdc-screen-location').allTextContents().then(x=>x.filter(v=>v.startsWith('Approx. postcode:')).length),25);
assert.equal(await page.locator('#datacentreHost .ggdc-screen-footnote').count(),1);assert.match(await page.locator('#datacentreHost .ggdc-screen-footnote').innerText(),/UK screening coverage.*not a grid-capacity assessment/);
const disclosure=page.locator('#datacentreHost .ggdc-location-sources');assert.equal(await disclosure.count(),1);assert.equal(await disclosure.getAttribute('open'),null);
await disclosure.locator('summary').click();const text=await disclosure.innerText();for(const credit of [...new Set(locationData.features.flatMap(f=>f.properties.location_precision==='POSTCODE_CENTROID_APPROXIMATE'?f.properties.geometry_attribution:[]))])assert.ok(text.includes(credit));
assert.equal(await disclosure.getByRole('link',{name:'Source GeoJSON (100 records)'}).getAttribute('href'),locationSpec.input.url);
assert.equal(await disclosure.getByRole('link',{name:'Postcode-provider terms'}).getAttribute('href'),'https://postcodes.io/docs/licences/');await disclosure.locator('summary').click();
const exported=await download(page,page.locator('#datacentreHost button.ggdc-download'),`v932-dc-global-${width}.csv`);assert.deepEqual(exported.rows,baselineDCCsv.rows,'optional locations never rewrite original100-record CSV');
const search=page.getByRole('searchbox',{name:'Search Data Centre records'});
for(const feature of [locationData.features.find(f=>f.properties.country.code!=='GB'&&f.properties.addresses.length),locationData.features.find(f=>!f.geometry&&f.properties.addresses.length)]){
assert.ok(feature,'real foreign/null-geometry address fixture exists');await search.fill(feature.id);await page.waitForFunction(()=>document.querySelectorAll('#datacentreHost tbody tr').length===1);
assert.deepEqual(await page.locator('#datacentreHost .ggdc-reported-address > p').allTextContents(),feature.properties.addresses.map(a=>a.text));assert.equal(await page.locator('#datacentreHost .ggdc-screen-actions').count(),0);
}
await search.fill('CyrusOne LON1');await page.waitForFunction(()=>document.querySelectorAll('#datacentreHost .ggdc-screen-actions').length===1);assert.match(await page.locator('#datacentreHost .ggdc-screen-location').innerText(),/Approx\. postcode/);
await tab(page,'solarTab');await tab(page,'datacentreTab');assert.equal(await search.inputValue(),'CyrusOne LON1');assert.equal(await page.locator('#datacentreHost .ggdc-location-sources').count(),1);assert.equal(await page.locator('#datacentreHost .ggdc-screen-footnote').count(),1);
await search.fill('');await page.waitForFunction(()=>document.querySelectorAll('#datacentreHost .ggdc-reported-address').length===38);
await painted(page,'#datacentreHost tbody tr');await page.screenshot({path:resolve(OUT,`v932-dc-global-${width}.png`)});
pass('actual host100ID join/38addressrecords/39statements/34GBScreen/source links and originalCSV preserved across filters',{width});
}
async function resetPriceTrace(page){await page.evaluate(()=>{window.__pricePaths=[];window.__priceLabels=[];window.__priceHollow=0;});}
async function priceRange(page,end,days='30'){
await resetPriceTrace(page);await page.getByLabel('Daily window',{exact:true}).selectOption(days);
await page.getByLabel('Window end date',{exact:true}).fill(end);await page.getByLabel('Window end date',{exact:true}).dispatchEvent('change');
await page.waitForFunction(()=>document.querySelector('.pn-daily-prices')?.dataset.state==='available');
}
async function assertPriceDrawing(page,rows){
await page.evaluate(()=>new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(r))));
const actual=await page.locator('#pricesLayerHost canvas').evaluate(canvas=>{
const r=canvas.getBoundingClientRect(),pixels=canvas.getContext('2d').getImageData(0,0,canvas.width,canvas.height).data;let colored=0;
for(let i=0;i<pixels.length;i+=4)if(pixels[i+1]>150&&(pixels[i]>150||pixels[i+2]>150))colored++;
return{series:JSON.parse(canvas.dataset.series),paths:window.__pricePaths,labels:window.__priceLabels,hollow:window.__priceHollow,canvas:{width:r.width,height:r.height,backingWidth:canvas.width,backingHeight:canvas.height,colored}};
});
const fields=[['maximum_observed_gbp_per_mwh','#ffcc00'],['mean_available_gbp_per_mwh','#00ffff'],['minimum_observed_gbp_per_mwh','#ff3333']];
for(const [field,color] of fields){const groups=priceModel.segments(rows,field),receipt=actual.series.find(s=>s.field===field);assert.deepEqual(receipt.segments,groups.map(g=>g.map(p=>p.date)));
const draws=actual.paths.filter(p=>p.color===color).slice(-groups.length);assert.deepEqual(draws.map(p=>p.points.length),groups.map(g=>g.length),'actual Canvas2D paths preserve each source gap');
assert.ok(draws.every(p=>p.points[0].kind==='moveTo'&&p.points.slice(1).every(q=>q.kind==='lineTo')));
}
assert.ok(actual.canvas.width>=240&&actual.canvas.height>=300&&actual.canvas.colored>100,'actual chart paints visible colored pixels');return actual;
}
async function verifyPrices(page,width,requests){
assert.equal(requests.filter(u=>u.startsWith(priceSpec.input.base)).length,0,'price source remains lazy until the owner category is opened');
await tab(page,'pricesTab');await page.waitForFunction(()=>document.querySelector('#pricesLayerHost .pn-daily-prices')?.dataset.state==='available');
assert.equal(await page.locator('#pricesLayerHost .pn-daily-prices').count(),1);assert.equal(await page.locator('#pricesLayerHost iframe').count(),0);
assert.match(await page.locator('#pricesLayerHost .pnd-source').innerText(),/Latest source date: 2026-10-31.*historical Elexon system-sell.*GBP\/MWh/);
assert.match(await page.locator('#pricesLayerHost .pnd-note').innerText(),/source-declared.*Complete source-day coverage does not certify stored UTC alignment/);
assert.match(await page.locator('#pricesLayerHost .pnd-quality').innerText(),/106,668.*without timestamp repair/);
assert.match(await page.locator('#pricesLayerHost .pnd-status').innerText(),/^2026-10-02 to 2026-10-31/);
assert.deepEqual(requests.filter(u=>u.startsWith(priceSpec.input.base)).map(u=>u.slice(priceSpec.input.base.length)),['index.json','2026.json'],'only index and selected source year load');
const defaultRows=priceYears.get(2026).rows.filter(r=>r.date>='2026-10-02'),drawing=await assertPriceDrawing(page,defaultRows);assert.ok(drawing.labels.some(t=>/LOW £-28\.49/.test(t)),'actual negative observed low remains a negative GBP chart annotation');
assert.match(await page.locator('#pricesLayerHost .pnd-stats').innerText(),/-28\.49/);
await page.locator('#pricesLayerHost canvas').scrollIntoViewIfNeeded();await page.screenshot({path:resolve(OUT,`v932-prices-default-${width}.png`)});
const disclosure=page.locator('#pricesLayerHost .pn-daily-prices > details');assert.equal(await disclosure.getAttribute('open'),null);await disclosure.locator('summary').click();
assert.equal(await disclosure.getByRole('link',{name:'Pinned data index',exact:true}).getAttribute('href'),priceSpec.input.base+'index.json');assert.match(await disclosure.innerText(),/unweighted mean of available daily means.*Partial days can affect/);
const original=page.locator('#pricesPanel').getByRole('link',{name:'Open the original electricity workspace',exact:true});assert.equal(await original.getAttribute('href'),'https://globalgrid2050.com/uk_energy_tracking_v6/');assert.equal(await original.getAttribute('target'),'_blank');
await priceRange(page,'2026-07-04');await page.waitForFunction(()=>document.querySelector('.pnd-status').textContent.startsWith('2026-06-05 to 2026-07-04'));
const gapRows=priceYears.get(2026).rows.filter(r=>r.date>='2026-06-05'&&r.date<='2026-07-04'),gap=await assertPriceDrawing(page,gapRows);assert.equal(gap.series[1].segments.length,2);assert.ok(gap.hollow>=3,'partial day is drawn with hollow markers in every series');
assert.match(await page.locator('#pricesLayerHost .pnd-coverage').innerText(),/16 complete source days.*1 partial.*13 missing/);
assert.equal(await page.locator('#pricesLayerHost tbody tr').filter({hasText:'NO_OBSERVATIONS'}).count(),13);assert.equal(await page.locator('#pricesLayerHost tbody tr').filter({hasText:'PARTIAL_SOURCE_DAY'}).count(),1);
await page.locator('#pricesLayerHost canvas').scrollIntoViewIfNeeded();await page.screenshot({path:resolve(OUT,`v932-prices-gap-${width}.png`)});
// No UI window is short enough to contain only the thirteen missing days.
// Exercise the same imported canvas runtime against those actual owner rows.
const missingRows=priceYears.get(2026).rows.filter(r=>r.date>='2026-06-18'&&r.date<='2026-06-30');
const empty=await page.evaluate(async({url,rows})=>{const {drawDaily}=await import(url),host=document.getElementById('pricesLayerHost'),canvas=document.createElement('canvas');host.querySelector('.pn-daily-prices').append(canvas);canvas.style.width='300px';canvas.style.height='350px';window.__pricePaths=[];window.__priceLabels=[];const result=drawDaily(canvas,{start:'2026-06-18',end:'2026-06-30' … [line shortened here: 624 characters; full line on GitHub]
assert.equal(empty.paths,0);assert.ok(empty.result.every(s=>s.segments.length===0));assert.ok(empty.labels.includes('No reported prices in this window'));
await page.getByLabel('Source year',{exact:true}).selectOption('2025');await page.waitForFunction(()=>document.querySelector('.pnd-status').textContent.startsWith('2025-01-01 to 2025-12-31'));assert.equal(await page.getByLabel('Daily window',{exact:true}).inputValue(),'year');assert.equal(await page.locator('#pricesLayerHost tbody tr').count(),365);
await priceRange(page,'2099-01-01');assert.equal(await page.getByLabel('Window end date',{exact:true}).inputValue(),'2026-10-31');await page.waitForFunction(()=>document.querySelector('.pnd-status').textContent.startsWith('2026-10-02 to 2026-10-31'));
assert.equal(requests.filter(u=>u===priceSpec.input.base+'2026.json').length,1,'returning to accepted 2026 reuses immutable cache');assert.equal(requests.filter(u=>u===priceSpec.input.base+'2025.json').length,1);
await tab(page,'solarTab');await tab(page,'pricesTab');assert.equal(await page.locator('#pricesLayerHost .pn-daily-prices').count(),1);assert.equal(requests.filter(u=>u===priceSpec.input.base+'index.json').length,1,'returning category reuses accepted index');
await fullWidth(page);pass('historical daily host lazy index/year cache, actual Canvas2D negative/gapped/partial/empty paths, source clocks and bounded year/date controls',{width,defaultDays:30,gapMissingDays:13,actualAllMissingRuntimeProbe:true});
}
let browser;
try{
browser=await chromium.launch({headless:true});receipt.browser=browser.version();
if(!process.env.V932_ROTATION_ONLY){
const b=await open(browser,1440,baseline);await allRepd(b.page);await b.page.waitForFunction(()=>!/^loading/i.test(document.getElementById('newsMeta')?.textContent||'loading'));
const oldCsv=await download(b.page,b.page.locator('#exportInline'),'v929-all.csv');assert.equal(oldCsv.rows.length,7776);
await tab(b.page,'datacentreTab');await b.page.waitForFunction(()=>document.querySelectorAll('#datacentreHost tbody tr').length===54);await dcGlobal(b.page);baselineDCLinks=await dcOriginalLinks(b.page);baselineDCCsv=await download(b.page,b.page.locator('#datacentreHost button.ggdc-download'),'v931-dc-global.csv');
await allRepd(b.page);baselineHeadlineHas=await headlineHas(b.page);
for(const ref of ['12588','10529','18174']){const button=await noteButton(b.page,ref);baselineNoteButtons[ref]=await button.innerText();if(ref==='12588'){await button.click();baselineHeadlineLinks=await existingBriefLinks(b.page);await b.page.keyboard.press('Escape');}}
await b.context.close();
pass('frozen V9.31 browser CSV establishes complete original population',{rows:7775,sha256:oldCsv.sha256});
for(const width of [390,393,1440]){
const {context,page,errors,requests}=await open(browser,width,candidate);
assert.equal(await page.locator('main > section').count(),2);
const fullWidthLayout=await fullWidth(page);await painted(page,'.release-header');
assert.deepEqual((await page.locator('main > section').evaluateAll(nodes=>nodes.map(n=>n.querySelector('h2')?.textContent.replace(/\s+/g,' ').trim().toUpperCase()))),['GLOBALGRID2050 HEADLINES','REPD PIPELINE ANALYTICS']);
assert.deepEqual((await page.locator('.pipeline-tabs > [role=tab]').allTextContents()).map(x=>x.trim()),['Solar','BESS','Grid','Data Centres','Offtakers','Prices']);
assert.equal(requests.filter(u=>sourceBytes.has(u)).length,0,'asset source layers remain lazy before selection');
await page.waitForFunction(()=>document.getElementById('tbody')?.dataset.total==='3604');
await tab(page,'bessTab');assert.ok((await page.locator('#tbody tr .badge').allTextContents()).every(t=>/battery/i.test(t)));
await allRepd(page);await page.locator('#search').fill('8162');await page.waitForFunction(()=>document.getElementById('repd-8162'));
const receiver=await import(pathToFileURL(resolve(baseline,'scripts/core/atlas-receiver-v9-7.js'))),m=JSON.parse(readFileSync(resolve(baseline,'data/v9.1/build_manifest.json')));
const row=m.project_partitions.flatMap(p=>JSON.parse(readFileSync(resolve(baseline,p.path))).projects).find(p=>String(p.repd_ref)==='8162');
assert.equal(await page.locator('#repd-8162 a.atlaslink').getAttribute('href'),receiver.buildAtlasDeepLinkV9_7(row));
await allRepd(page);await page.waitForFunction(()=>!/^loading/i.test(document.getElementById('newsMeta')?.textContent||'loading'));
await verifyPrimary(page,width,requests);
if(width===1440){const actual=await download(page,page.locator('#exportInline'),'v932-all.csv');assert.deepEqual(actual.rows,oldCsv.rows);pass('all 7,775 exported CSV rows/fields/order equal frozen V9.31',{sha256:actual.sha256});}
await page.waitForFunction(()=>document.querySelectorAll('#headlineTicker ul:not([aria-hidden]) li').length===10);
assert.equal(await page.locator('#newsStatus').getAttribute('data-state'),'snapshot');
const tickerLabel=await page.locator('#headlineTicker .pn-ticker-label').textContent();
assert.match(tickerLabel,/Latest available.*source unavailable.*saved snapshot collected.*articles may be older/i);
const sourceClock=JSON.parse(readFileSync(resolve(candidate,'news/snapshot-provenance.json'))).generated_at;
const clock=new Date(sourceClock),clockLabel=clock.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'UTC'})+' '+String(clock.getUTCHours()).padStart(2,'0')+':'+String(clock.getUTCMinutes()).padStart(2,'0')+' UTC';
assert.ok(tickerLabel.includes(clockLabel),'ticker preserves original source collection clock');
const headlineItems=JSON.parse(readFileSync(resolve(candidate,'news/pipeline_headlines.snapshot.json'))).items;
const sourceLinks=new Set(headlineItems.map(x=>x.link));
for(const a of await page.locator('#headlineTicker ul:not([aria-hidden]) a').all())assert.ok(sourceLinks.has(await a.getAttribute('href')));
assert.equal(await page.locator('#headlineTicker a').first().evaluate(n=>getComputedStyle(n).color),'rgb(255, 85, 85)');
await page.locator('#headlineTicker button').click();assert.equal(await page.locator('#headlineTicker').evaluate(n=>n.classList.contains('pn-paused')),true);
await tab(page,'gridTab');await page.waitForFunction(()=>document.querySelector('#gridLayerHost .pn-count')?.textContent.includes('5,800'));
assert.match(await page.locator('#gridLayerHost .pn-count').innerText(),/4,460 source names/);assert.equal(await page.locator('#gridLayerHost tbody tr').count(),100);
await page.locator('#gridLayerHost').getByRole('button',{name:'Next',exact:true}).click();assert.match(await page.locator('#gridLayerHost .pn-tools').last().innerText(),/Page 2/);
const search=page.locator('#gridLayerHost input[type=search]');await search.fill('grid_substations:0');assert.match(await page.locator('#gridLayerHost tbody').innerText(),/Name not recorded/);
await search.fill('Barrow');const selected=await download(page,page.locator('#gridLayerHost').getByRole('button',{name:'Export results'}),`substations-search-${width}.csv`);assert.ok(selected.rows.length>1);
const map=new URL(await page.locator('#gridLayerHost tbody a').first().getAttribute('href'));assert.equal(map.searchParams.has('repd_ref'),false);assert.equal(map.searchParams.has('capacity_mw'),false);assert.ok(map.searchParams.has('longitude')&&map.searchParams.has('latitude'));
await search.fill('');await page.locator('#gridLayerHost').getByRole('button',{name:'2D locations'}).click();assert.equal(await page.locator('#gridLayerHost canvas').isVisible(),true);
await page.locator('#gridLayerHost').getByRole('button',{name:'Analytics',exact:true}).click();assert.ok(await page.locator('#gridLayerHost meter').count()>0);
await page.locator('#gridLayerHost').getByRole('tab',{name:'Grid Projects',exact:true}).click();await page.waitForFunction(()=>document.querySelector('#gridLayerHost .pn-panel').textContent.includes('No independently approved'));
assert.equal(await page.locator('#gridLayerHost tbody tr').count(),0);
await tab(page,'offtakersTab');await page.waitForFunction(()=>document.querySelector('#offtakersLayerHost .pn-count')?.textContent.includes('1,568'));
const offtakersCsv=await download(page,page.locator('#offtakersLayerHost').getByRole('button',{name:'Export results'}),`offtakers-${width}.csv`);
assert.equal(offtakersCsv.rows.length,1569);assert.ok(offtakersCsv.rows[0].includes('Source record'));const exported=JSON.stringify(offtakersCsv.rows);assert.match(exported,/ODbL/);assert.match(exported,/OGL/);assert.match(exported,/NAEI/);
await verifyPrices(page,width,requests);
await tab(page,'datacentreTab');await page.waitForFunction(()=>document.querySelectorAll('#datacentreHost .ggdc-table tbody tr').length===54);
await verifyLocations(page,width);
await tab(page,'gridTab');await page.locator('#gridLayerHost').getByRole('tab',{name:'Substations',exact:true}).click();await page.waitForFunction(()=>document.querySelector('#gridLayerHost .pn-count')?.textContent.includes('5,800'));
assert.equal(requests.filter(u=>u===catalogue.layers.find(l=>l.id==='substations').data.url).length,1,'returning to Grid reuses pinned source cache');
await page.locator('#pricesTab').focus();await page.keyboard.press('Home');assert.equal(await page.locator('#solarTab').evaluate(n=>n===document.activeElement),true);
await page.waitForFunction(()=>document.getElementById('tbody')?.dataset.total==='3604');
const geometry=await page.evaluate(()=>({viewport:innerWidth,width:document.documentElement.scrollWidth,font:getComputedStyle(document.body).fontFamily}));assert.ok(geometry.width<=width+2);assert.match(geometry.font,/mono|courier/i);
await page.screenshot({path:resolve(OUT,`v932-solar-${width}.png`)});await tab(page,'gridTab');await page.screenshot({path:resolve(OUT,`v932-grid-${width}.png`)});
assert.deepEqual(errors,[]);pass('integrated categories, provenance, ticker, search/CSV/MAP, cache and controls',{width,substations:5800,named:4460,unnamed:1340,offtakers:1568,geometry,fullWidthLayout});await context.close();
}
}
const rotating=await open(browser,390,candidate,{mobile:true,height:844});
await tab(rotating.page,'datacentreTab');await rotating.page.waitForFunction(()=>document.getElementById('datacentreHost')?.dataset.locationsState==='available');await dcGlobal(rotating.page);
await rotating.page.getByRole('searchbox',{name:'Search Data Centre records'}).fill('CyrusOne LON1');await rotating.page.waitForFunction(()=>document.querySelectorAll('#datacentreHost .ggdc-screen-actions').length===1);
await rotating.page.locator('.ggdc-reported-address summary').tap();
const session=await rotating.context.newCDPSession(rotating.page),states=[];
for(const [name,size] of [['portrait',{width:390,height:844}],['landscape',{width:915,height:412}],['portrait-return',{width:390,height:844}]]){
await rotating.page.setViewportSize(size);
await session.send('Emulation.setDeviceMetricsOverride',{...size,screenWidth:size.width,screenHeight:size.height,deviceScaleFactor:2.625,mobile:true,screenOrientation:{type:name==='landscape'?'landscapePrimary':'portraitPrimary',angle:name==='landscape'?90:0}});
await rotating.page.waitForFunction(size=>Math.abs(innerWidth-size.width)<=1&&Math.abs(innerHeight-size.height)<=2,size);
const layout=await fullWidth(rotating.page),paint=await painted(rotating.page,'#datacentreHost .ggdc-reported-address > p');
assert.equal(await rotating.page.getByRole('searchbox',{name:'Search Data Centre records'}).inputValue(),'CyrusOne LON1');assert.equal(await rotating.page.locator('.ggdc-reported-address').getAttribute('open'),'');
assert.equal(await rotating.page.locator('#datacentreHost .ggdc-screen-actions').count(),1);assert.equal(await rotating.page.locator('#datacentreHost .ggdc-screen-footnote').count(),1);assert.equal(await rotating.page.locator('#datacentreHost .ggdc-location-sources').count(),1);
const screenshot=await orientationScreenshot(session,`v932-dc-${name}.png`,size);states.push({name,...size,layout,paint,screenshot});
}
assert.deepEqual(rotating.errors,[]);await rotating.context.close();pass('Android-UA/touch-emulated DC portrait-landscape-return preserves address disclosure/search/Screen/onefooter',{states,actualHandset:false});
const priceRotation=await open(browser,393,candidate,{mobile:true,height:851});await tab(priceRotation.page,'pricesTab');await priceRotation.page.waitForFunction(()=>document.querySelector('.pn-daily-prices')?.dataset.state==='available');
await priceRange(priceRotation.page,'2026-07-04');await priceRotation.page.waitForFunction(()=>document.querySelector('.pnd-status').textContent.startsWith('2026-06-05 to 2026-07-04'));
const priceSession=await priceRotation.context.newCDPSession(priceRotation.page),priceStates=[];
for(const [name,size] of [['portrait',{width:393,height:851}],['landscape',{width:915,height:412}],['portrait-return',{width:393,height:851}]]){
await priceRotation.page.setViewportSize(size);await priceSession.send('Emulation.setDeviceMetricsOverride',{...size,screenWidth:size.width,screenHeight:size.height,deviceScaleFactor:2.625,mobile:true,screenOrientation:{type:name==='landscape'?'landscapePrimary':'portraitPrimary',angle:name==='landscape'?90:0}});
await priceRotation.page.waitForFunction(size=>Math.abs(innerWidth-size.width)<=1&&Math.abs(innerHeight-size.height)<=2,size);const layout=await fullWidth(priceRotation.page);
assert.equal(await priceRotation.page.getByLabel('Window end date',{exact:true}).inputValue(),'2026-07-04');assert.equal(await priceRotation.page.locator('#pricesLayerHost .pn-daily-prices').count(),1);
const chart=await assertPriceDrawing(priceRotation.page,priceYears.get(2026).rows.filter(r=>r.date>='2026-06-05'&&r.date<='2026-07-04'));await priceRotation.page.locator('#pricesLayerHost canvas').scrollIntoViewIfNeeded();
const screenshot=await orientationScreenshot(priceSession,`v932-prices-${name}.png`,size);priceStates.push({name,...size,layout,canvas:chart.canvas,screenshot});
}
assert.deepEqual(priceRotation.errors,[]);await priceRotation.context.close();pass('Android-UA/touch-emulated Prices rotation keeps one painted gap chart and selected source window',{states:priceStates,actualHandset:false});
const primaryRotation=await open(browser,393,candidate,{mobile:true,height:851});await primaryRotation.page.waitForFunction(()=>document.documentElement.dataset.primaryNotesState==='available');await allRepd(primaryRotation.page);await (await noteButton(primaryRotation.page,'12588')).tap();
await primaryRotation.page.locator('.machine-note-primary details summary').tap();const primarySession=await primaryRotation.context.newCDPSession(primaryRotation.page),primaryStates=[];
for(const [name,size] of [['portrait',{width:393,height:851}],['landscape',{width:915,height:412}],['portrait-return',{width:393,height:851}]]){
await primaryRotation.page.setViewportSize(size);await primarySession.send('Emulation.setDeviceMetricsOverride',{...size,screenWidth:size.width,screenHeight:size.height,deviceScaleFactor:2.625,mobile:true,screenOrientation:{type:name==='landscape'?'landscapePrimary':'portraitPrimary',angle:name==='landscape'?90:0}});await primaryRotation.page.waitForFunction(size=>Math.abs(innerWidth-size.widt … [line shortened here: 450 characters; full line on GitHub]
const layout=await fullWidth(primaryRotation.page),paint=await painted(primaryRotation.page,'.machine-note-primary h3');assert.equal(await primaryRotation.page.locator('.machine-note-primary').count(),1);assert.equal(await primaryRotation.page.locator('.machine-note-primary details').getAttribute('open'),'');assert.equal(await primaryRotation.page.locator('#search').inputValue(),'12588');
const screenshot=await orientationScreenshot(primarySession,`v932-primary-${name}.png`,size);primaryStates.push({name,...size,layout,paint,screenshot});
}
await primaryRotation.page.keyboard.press('Escape');assert.equal(await primaryRotation.page.locator('.machine-note-dialog[open]').count(),0);assert.deepEqual(primaryRotation.errors,[]);await primaryRotation.context.close();pass('Android-UA/touch-emulated primary dialog rotates without losing provisional details/search/frozen record',{states:primaryStates,actualHandset:false});
for(const corrupt of ['primary-manifest','primary-model','primary-catalogue','primary-json','primary-mime','primary-renderer','primary-evaluation']){
const test=await open(browser,393,candidate,{corrupt});await test.page.waitForFunction(()=>document.documentElement.dataset.primaryNotesState==='unavailable');await test.page.waitForFunction(()=>!/^loading/i.test(document.getElementById('newsMeta')?.textContent||'loading'));
assert.deepEqual(await headlineHas(test.page),baselineHeadlineHas);assert.equal(await test.page.locator('[data-note-primary]').count(),0);await allRepd(test.page);const button=await noteButton(test.page,'12588');assert.equal(await button.innerText(),baselineNoteButtons['12588']);await button.click();assert.equal(await test.page.locator('.machine-note-dialog .machine-note-primary').count(),0);a … [line shortened here: 654 characters; full line on GitHub]
await allRepd(test.page);assert.equal(await test.page.locator('#tbody').getAttribute('data-total'),'7775');await tab(test.page,'datacentreTab');await test.page.waitForFunction(()=>document.getElementById('datacentreHost')?.dataset.locationsState==='available');assert.equal(await test.page.locator('#datacentreHost tbody tr').count(),54);assert.equal(await test.page.locator('#datacentreHost .ggd … [line shortened here: 431 characters; full line on GitHub]
await tab(test.page,'pricesTab');await test.page.waitForFunction(()=>document.querySelector('.pn-daily-prices')?.dataset.state==='available');assert.match(await test.page.locator('.pnd-status').innerText(),/^2026-10-02 to 2026-10-31/);assert.deepEqual(test.errors,[]);await test.context.close();pass('invalid primary cartridge/evaluation withholds only primary source; original headline brief/777 … [line shortened here: 442 characters; full line on GitHub]
}
for(const corrupt of ['price-manifest','price-module','price-index','price-year']){
const test=await open(browser,393,candidate,{corrupt});await tab(test.page,'pricesTab');await test.page.waitForFunction(()=>document.getElementById('pricesLayerHost')?.dataset.priceState==='unavailable');
assert.equal(await test.page.locator('#pricesLayerHost canvas:visible').count(),0);assert.equal(await test.page.locator('#pricesLayerHost tbody tr').count(),0);assert.equal(await test.page.locator('#pricesLayerHost .pnd-stats:not([hidden])').count(),0);
assert.equal(await test.page.locator('#pricesPanel').getByRole('link',{name:'Open the original electricity workspace',exact:true}).getAttribute('href'),'https://globalgrid2050.com/uk_energy_tracking_v6/');
await allRepd(test.page);assert.equal(await test.page.locator('#tbody').getAttribute('data-total'),'7775');await tab(test.page,'datacentreTab');await test.page.waitForFunction(()=>document.getElementById('datacentreHost')?.dataset.locationsState==='available');
assert.equal(await test.page.locator('#datacentreHost tbody tr').count(),54);assert.equal(await test.page.locator('#datacentreHost .ggdc-screen-actions').count(),34);await dcGlobal(test.page);assert.deepEqual(await dcOriginalLinks(test.page),baselineDCLinks);
assert.deepEqual(test.errors,[]);await test.context.close();pass('price corruption withholds chart/results while all REPD rows, original workspace and DC locations/maps remain usable',{corrupt});
}
for(const corrupt of ['dc-manifest','dc-module','dc-source']){
const test=await open(browser,390,candidate,{corrupt});await tab(test.page,'datacentreTab');await test.page.waitForFunction(()=>document.getElementById('datacentreHost')?.dataset.locationsState==='unavailable');
assert.equal(await test.page.locator('#datacentreHost tbody tr').count(),54);assert.equal(await test.page.locator('#datacentreHost .ggdc-location-actions').count(),0);assert.equal(await test.page.locator('#datacentreHost .ggdc-screen-footnote').count(),0);
assert.match(await test.page.locator('#datacentreHost .dc-location-status').innerText(),/Additional location data unavailable/);await dcGlobal(test.page);assert.deepEqual(await dcOriginalLinks(test.page),baselineDCLinks);
await test.page.getByRole('searchbox',{name:'Search Data Centre records'}).fill('CyrusOne LON1');await test.page.waitForFunction(()=>document.querySelectorAll('#datacentreHost tbody tr').length===1);await allRepd(test.page);assert.equal(await test.page.locator('#tbody').getAttribute('data-total'),'7775');assert.deepEqual(test.errors,[]);await test.context.close();
pass('optional location corruption fails closed without changing original DC controls/maps or REPD',{corrupt});
}
const bad=await open(browser,393,candidate,{corrupt:true,reducedMotion:true});await tab(bad.page,'gridTab');await bad.page.waitForFunction(()=>document.querySelector('#gridLayerHost .pn-panel')?.dataset.state==='unavailable');assert.equal(await bad.page.locator('#gridLayerHost tbody tr').count(),0);
await allRepd(bad.page);assert.equal(await bad.page.locator('#tbody').getAttribute('data-total'),'7775');await tab(bad.page,'offtakersTab');await bad.page.waitForFunction(()=>document.querySelector('#offtakersLayerHost .pn-count')?.textContent.includes('1,568'));
await bad.page.waitForFunction(()=>document.querySelector('#headlineTicker .pn-ticker-track'));assert.equal(await bad.page.locator('#headlineTicker .pn-ticker-track').evaluate(n=>getComputedStyle(n).animationName),'none');assert.deepEqual(bad.errors,[]);await bad.context.close();
pass('corrupt pinned substation source fails closed while REPD/Offtakers remain usable; reduced motion suppresses ticker animation');receipt.status='PASS';
}catch(error){receipt.status='FAIL';receipt.failure=error.stack;throw error;}
finally{receipt.blocked_external=[...new Set(receipt.blocked_external)];writeFileSync(resolve(OUT,'browser.json'),JSON.stringify(receipt,null,2)+'\n');if(browser)await browser.close();await new Promise(r=>server.close(r));}Contracts Test
A test in the automation folder of GlobalGrid2050 that checks Model and Catalogue, using SHA-256.
testglobalgrid2050 / automation/v932_preview/contracts.test.mjs · lines 1–137 of 137 · Entry point · pattern projects (shared by 4 files)
- What it does
- It tests the REPD register and solar. Defines projects. Uses libraries node:test, node:assert/strict, node:fs, node:path, node:crypto. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain terms in the code: the REPD register, solar.
- Inputs & outputs
- In: JSON file build_manifest.json.
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 V932 Preview Acceptance Workflow (globalgrid2050).
- What it achieves
- Defines `projects`.
- Why it matters
- Run by GlobalGrid2050 V932 Preview Acceptance Workflow.
- Application
- globalgrid2050 · automation/v932_preview · test
- Uses
- Model (import), Catalogue (import), node:test, node:assert/strict, node:fs, node:path, node:crypto
- Used by
- run by GlobalGrid2050 V932 Preview Acceptance Workflow (workflow run)
- Produces
- projects
- Defines here
- projects
- 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/v932_preview/contracts.test.mjs:1-137 · blob de04eeac5b48097bc38d758eddb62a8bbc45e7ed · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: filesystem · domain stage: unknown · users: none · canonical: production_core
import test from 'node:test';
import assert from 'node:assert/strict';
import {readFileSync} from 'node:fs';
import {resolve} from 'node:path';
import {createHash} from 'node:crypto';
import {buildPrimaryNotes,CURATED_NOTES,utcInstant} from '../primary_note_ui/b5eed3d2ae878c78e5153be06ef531c11fff2148/model.mjs';
import {CATALOGUE} from '../primary_note_ui/b5eed3d2ae878c78e5153be06ef531c11fff2148/catalogue.mjs';
const AS_OF='2026-11-17T03:16:20Z',copy=value=>JSON.parse(JSON.stringify(value));
// Actual reviewed canonical target. Remaining fixture rows are explicitly synthetic.
const TARGET={repd_ref:'12588',gg_project_id:'GG2050-REPD-12588',planning_application_reference:'EN010147',
name:'Botley West, Botley - Botley West Solar Project',operator:'Photovolt Development Partners & SolarFive',county:'Oxfordshire',country:'England',technology:'solar',
capacity_known:true,capacity_mw:840,status:'Application Submitted',repd_record_updated:'2024-12-16',planning_application_submitted:'2024-11-15',latitude:51.8132088,longitude:-1.3489728};
function projects(){return [copy(TARGET),...Array.from({length:7774},(_,i)=>({repd_ref:String(500000+i),gg_project_id:'GG2050-REPD-'+(500000+i),name:'SYNTHETIC UNRELATED '+i,planning_application_reference:null}))];}
const evaluate=(rows=projects(),records=copy(CURATED_NOTES.notes),asOf=AS_OF)=>buildPrimaryNotes(rows,{records,asOf});
test('actual canonical target binds one frozen provisional note andzero verifieddelta',()=>{
const result=evaluate(),note=result.by_repd_ref['12588'][0];
assert.equal(result.association_count,1);assert.equal(result.verified_count,0);assert.equal(result.solar1000_verified_delta,0);
assert.equal(note.association,'PROVISIONAL');assert.equal(result.by_project_id['GG2050-REPD-12588'][0],note);
assert.equal(note.claim.decision_date,'2026-11-10');assert.equal(note.news_metadata.published_at,'2026-11-11T12:29:34Z');
assert.equal(note.claim.capacity_context.final_reduced_capacity_mw,null);assert.equal(note.claim.unknowns.judicial_review_status,null);
assert.equal(CATALOGUE.canonical.fields.status,'Application Submitted');
});
test('whole accepted canonical population is required; empty input doesnotinventbinding',()=>{
assert.throws(()=>evaluate([copy(TARGET)]),/population/);assert.throws(()=>evaluate([]),/population/);
assert.equal(evaluate(projects(),[]).association_count,0);
});
test('homonym IDs and local planning references are rejected',()=>{
for(const [ref,planning] of [['10529','P23/V2624/FUL'],['18174','P24/V2489/FUL']]){
const rows=projects();Object.assign(rows[0],{repd_ref:ref,gg_project_id:'GG2050-REPD-'+ref,planning_application_reference:planning,name:'Botley - Solar Photovoltaic Array',operator:'Red House Solar Limited',capacity_mw:49.99});
assert.throws(()=>evaluate(rows),/planning reference/);
}
});
test('wrong exact identity, developer, country, point or frozenstatus withholds',()=>{
for(const [field,value] of [['operator','Other Developer'],['country','Germany'],['name','Botley'],['county','Hampshire'],['latitude',null],['longitude',-1.3052428],['capacity_mw',49.99],['status','Application Refused'],['planning_application_submitted','2024-11-14'],['repd_record_updated','2026-11-10']]){
const rows=projects();rows[0][field]=value;assert.throws(()=>evaluate(rows),/canonical/);
}
const rows=projects();rows[0].repd_ref='10529';rows[0].gg_project_id='GG2050-REPD-10529';assert.throws(()=>evaluate(rows),/canonical repd_ref/);
});
test('duplicate canonical identities or a second EN010147 cannotbind',()=>{
const duplicate=projects();duplicate[1]=copy(TARGET);assert.throws(()=>evaluate(duplicate),/duplicate canonical/);
const shared=projects();shared[1].planning_application_reference='EN010147';assert.throws(()=>evaluate(shared),/unique/);
});
test('duplicate notes or bindings are rejected',()=>{
const notes=copy(CURATED_NOTES.notes);assert.throws(()=>evaluate(projects(),[notes[0],copy(notes[0])]),/duplicate note/);
const other=copy(notes[0]);other.id='OTHER';assert.throws(()=>evaluate(projects(),[notes[0],other]),/duplicate note/);
});
test('VERIFIED, currentcapacity and unsupported project claims are rejected',()=>{
for(const mutate of [n=>n.association='VERIFIED',n=>n.claim.current_capacity_mw=840,n=>n.claim.capacity_context.final_reduced_capacity_mw=840,
n=>n.claim.type='CONSTRUCTION_STARTED',n=>n.claim.statement='The project is cancelled and grid-connected.',n=>n.claim.unknowns.judicial_review_status='NONE',n=>n.verified_count=1]){
const notes=copy(CURATED_NOTES.notes);mutate(notes[0]);assert.throws(()=>evaluate(projects(),notes));
}
});
test('unknown document, changed URL/hash/bytes and forged receipt reject',()=>{
for(const mutate of [n=>n.source.id='unreviewed',n=>n.source.url=n.source.url.replace('002440','002441'),n=>n.source.sha256='0'.repeat(64),n=>n.source.bytes++,
n=>n.source.headers['Last-Modified']='Wed, 11 Nov 2026 16:20:36 GMT',n=>n.evidence_review.status='CALLER_ACCEPTED']){
const notes=copy(CURATED_NOTES.notes);mutate(notes[0]);assert.throws(()=>evaluate(projects(),notes),/catalogue/);
}
});
test('unsafe links cannotinheritrightsfromapublichostname',()=>{
for(const url of ['javascript:alert(1)','http://www.gov.uk/','https://u:p@www.gov.uk/x','https://127.0.0.1/x','https://www.gov.uk/a#document']){
const notes=copy(CURATED_NOTES.notes);notes[0].source.url=url;assert.throws(()=>evaluate(projects(),notes));
}
});
test('missing, unknown and broadened rights cannot selfapprove',()=>{
for(const mutate of [n=>n.rights=null,n=>n.rights.status='UNKNOWN',n=>n.rights.status='ACCEPTED',n=>n.rights.terms_receipts=[],
n=>n.rights.terms_receipts[0].sha256='a'.repeat(64),n=>n.rights.scope='ALL_PINS_DOCUMENTS',n=>n.rights.exclusions=[],n=>n.rights.attribution='']){
const notes=copy(CURATED_NOTES.notes);mutate(notes[0]);assert.throws(()=>evaluate(projects(),notes));
}
assert.throws(()=>buildPrimaryNotes(projects(),{asOf:AS_OF,rightsAccepted:true}),/unsupported/);
});
test('future publication/retrieval/evaluation andmalformedclocks withhold',()=>{
for(const mutate of [n=>n.source.retrieved_at='2026-11-18T00:00:00Z',n=>n.news_metadata.published_at='2026-11-18T00:00:00Z',
n=>n.evidence_review.curated_at='2026-11-17T03:16:20.000000001Z',n=>n.source.document_date='2026-11-18']){
const notes=copy(CURATED_NOTES.notes);mutate(notes[0]);assert.throws(()=>evaluate(projects(),notes),/future/);
}
for(const value of ['2026-02-29T00:00:00Z','2026-11-17T24:00:00Z','2026-11-17T03:16:20+01:00','not-a-clock'])assert.throws(()=>evaluate(projects(),copy(CURATED_NOTES.notes),value));
assert.throws(()=>evaluate(projects(),copy(CURATED_NOTES.notes),'2026-11-17T02:00:00Z'),/future/);
});
test('distinct chronology cannotbequietlyreconciledorrewritten',()=>{
const notes=copy(CURATED_NOTES.notes);notes[0].news_metadata.first_seen='2026-11-10T00:00:00Z';assert.throws(()=>evaluate(projects(),notes),/chronology/);
const altered=copy(CURATED_NOTES.notes);altered[0].claim.source_application_submitted='2024-11-15';assert.throws(()=>evaluate(projects(),altered),/claim/);
assert(utcInstant('2026-11-17T03:16:20.000000001Z')>utcInstant(AS_OF));
});
test('source catalogue, curated inputs and returned records remainimmutable',()=>{
const notes=copy(CURATED_NOTES.notes),rows=projects(),before=JSON.stringify(rows),result=evaluate(rows,notes),accepted=result.by_repd_ref['12588'][0];
assert.equal(JSON.stringify(rows),before);
assert.equal(Reflect.set(CATALOGUE.source,'sha256','0'.repeat(64)),false);assert.equal(Reflect.set(CURATED_NOTES.notes[0].claim,'type','VERIFIED'),false);
assert.equal(Reflect.set(accepted.rights.terms_receipts[0],'sha256','0'.repeat(64)),false);assert.equal(Reflect.set(result.by_repd_ref['12588'],'0',{}),false);
notes[0].claim.statement='POISON';rows[0].operator='POISON';assert.notEqual(accepted.claim.statement,'POISON');assert.equal(accepted.association,'PROVISIONAL');
assert.throws(()=>evaluate(projects(),notes));
});
test('hidden toJSON cannot replace a validated provisional note',()=>{
const notes=copy(CURATED_NOTES.notes);let called=false;
Object.defineProperty(notes[0],'toJSON',{enumerable:false,value(){called=true;return {association:'VERIFIED'};}});
assert.throws(()=>evaluate(projects(),notes),/hidden fields/);assert.equal(called,false);
});
test('accessors and custom prototypes cannot change validated metadata',()=>{
const notes=copy(CURATED_NOTES.notes);let calls=0;
Object.defineProperty(notes[0],'source',{enumerable:true,get(){calls++;return copy(CATALOGUE.source);}});
assert.throws(()=>evaluate(projects(),notes),/accessors/);assert.equal(calls,0);
const rows=projects();Object.defineProperty(rows[0],'repd_ref',{get(){return '12588';}});assert.throws(()=>evaluate(rows),/accessors/);
const proto=copy(CURATED_NOTES.notes);Object.setPrototypeOf(proto[0],{selfApproved:true});assert.throws(()=>evaluate(projects(),proto),/prototype/);
});
test('caller filter cannot substitute a reviewed row into an invalid population',()=>{
for(const enumerable of [true,false]){
const rows=projects();rows[0].planning_application_reference='UNRELATED';rows[0].operator='Wrong Developer';let called=false;
Object.defineProperty(rows,'filter',{enumerable,value(){called=true;return [copy(TARGET)];}});
assert.throws(()=>evaluate(rows),/canonical array/);assert.equal(called,false);
}
});
test('canonical iterator/custom/prototype/sparse/accessor arrays reject withoutcalls',()=>{
const changes=[
(rows,called)=>Object.defineProperty(rows,Symbol.iterator,{value(){called.value++;return Array.prototype[Symbol.iterator].call(rows);}}),
rows=>Object.defineProperty(rows,'selfApproved',{value:true}),
rows=>Object.setPrototypeOf(rows,Object.create(Array.prototype)),
rows=>delete rows[1],
(rows,called)=>Object.defineProperty(rows,'0',{enumerable:true,get(){called.value++;return copy(TARGET);}})
];
for(const change of changes){const rows=projects(),called={value:0};change(rows,called);assert.throws(()=>evaluate(rows),/canonical array/);assert.equal(called.value,0);}
});
function actualProjects(){const edition=resolve(process.env.V932_CANDIDATE||'uk_renewables_pipeline/202611170324'),manifest=JSON.parse(readFileSync(resolve(edition,'data/v9.1/build_manifest.json'))),rows=[];for(const part of manifest.project_partitions){const raw=readFileSync(resolve(edition,part.path));assert.equal(createHash('sha256').update(raw).digest('hex'),part.sha256);rows.push(...JSON.pars … [line shortened here: 431 characters; full line on GitHub]
test('independent actual7775 population binds only12588 without changing canonical fields or Solar1000',()=>{
const rows=actualProjects(),before=JSON.stringify(rows),result=buildPrimaryNotes(rows,{asOf:AS_OF});
assert.equal(result.association_count,1);assert.deepEqual(Object.keys(result.by_repd_ref),['12588']);assert.equal(result.verified_count,0);assert.equal(result.solar1000_verified_delta,0);assert.equal(JSON.stringify(rows),before);
const pilot=JSON.parse(readFileSync(resolve(process.env.V932_CANDIDATE||'uk_renewables_pipeline/202611170324','solar1000/manifest.json')));assert.equal(pilot.ids.length,1000);assert.equal(pilot.ids.includes('12588'),false);
for(const ref of ['10529','18174'])assert.equal(result.by_repd_ref[ref],undefined);
});
test('independent actual canonical population cannot execute own filter/iterator to replace identity',()=>{
for(const [key,value] of [['filter',()=>{throw Error('caller filter ran');}],[Symbol.iterator,()=>{throw Error('caller iterator ran');}]]){const rows=actualProjects();Object.defineProperty(rows,key,{value});assert.throws(()=>buildPrimaryNotes(rows,{asOf:AS_OF}),/canonical array/);}
const rows=actualProjects();rows.find(r=>r.repd_ref==='12588').status='Application Refused';assert.throws(()=>buildPrimaryNotes(rows,{asOf:AS_OF}),/canonical status/);
});
test('independent actual note clocks preserve source dates, null capacity and narrow government rights',()=>{
const rows=actualProjects();assert.throws(()=>buildPrimaryNotes(rows,{asOf:'2026-11-17T03:16:19.999999999Z'}),/future/);
const note=buildPrimaryNotes(rows,{asOf:AS_OF}).by_repd_ref['12588'][0];assert.equal(note.source.document_date,'2026-11-10');assert.equal(note.news_metadata.published_at.slice(0,10),'2026-11-11');assert.equal(note.source.retrieved_at.slice(0,10),'2026-11-17');
assert.equal(note.rights.scope,'GOVERNMENT_AUTHORED_DECISION_FACTS_ONLY');assert.equal(note.news_metadata.publisher_content_rights,'NOT_ASSESSED');assert.equal(note.claim.capacity_context.final_reduced_capacity_mw,null);assert(Object.values(note.claim.unknowns).every(v=>v===null));assert.equal(Object.isFrozen(note.rights.terms_receipts[0]),true);
});Invariants
A JavaScript module in the automation folder of GlobalGrid2050 that fetches primary notes, prices, DC locations and projects, using SHA-256.
storageglobalgrid2050 / automation/v932_preview/invariants.mjs · lines 1–135 of 135 · Entry point · pattern priceInput (shared by 3 files)
- What it does
- It fetches primary notes, prices, DC locations and projects. Defines 6 functions or classes, including bytes, git, pass, treeBytes, population. Uses libraries node:assert/strict, node:crypto, node:child_process, node:fs, node:path. Side effects: reads or writes files; makes network requests; starts processes; uses storage (browser storage, DuckDB or Parquet).
- Inputs & outputs
- In: JSON file build_manifest.json; JSON file primary-notes.v932.json; JSON file notes.json; JSON file prices.v931.json; JSON file index.json; JSON file dc-locations.v930.json; JSON file projects.json; JSON file layers-v929.json. Out: JSON file invariants.json.
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 V932 Preview Acceptance Workflow (globalgrid2050).
- What it achieves
- It is built from the bytes step (`bytes`), the git step (`git`) and the pass step (`pass`). Exact-source and historical-preservation acceptance for the formal V9.32 edition.
- Why it matters
- Run by GlobalGrid2050 V932 Preview Acceptance Workflow.
- Application
- globalgrid2050 · automation/v932_preview · JavaScript module
- Uses
- Edition History (script call), node:assert/strict, node:crypto, node:child_process, node:fs, node:path, node:url
- Used by
- run by GlobalGrid2050 V932 Preview Acceptance Workflow (workflow run)
- Produces
- bytes, git, pass, treeBytes, population, priceInput
- Defines here
- bytes, git, pass, treeBytes, population, priceInput
- 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/v932_preview/invariants.mjs:1-135 · blob 1386d403dd756b691656f0ca978c6a13c3139be3 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: filesystem, network, process, storage · domain stage: unknown · users: none · canonical: production_core
/** Exact-source and historical-preservation acceptance for the formal V9.32 edition. */
import assert from 'node:assert/strict';
import {createHash} from 'node:crypto';
import {execFileSync} from 'node:child_process';
import {readFileSync,readdirSync,statSync,mkdirSync,writeFileSync} from 'node:fs';
import {dirname,resolve,basename,relative} from 'node:path';
import {fileURLToPath,pathToFileURL} from 'node:url';
import {protectedEditionChanges} from '../pipeline_release/edition_history.mjs';
const ROOT=resolve(dirname(fileURLToPath(import.meta.url)),'../..');
const EDITION=process.env.V932_CANDIDATE||'uk_renewables_pipeline/202611170324';
const candidate=resolve(ROOT,EDITION),baseline=resolve(ROOT,'uk_renewables_pipeline/202611170243');
const sourceBase=process.env.V932_BASE_SHA||execFileSync('git',['rev-parse','origin/main'],{cwd:ROOT,encoding:'utf8'}).trim();
const out=process.env.V932_OUT;
const bytes=p=>readFileSync(p),json=p=>JSON.parse(bytes(p)),hash=b=>createHash('sha256').update(b).digest('hex');
const git=args=>execFileSync('git',args,{cwd:ROOT,encoding:'utf8'}).trim();
const receipt={status:'RUNNING',utc:new Date().toISOString(),head:git(['rev-parse','HEAD']),edition:EDITION,
historical_base:sourceBase,checks:[],limitations:['Source-byte and local data/MAP-construction acceptance only; no public GridAtlas execution or source-rights approval.']};
const pass=(name,details={})=>{receipt.checks.push({name,status:'PASS',...details});console.log('PASS:',name);};
function treeBytes(dir){return readdirSync(dir).filter(n=>n!=='__pycache__').reduce((total,name)=>{const p=resolve(dir,name);return total+(statSync(p).isDirectory()?treeBytes(p):statSync(p).size);},0);}
function population(folder){
const manifest=json(resolve(folder,'data/v9.1/build_manifest.json')),rows=[];
for(const part of manifest.project_partitions){const raw=bytes(resolve(folder,part.path));assert.equal(hash(raw),part.sha256,part.path);const projects=JSON.parse(raw).projects;assert.equal(projects.length,part.record_count);rows.push(...projects);}
for(const part of manifest.atlas_partitions){const raw=bytes(resolve(folder,part.path));assert.equal(hash(raw),part.sha256);assert.equal(JSON.parse(raw).features.length,part.feature_count);}
assert.equal(rows.length,7775);assert.equal(rows.filter(x=>x.technology==='solar').length,3604);assert.equal(new Set(rows.map(x=>String(x.repd_ref))).size,7775);
return rows;
}
try{
const primaryContractBytes=bytes(resolve(candidate,'contracts/primary-notes.v932.json')),primaryContract=JSON.parse(primaryContractBytes),primaryDonor='b5eed3d2ae878c78e5153be06ef531c11fff2148';
assert.equal(primaryContract.schema,'globalgrid2050.primary-note-cartridge.v1');assert.equal(primaryContract.producer.commit,primaryDonor);assert.deepEqual(Object.keys(primaryContract.files).sort(),['catalogue.mjs','model.mjs','notes.json']);
const primaryCache=resolve(ROOT,'automation/primary_note_ui',primaryDonor);
for(const [name,pin] of Object.entries(primaryContract.files)){
const raw=bytes(resolve(primaryCache,name)),donor=execFileSync('git',['show',primaryDonor+':'+pin.source_path],{cwd:ROOT});assert.deepEqual(raw,donor,name+' exact reviewed donor');assert.equal(raw.length,pin.bytes);assert.equal(hash(raw),pin.sha256);
assert.equal(createHash('sha1').update(Buffer.concat([Buffer.from(`blob ${raw.length}\0`),raw])).digest('hex'),pin.git_blob);
}
const renderer=bytes(resolve(ROOT,primaryContract.renderer.path));assert.equal(renderer.length,3748);assert.equal(hash(renderer),'45344a1ad8b3926811f7146bb0bdc458d605e688af30b286bec294fc5f0a4806');assert.equal(primaryContract.renderer.bytes,renderer.length);assert.equal(primaryContract.renderer.sha256,hash(renderer));
assert.equal(createHash('sha1').update(Buffer.concat([Buffer.from(`blob ${renderer.length}\0`),renderer])).digest('hex'),primaryContract.renderer.git_blob);
const primaryBoot=bytes(resolve(candidate,'scripts/plugins/primary-notes-v932.mjs')).toString('utf8');assert.ok(primaryBoot.includes("const manifestHash = '"+hash(primaryContractBytes)+"'"));assert.match(primaryBoot,/state\.canonicalModel\?\.projects/);assert.doesNotMatch(primaryBoot,/fetch\([^)]*projects|project_partitions/);
const primaryModel=await import(pathToFileURL(resolve(primaryCache,'model.mjs'))),primaryCatalogue=(await import(pathToFileURL(resolve(primaryCache,'catalogue.mjs')))).CATALOGUE;
assert.match(bytes(resolve(primaryCache,'model.mjs')).toString('utf8'),/import data from '\.\/notes\.json' with \{type:'json'\}/);
const allCanonical=population(candidate),canonicalBefore=JSON.stringify(allCanonical),primaryIndex=primaryModel.buildPrimaryNotes(allCanonical,{asOf:new Date().toISOString()});
assert.deepEqual(primaryContract.expected,{canonical_population:7775,associations:1,verified:0,solar1000_verified_delta:0});assert.equal(primaryIndex.association_count,1);assert.equal(primaryIndex.verified_count,0);assert.equal(primaryIndex.solar1000_verified_delta,0);assert.deepEqual(Object.keys(primaryIndex.by_repd_ref),['12588']);assert.equal(JSON.stringify(allCanonical),canonicalBefore);
const primary=primaryIndex.by_repd_ref['12588'][0];assert.equal(primary.association,'PROVISIONAL');assert.equal(primary.source.sha256,'335eff9eed9c8e32658fe70186d2f02f4bf82a92ffbed1eaa835ac7ced0f857e');assert.equal(primary.source.bytes,1247918);assert.equal(primary.source.document_date,'2026-11-10');assert.equal(primary.news_metadata.published_at,'2026-11-11T12:29:34Z');assert.equal(primary.sour … [line shortened here: 442 characters; full line on GitHub]
assert.equal(primary.rights.scope,'GOVERNMENT_AUTHORED_DECISION_FACTS_ONLY');assert.equal(primary.rights.terms_receipts.length,2);assert.equal(primary.news_metadata.publisher_content_rights,'NOT_ASSESSED');assert.equal(primary.claim.capacity_context.original_application_repd_baseline_mw,840);assert.equal(primary.claim.capacity_context.final_reduced_capacity_mw,null);assert(Object.values(primary. … [line shortened here: 436 characters; full line on GitHub]
assert.equal(hash(bytes(resolve(ROOT,'uk_renewables_pipeline',primaryCatalogue.canonical.edition,primaryCatalogue.canonical.partition))),primaryCatalogue.canonical.partition_sha256);
assert.equal(allCanonical.find(r=>r.repd_ref==='12588').status,'Application Submitted');assert.equal(primary.claim.source_application_submitted,'2024-11-14');assert.equal(primaryCatalogue.canonical.fields.planning_application_submitted,'2024-11-15');
for(const ref of ['10529','18174'])assert.equal(primaryIndex.by_repd_ref[ref],undefined);
assert.throws(()=>primaryModel.buildPrimaryNotes(allCanonical,{asOf:'2026-11-17T03:16:19.999999999Z'}),/future/);
pass('three exact primary donor blobs and ROOT renderer preserve unique canonical provisional binding, receipt/rights/date/null distinctions',{producer:primaryDonor,runtime_bytes:Object.values(primaryContract.files).reduce((n,p)=>n+p.bytes,0),renderer_sha256:hash(renderer),canonical:7775,associations:1,verified:0,solar1000_verified_delta:0,source_document_sha256:primary.source.sha256});
const priceContractBytes=bytes(resolve(candidate,'contracts/prices.v931.json')),priceContract=JSON.parse(priceContractBytes);
const priceProducer='78d5360239e1a5fcffa83fcb30d5937c5521acb9',priceCache=resolve(ROOT,'automation/price_daily_ui',priceProducer);
assert.equal(priceContract.producer.commit,priceProducer);assert.deepEqual(Object.keys(priceContract.files).sort(),['canvas.mjs','model.mjs','styles.css','view.mjs']);
for(const [name,pin] of Object.entries(priceContract.files)){
const raw=bytes(resolve(priceCache,name)),donor=execFileSync('git',['show',priceProducer+':automation/news/price-daily-ui/'+name],{cwd:ROOT});
assert.deepEqual(raw,donor,name+' actual accepted producer bytes');assert.equal(raw.length,pin.bytes);assert.equal(hash(raw),pin.sha256);
assert.equal(createHash('sha1').update(Buffer.concat([Buffer.from(`blob ${raw.length}\0`),raw])).digest('hex'),pin.git_blob);
}
const priceBoot=bytes(resolve(candidate,'scripts/plugins/prices-v931.mjs')).toString('utf8');assert.ok(priceBoot.includes("const manifestHash = '"+hash(priceContractBytes)+"'"));
const priceModel=await import(pathToFileURL(resolve(priceCache,'model.mjs')));assert.deepEqual(priceContract.input,priceModel.SOURCE);
assert.equal(priceModel.SOURCE.commit,'cf48c8d6fdd9ab686c4af7261149d81a0129f7fc');assert.equal(priceModel.SOURCE.index.sha256,'3c3ad8e0d8169b4bc253dabbad2a7d35b64984f40accce1abd016e1ca15a1e8e');assert.equal(priceModel.SOURCE.index.bytes,3616);
async function priceInput(name,pin){
let raw;if(process.env.V932_PRICE_SOURCE)raw=bytes(resolve(process.env.V932_PRICE_SOURCE,name));
else{const response=await fetch(priceModel.SOURCE.base+name,{redirect:'error',signal:AbortSignal.timeout(15000)});assert.ok(response.ok);raw=Buffer.from(await response.arrayBuffer());}
assert.equal(raw.length,pin.bytes);assert.equal(hash(raw),pin.sha256,name+' immutable source bytes');return raw;
}
const priceIndex=priceModel.validateIndex(JSON.parse(await priceInput('index.json',priceModel.SOURCE.index)));
const annualRows=(await Promise.all(priceIndex.parts.map(async part=>priceModel.validateYear(JSON.parse(await priceInput(part.path,part)),part,priceIndex)))).flat();
const priceSources=JSON.parse(await priceInput(priceIndex.sources.path,priceIndex.sources));await priceInput(priceIndex.parquet.path,priceIndex.parquet);
const priceSummary=priceModel.summarise(annualRows),expected={daily_rows:annualRows.length,source_parts:priceSources.files.length,source_prices:priceSummary.priced,complete_days:priceSummary.completeDays,partial_days:priceSummary.partialDays,missing_days:priceSummary.missingDays,utc_disagreements:priceSummary.clockMismatches,first_date:annualRows[0].date,last_date:annualRows.at(-1).date};
assert.deepEqual(expected,{daily_rows:3957,source_parts:188,source_prices:189270,complete_days:3919,partial_days:25,missing_days:13,utc_disagreements:106668,first_date:'2016-01-01',last_date:'2026-10-31'});assert.deepEqual(priceContract.expected,expected);
assert.equal(priceSources.input_grain.rows,189270);assert.equal(priceSources.utc_alignment_mismatches,106668);assert.equal(new Set(priceSources.files.map(p=>p.path)).size,188);
assert.match(priceIndex.calendar_quality,/Source-declared/);assert.match(priceContract.scope,/no interpolation.*realtime/);
pass('four exact price donor blobs and accepted source/index/annual/hash provenance preserve source-day gaps/partial/UTC distinctions',{producer:priceProducer,source:priceModel.SOURCE.commit,runtime_bytes:Object.values(priceContract.files).reduce((n,p)=>n+p.bytes,0),expected,transport:process.env.V932_PRICE_SOURCE?'existing data-owner bytes matched to immutable pins':'immutable source-owner HTTP … [line shortened here: 405 characters; full line on GitHub]
const contractPath=resolve(candidate,'contracts/dc-locations.v930.json'),contractBytes=bytes(contractPath),contract=JSON.parse(contractBytes);
const donorCommit='83e7c36d08ef98f3665f7f35b8637405391dc4be';
assert.equal(contract.producer.commit,donorCommit);assert.deepEqual(Object.keys(contract.files).sort(),['actions.css','actions.mjs']);
const cache=resolve(ROOT,'automation/dc_location_ui',donorCommit);
for(const [name,pin] of Object.entries(contract.files)){
const local=bytes(resolve(cache,name)),donor=execFileSync('git',['show',donorCommit+':automation/news/dc-locations/'+name],{cwd:ROOT});
assert.deepEqual(local,donor,name+' actual immutable producer bytes');assert.equal(hash(local),pin.sha256);assert.equal(local.length,pin.bytes);
assert.equal(createHash('sha1').update(Buffer.concat([Buffer.from(`blob ${local.length}\0`),local])).digest('hex'),pin.git_blob);
}
const boot=bytes(resolve(candidate,'scripts/plugins/dc-locations-v930.mjs')).toString('utf8');
assert.ok(boot.includes("const manifestHash = '"+hash(contractBytes)+"'"),'host pins exact accepted manifest bytes');
const imported=await import(pathToFileURL(resolve(cache,'actions.mjs')));assert.deepEqual(contract.input,imported.INPUT);
assert.equal(contract.input.sha256,'6f68e078d9b57057acdda679288730e638553f68df884dfd747c5049e56ea88e');assert.equal(contract.input.bytes,183561);
let input,transport;
if(process.env.V932_DATA_SOURCE){input=bytes(resolve(process.env.V932_DATA_SOURCE));transport='explicit existing data-owner file, byte checked';}
else{const response=await fetch(contract.input.url,{redirect:'error',signal:AbortSignal.timeout(15000)});assert.equal(response.ok,true);input=Buffer.from(await response.arrayBuffer());transport='immutable data-owner HTTPS source';}
assert.equal(input.length,contract.input.bytes);assert.equal(hash(input),contract.input.sha256);
const locations=JSON.parse(input),indexed=imported.indexLocations(locations),oldDC=json(resolve(baseline,'global-datacentres/projects.json')).records;
assert.deepEqual([...indexed.keys()].sort(),oldDC.map(x=>x.id).sort(),'exact100originalIDs; no name-based join');
const observed={records:locations.features.length,with_address:locations.features.filter(f=>f.properties.addresses.length).length,address_statements:locations.features.flatMap(f=>f.properties.addresses).length,with_geometry:locations.features.filter(f=>f.geometry).length,wikidata_reported_points:locations.features.filter(f=>f.properties.location_precision==='WIKIDATA_REPORTED_POINT').length,post … [line shortened here: 673 characters; full line on GitHub]
assert.deepEqual(observed,{records:100,with_address:38,address_statements:39,with_geometry:64,wikidata_reported_points:39,postcode_centroids:25,unknown_geometry:36,screenable_gb_records:34});assert.deepEqual(contract.expected,observed);
assert.ok(locations.features.every(f=>f.properties.facility_identity_review==='NOT_INDEPENDENTLY_VERIFIED'&&f.properties.grid_connection_assessed===false));
pass('exact83e cartridge/cache/host-manifest pins and100originalIDs/38addressrecords/39statements/34GBscreens',{donorCommit,observed,source_sha256:hash(input),transport,cache_bytes:treeBytes(cache)});
const pageSource=bytes(resolve(candidate,'index.html')).toString('utf8');
assert.ok(pageSource.includes('integrity="sha256-'+createHash('sha256').update(bytes(resolve(priceCache,'styles.css'))).digest('base64')+'"'),'price CSS SRI');
assert.ok(pageSource.includes('https://globalgrid2050.com/uk_energy_tracking_v6/'),'original independent V6 workspace link retained');
assert.ok(!bytes(resolve(candidate,'scripts/plugins/layers-v929.mjs')).toString('utf8').includes("prices: {host:"),'only the new price owner mounts the Prices category');
const cssSRI='sha256-'+createHash('sha256').update(bytes(resolve(cache,'actions.css'))).digest('base64');assert.ok(pageSource.includes('integrity="'+cssSRI+'"'),'optional CSS is pinned by SRI');
assert.doesNotMatch(pageSource,/<aside\b|class=["'][^"']*\bsidebar\b/i,'new edition must not restore the removed navigation sidebar');
for(const required of ['class="release-header"','aria-label="Pipeline navigation"','../versions.html','../202611170243/','id="mapAtlasNav"','id="export"'])assert.ok(pageSource.includes(required),'compact navigation retains '+required);
pass('sidebar markup removed; compact header preserves Versions, previous edition, MAP and CSV navigation');
const pins=json(resolve(candidate,'contracts/layers-v929.json'));
assert.equal(pins.source_commit,'8f94299afc8628908dc8bf461cb5ea607560332b');assert.equal(pins.files.length,8);
for(const pin of pins.files){
const raw=bytes(resolve(candidate,'scripts/layers',basename(pin.path)));
const donor=execFileSync('git',['show',pins.source_commit+':'+pin.path],{cwd:ROOT});
assert.deepEqual(raw,donor,pin.path+' must match the actual immutable donor, not only a self-declared manifest');
assert.equal(hash(raw),pin.sha256,pin.path+' exact donor bytes');assert.equal(raw.length,pin.bytes);
assert.equal(createHash('sha1').update(Buffer.concat([Buffer.from(`blob ${raw.length}\0`),raw])).digest('hex'),pin.git_blob);
}
pass('eight imported runtime assets exactly match reviewed donor Git blobs/SHA-256',{source_commit:pins.source_commit});
const size=treeBytes(candidate);assert.ok(size<=18*1024*1024,`${size} exceeds 18 MiB`);pass('complete working edition fits unchanged 18 MiB budget',{bytes:size,limit:18*1024*1024});
const current=population(candidate),original=population(baseline);assert.deepEqual(current,original);
pass('all 7,775 official records and order equal frozen V9.31; 3,604 solar',{records:7775,solar:3604});
for(const name of ['solar1000/manifest.json','solar1000/candidates.json'])assert.deepEqual(bytes(resolve(candidate,name)),bytes(resolve(baseline,name)),name);
const selected=json(resolve(candidate,'solar1000/manifest.json'));assert.equal(selected.ids.length,1000);assert.equal(selected.independently_verified,0);
assert.deepEqual(selected.ids,current.filter(x=>x.technology==='solar').map(x=>String(x.repd_ref)).sort((a,b)=>Number(a)-Number(b)).slice(0,1000));
pass('ordered immutable Solar-1000 and provisional receipt bytes equal frozen V9.31',{sha256:hash(bytes(resolve(candidate,'solar1000/manifest.json')))});
const receiver=await import(pathToFileURL(resolve(candidate,'scripts/core/atlas-receiver-v9-7.js')));
const oldReceiver=await import(pathToFileURL(resolve(baseline,'scripts/core/atlas-receiver-v9-7.js')));
for(let i=0;i<current.length;i++)assert.equal(receiver.buildAtlasDeepLinkV9_7(current[i]),oldReceiver.buildAtlasDeepLinkV9_7(original[i]),String(current[i].repd_ref));
const existing=execFileSync(process.execPath,[resolve(candidate,'tests/check_map_contract_all_rows.mjs')],{cwd:ROOT,encoding:'utf8'}).trim();
pass('all 7,775 original MAP routes and established all-row contract preserved',{established_check:existing});
const snapshot=bytes(resolve(candidate,'news/pipeline_headlines.snapshot.json')),source=json(resolve(candidate,'news/snapshot-provenance.json'));
assert.deepEqual(bytes(resolve(candidate,'news/snapshot-provenance.json')),bytes(resolve(baseline,'news/snapshot-provenance.json')),'original source clock/provenance receipt bytes preserved');
assert.equal(hash(snapshot),source.sha256);assert.equal(JSON.parse(snapshot).items.length,71);assert.deepEqual(snapshot,bytes(resolve(baseline,'news/pipeline_headlines.snapshot.json')));
pass('original saved 71-headline source bytes and publication clock preserved',{source_commit:source.source_commit,generated_at:source.generated_at,sha256:source.sha256});
const historical=protectedEditionChanges({cwd:ROOT,base:sourceBase});
assert.deepEqual(historical,[],'every edition directory present in the pinned base remains unchanged');
pass('every baseline edition tree remains unchanged against the pinned Git base',{base:sourceBase});
receipt.status='PASS';
}catch(error){receipt.status='FAIL';receipt.failure=error.stack;throw error;}
finally{if(out){mkdirSync(out,{recursive:true});writeFileSync(resolve(out,'invariants.json'),JSON.stringify(receipt,null,2)+'\n');}}