In this section
- Index V7 Before Leapfrog render · solar-electrical-topology-analysis-engine-text-based / restore_points/2026-07-27-v8-leapfrog/index-v7-before-leapfrog.html lines 1–107
- Index V8 Initial render · solar-electrical-topology-analysis-engine-text-based / restore_points/2026-07-27-v8-leapfrog/index-v8-initial.html lines 1–88
- Advance Microbuild ingest · solar-electrical-topology-analysis-engine-text-based / scripts/advance_microbuild.py lines 1–129
- Build Authority Bundle storage · solar-electrical-topology-analysis-engine-text-based / scripts/build_authority_bundle.py lines 1–92
- Build Topology Store ingest · solar-electrical-topology-analysis-engine-text-based / scripts/build_topology_store.py lines 1–100
- Check Capsule Links ingest · solar-electrical-topology-analysis-engine-text-based / scripts/check_capsule_links.py lines 1–180
Index V7 Before Leapfrog
A web page in the restore points folder of Solar Electrical Topology Analysis Engine Text Based that draws solar DC topology study and cables. Published at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/restore_points/2026-07-27-v8-leapfrog/index-v7-before-leapfrog.html.
rendersolar-electrical-topology-analysis-engine-text-based / restore_points/2026-07-27-v8-leapfrog/index-v7-before-leapfrog.html · lines 1–107 of 107 · Entry point · pattern cmInductance (shared by 2 files)
- What it does
- It draws solar DC topology study and cables. Defines 10 functions or classes, including bands, acosh, twoWire, cap, coldVoc. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage sub33kv_design (repository name word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: cables.
- Inputs & outputs
- In: form fields (user input). Out: JSON file solar-dc-topology-v7-study.json; downloaded file solar-dc-topology-v7-study.json; web page; canvas drawing.
- Downstream impact
- It is itself an entry point, published at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/restore_points/2026-07-27-v8-leapfrog/index-v7-before-leapfrog.html.
- What it achieves
- It sets zoom (`setZoom`) and is built from the bands step (`bands`) and the acosh step (`acosh`). Solar DC String Topology Engine V7 — Independent Development. It responds to input, pointerdown and pointermove events.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- solar-electrical-topology-analysis-engine-text-based · restore_points/2026-07-27-v8-leapfrog · page
- Uses
- none found
- Used by
- none found
- Produces
- bands, acosh, twoWire, cap, coldVoc, moduleCaps, route, pairMppts, cmInductance, setZoom
- Defines here
- bands, acosh, twoWire, cap, coldVoc, moduleCaps, route, pairMppts, cmInductance, setZoom
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 restore_points/2026-07-27-v8-leapfrog/index-v7-before-leapfrog.html:1-107 · blob e55babbdf44c8c5a911ee01fce3ad36931bbe3ed · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Solar DC String Topology Engine V7 — Independent Development</title>
<style>
:root{color-scheme:dark;--bg:#05070a;--panel:#0b1118;--line:#263747;--text:#ecf7ff;--muted:#90a4b8;--cyan:#27d8ff;--purple:#b893ff;--amber:#ffb347;--red:#ff5c67;--green:#48e28d}*{box-sizing:border-box}html,body{margin:0;background:radial-gradient(circle at 75% 0,#10263a 0,#05070a 38%);color:var(--text);font-family:Inter,system-ui,-apple-system,"Segoe UI",sans-serif}header{display:flex;justify-cont … [line shortened here: 5,017 characters; full line on GitHub]
</style>
</head>
<body>
<header><div><div class="kicker">GLOBALGRID2050 · INDEPENDENT V7 WORKSPACE</div><h1>Solar DC String Topology Engine</h1><p>Independent calculation workspace using the proven physical array geometry from the working engine.</p></div><div class="status">V7 IN DEVELOPMENT</div></header>
<div class="warning"><strong>USE AT YOUR OWN RISK.</strong> Research prototype only. The root V6 engine remains independent and unchanged. The frequency-dependent water-film model is still pending.</div>
<div class="shell">
<aside class="controls">
<section class="card"><h2>Physical A-frame geometry</h2>
<label>Modules / string <input id="modules" type="number" value="30" min="1"></label>
<label>Module width (m) <input id="moduleWidth" type="number" value="1.303" step="0.001"></label>
<label>Module length (m) <input id="moduleLength" type="number" value="2.384" step="0.001"></label>
<label>Along-row gap (m) <input id="gap" type="number" value="0.020" step="0.001"></label>
<label>Clamp gap (m) <input id="clampGap" type="number" value="0.020" step="0.001"></label>
<label>Tilt (degrees) <input id="tilt" type="number" value="10" step="0.1"></label>
<label>East bands <input id="eastBands" type="text" value="5,5,2"></label>
<label>West bands <input id="westBands" type="text" value="5,5,2"></label>
<label>Near allowance (m) <input id="near" type="number" value="10" step="0.5"></label>
<div class="note">The renderer now uses the same physical structure as the working engine: bands run along the row; East and West faces occupy opposite sides of the A-frame centreline.</div></section>
<section class="card"><h2>Wiring scenario</h2>
<label>Topology <select id="wiring"><option value="sequential">Sequential / far return</option><option value="leapfrog">Leapfrog / both ends near</option></select></label>
<label>MPPT count <input id="mppts" type="number" value="12" min="1"></label>
<label>External spacing (mm) <input id="spacing" type="number" value="40" min="3" step="1"></label>
<label>Effective εr <input id="epsilon" type="number" value="1.3" min="1" step="0.1"></label>
<label>Cable height (m) <input id="height" type="number" value="1.5" min="0.01" step="0.1"></label>
<label>Rise time (µs) <input id="rise" type="number" value="1.2" min="0.001" step="0.1"></label>
<div class="note">The wiring mode changes conductor routes only. It does not alter the physical module arrangement.</div></section>
<section class="card"><h2>Complete series circuit</h2>
<label>Positive lead/module (m) <input id="posLead" type="number" value="0.35" step="0.01"></label>
<label>Negative lead/module (m) <input id="negLead" type="number" value="0.28" step="0.01"></label>
<label>Home-run R20 (mΩ/m) <input id="homeR20" type="number" value="3.39" step="0.01"></label>
<label>Lead R20 (mΩ/m) <input id="leadR20" type="number" value="5.09" step="0.01"></label>
<label>Home-run temp (°C) <input id="homeTemp" type="number" value="70"></label>
<label>Lead temp (°C) <input id="leadTemp" type="number" value="75"></label>
<label>Connector mated pairs <input id="pairs" type="number" value="33" min="0"></label>
<label>Resistance / pair (mΩ) <input id="pairR" type="number" value="0.35" step="0.01"></label>
<div class="note">4 mm² module leads and 6 mm² home-runs remain calculated separately.</div></section>
<section class="card"><h2>Module capacitance to frame / earth</h2>
<label>Glass εr <input id="glassEr" type="number" value="7.5" step="0.1"></label>
<label>Glass thickness (mm) <input id="glass" type="number" value="2.0" step="0.1"></label>
<label>Wetted face count <select id="wetFaces"><option value="1">1</option><option value="2" selected>2</option></select></label>
<label>Frame/glass contact width (mm) <input id="contactWidth" type="number" value="10" step="1"></label>
<label>IMD alarm threshold (kΩ) <input id="alarmKohm" type="number" value="100" step="10"></label>
<label>Required response time (s) <input id="responseTime" type="number" value="30" step="1"></label>
<label>Switching frequency (Hz) <input id="switchingHz" type="number" value="4000" step="100"></label>
<div class="note">Current V7 retains fixed dry/full-area wet screening values. Frequency-dependent film participation and iterative resonance remain pending.</div></section>
<section class="card"><h2>Module voltage</h2>
<label>Module Voc (V) <input id="moduleVoc" type="number" value="45.9" step="0.1"></label>
<label>βVoc (%/°C) <input id="betaVoc" type="number" value="-0.25" step="0.01"></label>
<label>Minimum cell temperature (°C) <input id="coldTemp" type="number" value="-10"></label>
<label>System maximum voltage (V) <input id="systemMax" type="number" value="1500"></label>
</section>
<section class="card"><h2>Plant basis</h2>
<label>Installed inverters <input id="siteInv" type="number" value="900"></label>
<label>Actual strings <input id="siteStrings" type="number" value="18918"></label>
<label>Max strings/inverter <input id="maxStrings" type="number" value="24"></label>
<label>Inverter kVA <input id="invKva" type="number" value="352"></label>
<label>Registered export MW <input id="exportMw" type="number" value="280"></label>
<label>Installed DC MWp <input id="dcMwp" type="number" value="372.8376" step="0.0001"></label>
</section>
<div class="buttons"><button id="reset">RESET</button><button id="export" class="primary">EXPORT V7 JSON</button></div>
</aside>
<section class="workspace">
<div id="fatal" class="error"></div>
<div class="toprow"><div><h2>Independent V7 topology</h2><p>Physical layout retained from V6; only the V7 solver and outputs differ.</p></div><div class="legend"><span class="east">East</span><span class="west">West</span><span class="pos">+</span><span class="neg">−</span><span class="inv">Inverter</span></div></div>
<div class="canvasWrap" id="wrap"><div class="zoom"><button id="zoomOut">−</button><button id="zoomReset">100%</button><button id="zoomIn">+</button></div><canvas id="scene" width="2200" height="1350"></canvas></div>
<div id="modelBanner" class="banner"></div>
<div class="summary">
<article><span>Row span</span><strong id="rowSpan">—</strong><small>derived geometry</small></article><article><span>Archetype strings</span><strong id="archetypeStrings">—</strong><small>selected drawing</small></article><article><span>Fleet average</span><strong id="fleetAverage">—</strong><small>actual strings / inverters</small></article><article><span>Installed ACmax</span><strong id="acmax"> … [line shortened here: 455 characters; full line on GitHub]
<article><span>Selected + / −</span><strong id="selectedLengths">—</strong><small>external conductors</small></article><article><span>Complete conductor</span><strong id="totalConductor">—</strong><small>home-runs + module leads</small></article><article><span>R20 / R operating</span><strong id="resistance">—</strong><small>complete circuit</small></article><article><span>Voltage drop</span><stron … [line shortened here: 472 characters; full line on GitHub]
<article><span>L differential low / high</span><strong id="inductance">—</strong><small>internal L included / removed</small></article><article><span>L common mode</span><strong id="cmInductance">—</strong><small>both poles against earth</small></article><article><span>C module dry / wet</span><strong id="capModule">—</strong><small>per module</small></article><article><span>C string dry / wet</sp … [line shortened here: 479 characters; full line on GitHub]
<article><span>C MPPT dry / wet</span><strong id="capMppt">—</strong><small>two-string input</small></article><article><span>C inverter dry / wet</span><strong id="capInverter">—</strong><small>all archetype strings</small></article><article><span>IMD τ dry / wet</span><strong id="imdTau">—</strong><small>Ralarm × C</small></article><article><span>Minimum detectable R</span><strong id="imdRmin">—< … [line shortened here: 456 characters; full line on GitHub]
<article><span>CM impedance @ switching</span><strong id="cmZ">—</strong><small>per inverter</small></article><article><span>CM resonance dry / wet</span><strong id="cmResonance">—</strong><small>fixed screening model</small></article><article><span>Z₀ / initial wave</span><strong id="wave">—</strong><small>high-frequency differential screen</small></article><article><span>One-way / round-trip</sp … [line shortened here: 478 characters; full line on GitHub]
<article><span>Cold Voc / margin</span><strong id="coldVocOut">—</strong><small id="coldVocBasis">—</small></article><article><span>Breach temperature</span><strong id="breachTempOut">—</strong><small>system maximum voltage</small></article>
</div>
<div class="tables"><details open><summary>All strings — V7 schedule</summary><div class="scroll"><table><thead><tr><th>ID</th><th>Face</th><th>Band</th><th>Rank</th><th>Mode</th><th>+ m</th><th>− m</th><th>Leads m</th><th>Total m</th><th>R20 Ω</th><th>R op Ω</th><th>ΔV V</th><th>L diff low µH</th><th>L diff high µH</th><th>L CM µH</th><th>C dry/wet µF</th><th>Z₀ Ω</th><th>MPPT</th></tr></thead><t … [line shortened here: 681 characters; full line on GitHub]
<div class="compare"><section><h3>Working root engine</h3><ul><li>Protected and unchanged</li><li>Source of the proven geometry and interaction pattern</li><li>Regression reference</li></ul></section><section><h3>Independent V7</h3><ul><li>Same physical array representation</li><li>Separate V7 calculations and exports</li><li>Sequential/leapfrog scenarios alter cable paths, not modules</li><li>Fre … [line shortened here: 480 characters; full line on GitHub]
</section></div>
<script>
'use strict';(()=>{
const MU0=4*Math.PI*1e-7,EPS0=8.8541878128e-12,ALPHA=.00393,$=id=>document.getElementById(id),num=id=>Number($(id).value),text=id=>$(id).value;let selected=1,zoom=1,drag=false,startX=0,startY=0,startLeft=0,startTop=0;
function bands(id){const a=text(id).split(',').map(x=>Math.round(Number(x.trim()))).filter(x=>x>0);return a.length?a:[1]}
function acosh(x){return Math.log(x+Math.sqrt(x*x-1))}
function twoWire(spacingMm,areaMm2,er){const d=Math.sqrt(4*areaMm2/Math.PI)/1000,D=spacingMm/1000;if(!(D>d))throw new Error('Spacing must exceed metallic conductor diameter');const g=acosh(D/d),ext=MU0/Math.PI*g,int=MU0/(4*Math.PI),C=Math.PI*EPS0*er/g;return{diameter:d,Llow:ext+int,Lhigh:ext,C,z0:Math.sqrt(ext/C),v:1/Math.sqrt(ext*C)}}
function cap(area,thickMm,er){return EPS0*er*area/(thickMm/1000)}function rTemp(r20,t){return r20*(1+ALPHA*(t-20))}
function coldVoc(){return num('moduleVoc')*num('modules')*(1+(num('betaVoc')/100)*(num('coldTemp')-25))}function breachTemp(){const base=num('moduleVoc')*num('modules'),b=num('betaVoc')/100;return b===0?NaN:25+(num('systemMax')/base-1)/b}
function moduleCaps(){const w=num('moduleWidth'),l=num('moduleLength'),area=w*l,perimeter=2*(w+l),dryArea=perimeter*num('contactWidth')/1000;return{area,dryArea,dryModule:cap(dryArea,num('glass'),num('glassEr')),wetModule:cap(area*num('wetFaces'),num('glass'),num('glassEr'))}}
function geometry(){const N=num('modules'),w=num('moduleWidth'),gap=num('gap'),row=N*w+(N-1)*gap,rankSlope=num('moduleLength')+num('clampGap'),rankPlan=rankSlope*Math.cos(num('tilt')*Math.PI/180),near=num('near'),bandGap=.5,all=[];let id=1;[['E',-1,bands('eastBands')],['W',1,bands('westBands')]].forEach(([face,sign,list])=>list.forEach((count,band)=>{const x0=near+band*(row+bandGap),x1=x0+row;for( … [line shortened here: 766 characters; full line on GitHub]
function route(s){const mode=text('wiring'),nearEnd=s.x0,farEnd=s.x1;if(mode==='leapfrog')return{p:nearEnd,n:nearEnd};return s.face==='E'?{p:nearEnd,n:farEnd}:{p:farEnd,n:nearEnd}}
function pairMppts(strings){const mppts=num('mppts'),un=[...strings],pairs=[];let m=1;while(un.length&&m<=mppts){const a=un.shift(),idx=un.findIndex(x=>x.face===a.face&&x.band===a.band),b=idx>=0?un.splice(idx,1)[0]:un.shift();pairs.push({mppt:m++,a,b,type:b?(a.face===b.face&&a.band===b.band?'within-band':'forced cross-band'):'single'})}return pairs}
function cmInductance(s,tw){const r=tw.diameter/2,separation=num('spacing')/1000,req=Math.sqrt(Math.max(r*separation,1e-15)),ratio=2*num('height')/req,perM=ratio>1?MU0/(2*Math.PI)*Math.log(ratio):0,length=Math.max(s.p,s.n)+s.leadLen/2;return{perM,length,total:perM*length}}
function compute(){const g=geometry(),tw=twoWire(num('spacing'),6,num('epsilon')),caps=moduleCaps(),r20Home=num('homeR20')/1000,r20Lead=num('leadR20')/1000,pairR=num('pairR')/1000,imp=17.35;g.strings.forEach(s=>{Object.assign(s,route(s));s.leadLen=num('modules')*(num('posLead')+num('negLead'));s.total=s.p+s.n+s.leadLen;s.r20=(s.p+s.n)*r20Home+s.leadLen*r20Lead+num('pairs')*pairR;s.rop=(s.p+s.n)*rT … [line shortened here: 797 characters; full line on GitHub]
function renderCanvas(d){const c=$('scene'),ctx=c.getContext('2d'),W=c.width,H=c.height;ctx.clearRect(0,0,W,H);ctx.fillStyle='#04070b';ctx.fillRect(0,0,W,H);const padL=190,padR=90,padY=125,worldMinX=0,worldMaxX=d.width+2,worldMinY=-d.maxRanks*d.rankPlan,worldMaxY=d.maxRanks*d.rankPlan,sc=Math.min((W-padL-padR)/(worldMaxX-worldMinX),(H-2*padY)/(worldMaxY-worldMinY)),sx=x=>padL+(x-worldMinX)*sc,sy=y … [line shortened here: 902 characters; full line on GitHub]
for(const s of d.strings){const sel=s.id===selected,yy=Math.min(s.y0,s.y1),h=Math.abs(s.y1-s.y0),moduleW=num('moduleWidth')*sc,gap=num('gap')*sc;for(let i=0;i<num('modules');i++){const x=s.x0+i*(num('moduleWidth')+num('gap'));ctx.fillStyle=sel?'rgba(255,179,71,.30)':s.face==='E'?'rgba(39,216,255,.19)':'rgba(184,147,255,.22)';ctx.strokeStyle=sel?'#ffb347':s.face==='E'?'#67dcff':'#c1a7ff';ctx.lineWi … [line shortened here: 1,403 characters; full line on GitHub]
function render(){try{$('fatal').style.display='none';const d=compute(),strings=d.strings,s=strings.find(x=>x.id===selected)||strings[0];if(!s)return;selected=s.id;renderCanvas(d);const invCount=strings.length,CinvDry=s.Cdry*invCount,CinvWet=s.Cwet*invCount,CmpptDry=s.Cdry*2,CmpptWet=s.Cwet*2,Ralarm=num('alarmKohm')*1000,response=num('responseTime'),f=num('switchingHz'),tauDry=Ralarm*CinvDry,tauWe … [line shortened here: 4,065 characters; full line on GitHub]
function setZoom(next){zoom=Math.max(.5,Math.min(2.2,next));$('scene').style.width=(2200*zoom)+'px';$('scene').style.height=(1350*zoom)+'px';$('zoomReset').textContent=Math.round(zoom*100)+'%'}
document.querySelectorAll('input,select').forEach(el=>el.addEventListener('input',render));$('zoomIn').onclick=()=>setZoom(zoom+.25);$('zoomOut').onclick=()=>setZoom(zoom-.25);$('zoomReset').onclick=()=>setZoom(1);$('reset').onclick=()=>location.reload();$('export').onclick=()=>{const d=compute(),blob=new Blob([JSON.stringify({version:'v7-development-geometry-recovered',generated:new Date().toISOS … [line shortened here: 1,451 characters; full line on GitHub]
})();
</script>
</body></html>Index V8 Initial
A web page in the restore points folder of Solar Electrical Topology Analysis Engine Text Based that draws leapfrog cable schedule and cables. Published at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/restore_points/2026-07-27-v8-leapfrog/index-v8-initial.html.
rendersolar-electrical-topology-analysis-engine-text-based / restore_points/2026-07-27-v8-leapfrog/index-v8-initial.html · lines 1–88 of 88 · Entry point · pattern parseBands (shared by 2 files)
- What it does
- It draws leapfrog cable schedule and cables. Defines $, fmt, parseBands, parseNumbers, rowSpan. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage sub33kv_design (repository name word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: cables.
- Inputs & outputs
- In: form fields (user input). Out: JSON file v8-leapfrog-cable-schedule.json; downloaded file v8-leapfrog-cable-schedule.json; web page; canvas drawing.
- Downstream impact
- It is itself an entry point, published at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/restore_points/2026-07-27-v8-leapfrog/index-v8-initial.html.
- What it achieves
- It parses bands (`parseBands`) and parses numbers (`parseNumbers`). Independent V8 development workbench comparing sequential and leapfrog PV string home-run cable schedules. It responds to input and click events.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- solar-electrical-topology-analysis-engine-text-based · restore_points/2026-07-27-v8-leapfrog · page
- Uses
- none found
- Used by
- none found
- Produces
- $, fmt, parseBands, parseNumbers, rowSpan
- Defines here
- $, fmt, parseBands, parseNumbers, rowSpan
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 restore_points/2026-07-27-v8-leapfrog/index-v8-initial.html:1-88 · blob 4eab2b3c2428f302f2be7192a86fe99ffbb21460 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>V8 Leapfrog DC String Cable Schedule</title>
<meta name="description" content="Independent V8 development workbench comparing sequential and leapfrog PV string home-run cable schedules.">
<style>
:root{color-scheme:dark;--bg:#05070a;--panel:#0b1118;--panel2:#101923;--line:#263747;--text:#eef7ff;--muted:#9db0c0;--cyan:#27d8ff;--amber:#ffb347;--green:#53e28b;--red:#ff6170;--purple:#bd96ff}*{box-sizing:border-box}html,body{margin:0;background:radial-gradient(circle at 70% 0,#112b3f 0,#05070a 42%);color:var(--text);font-family:Inter,system-ui,-apple-system,"Segoe UI",Arial,sans-serif}body{min- … [line shortened here: 4,963 characters; full line on GitHub]
</style>
</head>
<body>
<header class="top"><div><div class="kicker">GLOBALGRID2050 · OPEN ELECTRICAL ENGINEERING · V8 DEVELOPMENT</div><h1>Leapfrog DC String Cable Schedule</h1><p>Independent V8 workbench comparing sequential stringing against leapfrog stringing. It focuses on the external EPC-installed 6 mm² DC string cables / home-runs, then shows resistance, voltage drop and loss difference from that topology choice. … [line shortened here: 478 characters; full line on GitHub]
<div class="warning"><strong>ENGINEERING SCREENING OUTPUT.</strong> V8 is a generic calculation aid. It does not prove as-built wiring, routing feasibility, cable quantities, compliance, protection coordination or procurement readiness. Every value must be checked against drawings, measured lead lengths, actual route, cable datasheets, connector evidence and competent engineering review.</div>
<div class="layout">
<aside class="controls">
<section class="panel"><h2>String geometry</h2>
<label>Modules per string <input id="modules" type="number" min="1" value="30"></label>
<label>Module width along row (m) <input id="moduleWidth" type="number" min="0.1" step="0.001" value="1.303"></label>
<label>Along-row module gap (m) <input id="gap" type="number" min="0" step="0.001" value="0.020"></label>
<label>Band gap / route allowance (m) <input id="bandGap" type="number" min="0" step="0.1" value="0.0"></label>
<div class="note">Row span is derived as modules × module width + gaps between modules. No user-entered row length is used.</div>
</section>
<section class="panel"><h2>String bands</h2>
<p>Each band is a group of strings whose near terminals sit the same number of row spans away from the inverter end.</p>
<label>East face bands <input id="eastBands" type="text" value="5,5,2"></label>
<label>West face bands <input id="westBands" type="text" value="5,5,2"></label>
<label>Near distance to inverter (m) <input id="distance" type="number" min="0" step="1" value="10"></label>
<label>Scenario distances (m) <input id="scenarios" type="text" value="10,20,30"></label>
<div class="note">Changing inverter distance raises both modes. Leapfrog saving comes from removing one full-row return conductor per string.</div>
</section>
<section class="panel"><h2>Cable and electrical inputs</h2>
<label>External cable R20 (mΩ/m) <input id="r20" type="number" min="0" step="0.01" value="3.39"></label>
<label>Cable operating temp (°C) <input id="temp" type="number" step="1" value="70"></label>
<label>Current per string (A) <input id="current" type="number" min="0" step="0.01" value="17.35"></label>
<label>Inverter count for fleet <input id="inverters" type="number" min="1" step="1" value="795"></label>
<label>Currency rate per m (optional) <input id="rate" type="number" min="0" step="0.01" value="0"></label>
<div class="note">Default external cable resistance uses a 6 mm² tinned copper PV string cable screening value. Module factory leads are not counted as EPC-installed external home-runs here.</div>
</section>
<section class="panel"><h2>Mode meaning</h2>
<div class="formula">Sequential: one string terminal near, one terminal far.
Leapfrog: both free terminals near; far end is turn-around.
Saving per string = one row span.</div>
<div class="buttons"><button class="primary" id="exportBtn">Export JSON</button><a class="button" href="../">Back to V6</a></div>
</section>
</aside>
<main class="work">
<div class="tabs"><button class="tab active" data-tab="tabcalc">Calculator</button><button class="tab" data-tab="tabdiagram">Diagram</button><button class="tab" data-tab="tabcommentary">Technical commentary</button></div>
<div id="tabcalc" class="tabpane active">
<div class="summary">
<article><span>Row span</span><strong id="rowSpan" class="cyan">—</strong><small>derived 30-module length</small></article>
<article><span>Strings / inverter</span><strong id="stringsInv">—</strong><small>east + west bands</small></article>
<article><span>Saving / inverter</span><strong id="savingInv" class="green">—</strong><small>external 6 mm² avoided</small></article>
<article><span>Saving / fleet</span><strong id="savingFleet" class="green">—</strong><small>using editable inverter count</small></article>
<article><span>Sequential / inverter</span><strong id="seqInv" class="bad">—</strong><small>external + and − cable</small></article>
<article><span>Leapfrog / inverter</span><strong id="leapInv">—</strong><small>external + and − cable</small></article>
<article><span>Resistance saved</span><strong id="rSaved" class="green">—</strong><small>at operating temperature</small></article>
<article><span>Loss saved</span><strong id="lossSaved" class="green">—</strong><small>at string current</small></article>
</div>
<section class="section"><h2>Band schedule · sequential versus leapfrog</h2><div class="table-wrap"><table><thead><tr><th>Face</th><th>Band</th><th>Strings</th><th>Offset m</th><th>Sequential + m</th><th>Sequential − m</th><th>Sequential total m</th><th>Leapfrog + m</th><th>Leapfrog − m</th><th>Leapfrog total m</th><th>Saving m/string</th><th>Saving m/band</th></tr></thead><tbody id="schedule"></t … [line shortened here: 462 characters; full line on GitHub]
<section class="section"><h2>Distance scenarios</h2><div class="table-wrap"><table><thead><tr><th>Inverter distance m</th><th>Sequential m/inverter</th><th>Leapfrog m/inverter</th><th>Saving m/inverter</th><th>Saving km/fleet</th><th>Loss saving kW/fleet</th></tr></thead><tbody id="scenarioTable"></tbody></table></div></section>
<section class="section"><h2>Calculation trace</h2><div class="body"><pre id="trace"></pre></div></section>
</div>
<div id="tabdiagram" class="tabpane"><section class="section"><h2>Visual impact of leapfrog</h2><div class="body">Black cables show the home-run consequence. In sequential wiring one free terminal is at the far end, so a far-end return conductor is required. In leapfrog wiring both free terminals emerge at the inverter-side end; the far end is only a turn-around within the module string.</div><div … [line shortened here: 497 characters; full line on GitHub]
<div id="tabcommentary" class="tabpane"><section class="section"><h2>Technical commentary used to build V8</h2><div class="body"><p>A thirty-module string still has one positive free terminal and one negative free terminal. Leapfrog does not change the electrical string. It changes where the two terminals appear physically.</p><p>In conventional sequential wiring, the modules are connected in phys … [line shortened here: 1,508 characters; full line on GitHub]
</main>
</div>
<footer class="foot">V8 is isolated in its own folder. V6 and V7 remain comparison versions. Public manufacturer defaults are helpful, but this page is not a substitute for measured lead lengths, as-built string tracing or competent review.</footer>
<script>
'use strict';
const $=id=>document.getElementById(id);const ids=['modules','moduleWidth','gap','bandGap','eastBands','westBands','distance','scenarios','r20','temp','current','inverters','rate'];
const fmt=(v,d=2)=>Number.isFinite(v)?v.toLocaleString('en-GB',{minimumFractionDigits:d,maximumFractionDigits:d}):'—';
function parseBands(id){const arr=$(id).value.split(',').map(x=>Math.max(0,Math.round(Number(x.trim())))).filter(x=>x>0);return arr.length?arr:[0];}
function parseNumbers(id){return $(id).value.split(',').map(x=>Number(x.trim())).filter(x=>Number.isFinite(x)&&x>=0);}
function inputs(){return{modules:Math.max(1,Math.round(Number($('modules').value))),moduleWidth:Math.max(.001,Number($('moduleWidth').value)),gap:Math.max(0,Number($('gap').value)),bandGap:Math.max(0,Number($('bandGap').value)),eastBands:parseBands('eastBands'),westBands:parseBands('westBands'),distance:Math.max(0,Number($('distance').value)),scenarios:parseNumbers('scenarios'),r20:Math.max(0,Numb … [line shortened here: 602 characters; full line on GitHub]
function rowSpan(m){return m.modules*m.moduleWidth+(m.modules-1)*m.gap;}
function rowsFor(m,D=m.distance){const R=rowSpan(m),faces=[['E',m.eastBands],['W',m.westBands]],rows=[];for(const [face,bands] of faces){bands.forEach((count,i)=>{const off=i*(R+m.bandGap),near=D+off,far=near+R;const seqP=near,seqN=far,leapP=near,leapN=near;rows.push({face,band:i+1,count,offset:off,seqP,seqN,seqTotal:(seqP+seqN)*count,leapP,leapN,leapTotal:(leapP+leapN)*count,savingPerString:R,sav … [line shortened here: 435 characters; full line on GitHub]
function totals(m,D=m.distance){const rows=rowsFor(m,D);const strings=rows.reduce((a,r)=>a+r.count,0);const seq=rows.reduce((a,r)=>a+r.seqTotal,0);const leap=rows.reduce((a,r)=>a+r.leapTotal,0);const saved=seq-leap;const rOpPerM=m.r20/1000*(1+0.00393*(m.temp-20));const rSaved=saved*rOpPerM;const lossSaved=m.current*m.current*rSaved;return{rows,strings,seq,leap,saved,rOpPerM,rSaved,lossSaved,costSa … [line shortened here: 419 characters; full line on GitHub]
function drawDiagram(m,t){const c=$('diagram'),ctx=c.getContext('2d'),W=c.width,H=c.height;ctx.clearRect(0,0,W,H);ctx.fillStyle='#03070b';ctx.fillRect(0,0,W,H);const R=rowSpan(m),D=m.distance;const modules=Math.min(m.modules,30);function cable(points,w=4){ctx.save();ctx.lineJoin='round';ctx.lineCap='round';ctx.strokeStyle='rgba(238,247,255,.75)';ctx.lineWidth=w+2;ctx.beginPath();points.forEach((p, … [line shortened here: 616 characters; full line on GitHub]
function moduleRow(y,title,leap){const x0=180,w=25,h=52,g=7;ctx.fillStyle='#dff7ff';ctx.font='800 20px ui-monospace,monospace';ctx.fillText(title,30,y+32);ctx.fillStyle='#ffb347';ctx.fillRect(78,y+8,42,110);ctx.fillStyle='#ffdca6';ctx.font='700 15px ui-monospace,monospace';ctx.fillText('INVERTER',42,y);for(let i=0;i<modules;i++){const x=x0+i*(w+g);ctx.fillStyle=i%2?'#12344a':'#16485e';ctx.fillRect … [line shortened here: 1,425 characters; full line on GitHub]
moduleRow(70,'Sequential',false);moduleRow(310,'Leapfrog',true);ctx.fillStyle='#adc0cf';ctx.font='800 17px ui-monospace,monospace';ctx.fillText(`Current inputs: row span ${fmt(R,2)} m, inverter distance ${fmt(D,1)} m, saving ${fmt(t.saved,1)} m/inverter`,30,500);}
function render(){const m=inputs(),R=rowSpan(m),t=totals(m);$('rowSpan').textContent=fmt(R,2)+' m';$('stringsInv').textContent=String(t.strings);$('savingInv').textContent=fmt(t.saved/1000,3)+' km';$('savingFleet').textContent=fmt(t.saved*m.inverters/1000,1)+' km';$('seqInv').textContent=fmt(t.seq/1000,3)+' km';$('leapInv').textContent=fmt(t.leap/1000,3)+' km';$('rSaved').textContent=fmt(t.rSaved, … [line shortened here: 2,301 characters; full line on GitHub]
ids.forEach(id=>$(id).addEventListener('input',render));document.querySelectorAll('.tab').forEach(b=>b.addEventListener('click',()=>{document.querySelectorAll('.tab').forEach(x=>x.classList.remove('active'));document.querySelectorAll('.tabpane').forEach(x=>x.classList.remove('active'));b.classList.add('active');$(b.dataset.tab).classList.add('active');render();}));
$('exportBtn').addEventListener('click',()=>{const m=inputs(),t=totals(m),payload={schema:'v8-leapfrog-external-dc-string-cable-schedule',reliance:'Indicative screening only. Not as-built, procurement, design approval or compliance certificate.',inputs:m,row_span_m:rowSpan(m),strings_per_inverter:t.strings,sequential_external_cable_m_per_inverter:t.seq,leapfrog_external_cable_m_per_inverter:t.leap … [line shortened here: 676 characters; full line on GitHub]
render();
</script>
</body>
</html>Advance Microbuild
A Python command-line tool in the scripts folder of Solar Electrical Topology Analysis Engine Text Based that loads evidence (`load_evidence`).
ingestsolar-electrical-topology-analysis-engine-text-based / scripts/advance_microbuild.py · lines 1–129 of 129 · Entry point · pattern load_evidence (shared by 2 files)
- What it does
- It loads data. Defines 6 functions or classes, including AdvancementError, require, load_evidence, manifest_evidence_record, preview_advancement. Uses libraries __future__, argparse, copy, json, pathlib. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (repository name word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
- Inputs & outputs
- In: command-line arguments.
- Downstream impact
- Used directly by 1 file: Test Microbuild Advancement (solar-electrical-topology-analysis-engine-text-based). Reached from 6 other entry points, including Build 025 Small Gates Workflow (solar-electrical-topology-analysis-engine-text-based); Microbuild Worker Workflow (solar-electrical-topology-analysis-engine-text-based); Run Microbuild (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- It is built from the advancement error class (`AdvancementError`), the require step (`require`) and the manifest evidence record helper (`manifest_evidence_record`). Preview one evidence-bound microbuild advancement without writing files. It accepts `--plan` and `--evidence`.
- Why it matters
- Checked by Test Microbuild Advancement.
- Application
- solar-electrical-topology-analysis-engine-text-based · scripts · Python CLI
- Uses
- Check Microbuild Plan (import), Microbuild Evidence (import), __future__, argparse, copy, json, pathlib, typing
- Used by
- imported by Test Microbuild Advancement (import)
- Produces
- AdvancementError, require, load_evidence, manifest_evidence_record, preview_advancement, main
- Defines here
- AdvancementError, require, load_evidence, manifest_evidence_record, preview_advancement, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 scripts/advance_microbuild.py:1-129 · blob 3a45821001763bf625974807ee3832b85bd69135 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: ingest · effects: filesystem · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
"""Preview one evidence-bound microbuild advancement without writing files."""
from __future__ import annotations
import argparse
from copy import deepcopy
import json
from pathlib import Path
from typing import Any
try:
from scripts.check_microbuild_plan import (
DEFAULT_PLAN_PATH,
load_plan,
validate_plan,
)
from scripts.microbuild_evidence import (
canonical_json,
microbuild_evidence_hash,
)
except ModuleNotFoundError: # Direct execution from the scripts directory.
from check_microbuild_plan import DEFAULT_PLAN_PATH, load_plan, validate_plan
from microbuild_evidence import canonical_json, microbuild_evidence_hash
class AdvancementError(ValueError):
"""The supplied evidence cannot advance the active step."""
def require(condition: bool, message: str) -> None:
if not condition:
raise AdvancementError(message)
def load_evidence(path: Path) -> dict[str, Any]:
payload = json.loads(path.read_text(encoding="utf-8"))
require(isinstance(payload, dict), "evidence must be one JSON object")
return payload
def manifest_evidence_record(evidence: dict[str, Any]) -> dict[str, object]:
require(set(evidence) == {"core", "evidence_hash", "runtime"}, "evidence fields changed")
core = evidence["core"]
runtime = evidence["runtime"]
require(isinstance(core, dict), "evidence core must be an object")
require(isinstance(runtime, dict), "evidence runtime must be an object")
require(
evidence["evidence_hash"] == microbuild_evidence_hash(core),
"evidence hash mismatch",
)
workflow_run_id = runtime.get("workflow_run_id")
artifact_id = runtime.get("artifact_id")
require(
isinstance(workflow_run_id, int) and workflow_run_id > 0,
"workflow_run_id is required for advancement",
)
require(
isinstance(artifact_id, int) and artifact_id > 0,
"artifact_id is required for advancement",
)
return {
"step_id": core["step_id"],
"manifest_revision": core["manifest_revision"],
"tested_commit": core["tested_commit"],
"test_id": core["test_id"],
"result": core["result"],
"workflow_run_id": workflow_run_id,
"artifact_id": artifact_id,
"evidence_hash": evidence["evidence_hash"],
}
def preview_advancement(
plan: dict[str, Any],
evidence: dict[str, Any],
) -> dict[str, Any]:
summary = validate_plan(plan)
require(summary["programme_status"] != "completed", "completed programme cannot advance")
record = manifest_evidence_record(evidence)
require(record["result"] == "pass", "only passing evidence may advance")
require(record["step_id"] == summary["active_step"], "evidence step does not match active step")
require(record["test_id"] == summary["active_test_id"], "evidence test does not match active test")
require(
record["manifest_revision"] == summary["manifest_revision"],
"evidence manifest revision does not match active revision",
)
result = deepcopy(plan)
current_index = next(
index
for index, item in enumerate(result["steps"])
if item["status"] in {"active", "blocked"}
)
result["steps"][current_index]["status"] = "passed"
result["steps"][current_index]["evidence"] = record
result["manifest_revision"] += 1
if current_index == len(result["steps"]) - 1:
result["active_step"] = None
result["next_step"] = None
else:
next_index = current_index + 1
result["steps"][next_index]["status"] = "active"
result["active_step"] = result["steps"][next_index]["id"]
result["next_step"] = (
result["steps"][next_index + 1]["id"]
if next_index + 1 < len(result["steps"])
else None
)
validate_plan(result)
return result
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--plan", type=Path, default=DEFAULT_PLAN_PATH)
parser.add_argument("--evidence", type=Path, required=True)
args = parser.parse_args()
preview = preview_advancement(load_plan(args.plan), load_evidence(args.evidence))
print(canonical_json(preview))
return 0
if __name__ == "__main__":
raise SystemExit(main())Build Authority Bundle
A Python command-line tool in the scripts folder of Solar Electrical Topology Analysis Engine Text Based that works with authority response payload (`authority_response_payload`), covering reference inverter block, using SHA-256.
storagesolar-electrical-topology-analysis-engine-text-based / scripts/build_authority_bundle.py · lines 1–92 of 92 · Entry point · pattern canonical_json (shared by 11 files)
- What it does
- Defines canonical_json, authority_response_payload, authority_response_json, write_authority_bundle, main. Uses libraries __future__, argparse, hashlib, json, pathlib. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (repository name word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
- Inputs & outputs
- In: JSON file reference-inverter-block.json; command-line arguments.
- Downstream impact
- Used directly by 9 files: Local Authority Bridge (solar-electrical-topology-analysis-engine-text-based); Run Authority Slice (solar-electrical-topology-analysis-engine-text-based); Validate Authority Bundle (solar-electrical-topology-analysis-engine-text-based); Test Authority Bundle (solar-electrical-topology-analysis-engine-text-based); and 5 more. Reached from 5 other entry points, including Build 025 Small Gates Workflow (solar-electrical-topology-analysis-engine-text-based); Run Microbuild (solar-electrical-topology-analysis-engine-text-based); Test Microbuild Runner (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- It writes authority bundle (`write_authority_bundle`) and is built from the canonical JSON helper (`canonical_json`) and the authority response JSON helper (`authority_response_json`). Generate the deterministic reference inverter-block authority bundle. It accepts `--strategy`, `--write` and `--output`.
- Why it matters
- Imported by Local Authority Bridge, Run Authority Slice and Validate Authority Bundle. Run by Authority Bundle Sync Workflow, Microbuild Worker Workflow and V10 Validation Workflow. Checked by 3 tests, including Test Authority Bundle.
- Application
- solar-electrical-topology-analysis-engine-text-based · scripts · Python CLI
- Uses
- Reference Block Command (import), __future__, argparse, hashlib, json, pathlib, sys, solar_topology, solar_topology.array
- Used by
- imported by Local Authority Bridge (import), imported by Run Authority Slice (import), imported by Validate Authority Bundle (import), imported by Test Authority Bundle (import), run by Test End to End Authority Slice (script call), imported by Test Local Authority Bridge (import), run by Authority Bundle Sync Workflow (workflow run), run by Microbuild Worker Workflow (workflow run), and 1 more
- Produces
- canonical_json, authority_response_payload, authority_response_json, write_authority_bundle, main
- Defines here
- canonical_json, authority_response_payload, authority_response_json, write_authority_bundle, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 scripts/build_authority_bundle.py:1-92 · blob 68ffc1aed4cb2bcbbd5a9127fe92f4a14d71923e · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: filesystem · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
"""Generate the deterministic reference inverter-block authority bundle."""
from __future__ import annotations
import argparse
import hashlib
import json
from pathlib import Path
import sys
import solar_topology as topology
import solar_topology.array as array_topology
try:
from scripts.reference_block_command import REFERENCE_BLOCK_COMMAND_VERSION
except ModuleNotFoundError: # Direct execution from the scripts directory.
from reference_block_command import REFERENCE_BLOCK_COMMAND_VERSION
ROOT = Path(__file__).resolve().parents[1]
AUTHORITY_RESPONSE_SCHEMA_VERSION = (
"globalgrid2050.solar-dc.authority-response.v1"
)
AUTHORITY_BUNDLE_PATH = (
ROOT / "authority-bundles" / "reference-inverter-block.json"
)
def canonical_json(payload: object) -> str:
return json.dumps(
payload,
sort_keys=True,
separators=(",", ":"),
ensure_ascii=False,
)
def authority_response_payload(strategy: str = "leapfrog") -> dict[str, object]:
block = topology.build_reference_inverter_block(strategy=strategy)
topology.validate_inverter_block_receipt(block)
if len(block.table_receipts) != 1:
raise ValueError("reference authority bundle requires one child Build 025 receipt")
child = block.table_receipts[0]
basis: dict[str, object] = {
"schema_version": AUTHORITY_RESPONSE_SCHEMA_VERSION,
"command_version": REFERENCE_BLOCK_COMMAND_VERSION,
"strategy": strategy,
"inverter_block": topology.inverter_block_payload(block),
"build025": array_topology.build025_payload(child),
}
response_hash = "sha256:" + hashlib.sha256(
canonical_json(basis).encode("utf-8")
).hexdigest()
# Canonical JSON already maps tuples to arrays. Return that same JSON-native
# shape so the Python payload equals its serialised representation exactly.
return json.loads(canonical_json({**basis, "response_hash": response_hash}))
def authority_response_json(strategy: str = "leapfrog") -> str:
return canonical_json(authority_response_payload(strategy))
def write_authority_bundle(
path: Path = AUTHORITY_BUNDLE_PATH,
*,
strategy: str = "leapfrog",
) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(authority_response_json(strategy) + "\n", encoding="utf-8")
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
"--strategy",
choices=("leapfrog", "sequential"),
default="leapfrog",
)
parser.add_argument("--write", action="store_true")
parser.add_argument("--output", type=Path, default=AUTHORITY_BUNDLE_PATH)
args = parser.parse_args(argv)
if args.write:
write_authority_bundle(args.output, strategy=args.strategy)
else:
sys.stdout.write(authority_response_json(args.strategy) + "\n")
return 0
if __name__ == "__main__":
raise SystemExit(main())Build Topology Store
A Python command-line tool in the scripts folder of Solar Electrical Topology Analysis Engine Text Based that parses bands (`parse_bands`). It is built from the parser step (`parser`).
ingestsolar-electrical-topology-analysis-engine-text-based / scripts/build_topology_store.py · lines 1–100 of 100 · Entry point · pattern parser (shared by 2 files)
- What it does
- Defines parse_bands, parser, main. Uses libraries __future__, argparse, json, os, pathlib. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'topology'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
- Inputs & outputs
- In: command-line arguments.
- Downstream impact
- It is itself an entry point (Python CLI); no other file was found loading it.
- What it achieves
- Build the deterministic topology segment store. It accepts `--output`, `--inverter-count` and `--string-count`.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- solar-electrical-topology-analysis-engine-text-based · scripts · Python CLI
- Uses
- __future__, argparse, json, os, pathlib, solar_topology.fleet_store, solar_topology.segments
- Used by
- none found
- Produces
- parse_bands, parser, main
- Defines here
- parse_bands, parser, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 scripts/build_topology_store.py:1-100 · blob fc7f25d778ea3858e6c07077c6a6555225432c4c · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: ingest · effects: filesystem · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
"""Build the deterministic topology segment store."""
from __future__ import annotations
import argparse
import json
import os
from pathlib import Path
from solar_topology.fleet_store import build_deterministic_store
from solar_topology.segments import TopologyInputs
def parse_bands(value: str) -> tuple[int, ...]:
parts = tuple(
int(part.strip())
for part in value.split(",")
if part.strip()
)
if not parts or any(part < 1 for part in parts):
raise argparse.ArgumentTypeError(
"Bands must be a comma-separated list of positive integers"
)
return parts
def parser() -> argparse.ArgumentParser:
result = argparse.ArgumentParser(
description=(
"Build zstd-compressed Hive-partitioned topology Parquet twice "
"and fail if the outputs are not byte-identical."
)
)
result.add_argument(
"--output",
type=Path,
default=Path("data/topology/current"),
)
result.add_argument("--inverter-count", type=int, default=795)
result.add_argument("--string-count", type=int, default=18_918)
result.add_argument("--east-bands", type=parse_bands, default=(5, 5, 2))
result.add_argument("--west-bands", type=parse_bands, default=(5, 5, 2))
result.add_argument(
"--positive-factory-lead-m",
type=float,
default=0.350,
)
result.add_argument(
"--negative-factory-lead-m",
type=float,
default=0.280,
)
result.add_argument(
"--measured-leapfrog-span-m",
type=float,
default=None,
)
result.add_argument(
"--source-commit",
default=os.environ.get("GITHUB_SHA", "unknown"),
)
result.add_argument(
"--fixture",
action="store_true",
help="Build a small 47-string, two-inverter passing fixture.",
)
return result
def main() -> int:
arguments = parser().parse_args()
if arguments.fixture:
arguments.inverter_count = 2
arguments.string_count = 47
arguments.positive_factory_lead_m = 1.4
arguments.negative_factory_lead_m = 1.4
inputs = TopologyInputs(
inverter_count=arguments.inverter_count,
total_site_string_count=arguments.string_count,
east_bands=arguments.east_bands,
west_bands=arguments.west_bands,
positive_factory_lead_m=arguments.positive_factory_lead_m,
negative_factory_lead_m=arguments.negative_factory_lead_m,
measured_leapfrog_span_m=(
arguments.measured_leapfrog_span_m
),
)
summary = build_deterministic_store(
inputs,
arguments.output,
source_commit=arguments.source_commit,
)
print(json.dumps(summary, indent=2, sort_keys=True))
return 0
if __name__ == "__main__":
raise SystemExit(main())Check Capsule Links
A Python command-line tool in the scripts folder of Solar Electrical Topology Analysis Engine Text Based that cleans reference (`clean_reference`), extracts references (`extract_references`) and resolves reference (`resolve_reference`).
ingestsolar-electrical-topology-analysis-engine-text-based / scripts/check_capsule_links.py · lines 1–180 of 180 · Entry point
- What it does
- It loads data. Defines 10 functions or classes, including LinkIssue, message, capsule_files, clean_reference, extract_references. Uses libraries __future__, argparse, dataclasses, pathlib, re. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (repository name word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
- Inputs & outputs
- In: command-line arguments.
- Downstream impact
- Used directly by 2 files: Run Ts004 Integration (solar-electrical-topology-analysis-engine-text-based); V10 Validation Workflow (solar-electrical-topology-analysis-engine-text-based). Reached from 6 other entry points, including Build 025 Small Gates Workflow (solar-electrical-topology-analysis-engine-text-based); Microbuild Worker Workflow (solar-electrical-topology-analysis-engine-text-based); Run Microbuild (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- It is built from the link issue class (`LinkIssue`), the message step (`message`) and the capsule files helper (`capsule_files`). Validate path references inside Quantum Spawn and Trueself capsules. It accepts `--check`.
- Why it matters
- Run by Run Ts004 Integration and V10 Validation Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · scripts · Python CLI
- Uses
- __future__, argparse, dataclasses, pathlib, re, sys, urllib.parse
- Used by
- run by Run Ts004 Integration (script call), run by V10 Validation Workflow (workflow run)
- Produces
- LinkIssue, capsule_files, clean_reference, extract_references, resolve_reference, canonical_title, check_compatibility_pointer, check_capsule_links, main
- Defines here
- LinkIssue, message, capsule_files, clean_reference, extract_references, resolve_reference, canonical_title, check_compatibility_pointer, check_capsule_links, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 scripts/check_capsule_links.py:1-180 · blob 4ed997f8fed1feeebe2d874f1d96d1257a6060c5 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: ingest · effects: filesystem · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
"""Validate path references inside Quantum Spawn and Trueself capsules."""
from __future__ import annotations
import argparse
from dataclasses import dataclass
from pathlib import Path
import re
import sys
from urllib.parse import unquote
ROOT = Path(__file__).resolve().parents[1]
CAPSULE_ROOTS = (
ROOT / "docs" / "quantum-spawn",
ROOT / "docs" / "trueself",
)
MARKDOWN_LINK_RE = re.compile(r"\[[^\]]*\]\(([^)]+)\)")
BACKTICK_RE = re.compile(r"`([^`\n]+\.md(?:#[^`\n]+)?)`")
TITLE_RE = re.compile(r"^\*\*Title:\*\*\s*(.+?)\s*$", re.MULTILINE)
CANONICAL_TARGET_RE = re.compile(
r"^\*\*Canonical Target:\*\*\s*\[[^\]]+\]\(([^)]+)\)\s*$",
re.MULTILINE,
)
PLACEHOLDER_TOKENS = ("YYYY", "...", "<", ">", "{", "}", "*", "?")
ROOT_PREFIXES = (
"docs/",
"schemas/",
"scripts/",
"tests/",
"src/",
"v6-",
"v7-",
"v8-",
"v9-",
"v10-",
"restore/",
"restore_points/",
)
@dataclass(frozen=True)
class LinkIssue:
source: Path
reference: str
resolved: Path | None
reason: str
def message(self) -> str:
source = self.source.relative_to(ROOT).as_posix()
resolved = (
self.resolved.relative_to(ROOT).as_posix()
if self.resolved is not None and self.resolved.is_relative_to(ROOT)
else str(self.resolved) if self.resolved is not None else "unresolved"
)
return f"{source}: {self.reference!r} -> {resolved}: {self.reason}"
def capsule_files() -> tuple[Path, ...]:
files: list[Path] = []
for root in CAPSULE_ROOTS:
if root.is_dir():
files.extend(root.rglob("*.md"))
return tuple(sorted(files))
def clean_reference(raw: str) -> str | None:
value = unquote(raw.strip()).strip("<>")
if not value or value.startswith(("http://", "https://", "mailto:")):
return None
value = value.split("#", 1)[0].strip()
if not value.lower().endswith(".md"):
return None
if any(token in value for token in PLACEHOLDER_TOKENS):
return None
return value
def extract_references(text: str) -> tuple[str, ...]:
references: set[str] = set()
for match in MARKDOWN_LINK_RE.finditer(text):
cleaned = clean_reference(match.group(1).split()[0])
if cleaned is not None:
references.add(cleaned)
for match in BACKTICK_RE.finditer(text):
cleaned = clean_reference(match.group(1))
if cleaned is not None:
references.add(cleaned)
return tuple(sorted(references))
def resolve_reference(source: Path, reference: str) -> Path:
candidate = Path(reference)
if candidate.is_absolute():
return ROOT / str(candidate).lstrip("/")
if reference.startswith(ROOT_PREFIXES) or candidate.parent == Path(".") and reference in {
"README.md",
"BUILD_RECOVERY_INSTRUCTIONS_CHATGPT.md",
}:
return ROOT / candidate
return source.parent / candidate
def canonical_title(path: Path) -> str | None:
match = TITLE_RE.search(path.read_text(encoding="utf-8"))
return match.group(1).strip() if match else None
def check_compatibility_pointer(path: Path, text: str) -> tuple[LinkIssue, ...]:
if not text.startswith("# Quantum Spawn Compatibility Pointer"):
return ()
match = CANONICAL_TARGET_RE.search(text)
if match is None:
return (
LinkIssue(path, "Canonical Target", None, "compatibility pointer lacks canonical target"),
)
reference = clean_reference(match.group(1))
if reference is None:
return (
LinkIssue(path, match.group(1), None, "canonical target is not a concrete Markdown path"),
)
target = resolve_reference(path, reference).resolve()
if not target.is_file():
return (
LinkIssue(path, reference, target, "canonical target does not exist"),
)
pointer_title = canonical_title(path) or ""
target_title = canonical_title(target)
if target_title is None:
return (
LinkIssue(path, reference, target, "canonical target has no Title metadata"),
)
if target_title not in pointer_title:
return (
LinkIssue(
path,
reference,
target,
f"pointer title does not contain canonical title {target_title!r}",
),
)
return ()
def check_capsule_links() -> tuple[LinkIssue, ...]:
issues: list[LinkIssue] = []
for source in capsule_files():
text = source.read_text(encoding="utf-8")
issues.extend(check_compatibility_pointer(source, text))
for reference in extract_references(text):
resolved = resolve_reference(source, reference).resolve()
if not resolved.is_relative_to(ROOT):
issues.append(
LinkIssue(source, reference, resolved, "reference escapes repository root")
)
elif not resolved.is_file():
issues.append(
LinkIssue(source, reference, resolved, "referenced Markdown file does not exist")
)
return tuple(issues)
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--check", action="store_true", help="validate capsule references")
parser.parse_args(argv)
issues = check_capsule_links()
if issues:
print("capsule-link integrity failed:", file=sys.stderr)
for issue in issues:
print("- " + issue.message(), file=sys.stderr)
return 1
print(f"capsule-link integrity passed for {len(capsule_files())} Markdown capsules")
return 0
if __name__ == "__main__":
raise SystemExit(main())