Skip to content

Commit 45c5ed8

Browse files
anth-volkclaude
andcommitted
Split Stage 12 coordination and the execution contracts into smaller modules
stage12_runtime/coordination.py (1,091 lines) and the contract's stage12_execution.py (929 lines) were over the file-length limit. The code moves unchanged. coordination.py keeps coordinate_report and re-exports every public name. The coordinator class, ReportCoordination, its dataclasses and the polling constants move to report_coordination.py, the child simulations' records, failures and cancellation to coordinated_simulations.py, and the parent report's checks and claim to parent_claim.py. Child failures still log under the coordination module's logger, now named explicitly. Private names another module uses are public: _ReportCoordination, _cancel_pending_simulations, _cancellation, _child_failure_detail, _child_record and _simulation_failure_attributes (both with a new docstring), _record_child_failure, _validate_dispatch_context, _validate_submitted_parent and _claim_parent. stage12_execution becomes a package with the same import path, whose __init__.py re-exports every name: base.py holds the field types, the strict contract base and the simulation execution input; report_inputs.py the report input and output plans; result_artifacts.py the artifact descriptors and payloads; comparison_runs.py the invocation context and the comparison-run records. The models in the other modules subclass StrictContractModel and SimulationExecutionInput through the package path, which ruff.toml already lists as runtime-evaluated, so ruff keeps their annotation imports at runtime with no settings change; base.py sorts first, so the package binds those bases before the other modules import them. Every model's JSON schema is unchanged. The coordination tests' fixed clock patches datetime in each of the three modules that read it, and uuid4 and resolve_report_output_plan in report_coordination.py, where the coordinator looks them up. The file-length baseline drops both files (count 10 to 8). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1781f17 commit 45c5ed8

15 files changed

Lines changed: 2198 additions & 1940 deletions

File tree

‎changelog_entry.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- Ran Stage 12 US national simulations as 20 region-group calls each, and built an independent, immutable Stage 12 cache of three annual US datasets and 60 current-law baselines before each deployment, publishing it only after a recorded determinism check and recording its release in the v2 version manifest under a new key, while the existing key keeps a copy that earlier readers accept
1717
- Made the budget refuse a household count outside its country's plausible range (above 200 million in the US or 60 million in the UK, negative or not finite), raising ImplausibleEntityCountError instead of publishing a count like #767's
1818
changed:
19+
- Split Stage 12 report coordination (stage12_runtime/coordination.py, 1,091 lines) into modules for the report coordinator class, its child simulations' records, failures and cancellation, and the parent report's checks and claim, with coordinate_report and every public name still in coordination.py and child failures still logged under its logger; and turned the contract's stage12_execution.py (929 lines) into a stage12_execution package of modules for the shared field types and simulation input, report inputs and output plans, result artifacts, and comparison-run records, which re-exports every name from the same import path, with unchanged JSON schemas; models subclass the base models through the package path ruff.toml lists, so no ruff setting changes
1920
- Split the gateway's endpoints.py (1,454 lines) into modules for the shared router and request helpers, route resolution from the active routing state, Modal reads of job metadata and routing, bundle payloads, and the job submission, job status and version routes, which register their routes in the same order, so the OpenAPI document is unchanged; endpoints.py re-exports every public name, the routes keep logging under the policyengine_simulation_gateway.endpoints logger, and the private helpers the new modules share are now public; its 1,801-line test file is split into five test files, with the shared expected-response helpers in fixtures/gateway_responses.py
2021
- Split the routing publisher (src/modal/utils/update_version_registry.py, 1,584 lines) into a src/modal/routing_publisher package of modules for the bundle manifest, the routing state, routing plans and their publication record, the check that only serialized workflows write routing, Modal Dict access, plan publication, the legacy seed and the command-line options, and its 2,728-line test file into a tests/version_registry directory of nine test files with shared fixtures; update_version_registry.py keeps the command line, still runs with python -m src.modal.utils.update_version_registry and re-exports every public name; behaviour and output are unchanged, and the private helpers the new modules share are now public
2122
- Removed the UK constituency and local-authority weight-matrix region fallback (_build_uk_weight_replacement_region, _require_certified_uk_weight_matrix and its Stage 12 call); each deployment rebuilds only the app for the current policyengine.py version, now 6.10.0, which routes those regions to the local-area dataset, and apps deployed for older versions are not rebuilt and keep their own code; on a bundle that does not route them, an area region is now an unsupported region

‎docs/generated/rules.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Every rule that governs `policyengine-sim-api` is listed here with how it is enf
6666

6767
- `sim.ci.multiline-run-is-script`: 13 remaining in `rules/baselines/ci-multiline-run.txt`
6868
- `sim.microdata.weight-stripping-confined`: 0 remaining in `rules/baselines/sim-microdata-weight-stripping.txt`
69-
- `sim.quality.python-file-length`: 10 remaining in `rules/baselines/python-file-length.txt`
69+
- `sim.quality.python-file-length`: 8 remaining in `rules/baselines/python-file-length.txt`
7070

7171
### Exceptions and review dates
7272

0 commit comments

Comments
 (0)