Repository navigation
Serve dynamic parameters as their own v2 metadata category, US simulation.* included - #4349
Merged
Merged
Conversation
Tests for the routes that serve dynamic parameters and their current-law
values apart from policy parameters: /v2/dynamic-parameters (with
/{parameter_id} and /children?settable=true), /v2/dynamic-parameter-values
(with /{value_id}) and /v2/model-catalog/dynamic-parameters. They cover the
settable rule (economy or household flag, no gov. requirement), the tree
built on each request with the version's enum labels, 404s for IDs outside
the category, pruned versions, request logs, route groups and OpenAPI.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
API v1's metadata routes list, read and browse dynamic parameters and their
current-law values apart from policy parameters, reading only
dynamic_parameters and dynamic_parameter_values (C1 · 50):
- GET /v2/dynamic-parameters and /{parameter_id}, mirroring /v2/parameters;
- GET /v2/dynamic-parameters/children, built on each request with
parameter_tree.py's builder, the stored node labels and the version's
enum labels; settable=true keeps what a dynamic may set;
- GET /v2/dynamic-parameter-values and /{value_id}, current law only;
- GET /v2/model-catalog/dynamic-parameters, the version's whole category
with values and ancestor node labels, for v3.
A dynamic may set a dynamic parameter whose economy or household flag is
true (is_dynamic_settable, beside is_reform_changeable), so US simulation.*
qualifies. Pruned versions answer as the policy routes do. The routes join
the metadata route group and its request logs, the contract registry and
the generated contract documents, and stage-9-v2-metadata.md describes them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Sort four test modules' imports as ruff does on a fresh cache: the failing-tests commit's cache had classed the then-missing dynamic_parameters package as third-party, so CI's ruff --fix would have changed them. - Test the children route answering from a selection kept from before a pruning, a pruned version's value detail, and another version's IDs of the same country, and detach the kept selection's rows in the kept-selection test, as a closed request session leaves them. - List the dynamic routes in the Stage 9 runbook's rollback section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The /v2/model-catalog routes, /v2/model-catalog/dynamic-parameters included, log Supabase as their read source, as the other v2 metadata reads do. They log Cloud SQL today, because model-catalog isn't a v2 metadata segment. - Dynamic values are paged, and a value's detail answers a pruned version from a selection kept from before the pruning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- model-catalog joins the v2 metadata segments, so the /v2/model-catalog routes, /v2/model-catalog/dynamic-parameters included, log Supabase as their read source, with a changelog fragment for the fix. - The Stage 9 runbook gives the measured size of the children route's enum read: about 458 KB of JSON for the US and 41 KB for the UK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The cross-database integration workflow runs the dynamic parameter routes' Postgres tests, which also read as the runtime role. It doesn't yet, so CI never runs them. - Every dynamic read of a version without dynamic parameters answers with empty results. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The cross-database integration workflow runs the dynamic parameter routes' Postgres tests in its metadata step, and the module joins the scope of api.v2.runtime-privileges-tested-as-runtime-role, which now names the dynamic parameter reads (rules documentation regenerated). The step adds no environment variable: it uses the job's env block. - The routes' docstrings and the Stage 9 runbook say which tables each dynamic read uses, and the runbook's pruning list names the children route's exception for a selection kept from before a pruning. - The model-catalog changelog fragment says what the logs recorded before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ic parameter routes branch
… parameter routes branch
The six dynamic parameter routes join metadata_resources_v2_preview, so the migration contract payload holds 119 requests, not 113. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4349 +/- ##
==========================================
- Coverage 93.88% 93.88% -0.01%
==========================================
Files 428 432 +4
Lines 24023 24195 +172
Branches 3719 3752 +33
==========================================
+ Hits 22555 22715 +160
- Misses 847 852 +5
- Partials 621 628 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Base automatically changed from
v2plan/c1-50-dynamic-parameter-tables
to
master
November 26, 2026 20:45
…eter routes branch
anth-volk
added a commit
that referenced
this pull request
Nov 27, 2026
…ues dynamic_id drop branch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was previously deployed
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 #4348
Summary
API v1's v2 metadata routes serve dynamic parameters (the model assumptions under
gov.simulation., USsimulation.and UKgov.dynamic.) and their current-law values apart from policy parameters, USsimulation.*included. Tracker task C1 · 51 of the detailed-save API plan.New routes, all read-only
GETs with the metadata routes' caching headers (ETag,Cache-Control,Vary, 304):/v2/dynamic-parametersParameterCollectionQuery: page,search, repeatedname/v2/parameters/v2/dynamic-parameters/{parameter_id}CatalogQuery/v2/parameters/{parameter_id}/v2/dynamic-parameters/childrenDynamicParameterChildrenQuery: page,parent_path,settable/v2/parameters/children/v2/dynamic-parameter-valuesParameterValueCollectionQuery: page,parameter_id, repeatedparameter_name,current/v2/parameter-values/v2/dynamic-parameter-values/{value_id}CatalogQuery/v2/parameter-values/{value_id}/v2/model-catalog/dynamic-parametersCatalogQuery, no names/v2/model-catalog/parametersdynamic_parametersand the current-law rows ofdynamic_parameter_values. So a policy parameter's or policy value's ID, a value a dynamic sets, and another version's ID all answer 404.parameter_nodes, and the children route reads the version'svariables.enum_values.Session.MetadataParameterSummaryandMetadataCanonicalParameterValue. A value'sparameter_idis the dynamic parameter's catalog ID, whichPOST /v2/dynamicstakes./v2/model-catalog/dynamic-parametersreturns the version's whole category in one response for v3 (D1 · 4):node_labels, the stored label of each ancestor node./v2/dynamic-parameters/childrenbuilds the tree on each request:parameter_tree.build_parameter_tree, so the policy tree's label and order rules aren't copied; there is no stored tree table and no search file;gov, plussimulationfor the US.is_dynamic_settable, besideis_reform_changeable:economyorhouseholdflag is true, with nogov.requirement;metadataroute group and the v2 metadata read segments.model-catalogjoins those segments too, so every/v2/model-catalog*route now logs Supabase as its read source. Before, they logged whateverDB_READ_METADATAandDB_WRITE_METADATAselect. This has its ownfixedchangelog fragment.metadata_resources_v2_previewintests/contract/registry.py, with the regenerateddocs/generated/migration_contracts.jsonanddocs/engineering/migration-contracts.md;docs/migration/stage-9-v2-metadata.md("Dynamic parameter routes", "Catalog pruning", rollback) list them.v2-integration-check.ymlruns the new Postgres module in its metadata step, and the module joins the scope ofapi.v2.runtime-privileges-tested-as-runtime-role. The step adds no environment variable: it uses the job'senv:block, whose literal values point at the job's own service containers, andpr.ymlpasses no secrets.Decisions this follows
The user's decisions in C1 · 46, plus three follow-ups made while building:
require_unprunedas their policy counterparts do, so a pruned version answers 404 withCache-Control: no-store, or 503 for the running version. The children route checks when it selects the version. Its tree's rows are never pruned, so a process holding a selection from before the pruning still answers 200, as documented.categoryquery parameter. The policy routes are unchanged.POST /v2/dynamicsstill accepts any dynamic parameter.settable=true;/v2/model-catalog/dynamic-parametersis read on each request, with no in-process body cache;Stack and deploy order
v2plan/c1-50-dynamic-parameter-tables), which is stacked on Make UK gov.dynamic a model assumption, and add a command that splits stored policies holding model assumptions #4345 (C1 · 48). Retarget as those merge; merge after Keep dynamic parameters and their values in their own tables #4347.7f7335f0eb31creates. The seed job applies that revision before the release that serves these routes starts, so this merges after Keep dynamic parameters and their values in their own tables #4347. No revision, workflow secret or deployment change is added here.Files #4347 also changes
docs/migration/stage-9-v2-metadata.md;policyengine_api/data/v2/catalog/publication_parameter_tree.py, whoseenum_value_labelsnow calls the sharedparameter_tree.enum_labels_by_value.Testing
9fcde69f5), then the implementation (683ad7666). Then three adversarial review rounds, each fixed test-first:/v2/model-catalog*request logs.policyengine_v2_runtime.ruff check --no-cache,ruff format --check, mypy (including the changeddata/v2/catalogmodules),lint-imports,python -m scripts.rules validate,python scripts/run_quality_guards.py, theapi.data.orm-onlyscan and the changelog fragment check all pass.🤖 Generated with Claude Code