Repository navigation
Move Stage 12's v2 default version only after a deployment's checks - #1028
Merged
Merged
Conversation
The Simulation Entrypoint resolves every Stage 12 report through the v2 manifest's default version, which the Stage 12 manifest job moved when it published the worker, before the checks, and nothing put back. The job now adds the worker with --keep-default. A new job after every check and the Cloud Run promotion moves the default when the release is newer (--move-default, keeping a plan), checks that a reader resolves it (--verify-plan), and writes back the manifest it replaced if a later step fails or the run is cancelled (--restore-plan, only while the stored manifest is what it wrote). deployment_ready requires it when Stage 12 was requested. This is Stage 12's own mechanism: no code is shared with the v1 routing jobs. Registers rule sim.deploy.stage12-default-moves-after-checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… move that changes nothing The v2 manifest is three keys written one after another. A move or a restore that stopped part-way left readers on an older key's copy without region datasets, which the restore, comparing one digest, refused to recognise; a rerun would then copy that reduced manifest to every key. The move now refuses to start unless all three keys hold the same manifest, the check reads all three, and the restore writes the starting manifest back whenever each key holds the starting or the moved copy. A move that leaves the default where it is now writes nothing, so the manifest's digest, which Stage 12 report identities include, stays the same. --force-default is refused outside a worker publication. Tests pin each default step's Modal access, show the plan is kept before the manifest is written, and isolate the Stage 12 input. The changelog fragment and README say which cases still reach a worker early and how an operator restores from the kept plan. (Review round 1.) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…expired older manifest key The step that uploads the v2 default plan now runs whenever the move step ran, so a move that stopped part-way still leaves its plan for an operator if the restore step fails too. A move that failed before planning wrote nothing and kept no plan, so a missing file is not an error. The restore step's message now says only that this attempt wrote nothing, and where an earlier attempt's plan is. Modal expires a Dict entry after 7 days without a read or write, and current readers read the oldest manifest key only when neither newer key exists. The move, check and restore now accept a missing older key, since a write never deletes one, and the move and restore write it again. The newest key stays required. The plan's advances_default is now release_is_default, since it is also true when the default already was the release, and the unused job output is gone. New tests pin a restore that refuses another manifest under any one key, and a check or restore that refuses a plan whose manifests no longer match its digests. The rule now lists the publisher and script tests too. The README says to restore from the kept plan before rerunning or redeploying after a failed restore, and that this job does not wait for the v1 publish_latest job. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fest, and test the move's write checks The publisher now refuses --force-default with --keep-default along with its other argument checks, before it opens the Modal Dict, and reads the validation file once for every worker publication. New tests cover a move whose write reads back differently, a manifest that changes between planning the move and writing it, and --force-default publishing an older worker as the default; each fails if its check is removed. The rule now covers the contract module's add, move and write functions and their tests. The README says that a deployment that keeps the policyengine.py version redeploys the current worker's app before the checks, that a missing older key is written again by the next write, and that if all three keys expire, the next worker publication treats the manifest as empty and makes its worker the default before the checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/generated/rules.md and AGENTS.md are re-rendered from the merged rule registry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ach Stage 12 default move on the run's summary The publisher now opens the Modal Dict with create_if_missing only for a worker publication, so a move, check or restore against a Modal environment without a manifest fails instead of creating an empty Dict there (for example, an operator restore that names the wrong environment). The move script adds the manifest's digests before and after the move, and whether requests that pin no v2 version now reach the release's worker, to the run's step summary instead of step outputs that nothing read. The workflow test now pins the plan upload's path to the file the scripts use, and that no step of the default job, or the job, continues on error; each assertion fails if the workflow is changed that way. The rule lists the remaining publisher and script tests. The README says how release environments map to Modal environments, that a release with a newer worker changes the manifest digest twice, and what happens if the runner is lost after the move starts writing and before the plan is uploaded. 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 #1027
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
A deployment that publishes Stage 12 now moves the Stage 12 v2 manifest's default version to the new release's worker only after every check and the Cloud Run promotion pass. This is Stage 12's own mechanism, with no code shared with the v1 routing jobs.
publish_stage12_v2_manifestadds the release's worker withupdate_v2_version_manifest --keep-defaultand leavesdefault_versionunchanged. The first worker in an empty manifest still becomes the default. No check that runs after this publication is upstream of the job, so "Re-run failed jobs" never republishes the worker.publish_stage12_v2_default, needs the worker publication, the integration tests, the authenticated tests and the promotion. It:--move-default), keeping a plan of the manifest before and after the move, with their digests;stage12-v2-default-plan-<environment>-<attempt>whenever the move step ran;--verify-plan);--restore-plan).deployment_readyrequires that job to succeed whenever Stage 12 was requested, and to be skipped otherwise.sim.deploy.stage12-default-moves-after-checkslists the contract, publisher, script and workflow tests. The executor README has a new section, "Stage 12 v2 default version", that covers the operator restore from the kept plan and the limitations listed below.Limitations:
force_latestinput does not move the v2 default.publish_latestjob.deployment_readystill fails a deployment whose v1latestmove failed.Environment variables for the new job's steps:
MODAL_TOKEN_ID,MODAL_TOKEN_SECRETsecrets: inheritbysimulation-deploy.ymlandstage12-deploy.ymlMODAL_ENVIRONMENTmodal_environmentinputPOLICYENGINE_VERSIONpreparejob'spolicyengine_versionoutputREQUESTED,DEFAULT_RESULT(indeployment_ready)deploy_stage12_v2input and the new job's resultRUNNER_TEMP,GITHUB_OUTPUTTesting
Each new or changed test was written first and seen failing, then run individually by node ID:
libs/policyengine-simulation-contract/tests/test_stage12_manifest_default.py: adding a worker, moving the default, writing the manifest copies.projects/policyengine-simulation-executor/tests/test_update_v2_version_manifest_default.py: the publisher modes; part-way writes; expired older keys; a manifest another publish changed; altered plans; a write that reads back differently; a manifest that changes between planning and writing;--force-default; command-line refusals.projects/policyengine-simulation-entry/tests/test_deployment_assets_stage12_default.py: job ordering; the job'sif:across 11 result combinations; step order, conditions and environment; no shared code with v1 routing.projects/policyengine-simulation-entry/tests/test_stage12_default_scripts.py: each script with a fakeuv.projects/policyengine-simulation-entry/tests/test_deployment_assets.py::test_deployment_uses_gcloud_workflow_without_terraform, for the updated count of jobs that declare the release environment.Mutation checks. Each of these changes makes a test fail:
alltoanyin the restore's key comparison;force_defaultthrough;continue-on-erroron the default job or any of its steps.After main was merged in (bringing #898), every test this PR adds or changes was run again by node ID, and all pass.
Also run: ruff 0.15.22 format and check, shellcheck on the four scripts,
python3 -m scripts.rules validate,renderandguard, and Pyright on the executor package. The workflow has not run in a deployment yet.🤖 Generated with Claude Code