Repository navigation
Split the Stage 12 runtime tests under the file-length limit - #936
Merged
Merged
Conversation
2 tasks done
anth-volk
force-pushed
the
file-length-split-stage12-runtime-tests
branch
from
October 27, 2026 13:45
b72ac3f to
9ff580d
Compare
anth-volk
force-pushed
the
file-length-split-stage12-runtime-tests
branch
3 times, most recently
from
October 27, 2026 16:17
751a192 to
c15dab7
Compare
Base automatically changed from
file-length-split-stage12-coordination
to
main
October 27, 2026 16:30
tests/test_stage12_runtime.py (4,709 lines) was over the file-length limit for test code. Its tests move, unchanged, into thirteen files by behaviour: - test_stage12_runtime.py: loading a simulation's dataset and region - test_stage12_dataset_provenance.py: the dataset a calculation loads - test_stage12_single_worker.py, test_stage12_single_worker_failures.py - test_stage12_aggregate_reports.py - test_stage12_coordinator.py, test_stage12_coordinator_failures.py, test_stage12_coordinator_failure_records.py - test_stage12_runtime_store_retries.py - test_stage12_child_cancellation.py, test_stage12_child_state_errors.py - test_stage12_wait_window.py The helpers several files use move to three support modules: stage12_runtime_support.py (inputs, records, runtimes and failure checks), stage12_fake_stores.py (the in-memory stores) and stage12_child_call_support.py (fake child calls and invokers). Their private names are now public, under names that no test uses for a local variable: for example _report is report_execution_input, _simulation is simulation_execution_input, _context is invocation_context and _parent is parent_record. The seven other Stage 12 test modules that imported them from test_stage12_runtime.py now import them from the support modules, and coordinate_report_impl from the package itself. All 1,895 tests keep their names and bodies, apart from the renamed helpers. Pytest names two parametrized cases of test_installed_bundle_accepts_the_dataset_a_region_loads after the bundle helper, so they are now [us-bundle_provenance] and [state/ut-bundle_provenance]. The file-length baseline drops the file (count 8 to 7). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
force-pushed
the
file-length-split-stage12-runtime-tests
branch
from
October 27, 2026 16:30
c15dab7 to
587c559
Compare
anth-volk
marked this pull request as ready for review
October 27, 2026 16:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #935
Same-Repository Draft PR Check
PolicyEngine/policyengine-sim-api, not a personal fork.Summary
Fifth of nine stacked PRs; it builds on #933. It splits the executor's
tests/test_stage12_runtime.py(4,709 lines) into test files under the 1,500-line limit for tests, without changing any test or any source file, and removes it from the file-length baseline (count 8 to 7).A script compared every top-level statement of the old file with the new files: all 168 appear exactly once and unchanged apart from the helper renames, in their original order.
stage12_runtime_support.pycoordinate_reportwrapper, recording runtimes, failure-summary checks, the dataset-load harnessstage12_fake_stores.pyFakeStore,FakeArtifactsand the simulation frames they holdstage12_child_call_support.pytest_stage12_runtime.pytest_stage12_dataset_provenance.pytest_stage12_single_worker.pytest_stage12_single_worker_failures.pytest_stage12_aggregate_reports.pytest_stage12_coordinator.pytest_stage12_coordinator_failures.pytest_stage12_coordinator_failure_records.pytest_stage12_runtime_store_retries.pytest_stage12_child_cancellation.pytest_stage12_child_state_errors.pytest_stage12_wait_window.pyRenames
The helpers the files share are now public, under names no test already uses for a local variable or parameter (a script checked):
_spm_calculation_provenancetospm_calculation_provenance,_bundletobundle_provenance,_simulationtosimulation_execution_input,_output_plantoshared_output_plan,_planned_simulationtoplanned_simulation,_reporttoreport_execution_input,_aggregate_payloadtoaggregate_payload,_contexttoinvocation_context,_parenttoparent_record,_childtochild_record,_automatic_parenttoautomatic_parent_record,_framestosimulation_frames,_connection_limit_errortoconnection_limit_error,_correlation_idtosummary_correlation_id,_failure_causetosummary_failure_cause,_stage12_loadtorun_until_dataset_loaded,_simulation_idtorole_simulation_id,_report_with_segmentationtoreport_with_segmentation,_coordinate_withtocoordinate_with,_assert_cancelledtoassert_cancelled,_assert_original_coordinator_failuretoassert_original_coordinator_failure,_coordination_logtocoordination_log_record,_assert_log_identifies_childtoassert_log_identifies_child. Fakes whose unused parameters were named_simulationor_reportkeep those parameter names.Seven other test modules imported these helpers from
test_stage12_runtime.py(test_stage12_cache_runtime.py,test_stage12_coordination.py,test_stage12_qualification.py,test_stage12_segment_calculation.py,test_stage12_segment_fanout.py,test_stage12_segmentation_foundation.py,test_stage12_simulation_worker.py). They now import them from the support modules under the new names, andtest_stage12_coordination.pyimportscoordinate_report_implfrompolicyengine_simulation_executor.stage12_runtimedirectly.Tests
test_installed_bundle_accepts_the_dataset_a_region_loadsafter the helper passed as their parameter, so[us-_bundle]and[state/ut-_bundle]are now[us-bundle_provenance]and[state/ut-bundle_provenance].Environment variables
None: only test files change.
Testing
ruff format --checkon the executor's tests.python scripts/run_quality_guards.pyandpython -m scripts.rules guard --base-ref origin/file-length-split-stage12-coordination: passed;python -m scripts.rules renderleaves no diff.includeissrc), and no source changes.Only the lowest PR in the stack runs full CI, so this PR's
CI completecheck fails by design until the PRs below it merge.🤖 Generated with Claude Code