Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
52 changes: 52 additions & 0 deletions .github/workflows/pure-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Pure preparation tests

on:
pull_request:
branches: [main]

permissions:
contents: read

concurrency:
group: pure-preparation-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
pure-tests:
name: Synthetic currency tests
runs-on: ubuntu-24.04
timeout-minutes: 5
env:
OMP_NUM_THREADS: "1"
OPENBLAS_NUM_THREADS: "1"
MKL_NUM_THREADS: "1"
NUMEXPR_NUM_THREADS: "1"
VECLIB_MAXIMUM_THREADS: "1"
PYTHONDONTWRITEBYTECODE: "1"
PYTEST_DISABLE_PLUGIN_AUTOLOAD: "1"
UV_PYTHON_DOWNLOADS: never
steps:
- name: Check out the pull request
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up CPython
id: python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.13.13"
architecture: x64
check-latest: false
- name: Set up uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
version: "0.13.8"
enable-cache: false
- name: Install only the pinned pure-test dependencies
env:
PURE_TEST_PYTHON: ${{ steps.python.outputs.python-path }}
run: |
uv venv --python "$PURE_TEST_PYTHON" .venv
uv pip install --python .venv/bin/python --only-binary :all: --require-hashes -r ci/pure-test-requirements.txt
- name: Run the existing synthetic tests with model imports blocked
run: uv run --offline --no-sync python -I -B scripts/run_native_currency_tests.py
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Tax-benefit cliffs under 2017 federal rules
# Cliffs: archived experiments and counterfactual preparation

How many American adults would see their household's net income fall if they earned $1,000 more? We estimate that count under 2017 federal tax and benefit rules and, for comparison, under 2025 rules, with and without counting health coverage as income. Where PolicyEngine-US holds no 2017 value for a rule, as for state Medicaid limits and most state taxes, the 2017 runs read its earliest later value; METHODOLOGY.md lists them. We use [PolicyEngine-US](https://github.com/PolicyEngine/policyengine-us) and Microcosm, PolicyEngine's US microdata.
This repository contains archived experiments measuring whether a specified earnings increase lowers household resources, with and without government-valued health coverage. The 2017-oriented experiments combine dated policies with later rule fallbacks, selected monetary rescaling and population reweighting. These hybrid sensitivities do not estimate actual 2017 incidence or compare laws while holding a recent population and real incomes fixed.

The [proposed counterfactual protocol](docs/counterfactual-protocol.md) describes a fresh comparison on one recent reference population. Its helper converts declared monetary inputs and preserves household characteristics. Fresh policy results require the managed population adapter and model/data qualification; existing result files report the hybrid experiments.

- [results/summary.md](results/summary.md): the counts, with 95% intervals.
- [METHODOLOGY.md](METHODOLOGY.md): how we define a cliff, build the 2017 population and measure uncertainty, and what the model leaves out.
- [METHODOLOGY.md](METHODOLOGY.md): the archived experiment's definition, construction of 2017-oriented inputs, uncertainty and coverage limits.
- [CORRECTION.md](CORRECTION.md): why our April 2025 estimate overstated the count, and the evidence.
- [april2025/](april2025/): the scripts that reproduce the April 2025 estimate and trace the error.

Expand All @@ -12,6 +14,8 @@ How many American adults would see their household's net income fall if they ear
| Path | Contents |
|---|---|
| cliffs2017/run.py | One run: a year, with or without health coverage, on the full sample, a household subsample or one of several disjoint household groups |
| cliffs2017/native_currency.py | Explicit input-currency and field-disposition helper for the proposed counterfactual; no engine adapter or policy calculations |
| docs/counterfactual-protocol.md, docs/price_basis.csv | Proposed comparison and published annual-average CPI-U price basis |
| cliffs2017/deflate.py | Scales the 2024 data to 2017 dollar levels and population; splits and subsamples households |
| cliffs2017/aca2017.py | The ACA premium tax credit before 2018, which PolicyEngine-US leaves at $0 |
| cliffs2017/decompose.py | Breaks each tested adult's change in net income into programs and taxes |
Expand All @@ -34,7 +38,27 @@ How many American adults would see their household's net income fall if they ear
| scripts/audit_*.py, scripts/summarize_parameters.py | The parameter and formula audits behind the coverage notes in METHODOLOGY.md, and the counts it quotes from the parameter audit |
| tests/ | Property and example tests (pytest) |

## Running it
## Testing counterfactual preparation

The helper tests use synthetic inputs and mock price indices and execute without model imports or population data.

Numeric facts retain their finite numeric types, including fractional ages; numeric strings fail validation. Money converts to exact fractions. Representation guards limit integers and ratio components to 4,096 bits, decimal coefficients to 1,000 digits, decimal exponents to ±1,000 and numeric text to 2,048 characters. These resource limits apply to supplied numbers.

Declare every input field explicitly. For age-derived birth facts, supply `calendar_scope` and `calendar_reason`, approve the scope in `InputContract.calendar_scopes`, and choose the reviewed drop or compatible hold. The returned `calendar_dispositions` records the scope, reason and disposition; `dropped_fields` also lists any dropped birth fact. Retained calendar values never shift or clamp. Lexical name guards cover selected common names; the complete reviewed field contract must identify other date and cohort facts.

Run the isolated pure suite:

```bash
uv run --no-project --python 3.13 --with pytest==9.2.0 --with hypothesis==6.170.15 python -m pytest tests/test_native_currency.py
```

The existing package pins and drivers below reproduce the archived experiments. New policy analysis requires the qualified managed `policyengine` interface described in the proposed protocol and entity-aware MicroSeries operations for weighted statistics.

## Counterfactual qualification status

A November 14, 2026 compatibility check in `policyengine` 6.19.0 refused the development target declaring US 2.124.0 and Core 3.36.0 at country source `43ca7bd3cd8615cac187db1b270ec2c3dd77f85f`. That certificate bound the 20260915 data release. Qualification of any replacement target must verify genuine package identities and prepared inputs; identical raw H5 bytes do not establish compatibility.

## Reproducing archived experiments

```bash
uv venv --python 3.13 && uv pip install -e ".[test]" && source .venv/bin/activate
Expand All @@ -56,6 +80,8 @@ Each part needs about 11 GB of memory. To queue the runs under a memory limit, s

Each result file records the repository commit and a hash of the cliffs2017/ code that produced it. The final results in this repository came from commit cd77a87, whose cliffs2017/ code hashes to 04f6b6c3. The files in results/counted_once/ came from commit cd77a87; each part stops unless it reproduces the counts of the committed run it rebuilds. results/take_up_bounds.json came from commit 5a53e32; the script reads the per-person files of the final runs, which those runs write and git ignores, and stops unless the files reproduce each run's count. results/driver_intervals.json came from commit 79a52f4; scripts/driver_intervals.py reads the same files and stops unless they reproduce each run's counts, in total and by largest loss. results/health_only.json came from commit 13e1553; scripts/health_only.py reads the same files and stops unless they reproduce each headline count. results/csfp/reach_2025.json holds the number of people the model gives a Commodity Supplemental Food Program package. It came from commit efa0b34, before the runs set WIC take-up, and no formula behind that program reads WIC. The Medicaid totals in results/medicaid/ also predate cliffs2017/wic_take_up.py, and tests/test_wic_take_up.py checks on a sample that setting WIC take-up from the draw leaves Medicaid's sums unchanged. We last regenerated the parameter and formula audit files before cliffs2017/wic_take_up.py existed (commits 3286bdd and 6915a57).

The run provenance digest covers every Python and CSV file under `cliffs2017/`, including the currency helper. A new helper changes that digest even when the archived calculation drivers remain untouched. The combination and part-scaling checks reject runs with different code digests. Reproduce an archived run from its recorded code version, or regenerate all compared parts together at one version; do not mix old and new parts or bypass the checks.

## License

MIT
1 change: 1 addition & 0 deletions changelog.d/counterfactual-currency.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add exact input-currency conversion, recorded age-led birth-fact dispositions, bounded numeric validation and synthetic tests, with a proposed protocol for historical-law comparisons on one recent reference population. Population estimation requires a qualified model/data pair and native-year adapter.
9 changes: 9 additions & 0 deletions ci/pure-test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Pure tests only: CPython 3.13 on Linux x86_64. Do not install this project.
# Metadata-derived pins; no dependency resolver or installation ran during preparation.
pytest==9.2.0 --hash=sha256:07acdcf88ec174f907dc01af70bf52d49b014bbab03faeeade31c96b18c2e588
hypothesis==6.170.15 --hash=sha256:f25261d1656f830a78863844be5fb55cd0208154dc9ddec85d44fe691488c557
iniconfig==2.3.1 --hash=sha256:9121e2c1fdb355232495be3194c8dfe87ccc2d5dee45947b78e68f499790d7a7
packaging==26.3 --hash=sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c
pluggy==1.7.0 --hash=sha256:7dd7b0d8832ba3cb632c306926ded123429211b83641b35dc5c41ad2d34f9bec
pygments==2.21.0 --hash=sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9
sortedcontainers==2.4.0 --hash=sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0
Loading