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 1/5] 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 2/5] 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 3/5] 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 4/5] 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 5/5] 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" },