Skip to content

Model 2027 coverage in the calculator API, with 2026 current law alongside - #33

Closed
DTrim99 wants to merge 5 commits into
mainfrom
aca-2027-backend
Closed

DTrim99 wants to merge 5 commits into
mainfrom
aca-2027-backend

Conversation

@DTrim99

@DTrim99 DTrim99 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR lets the calculator API model 2027 coverage under current law and under H.R. 1834, and return 2026 current law for the same household alongside. Requests without a year still get 2026, so the live page's answers don't change until the calculator frontend (#34) asks for 2027.

It is the backend part of the 2027 update, which now tells one story: how premiums rise from 2026 to 2027 under current law, and what reviving the enhanced credits would do. It pins policyengine-us 2.115.0, the first release with the published 2027 premiums (PolicyEngine/policyengine-us#10682).

What changes

  • Year. Requests take year, 2026 or 2027 (2026 if absent). The household's inputs, every simulation period and both cache keys follow it. Responses report year, fpl_year and model_version.
  • 2026 alongside 2027. A 2027 request with show_prior_year also gets 2026 current law for the same household and incomes: ptc_prior_year, slcsp_by_income_prior_year and fpl_prior_year. The API runs it in parallel with the 2027 scenarios. A 2026 request can't ask for it, since the API doesn't model 2025.
  • The poverty line. The credit measures income against the prior year's poverty guideline (aca_magi_fraction), but the API reported the coverage year's: $15,960 instead of $15,650 for a single person's 2026 coverage. It now reports the prior year's, so the page's FPL lines and its "% FPL" figures match the credit.
  • Alaska and Hawaii. The household's state was set only for the coverage year, so the prior-year guideline fell back to the 48 states' figure. A single 40-year-old in Anchorage earning $40,000 got a 2027 credit of $9,177 instead of $9,947. The state is now set for both years.
  • Scenarios. One table now drives both calculator endpoints, which had duplicated the scenario code. show_ira is H.R. 1834: the enhanced (ARPA/IRA) schedule for 2026–2028, with no income limit. It passed the House on January 8, 2026 and has not been enacted. Its reform now ends with the bill, in 2028, where the old IRA-extension reform ran to 2100; 2026 and 2027 results are unchanged. The 700% FPL bill and CRFB's two brackets are unchanged. The calculator page stops offering them in Compare 2026 and 2027 current law with H.R. 1834 in the calculator #34, but the live page uses them until then, so a follow-up can remove them from the API.
  • slcsp_by_income. The benchmark premium at each income, for the household members who'd buy a marketplace plan, so the page can show what the benchmark plan costs after the credit.
  • AI explanations. The prompt takes the year, names H.R. 1834, says every scenario is a proposal rather than law, and attributes the CRFB brackets' cost estimates to CRFB. With show_prior_year it also compares the 2026 and 2027 benchmark premiums and credits. Its cache key includes the year, show_prior_year and the model version.
  • policyengine-us 2.115.0, from 1.691.3, with the policyengine-core (3.34.9) and spm-calculator (1.1.0) versions it requires; every other pin is unchanged. It has the 2027 applicable percentages, the bracket variants' eligibility fix (Apply the baseline ACA coverage exclusions in the bracket reforms policyengine-us#10680) and the published 2027 premiums.
  • Memory. The Modal function's memory goes from 2 GB to 4 GB. policyengine-us 2.x takes about 0.9 GB to load, and a process reached 2.4–2.9 GB after running the scenarios' reforms.
  • Smoke test. After a deploy it also checks a 2027 calculation with 2026 alongside, and that it uses the 2026 guideline.

An earlier version of this PR also modeled two January 2026 draft variants of H.R. 1834 (a 700% FPL cap and a $5 minimum premium). The update now compares only current law and H.R. 1834, so they're gone.

Results

A single 45-year-old in Lebanon County, PA (policyengine-us 2.115.0). Annual credits, with what the benchmark plan costs after them each month. The benchmark premium is $13,523 a year in 2026 and $14,837 in 2027.

Income (% FPL for 2027 / 2026 credits) 2026 current law 2027 current law 2027 H.R. 1834
$24,000 (150% / 153%) $12,482 ($87/mo) $13,805 ($86/mo) $14,837 ($0/mo)
$40,000 (251% / 256%) $10,086 ($286/mo) $11,373 ($289/mo) $13,237 ($133/mo)
$56,000 (351% / 358%) $7,945 ($465/mo) $9,113 ($477/mo) $10,777 ($338/mo)
$72,000 (451% / 460%) $0 ($1,127/mo) $0 ($1,236/mo) $8,717 ($510/mo)
$104,000 (652% / 665%) $0 ($1,127/mo) $0 ($1,236/mo) $5,997 ($737/mo)
$120,000 (752% / 767%) $0 ($1,127/mo) $0 ($1,236/mo) $4,637 ($850/mo)

Below 400% FPL, current law caps the household's payment at a share of income, so the 2027 credit grows with the premium and the payment barely moves. Above it, the household pays the whole premium, $109 a month more in 2027.

Tests

  • Run in CI: tests/test_api_scenarios.py, with the image's exact packages:
    • requests without a year get 2026, and other years are refused;
    • only 2027 requests can ask for 2026 alongside;
    • the cache key names the year, the 2026 comparison and the model version;
    • a 2027 answer reports the 2026 guideline, and Alaska gets its own;
    • current law ends the credit at 400% FPL in 2027;
    • H.R. 1834 charges nothing below 150% FPL and continues above 400%;
    • 2026 current law comes back for the same incomes, measured against the 2025 guideline and ending at 400% of it;
    • the 700% FPL bill and the CRFB brackets still run for 2027;
    • a scenario that's off returns zeros, and the 2026 fields are empty unless asked for.
  • CI: 63 passed across the five API test files, with the image's exact packages (on 5d7a10d, which merges current main).

🤖 Generated with Claude Code

- Requests take a year, 2026 or 2027 (2026 if absent, so the live page's
  answers don't change), and every period, the household and both cache
  keys follow it. Responses report the year, the guideline's year and the
  policyengine-us version.
- The FPL the API reports is now the prior year's guideline, the one the
  credit uses, and the household's state is set for that year too, so
  Alaska and Hawaii households get their own guideline for it.
- One scenario table drives both calculator endpoints. New: the enhanced
  schedule capped at 700% FPL, and the enhanced schedule with a $5 minimum
  premium, which returns a 400 until policyengine-us models it (#10681).
  H.R. 1834's reform ends in 2028, as the bill does.
- Responses include the benchmark premium at each income.
- The AI explanation prompt takes the year and names the new scenarios.
- Pin policyengine-us 2.105.0 (policyengine-core 3.34.9, spm-calculator
  1.1.0), give the Modal function 4 GB, and smoke-test a 2027 answer after
  each deploy.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
aca-calc Ready Ready Preview Nov 11, 2026 2:48pm UTC

Request Review

…remium

2.115.0 is the first release with the published 2027 premiums
(policyengine-us #10682) and the minimum premium reform (#10681), so the $5
minimum premium scenario now runs. The tests check that it leaves $60 a year
where H.R. 1834's credit covers the whole benchmark and matches H.R. 1834
where the household pays more, and that a model without it still gets a 400
that says so. Its requirements are those of 2.105.0.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The calculator now compares 2027 current law with H.R. 1834 and shows 2026
current law beside them, so the January 2026 draft variants (the 700% FPL
cap and the $5 minimum premium) go. A 2027 request with show_prior_year
also gets 2026 current law for the same household and incomes:
ptc_prior_year, slcsp_by_income_prior_year and fpl_prior_year. The smoke
test asks for it, and the explanation prompt uses it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@DTrim99 DTrim99 changed the title Model 2027 coverage and the extension scenarios in the calculator API Model 2027 coverage in the calculator API, with 2026 current law alongside Nov 9, 2026
ACA_API_APP_NAME names the Modal app (aca-calc-api by default). A preview
deploy, such as aca-calc-api-preview, gets caches of its own, and the image
carries the name so its containers open them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DTrim99

DTrim99 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Combined into #37, which now holds the whole 2027 update (API, calculator and Overview) so nothing reaches the live app until we relaunch. Review it on #37's Vercel preview, which calls the preview API. This branch stays as is.

@DTrim99 DTrim99 closed this Nov 12, 2026

This branch was successfully deployed

1 active deployment
Preview — fb7bbb64 Deployed Nov 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant