Repository navigation
Give comparison-path US baselines their stored plan so they load the precomputed baselines - #1138
Merged
Merged
Conversation
The comparison-path coordinator (ReportCoordination), which serves shadow comparisons and the operator route, gives its baseline the report's plan, so a current-law US national baseline segment computes a cache identity the precompute never stores. These tests expect the stored plan instead whenever it holds every column the report reads from the baseline: the CTC report's group-0 segment gets the precomputed identity (it gets stage12-bl1-6bf58faeedaedc36, not stage12-bl1-928929ee9ffcc2a4), a labour-supply reform splits its baseline into segments with that identity, and a baseline stored under its own plan is aggregated with the same values as under the report's plan. A cliff report's baseline and every reform keep the report's plan. Two tests that build the coordinator's dependencies directly now pass a stored plan resolver, so planning a baseline loads no country model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…port's reads Since the precompute plans the US baselines as simulation runs store them (resolve_simulation_output_plan), only the report-run coordinator's baselines found them. ReportCoordination, which serves shadow comparisons and the operator route, gave each child the report's plan, so every US national baseline segment computed a cache identity the precompute never stores and calculated its baseline. ReportCoordination.child_output_plan now gives the baseline its stored plan whenever that plan holds every column the report reads from the baseline (side_read_plan, checked by the new stored_plan_holds), and keeps the report's plan otherwise, as for include_cliffs reports. The reform always keeps the report's plan. The shared aggregation already reads a side stored under its own plan, zero-filling the labour-supply responses it doesn't store. Both coordinators now resolve a stored plan through CoordinationCore.stored_output_plan. A US national baseline is split into region groups from its own plan, so a comparison report whose reform turns a labour-supply response on now splits its current-law baseline into 20 segments, which find the precomputed files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ort shapes Review found passages that still said both children get the same plan, that segmentation follows a shared plan, and that the precomputed files serve only report runs; they now describe each child's own plan. The changelog and the migration doc now say that any US national baseline whose own policy turns no response on is split when its reform turns one on, and that only the precomputed years and SPM selection load from the cache. The observability skill describes the stored-plan resolution inside stage12_child_input_planning. The aggregation test now covers a report turning no response on, where the baseline's file holds columns neither side reads, and its name says what it checks: the aggregation receives the same values in every column the report reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The observability skill said the nested planning operations appear where a child is given its stored plan; the comparison-path coordinator resolves the baseline's stored plan before checking it, so a baseline that keeps the report's plan records them too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since #1136, qualifying_cache_identity takes the run's RunScope (country, year, region and dataset selection) in place of the dataset-default flag and the scoping strategy. The test now builds it as the segment worker does. Against main's coordinator the identity test still fails with stage12-bl1-6bf58faeedaedc36 against stage12-bl1-928929ee9ffcc2a4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 #1137
Same-Repository Draft PR Check
PolicyEngine/policyengine-sim-api, not a personal fork.Changelog
changelog.d/<name>.<type>.md, whose type is breaking, added, changed, fixed or removed.Summary
Since #1072, the precompute plans the US national baselines with
resolve_simulation_output_plan, the plan every run of a simulation stores. The comparison-path coordinator (ReportCoordination) serves shadow comparisons with production jobs and the operator-onlyPOST /internal/stage12/reports. It still gave its baseline the report's own plan, so each baseline region-group segment computed a cache key the precompute never stores, and calculated the baseline (#1137).ReportCoordination.child_output_plangives the baseline its stored plan whenever that plan holds every column the report reads from the baseline (side_read_plan). Otherwise the baseline keeps the report's plan, as for a report withinclude_cliffs: true, whose cliff columns the stored plan lacks. The reform always keeps the report's plan.stored_plan_holds(output_planning.py) is the check: every entity the read plan names is in the stored plan, and its materialized columns are a subset of the stored entity's.CoordinationCore.stored_output_planresolves a simulation's stored plan (thestored_plan_resolverseam, orresolve_simulation_output_plan). Both coordinators now use it;ReportRunCoordination.child_output_planbehaves as before.self_employment_incomeandweekly_hours_worked.should_segment_simulationreads each child's own plan. A comparison report whose reform turns on a labour-supply response, and whose baseline's own policy turns none on, now splits its US national baseline into 20 region-group segments instead of calculating it in one container. For a current-law baseline in a precomputed year (2025–2027), those segments load the precomputed files.stage-12-modal-worker-foundation.md) and the observability skill now describe each child's own plan.Offline, from the installed bundle: a US national 2026 report raising the CTC base amount to $3,000 had a group-0 baseline segment identity of
stage12-bl1-6bf58faeedaedc36before this change. It now hasstage12-bl1-928929ee9ffcc2a4, the precomputed one. Measured value of a hit, from production telemetry: about 470 segment-seconds of compute and about 58 s of the baseline's elapsed time per current-law US national report.Known, not changed here
stage12_qualification.qualify_report_parity, the operator parity tool, still plans both sides with the report's plan. Its receipts therefore don't match the comparison path's baseline input digest. They already differed from the report-run path's since Let Stage 12 report runs share simulation runs, each storing its own simulation's output #1072.create_or_resolve_simulationwould then collide on the child's primary key. This affects only shadow or operator reports in progress during the deploy, as any change to plan selection would.Testing
Tests were run one at a time by node ID, not as a suite.
tests/test_stage12_comparison_baseline_cache.py, committed failing before the change:test_comparison_report_baseline_segment_uses_the_precomputed_identity: failed with…6bf58faeedaedc36against…928929ee9ffcc2a4; passes now.test_a_labour_supply_reform_splits_its_baseline_into_precomputed_segments: failed (should_segment_simulationfalse); passes now.test_a_baseline_stored_under_its_own_plan_gives_the_same_report_columns[reform_turns_responses_on]: failed (the baseline was given the report's plan); passes now.[no_responses]was added with the review fixes.test_a_cliff_report_keeps_the_report_plan_for_its_baselineandtest_the_reform_keeps_the_report_plan[…]pass both before and after the change; they check the cases that keep the report's plan.test_stage12_coordinator.py::test_coordinator_starts_both_children_before_waiting_and_aggregatesandtest_stage12_coordination.py::test_default_output_plan_resolver_measures_its_own_stagesnow pass a stored plan resolver, so planning a baseline loads no country model. Both pass.scripts/run_quality_guards.py;check-changelog-fragment.sh.32bf311bandd8b2e999.mainwas merged into this branch (no text conflicts). The identity tests now build the segment'sRunScope, whichqualifying_cache_identitytakes since Move the v2 report app's cache onto the prebuilt-file level handlers #1136, as the segment worker does. On the merged tree all 9 test cases above pass. Withmain'sreport_coordination.pyswapped back in, the identity test still fails with…6bf58faeedaedc36against…928929ee9ffcc2a4.🤖 Generated with Claude Code