From fe947642019455cbcd7822d28a1f741734f040c4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 1 Dec 2026 01:45:40 +0000 Subject: [PATCH 1/9] Update PolicyEngine bundle to 6.20.4 --- ...date-policyengine-bundle-6.20.4.changed.md | 1 + docker/Dockerfile | 2 +- pyproject.toml | 2 +- uv.lock | 20 +++++++++---------- 4 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 changelog.d/update-policyengine-bundle-6.20.4.changed.md diff --git a/changelog.d/update-policyengine-bundle-6.20.4.changed.md b/changelog.d/update-policyengine-bundle-6.20.4.changed.md new file mode 100644 index 000000000..ebbd6fbd2 --- /dev/null +++ b/changelog.d/update-policyengine-bundle-6.20.4.changed.md @@ -0,0 +1 @@ +Update the PolicyEngine bundle to 6.20.4. diff --git a/docker/Dockerfile b/docker/Dockerfile index 0152908eb..8bd039ae1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ FROM python:3.12 # Match the API bundle in pyproject.toml; the bundle updater changes both pins. # The models extra pins the complete certified runtime package set. -RUN pip install "policyengine[models]==6.20.0" ipython +RUN pip install "policyengine[models]==6.20.4" ipython diff --git a/pyproject.toml b/pyproject.toml index 07e523472..3357b52a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ dependencies = [ # versions certified by this PolicyEngine bundle. Cloud Run installs the # complete frozen environment from uv.lock; the generic image installs # this requirement directly. - "policyengine[models]==6.20.0", + "policyengine[models]==6.20.4", # The simulation service's generated client, which builds the requests of # the detailed-save API's household calculation, simulation and report # routes (policyengine_api.libs.simulation_service_operations). The pin is diff --git a/uv.lock b/uv.lock index c2d455330..6cfa13d5c 100644 --- a/uv.lock +++ b/uv.lock @@ -2954,7 +2954,7 @@ wheels = [ [[package]] name = "policyengine" -version = "6.20.0" +version = "6.20.4" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "h5py" }, @@ -2966,9 +2966,9 @@ dependencies = [ { name = "pydantic" }, { name = "requests" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/14/e8/4373c716f428ed885392ff1776dc1be1f9e9a3a6f7608afcc1f39d683546/policyengine-6.20.0.tar.gz", hash = "sha256:65dad563d92c17485c5943b2bb8114d8f16cd49c977acbce6412cd8b8bcfadfd", size = 1863269, upload-time = "2026-11-16T16:21:45.756Z" } +sdist = { url = "https://files.pythonhosted.org/packages/32/77/e2970d5839f497d6fefd06aeef99774859ca2f30bb5ee1691dfb458a7e2c/policyengine-6.20.4.tar.gz", hash = "sha256:4f253587872230fd55e8c045622ccd913ada304c1ead9b60dbc33cf4315685cf", size = 1868173, upload-time = "2026-12-01T01:43:30.923Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/64/b6/9ebed9a78c755c25893a20c924bc6952100bc3376608511fbcdb065145c3/policyengine-6.20.0-py3-none-any.whl", hash = "sha256:cc2da1b7448ae229294090318140bfe39440e8899415b8e465459c7e89bb7135", size = 774390, upload-time = "2026-11-16T16:21:43.414Z" }, + { url = "https://files.pythonhosted.org/packages/fc/92/02d046bf927873476ebf3e54e3efd23acd7270b221bca00d972f69086312/policyengine-6.20.4-py3-none-any.whl", hash = "sha256:0b93ec55feab0edfde61dcf27ecb81c68e1f7a271bd328a0ddf0e92f54933301", size = 775042, upload-time = "2026-12-01T01:43:28.788Z" }, ] [package.optional-dependencies] @@ -3073,7 +3073,7 @@ requires-dist = [ { name = "mypy", marker = "extra == 'dev'", specifier = ">=1.15,<2" }, { name = "openai" }, { name = "packaging", specifier = ">=24,<27" }, - { name = "policyengine", extras = ["models"], specifier = "==6.20.0" }, + { name = "policyengine", extras = ["models"], specifier = "==6.20.4" }, { name = "policyengine-api-simulation-client", specifier = "==0.20261127.430" }, { name = "policyengine-observability", extras = ["flask", "google", "httpx", "otlp-grpc"], specifier = ">=3.0.3,<4" }, { name = "psycopg", extras = ["binary"], specifier = ">=3.3,<4" }, @@ -3116,7 +3116,7 @@ wheels = [ [[package]] name = "policyengine-core" -version = "3.33.3" +version = "3.34.10" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "dpath" }, @@ -3136,9 +3136,9 @@ dependencies = [ { name = "standard-imghdr" }, { name = "wheel" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/17/af/e8449e8a488468e5ce28b6b9066a2372e05bc7971ad9a441eb4e6efbb740/policyengine_core-3.33.3.tar.gz", hash = "sha256:7da78ae9cc7b1d6833dc30651a0a4775edd2d5e205a73bbafcc0b15c988c880e", size = 693203, upload-time = "2026-10-12T20:53:17.299Z" } +sdist = { url = "https://files.pythonhosted.org/packages/39/15/8526adf38be5c96324f458886a2622704daec39b7e487899a7e922e299eb/policyengine_core-3.34.10.tar.gz", hash = "sha256:d232ddc415c3fa65bad31c0be25ff0f2c5826a5ae4cae10a47e6cd0a2102931d", size = 779988, upload-time = "2026-11-08T01:59:34.917Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/c8/d6/253cc99d853e36996f264138f4f8a2c662047da3eda8e37ddf39959397fc/policyengine_core-3.33.3-py3-none-any.whl", hash = "sha256:5847d9938412095fe9848c2ce535838a7dc8fac9238d8fd9e6c9d0a0648e0888", size = 301905, upload-time = "2026-10-12T20:53:15.706Z" }, + { url = "https://files.pythonhosted.org/packages/ef/2e/b92cc4271bd5d02cc7830201316514cef91128861074cc5e06d6ac3c3dd2/policyengine_core-3.34.10-py3-none-any.whl", hash = "sha256:5045ed5e4d157eefab22bd285c8ba09e107f5c3a5a61e380fc2a85163259982a", size = 311145, upload-time = "2026-11-08T01:59:32.984Z" }, ] [[package]] @@ -3169,7 +3169,7 @@ otlp-grpc = [ [[package]] name = "policyengine-uk" -version = "2.174.1" +version = "2.179.2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "microdf-python" }, @@ -3177,9 +3177,9 @@ dependencies = [ { name = "pydantic" }, { name = "tables" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/be/3a/fbf290895263fd4f8394f76fe1694e90e2c7b8b51a5a18f45f9bda16a4e2/policyengine_uk-2.174.1.tar.gz", hash = "sha256:c8302686c4d7c6fa92fb87febe1ad8130b7a0dd7987d5b14104384bd171f2245", size = 4434552, upload-time = "2026-11-04T07:36:05.319Z" } +sdist = { url = "https://files.pythonhosted.org/packages/69/45/9bfc794973d685c5da6c09d3b84b2445ffbfc16fc28bfd96772f8457aee0/policyengine_uk-2.179.2.tar.gz", hash = "sha256:56a99e8e3a48d2ebf5ee5f4383e5b5671b3c3b3b84f668cabc7b560f83bfd44e", size = 5294795, upload-time = "2026-11-18T15:41:54.502Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/35/ed/5ea303be2fd38da4e5f9b9a3fd012a5f9454fd5ef66a1df26c3267fb57a8/policyengine_uk-2.174.1-py3-none-any.whl", hash = "sha256:1d4d17c74bd5b853a148e9c44b080490dd0393725fe18b2b82ec55eecdb9bb58", size = 6313656, upload-time = "2026-11-04T07:36:02.964Z" }, + { url = "https://files.pythonhosted.org/packages/c6/55/84a5f328cff944fae92dc64d49ca139fe51b0f06b0217063ff87e3ea9779/policyengine_uk-2.179.2-py3-none-any.whl", hash = "sha256:a1da93b521408fd4aee7e85f6550d33fb392f0291bcab0eaba631533e3cc0836", size = 7416601, upload-time = "2026-11-18T15:41:51.547Z" }, ] [[package]] From 5e42fa56e32b66edccb8f56c00c61c80c467a938 Mon Sep 17 00:00:00 2001 From: Anthony Volk <14987227+anth-volk@users.noreply.github.com> Date: Tue, 1 Dec 2026 06:18:32 +0400 Subject: [PATCH 2/9] Test that API v1 runs on a .py release with the stable inequality sort API v1's economy requests send its installed .py version as policyengine_version, and the simulation service runs each request on the app it deployed for that version; the /v2/ routes read that version's catalog. Releases before 6.20.4 rank households with equal incomes with numpy's default sort, whose order depends on the CPU. This test fails on the 6.20.0 pin. Co-Authored-By: Claude Opus 5.5 --- tests/unit/test_constants.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/unit/test_constants.py b/tests/unit/test_constants.py index ccf292307..aefef36f3 100644 --- a/tests/unit/test_constants.py +++ b/tests/unit/test_constants.py @@ -1,8 +1,10 @@ +import importlib.metadata import json import subprocess import sys import pytest +from packaging.version import Version from policyengine_api.constants import ( COUNTRY_PACKAGE_VERSIONS, @@ -39,6 +41,11 @@ def find_spec(self, fullname, path=None, target=None): sys.meta_path.insert(0, BlockPolicyEngineImports()) """ +# The first .py release whose inequality outputs (the Gini coefficient and +# the top 10%, top 1% and bottom 50% income shares) rank households with equal +# incomes in the order of their rows (PolicyEngine/policyengine.py#777). +FIRST_RELEASE_WITH_STABLE_INEQUALITY_SORT = Version("6.20.4") + class TestBundleDatasetDisplayLabels: @pytest.mark.parametrize( @@ -300,6 +307,22 @@ def test__load_policyengine_bundle_rejects_non_object_manifest( with pytest.raises(TypeError, match="must be a JSON object"): _load_policyengine_bundle() + def test__requests_name_a_release_that_sorts_incomes_stably(self): + """API v1's reports run on a .py release with the stable inequality sort. + + Economy requests send ``POLICYENGINE_VERSION`` as + ``policyengine_version``, and the simulation service runs each request + on the app it deployed for that version. The /v2/ routes read the + catalog of the installed distribution's version. Before 6.20.4, .py + ranked households with equal incomes with numpy's default sort, whose + order depends on the CPU, so the same report could give different top + income shares on different hosts. + """ + installed_version = importlib.metadata.version("policyengine") + + assert installed_version == POLICYENGINE_VERSION + assert Version(installed_version) >= FIRST_RELEASE_WITH_STABLE_INEQUALITY_SORT + def test__uses_policyengine_bundle_versions_for_us_uk_and_core(self): expected_versions = self._expected_bundle_versions() assert expected_versions["policyengine"] == POLICYENGINE_VERSION From fdcc790a3d675bb2f02e5734920fc1e3a9cabff6 Mon Sep 17 00:00:00 2001 From: Anthony Volk <14987227+anth-volk@users.noreply.github.com> Date: Tue, 1 Dec 2026 06:20:49 +0400 Subject: [PATCH 3/9] Describe what the 6.20.4 bundle brings in The changelog fragment names the stable inequality sort and the policyengine-uk, policyengine-core and UK data release changes from 6.20.1 to 6.20.3. The dynamic parameters' docstring names the installed policyengine-uk version, whose gov.dynamic. folder is unchanged. Co-Authored-By: Claude Opus 5.5 --- changelog.d/update-policyengine-bundle-6.20.4.changed.md | 2 +- policyengine_api/dynamic_parameters.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog.d/update-policyengine-bundle-6.20.4.changed.md b/changelog.d/update-policyengine-bundle-6.20.4.changed.md index ebbd6fbd2..6625b17cb 100644 --- a/changelog.d/update-policyengine-bundle-6.20.4.changed.md +++ b/changelog.d/update-policyengine-bundle-6.20.4.changed.md @@ -1 +1 @@ -Update the PolicyEngine bundle to 6.20.4. +Update the PolicyEngine bundle to 6.20.4. Its inequality outputs rank households with equal incomes in the order of their rows, so a report gives the same Gini coefficient and income shares on every host. It also brings in 6.20.1 to 6.20.3: policyengine-uk 2.179.2, policyengine-core 3.34.10 and a new certified UK data release, which change UK household calculations, UK metadata, UK economy results and the /v2/ model catalog. diff --git a/policyengine_api/dynamic_parameters.py b/policyengine_api/dynamic_parameters.py index aa1344242..00a62a097 100644 --- a/policyengine_api/dynamic_parameters.py +++ b/policyengine_api/dynamic_parameters.py @@ -6,7 +6,7 @@ behavioural responses, model settings and data assumptions, which a report applies alongside a policy. Parameters a country package adds later under these prefixes belong to dynamics with no code change. In policyengine-uk -2.174.1, ``gov.dynamic.`` holds one parameter, +2.179.2, ``gov.dynamic.`` holds one parameter, ``gov.dynamic.obr_labour_supply_assumptions``, a yes/no switch. The rule is used in these places: From 6b242d62f3dee9d229fbc1fcb5f63732d20b0fb5 Mon Sep 17 00:00:00 2001 From: Anthony Volk <14987227+anth-volk@users.noreply.github.com> Date: Tue, 1 Dec 2026 06:47:51 +0400 Subject: [PATCH 4/9] Name the US effect and keep the dynamic parameters' docstring current The changelog fragment says policyengine-core's reform and caching fixes may also change some US household results, and that the /v2/ model catalog gets a 6.20.4 version for both countries. The docstring states the range of policyengine-uk versions it was checked against, so the next bundle update doesn't make it wrong. Co-Authored-By: Claude Opus 5.5 --- changelog.d/update-policyengine-bundle-6.20.4.changed.md | 2 +- policyengine_api/dynamic_parameters.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/changelog.d/update-policyengine-bundle-6.20.4.changed.md b/changelog.d/update-policyengine-bundle-6.20.4.changed.md index 6625b17cb..a53945b07 100644 --- a/changelog.d/update-policyengine-bundle-6.20.4.changed.md +++ b/changelog.d/update-policyengine-bundle-6.20.4.changed.md @@ -1 +1 @@ -Update the PolicyEngine bundle to 6.20.4. Its inequality outputs rank households with equal incomes in the order of their rows, so a report gives the same Gini coefficient and income shares on every host. It also brings in 6.20.1 to 6.20.3: policyengine-uk 2.179.2, policyengine-core 3.34.10 and a new certified UK data release, which change UK household calculations, UK metadata, UK economy results and the /v2/ model catalog. +Update the PolicyEngine bundle to 6.20.4. Its inequality outputs rank households with equal incomes in the order of their rows, so a report gives the same Gini coefficient and income shares on every host. It also brings in 6.20.1 to 6.20.3: policyengine-uk 2.179.2, policyengine-core 3.34.10 and a new certified UK data release, which change UK household calculations, UK metadata and UK economy results. policyengine-core's reform and caching fixes may also change some US household results, and the /v2/ model catalog gets a 6.20.4 version for both countries. diff --git a/policyengine_api/dynamic_parameters.py b/policyengine_api/dynamic_parameters.py index 00a62a097..6b28d4705 100644 --- a/policyengine_api/dynamic_parameters.py +++ b/policyengine_api/dynamic_parameters.py @@ -5,8 +5,8 @@ tree (C1 · 35, Q1) and the UK's ``gov.dynamic.`` (C1 · 46, Q6). These are behavioural responses, model settings and data assumptions, which a report applies alongside a policy. Parameters a country package adds later under -these prefixes belong to dynamics with no code change. In policyengine-uk -2.179.2, ``gov.dynamic.`` holds one parameter, +these prefixes belong to dynamics with no code change. From policyengine-uk +2.174.1 to at least 2.179.2, ``gov.dynamic.`` holds one parameter, ``gov.dynamic.obr_labour_supply_assumptions``, a yes/no switch. The rule is used in these places: From c6eab65240b42f852ed5d7c90c174d7e3e8d4c3a Mon Sep 17 00:00:00 2001 From: Anthony Volk <14987227+anth-volk@users.noreply.github.com> Date: Tue, 1 Dec 2026 23:59:16 +0400 Subject: [PATCH 5/9] Test that economy requests name a .py release that records dataset inputs API v1 sends its installed .py version with each economy request, and the simulation service runs the request on that version's app. From .py 6.0.0 to 6.20.4, a US simulation built from a dataset doesn't list the dataset's columns in input_variables, so policyengine-us's marginal_tax_rate copies delete them and target=cliff results count the lost income as cliff gaps. This test fails until API v1 pins the release that fixes it (expected 6.20.5). Co-Authored-By: Claude Opus 5.5 --- tests/unit/test_constants.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/unit/test_constants.py b/tests/unit/test_constants.py index aefef36f3..45ed64232 100644 --- a/tests/unit/test_constants.py +++ b/tests/unit/test_constants.py @@ -46,6 +46,11 @@ def find_spec(self, fullname, path=None, target=None): # incomes in the order of their rows (PolicyEngine/policyengine.py#777). FIRST_RELEASE_WITH_STABLE_INEQUALITY_SORT = Version("6.20.4") +# The first .py release whose US simulations built from a dataset list every +# stored dataset column in ``input_variables``, so policyengine-us's +# ``marginal_tax_rate`` and ``cliff_gap`` keep the household's inputs. +FIRST_RELEASE_RECORDING_DATASET_INPUTS = Version("6.20.5") + class TestBundleDatasetDisplayLabels: @pytest.mark.parametrize( @@ -323,6 +328,21 @@ def test__requests_name_a_release_that_sorts_incomes_stably(self): assert installed_version == POLICYENGINE_VERSION assert Version(installed_version) >= FIRST_RELEASE_WITH_STABLE_INEQUALITY_SORT + def test__requests_name_a_release_that_records_dataset_inputs(self): + """API v1's economy requests run on a .py release that records dataset inputs. + + Economy requests send ``POLICYENGINE_VERSION`` as + ``policyengine_version``, and the simulation service runs each request + on the app it deployed for that version. From 6.0.0 to 6.20.4, .py + built a US simulation from a dataset without listing the dataset's + columns in ``input_variables``. policyengine-us's ``marginal_tax_rate`` + recalculates each adult's income in a copy of the simulation that + deletes every variable not in that list, so the copy lost the + household's other income, and ``target=cliff`` results counted the + lost income as cliff gaps. + """ + assert Version(POLICYENGINE_VERSION) >= FIRST_RELEASE_RECORDING_DATASET_INPUTS + def test__uses_policyengine_bundle_versions_for_us_uk_and_core(self): expected_versions = self._expected_bundle_versions() assert expected_versions["policyengine"] == POLICYENGINE_VERSION From d3e21f3ad4936d720b611c60c77b2efdc4f4cebc Mon Sep 17 00:00:00 2001 From: Anthony Volk <14987227+anth-volk@users.noreply.github.com> Date: Tue, 1 Dec 2026 23:59:58 +0400 Subject: [PATCH 6/9] Add the changelog fragment for the .py release that records dataset inputs Co-Authored-By: Claude Opus 5.5 --- changelog.d/update-policyengine-bundle-6.20.5.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/update-policyengine-bundle-6.20.5.fixed.md diff --git a/changelog.d/update-policyengine-bundle-6.20.5.fixed.md b/changelog.d/update-policyengine-bundle-6.20.5.fixed.md new file mode 100644 index 000000000..6a0819e3a --- /dev/null +++ b/changelog.d/update-policyengine-bundle-6.20.5.fixed.md @@ -0,0 +1 @@ +Update the PolicyEngine bundle to 6.20.5. From 6.0.0 to 6.20.4, .py built US simulations from a dataset without listing the dataset's inputs, so policyengine-us recalculated each adult's marginal tax rate without the household's other income, and `target=cliff` economy results counted that income as cliff gaps. 6.20.5 lists the inputs, which corrects US cliff results and the other US economy results that read marginal tax rates, such as labor supply responses. From d547b4388ffa65f000be620c1a82d5b7c52f79ef Mon Sep 17 00:00:00 2001 From: Anthony Volk <14987227+anth-volk@users.noreply.github.com> Date: Wed, 2 Dec 2026 00:09:34 +0400 Subject: [PATCH 7/9] Fix review round 1's findings on the dataset-inputs test and fragment Describe marginal_tax_rate's branch exactly (the two highest earners, and the lost age and location as well as income), say that 6.20.5 is the expected release until the fix is published, drop the fragment's labor supply claim until the release is checked, and give the fragment a name the bundle workflow's fragment for the same release won't share. Co-Authored-By: Claude Opus 5.5 --- changelog.d/py-dataset-inputs.fixed.md | 1 + .../update-policyengine-bundle-6.20.5.fixed.md | 1 - tests/unit/test_constants.py | 14 +++++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 changelog.d/py-dataset-inputs.fixed.md delete mode 100644 changelog.d/update-policyengine-bundle-6.20.5.fixed.md diff --git a/changelog.d/py-dataset-inputs.fixed.md b/changelog.d/py-dataset-inputs.fixed.md new file mode 100644 index 000000000..aa483ff7e --- /dev/null +++ b/changelog.d/py-dataset-inputs.fixed.md @@ -0,0 +1 @@ +Update the PolicyEngine bundle to 6.20.5. From 6.0.0 to 6.20.4, .py built US simulations from a dataset without listing the dataset's inputs, so policyengine-us recalculated marginal tax rates without the household's other income, age and location, and `target=cliff` economy results counted the lost income as cliff gaps. 6.20.5 lists the inputs, so US marginal tax rates and `target=cliff` results calculated from datasets keep the household's inputs. diff --git a/changelog.d/update-policyengine-bundle-6.20.5.fixed.md b/changelog.d/update-policyengine-bundle-6.20.5.fixed.md deleted file mode 100644 index 6a0819e3a..000000000 --- a/changelog.d/update-policyengine-bundle-6.20.5.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Update the PolicyEngine bundle to 6.20.5. From 6.0.0 to 6.20.4, .py built US simulations from a dataset without listing the dataset's inputs, so policyengine-us recalculated each adult's marginal tax rate without the household's other income, and `target=cliff` economy results counted that income as cliff gaps. 6.20.5 lists the inputs, which corrects US cliff results and the other US economy results that read marginal tax rates, such as labor supply responses. diff --git a/tests/unit/test_constants.py b/tests/unit/test_constants.py index 45ed64232..18e7543f7 100644 --- a/tests/unit/test_constants.py +++ b/tests/unit/test_constants.py @@ -48,7 +48,9 @@ def find_spec(self, fullname, path=None, target=None): # The first .py release whose US simulations built from a dataset list every # stored dataset column in ``input_variables``, so policyengine-us's -# ``marginal_tax_rate`` and ``cliff_gap`` keep the household's inputs. +# ``marginal_tax_rate`` recalculates net income with the household's inputs. +# The fix isn't released yet: 6.20.5 is the expected version, and the pin raise +# sets this to the release that contains it. FIRST_RELEASE_RECORDING_DATASET_INPUTS = Version("6.20.5") @@ -336,10 +338,12 @@ def test__requests_name_a_release_that_records_dataset_inputs(self): on the app it deployed for that version. From 6.0.0 to 6.20.4, .py built a US simulation from a dataset without listing the dataset's columns in ``input_variables``. policyengine-us's ``marginal_tax_rate`` - recalculates each adult's income in a copy of the simulation that - deletes every variable not in that list, so the copy lost the - household's other income, and ``target=cliff`` results counted the - lost income as cliff gaps. + raises the earnings of each of the household's two highest earners in + a branch of the simulation that deletes every variable not in that + list, then recalculates household net income. The branch lost the + household's other income, age and location, so marginal tax rates were + wrong, and ``target=cliff`` results counted the lost income as cliff + gaps. """ assert Version(POLICYENGINE_VERSION) >= FIRST_RELEASE_RECORDING_DATASET_INPUTS From 24815f9cd5667aca34b2e160af03fa182cdb6bd7 Mon Sep 17 00:00:00 2001 From: Anthony Volk <14987227+anth-volk@users.noreply.github.com> Date: Wed, 2 Dec 2026 00:20:24 +0400 Subject: [PATCH 8/9] Fix review round 2's quality findings on the dataset-inputs test Write the docstring relative to FIRST_RELEASE_RECORDING_DATASET_INPUTS, name the fragment in the constant's comment, and describe marginal_tax_rate's adults and the lost inputs exactly. Co-Authored-By: Claude Opus 5.5 --- changelog.d/py-dataset-inputs.fixed.md | 2 +- tests/unit/test_constants.py | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/changelog.d/py-dataset-inputs.fixed.md b/changelog.d/py-dataset-inputs.fixed.md index aa483ff7e..7ac88e54d 100644 --- a/changelog.d/py-dataset-inputs.fixed.md +++ b/changelog.d/py-dataset-inputs.fixed.md @@ -1 +1 @@ -Update the PolicyEngine bundle to 6.20.5. From 6.0.0 to 6.20.4, .py built US simulations from a dataset without listing the dataset's inputs, so policyengine-us recalculated marginal tax rates without the household's other income, age and location, and `target=cliff` economy results counted the lost income as cliff gaps. 6.20.5 lists the inputs, so US marginal tax rates and `target=cliff` results calculated from datasets keep the household's inputs. +Update the PolicyEngine bundle to 6.20.5. From 6.0.0 to 6.20.4, .py built US simulations from a dataset without listing most of the dataset's inputs, so policyengine-us recalculated marginal tax rates without the household's income other than earnings, its age and its location, and `target=cliff` economy results counted the lost income as cliff gaps. 6.20.5 lists the inputs, so US marginal tax rates and `target=cliff` results calculated from datasets keep the household's inputs. diff --git a/tests/unit/test_constants.py b/tests/unit/test_constants.py index 18e7543f7..3e45c8a21 100644 --- a/tests/unit/test_constants.py +++ b/tests/unit/test_constants.py @@ -49,8 +49,9 @@ def find_spec(self, fullname, path=None, target=None): # The first .py release whose US simulations built from a dataset list every # stored dataset column in ``input_variables``, so policyengine-us's # ``marginal_tax_rate`` recalculates net income with the household's inputs. -# The fix isn't released yet: 6.20.5 is the expected version, and the pin raise -# sets this to the release that contains it. +# The fix isn't released yet: 6.20.5 is the expected version. The pin raise +# sets this, and the versions in changelog.d/py-dataset-inputs.fixed.md, to the +# release that contains it. FIRST_RELEASE_RECORDING_DATASET_INPUTS = Version("6.20.5") @@ -335,15 +336,16 @@ def test__requests_name_a_release_that_records_dataset_inputs(self): Economy requests send ``POLICYENGINE_VERSION`` as ``policyengine_version``, and the simulation service runs each request - on the app it deployed for that version. From 6.0.0 to 6.20.4, .py - built a US simulation from a dataset without listing the dataset's + on the app it deployed for that version. From 6.0.0 up to the release + in ``FIRST_RELEASE_RECORDING_DATASET_INPUTS``, .py built a US + simulation from a dataset without listing most of the dataset's columns in ``input_variables``. policyengine-us's ``marginal_tax_rate`` - raises the earnings of each of the household's two highest earners in - a branch of the simulation that deletes every variable not in that - list, then recalculates household net income. The branch lost the - household's other income, age and location, so marginal tax rates were - wrong, and ``target=cliff`` results counted the lost income as cliff - gaps. + raises the earnings of each of the household's two adults with the + highest market income in a branch of the simulation that deletes every + variable not in that list, then recalculates household net income. + The branch lost the household's income other than earnings, its age + and its location, so marginal tax rates were wrong, and + ``target=cliff`` results counted the lost income as cliff gaps. """ assert Version(POLICYENGINE_VERSION) >= FIRST_RELEASE_RECORDING_DATASET_INPUTS From 5491248fa603df3a34a2c63d602a69f203f7b2a7 Mon Sep 17 00:00:00 2001 From: Anthony Volk <14987227+anth-volk@users.noreply.github.com> Date: Thu, 3 Dec 2026 19:52:15 +0400 Subject: [PATCH 9/9] Run API v1 on .py 6.20.5, which records US dataset inputs Raise policyengine[models] from 6.20.4 to 6.20.5 in pyproject.toml and docker/Dockerfile and relock (uv lock --upgrade-package policyengine). 6.20.5 holds only PolicyEngine/policyengine.py#783, which lists a US dataset's stored columns in input_variables; the bundle's other package versions and data releases are unchanged. Cite #783 in the test's constant and name the labor supply change in the changelog fragment. Co-Authored-By: Claude Opus 5.5 --- changelog.d/py-dataset-inputs.fixed.md | 2 +- docker/Dockerfile | 2 +- pyproject.toml | 2 +- tests/unit/test_constants.py | 6 ++---- uv.lock | 8 ++++---- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/changelog.d/py-dataset-inputs.fixed.md b/changelog.d/py-dataset-inputs.fixed.md index 7ac88e54d..d0fa5b16f 100644 --- a/changelog.d/py-dataset-inputs.fixed.md +++ b/changelog.d/py-dataset-inputs.fixed.md @@ -1 +1 @@ -Update the PolicyEngine bundle to 6.20.5. From 6.0.0 to 6.20.4, .py built US simulations from a dataset without listing most of the dataset's inputs, so policyengine-us recalculated marginal tax rates without the household's income other than earnings, its age and its location, and `target=cliff` economy results counted the lost income as cliff gaps. 6.20.5 lists the inputs, so US marginal tax rates and `target=cliff` results calculated from datasets keep the household's inputs. +Update the PolicyEngine bundle to 6.20.5. From 6.0.0 to 6.20.4, .py built US simulations from a dataset without listing most of the dataset's inputs, so policyengine-us recalculated marginal tax rates without the household's income other than earnings, its age and its location, and `target=cliff` economy results counted the lost income as cliff gaps. 6.20.5 lists the inputs, so US marginal tax rates and `target=cliff` results calculated from datasets keep the household's inputs. US labor supply responses, which read marginal tax rates, change too: in .py's example, one earner's response to a reform moves from -$591.09 to policyengine-us's -$655.38. diff --git a/docker/Dockerfile b/docker/Dockerfile index 8bd039ae1..38010a492 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ FROM python:3.12 # Match the API bundle in pyproject.toml; the bundle updater changes both pins. # The models extra pins the complete certified runtime package set. -RUN pip install "policyengine[models]==6.20.4" ipython +RUN pip install "policyengine[models]==6.20.5" ipython diff --git a/pyproject.toml b/pyproject.toml index 03ee7d737..b17855250 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ dependencies = [ # versions certified by this PolicyEngine bundle. Cloud Run installs the # complete frozen environment from uv.lock; the generic image installs # this requirement directly. - "policyengine[models]==6.20.4", + "policyengine[models]==6.20.5", # The simulation service's generated client, which builds the requests of # API v2's household calculation, simulation and report routes, and the # one-time migration command's run-free report create diff --git a/tests/unit/test_constants.py b/tests/unit/test_constants.py index 3e45c8a21..7ce6c0056 100644 --- a/tests/unit/test_constants.py +++ b/tests/unit/test_constants.py @@ -48,10 +48,8 @@ def find_spec(self, fullname, path=None, target=None): # The first .py release whose US simulations built from a dataset list every # stored dataset column in ``input_variables``, so policyengine-us's -# ``marginal_tax_rate`` recalculates net income with the household's inputs. -# The fix isn't released yet: 6.20.5 is the expected version. The pin raise -# sets this, and the versions in changelog.d/py-dataset-inputs.fixed.md, to the -# release that contains it. +# ``marginal_tax_rate`` recalculates net income with the household's inputs +# (PolicyEngine/policyengine.py#783). FIRST_RELEASE_RECORDING_DATASET_INPUTS = Version("6.20.5") diff --git a/uv.lock b/uv.lock index 2773b189c..aa0285cda 100644 --- a/uv.lock +++ b/uv.lock @@ -2954,7 +2954,7 @@ wheels = [ [[package]] name = "policyengine" -version = "6.20.4" +version = "6.20.5" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "h5py" }, @@ -2966,9 +2966,9 @@ dependencies = [ { name = "pydantic" }, { name = "requests" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/32/77/e2970d5839f497d6fefd06aeef99774859ca2f30bb5ee1691dfb458a7e2c/policyengine-6.20.4.tar.gz", hash = "sha256:4f253587872230fd55e8c045622ccd913ada304c1ead9b60dbc33cf4315685cf", size = 1868173, upload-time = "2026-12-01T01:43:30.923Z" } +sdist = { url = "https://files.pythonhosted.org/packages/c3/25/06d21a495fdb08d5ca28c2fce7a3c02fa054a65647d3a64f5d882261590c/policyengine-6.20.5.tar.gz", hash = "sha256:9ae71e19ba440bedede2e0b61b42a64cb969749df808dba50c28ef14874a441f", size = 1871654, upload-time = "2026-12-02T20:46:20.663Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/fc/92/02d046bf927873476ebf3e54e3efd23acd7270b221bca00d972f69086312/policyengine-6.20.4-py3-none-any.whl", hash = "sha256:0b93ec55feab0edfde61dcf27ecb81c68e1f7a271bd328a0ddf0e92f54933301", size = 775042, upload-time = "2026-12-01T01:43:28.788Z" }, + { url = "https://files.pythonhosted.org/packages/53/a0/6dcb72b7925453eeb322d340f9c5de4a5ffbfd0b711c12f57cb757ed0193/policyengine-6.20.5-py3-none-any.whl", hash = "sha256:ed35016f2bc62a6176e2da3c8ad34dd6f386b424369fc71a9ea3d05e387cfc54", size = 775369, upload-time = "2026-12-02T20:46:18.59Z" }, ] [package.optional-dependencies] @@ -3073,7 +3073,7 @@ requires-dist = [ { name = "mypy", marker = "extra == 'dev'", specifier = ">=1.15,<2" }, { name = "openai" }, { name = "packaging", specifier = ">=24,<27" }, - { name = "policyengine", extras = ["models"], specifier = "==6.20.4" }, + { name = "policyengine", extras = ["models"], specifier = "==6.20.5" }, { name = "policyengine-api-simulation-client", specifier = "==0.20261201.454" }, { name = "policyengine-observability", extras = ["flask", "google", "httpx", "otlp-grpc"], specifier = ">=3.0.3,<4" }, { name = "psycopg", extras = ["binary"], specifier = ">=3.3,<4" },