Repository navigation
Conversation
Cliff-watch set totals and derived variables as inputs. An input on a policyengine-us variable that is computed from others replaces the computation, so every rule reading a component or sibling saw zero: - pension_income left taxable_pension_income, and so AGI and income tax, at 0; pensions now go to taxable_private_pension_income, with a new government pension field on taxable_public_pension_income. - social_security left social_security_retirement at 0 and dropped SSDI from the total; it now sets social_security_retirement. - dividend_income taxed all dividends as ordinary income; it now sets qualified_dividend_income. - A tanf_gross_earned_income override on a second earner fixed the head's at 0, freezing TANF (and TANF-linked Head Start and WIC) across the earnings axis. Only employment_income is set now. - The household path's aca_magi/medicaid_magi estimate left out Social Security; policyengine-us now derives MAGI on both paths. - snap_assets hid savings from TANF and SSI resource tests; savings go to bank_account_assets. - utility_expense gave no SNAP utility allowance; utilities go to heating_cooling_expense. Pins policyengine-us 1.755.5, policyengine-core 3.28.0 and spm-calculator 0.3.1 and commits uv.lock. That environment reproduces production byte for byte. An unpinned redeploy would install 2.15.16, which crashes the API. Adds Hypothesis and fast-check invariants checked against the policyengine-us variable graph, a JS-vs-Python builder differential, a household-vs-series differential, engine-pinned regressions, opt-in live-API checks, and a CI test workflow. Moves frontend tests to Vitest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main added seriesRefine.test.js on node:test after this branch moved the frontend suites to Vitest, so the rebased suite found no tests in it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
policyengine-us adds the 20 gross income sources one at a time in float32, so irs_gross_income can differ from the exact sum by up to 20 * 2**-24 of itself. An Alaska household with $523,288 of miscellaneous income and $1 of SSDI computes $0.85 of taxable benefits, but gross income comes back $0.875 above the other income, so the fixed $0.01 tolerance failed on Hypothesis' random draws. The tolerance now scales with that bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Savings go to a spouse only when the spouse is 65 or over or blind, the engine's own SSI test: the Disabled checkbox never sets meets_ssi_disability_criteria, so it made a disabled head keep the savings that an aged spouse's resource test needed. Both builders change; new tests cover that couple and compare _could_claim_ssi with the engine. - New invariant: neither builder sets a formula variable unless KNOWN_COMPUTED_INPUTS lists it with what the input replaces. - The gross-income invariant compares with the engine's taxable_social_security instead of a 0-85% band, and pins the September float32 household as an @example. - The changelog no longer credits this PR with #41's pins and workflow, and notes the relabelled fields; the JS differential states its scope. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Depend on policyengine[us], whose extra pins policyengine-us 2.2.1, policyengine-core 3.33.3 and spm-calculator 1.0.0. A new engine module turns the calculator's situations into calculate_household's arguments and answers its reads from the result, so the builders, the JS differential and the payload invariants keep working. Read SNAP and WIC for the calendar year, drop ccdf_age_group, which 2.2.1 removes, and take away the try/except around TANF and child care, since those reads no longer run on their own. New tests compare every read with a direct Simulation and run all 51 states on both paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
policyengine-us now reads missing hours as zero rather than 40, and zero hours fail its work tests at every earnings level. CliffWatch doesn't ask about hours, so on the new engine a childless adult lost SNAP at every earnings level and a working parent lost child care subsidies in the states whose activity tests read hours. Both builders now send 40 hours for every adult, which keeps those results as they were and matches the CCDF activity test they already mark as met. Medicaid's community engagement test reads a second hours variable from 2027, so they set that too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vercel's runtime installs public packages into /tmp when an instance starts. An install that stops partway leaves its files behind, and on the 5 November windows every later attempt on that instance failed with "No space left on device". Drop plotly, tables, hf-xet and jedi from the install, none of which a household calculation imports, and give policyengine-us a URL source so it stays in the zip. The install now occupies 239 MiB rather than 390 MiB and a complete one fits on top of a stopped one, which a new test enforces. Raise the calculation routes to 120 seconds, since loading the engine takes about 40 on a cold instance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
importlib.metadata raises TypeError on path=None rather than falling back to sys.path, so the Linux-only test failed in CI. Mac runs skip that test, which hid it. Also note in the README that a bump moves the wheel URL too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
force-pushed
the
claude/cliffwatch-on-policyengine-py
branch
from
November 5, 2026 05:36
0faae1c to
241456e
Compare
policyengine-us added Maryland's county income tax to household_state_tax_before_refundable_credits (changelog 1.756.0), so the chart's "State taxes" number rose by up to $3,424 at $100,000 of earnings in Maryland. The form doesn't ask for a county, and the engine falls back to Allegany County's 3.03% rate. Rename the line "State and local taxes" and state the assumption in the README's scope notes, along with what the wider-grid attribution found about the TANF enrollment flag and Florida's disregard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 5, 2026
Main now carries #40, whose files match this branch's base, and #46, which removes the cold-start install on main's engine. This branch's engine takes the function past Vercel's 225 MiB bundle again, so the port keeps its install-fits-twice test and README section, adding #46's 4 KiB block wording, its note that main requires no checks, the size walk's sanity floor and the CI summary line. The pyproject comment now names policyengine-us as the package that brings in tables, as uv.lock shows. The cold-start changelog entry becomes a change from main rather than a fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
changed the base branch from
claude/blissful-zhukovsky-0d720c
to
main
November 6, 2026 00:58
Conflicts: - cliff_watch/calculator.py keeps the engine bridge's import beside #47's zip_county import. - cliff_watch/variable_graph.py lists is_tanf_enrolled and slcsp_rating_area. This branch already keeps ssi in REVIEWED_TOTAL_INPUTS, so main's duplicate entry goes. #47's engine test built its direct Simulation through calculator._load_simulation, which this branch removed. It now imports Simulation from policyengine_us, as the other engine tests do, and its 27 tests pass on policyengine-us 2.2.1. The README's Maryland note now follows the county the API resolves from the ZIP. Regenerating the variable-graph snapshot on 2.2.1 reproduces the merged file, which adds #47's zip_code, slcsp_rating_area and takes_up_housing_assistance_if_eligible. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The port dropped `import sys` from cliff_watch/calculator.py, so `python -m cliff_watch.calculator -` raised NameError when it read a payload from stdin. tests/test_cli.py reads a payload from stdin and from a file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PolicyEngine/policyengine.py#739 merged on 9 November, and 6.17.1 on PyPI contains it. Its `us` extra still pins policyengine-us 2.2.1, policyengine-core 3.33.3 and spm-calculator 1.0.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The git pin kept policyengine in the function's zip, and the registry pin sent it to the cold-start install, so test_url_sourced_packages_stay_in_the_zip failed. The PyPI wheel URL keeps it in the zip, as policyengine-us's does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
pe.us.calculate_householdfrom policyengine.py. One pin,policyengine[us]==6.17.1, now sets the engine: policyengine-us 2.2.1, policyengine-core 3.33.3 and spm-calculator 1.0.0. policyengine.py shipped #739 in 6.17.1. It letscalculate_householdtake several marital units, which a married couple with a child needs for Medicaid and SSI.main, removed the install frommain's engine./api/calculate,/api/seriesand/api/householdsget 120 seconds, since the first request on an idle instance takes 44 to 58 seconds.API callers see two other changes. A household needs someone aged 18 or older, because the engine's default outputs measure SPM poverty. Years outside 2022 to 2035 raise an error, since spm-calculator's forecast has no entry for them.
Impact
The grid runs four households through the 50 states and DC in 2026 and 2027, at earnings from $0 to $100,000 in steps of $2,500: 408 series and 16,728 points. A single adult aged 30, a parent aged 30 with children aged 5 and 8, a couple aged 35 and 33 with a 2-year-old, and a 62-year-old with an $18,000 private pension make up the households. One adult in the couple earns, and both families pay $8,000 a year for child care. The grid sends no ZIP, so the engine gives every household its state's first county alphabetically and, in Maryland, Allegany County's income tax rate.
Against
main, 24,110 displayed amounts move by $0.50 or more, and every one traces to a cause. policyengine-us 2.2.1 moves 23,625 of them, 7,471 together with the annual SNAP and WIC reads. The annual reads alone move 455, and the hours input moves 30 Maryland TANF amounts. At every point, the port's amounts match a direct policyengine-us simulation of the same household.frontend/src/policyengineApi.jsstill multiplies January by twelve in its own reads, but the app imports onlybuildCliffDriversfrom that file, and that function works from the annual series.Head Start, Early Head Start and school meals
Both engines count a full year of these services once a family gets SNAP in any month.
is_head_start_categorically_eligibletests annual SNAP, TANF or SSI, andhead_startandearly_head_startreturn a year of state spending per enrolled child.school_meal_tierreads an annual categorical test the same way. So a calendar-year chart counts three months of SNAP as 3/12 of a year's SNAP and 12/12 of the services it unlocks.main's engineThe pattern predates the port. Across the grid,
main's engine shows $11,244 to $31,542 of these services at 90 points where the chart shows SNAP, TANF and SSI at zero. The chart reads January's SNAP, and the engine reads the year. For example, a couple with a toddler in Nevada at $52,500 in 2026 gets $16.90 of SNAP a month from October, and with it $26,419.82 of Early Head Start. At $55,000, the couple loses both. This PR shows the SNAP at each of those points, and its engine pays $26.72 a month at the Nevada point.The port adds six such points, in Alaska and Arizona, and removes none:
main's engine misses a benefit by $2.35 a month, with a $1,037.75 maximum against a $1,040.10 contribution. This PR's engine pays $11.84, with a $1,050.84 maximum against $1,039. With that SNAP, the engine counts $22,646 of Head Start and $3,710 of school meals for the parent, and $24,960 of Early Head Start for the couple.This PR leaves open whether policyengine-us should prorate these values by qualifying months or the chart should keep them and say so.
Every cause on the grid
A point can have several causes, so the counts overlap.
hours_worked_last_week, which raises Maryland's TANF child care deductionWork hours
policyengine-us 1.794.3 moved the default for
weekly_hours_worked_before_lsrfrom 40 to 0, so a household that sends no hours fails the engine's work-hours tests at every earnings level. The form doesn't ask about hours, and both situation builders already mark the household as meeting the child care activity test. So_base_person_datasends 40 weekly hours for each person aged 18 or over, including an adult with no earnings. For Medicaid's community engagement test, which starts in 2027, the engine reads a different variable,hours_worked_last_week, so the builders send 40 there too.On the 51-state grid, the hours inputs change displayed amounts from
mainin one program: Maryland TANF.md_tca_childcare_deductiontakes the highest adult monthly hours, which come fromhours_worked_last_weekand stay at zero onmain. It caps the child care deduction at $200 a month per child at 100 hours or more, against $100 below. For example, the parent at $10,000 goes from $5,436 to $7,836 a year, and the couple at $5,000 from $7,236 to $8,436.Everywhere else the inputs keep
main's amounts, some by a different route. policyengine-us 2.2.1 exempts a 30-hour worker from SNAP work registration and takes that worker out of Medicaid's SNAP pass-through, so the engine now tests the single adult's 2027 Medicaid againsthours_worked_last_week. Without either input, the grid would lose these amounts:Idaho's state refundable credits would rise $155 for the single adult at $0 in 2026. Without
hours_worked_last_weekalone, the single adult would lose 2027 Medicaid in 40 states, up to $15,892.72 in Washington.DC and Montana keep that Medicaid until both inputs go. Both builders declare TANF enrollment in every month when the form selects TANF, even where the engine pays no TANF, and the weekly hours pass those states' TANF work tests. policyengine-us counts the declared enrollment toward Medicaid's pass-through, which exempts a childless adult who gets no TANF from Medicaid's work test.
maindeclares enrollment the same way.Like production, the chart can't show adults who don't work losing benefits to the One Big Beautiful Bill Act's work tests. The README's scope notes state the assumption, and an hours field on the form would let the chart show those tests.
Packaging and cold start
#46's trim brought
main's engine under Vercel's 225 MiB limit, so no install runs there. This engine adds 73 MiB of dependencies, 57 MiB of it fromspm-calculator1.0.0, whose two forecast files take 49 MiB. The install comes back in a smaller form:override-dependenciesremoves the same packages as Remove the cold-start install by trimming packages a calculation never imports #46:plotly,tables(withblosc2,msgpackandndindex),hf-xetandjedi(withparso).policyengine-uskeeps it in the function's zip and out of the install.uv lockfails if the URL's version disagrees with the onepolicyengine[us]pins.maindpl_fBK2zhv7sdoyGi2D3D81eJKSc6csdpl_BKG12Jgi9r3zn8jvjVsAwXEs3xhVdpl_6NTuKPaXjc71rRA9zbFpiHWMbefj/tmpafter a cold start/tmp/api/serieson a fresh instance/api/seriesAfter all three previews sat idle and then took requests together on 5 November, the first
/api/seriestook 34.54 s before #46, 32.82 s on #46 and 45.47 s on this PR.In every test that stopped this PR's install between 0.3 and 1.5 seconds, the next run succeeded. A stop at 1.5 seconds leaves 237.1 MiB, the worst case, and the retry peaks at 480 MiB; by 2 seconds the install has finished. Two previews test the same thing in the platform's own init path.
concurrent-downloads = 1,main's tree before Remove the cold-start install by trimming packages a calculation never imports #46 failed with production's error (dpl_DcSE4aRRtTVfmj9H5TLNXGRJwm39). This tree kept every route at 200 on all three rounds, with only the finished install in/tmp(dpl_2GMbGWf2CnyRxQm39R2ocK7qZcDN).compile-bytecode = true(dpl_21MyaobJYW6ar2xVa2qJHfHkbs6y) pushes this tree's install past the limit./tmpthen holds a stopped attempt's 239.5 MiB directory beside the finished install, and every route still returns 200 on all three rounds.tests/test_deploy_footprint.pyfails when a complete install stops fitting on top of a stopped one, using the same 4 KiB block count the measurements use. If it fails after a version bump, givespm-calculatora URL source next; on a preview, that cut/tmpto 182.2 MiB (dpl_89Z64sLSFEQyNdMukVXrNZvWxWoY). This PR holds that back: this set already fits, and one URL pin costs less to maintain than two.First requests take longer
The engine accounts for the extra time on a fresh instance.
mainpolicyengine_corepolicyengine_uspolicyengineOn a Mac,
import policyenginespends about half of its own time hashing 12,259 of policyengine-us's source files for a data-build fingerprint, which a household calculation doesn't read. At import, policyengine.py feeds that fingerprint to a dataset compatibility check that can raise an error. Its maintainers could defer the hash, or policyengine-us could compute it when it builds its wheel.After idling, this PR's previews answered every first request with 200:
/api/seriesin 43.68 to 51.2 seconds,/api/calculatein 45.12 to 51.15,/api/householdsin 49.3 to 57.85 and/api/metadatain 3.79 to 4.47. Sixty seconds would run close, sovercel.jsongives the three calculation routes 120.Invariants
engine.py's translation keeps every input and puts each person in exactly one marital unit (test_kwargs_keep_every_input_and_each_person_in_one_marital_unit, property test).calculate_householdcan't carry: values that vary within a year, and a tax unit or other shared group that doesn't hold one group of everyone in order (test_kwargs_refuse_values_that_vary_within_the_year,test_kwargs_refuse_anything_but_one_group_of_everyone).calculate_householdequals a directSimulationof the same situation, for fixed households and for generated ones that carry Resolve a household's county from its ZIP code #47's ZIPs, counties and rating-area overrides (test_every_read_matches_a_direct_simulationandtest_reads_match_a_direct_simulation_for_any_household, the differential tests).test_every_state_computes_on_both_paths).test_snap_and_wic_are_calendar_year_sums).test_every_adult_and_nobody_else_carries_the_assumed_hours, property test).uv.lockagrees withuv exporton what the function contains (tests/test_deploy_footprint.py).Plan
calculate_householdarguments incliff_watch/engine.py, and answer the calculator's reads from the result.Simulation, all 51 states on both paths, and the translation and result layout with property tests.mainwith Resolve a household's county from its ZIP code #47's county from ZIP into this branch, and get Resolve a household's county from its ZIP code #47's engine tests passing on policyengine-us 2.2.1./api/metadata.mainhas it./api/metadata.axiom: n/a: cliff-watch app engine dependency; no policy encoding change
🤖 Generated with Claude Code