In this section
- Test Microbuild Plan test · solar-electrical-topology-analysis-engine-text-based / tests/test_microbuild_plan.py lines 1–113
- Test Microbuild Runner test · solar-electrical-topology-analysis-engine-text-based / tests/test_microbuild_runner.py lines 1–73
- Test Microbuild Workflow test · solar-electrical-topology-analysis-engine-text-based / tests/test_microbuild_workflow.py lines 1–55
- Test Parquet Store test · solar-electrical-topology-analysis-engine-text-based / tests/test_parquet_store.py lines 1–182
- Test Persistence test · solar-electrical-topology-analysis-engine-text-based / tests/test_persistence.py lines 1–60
- Test Programme State test · solar-electrical-topology-analysis-engine-text-based / tests/test_programme_state.py lines 1–98
- Test Public API Inventory test · solar-electrical-topology-analysis-engine-text-based / tests/test_public_api_inventory.py lines 1–21
- Test Public Topology test · solar-electrical-topology-analysis-engine-text-based / tests/test_public_topology.py lines 1–97
Test Microbuild Plan
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based that checks Check Microbuild Plan.
testsolar-electrical-topology-analysis-engine-text-based / tests/test_microbuild_plan.py · lines 1–113 of 113 · Entry point
- What it does
- It tests its inputs. Defines 8 functions or classes, including _active_before_final, test_manifest_contract_has_twenty_ordered_completed_steps, test_manifest_still_accepts_one_active_final_gate, test_manifest_rejects_multiple_current_steps, test_manifest_rejects_incomplete_plan_without_current_step. Uses libraries __future__, copy, json, pathlib, pytest. 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.
- Downstream impact
- Used directly by 2 files: Run Microbuild (solar-electrical-topology-analysis-engine-text-based); Build 025 Small Gates Workflow (solar-electrical-topology-analysis-engine-text-based). Reached from 4 other entry points, including Microbuild Worker Workflow (solar-electrical-topology-analysis-engine-text-based); Test Microbuild Runner (solar-electrical-topology-analysis-engine-text-based); Test Microbuild Workflow (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- Defines `test_manifest_contract_has_twenty_ordered_completed_steps`, `test_manifest_still_accepts_one_active_final_gate`, `test_manifest_rejects_multiple_current_steps` and 4 more.
- Why it matters
- Run by Run Microbuild and Build 025 Small Gates Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · tests · test
- Uses
- Check Microbuild Plan (import), __future__, copy, json, pathlib, pytest
- Used by
- run by Run Microbuild (script call), run by Build 025 Small Gates Workflow (workflow run)
- Produces
- test_manifest_contract_has_twenty_ordered_completed_steps, test_manifest_still_accepts_one_active_final_gate, test_manifest_rejects_multiple_current_steps, test_manifest_rejects_incomplete_plan_without_current_step, test_manifest_rejects_skipped_and_out_of_order_states, test_manifest_rejects_unknown_test_identifiers_and_missing_spawn, test_manifest_file_is_canonical_json_object
- Defines here
- _active_before_final, test_manifest_contract_has_twenty_ordered_completed_steps, test_manifest_still_accepts_one_active_final_gate, test_manifest_rejects_multiple_current_steps, test_manifest_rejects_incomplete_plan_without_current_step, test_manifest_rejects_skipped_and_out_of_order_states, test_manifest_rejects_unknown_test_identifiers_and_missing_spawn, test_manifest_file_is_canonical_json_object
- 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_microbuild_plan.py:1-113 · blob 6acf3594f976fa548e43b7121550c7a845d090c0 · 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
from __future__ import annotations
from copy import deepcopy
import json
from pathlib import Path
import pytest
from scripts.check_microbuild_plan import (
DEFAULT_PLAN_PATH,
PlanValidationError,
load_plan,
validate_plan,
)
def _active_before_final() -> dict[str, object]:
plan = deepcopy(load_plan())
final = plan["steps"][-1]
final["status"] = "active"
final["evidence"] = None
plan["manifest_revision"] = 20
plan["active_step"] = "MB-20"
plan["next_step"] = None
return plan
def test_manifest_contract_has_twenty_ordered_completed_steps() -> None:
plan = load_plan()
summary = validate_plan(plan)
assert summary["pass"] is True
assert summary["programme_status"] == "completed"
assert summary["programme_id"] == "twenty-step-autopilot-20260801"
assert summary["manifest_revision"] == plan["manifest_revision"]
assert summary["active_step"] is None
assert summary["active_status"] is None
assert summary["active_test_id"] is None
assert summary["next_step"] is None
assert summary["passed_steps"] == 20
assert summary["planned_steps"] == 0
assert summary["total_steps"] == 20
assert plan["active_step"] is None
assert plan["next_step"] is None
assert [item["id"] for item in plan["steps"]] == [
f"MB-{ordinal:02d}" for ordinal in range(1, 21)
]
assert [item["phase"] for item in plan["steps"][:10]] == ["A"] * 10
assert [item["phase"] for item in plan["steps"][10:]] == ["B"] * 10
assert len({item["test_id"] for item in plan["steps"]}) == 20
assert all(item["status"] == "passed" for item in plan["steps"])
assert all(item["evidence"]["result"] == "pass" for item in plan["steps"])
assert all("command" not in item and "run" not in item for item in plan["steps"])
def test_manifest_still_accepts_one_active_final_gate() -> None:
summary = validate_plan(_active_before_final())
assert summary["programme_status"] == "active"
assert summary["active_step"] == "MB-20"
assert summary["active_test_id"] == "end_to_end_authority_slice"
assert summary["next_step"] is None
assert summary["passed_steps"] == 19
assert summary["planned_steps"] == 0
def test_manifest_rejects_multiple_current_steps() -> None:
plan = _active_before_final()
previous = plan["steps"][-2]
previous["status"] = "active"
previous["evidence"] = None
with pytest.raises(PlanValidationError, match="at most one active or blocked"):
validate_plan(plan)
def test_manifest_rejects_incomplete_plan_without_current_step() -> None:
plan = deepcopy(load_plan())
plan["steps"][-1]["status"] = "planned"
plan["steps"][-1]["evidence"] = None
with pytest.raises(PlanValidationError, match="must be fully passed"):
validate_plan(plan)
def test_manifest_rejects_skipped_and_out_of_order_states() -> None:
plan = _active_before_final()
plan["steps"][-2]["status"] = "planned"
plan["steps"][-2]["evidence"] = None
with pytest.raises(PlanValidationError, match="before current step must be passed"):
validate_plan(plan)
def test_manifest_rejects_unknown_test_identifiers_and_missing_spawn(tmp_path: Path) -> None:
plan = deepcopy(load_plan())
plan["steps"][0]["test_id"] = "shell: rm -rf"
with pytest.raises(PlanValidationError, match="test id invalid"):
validate_plan(plan)
plan = deepcopy(load_plan())
plan["quantum_spawn"] = "docs/quantum-spawn/missing.md"
with pytest.raises(PlanValidationError, match="Quantum Spawn path does not exist"):
validate_plan(plan)
def test_manifest_file_is_canonical_json_object() -> None:
text = DEFAULT_PLAN_PATH.read_text(encoding="utf-8")
payload = json.loads(text)
assert isinstance(payload, dict)
assert text.endswith("\n")Test Microbuild Runner
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based that checks Check Microbuild Plan and Run Microbuild.
testsolar-electrical-topology-analysis-engine-text-based / tests/test_microbuild_runner.py · lines 1–73 of 73 · Entry point
- What it does
- It tests its inputs. Defines test_completed_manifest_selects_no_further_command, test_all_twenty_manifest_test_identifiers_are_allowlisted, test_unknown_identifier_is_rejected_without_shell_execution, test_cli_reports_completed_programme_without_execution, test_explicit_allowlisted_test_remains_available_after_completion. Uses libraries __future__, json, pathlib, subprocess, sys. 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 microbuild-plan.json.
- Downstream impact
- Used directly by 2 files: Run Microbuild (solar-electrical-topology-analysis-engine-text-based); Build 025 Small Gates Workflow (solar-electrical-topology-analysis-engine-text-based). Reached from 3 other entry points, including Microbuild Worker Workflow (solar-electrical-topology-analysis-engine-text-based); Test Microbuild Workflow (solar-electrical-topology-analysis-engine-text-based); Test Ts005 Handoff (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- Defines `test_completed_manifest_selects_no_further_command`, `test_all_twenty_manifest_test_identifiers_are_allowlisted`, `test_unknown_identifier_is_rejected_without_shell_execution` and 2 more.
- Why it matters
- Run by Run Microbuild and Build 025 Small Gates Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · tests · test
- Uses
- Check Microbuild Plan (import), Run Microbuild (import), __future__, json, pathlib, subprocess, sys, pytest
- Used by
- run by Run Microbuild (script call), run by Build 025 Small Gates Workflow (workflow run)
- Produces
- test_completed_manifest_selects_no_further_command, test_all_twenty_manifest_test_identifiers_are_allowlisted, test_unknown_identifier_is_rejected_without_shell_execution, test_cli_reports_completed_programme_without_execution, test_explicit_allowlisted_test_remains_available_after_completion
- Defines here
- test_completed_manifest_selects_no_further_command, test_all_twenty_manifest_test_identifiers_are_allowlisted, test_unknown_identifier_is_rejected_without_shell_execution, test_cli_reports_completed_programme_without_execution, test_explicit_allowlisted_test_remains_available_after_completion
- 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_microbuild_runner.py:1-73 · blob 32dccc4effcdf59b89a9d9cd9356af7c58b3a0e6 · 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
import json
from pathlib import Path
import subprocess
import sys
import pytest
from scripts.check_microbuild_plan import load_plan, validate_plan
from scripts.run_microbuild import (
TEST_COMMANDS,
UnknownTestIdentifier,
active_command,
active_test_id,
command_for_test,
)
ROOT = Path(__file__).resolve().parents[1]
def test_completed_manifest_selects_no_further_command() -> None:
summary = validate_plan(load_plan())
assert summary["programme_status"] == "completed"
assert active_test_id() is None
assert active_command() == ()
def test_all_twenty_manifest_test_identifiers_are_allowlisted() -> None:
plan = json.loads((ROOT / "microbuild-plan.json").read_text(encoding="utf-8"))
manifest_ids = {item["test_id"] for item in plan["steps"]}
assert manifest_ids == set(TEST_COMMANDS)
assert len(TEST_COMMANDS) == 20
assert all(isinstance(command, tuple) and command for command in TEST_COMMANDS.values())
def test_unknown_identifier_is_rejected_without_shell_execution() -> None:
with pytest.raises(UnknownTestIdentifier, match="unknown microbuild test id"):
command_for_test("rm_rf_repository")
def test_cli_reports_completed_programme_without_execution() -> None:
completed = subprocess.run(
[sys.executable, "scripts/run_microbuild.py"],
cwd=ROOT,
check=True,
capture_output=True,
text=True,
)
payload = json.loads(completed.stdout)
assert payload == {
"programme_status": "completed",
"test_id": None,
"command": [],
}
def test_explicit_allowlisted_test_remains_available_after_completion() -> None:
completed = subprocess.run(
[sys.executable, "scripts/run_microbuild.py", "--test-id", "manifest_contract"],
cwd=ROOT,
check=True,
capture_output=True,
text=True,
)
payload = json.loads(completed.stdout)
assert payload["test_id"] == "manifest_contract"
assert payload["command"] == list(TEST_COMMANDS["manifest_contract"])Test Microbuild Workflow
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based that checks Check Microbuild Plan and Run Microbuild.
testsolar-electrical-topology-analysis-engine-text-based / tests/test_microbuild_workflow.py · lines 1–55 of 55 · Entry point
- What it does
- It tests its inputs. Defines test_microbuild_worker_runs_only_manifest_and_allowlisted_runner, test_worker_is_triggerable_by_marker_and_future_authority_files, test_worker_never_interpolates_manifest_text_into_shell, test_execution_envelope_uses_canonical_writer_and_github_state. Uses libraries __future__, pathlib. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (repository name word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
- Inputs & outputs
- In: JSON file microbuild-plan.json; JSON file latest.json.
- Downstream impact
- Used directly by 2 files: Run Microbuild (solar-electrical-topology-analysis-engine-text-based); Build 025 Small Gates Workflow (solar-electrical-topology-analysis-engine-text-based). Reached from 3 other entry points, including Microbuild Worker Workflow (solar-electrical-topology-analysis-engine-text-based); Test Microbuild Runner (solar-electrical-topology-analysis-engine-text-based); Test Ts005 Handoff (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- Defines `test_microbuild_worker_runs_only_manifest_and_allowlisted_runner`, `test_worker_is_triggerable_by_marker_and_future_authority_files`, `test_worker_never_interpolates_manifest_text_into_shell` and 1 more.
- Why it matters
- Run by Run Microbuild and Build 025 Small Gates Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · tests · test
- Uses
- Check Microbuild Plan (script call), Run Microbuild (script call), Microbuild Evidence (script call), __future__, pathlib
- Used by
- run by Run Microbuild (script call), run by Build 025 Small Gates Workflow (workflow run)
- Produces
- test_microbuild_worker_runs_only_manifest_and_allowlisted_runner, test_worker_is_triggerable_by_marker_and_future_authority_files, test_worker_never_interpolates_manifest_text_into_shell, test_execution_envelope_uses_canonical_writer_and_github_state
- Defines here
- test_microbuild_worker_runs_only_manifest_and_allowlisted_runner, test_worker_is_triggerable_by_marker_and_future_authority_files, test_worker_never_interpolates_manifest_text_into_shell, test_execution_envelope_uses_canonical_writer_and_github_state
- 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_microbuild_workflow.py:1-55 · blob 98d47ff2b3529556744c77aa0b5a4496defd8f08 · 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
from __future__ import annotations
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
WORKFLOW = ROOT / ".github" / "workflows" / "microbuild-worker.yml"
def test_microbuild_worker_runs_only_manifest_and_allowlisted_runner() -> None:
text = WORKFLOW.read_text(encoding="utf-8")
assert "name: Microbuild Worker" in text
assert "fetch-depth: 0" in text
assert "python scripts/check_microbuild_plan.py --check" in text
assert "python scripts/run_microbuild.py --execute" in text
assert "actions/upload-artifact@v4" in text
assert "microbuild-evidence-${{ github.sha }}" in text
assert "permissions:\n contents: read" in text
assert "cancel-in-progress: false" in text
def test_worker_is_triggerable_by_marker_and_future_authority_files() -> None:
text = WORKFLOW.read_text(encoding="utf-8")
for required_path in (
'".microbuild/**"',
'"microbuild-plan.json"',
'"scripts/microbuild_*.py"',
'"authority-bundles/**"',
'"v10-development/tests/studio-authority.test.mjs"',
):
assert required_path in text
def test_worker_never_interpolates_manifest_text_into_shell() -> None:
text = WORKFLOW.read_text(encoding="utf-8")
assert "steps[].command" not in text
active_block = text.split("Run active allowlisted test", 1)[1].split(
"Write canonical microbuild evidence", 1
)[0]
assert "active_test_id" not in active_block
assert "run: ${{" not in text
assert "python scripts/run_microbuild.py --execute" in text
def test_execution_envelope_uses_canonical_writer_and_github_state() -> None:
text = WORKFLOW.read_text(encoding="utf-8")
assert "python scripts/microbuild_evidence.py" in text
assert '--tested-commit "$GITHUB_SHA"' in text
assert '--workflow-run-id "$GITHUB_RUN_ID"' in text
assert "--result pass" in text
assert "--output .microbuild/evidence/latest.json" in textTest Parquet Store
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based.
testsolar-electrical-topology-analysis-engine-text-based / tests/test_parquet_store.py · lines 1–182 of 182 · Entry point
- What it does
- It tests its inputs. Defines read_one, test_deterministic_partitioned_store_and_actual_string_count, test_infeasible_leapfrog_keeps_theory_but_blocks_available_saving, test_route_and_conductor_length_are_separate_columns. Uses libraries json, math, duckdb, pytest, solar_topology.fleet_store. Side effects: uses storage (browser storage, DuckDB or Parquet).
- 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: Parquet file comparison.parquet; Parquet file site.parquet; Parquet file strings.parquet; DuckDB queries.
- Downstream impact
- Used directly by 1 file: Build 025 Small Gates Workflow (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- Defines `read_one`, `test_deterministic_partitioned_store_and_actual_string_count`, `test_infeasible_leapfrog_keeps_theory_but_blocks_available_saving` and 1 more.
- Why it matters
- Run by Build 025 Small Gates Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · tests · test
- Uses
- json, math, duckdb, pytest, solar_topology.fleet_store, solar_topology.segments
- Used by
- run by Build 025 Small Gates Workflow (workflow run)
- Produces
- read_one, test_deterministic_partitioned_store_and_actual_string_count, test_infeasible_leapfrog_keeps_theory_but_blocks_available_saving, test_route_and_conductor_length_are_separate_columns
- Defines here
- read_one, test_deterministic_partitioned_store_and_actual_string_count, test_infeasible_leapfrog_keeps_theory_but_blocks_available_saving, test_route_and_conductor_length_are_separate_columns
- 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_parquet_store.py:1-182 · blob da2e6396624f6227121844b4542ca238ddfc4315 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: storage · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
import json
import math
import duckdb
import pytest
from solar_topology.fleet_store import (
build_deterministic_store,
build_store,
)
from solar_topology.segments import TopologyInputs
def read_one(connection, path, columns="*"):
return connection.execute(
f"SELECT {columns} FROM read_parquet(?)",
[str(path)],
).fetchone()
def test_deterministic_partitioned_store_and_actual_string_count(tmp_path):
inputs = TopologyInputs(
inverter_count=2,
total_site_string_count=47,
positive_factory_lead_m=1.4,
negative_factory_lead_m=1.4,
)
output = tmp_path / "store"
result = build_deterministic_store(
inputs,
output,
source_commit="test-commit",
)
assert result["deterministic"] is True
assert result["string_count"] == 47
assert result["generated_segment_rows"] == 47 * 183
partitions = sorted(
output.glob("segments/topology=*/band=*/data_*.parquet")
)
result_partitions = sorted(
output.glob("results/segments/topology=*/band=*/data_*.parquet")
)
assert len(partitions) == 6
assert len(result_partitions) == 6
connection = duckdb.connect()
try:
comparison = read_one(
connection,
output / "aggregates" / "comparison.parquet",
)
assert comparison[0] == 47
assert comparison[3] == pytest.approx(47 * 39.67)
assert comparison[4] == pytest.approx(47 * 39.67)
assert comparison[5] is True
site = connection.execute(
"""
SELECT topology, string_count
FROM read_parquet(?)
ORDER BY topology
""",
[str(output / "aggregates" / "site.parquet")],
).fetchall()
assert site == [("leapfrog", 47), ("sequential", 47)]
factory = connection.execute(
"""
SELECT
topology,
min(factory_lead_m),
max(factory_lead_m),
min(connector_count),
max(connector_count)
FROM read_parquet(?)
GROUP BY topology
ORDER BY topology
""",
[str(output / "aggregates" / "strings.parquet")],
).fetchall()
assert [row[0] for row in factory] == [
"leapfrog",
"sequential",
]
for row in factory:
assert row[1] == pytest.approx(84.0)
assert row[2] == pytest.approx(84.0)
assert row[3] == 62
assert row[4] == 62
result_glob = (
output / "results" / "segments" / "**" / "*.parquet"
)
speeds = connection.execute(
"""
SELECT
min(propagation_velocity_m_per_s),
max(propagation_velocity_m_per_s)
FROM read_parquet(?, hive_partitioning = true)
WHERE loop_parameter_weight > 0
""",
[str(result_glob)],
).fetchone()
expected_velocity = 1 / math.sqrt(
4 * math.pi * 1e-7
* 8.8541878128e-12
* inputs.effective_epsilon_r
)
assert speeds[0] == pytest.approx(expected_velocity)
assert speeds[1] == pytest.approx(expected_velocity)
finally:
connection.close()
manifest = json.loads(
(
output
/ "manifests"
/ "topology=leapfrog"
/ "manifest.json"
).read_text(encoding="utf-8")
)
assert manifest["data_law_result"] == "PASS"
assert manifest["distinct_string_count"] == 47
assert manifest["feasibility_status"] == "FEASIBLE_LENGTH_SCREEN"
assert manifest["parquet_files"]
def test_infeasible_leapfrog_keeps_theory_but_blocks_available_saving(
tmp_path,
):
inputs = TopologyInputs(
inverter_count=1,
total_site_string_count=24,
)
output = tmp_path / "store"
build_store(inputs, output, source_commit="test-commit")
connection = duckdb.connect()
try:
comparison = read_one(
connection,
output / "aggregates" / "comparison.parquet",
)
assert comparison[0] == 24
assert comparison[3] == pytest.approx(24 * 39.67)
assert comparison[4] is None
assert comparison[5] is False
finally:
connection.close()
def test_route_and_conductor_length_are_separate_columns(tmp_path):
inputs = TopologyInputs(
inverter_count=1,
total_site_string_count=1,
east_bands=(1,),
west_bands=(),
positive_factory_lead_m=1.4,
negative_factory_lead_m=1.4,
)
output = tmp_path / "store"
build_store(inputs, output, source_commit="test-commit")
connection = duckdb.connect()
try:
rows = connection.execute(
"""
SELECT
topology,
route_displacement_m,
conductor_length_m
FROM read_parquet(?)
ORDER BY topology
""",
[str(output / "aggregates" / "strings.parquet")],
).fetchall()
assert len(rows) == 2
assert all(route != conductor for _, route, conductor in rows)
finally:
connection.close()Test Persistence
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based.
testsolar-electrical-topology-analysis-engine-text-based / tests/test_persistence.py · lines 1–60 of 60 · Entry point · pattern _record (shared by 4 files)
- What it does
- It tests its inputs. Defines 6 functions or classes, including _record, test_store_is_deterministic_under_record_reordering, test_read_back_reconstructs_identical_store, test_tampered_payload_is_rejected, test_noncanonical_serialisation_is_rejected_on_read_back. Uses libraries json, pytest, solar_topology.persistence.
- 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_store_is_deterministic_under_record_reordering`, `test_read_back_reconstructs_identical_store`, `test_tampered_payload_is_rejected` and 2 more.
- Why it matters
- Run by Build 025 Small Gates Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · tests · test
- Uses
- json, pytest, solar_topology.persistence
- Used by
- run by Build 025 Small Gates Workflow (workflow run)
- Produces
- test_store_is_deterministic_under_record_reordering, test_read_back_reconstructs_identical_store, test_tampered_payload_is_rejected, test_noncanonical_serialisation_is_rejected_on_read_back, test_duplicate_record_identifiers_are_rejected
- Defines here
- _record, test_store_is_deterministic_under_record_reordering, test_read_back_reconstructs_identical_store, test_tampered_payload_is_rejected, test_noncanonical_serialisation_is_rejected_on_read_back, test_duplicate_record_identifiers_are_rejected
- 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_persistence.py:1-60 · blob 6612901f11002c98dfc28001e5557eeee1eaa072 · 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 json
import pytest
from solar_topology.persistence import (
PersistedRecord,
build_deterministic_record_store,
deterministic_store_hash,
deterministic_store_json,
persist_record,
read_back_store,
)
def _record(record_id, value):
return persist_record(
record_id=record_id,
record_type="fixture",
source_schema_version="fixture.v1",
payload={"value": value, "nested": {"b": 2, "a": 1}},
)
def test_store_is_deterministic_under_record_reordering():
first = build_deterministic_record_store([_record("b", 2), _record("a", 1)])
second = build_deterministic_record_store([_record("a", 1), _record("b", 2)])
assert deterministic_store_json(first) == deterministic_store_json(second)
assert deterministic_store_hash(first) == deterministic_store_hash(second)
def test_read_back_reconstructs_identical_store():
store = build_deterministic_record_store([_record("a", 1), _record("b", 2)])
serialised = deterministic_store_json(store)
recovered = read_back_store(serialised)
assert recovered == store
assert deterministic_store_hash(recovered) == deterministic_store_hash(store)
def test_tampered_payload_is_rejected():
record = _record("a", 1)
with pytest.raises(ValueError, match="payload_hash"):
PersistedRecord(
record_id=record.record_id,
record_type=record.record_type,
source_schema_version=record.source_schema_version,
payload_json='{"value":2}',
payload_hash=record.payload_hash,
)
def test_noncanonical_serialisation_is_rejected_on_read_back():
store = build_deterministic_record_store([_record("a", 1)])
noncanonical = json.dumps(json.loads(deterministic_store_json(store)), indent=2)
with pytest.raises(ValueError, match="not canonical"):
read_back_store(noncanonical)
def test_duplicate_record_identifiers_are_rejected():
with pytest.raises(ValueError, match="identifiers must be unique"):
build_deterministic_record_store([_record("a", 1), _record("a", 2)])Test Programme State
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based.
testsolar-electrical-topology-analysis-engine-text-based / tests/test_programme_state.py · lines 1–98 of 98 · Entry point
- What it does
- It tests its inputs. Defines load_sync_module, test_programme_state_schema_arithmetic_and_capability_boundaries, test_readme_and_dashboard_are_exact_manifest_projections, test_stale_manual_status_claims_are_absent, test_programme_state_check_command_passes. Uses libraries __future__, importlib.util, json, pathlib, subprocess. 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 programme-state.json.
- Downstream impact
- Used directly by 2 files: Run Microbuild (solar-electrical-topology-analysis-engine-text-based); Build 025 Small Gates Workflow (solar-electrical-topology-analysis-engine-text-based). Reached from 4 other entry points, including Microbuild Worker Workflow (solar-electrical-topology-analysis-engine-text-based); Test Microbuild Runner (solar-electrical-topology-analysis-engine-text-based); Test Microbuild Workflow (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- Defines `load_sync_module`, `test_programme_state_schema_arithmetic_and_capability_boundaries`, `test_readme_and_dashboard_are_exact_manifest_projections` and 2 more.
- Why it matters
- Run by Run Microbuild and Build 025 Small Gates Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · tests · test
- Uses
- __future__, importlib.util, json, pathlib, subprocess, sys
- Used by
- run by Run Microbuild (script call), run by Build 025 Small Gates Workflow (workflow run)
- Produces
- load_sync_module, test_programme_state_schema_arithmetic_and_capability_boundaries, test_readme_and_dashboard_are_exact_manifest_projections, test_stale_manual_status_claims_are_absent, test_programme_state_check_command_passes
- Defines here
- load_sync_module, test_programme_state_schema_arithmetic_and_capability_boundaries, test_readme_and_dashboard_are_exact_manifest_projections, test_stale_manual_status_claims_are_absent, test_programme_state_check_command_passes
- 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_programme_state.py:1-98 · blob 045449593196d989489b3f51d4de65570d238491 · 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
import importlib.util
import json
from pathlib import Path
import subprocess
import sys
ROOT = Path(__file__).resolve().parents[1]
SCRIPT = ROOT / "scripts" / "sync_programme_state.py"
def load_sync_module():
spec = importlib.util.spec_from_file_location("sync_programme_state", SCRIPT)
assert spec is not None and spec.loader is not None
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
def test_programme_state_schema_arithmetic_and_capability_boundaries() -> None:
sync = load_sync_module()
state = json.loads((ROOT / "programme-state.json").read_text(encoding="utf-8"))
sync.validate_state(state)
block = state["reference_inverter_block"]
assert block == {
"module_technology": "bifacial",
"module_rated_power_wp": 660,
"modules_per_string": 30,
"string_rated_power_kwp": 19.8,
"strings": 24,
"module_count": 720,
"dc_nameplate_power_kwp": 475.2,
"inverter_apparent_power_kva": 352,
"dc_ac_nameplate_ratio": 1.35,
}
assert state["current_build"] == "Build 026 — Continuity and model repair"
assert state["active_gate"] == "TS-005 — Complete"
assert state["next_single_goal"] == "B026-07 — Deliberate root gitignore"
assert state["current_trueself"] == (
"docs/trueself/202608011610-the-demonstration-exists-the-ledger-does-not-trueself-claude.md"
)
assert state["validation"]["suites"][0] == {
"name": "Python",
"passed": 377,
"total": 377,
}
assert any(
item["name"] == "Inverter-block clean wheel"
and item["passed"] == item["total"] == 1
for item in state["validation"]["suites"]
)
assert "weighted_programme_progress" not in state
assert "progress_percent" not in state
def test_readme_and_dashboard_are_exact_manifest_projections() -> None:
sync = load_sync_module()
state = sync.load_json(sync.MANIFEST_PATH)
sync.validate_state(state)
sync.check_outputs(state)
readme = (ROOT / "README.md").read_text(encoding="utf-8")
dashboard = (ROOT / "progress-dashboard.html").read_text(encoding="utf-8")
assert readme.count(sync.README_START) == 1
assert readme.count(sync.README_END) == 1
assert dashboard == sync.render_dashboard(state)
def test_stale_manual_status_claims_are_absent() -> None:
public_state = (
(ROOT / "README.md").read_text(encoding="utf-8")
+ (ROOT / "progress-dashboard.html").read_text(encoding="utf-8")
)
for stale in (
"BUILD 024 ACTIVE",
"Total validated tests</small><strong>176",
"31.25%",
"width:31.25%",
"Current programme: Build 024",
"Python authority suite</small><strong>140",
):
assert stale not in public_state
def test_programme_state_check_command_passes() -> None:
completed = subprocess.run(
[sys.executable, str(SCRIPT), "--check"],
cwd=ROOT,
check=False,
text=True,
capture_output=True,
)
assert completed.returncode == 0, completed.stderr
assert "generated outputs are in sync" in completed.stdoutTest Public API Inventory
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based.
testsolar-electrical-topology-analysis-engine-text-based / tests/test_public_api_inventory.py · lines 1–21 of 21 · Entry point
- What it does
- It tests its inputs. Defines test_public_api_inventory_is_total_unique_and_sorted, test_explicit_public_api_classification_has_no_duplicates, test_unadjudicated_exports_remain_provisional_not_canonical. 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_public_api_inventory_is_total_unique_and_sorted`, `test_explicit_public_api_classification_has_no_duplicates` and `test_unadjudicated_exports_remain_provisional_not_canonical`.
- 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_public_api_inventory_is_total_unique_and_sorted, test_explicit_public_api_classification_has_no_duplicates, test_unadjudicated_exports_remain_provisional_not_canonical
- Defines here
- test_public_api_inventory_is_total_unique_and_sorted, test_explicit_public_api_classification_has_no_duplicates, test_unadjudicated_exports_remain_provisional_not_canonical
- 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_public_api_inventory.py:1-21 · blob 950d8c3e183d36a1037fae3ac09836cabea7d01f · 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 api
def test_public_api_inventory_is_total_unique_and_sorted():
inventory = api.build_public_api_inventory(api.__all__)
names = [name for name, _status in inventory]
assert names == sorted(names)
assert len(names) == len(set(names))
assert set(names) == set(api.__all__)
def test_explicit_public_api_classification_has_no_duplicates():
names = api.explicitly_classified_public_names()
assert names == tuple(sorted(names))
assert len(names) == len(set(names))
def test_unadjudicated_exports_remain_provisional_not_canonical():
assert api.public_api_status("definitely-not-an-export") == api.ApiStatus.PROVISIONAL
assert api.public_api_status("CircuitModel") == api.ApiStatus.CANONICAL
assert api.public_api_status("INITIAL_CARTRIDGES") == api.ApiStatus.COMPATIBILITYTest Public Topology
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based.
testsolar-electrical-topology-analysis-engine-text-based / tests/test_public_topology.py · lines 1–97 of 97 · Entry point · pattern _record (shared by 4 files)
- What it does
- It tests its inputs. Defines 7 functions or classes, including _source, _record, test_public_manifest_builds_and_hashes_deterministically, test_public_manifest_rejects_confidential_source_even_with_public_record_name, test_public_manifest_rejects_unknown_source. Uses libraries pytest, solar_topology.circuit, solar_topology.evidence, solar_topology.evidence_boundary, solar_topology.identifiers.
- 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.
- Downstream impact
- Used directly by 1 file: Build 025 Small Gates Workflow (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- Defines `test_public_manifest_builds_and_hashes_deterministically`, `test_public_manifest_rejects_confidential_source_even_with_public_record_name`, `test_public_manifest_rejects_unknown_source` and 2 more.
- Why it matters
- Run by Build 025 Small Gates Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · tests · test
- Uses
- pytest, solar_topology.circuit, solar_topology.evidence, solar_topology.evidence_boundary, solar_topology.identifiers, solar_topology.public_topology
- Used by
- run by Build 025 Small Gates Workflow (workflow run)
- Produces
- test_public_manifest_builds_and_hashes_deterministically, test_public_manifest_rejects_confidential_source_even_with_public_record_name, test_public_manifest_rejects_unknown_source, test_public_manifest_rejects_record_from_another_project, test_record_requires_sorted_unique_sources_and_attributes
- Defines here
- _source, _record, test_public_manifest_builds_and_hashes_deterministically, test_public_manifest_rejects_confidential_source_even_with_public_record_name, test_public_manifest_rejects_unknown_source, test_public_manifest_rejects_record_from_another_project, test_record_requires_sorted_unique_sources_and_attributes
- 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_public_topology.py:1-97 · blob 8d4f6481f5338f266e5e4ea1a7291561a67330a6 · 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 pytest
from solar_topology.circuit import EvidenceClass
from solar_topology.evidence import VerificationState, canonical_evidence_descriptor
from solar_topology.evidence_boundary import (
EvidenceSource,
PublicationPermission,
RightsStatus,
)
from solar_topology.identifiers import EntityLevel, project_id
from solar_topology.public_topology import (
PublicTopologyRecord,
build_public_topology_manifest,
public_topology_hash,
public_topology_json,
)
def _source(source_id="planning-layout", public=True):
return EvidenceSource(
source_id=source_id,
descriptor=canonical_evidence_descriptor(
EvidenceClass.PUBLIC_OBSERVATION,
verification_state=VerificationState.CANDIDATE,
source_reference=f"fixture:{source_id}",
),
rights_status=RightsStatus.PUBLIC if public else RightsStatus.CONFIDENTIAL_NDA,
publication_permission=(
PublicationPermission.PUBLIC
if public
else PublicationPermission.INTERNAL_ONLY
),
)
def _record(project, source_id="planning-layout"):
site = project.child(EntityLevel.SITE, "site-001")
system = site.child(EntityLevel.SYSTEM, "dc-array")
return PublicTopologyRecord(
identifier=system,
record_type="array-system",
source_ids=(source_id,),
attributes=(("status", "publicly-observed"),),
)
def test_public_manifest_builds_and_hashes_deterministically():
project = project_id("public-cleve-hill-study")
source = _source()
record = _record(project)
first = build_public_topology_manifest(project, [record], {source.source_id: source})
second = build_public_topology_manifest(project, tuple(reversed([record])), {source.source_id: source})
assert public_topology_json(first) == public_topology_json(second)
assert public_topology_hash(first) == public_topology_hash(second)
def test_public_manifest_rejects_confidential_source_even_with_public_record_name():
project = project_id("study")
source = _source("internal-sld", public=False)
with pytest.raises(PermissionError, match="blocked"):
build_public_topology_manifest(
project,
[_record(project, "internal-sld")],
{source.source_id: source},
)
def test_public_manifest_rejects_unknown_source():
project = project_id("study")
with pytest.raises(ValueError, match="unknown evidence sources"):
build_public_topology_manifest(project, [_record(project)], {})
def test_public_manifest_rejects_record_from_another_project():
project = project_id("study-a")
other = project_id("study-b")
source = _source()
with pytest.raises(ValueError, match="belong"):
build_public_topology_manifest(
project,
[_record(other)],
{source.source_id: source},
)
def test_record_requires_sorted_unique_sources_and_attributes():
project = project_id("study")
site = project.child(EntityLevel.SITE, "site-001")
with pytest.raises(ValueError, match="source_ids"):
PublicTopologyRecord(site, "site", ("b", "a"))
with pytest.raises(ValueError, match="attribute keys"):
PublicTopologyRecord(
site,
"site",
("a",),
(("z", 1), ("a", 2)),
)