Restore real Medicaid cost in partner contract tests#8539
Conversation
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>
daphnehanse11
left a comment
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Partner contract tests under
tests/policy/baseline/partners/**were patched in #8499 with injectedmedicaid_cost_if_enrolledinputs so their asserted outputs would not move after that PR removed themedicaid_cost_if_enrolledformula (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.
These are API partner contract tests. Removing the injected inputs changes the asserted
medicaiddollar 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
amplifiandmy_friend_ben;analytics_coverageis 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_enrolledinput, 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
medicaidvalues replaced by their recomputed values).Test plan
Verified subfolder-by-subfolder (
policyengine-core test <folder> -c policyengine_us), all passing:amplifimy_friend_benanalytics_coverage/.../cash/ssianalytics_coverage/.../composition/cash_healthanalytics_coverage/.../healthcare/aca_ptcanalytics_coverage/.../healthcare/chipanalytics_coverage/.../healthcare/medicaidanalytics_coverage/.../healthcare/mspanalytics_coverage/signaturesRelated: #8499 (removed the formula), #8538 (restored it).
🤖 Generated with Claude Code