GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Solar and storage design / solar-electrical-topology-analysis-engine-text-based / v8-leapfrog

Authority Reconciliation and 1 more file

A JavaScript module in Solar Electrical Topology Analysis Engine Text Based that runs golden, renders browser and applies scope boundary, covering cables. Served with the page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v8-leapfrog/.

409 lines of JavaScript from solar-electrical-topology-analysis-engine-text-based, in 2 files. Topic: Solar and storage design. Section 250 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. Solar Electrical Topology Analysis Engine Text Based — V8 Leapfrog electrical · solar-electrical-topology-analysis-engine-text-based / v8-leapfrog/app.js lines 1146–1260
  2. Authority Reconciliation interaction · solar-electrical-topology-analysis-engine-text-based / v8-leapfrog/authority-reconciliation.js lines 1–294

Solar Electrical Topology Analysis Engine Text Based — V8 Leapfrog

A JavaScript file that reads inputs (`readInputs`), sets input (`setInputValues`) and groups bands (`groupBands`) (units: Ω, kW), covering leapfrog cable comparison and cables. Served with the page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v8-leapfrog/.

electricalsolar-electrical-topology-analysis-engine-text-based / v8-leapfrog/app.js · lines 1146–1260 of 1260 (continued from section 248) · Entry point · pattern clearError (shared by 2 files)

What it does
It draws leapfrog cable comparison and cables. Defines 40 functions or classes, including $, fmt, available, setText, readInputs. 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: JSON file v8-leapfrog-cable-comparison.json; downloaded file v8-leapfrog-cable-comparison.json.
Downstream impact
Used directly by 2 files: Solar Electrical Topology Analysis Engine Text Based — V8 Leapfrog Page (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v8-leapfrog/); V8 Tests Workflow (solar-electrical-topology-analysis-engine-text-based). Reached from 127 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/v8-leapfrog/.
What it achieves
It sets text (`setText`), reads inputs (`readInputs`) and sets input (`setInputValues`). Defines `fmt`, `available`, `setText` and 36 more. It responds to click, input and change events.
Why it matters
Loaded by the page of the same name at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v8-leapfrog/. Checked by V8 Tests Workflow.
Application
solar-electrical-topology-analysis-engine-text-based · v8-leapfrog · script
Uses
none found
Used by
loaded by Solar Electrical Topology Analysis Engine Text Based — V8 Leapfrog Page (script src), run by V8 Tests Workflow (workflow run)
Produces
$, fmt, available, setText, readInputs, setInputValues, groupBands, renderFeasibilityBanner, renderMetrics, renderLeadScreen, renderBandSchedule, renderStringSchedule
Defines here
exportJson, copySummary, initialiseTabs, initialise
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 v8-leapfrog/app.js:1146-1260 · blob 7c796bc6748cf14500cc7786248eabdb53db4f0f · 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
      const study = Model.calculate(raw);

      renderFeasibilityBanner(study);
      renderMetrics(study);
      renderLeadScreen(study);
      renderBandSchedule(study);
      renderStringSchedule(study);
      renderScenarios(raw);
      renderDiagram(study);
      renderTrace(study);
      renderSummary(study);
      renderComparison();
      renderSelfTests();

      window.__V8_LAST_STUDY__ = study;
    } catch (error) {
      console.error(error);
      showError(error);
    }
  }

  function exportJson() {
    const raw = readInputs();
    const study = Model.calculate(raw);
    const payload = {
      schema: 'globalgrid2050-v8-leapfrog-cable-comparison',
      schemaVersion: '2.1.0',
      generatedAt: new Date().toISOString(),
      reliance:
        'Indicative engineering screening only. Not an as-built ' +
        'quantity, procurement instruction, design approval or ' +
        'compliance certificate.',
      geometry: window.__V8_GEOMETRY__,
      study,
      scenarios: Model.scenarioStudies(raw),
      tests: renderSelfTests()
    };
    const url = URL.createObjectURL(
      new Blob(
        [JSON.stringify(payload, null, 2)],
        { type: 'application/json' }
      )
    );
    const link = document.createElement('a');

    link.href = url;
    link.download = 'v8-leapfrog-cable-comparison.json';
    link.click();

    setTimeout(() => URL.revokeObjectURL(url), 1000);
  }

  async function copySummary() {
    const text = renderSummary(Model.calculate(readInputs()));

    try {
      await navigator.clipboard.writeText(text);
    } catch (error) {
      const textarea = $('plainSummary');

      if (textarea) {
        textarea.select();
        document.execCommand('copy');
      }
    }

    setText('copyStatus', 'Copied');
    setTimeout(() => setText('copyStatus', 'Copy summary'), 1400);
  }

  function initialiseTabs() {
    document.querySelectorAll('.tab').forEach((button) => {
      button.addEventListener('click', () => {
        document.querySelectorAll('.tab').forEach((candidate) => {
          candidate.classList.remove('active');
        });
        document.querySelectorAll('.tabpane').forEach((pane) => {
          pane.classList.remove('active');
        });

        button.classList.add('active');
        $(button.dataset.tab)?.classList.add('active');

        if (button.dataset.tab === 'diagramTab') {
          renderDiagram(Model.calculate(readInputs()));
        }
      });
    });
  }

  function initialise() {
    setInputValues(Model.DEFAULTS);

    Object.values(valueMap).forEach((id) => {
      $(id)?.addEventListener('input', render);
      $(id)?.addEventListener('change', render);
    });

    $('resetBtn')?.addEventListener('click', () => {
      setInputValues(Model.DEFAULTS);
      render();
    });
    $('exportBtn')?.addEventListener('click', exportJson);
    $('copyBtn')?.addEventListener('click', copySummary);

    initialiseTabs();
    render();
  }

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', initialise, { once: true });
  } else {
    initialise();
  }
})();

Authority Reconciliation

A JavaScript module in Solar Electrical Topology Analysis Engine Text Based that runs golden, renders browser and applies scope boundary, covering cables. Served with the page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v8-leapfrog/.

interactionsolar-electrical-topology-analysis-engine-text-based / v8-leapfrog/authority-reconciliation.js · lines 1–294 of 294 · Entry point · pattern runGoldenTests (shared by 2 files)

What it does
It draws cables. Defines 10 functions or classes, including buildAuthorityReconciliation, calculate, nearlyEqual, runGoldenTests, format. 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.
Downstream impact
Used directly by 2 files: V8 Model Test (solar-electrical-topology-analysis-engine-text-based); Solar Electrical Topology Analysis Engine Text Based — V8 Leapfrog Page (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v8-leapfrog/). Reached from 137 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/v8-leapfrog/.
What it achieves
It runs golden tests (`runGoldenTests`), renders browser (`renderBrowser`) and sets text (`setText`). Defines `buildAuthorityReconciliation`, `calculate`, `nearlyEqual` and 7 more. It responds to input, change and DOMContentLoaded events.
Why it matters
Loaded by the V8 Leapfrog page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v8-leapfrog/. Checked by V8 Model Test.
Application
solar-electrical-topology-analysis-engine-text-based · v8-leapfrog · JavaScript module
Uses
none found
Used by
required by V8 Model Test (require), loaded by Solar Electrical Topology Analysis Engine Text Based — V8 Leapfrog Page (script src), mentioned in Standalone (comment link)
Produces
buildAuthorityReconciliation, calculate, nearlyEqual, runGoldenTests, format, renderBrowser, setText, applyScopeBoundary, applySummary, applyAll
Defines here
buildAuthorityReconciliation, calculate, nearlyEqual, runGoldenTests, format, renderBrowser, setText, applyScopeBoundary, applySummary, applyAll
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 v8-leapfrog/authority-reconciliation.js:1-294 · blob f431906a9b2b9bd7623d502ff969f053a225f1b3 · 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
(function attachAuthorityReconciliation(root, factory) {
  'use strict';

  const api = factory();

  if (typeof module === 'object' && module.exports) {
    module.exports = api;
  }

  if (root) {
    root.V8AuthorityReconciliation = api;
  }
})(
  typeof window !== 'undefined' ? window : globalThis,
  function buildAuthorityReconciliation() {
    'use strict';

    const VERSION = '1.0.1';

    const BUILD_025_REFERENCE = Object.freeze({
      fixtureId: 'build-025-reference-24-by-30',
      fixtureDescription:
        '24 strings × 30 modules, Build 025 plan-coordinate reference fixture',
      authorityStatus: 'V10_CANONICAL_CANDIDATE_REFERENCE',
      sourceMethod: 'globalgrid2050.solar-dc.strategy-comparison.v1',
      sourceReference:
        'Build 025 compare_reference_24_by_30 deterministic receipt',
      geometryDimensionality: 'plan_2d',
      terminalGeometryEvidence: 'generic_unresolved',
      terminalGeometrySource:
        'build_025_junction_box_centre_reference',
      sequential: Object.freeze({
        fieldInstalledConductorM: 1710.144,
        factoryFittedConductorM: 803.184,
        totalCircuitConductorM: 2513.328,
        signedLoopAreaM2: 420.4362,
        absoluteWindingAreaM2: 420.4362
      }),
      leapfrog: Object.freeze({
        fieldInstalledConductorM: 911.856,
        factoryFittedConductorM: 1648.272,
        totalCircuitConductorM: 2560.128,
        signedLoopAreaM2: 71.5608,
        absoluteWindingAreaM2: 84.9216
      })
    });

    function calculate(reference = BUILD_025_REFERENCE) {
      const fieldInstalledReductionM =
        reference.sequential.fieldInstalledConductorM -
        reference.leapfrog.fieldInstalledConductorM;
      const factoryFittedIncreaseM =
        reference.leapfrog.factoryFittedConductorM -
        reference.sequential.factoryFittedConductorM;
      const totalCircuitChangeM =
        reference.leapfrog.totalCircuitConductorM -
        reference.sequential.totalCircuitConductorM;
      const absoluteWindingAreaReductionM2 =
        reference.sequential.absoluteWindingAreaM2 -
        reference.leapfrog.absoluteWindingAreaM2;
      const absoluteWindingAreaReductionPercent =
        100 * absoluteWindingAreaReductionM2 /
        reference.sequential.absoluteWindingAreaM2;

      return Object.freeze({
        version: VERSION,
        fixtureId: reference.fixtureId,
        fieldInstalledReductionM,
        factoryFittedIncreaseM,
        totalCircuitChangeM,
        absoluteWindingAreaReductionM2,
        absoluteWindingAreaReductionPercent,
        warning:
          'V8 calculates field-installed external-cable reduction only. ' +
          'Build 025 additionally includes factory-fitted interconnect conductor. ' +
          'The Build 025 loop-area result is fixture-specific because terminal ' +
          'geometry is unresolved and geometry is plan_2d.'
      });
    }

    function nearlyEqual(actual, expected, tolerance = 1e-9) {
      return Math.abs(actual - expected) <= tolerance;
    }

    function runGoldenTests() {
      const result = calculate();
      const tests = [
        {
          name: 'Build 025 field-installed reduction is 798.288 m',
          pass: nearlyEqual(result.fieldInstalledReductionM, 798.288),
          actual: result.fieldInstalledReductionM,
          expected: 798.288
        },
        {
          name: 'Build 025 factory-fitted increase is 845.088 m',
          pass: nearlyEqual(result.factoryFittedIncreaseM, 845.088),
          actual: result.factoryFittedIncreaseM,
          expected: 845.088
        },
        {
          name: 'Build 025 total circuit conductor increases by 46.800 m',
          pass: nearlyEqual(result.totalCircuitChangeM, 46.8),
          actual: result.totalCircuitChangeM,
          expected: 46.8
        },
        {
          name: 'Build 025 absolute winding area falls by about 79.8 percent',
          pass: nearlyEqual(
            result.absoluteWindingAreaReductionPercent,
            79.801548963,
            1e-9
          ),
          actual: result.absoluteWindingAreaReductionPercent,
          expected: 79.801548963
        },
        {
          name: 'Reference declares unresolved terminal geometry',
          pass:
            BUILD_025_REFERENCE.terminalGeometryEvidence ===
            'generic_unresolved',
          actual: BUILD_025_REFERENCE.terminalGeometryEvidence,
          expected: 'generic_unresolved'
        },
        {
          name: 'Reference declares plan-coordinate geometry',
          pass:
            BUILD_025_REFERENCE.geometryDimensionality === 'plan_2d',
          actual: BUILD_025_REFERENCE.geometryDimensionality,
          expected: 'plan_2d'
        }
      ];

      return Object.freeze({
        version: VERSION,
        passed: tests.filter((test) => test.pass).length,
        total: tests.length,
        allPassed: tests.every((test) => test.pass),
        tests
      });
    }

    function format(value, decimals) {
      return Number(value).toLocaleString('en-GB', {
        minimumFractionDigits: decimals,
        maximumFractionDigits: decimals
      });
    }

    function renderBrowser() {
      if (typeof document === 'undefined') {
        return;
      }

      const result = calculate();
      const host = typeof globalThis !== 'undefined'
        ? globalThis
        : null;
      const setText = (id, text) => {
        const element = document.getElementById(id);
        if (element) {
          element.textContent = text;
        }
      };

      setText(
        'authorityFieldInstalledReduction',
        `${format(result.fieldInstalledReductionM, 3)} m reduction`
      );
      setText(
        'authorityFactoryFittedIncrease',
        `${format(result.factoryFittedIncreaseM, 3)} m increase`
      );
      setText(
        'authorityTotalCircuitChange',
        `${format(result.totalCircuitChangeM, 3)} m increase`
      );
      setText(
        'authorityLoopAreaReduction',
        `${format(result.absoluteWindingAreaReductionPercent, 1)}% reduction`
      );
      setText(
        'authorityGeometryBasis',
        `${BUILD_025_REFERENCE.geometryDimensionality} · ` +
          `${BUILD_025_REFERENCE.terminalGeometryEvidence}`
      );

      const applyScopeBoundary = () => {
        const banner = document.getElementById('feasibilityBanner');
        if (banner) {
          banner.innerHTML = banner.innerHTML
            .replace(
              'LEAPFROG SAVING NOT AVAILABLE',
              'LEAPFROG EXTERNAL-CABLE REDUCTION NOT AVAILABLE'
            )
            .replace(
              'LEAPFROG LENGTH SCREEN PASSED',
              'LEAPFROG EXTERNAL-CABLE LENGTH SCREEN PASSED'
            );
        }

        const trace = document.getElementById('calculationTrace');
        if (trace) {
          trace.textContent = trace.textContent
            .replace(
              'THEORETICAL DIFFERENCE PER STRING',
              'THEORETICAL EXTERNAL-CABLE REDUCTION PER STRING'
            )
            .replace(
              'THEORETICAL SITE DIFFERENCE',
              'THEORETICAL SITE EXTERNAL-CABLE REDUCTION'
            )
            .replace(
              'AVAILABLE SITE DIFFERENCE',
              'AVAILABLE SITE EXTERNAL-CABLE REDUCTION'
            );
        }

        setText(
          'v8Comparison',
          'V8 is a historical/reference field-installed external-cable ' +
            'comparison with a lead-feasibility gate. Build 025/V10 is the ' +
            'canonical candidate for complete routed conductor, loop geometry ' +
            'and deterministic receipts.'
        );
      };

      const applySummary = () => {
        const summary = document.getElementById('plainSummary');
        if (!summary) {
          return;
        }
        const marker = 'BUILD 025 AUTHORITY RECONCILIATION';
        const base = summary.value
          .split(`\n\n${marker}`)[0]
          .replace(
            'V8.2 sequential versus leapfrog cable comparison',
            'V8.2 sequential versus leapfrog field-installed external-cable comparison'
          )
          .replace(
            'Available site saving:',
            'Available site external-cable reduction:'
          );
        summary.value = [
          base,
          '',
          marker,
          `Field-installed conductor reduction: ${format(result.fieldInstalledReductionM, 3)} m`,
          `Factory-fitted conductor increase: ${format(result.factoryFittedIncreaseM, 3)} m`,
          `Total circuit conductor change: +${format(result.totalCircuitChangeM, 3)} m`,
          `Absolute winding-area reduction: ${format(result.absoluteWindingAreaReductionPercent, 1)}%`,
          `Geometry basis: ${BUILD_025_REFERENCE.geometryDimensionality}; terminals ${BUILD_025_REFERENCE.terminalGeometryEvidence}.`,
          'V8 resistance, voltage-drop and loss differences apply only to the represented external 6 mm² field-installed portion.'
        ].join('\n');
      };

      const applyAll = () => {
        applyScopeBoundary();
        applySummary();
      };

      applyAll();
      document.querySelectorAll('input,select').forEach((element) => {
        element.addEventListener('input', () => setTimeout(applyAll, 0));
        element.addEventListener('change', () => setTimeout(applyAll, 0));
      });

      if (host) {
        host.__V8_AUTHORITY_RECONCILIATION__ = Object.freeze({
          reference: BUILD_025_REFERENCE,
          result,
          tests: runGoldenTests()
        });
      }
    }

    if (typeof document !== 'undefined') {
      if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', renderBrowser, {
          once: true
        });
      } else {
        renderBrowser();
      }
    }

    return Object.freeze({
      VERSION,
      BUILD_025_REFERENCE,
      calculate,
      runGoldenTests,
      renderBrowser
    });
  }
);