GLOBALGRID2050 / EXPLORE CODE

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

Authority View and 4 more files

A JavaScript module that renders authority geometry and authority bundle and loads authority bundle, covering reference inverter block. Served with the page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/authority/.

659 lines of JavaScript and Python from solar-electrical-topology-analysis-engine-text-based, in 5 files. Topic: Solar and storage design. Section 245 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. Test V10 Public API test · solar-electrical-topology-analysis-engine-text-based / tests/test_v10_public_api.py lines 1–26
  2. Test Zzz B026 Gitignore test · solar-electrical-topology-analysis-engine-text-based / tests/test_zzz_b026_gitignore.py lines 1–62
  3. V8 Model Test test · solar-electrical-topology-analysis-engine-text-based / tests/v8-model.test.js lines 1–187
  4. Authority Evidence render · solar-electrical-topology-analysis-engine-text-based / v10-development/authority/authority-evidence.js lines 1–165
  5. Authority View render · solar-electrical-topology-analysis-engine-text-based / v10-development/authority/authority-view.js lines 1–219

Test V10 Public API

A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based.

testsolar-electrical-topology-analysis-engine-text-based / tests/test_v10_public_api.py · lines 1–26 of 26 · Entry point

What it does
It tests its inputs. Defines test_v10_evidence_and_calculation_public_api_is_exported. Uses libraries solar_topology.
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.
Downstream impact
Used directly by 1 file: Build 025 Small Gates Workflow (solar-electrical-topology-analysis-engine-text-based).
What it achieves
Defines `test_v10_evidence_and_calculation_public_api_is_exported`.
Why it matters
Run by Build 025 Small Gates Workflow.
Application
solar-electrical-topology-analysis-engine-text-based · tests · test
Uses
solar_topology
Used by
run by Build 025 Small Gates Workflow (workflow run)
Produces
test_v10_evidence_and_calculation_public_api_is_exported
Defines here
test_v10_evidence_and_calculation_public_api_is_exported
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 tests/test_v10_public_api.py:1-26 · blob 07858e867fecbf164fdd2673b2d631bb9663ac1d · 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: production_core
import solar_topology as engine


def test_v10_evidence_and_calculation_public_api_is_exported():
    required = (
        "EVIDENCE_SCHEMA_VERSION",
        "EvidenceDescriptor",
        "VerificationState",
        "canonical_evidence_descriptor",
        "javascript_provenance_descriptor",
        "segment_provenance_descriptor",
        "weakest_evidence_class",
        "CALCULATION_RECEIPT_SCHEMA_VERSION",
        "COMPLETE_CIRCUIT_METHOD_VERSION",
        "OrderedCircuitCalculationReceipt",
        "SegmentCalculationResult",
        "calculation_receipt_hash",
        "calculation_receipt_json",
        "calculation_receipt_payload",
        "ALPHA_CU_20_PER_C",
        "calculate_complete_circuit",
    )

    missing = [name for name in required if not hasattr(engine, name)]
    assert missing == []
    assert all(name in engine.__all__ for name in required)

Test Zzz B026 Gitignore

A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based.

testsolar-electrical-topology-analysis-engine-text-based / tests/test_zzz_b026_gitignore.py · lines 1–62 of 62 · Entry point · pattern run_git (shared by 4 files)

What it does
It tests its inputs. Defines run_git, test_declared_generated_candidates_are_ignored, test_no_tracked_engineering_file_becomes_ignored, test_repository_tree_is_clean_after_python_suite_setup. Uses libraries __future__, pathlib, subprocess, pytest. Side effects: reads or writes files; starts processes.
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 cache.json; JSON file reference-inverter-block.json.
Downstream impact
Used directly by 1 file: Build 025 Small Gates Workflow (solar-electrical-topology-analysis-engine-text-based).
What it achieves
Defines `run_git`, `test_declared_generated_candidates_are_ignored`, `test_no_tracked_engineering_file_becomes_ignored` and 1 more.
Why it matters
Run by Build 025 Small Gates Workflow.
Application
solar-electrical-topology-analysis-engine-text-based · tests · test
Uses
__future__, pathlib, subprocess, pytest
Used by
run by Build 025 Small Gates Workflow (workflow run)
Produces
run_git, test_declared_generated_candidates_are_ignored, test_no_tracked_engineering_file_becomes_ignored, test_repository_tree_is_clean_after_python_suite_setup
Defines here
run_git, test_declared_generated_candidates_are_ignored, test_no_tracked_engineering_file_becomes_ignored, test_repository_tree_is_clean_after_python_suite_setup
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 tests/test_zzz_b026_gitignore.py:1-62 · blob b19a15ea4aaf5f2f84bd395688c6257057d31c6a · GitHub at these lines
State
achieves: name · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
from __future__ import annotations

from pathlib import Path
import subprocess

import pytest


ROOT = Path(__file__).resolve().parents[1]


def run_git(*args: str) -> subprocess.CompletedProcess[str]:
    return subprocess.run(
        ["git", *args],
        cwd=ROOT,
        check=False,
        capture_output=True,
        text=True,
        timeout=10,
    )


@pytest.mark.parametrize(
    "candidate",
    (
        "__pycache__/module.cpython-311.pyc",
        ".venv/bin/python",
        "build/lib/package.py",
        "dist/package.whl",
        "src/package.egg-info/PKG-INFO",
        ".pytest_cache/v/cache/nodeids",
        ".ruff_cache/content",
        ".mypy_cache/3.11/cache.json",
        "node_modules/package/index.js",
        ".microbuild/candidates/reference-inverter-block.json",
        ".DS_Store",
    ),
)
def test_declared_generated_candidates_are_ignored(candidate: str) -> None:
    completed = run_git("check-ignore", "--no-index", "--quiet", candidate)
    assert completed.returncode == 0, (
        f"expected generated candidate to be ignored: {candidate}\n"
        f"stdout={completed.stdout!r}\nstderr={completed.stderr!r}"
    )


def test_no_tracked_engineering_file_becomes_ignored() -> None:
    completed = run_git("ls-files", "-ci", "--exclude-standard")
    assert completed.returncode == 0, completed.stderr
    assert completed.stdout == "", (
        "tracked files must never be hidden by the root .gitignore:\n"
        + completed.stdout
    )


def test_repository_tree_is_clean_after_python_suite_setup() -> None:
    completed = run_git("status", "--porcelain=v1", "--untracked-files=all")
    assert completed.returncode == 0, completed.stderr
    assert completed.stdout == "", (
        "the Python validation setup left repository state behind:\n"
        + completed.stdout
    )

V8 Model Test

A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based that checks Model and Authority Reconciliation.

testsolar-electrical-topology-analysis-engine-text-based / tests/v8-model.test.js · lines 1–187 of 187 · Entry point

What it does
It tests its inputs. Defines close. Uses libraries node:assert/strict.
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.
Downstream impact
Used directly by 2 files: Run V10 Validation (solar-electrical-topology-analysis-engine-text-based); V8 Tests Workflow (solar-electrical-topology-analysis-engine-text-based). Reached from 8 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); V10 Validation Workflow (solar-electrical-topology-analysis-engine-text-based).
What it achieves
Defines `close`.
Why it matters
Run by Run V10 Validation. Checked by V8 Tests Workflow.
Application
solar-electrical-topology-analysis-engine-text-based · tests · test
Uses
Model (require), Authority Reconciliation (require), node:assert/strict
Used by
run by Run V10 Validation (script call), run by V8 Tests Workflow (workflow run), mentioned in Standalone (comment link)
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 tests/v8-model.test.js:1-187 · blob 20c34869d56b2356a80ac42c0b06a1df554e6ea9 · 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: production_core
'use strict';

const assert = require('node:assert/strict');
const model = require('../v8-leapfrog/model.js');
const authority = require('../v8-leapfrog/authority-reconciliation.js');

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

const golden = model.runGoldenTests();

assert.equal(
  golden.allPassed,
  true,
  JSON.stringify(golden.tests, null, 2)
);

const defaultStudy = model.calculate(model.DEFAULTS);

assert.equal(
  defaultStudy.totals.stringsPerArchetypeInverter,
  24
);
assert.equal(
  defaultStudy.totals.totalSiteStringCount,
  18_918
);
assert.ok(
  close(defaultStudy.geometry.modulePitchM, 1.323)
);
assert.ok(
  close(defaultStudy.geometry.rowSpanM, 39.67)
);
assert.ok(
  close(
    defaultStudy.geometry.requiredLeapfrogReachM,
    2.646
  )
);
assert.equal(
  defaultStudy.feasibility.feasible,
  false
);
assert.equal(
  defaultStudy.totals.availableSiteSavingKm,
  null
);
assert.ok(
  close(
    defaultStudy.totals
      .sequentialExternalMPerArchetypeInverter,
    2_878.20
  )
);
assert.ok(
  close(
    defaultStudy.totals
      .leapfrogExternalMPerArchetypeInverter,
    1_926.12
  )
);
assert.ok(
  close(
    defaultStudy.totals
      .theoreticalSavingMPerArchetypeInverter,
    952.08
  )
);
assert.ok(
  close(
    defaultStudy.totals.theoreticalSiteSavingKm,
    750.47706
  )
);

const feasibleStudy = model.calculate({
  ...model.DEFAULTS,
  positiveFactoryLeadM: 1.4,
  negativeFactoryLeadM: 1.4,
  leadEvidence: 'MANUFACTURER_CUSTOM_DECLARED'
});

assert.equal(
  feasibleStudy.feasibility.feasible,
  true
);
assert.ok(
  close(
    feasibleStudy.totals.availableSiteSavingKm,
    750.47706
  )
);

const shortLeadStudy = model.calculate({
  ...model.DEFAULTS,
  positiveFactoryLeadM: 1.2,
  negativeFactoryLeadM: 1.2
});

assert.equal(
  shortLeadStudy.feasibility.feasible,
  false
);
assert.ok(
  close(shortLeadStudy.feasibility.marginM, -0.246)
);
assert.ok(
  close(
    shortLeadStudy.feasibility.extensionRequiredM,
    0.246
  )
);

const distance30Study = model.calculate({
  ...model.DEFAULTS,
  inverterDistanceM: 30
});

assert.ok(
  close(
    distance30Study.totals
      .theoreticalSavingMPerArchetypeInverter,
    defaultStudy.totals
      .theoreticalSavingMPerArchetypeInverter
  )
);
assert.ok(
  distance30Study.totals
    .leapfrogExternalMPerArchetypeInverter >
  defaultStudy.totals
    .leapfrogExternalMPerArchetypeInverter
);

const west = defaultStudy.strings.find(
  (item) => item.face === 'W'
);

assert.ok(west);
assert.equal(
  west.sequential.positiveM,
  west.farRouteM
);
assert.equal(
  west.sequential.negativeM,
  west.nearRouteM
);
assert.equal(
  west.leapfrog.positiveM,
  west.nearRouteM
);
assert.equal(
  west.leapfrog.negativeM,
  west.nearRouteM
);

const authorityGolden = authority.runGoldenTests();
assert.equal(
  authorityGolden.allPassed,
  true,
  JSON.stringify(authorityGolden.tests, null, 2)
);

const reconciliation = authority.calculate();
assert.ok(close(reconciliation.fieldInstalledReductionM, 798.288));
assert.ok(close(reconciliation.factoryFittedIncreaseM, 845.088));
assert.ok(close(reconciliation.totalCircuitChangeM, 46.8));
assert.ok(
  close(
    reconciliation.absoluteWindingAreaReductionPercent,
    79.801548963,
    1e-9
  )
);
assert.equal(
  authority.BUILD_025_REFERENCE.geometryDimensionality,
  'plan_2d'
);
assert.equal(
  authority.BUILD_025_REFERENCE.terminalGeometryEvidence,
  'generic_unresolved'
);

console.log(
  `V8 regression tests passed: ${golden.passed}/${golden.total}; ` +
  `authority reconciliation ${authorityGolden.passed}/${authorityGolden.total}`
);

Authority Evidence

A JavaScript module in Solar Electrical Topology Analysis Engine Text Based that works with require object (`requireObject`) and require array (`requireArray`). Served with the page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/authority/.

rendersolar-electrical-topology-analysis-engine-text-based / v10-development/authority/authority-evidence.js · lines 1–165 of 165 · Entry point · pattern requireArray (shared by 2 files)

What it does
Defines 8 functions or classes, including requireObject, requireArray, requireValue, authorityEvidence, setText. 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.
Downstream impact
Used directly by 2 files: V10 Development — Authority Page (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/authority/); Studio Authority Evidence Test (solar-electrical-topology-analysis-engine-text-based). Reached from 132 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/v10-development/authority/.
What it achieves
It sets text (`setText`) and is built from the require object helper (`requireObject`) and the require array helper (`requireArray`). Defines `requireObject`, `requireArray`, `requireValue` and 5 more.
Why it matters
Loaded by the Authority page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/authority/. Checked by Studio Authority Evidence Test.
Application
solar-electrical-topology-analysis-engine-text-based · v10-development/authority · JavaScript module
Uses
Authority View (import)
Used by
loaded by V10 Development — Authority Page (script src), imported by Studio Authority Evidence Test (import), mentioned in Standalone (comment link)
Produces
authorityEvidence, renderAuthorityEvidence, loadAuthorityEvidence
Defines here
requireObject, requireArray, requireValue, authorityEvidence, setText, inputLines, renderAuthorityEvidence, loadAuthorityEvidence
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/authority/authority-evidence.js:1-165 · blob 27d4c6b2ee860482bf2c7855aef9293a5b15a045 · 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
import { AUTHORITY_BUNDLE_URL } from './authority-view.js';

function requireObject(value, name) {
  if (value === null || typeof value !== 'object' || Array.isArray(value)) {
    throw new TypeError(`${name} must be an object`);
  }
  return value;
}

function requireArray(value, name) {
  if (!Array.isArray(value)) throw new TypeError(`${name} must be an array`);
  return value;
}

function requireValue(value, name) {
  if (value === undefined) throw new TypeError(`${name} is required`);
  return value;
}

export function authorityEvidence(bundle) {
  const response = requireObject(bundle, 'authority response');
  const block = requireObject(response.inverter_block, 'inverter_block');
  const build025 = requireObject(response.build025, 'build025');
  const inputAuthority = requireObject(block.input_authority, 'input_authority');
  const equipmentEvidence = requireObject(block.equipment_evidence, 'equipment_evidence');
  const inputAllocation = requireObject(build025.input_allocation, 'build025.input_allocation');
  const assignments = requireArray(inputAllocation.assignments, 'input_allocation.assignments');
  const mappingStates = requireArray(
    inputAuthority.mppt_mapping_verification_states,
    'mppt_mapping_verification_states'
  );
  const equipmentMpptState = requireValue(mappingStates[0], 'equipment MPPT state');

  const physicalInputs = assignments.map((value, index) => {
    const assignment = requireObject(value, `input_allocation.assignments[${index}]`);
    return Object.freeze({
      ordinal: index + 1,
      fixtureInputId: requireValue(assignment.input_id, `assignment[${index}].input_id`),
      stringId: requireValue(assignment.string_id, `assignment[${index}].string_id`),
      equipmentMpptId: null,
      equipmentMpptState
    });
  });

  const physicalInputCount = requireValue(
    inputAuthority.physical_dc_input_count,
    'physical_dc_input_count'
  );
  const allocatedInputCount = requireValue(
    inputAuthority.allocated_physical_input_count,
    'allocated_physical_input_count'
  );
  if (physicalInputs.length !== physicalInputCount || physicalInputs.length !== allocatedInputCount) {
    throw new Error('physical input allocation count does not match the authority response');
  }

  const missingEvidence = requireArray(
    equipmentEvidence.missing_evidence,
    'equipment_evidence.missing_evidence'
  );
  const missingEvidenceCount = requireValue(
    equipmentEvidence.missing_evidence_count,
    'equipment_evidence.missing_evidence_count'
  );
  if (missingEvidence.length !== missingEvidenceCount) {
    throw new Error('missing-evidence count does not match the authority response');
  }

  return Object.freeze({
    physicalInputCount,
    allocatedInputCount,
    physicalInputs: Object.freeze(physicalInputs),
    equipmentMpptCount: requireValue(inputAuthority.mppt_count, 'equipment MPPT count'),
    equipmentMpptState,
    internalDcTopology: requireValue(
      inputAuthority.internal_dc_topology,
      'internal DC topology'
    ),
    internalDcTopologyState: requireValue(
      inputAuthority.internal_dc_topology_verification_state,
      'internal DC topology state'
    ),
    reverseCurrentBlocking: requireValue(
      inputAuthority.reverse_current_blocking,
      'reverse-current blocking'
    ),
    reverseCurrentBlockingState: requireValue(
      inputAuthority.reverse_current_blocking_verification_state,
      'reverse-current blocking state'
    ),
    pceBackfeedCurrentA: requireValue(
      inputAuthority.pce_backfeed_current_a,
      'PCE backfeed current'
    ),
    pceBackfeedState: requireValue(
      inputAuthority.pce_backfeed_verification_state,
      'PCE backfeed state'
    ),
    fixtureMpptLabelsAreEquipmentEvidence: requireValue(
      inputAuthority.routing_fixture_mppt_labels_are_equipment_evidence,
      'routing fixture MPPT evidence flag'
    ),
    evidenceState: requireValue(equipmentEvidence.state, 'equipment evidence state'),
    missingEvidenceCount,
    missingEvidence: Object.freeze([...missingEvidence])
  });
}

function setText(documentRef, id, value) {
  const element = documentRef.getElementById(id);
  if (!element) throw new Error(`authority evidence element is missing: ${id}`);
  element.textContent = String(value);
}

function inputLines(projection) {
  return projection.physicalInputs
    .map((input) => [
      String(input.ordinal).padStart(2, '0'),
      input.fixtureInputId,
      input.stringId,
      'UNRESOLVED'
    ].join(' | '))
    .join('\n');
}

export function renderAuthorityEvidence(documentRef, bundle) {
  const projection = authorityEvidence(bundle);
  const values = {
    'authority-physical-input-count': projection.physicalInputCount,
    'authority-allocated-input-count': projection.allocatedInputCount,
    'authority-equipment-mppt-count': 'UNRESOLVED',
    'authority-equipment-mppt-state': projection.equipmentMpptState,
    'authority-internal-topology': projection.internalDcTopology,
    'authority-reverse-blocking': projection.reverseCurrentBlocking,
    'authority-pce-backfeed': 'UNRESOLVED',
    'authority-fixture-label-evidence': String(
      projection.fixtureMpptLabelsAreEquipmentEvidence
    ),
    'authority-input-lines': inputLines(projection),
    'authority-evidence-lines': projection.missingEvidence.join('\n')
  };
  for (const [id, value] of Object.entries(values)) setText(documentRef, id, value);
  return projection;
}

export async function loadAuthorityEvidence({
  fetchImpl = globalThis.fetch,
  documentRef = globalThis.document
} = {}) {
  if (typeof fetchImpl !== 'function') throw new TypeError('fetch implementation is required');
  if (!documentRef) throw new TypeError('document is required');

  const response = await fetchImpl(AUTHORITY_BUNDLE_URL, { cache: 'no-store' });
  if (!response.ok) throw new Error(`authority bundle request failed: ${response.status}`);
  const bundle = await response.json();
  renderAuthorityEvidence(documentRef, bundle);
  return bundle;
}

if (typeof window !== 'undefined' && typeof document !== 'undefined') {
  loadAuthorityEvidence().catch((error) => {
    const evidenceState = document.getElementById('authority-equipment-mppt-state');
    if (evidenceState) evidenceState.textContent = `LOAD FAILED: ${error.message}`;
  });
}

Authority View

A JavaScript module that renders authority geometry and authority bundle and loads authority bundle, covering reference inverter block. Served with the page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/authority/.

rendersolar-electrical-topology-analysis-engine-text-based / v10-development/authority/authority-view.js · lines 1–219 of 219 · Entry point · pattern requireArray (shared by 2 files)

What it does
Defines 12 functions or classes, including requireObject, requireArray, requireValue, authoritySummary, projectedPoint. 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.
Inputs & outputs
In: JSON file reference-inverter-block.json.
Downstream impact
Used directly by 3 files: Authority Evidence (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/authority/); V10 Development — Authority Page (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/authority/); Studio Authority Test (solar-electrical-topology-analysis-engine-text-based). Reached from 132 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/v10-development/authority/.
What it achieves
It sets text (`setText`), renders authority geometry (`renderAuthorityGeometry`) and renders authority bundle (`renderAuthorityBundle`). Defines `requireObject`, `requireArray`, `requireValue` and 9 more.
Why it matters
Loaded by the Authority page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/authority/. Also imported by Authority Evidence. Checked by Studio Authority Test.
Application
solar-electrical-topology-analysis-engine-text-based · v10-development/authority · JavaScript module
Uses
none found
Used by
imported by Authority Evidence (import), loaded by V10 Development — Authority Page (script src), imported by Studio Authority Test (import)
Produces
AUTHORITY_BUNDLE_URL, authoritySummary, authorityGeometry, renderAuthorityGeometry, renderAuthorityBundle, loadAuthorityBundle
Defines here
requireObject, requireArray, requireValue, authoritySummary, projectedPoint, projectedRoute, authorityGeometry, setText, pointsAttribute, renderAuthorityGeometry, renderAuthorityBundle, loadAuthorityBundle
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/authority/authority-view.js:1-219 · blob 0d9db840285836fd1f0a37309fce7fef8b25bb2c · 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
export const AUTHORITY_BUNDLE_URL = '../../authority-bundles/reference-inverter-block.json';

const SVG_NS = 'http://www.w3.org/2000/svg';

function requireObject(value, name) {
  if (value === null || typeof value !== 'object' || Array.isArray(value)) {
    throw new TypeError(`${name} must be an object`);
  }
  return value;
}

function requireArray(value, name) {
  if (!Array.isArray(value)) throw new TypeError(`${name} must be an array`);
  return value;
}

function requireValue(value, name) {
  if (value === undefined) throw new TypeError(`${name} is required`);
  return value;
}

export function authoritySummary(bundle) {
  const response = requireObject(bundle, 'authority response');
  const block = requireObject(response.inverter_block, 'inverter_block');
  const boundary = requireObject(block.product_boundary, 'product_boundary');
  const evidence = requireObject(block.equipment_evidence, 'equipment_evidence');
  const build025 = requireObject(response.build025, 'build025');

  return Object.freeze({
    schemaVersion: requireValue(response.schema_version, 'schema_version'),
    strategy: requireValue(response.strategy, 'strategy'),
    modulePowerWp: requireValue(boundary.module_rated_power_wp, 'module_rated_power_wp'),
    modulesPerString: requireValue(boundary.modules_per_string, 'modules_per_string'),
    stringCount: requireValue(boundary.string_count, 'string_count'),
    moduleCount: requireValue(boundary.module_count, 'module_count'),
    dcPowerKwp: requireValue(boundary.dc_nameplate_power_kwp, 'dc_nameplate_power_kwp'),
    inverterPowerKva: requireValue(boundary.inverter_apparent_power_kva, 'inverter_apparent_power_kva'),
    dcAcRatio: requireValue(boundary.dc_ac_nameplate_ratio, 'dc_ac_nameplate_ratio'),
    evidenceState: requireValue(evidence.state, 'equipment evidence state'),
    missingEvidenceCount: requireValue(evidence.missing_evidence_count, 'missing evidence count'),
    responseHash: requireValue(response.response_hash, 'response_hash'),
    blockReceiptHash: requireValue(block.receipt_hash, 'inverter block receipt_hash'),
    build025ReceiptHash: requireValue(build025.receipt_hash, 'Build 025 receipt_hash')
  });
}

function projectedPoint(value, name) {
  const point = requireObject(value, name);
  return Object.freeze({
    x_m: requireValue(point.x_m, `${name}.x_m`),
    y_m: requireValue(point.y_m, `${name}.y_m`)
  });
}

function projectedRoute(value, kind, name) {
  const route = requireObject(value, name);
  const vertices = requireArray(route.vertices, `${name}.vertices`).map((point, index) =>
    projectedPoint(point, `${name}.vertices[${index}]`)
  );
  return Object.freeze({
    routeId: requireValue(route.route_id, `${name}.route_id`),
    stringId: requireValue(route.string_id, `${name}.string_id`),
    kind,
    vertices: Object.freeze(vertices)
  });
}

export function authorityGeometry(bundle) {
  const response = requireObject(bundle, 'authority response');
  const build025 = requireObject(response.build025, 'build025');
  const geometry = requireObject(build025.geometry, 'build025.geometry');
  const routing = requireObject(build025.routing, 'build025.routing');
  const bounds = requireArray(geometry.bounds_m, 'build025.geometry.bounds_m');
  const placements = requireArray(geometry.placements, 'build025.geometry.placements');
  const strings = requireArray(routing.strings, 'build025.routing.strings');

  const modules = placements.map((value, index) => {
    const placement = requireObject(value, `placement[${index}]`);
    const centre = requireArray(placement.centre_m, `placement[${index}].centre_m`);
    return Object.freeze({
      moduleId: requireValue(placement.module_id, `placement[${index}].module_id`),
      x_m: requireValue(centre[0], `placement[${index}].centre_m[0]`),
      y_m: requireValue(centre[1], `placement[${index}].centre_m[1]`)
    });
  });

  const routes = [];
  for (const [stringIndex, value] of strings.entries()) {
    const stringRoute = requireObject(value, `routing.strings[${stringIndex}]`);
    routes.push(
      projectedRoute(
        stringRoute.positive_route,
        'positive-home-run',
        `routing.strings[${stringIndex}].positive_route`
      )
    );
    routes.push(
      projectedRoute(
        stringRoute.negative_route,
        'negative-home-run',
        `routing.strings[${stringIndex}].negative_route`
      )
    );
    for (const [routeIndex, route] of requireArray(
      stringRoute.interconnect_routes,
      `routing.strings[${stringIndex}].interconnect_routes`
    ).entries()) {
      routes.push(
        projectedRoute(
          route,
          'series-interconnect',
          `routing.strings[${stringIndex}].interconnect_routes[${routeIndex}]`
        )
      );
    }
  }

  return Object.freeze({
    bounds_m: Object.freeze([...bounds]),
    modules: Object.freeze(modules),
    routes: Object.freeze(routes)
  });
}

function setText(documentRef, id, value) {
  const element = documentRef.getElementById(id);
  if (!element) throw new Error(`authority projection element is missing: ${id}`);
  element.textContent = String(value);
}

function pointsAttribute(vertices) {
  return vertices.map((point) => `${point.x_m},${point.y_m}`).join(' ');
}

export function renderAuthorityGeometry(documentRef, bundle) {
  const projection = authorityGeometry(bundle);
  const moduleLayer = documentRef.getElementById('authority-module-layer');
  const routeLayer = documentRef.getElementById('authority-route-layer');
  if (!moduleLayer || !routeLayer) throw new Error('authority geometry shell is incomplete');

  moduleLayer.replaceChildren();
  routeLayer.replaceChildren();

  for (const module of projection.modules) {
    const circle = documentRef.createElementNS(SVG_NS, 'circle');
    circle.setAttribute('class', 'authority-module-point');
    circle.setAttribute('data-module-id', String(module.moduleId));
    circle.setAttribute('cx', String(module.x_m));
    circle.setAttribute('cy', String(module.y_m));
    circle.setAttribute('r', '0.12');
    moduleLayer.appendChild(circle);
  }

  for (const route of projection.routes) {
    const polyline = documentRef.createElementNS(SVG_NS, 'polyline');
    polyline.setAttribute('class', `authority-route ${route.kind}`);
    polyline.setAttribute('data-route-id', String(route.routeId));
    polyline.setAttribute('data-string-id', String(route.stringId));
    polyline.setAttribute('data-route-kind', route.kind);
    polyline.setAttribute('points', pointsAttribute(route.vertices));
    routeLayer.appendChild(polyline);
  }

  setText(documentRef, 'authority-rendered-modules', projection.modules.length);
  setText(documentRef, 'authority-rendered-routes', projection.routes.length);
  return projection;
}

export function renderAuthorityBundle(documentRef, bundle) {
  const summary = authoritySummary(bundle);
  const view = documentRef.getElementById('authority-view');
  const banner = documentRef.getElementById('authority-banner');
  if (!view || !banner) throw new Error('authority view shell is incomplete');

  const values = {
    'authority-strategy': summary.strategy,
    'authority-module-power': `${summary.modulePowerWp} Wp`,
    'authority-modules-per-string': summary.modulesPerString,
    'authority-string-count': summary.stringCount,
    'authority-module-count': summary.moduleCount,
    'authority-dc-power': `${summary.dcPowerKwp} kWp`,
    'authority-inverter-power': `${summary.inverterPowerKva} kVA`,
    'authority-dc-ac-ratio': summary.dcAcRatio,
    'authority-evidence-state': summary.evidenceState,
    'authority-missing-evidence': summary.missingEvidenceCount,
    'authority-response-hash': summary.responseHash,
    'authority-block-hash': summary.blockReceiptHash,
    'authority-build025-hash': summary.build025ReceiptHash
  };
  for (const [id, value] of Object.entries(values)) setText(documentRef, id, value);

  view.dataset.authorityState = 'verified-bundle';
  banner.textContent = 'PYTHON AUTHORITY — VERIFIED COMMITTED BUNDLE';
  return summary;
}

export async function loadAuthorityBundle({
  fetchImpl = globalThis.fetch,
  documentRef = globalThis.document
} = {}) {
  if (typeof fetchImpl !== 'function') throw new TypeError('fetch implementation is required');
  if (!documentRef) throw new TypeError('document is required');

  const response = await fetchImpl(AUTHORITY_BUNDLE_URL, { cache: 'no-store' });
  if (!response.ok) throw new Error(`authority bundle request failed: ${response.status}`);
  const bundle = await response.json();
  renderAuthorityBundle(documentRef, bundle);
  renderAuthorityGeometry(documentRef, bundle);
  return bundle;
}

if (typeof window !== 'undefined' && typeof document !== 'undefined') {
  loadAuthorityBundle().catch((error) => {
    const view = document.getElementById('authority-view');
    const banner = document.getElementById('authority-banner');
    if (view) view.dataset.authorityState = 'load-failed';
    if (banner) banner.textContent = `PYTHON AUTHORITY — BUNDLE LOAD FAILED: ${error.message}`;
  });
}