Skip to content

Restore real Medicaid cost in partner contract tests#8539

Open
hua7450 wants to merge 2 commits into
PolicyEngine:mainfrom
hua7450:restore-medicaid-cost-partner-tests
Open

Restore real Medicaid cost in partner contract tests#8539
hua7450 wants to merge 2 commits into
PolicyEngine:mainfrom
hua7450:restore-medicaid-cost-partner-tests

Conversation

@hua7450
Copy link
Copy Markdown
Collaborator

@hua7450 hua7450 commented May 29, 2026

Summary

Partner contract tests under tests/policy/baseline/partners/** were patched in #8499 with injected medicaid_cost_if_enrolled inputs so their asserted outputs would not move after that PR removed the medicaid_cost_if_enrolled formula (making it data-backed). Now that #8538 has restored a real formula (SLCSP age / family-tier / location cost index), those injected inputs are stale overrides that bypass the formula — the tests pass without exercising it.

This PR removes the injected inputs and re-derives the expected outputs from the live model, so the partner tests reflect what the API actually returns.

⚠️ Partner-facing impact

These are API partner contract tests. Removing the injected inputs changes the asserted medicaid dollar amounts (old per-capita-by-eligibility-group values → new SLCSP-index values), e.g.:

  • medicaid: 4367.51 → 10074.67, 4367.51 → 9876.63 (TX adult couple)
  • medicaid: 22373.06 → 9236.48 (aged/disabled single)
  • medicaid: 3258.31 → 7954.03 (CA child), 4580.0 → 10936.13 (MyFriendBen)

This is a genuine contract change for amplifi and my_friend_ben; analytics_coverage is the internal coverage suite. Team and API partners were notified before making this change (three-question partner-test gate completed).

Invariant preserved: only dollar amounts move. Every eligibility/category output — is_medicaid_eligible, medicaid_category, msp_category, wic_category, school_meal_tier, etc. — is byte-for-byte unchanged. The regeneration was guardrailed to halt on any boolean/enum change; it reported 0 such changes across all 42 files.

Method

For each test: removed the medicaid_cost_if_enrolled input, rebuilt the simulation exactly as the YAML runner does, recomputed each asserted output, and surgically replaced only the changed numeric values (anchors, comments, and all other lines untouched).

Diff: 42 files, +259 / −516 (258 injected inputs removed + 258 old medicaid values replaced by their recomputed values).

Test plan

Verified subfolder-by-subfolder (policyengine-core test <folder> -c policyengine_us), all passing:

Subfolder Result
amplifi 4 passed
my_friend_ben 2 passed
analytics_coverage/.../cash/ssi 32 passed
analytics_coverage/.../composition/cash_health 6 passed
analytics_coverage/.../healthcare/aca_ptc 38 passed
analytics_coverage/.../healthcare/chip 28 passed
analytics_coverage/.../healthcare/medicaid 33 passed
analytics_coverage/.../healthcare/msp 5 passed
analytics_coverage/signatures 81 passed

Related: #8499 (removed the formula), #8538 (restored it).

🤖 Generated with Claude Code

PolicyEngine#8499 removed the medicaid_cost_if_enrolled formula (making it data-backed)
and patched every partner contract test with injected
`medicaid_cost_if_enrolled: <old per-capita-by-group value>` inputs so the
asserted outputs would not move. In a single-household/API context those
values masked the fact that the API returned 0, and after PolicyEngine#8538 restored a
real (SLCSP-index) formula they became stale overrides bypassing it.

Remove the injected inputs and re-derive the expected outputs from the live
formula. Only `medicaid` dollar amounts change; every eligibility flag and
category enum (is_medicaid_eligible, medicaid_category, msp_category,
wic_category, school_meal_tier, ...) is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@daphnehanse11 daphnehanse11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: the Medicaid SLCSP family-tier classification is using the full tax unit, not the people whose Medicaid cost is being indexed. medicaid_slcsp_family_tier_category counts all dependent children and derives adult_count from tax_unit_size, then medicaid_slcsp_family_tier_person_share divides the family tier premium by tax_unit_size. In New York, a single Medicaid child with two non-Medicaid parents classifies as TWO_ADULTS_AND_ONE_OR_MORE_CHILDREN and gets a 645.99994 cost index in my local repro; the same child alone is CHILD_ONLY with a 280.16 index. Since the denominator later only weights medicaid_enrolled people, non-Medicaid tax-unit members are driving Medicaid cost allocation. Please build the tier counts/share from Medicaid SLCSP covered people/enrollees, or otherwise exclude non-Medicaid members from the family-tier classification.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c52e3d0) to head (2bae1e9).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #8539      +/-   ##
===========================================
+ Coverage   97.83%   100.00%   +2.16%     
===========================================
  Files          12         3       -9     
  Lines         185        68     -117     
  Branches        3         0       -3     
===========================================
- Hits          181        68     -113     
+ Misses          4         0       -4     
Flag Coverage Δ
unittests 100.00% <100.00%> (+2.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants