Repository navigation
Remove the Simulation Entrypoint's unused create functions without keys, run-reuse search and output-bucket setting - #1082
Merged
anth-volk merged 2 commits intoNov 17, 2026
Conversation
…e entrypoint's output-bucket setting After #1074 the Simulation Entrypoint finds or creates every simulation, report and run by its definition key, so nothing it runs calls the code that created those rows without keys or searched for an earlier succeeded simulation run to reuse. Remove that code, with no change in behaviour: - the persistence library's insert_economy_report, insert_economy_simulation, insert_household_report and insert_budget_window_report, their input types, and the store methods that wrapped them (EconomyRunStore.create_report, create_simulation and create_budget_window_report, HouseholdReportStore.create_report); - find_reusable_run, find_reusable_run_of, ReusableRun, RunReuse and the searches built on them, the store's `reuse` parameters (and the window reads' `years`, which only fed the searches), and the reusable_run and reusable_runs fields; - RerunSide.reused and the checks that refused it; - ServiceSettings.output_bucket, Settings.v2_simulation_output_bucket, and the entrypoint deploy's V2_SIMULATION_OUTPUT_BUCKET format check, runtime variable and workflow input. The Stage 12 steps, scripts and Modal workers keep the bucket. Tests that store a record created before keys now insert its rows directly (economy_rows.insert_pending_report, household_report_rows and a window helper in the window re-run tests). The economy store's commit-failure tests use a forced report re-run, whose create only inserts rows. Fixes #1081 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…orrect the Stage 12 creation passages Review round 1: the tests deleted with the create functions without keys were the only database tests that a refused region, dataset, dynamic, policy or household reference names its column, which the Simulation Entrypoint turns into its unknown_* refusals. The same checks now call find_or_create_economy_report, find_or_create_household_report and find_or_create_budget_window, and pass, as the behaviour is unchanged. The Stage 12 migration doc's standalone-simulation and budget-window passages now say the service finds or creates the rows by key and starts a call only for a run it created. Refs #1081 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
merged commit Nov 17, 2026
81ee633
into
v2plan/c1-27-find-or-create-by-key
2 checks passed
Contributor
Author
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 #1081
Stacked on #1074 (base
v2plan/c1-27-find-or-create-by-key), and merges after it. #1074 makes the Simulation Entrypoint find or create every simulation, report and run by its definition key. After that, nothing the service runs calls the code that created those rows without keys, or the search for an earlier succeeded simulation run to reuse. This PR removes that code. Requests, answers and the rows the service writes don't change.What is removed
Persistence library (
libs/policyengine-simulation-persistence)insert_economy_report,insert_economy_simulation,insert_household_reportandinsert_budget_window_report, withinsert_simulation_with_run, which only they called.NewEconomyReport,NewEconomySimulation,ReportSimulation,NewHouseholdReport,HouseholdReportSimulation,NewBudgetWindowReportandBudgetWindowYear. Nothing else used them.EconomyRunStore.create_report,create_simulationandcreate_budget_window_report, andHouseholdReportStore.create_report.find_reusable_run,find_reusable_run_of,ReusableRun,RunReuse,search_by_definition,search_own_runsandREFUSED_REUSE_PREFIX.reuseparameter ofEconomyRunStore.read_report_inputs,read_report_rerun_inputs,read_window_rerun_inputsandread_budget_window_inputs. The service always passedNone. The window reads'yearsparameter goes too, because it only fed the search.SimulationInputs.reusable_runandBudgetWindowInputs.reusable_runsfields.RerunSide.reused, and the__post_init__checks inNewReportRerunandNewWindowRerunthat refused a side with it set. Thereusedmember of theWindowSideprotocol goes too:year_creatednow takes aFoundWindowYear, the only type it is called with, whose sides still say whether this request inserted the run.Simulation Entrypoint (
projects/policyengine-simulation-entry)reuseandyearsarguments in the store protocols and their call sites.ServiceSettings.output_bucketandSettings.v2_simulation_output_bucket, which readV2_SIMULATION_OUTPUT_BUCKET. Nothing used them.Deployment
.github/scripts/deploy-cloud-run-simulation-entry.shno longer requiresV2_SIMULATION_OUTPUT_BUCKET_VALUE, no longer checks its format, and no longer writesV2_SIMULATION_OUTPUT_BUCKETinto the Cloud Run runtime variables..github/workflows/simulation-deploy.reusable.ymlno longer passes it.What stays
The Modal coordinator and workers still write simulation output files to the bucket, so these keep it:
.github/scripts/stage12-validate-infrastructure.shand.github/scripts/stage12-sync-modal-secrets.sh;stage12-evaluation-runtimeModal secret and the executor'sstage12_runtime/dependencies.py.Environment variables
V2_SIMULATION_OUTPUT_BUCKETvars.V2_SIMULATION_OUTPUT_BUCKET, set inbeta(policyengine-v2-staging-simulation-outputs) andprod(policyengine-v2-production-simulation-outputs). No repository-level variable of that name exists.deploy_entrypointruns inenvironment: ${{ inputs.release_environment }}(beta, thenprod, fromsimulation-deploy.yml). Its step "Deploy Cloud Run entrypoint candidate" passed the variable asV2_SIMULATION_OUTPUT_BUCKET_VALUEtodeploy-cloud-run-simulation-entry.sh. The script required it, checked its format, and wroteV2_SIMULATION_OUTPUT_BUCKETinto the--env-vars-fileofgcloud run deploy.Settings.from_envread it, and nothing used the value.--env-vars-filereplaces all of a new revision's variables, so revisions deployed from this commit on have noV2_SIMULATION_OUTPUT_BUCKET. Revisions deployed earlier keep theirs. The service no longer reads it.V2_SIMULATION_OUTPUT_BUCKET(Stage 12)deploy_stage12_v2, in the same environment, passes it tostage12-validate-infrastructure.shand tostage12-sync-modal-secrets.sh. The sync script writes it into thestage12-evaluation-runtimeModal secret.src/modal/v2_app.pyattaches that secret, andstage12_runtime/dependencies.pyreadsV2_SIMULATION_OUTPUT_BUCKETfrom it.The change adds no variable and removes no provider. Not verified: the runtime variables of the Cloud Run revisions now serving. I didn't read them; they don't affect this change, because
--env-vars-filesets each new revision's variables in full.Tests
Tests that stored a record created before keys now insert its rows directly, with the same values the removed functions inserted:
tests/economy_rows.pygainsinsert_pending_report.tests/household_report_rows.pyinserts household reports.test_economy_window_reruns.pyhas its own window helper.Deleted tests:
tests/test_economy_run_reuse.pyand the reuse cases intest_economy_reruns.py,test_economy_run_store.pyandtest_budget_window_records.py.test_economy_run_records.py,test_household_report_store.pyandtest_budget_window_records.py.check_window_yearsremains covered by the window re-run tests.test_economy_deployment.pyand the setting's case intest_config.py.Some of the deleted tests checked behaviour that remains, so the keyed creators now test it:
unknown_*refusals.test_keyed_economy_records.py,test_keyed_household_records.pyandtest_keyed_window_records.pynow check this againstfind_or_create_economy_report,find_or_create_household_reportandfind_or_create_budget_window.These tests pass, because the behaviour hasn't changed. The economy store's commit-failure tests now use a forced report re-run, whose create only inserts rows.
The Stage 12 migration doc's report-run, standalone-simulation and budget-window passages now say that the service finds or creates these rows by key, and starts a call only for a run it created.
Checks run locally:
uv lock --check, and Pyright for both packages all pass.e96e52ffb(Share detailed-save reports and runs by key, and record each user's report runs policyengine-api#4303's merge), and 56 entry tests.The "Public API schema" check's last step requires the pinned commit on the Public API's
master. It fails on #1074's branch until #1074 moves the pin, and so it fails here too. #1074 fixes it.🤖 Generated with Claude Code