Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
14a6624
Derive every v2 country list from one list in code
anth-volk Oct 21, 2026
2729c37
Record each served country in a countries table that country columns …
anth-volk Oct 21, 2026
0d30696
Serve the countries table at GET /v2/countries
anth-volk Oct 22, 2026
f9a19c1
Refuse to start when the countries table and the country list differ
anth-volk Oct 22, 2026
6b8cbd2
Stop startup only when the countries table answers with a disagreement
anth-volk Oct 22, 2026
975c80f
Keep the startup check's log tests independent of earlier Alembic tests
anth-volk Oct 22, 2026
e86d9ce
Let a saved policy be repointed to a v2 policy
anth-volk Oct 21, 2026
8be3803
Let a saved household be repointed to a v2 household
anth-volk Oct 21, 2026
15f15aa
Pin the status codes of a refused household repoint
anth-volk Oct 21, 2026
3d0b105
Count saved policies by table name in the migration qualification com…
anth-volk Oct 22, 2026
320c5d2
Rename the v2 table user_policies to user_policy_associations
anth-volk Oct 22, 2026
54bef66
Tighten the saved-policy rename tests
anth-volk Oct 22, 2026
c747f00
Describe the saved-policy rename in the Stage 12A document
anth-volk Oct 22, 2026
d31f13d
Let the privilege reconciliation find, grant and verify views
anth-volk Oct 22, 2026
035af26
Keep a temporary user_policies view for the release before the rename
anth-volk Oct 26, 2026
eb4c29c
Run the saved-policy view tests in the cross-database integration wor…
anth-volk Oct 26, 2026
c0794eb
Require each declared relation to exist with its declared kind
anth-volk Oct 26, 2026
fa682e2
Add checked-in region reference files for the US and the UK
anth-volk Oct 22, 2026
f50890f
Publish catalog regions from the reference files and the certified da…
anth-volk Oct 22, 2026
6cf90bc
Refuse to publish regions whose filter column or weight-matrix row is…
anth-volk Oct 22, 2026
47902c1
Keep a stored catalog version's regions when the reference files change
anth-volk Oct 22, 2026
5670b18
Pin the UK catalog fixture's placeholder repository in the artifact test
anth-volk Oct 22, 2026
15d84e2
Depend directly on h5py and huggingface-hub
anth-volk Oct 22, 2026
4abc8a0
Print the kept-regions warning's country, version and counts
anth-volk Oct 22, 2026
103cf3b
Name the table that differs when a stored catalog version does not match
anth-volk Oct 22, 2026
089713d
Report a certified artifact's structure error with its own message
anth-volk Oct 22, 2026
c27bd92
Check the v2 revision before reading which catalog versions are stored
anth-volk Oct 22, 2026
052ef12
State exactly what the lookup copies and the read token cover
anth-volk Oct 22, 2026
a9160d9
Name the weight matrix's dimension count instead of suppressing the lint
anth-volk Oct 22, 2026
d96b115
Report the stored regions in the evidence when a version keeps them
anth-volk Oct 22, 2026
2a01b4c
Name the missing ancestor when a region's parent chain breaks higher up
anth-volk Oct 22, 2026
765c69b
Require the Hugging Face token before checking the UK's private data
anth-volk Oct 22, 2026
1a5beff
Test the remaining failure paths of region references, scoping and re…
anth-volk Oct 22, 2026
dc26367
Describe the lookup check without dating private storage
anth-volk Oct 22, 2026
d466c99
Describe exactly what the artifact reads download
anth-volk Oct 22, 2026
b120d44
Ignore the coverage.py data and report files
anth-volk Oct 22, 2026
00c558c
Rename the read-token variable constant so it needs no lint suppression
anth-volk Oct 22, 2026
637b628
Give region data and token failures error classes that match when the…
anth-volk Oct 22, 2026
50c7dfc
Type the release manifest scoping reads with a small Protocol
anth-volk Oct 22, 2026
59f9ccc
Row-filter UK constituencies and local authorities on the dataset the…
anth-volk Oct 26, 2026
cbb1656
Cover UK local authorities and the UK's lack of fallback at unit level
anth-volk Oct 26, 2026
d2f6c4c
Rewrap the Stage 9 region paragraphs like the surrounding text
anth-volk Oct 26, 2026
d662679
Add nullable catalog format 2 columns for v3's metadata
anth-volk Oct 22, 2026
14673dc
Extract v3's metadata from PolicyEngine.py's public records as catalo…
anth-volk Oct 22, 2026
07b7b0c
Store catalog format 2 fields when a catalog version is published
anth-volk Oct 22, 2026
b8a75d1
Name the missing catalog format 2 fields when PolicyEngine.py lacks them
anth-volk Oct 22, 2026
a94b2e2
Compare enum label types in the metadata parity test
anth-volk Oct 22, 2026
cca58e3
Test that enum labels and parameter paths round-trip through publication
anth-volk Oct 22, 2026
e46611f
Type the catalog's entity and enum-value columns
anth-volk Oct 22, 2026
494f434
Take each country's default dataset from the PolicyEngine.py release
anth-volk Oct 26, 2026
1f69e91
Say that the locked PolicyEngine.py 6.10.0 also lacks catalog format …
anth-volk Oct 26, 2026
5c565e6
Add each variable's unit and definition period to the catalog format …
anth-volk Oct 26, 2026
3768464
Extract each variable's unit and definition period from PolicyEngine.…
anth-volk Oct 26, 2026
7c0eac4
Store each variable's unit and definition period when a catalog versi…
anth-volk Oct 26, 2026
7e0fb95
Name the unit and definition period in the format 2 test and fixture …
anth-volk Oct 26, 2026
f803106
Check format 2's variable text fields against their column lengths
anth-volk Oct 26, 2026
816e005
Serve v2 metadata responses with an ETag and a cache lifetime
anth-volk Oct 22, 2026
7af6582
Serve the small parts of a catalog version at /v2/model-catalog
anth-volk Oct 22, 2026
290b042
Serve every variable of a catalog version with its part parameters' v…
anth-volk Oct 22, 2026
adff8a2
Fetch several parameters by name with their values and breadcrumb labels
anth-volk Oct 22, 2026
830ee5b
Filter parameter pages and values by exact parameter names
anth-volk Oct 22, 2026
17300e7
Keep whole catalog-version responses once built in each process
anth-volk Oct 22, 2026
08d990d
Check the on-demand catalog routes on each release and record their t…
anth-volk Oct 22, 2026
4c64114
Reuse current parameter values only until the next UTC midnight
anth-volk Oct 22, 2026
0738380
Read v2 metadata in autocommit sessions on the shared pool
anth-volk Oct 26, 2026
bb2071a
Keep each selected catalog version for the life of the process
anth-volk Oct 26, 2026
15355a4
Keep each whole-version response's ETag, under the version it was rea…
anth-volk Oct 26, 2026
038d593
Read every v2 metadata query through the shared query models
anth-volk Oct 26, 2026
ea169b0
Type the new metadata reads and remove their duplicated lookups
anth-volk Oct 26, 2026
6e7e52e
Let browser scripts read metadata responses' ETag
anth-volk Oct 26, 2026
09bbd99
Record the slow existing routes' times on each release, even after a …
anth-volk Oct 26, 2026
b979826
Read current parameter values and set their lifetime from one instant
anth-volk Oct 26, 2026
b9d734e
Vary every cacheable metadata response by Origin
anth-volk Oct 26, 2026
b921ec2
Document metadata caching headers, 304 and the 400 case in OpenAPI
anth-volk Oct 26, 2026
b0e98b6
Keep a response's build lock until it is stored, and state the cache'…
anth-volk Oct 26, 2026
77a12b5
Refuse writes through v2 read sessions and state who uses them
anth-volk Oct 26, 2026
87c17b1
Describe the metadata stores in the layout guide and drop FoundParame…
anth-volk Oct 26, 2026
4bbe04f
Give parameter-tree leaves the economy and household flags
anth-volk Oct 26, 2026
db0b4ae
Give every request waiting on a whole-version read that read's outcome
anth-volk Oct 26, 2026
ba1b435
Give cacheable 200 and 304 responses the same Vary, each value once
anth-volk Oct 26, 2026
ec9a9c7
Declare 400 only on the metadata route with the country in its path
anth-volk Oct 26, 2026
069d739
Test autocommit reads on one pooled connection and the production reader
anth-volk Oct 26, 2026
67785b5
Bring the 1.16 changelog fragment in line with the caching behavior
anth-volk Oct 26, 2026
1e93eaa
Import the connector modules in a test instead of suppressing line le…
anth-volk Oct 26, 2026
02e120a
Serve each variable's unit and definition period
anth-volk Oct 26, 2026
32eb336
Require the catalog format 2 fields in the metadata response schemas
anth-volk Oct 26, 2026
504f57e
Look up test model versions through one helper taking the model name
anth-volk Oct 26, 2026
fc8f61f
Test that both variables routes serve unit and definition period
anth-volk Oct 26, 2026
3885872
Say the same in the Stage 9 guide about who reads unit and definition…
anth-volk Oct 26, 2026
dc08d15
Merge remote-tracking branch 'origin/v2plan/1g-126-countries-table' i…
anth-volk Oct 27, 2026
f7d89e0
Merge remote-tracking branch 'origin/v2plan/1j-141-own-environment-ch…
anth-volk Oct 27, 2026
8417d1c
Record each catalog version's SPM availability from the simulation se…
anth-volk Oct 27, 2026
fcad8fd
Serve each catalog version's SPM availability at /v2/model-catalog
anth-volk Oct 27, 2026
54071cd
Convert stored households and policies to what the simulation service…
anth-volk Oct 27, 2026
d12b804
Calculate stored households through /v2/household-calculations
anth-volk Oct 27, 2026
f6d1d4e
Check household calculations and their parity with /calculate in staging
anth-volk Oct 27, 2026
c66b1d0
Read simulation service answers through the generated models
anth-volk Oct 27, 2026
0f9bf9f
Refuse axes the simulation service would refuse, before sending them
anth-volk Oct 27, 2026
0c9b65c
Calculate each household for its default year, and take no force
anth-volk Oct 27, 2026
aaf0df3
Open the catalog reader only to submit, and reuse the household colle…
anth-volk Oct 27, 2026
d910153
Leave SPM availability unrecorded until the service serves the version
anth-volk Oct 27, 2026
f6f5f0c
Compare reforms and added variables with API v1 in the staging parity…
anth-volk Oct 27, 2026
0a3851f
Keep the household's key order to and from the simulation service
anth-volk Oct 27, 2026
d82e798
Build the simulation service client only once a request reaches it
anth-volk Oct 27, 2026
7ed16f2
Vary the household's default year when an axis names no period
anth-volk Oct 27, 2026
538499d
Register the household calculation routes with the household route group
anth-volk Oct 27, 2026
bdbab60
Check the simulation service URL first, and never fail on its versions
anth-volk Oct 27, 2026
b54f7ef
Send a live check's calculation again after a 5xx answer
anth-volk Oct 27, 2026
4108a80
Log household calculations with the sources and compute they use
anth-volk Oct 27, 2026
e3b5f8d
Drop the unused generated client wrapper and correct two descriptions
anth-volk Oct 27, 2026
243c2d9
Retry only short outages in the live checks, and compare warnings in …
anth-volk Oct 27, 2026
ba761d4
Log household calculations without checking flags they do not use
anth-volk Oct 27, 2026
d695268
Type the simulation answer reader without a suppression
anth-volk Oct 27, 2026
220cf1e
Send the simulation service household and policy IDs, not their values
anth-volk Oct 28, 2026
78219f3
Send axes as given, now that the household function fills a missing p…
anth-volk Oct 28, 2026
2542739
Pass the simulation service's 422 refusals through with their reasons
anth-volk Oct 28, 2026
21ad205
Name the parity household's person `you`, so both sides add one year'…
anth-volk Oct 28, 2026
5184700
Check that axis periods are forwarded unchanged, and name the year check
anth-volk Oct 28, 2026
109d626
Answer 503 for a simulation refusal of another shape
anth-volk Oct 28, 2026
4c515e2
Describe the remaining 503s, the per-field 422, and test the sent def…
anth-volk Oct 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/scripts/check_simulation_entrypoint_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env bash

# Check that a deployment environment calls its own Simulation Entrypoint:
# staging must call the staging service and production the production
# service. The entrypoint names the Cloud Run revision that served a request
# in its x-policyengine-simulation-revision response header, and a Cloud Run
# revision name is its service name followed by a five-digit number and a
# three-character suffix.
#
# The old gateway (SIM_ENTRYPOINT=old_gateway_direct) is one shared Modal app
# that reports no environment, so it is not checked.
#
# Required env vars: DEPLOYMENT_ENVIRONMENT (staging or production),
# SIM_ENTRYPOINT, and the URL variable that SIM_ENTRYPOINT selects.
# Exit codes: 0 when the environments match, 1 when they do not or the
# response names no revision, 2 for an unknown DEPLOYMENT_ENVIRONMENT, and
# curl's own exit code when the request fails.

set -euo pipefail

source .github/scripts/simulation_entrypoint_env.sh

deployment_environment="${DEPLOYMENT_ENVIRONMENT:-}"
case "${deployment_environment}" in
staging)
expected_service="policyengine-simulation-entry-staging"
;;
production)
expected_service="policyengine-simulation-entry"
;;
*)
printf 'DEPLOYMENT_ENVIRONMENT must be staging or production, not %q\n' \
"${deployment_environment}" >&2
exit 2
;;
esac

if [[ "${SIM_ENTRYPOINT:-}" == "old_gateway_direct" ]]; then
printf 'SIM_ENTRYPOINT=old_gateway_direct: the shared old gateway reports no environment, so there is nothing to check\n'
exit 0
fi

simulation_url="$(simulation_entrypoint_selected_url "${SIM_ENTRYPOINT:-}")"
simulation_url="${simulation_url%/}"

health_response="$(
curl --fail --silent --show-error --include \
--connect-timeout 10 --max-time 60 \
"${simulation_url}/health"
)"

# With --include, curl prints every response's headers; the last revision
# header belongs to the final response.
served_revision="$(
awk '
tolower($1) == "x-policyengine-simulation-revision:" {
gsub("\r", "", $2)
print $2
}
' <<<"${health_response}" |
tail -n 1
)"

if [[ -z "${served_revision}" ]]; then
printf '%s/health did not name a Simulation Entrypoint revision; the %s deployment must call the stable URL of %s\n' \
"${simulation_url}" "${deployment_environment}" "${expected_service}" >&2
exit 1
fi

if ! [[ "${served_revision}" =~ ^(.+)-[0-9]{5}-[a-z0-9]{3}$ ]]; then
printf '%s, served by %s, is not a Cloud Run revision name\n' \
"${served_revision}" "${simulation_url}" >&2
exit 1
fi
served_service="${BASH_REMATCH[1]}"

if [[ "${served_service}" != "${expected_service}" ]]; then
printf 'The %s deployment calls %s, which revision %s of %s serves; it must call %s\n' \
"${deployment_environment}" "${simulation_url}" "${served_revision}" \
"${served_service}" "${expected_service}" >&2
exit 1
fi

printf 'The %s deployment calls %s, served by revision %s of %s\n' \
"${deployment_environment}" "${simulation_url}" "${served_revision}" \
"${served_service}"
2 changes: 2 additions & 0 deletions .github/scripts/run_live_staging_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ python -m pytest \
tests/integration/test_live_budget_window_cache.py \
tests/integration/test_live_calculate.py \
tests/integration/test_live_economy.py \
tests/integration/test_live_v2_household_calculations.py \
tests/integration/test_live_v2_household_parity.py \
-v
8 changes: 7 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ jobs:
&& (github.event.head_commit.message == 'Update PolicyEngine API')
environment: staging
env:
DEPLOYMENT_ENVIRONMENT: staging
SIM_ENTRYPOINT: ${{ vars.SIM_ENTRYPOINT }}
SIMULATION_ENTRYPOINT_URL: ${{ secrets.SIMULATION_ENTRYPOINT_URL }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Check the simulation service belongs to staging
run: bash .github/scripts/check_simulation_entrypoint_environment.sh
- name: Install jq
run: sudo apt-get install -y jq
- name: Set up uv for installed bundle validation
Expand Down Expand Up @@ -339,7 +342,7 @@ jobs:
parallel-live-simulation-tests-staging-cloud-run:
name: Run live simulations against the staging candidate
runs-on: ubuntu-latest
timeout-minutes: 20
timeout-minutes: 30
needs: deploy-cloud-run-staging
if: |
(github.repository == 'PolicyEngine/policyengine-api')
Expand Down Expand Up @@ -438,11 +441,14 @@ jobs:
&& (github.event.head_commit.message == 'Update PolicyEngine API')
environment: production
env:
DEPLOYMENT_ENVIRONMENT: production
SIM_ENTRYPOINT: ${{ vars.SIM_ENTRYPOINT }}
SIMULATION_ENTRYPOINT_URL: ${{ secrets.SIMULATION_ENTRYPOINT_URL }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Check the simulation service belongs to production
run: bash .github/scripts/check_simulation_entrypoint_environment.sh
- name: Install jq
run: sudo apt-get install -y jq
- name: Set up uv for installed bundle validation
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/seed-v2-database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ jobs:
run: uv run python scripts/publish_v2_metadata_catalog.py
env:
V2_DATA_WRITE_DATABASE_URL: ${{ secrets.V2_DATA_WRITE_DATABASE_URL }}
# Reads the certified UK data release, whose repository is private,
# to check each new catalog version's region filters.
HUGGING_FACE_TOKEN: ${{ secrets.PE_UK_PRIVATE_HF_READ_TOKEN }}
# Each version's SPM availability comes from this environment's
# simulation service's public versions answer.
SIMULATION_ENTRYPOINT_URL: ${{ secrets.SIMULATION_ENTRYPOINT_URL }}
10 changes: 5 additions & 5 deletions .github/workflows/v2-integration-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ jobs:
run: uv run python scripts/reconcile_v2_privileges.py apply --create-missing-roles
- name: Verify the managed v2 roles hold their declared privileges
run: uv run python scripts/reconcile_v2_privileges.py verify
- name: Verify the installed PolicyEngine.py catalog interface
run: uv run coverage run --branch -m pytest -q tests/integration/test_v2_catalog_installed.py
- name: Verify the installed PolicyEngine.py catalog interface and its parity with v1 metadata
run: uv run coverage run --branch -m pytest -q tests/integration/test_v2_catalog_installed.py tests/integration/test_v2_catalog_metadata_parity.py
env:
RUN_V2_CATALOG_COMPATIBILITY: "1"
- name: Test v2 metadata publication and resource routes
run: uv run coverage run -a --branch -m pytest -q tests/integration/test_v2_catalog_publication.py tests/integration/test_v2_metadata_routes.py
- name: Test v2 metadata publication, resource routes and the countries list
run: uv run coverage run -a --branch -m pytest -q tests/integration/test_v2_catalog_publication.py tests/integration/test_v2_catalog_spm_availability.py tests/integration/test_v2_metadata_routes.py tests/integration/test_v2_country_routes.py
- name: Test v2 policy persistence and immediate v1 mirroring
run: uv run coverage run -a --branch -m pytest -q tests/integration/test_v2_policy_persistence.py tests/integration/test_v1_policy_dual_write.py tests/integration/test_mysql_policy_dual_write.py tests/integration/test_v2_user_policy_mirroring.py tests/integration/test_v1_user_policy_dual_write.py
- name: Test signed-in identity provisioning and user associations
run: uv run coverage run -a --branch -m pytest -q tests/integration/test_v2_user_identity_persistence.py
run: uv run coverage run -a --branch -m pytest -q tests/integration/test_v2_user_identity_persistence.py tests/integration/test_v2_saved_policy_view.py
- name: Test comparison-run persistence and privilege reconciliation as the managed roles
run: uv run coverage run -a --branch -m pytest -q tests/integration/test_v2_stage12_comparison_persistence.py tests/integration/test_v2_privilege_reconciliation.py
- name: Test v2 household persistence and immediate v1 copying
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ gha-creds-*.json
## vscode settings
/.vscode
*.db.init.lock

# coverage.py data and reports written by `make test`
.coverage
.coverage.*
coverage.xml
1 change: 1 addition & 0 deletions changelog.d/catalog-spm-availability.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Each published catalog version now records whether it offers SPM settings, with their schema and certified defaults, from the simulation service's public versions answer; the catalog publication step reads `SIMULATION_ENTRYPOINT_URL`, and a version published earlier gets it on the next publication run of its PolicyEngine.py version.
1 change: 1 addition & 0 deletions changelog.d/model-catalog-spm-availability.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`GET /v2/model-catalog` now returns `spm`: whether the catalog version offers SPM settings for a household, with their JSON schema and certified defaults when it does.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Each release now checks, in its staging and production model-version alignment jobs, that the environment's simulation URL is served by that environment's own Simulation Entrypoint service, and fails otherwise; staging must call the staging simulation service, and production the production one.
1 change: 1 addition & 0 deletions changelog.d/v2-countries-route.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added `GET /v2/countries`, which lists every row of the countries table: each served country's ID and whether it supports household and society-wide calculations.
1 change: 1 addition & 0 deletions changelog.d/v2-countries-startup-check.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Public API refuses to start when the v2 `countries` table and its country list in code name different countries, or when the table or the privilege to read it is missing. The check runs on Cloud Run and wherever a v2 runtime database is configured; when it cannot query the table, it logs why and startup continues.
1 change: 1 addition & 0 deletions changelog.d/v2-countries-table.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a v2 `countries` table that records, for each country the Public API serves, whether it supports household and society-wide calculations. Its revision lists the US and the UK, both with both. Users' primary country and the country of every v2 household, policy and user association now reference this table instead of a fixed US-and-UK check.
1 change: 1 addition & 0 deletions changelog.d/v2-household-calculations.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`POST /v2/household-calculations` sends a stored household, under a stored policy or current law, with optional axes, to the simulation service for calculation, and `GET /v2/household-calculations/{calculation_id}` returns its status and, once it succeeded, the calculated household with its warnings and, in the US, the SPM selection applied and its receipt. Neither needs an account; a country whose `countries` row does not allow household calculations is refused with 422.
1 change: 1 addition & 0 deletions changelog.d/v2plan-1f-115-catalog-metadata-fields.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Catalog format 2 stores the metadata the app's v3 workspace reads, taken only from PolicyEngine.py's public records: each model version's entities and basic inputs; each variable's input and hidden-input flags, module, the parameter path its adds or subtracts names, its enum values' labels, its unit and its definition period; each parameter's economy and household flags. Bracket schedules are stored as parameter nodes with their stored label. A generated revision adds the columns as nullable, so catalog versions published earlier keep them empty and are compared without them when republished. An opt-in parity test, run by the v2 integration check, compares every new field for the US and the UK with /{country}/metadata. Each country's default dataset now comes from the installed PolicyEngine.py release's manifest; the Public API no longer fixes its own (populace_us_2024 and microcosm_uk_2024_25), and publication stops if the release names no default or does not certify it.
5 changes: 5 additions & 0 deletions changelog.d/v2plan-1f-116-catalog-routes-on-demand.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Every successful v2 metadata response carries a strong ETag (a hash of its body) and a public Cache-Control lifetime: a day when the request names its catalog with policyengine_version, five minutes for the running version, and never past the UTC midnight after the request for current parameter values (current=true). A request whose If-None-Match names the ETag gets 304 with no body. These responses and their 304s carry Vary: Origin, Accept-Encoding, each value once, and browser scripts can read the ETag.
GET /v2/model-catalog returns only the small parts of one catalog version (model, model version, entities, basic inputs, regions, logical input datasets and economy choices, which are empty lists for a catalog without regions) and names the selected PolicyEngine.py version, so a client can request every other part for that exact version.
GET /v2/model-catalog/variables returns every variable of a catalog version in one response, with the catalog format 2 fields (input and hidden-input flags, module, the parameter path an adds or subtracts list comes from, enum labels, unit and definition period), and the current-law values by date of each parameter such a list comes from. GET /v2/variables pages carry the same variable fields.
GET /v2/model-catalog/parameters fetches up to 100 parameters of a catalog version by name in one request, each with its economy and household flags and its current-law values by date, plus the stored labels of their ancestor nodes for breadcrumbs and the requested names the version lacks. /v2/parameters pages and details carry the economy and household flags.
Each API process keeps the serialized /v2/model-catalog and /v2/model-catalog/variables bodies and their ETags once built (up to eight route, country and version combinations), so only the first successful request per process reads them from the database; requests arriving during that read receive its outcome.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Every v2 metadata route reads its query through the shared query models, so unknown or repeated parameters, a missing or unsupported country_id and a malformed policyengine_version return 422 before any read (unsupported countries and malformed versions returned 400 before, and unknown parameters were ignored). /v2/parameters accepts repeated name keys and /v2/parameter-values repeated parameter_name keys to page only those parameters.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v2 metadata reads run in autocommit sessions on the shared pool, and each process keeps the catalog versions it has selected. A request that makes one read for a version the process has already selected, such as a page of parameters or one parameter's values, now sends two statements to the database (the pool's liveness check and the read) instead of five; each further read in a request adds one statement.
1 change: 1 addition & 0 deletions changelog.d/v2plan-1f-121-repoint-saved-items.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PATCH /v2/user-policies/{id} accepts policy_id and PATCH /v2/user-households/{id} accepts household_id, so a saved policy or household can point at another v2 record in its country while keeping its ID, name and creation time. Supplied alone, the v2 reference clears the v1 reference (legacy_policy_id or legacy_household_id); supplied with it, both are stored, and the v2 reference must be the v2 copy of that v1 record when one exists. Unknown, other-country and conflicting records are refused as on creation, and saved policies maintained by the v1 saved-policy mirror still return 409.
1 change: 1 addition & 0 deletions changelog.d/v2plan-1f-122-rename-user-policies.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The v2 table user_policies is renamed to user_policy_associations, matching the other user-association tables; its constraints and convention-named indexes take the new name. Saved policies, their v1 mappings and the reports that name them are kept. A temporary view named user_policies, with the runtime role's privileges, lets the release from before the rename keep reading and writing saved policies during the deploy and after a rollback; a later change removes it. The privilege reconciliation now finds, grants and verifies privileges on views. The route /v2/user-policies, the user_policy_id columns, legacy_user_policy_mappings and the v1 Cloud SQL table user_policies are unchanged.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Catalog publication reads regions from the Public API's checked-in reference files, one per country, instead of PolicyEngine.py's region registry. Each region takes its dataset from the certified data release and a row filter from a scoping rule: state_fips or congressional_district_geoid for US states and districts, the UK region column for UK nations, and constituency_code_oa or la_code_oa on the local-area dataset the release routes UK constituencies and local authorities to. The UK now publishes 1,016 regions, with 650 constituencies and 361 local authorities (including Ards and North Down) by ONS code and Northern Ireland as country/northern_ireland; the national regions are "United States" and "United Kingdom". US places are listed in the reference file but left out of the catalog until they can run, and the publication evidence counts them. Before it publishes a catalog version that is not stored yet, the publication command reads the HDF5 metadata of the certified datasets the filters use, from Hugging Face at their pinned revisions, and stops if a filter's column is missing; the seed workflow's publication step receives the UK data read token as HUGGING_FACE_TOKEN for this. A catalog version that is already stored keeps the regions it was published with, so region file changes take effect in the next catalog version; republishing it logs the difference in region rows instead of failing, its evidence counts the stored regions and lists the kept version under kept_regions, and every other table must still match.
Loading
Loading