In this section
- Cross Language Test test · solar-electrical-topology-analysis-engine-text-based / v10-development/tests/cross-language.test.mjs lines 1–59
- Kernel Test test · solar-electrical-topology-analysis-engine-text-based / v10-development/tests/kernel.test.mjs lines 1–85
- Studio Authority Evidence Test test · solar-electrical-topology-analysis-engine-text-based / v10-development/tests/studio-authority-evidence.test.mjs lines 1–118
- Studio Authority Test test · solar-electrical-topology-analysis-engine-text-based / v10-development/tests/studio-authority.test.mjs lines 1–215
- Topology Test test · solar-electrical-topology-analysis-engine-text-based / v10-development/tests/topology.test.mjs lines 1–73
- V6 Leapfrog render · solar-electrical-topology-analysis-engine-text-based / v6-leapfrog.js lines 1–128
Cross Language Test
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based that checks Electrical and Quantity.
testsolar-electrical-topology-analysis-engine-text-based / v10-development/tests/cross-language.test.mjs · lines 1–59 of 59 · Entry point
- What it does
- It tests its inputs. Defines close. Uses libraries node:assert/strict, node:fs, node:test, node:url. 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 steady_state_cross_language_v1.json.
- Downstream impact
- It is itself an entry point (test); no other file was found loading it.
- What it achieves
- Defines `close`.
- Why it matters
- Guards the behaviour of Electrical and Quantity.
- Application
- solar-electrical-topology-analysis-engine-text-based · v10-development/tests · test
- Uses
- Electrical (import), Quantity (import), node:assert/strict, node:fs, node:test, node:url
- Used by
- none found
- Produces
- close
- Defines here
- close
- 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 v10-development/tests/cross-language.test.mjs:1-59 · blob 24e30f4b9d25d9caee57495d30a0b75bfc1a71fa · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: filesystem · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
import { fileURLToPath } from "node:url";
import {
conductorResistance,
resistivePowerLoss,
voltageDrop,
} from "../src/electrical.mjs";
import { quantity } from "../src/quantity.mjs";
const fixturePath = fileURLToPath(
new URL("../fixtures/steady_state_cross_language_v1.json", import.meta.url),
);
const fixture = JSON.parse(readFileSync(fixturePath, "utf8"));
function close(actual, expected, tolerance = 1e-12) {
assert.ok(
Math.abs(actual - expected) <= tolerance * Math.max(1, Math.abs(expected)),
`expected ${actual} to be within ${tolerance} of ${expected}`,
);
}
test("JavaScript matches the shared 20 C steady-state formula fixture", () => {
for (const item of fixture.cases) {
const resistancePerMetre = quantity({
id: `${item.id}.r20`,
value: item.resistance_ohm_per_m,
unit: "ohmPerMetre",
provenance: "datasheet",
});
const length = quantity({
id: `${item.id}.length`,
value: item.length_m,
unit: "m",
provenance: "geometryDerived",
});
const current = quantity({
id: `${item.id}.current`,
value: item.current_a,
unit: "A",
provenance: "datasheet",
});
const resistance = conductorResistance({
resistancePerMetre,
length,
circuitFactor: item.circuit_factor,
});
const drop = voltageDrop({ current, resistance });
const loss = resistivePowerLoss({ current, resistance });
close(resistance.value, item.expected.resistance_ohm);
close(drop.value, item.expected.voltage_drop_v);
close(loss.value, item.expected.resistive_loss_w);
}
});Kernel Test
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based that checks Kernel and Quantity. It is built from the close to helper (`closeTo`).
testsolar-electrical-topology-analysis-engine-text-based / v10-development/tests/kernel.test.mjs · lines 1–85 of 85 · Not reached from any entry point (candidate for review) · pattern closeTo (shared by 2 files)
- What it does
- It tests its inputs. Defines closeTo. Uses libraries node:assert/strict, node:test.
- 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.
- What it achieves
- Defines `closeTo`.
- Why it matters
- Guards the behaviour of Kernel and Quantity.
- Application
- solar-electrical-topology-analysis-engine-text-based · v10-development/tests · test
- Uses
- Kernel (import), Quantity (import), node:assert/strict, node:test
- Used by
- none found
- Produces
- closeTo
- Defines here
- closeTo
- 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 v10-development/tests/kernel.test.mjs:1-85 · blob 6531e51978741a57e7175867c54e51c4e6a89950 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
import assert from "node:assert/strict";
import test from "node:test";
import { runKernel } from "../src/kernel.mjs";
import { quantity, weakestProvenance } from "../src/quantity.mjs";
const closeTo = (actual, expected, tolerance = 1e-9) => {
assert.ok(Math.abs(actual - expected) <= tolerance, `${actual} not within ${tolerance} of ${expected}`);
};
test("quantity rejects unsupported units and propagates weakest provenance", () => {
assert.throws(() => quantity({ id: "x", value: 1, unit: "bananas", provenance: "measured" }));
const measured = quantity({ id: "m", value: 1, unit: "m", provenance: "measured" });
const assumed = quantity({ id: "a", value: 1, unit: "m", provenance: "assumed" });
assert.equal(weakestProvenance([measured, assumed]), "assumed");
});
test("kernel computes geometry-derived resistance, voltage drop and power loss", () => {
const output = runKernel({
documentId: "golden-sequential-4",
layout: { moduleCount: 4, pitchMetres: 2, topology: "sequential" },
electrical: {
resistanceOhmPerMetre: 0.003,
currentAmps: 10,
circuitFactor: 1,
},
});
closeTo(output.geometry.pathLengthMetres, 6);
closeTo(output.results.resistance.value, 0.018);
closeTo(output.results.voltageDrop.value, 0.18);
closeTo(output.results.resistivePowerLoss.value, 1.8);
assert.equal(output.results.resistance.provenance, "datasheet");
assert.equal(output.schemaVersion, "globalgrid2050.solar-dc-computation.v10.kernel.1");
});
test("kernel preserves uncertainty intervals through resistance and voltage drop", () => {
const output = runKernel({
layout: { moduleCount: 3, pitchMetres: 1, topology: "sequential" },
electrical: {
resistanceOhmPerMetre: 0.01,
resistanceIntervalOhmPerMetre: { lo: 0.009, hi: 0.011 },
currentAmps: 5,
currentIntervalAmps: { lo: 4.5, hi: 5.5 },
lengthUncertaintyMetres: 0.1,
},
});
const resistanceInterval = output.results.resistance.uncertainty;
closeTo(resistanceInterval.lo, 0.009 * 1.9);
closeTo(resistanceInterval.hi, 0.011 * 2.1);
const dropInterval = output.results.voltageDrop.uncertainty;
closeTo(dropInterval.lo, 4.5 * resistanceInterval.lo);
closeTo(dropInterval.hi, 5.5 * resistanceInterval.hi);
});
test("cold Voc candidate calculation is traceable and interval bounded", () => {
const output = runKernel({
layout: { moduleCount: 30, pitchMetres: 1.3, topology: "sequential" },
electrical: {
resistanceOhmPerMetre: 0.003,
currentAmps: 17,
vocStcVolts: 50,
betaVocPercentPerKelvin: -0.29,
minimumCellTemperatureKelvin: 263.15,
minimumCellTemperatureIntervalKelvin: { lo: 261.15, hi: 265.15 },
},
});
closeTo(output.results.voltageLimits.moduleVocCold.value, 55.075);
closeTo(output.results.voltageLimits.stringVocCold.value, 1652.25);
assert.equal(
output.results.voltageLimits.moduleVocCold.evidenceStatus,
"candidate-needs-standards-verification",
);
assert.equal(output.results.voltageLimits.stringVocCold.source.inputIds[0], "moduleVocCold");
});
test("kernel output is deterministic for identical JSON input", () => {
const input = {
layout: { moduleCount: 8, pitchMetres: 1.2, topology: "leapfrog" },
electrical: { resistanceOhmPerMetre: 0.0031, currentAmps: 12.5 },
};
assert.deepEqual(runKernel(input), runKernel(input));
});Studio Authority Evidence Test
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based that checks Authority Evidence. It is built from the fake document helper (`fakeDocument`).
testsolar-electrical-topology-analysis-engine-text-based / v10-development/tests/studio-authority-evidence.test.mjs · lines 1–118 of 118 · pattern fakeDocument (shared by 2 files)
- What it does
- It tests its inputs. Defines fakeDocument, testEvidenceProjection. Uses libraries node:assert/strict, node:fs, node:url, node:path. Side effects: changes the web page (DOM); 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.
- Downstream impact
- Used directly by 1 file: Run Microbuild (solar-electrical-topology-analysis-engine-text-based). Reached from 5 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); Test Microbuild Runner (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- Defines `fakeDocument` and `testEvidenceProjection`.
- Why it matters
- Run by Run Microbuild.
- Application
- solar-electrical-topology-analysis-engine-text-based · v10-development/tests · test
- Uses
- Authority Evidence (import), node:assert/strict, node:fs, node:url, node:path
- Used by
- run by Run Microbuild (script call)
- Produces
- fakeDocument, testEvidenceProjection
- Defines here
- fakeDocument, testEvidenceProjection
- 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 v10-development/tests/studio-authority-evidence.test.mjs:1-118 · blob 785f2b9cf76786ba502f3d7a8f6c38d12162d5cc · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom, filesystem · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, resolve } from 'node:path';
import {
authorityEvidence,
renderAuthorityEvidence
} from '../authority/authority-evidence.js';
const here = dirname(fileURLToPath(import.meta.url));
const shellPath = resolve(here, '../authority/index.html');
const modulePath = resolve(here, '../authority/authority-evidence.js');
const bundlePath = resolve(here, '../../authority-bundles/reference-inverter-block.json');
const html = readFileSync(shellPath, 'utf8');
const source = readFileSync(modulePath, 'utf8');
const bundle = JSON.parse(readFileSync(bundlePath, 'utf8'));
function fakeDocument() {
const ids = [
'authority-physical-input-count',
'authority-allocated-input-count',
'authority-equipment-mppt-count',
'authority-equipment-mppt-state',
'authority-internal-topology',
'authority-reverse-blocking',
'authority-pce-backfeed',
'authority-fixture-label-evidence',
'authority-input-lines',
'authority-evidence-lines'
];
const elements = new Map(ids.map((id) => [id, { id, textContent: '' }]));
return {
elements,
getElementById(id) {
return elements.get(id) ?? null;
}
};
}
function testEvidenceProjection() {
const projection = authorityEvidence(bundle);
const authority = bundle.inverter_block.input_authority;
const evidence = bundle.inverter_block.equipment_evidence;
const assignments = bundle.build025.input_allocation.assignments;
assert.equal(projection.physicalInputCount, 24);
assert.equal(projection.allocatedInputCount, 24);
assert.equal(projection.physicalInputs.length, 24);
assert.equal(projection.equipmentMpptCount, null);
assert.equal(projection.equipmentMpptState, 'unknown');
assert.equal(projection.internalDcTopology, 'unknown');
assert.equal(projection.internalDcTopologyState, 'unknown');
assert.equal(projection.reverseCurrentBlocking, 'unknown');
assert.equal(projection.reverseCurrentBlockingState, 'unknown');
assert.equal(projection.pceBackfeedCurrentA, null);
assert.equal(projection.pceBackfeedState, 'unknown');
assert.equal(projection.fixtureMpptLabelsAreEquipmentEvidence, false);
assert.equal(projection.evidenceState, 'incomplete_evidence');
assert.equal(projection.missingEvidenceCount, 47);
assert.deepEqual(projection.missingEvidence, evidence.missing_evidence);
assert.deepEqual(projection.physicalInputs[0], {
ordinal: 1,
fixtureInputId: assignments[0].input_id,
stringId: assignments[0].string_id,
equipmentMpptId: null,
equipmentMpptState: 'unknown'
});
assert.deepEqual(projection.physicalInputs[23], {
ordinal: 24,
fixtureInputId: assignments[23].input_id,
stringId: assignments[23].string_id,
equipmentMpptId: null,
equipmentMpptState: 'unknown'
});
assert.ok(projection.physicalInputs.every((item) => item.equipmentMpptId === null));
assert.ok(projection.physicalInputs.every((item) => item.equipmentMpptState === 'unknown'));
assert.equal(authority.routing_fixture_mppt_labels_are_equipment_evidence, false);
const documentRef = fakeDocument();
const rendered = renderAuthorityEvidence(documentRef, bundle);
assert.deepEqual(rendered, projection);
assert.equal(documentRef.elements.get('authority-physical-input-count').textContent, '24');
assert.equal(documentRef.elements.get('authority-allocated-input-count').textContent, '24');
assert.equal(documentRef.elements.get('authority-equipment-mppt-count').textContent, 'UNRESOLVED');
assert.equal(documentRef.elements.get('authority-equipment-mppt-state').textContent, 'unknown');
assert.equal(documentRef.elements.get('authority-internal-topology').textContent, 'unknown');
assert.equal(documentRef.elements.get('authority-reverse-blocking').textContent, 'unknown');
assert.equal(documentRef.elements.get('authority-pce-backfeed').textContent, 'UNRESOLVED');
assert.equal(documentRef.elements.get('authority-fixture-label-evidence').textContent, 'false');
const inputLines = documentRef.elements.get('authority-input-lines').textContent.split('\n');
assert.equal(inputLines.length, 24);
assert.match(inputLines[0], /^01 \| .* \| .* \| UNRESOLVED$/);
assert.match(inputLines[23], /^24 \| .* \| .* \| UNRESOLVED$/);
assert.equal(
documentRef.elements.get('authority-evidence-lines').textContent,
evidence.missing_evidence.join('\n')
);
assert.match(html, /Routing-fixture labels are not equipment evidence\./);
assert.match(html, /id="authority-input-lines"/);
assert.match(html, /id="authority-evidence-lines"/);
assert.match(html, /src="\.\/authority-evidence\.js"/);
assert.doesNotMatch(source, /assignment\.mppt_id/);
assert.doesNotMatch(source, /physicalInput\.mppt_id/);
assert.doesNotMatch(source, /equipment_profile\.mppt_ids/);
assert.doesNotMatch(source, /parallel_node_id|dc_bus_node_id/);
assert.doesNotMatch(source, /Math\.|reduce\(|resistance|voltageDrop|powerLoss/i);
assert.match(source, /assignment\.input_id/);
assert.match(source, /assignment\.string_id/);
assert.match(source, /equipmentMpptId: null/);
}
testEvidenceProjection();
console.log('studio authority evidence: PASS');Studio Authority Test
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based that checks Authority View.
testsolar-electrical-topology-analysis-engine-text-based / v10-development/tests/studio-authority.test.mjs · lines 1–215 of 215 · Entry point · pattern fakeDocument (shared by 2 files)
- What it does
- It tests its inputs. Defines 6 functions or classes, including testModeSeparation, FakeNode, fakeDocument, testBundleProjection, expectedRouteCount. Uses libraries node:assert/strict, node:fs, node:url, node:path. Side effects: changes the web page (DOM); 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 1 file: Run Microbuild (solar-electrical-topology-analysis-engine-text-based). Reached from 5 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); Test Microbuild Runner (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- It is built from the fake node class (`FakeNode`), the fake document helper (`fakeDocument`) and the expected route count helper (`expectedRouteCount`). Defines `testModeSeparation`, `FakeNode`, `fakeDocument` and 3 more. Its code works with 352 kVA.
- Why it matters
- Run by Run Microbuild.
- Application
- solar-electrical-topology-analysis-engine-text-based · v10-development/tests · test
- Uses
- Authority View (import), node:assert/strict, node:fs, node:url, node:path
- Used by
- run by Run Microbuild (script call)
- Produces
- testModeSeparation, FakeNode, fakeDocument, testBundleProjection, expectedRouteCount, testGeometryProjection
- Defines here
- testModeSeparation, FakeNode, fakeDocument, testBundleProjection, expectedRouteCount, testGeometryProjection
- 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 v10-development/tests/studio-authority.test.mjs:1-215 · blob 3464c49b013907caf0de7978f13bf42e4f5029c6 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom, filesystem · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, resolve } from 'node:path';
import {
AUTHORITY_BUNDLE_URL,
authorityGeometry,
authoritySummary,
renderAuthorityBundle,
renderAuthorityGeometry
} from '../authority/authority-view.js';
const here = dirname(fileURLToPath(import.meta.url));
const shellPath = resolve(here, '../authority/index.html');
const modulePath = resolve(here, '../authority/authority-view.js');
const bundlePath = resolve(here, '../../authority-bundles/reference-inverter-block.json');
const html = readFileSync(shellPath, 'utf8');
const projectionSource = readFileSync(modulePath, 'utf8');
const bundle = JSON.parse(readFileSync(bundlePath, 'utf8'));
const mode = process.argv[2];
function testModeSeparation() {
assert.match(html, /INDICATIVE — NON-AUTHORITATIVE/);
assert.match(html, /data-authority-state="non-authoritative"/);
assert.match(html, /src="\.\.\/topology-studio\.html"/);
assert.match(html, /data-mode="playground"/);
assert.match(html, /data-mode="authority"/);
assert.match(html, /data-authority-state="loading"/);
assert.match(html, /PYTHON AUTHORITY — LOADING VERIFIED BUNDLE/);
assert.match(html, /type="module" src="\.\/authority-view\.js"/);
const inlineScript = html.match(/<script>([\s\S]*?)<\/script>/)?.[1] ?? '';
assert.doesNotMatch(inlineScript, /Math\./);
assert.doesNotMatch(inlineScript, /resistance|voltage drop|cable length|routing hash/i);
assert.doesNotMatch(inlineScript, /response_hash|receipt_hash/);
assert.match(inlineScript, /selectMode/);
}
class FakeNode {
constructor(id = '') {
this.id = id;
this.textContent = '';
this.dataset = {};
this.attributes = new Map();
this.children = [];
}
setAttribute(name, value) {
this.attributes.set(name, String(value));
}
appendChild(child) {
this.children.push(child);
return child;
}
replaceChildren(...children) {
this.children = [...children];
}
}
function fakeDocument() {
const ids = [
'authority-view',
'authority-banner',
'authority-strategy',
'authority-module-power',
'authority-modules-per-string',
'authority-string-count',
'authority-module-count',
'authority-dc-power',
'authority-inverter-power',
'authority-dc-ac-ratio',
'authority-evidence-state',
'authority-missing-evidence',
'authority-rendered-modules',
'authority-rendered-routes',
'authority-response-hash',
'authority-block-hash',
'authority-build025-hash',
'authority-geometry',
'authority-route-layer',
'authority-module-layer'
];
const elements = new Map(ids.map((id) => [id, new FakeNode(id)]));
return {
elements,
getElementById(id) {
return elements.get(id) ?? null;
},
createElementNS(_namespace, tagName) {
const node = new FakeNode();
node.tagName = tagName;
return node;
}
};
}
function testBundleProjection() {
assert.equal(AUTHORITY_BUNDLE_URL, '../../authority-bundles/reference-inverter-block.json');
const summary = authoritySummary(bundle);
const boundary = bundle.inverter_block.product_boundary;
assert.equal(summary.modulePowerWp, boundary.module_rated_power_wp);
assert.equal(summary.modulesPerString, boundary.modules_per_string);
assert.equal(summary.stringCount, boundary.string_count);
assert.equal(summary.moduleCount, boundary.module_count);
assert.equal(summary.dcPowerKwp, boundary.dc_nameplate_power_kwp);
assert.equal(summary.inverterPowerKva, boundary.inverter_apparent_power_kva);
assert.equal(summary.dcAcRatio, boundary.dc_ac_nameplate_ratio);
assert.equal(summary.responseHash, bundle.response_hash);
assert.equal(summary.blockReceiptHash, bundle.inverter_block.receipt_hash);
assert.equal(summary.build025ReceiptHash, bundle.build025.receipt_hash);
const documentRef = fakeDocument();
const rendered = renderAuthorityBundle(documentRef, bundle);
assert.deepEqual(rendered, summary);
assert.equal(documentRef.elements.get('authority-view').dataset.authorityState, 'verified-bundle');
assert.equal(
documentRef.elements.get('authority-banner').textContent,
'PYTHON AUTHORITY — VERIFIED COMMITTED BUNDLE'
);
assert.equal(documentRef.elements.get('authority-module-power').textContent, '660 Wp');
assert.equal(documentRef.elements.get('authority-modules-per-string').textContent, '30');
assert.equal(documentRef.elements.get('authority-string-count').textContent, '24');
assert.equal(documentRef.elements.get('authority-module-count').textContent, '720');
assert.equal(documentRef.elements.get('authority-dc-power').textContent, '475.2 kWp');
assert.equal(documentRef.elements.get('authority-inverter-power').textContent, '352 kVA');
assert.equal(documentRef.elements.get('authority-dc-ac-ratio').textContent, '1.35');
assert.equal(documentRef.elements.get('authority-response-hash').textContent, bundle.response_hash);
assert.doesNotMatch(projectionSource, /Math\.|reduce\(|resistance|voltageDrop|powerLoss/i);
assert.match(projectionSource, /boundary\.module_rated_power_wp/);
assert.match(projectionSource, /response\.response_hash/);
}
function expectedRouteCount() {
let count = 0;
for (const stringRoute of bundle.build025.routing.strings) {
count += 2;
count += stringRoute.interconnect_routes.length;
}
return count;
}
function testGeometryProjection() {
const projection = authorityGeometry(bundle);
const placements = bundle.build025.geometry.placements;
const strings = bundle.build025.routing.strings;
assert.equal(projection.modules.length, placements.length);
assert.equal(projection.modules.length, 720);
assert.equal(projection.routes.length, expectedRouteCount());
assert.equal(projection.routes.length, 744);
assert.deepEqual(projection.bounds_m, bundle.build025.geometry.bounds_m);
assert.deepEqual(projection.modules[0], {
moduleId: placements[0].module_id,
x_m: placements[0].centre_m[0],
y_m: placements[0].centre_m[1]
});
assert.deepEqual(projection.routes[0].vertices, strings[0].positive_route.vertices);
assert.deepEqual(projection.routes[1].vertices, strings[0].negative_route.vertices);
assert.deepEqual(
projection.routes[2].vertices,
strings[0].interconnect_routes[0].vertices
);
const documentRef = fakeDocument();
const rendered = renderAuthorityGeometry(documentRef, bundle);
const moduleNodes = documentRef.elements.get('authority-module-layer').children;
const routeNodes = documentRef.elements.get('authority-route-layer').children;
assert.deepEqual(rendered, projection);
assert.equal(moduleNodes.length, placements.length);
assert.equal(routeNodes.length, expectedRouteCount());
assert.equal(moduleNodes[0].tagName, 'circle');
assert.equal(moduleNodes[0].attributes.get('cx'), String(placements[0].centre_m[0]));
assert.equal(moduleNodes[0].attributes.get('cy'), String(placements[0].centre_m[1]));
assert.equal(routeNodes[0].tagName, 'polyline');
assert.equal(
routeNodes[0].attributes.get('points'),
strings[0].positive_route.vertices
.map((point) => `${point.x_m},${point.y_m}`)
.join(' ')
);
assert.equal(documentRef.elements.get('authority-rendered-modules').textContent, '720');
assert.equal(documentRef.elements.get('authority-rendered-routes').textContent, '744');
assert.match(html, /id="authority-geometry"/);
assert.match(html, /id="authority-route-layer"/);
assert.match(html, /id="authority-module-layer"/);
assert.doesNotMatch(
projectionSource,
/Math\.|hypot|sqrt|geometric_length_m|route_length|cable_length|resistance|voltageDrop|powerLoss/i
);
assert.match(projectionSource, /placement\.centre_m/);
assert.match(projectionSource, /route\.vertices/);
}
switch (mode) {
case 'mode':
testModeSeparation();
break;
case 'bundle':
testBundleProjection();
break;
case 'geometry':
testGeometryProjection();
break;
default:
throw new Error(`unknown studio-authority test mode: ${mode}`);
}
console.log(`studio authority ${mode}: PASS`);Topology Test
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based that checks Topology. It is built from the close to helper (`closeTo`).
testsolar-electrical-topology-analysis-engine-text-based / v10-development/tests/topology.test.mjs · lines 1–73 of 73 · Not reached from any entry point (candidate for review) · pattern closeTo (shared by 2 files)
- What it does
- It tests its inputs. Defines closeTo. Uses libraries node:assert/strict, node:test.
- 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.
- What it achieves
- Defines `closeTo`.
- Why it matters
- Guards the behaviour of Topology.
- Application
- solar-electrical-topology-analysis-engine-text-based · v10-development/tests · test
- Uses
- Topology (import), node:assert/strict, node:test
- Used by
- none found
- Produces
- closeTo
- Defines here
- closeTo
- 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 v10-development/tests/topology.test.mjs:1-73 · blob 5b466ac8c5b77882e3672e9f666f2157fb37af23 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
import assert from "node:assert/strict";
import test from "node:test";
import {
canonicalLeapfrogOrder,
computeTopologyGeometry,
mirroredSequentialOrder,
sequentialOrder,
validateCustomOrder,
} from "../src/topology.mjs";
const closeTo = (actual, expected, tolerance = 1e-9) => {
assert.ok(
Math.abs(actual - expected) <= tolerance,
`expected ${actual} to be within ${tolerance} of ${expected}`,
);
};
test("sequential order is deterministic", () => {
assert.deepEqual(sequentialOrder(5), [1, 2, 3, 4, 5]);
});
test("mirrored sequential order is deterministic", () => {
assert.deepEqual(mirroredSequentialOrder(5), [5, 4, 3, 2, 1]);
});
test("canonical leapfrog order is a complete permutation", () => {
const order = canonicalLeapfrogOrder(30);
assert.equal(order.length, 30);
assert.equal(new Set(order).size, 30);
assert.deepEqual(order.slice(0, 5), [1, 3, 5, 7, 9]);
assert.deepEqual(order.slice(-5), [10, 8, 6, 4, 2]);
});
test("custom order rejects duplicates and omissions", () => {
assert.throws(() => validateCustomOrder([1, 2, 2], 3));
assert.throws(() => validateCustomOrder([1, 2], 3));
assert.deepEqual(validateCustomOrder([2, 3, 1], 3), [2, 3, 1]);
});
test("sequential path for 30 modules equals 29 pitches", () => {
const result = computeTopologyGeometry({
moduleCount: 30,
pitchMetres: 1.303,
topology: "sequential",
});
closeTo(result.pathLengthMetres, 29 * 1.303);
closeTo(result.terminalSeparationMetres, 29 * 1.303);
assert.equal(result.segments.length, 29);
});
test("canonical leapfrog path for 30 modules equals 57 pitches", () => {
const result = computeTopologyGeometry({
moduleCount: 30,
pitchMetres: 1.303,
topology: "leapfrog",
});
closeTo(result.pathLengthMetres, 57 * 1.303);
closeTo(result.pathLengthMetres, 74.271);
closeTo(result.terminalSeparationMetres, 1.303);
assert.equal(result.segments.length, 29);
});
test("geometry output is deterministic", () => {
const input = {
moduleCount: 8,
pitchMetres: 1.2,
topology: "leapfrog",
};
assert.deepEqual(computeTopologyGeometry(input), computeTopologyGeometry(input));
});V6 Leapfrog
A JavaScript file in Solar Electrical Topology Analysis Engine Text Based that draws module row (`drawModuleRow`) and impact (`drawImpact`), covering cables. Served with the page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/.
rendersolar-electrical-topology-analysis-engine-text-based / v6-leapfrog.js · lines 1–128 of 128 · Entry point · pattern cable (shared by 5 files)
- What it does
- It draws cables. Defines cable, drawModuleRow, drawImpact, redraw. 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
- Out: canvas drawing.
- Downstream impact
- Used directly by 1 file: Solar Electrical Topology Analysis Engine Text Based — Index Page (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/). Reached from 134 other entry points, including GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html); GlobalGrid2050 Homepage Before Four Nests (globalgrid2050, https://globalgrid2050.com/homepage-before-four-nests-20260925.html); Homepage V002 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v002.html). It is itself an entry point, published at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/.
- What it achieves
- It draws module row (`drawModuleRow`) and draws impact (`drawImpact`). Defines `cable`, `drawModuleRow`, `drawImpact` and 1 more. It responds to input and resize events.
- Why it matters
- Loaded by the Solar Electrical Topology Analysis Engine Text Based page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/.
- Application
- solar-electrical-topology-analysis-engine-text-based · / · script
- Uses
- none found
- Used by
- loaded by Solar Electrical Topology Analysis Engine Text Based — Index Page (script src)
- Produces
- cable, drawModuleRow, drawImpact, redraw
- Defines here
- cable, drawModuleRow, drawImpact, redraw
- 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 v6-leapfrog.js:1-128 · blob 8b7cbeafab0f86acbc269182e2e3e89a49edc68e · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
"use strict";
(()=>{
const baseInput=input;
const baseExternalLengths=externalLengths;
const baseStudy=study;
const basePaths=paths;
input=function(){
const m=baseInput();
const modeEl=$("wiringMode");
const spacingEl=$("leapfrogSpacing");
m.wiringMode=modeEl?modeEl.value:"sequential";
m.leapfrogSpacing=Math.max(0.1,spacingEl?Number(spacingEl.value):40);
return m;
};
externalLengths=function(s){
const ext=baseExternalLengths(s);
const mode=$("wiringMode")?.value||"sequential";
if(mode==="leapfrog"){
return{positive:ext.near,negative:ext.near,near:ext.near,far:ext.far};
}
return ext;
};
study=function(s,m){
const st=baseStudy(s,m);
st.wiringMode=m.wiringMode;
st.rowSpan=Math.abs(s.x1-s.x0);
st.externalCableAvoided=m.wiringMode==="leapfrog"?Math.max(0,st.ext.far-st.ext.near):0;
if(m.wiringMode==="leapfrog"){
const dExt=P.conductorDiameterFromArea(m.csa);
const dLead=P.conductorDiameterFromArea(m.leadCsa);
const twExt=safeTwoWire(m.externalSpacing,dExt,m.epsilonR);
const twModule=safeTwoWire(m.leapfrogSpacing,dLead,m.epsilonR);
st.L=twExt.inductancePerM*st.externalTotal+twModule.inductancePerM*st.moduleLeadTotal;
st.Cdiff=twExt.capacitancePerM*st.externalTotal+twModule.capacitancePerM*st.moduleLeadTotal;
st.area=st.ext.near*(m.externalSpacing/1000)+st.rowSpan*(m.leapfrogSpacing/1000);
st.delay=Math.max(st.ext.positive,st.ext.negative)/twExt.velocity+st.moduleLeadTotal/(2*twModule.velocity);
st.criterion=2*st.delay;
const rise=m.riseUs*1e-6;
st.distributed=rise<st.criterion;
st.margin=rise/st.criterion;
}
return st;
};
paths=function(st,m){
if(m.wiringMode!=="leapfrog")return basePaths(st,m);
const s=st.s;
const displayOff=Math.max(.045,Math.min(.12,m.moduleLength*.025));
const plusY=s.y-displayOff,minusY=s.y+displayOff,nearX=s.x0,farX=s.x1;
return{
plus:[[state.inverter.x,plusY],[nearX,plusY]],
module:[[nearX,s.y],[farX,s.y]],
minus:[[nearX,minusY],[state.inverter.x,minusY]],
polygon:[[state.inverter.x,plusY],[nearX,plusY],[farX,s.y-displayOff*.3],[farX,s.y+displayOff*.3],[nearX,minusY],[state.inverter.x,minusY]]
};
};
function cable(ctx,points,width=4){
ctx.save();
ctx.lineJoin="round";ctx.lineCap="round";
ctx.strokeStyle="rgba(232,244,252,.72)";ctx.lineWidth=width+2;
ctx.beginPath();points.forEach((p,i)=>i?ctx.lineTo(p[0],p[1]):ctx.moveTo(p[0],p[1]));ctx.stroke();
ctx.strokeStyle="#000";ctx.lineWidth=width;
ctx.beginPath();points.forEach((p,i)=>i?ctx.lineTo(p[0],p[1]):ctx.moveTo(p[0],p[1]));ctx.stroke();
ctx.restore();
}
function drawModuleRow(ctx,y,title,leap,m){
const c=$("wiringComparison"),W=c.width;
const invX=62,rowX=170,rowRight=W-48,count=Math.max(2,m.modulesPerString);
const pitch=(rowRight-rowX)/count,moduleW=Math.max(5,pitch-2),moduleH=54;
ctx.fillStyle="#d9f4ff";ctx.font="800 20px ui-monospace,monospace";ctx.fillText(title,20,y+34);
ctx.fillStyle="#ffb347";ctx.fillRect(invX,y+4,36,112);
ctx.fillStyle="#ffd79b";ctx.font="700 12px ui-monospace,monospace";ctx.fillText("INV",invX+5,y-5);
for(let i=0;i<count;i++){
const x=rowX+i*pitch;
ctx.fillStyle=i%2?"#18394b":"#154a61";ctx.fillRect(x,y,moduleW,moduleH);
ctx.strokeStyle="#66dcff";ctx.lineWidth=1;ctx.strokeRect(x,y,moduleW,moduleH);
ctx.fillStyle="#000";ctx.fillRect(x+moduleW/2-2.5,y+11,5,4);
}
ctx.font="800 15px ui-monospace,monospace";
if(!leap){
cable(ctx,[[invX+36,y+20],[rowX,y+20]],4);
cable(ctx,[[rowRight-pitch/2,y+42],[rowRight-pitch/2,y+92],[invX+36,y+92]],4);
ctx.fillStyle="#fff";ctx.fillText("+",invX+46,y+17);ctx.fillText("−",rowRight-pitch/2+8,y+45);
ctx.fillStyle="#ff6d79";ctx.fillText("one far-end return ≈ one complete row span",rowX,y+116);
}else{
cable(ctx,[[invX+36,y+19],[rowX,y+19]],4);
cable(ctx,[[invX+36,y+43],[rowX+pitch,y+43]],4);
ctx.fillStyle="#fff";ctx.fillText("+",invX+46,y+16);ctx.fillText("−",invX+46,y+48);
for(let i=0;i<count-2;i+=2){
const a=rowX+i*pitch+moduleW/2,b=rowX+(i+2)*pitch+moduleW/2;
cable(ctx,[[a,y+14],[b,y+14]],2);
}
for(let i=1;i<count-2;i+=2){
const a=rowX+i*pitch+moduleW/2,b=rowX+(i+2)*pitch+moduleW/2;
cable(ctx,[[a,y+48],[b,y+48]],2);
}
const a=rowX+(count-2)*pitch+moduleW/2,b=rowX+(count-1)*pitch+moduleW/2;
cable(ctx,[[a,y+14],[b,y+48]],2);
ctx.fillStyle="#53e28b";ctx.fillText("both free terminals emerge at inverter end",rowX,y+88);
}
}
function drawImpact(){
const c=$("wiringComparison"),summary=$("wiringImpactSummary");
if(!c||!summary)return;
const m=input(),g=geometry(m),ctx=c.getContext("2d");
ctx.clearRect(0,0,c.width,c.height);ctx.fillStyle="#03070b";ctx.fillRect(0,0,c.width,c.height);
drawModuleRow(ctx,62,"Sequential",false,m);
drawModuleRow(ctx,254,"Leapfrog",true,m);
const savingPerString=g.rowLength;
const savingPerInverter=savingPerString*g.strings.length;
summary.innerHTML=`<strong>${m.wiringMode==="leapfrog"?"LEAPFROG ACTIVE":"SEQUENTIAL ACTIVE"}</strong><br>`+
`Distance to nearest terminals: ${fmt(m.nearAllowance,2)} m.<br>`+
`Derived row span: ${fmt(g.rowLength,2)} m.<br>`+
`Leapfrog removes approximately ${fmt(savingPerString,2)} m of external 6 mm² cable per string, or ${fmt(savingPerInverter/1000,3)} km across this ${g.strings.length}-string inverter archetype.`;
}
const redraw=()=>{render();drawImpact();};
["wiringMode","leapfrogSpacing"].forEach(id=>$(id)?.addEventListener("input",redraw));
ids.forEach(id=>$(id)?.addEventListener("input",drawImpact));
window.addEventListener("resize",drawImpact);
redraw();
})();