From ca85b7ebd1222905242ed80d32980601ab241ff5 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Thu, 12 Nov 2026 00:59:24 -0500 Subject: [PATCH 01/11] Limit school meal categorical eligibility to each qualifying child Co-Authored-By: Claude Opus 5.5 --- ...chool-meals-head-start-enrollment.fixed.md | 1 + .../school_meals/categorical_eligibility.yaml | 9 +- ...meal_categorical_eligibility_invariants.py | 222 ++++++++ ...is_school_meal_categorically_eligible.yaml | 517 ++++++++++++++++++ ...s_school_meal_categorical_eligibility.yaml | 64 ++- .../usda/school_meals/free_school_meals.py | 26 +- .../is_school_meal_categorically_eligible.py | 39 ++ ...ets_school_meal_categorical_eligibility.py | 10 +- .../reduced_price_school_meals.py | 26 +- .../school_meal_child_breakfast_tier.py | 23 + .../school_meal_child_lunch_tier.py | 23 + .../school_meals/school_meal_daily_subsidy.py | 48 +- .../gov/usda/school_meals/school_meal_tier.py | 6 +- .../person/is_enrolled_in_head_start.py | 8 + .../demographic/person/is_homeless_child.py | 19 + .../demographic/person/is_in_foster_care.py | 8 +- 16 files changed, 979 insertions(+), 70 deletions(-) create mode 100644 changelog.d/fix-school-meals-head-start-enrollment.fixed.md create mode 100644 policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py create mode 100644 policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml create mode 100644 policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py create mode 100644 policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py create mode 100644 policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py create mode 100644 policyengine_us/variables/household/demographic/person/is_homeless_child.py diff --git a/changelog.d/fix-school-meals-head-start-enrollment.fixed.md b/changelog.d/fix-school-meals-head-start-enrollment.fixed.md new file mode 100644 index 00000000000..fb949b432a8 --- /dev/null +++ b/changelog.d/fix-school-meals-head-start-enrollment.fixed.md @@ -0,0 +1 @@ +Limited Head Start, foster, homeless, migrant and runaway school-meal eligibility to each qualifying child, and required Head Start enrollment. diff --git a/policyengine_us/parameters/gov/usda/school_meals/categorical_eligibility.yaml b/policyengine_us/parameters/gov/usda/school_meals/categorical_eligibility.yaml index 4b84f6d69aa..729a4845f41 100644 --- a/policyengine_us/parameters/gov/usda/school_meals/categorical_eligibility.yaml +++ b/policyengine_us/parameters/gov/usda/school_meals/categorical_eligibility.yaml @@ -1,4 +1,4 @@ -description: Program participation that qualifies families for free school meals. +description: Program participation that qualifies every child in a family for free school meals. values: 2009-09-01: @@ -7,11 +7,6 @@ values: - tanf # Temporary Assistance to Needy Families. Currently only available in CA and IL. - receives_tanf # Reported TANF receipt, for households the model gives a $0 benefit. - fdpir # Food Distribution Program on Indian Reservations. - - was_in_foster_care - - is_homeless - - is_runaway_child - - is_migratory_child - - is_head_start_eligible metadata: unit: list @@ -20,5 +15,7 @@ metadata: reference: - title: 7 CFR § 245.2 - Definitions href: https://www.law.cornell.edu/cfr/text/7/245.2 + - title: 7 CFR § 245.6(b)(7)-(8) - Household and child categorical eligibility + href: https://www.ecfr.gov/current/title-7/section-245.6#p-245.6(b)(7) - title: 42 U.S. Code § 1758 - Program requirements href: https://www.law.cornell.edu/uscode/text/42/1758#b_5 diff --git a/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py b/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py new file mode 100644 index 00000000000..0e3848089d6 --- /dev/null +++ b/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py @@ -0,0 +1,222 @@ +"""Check categorical eligibility across generated sibling configurations. + +Each draw runs independent SPM units together, reusing one read-only system. +We vary siblings, income tiers, enrollment, K-12 attendance and receipt months. +The paired units hold their poverty ratios fixed when a child joins them. +""" + +import numpy as np +import pytest +from hypothesis import HealthCheck, given, settings +from hypothesis import strategies as st + +from policyengine_us import Simulation + +YEAR = 2025 +MONTHS = tuple(f"{YEAR}-{month:02d}" for month in range(1, 13)) +CHILD_CATEGORIES = ( + "is_enrolled_in_head_start", + "is_in_foster_care", + "is_homeless_child", + "is_runaway_child", + "is_migratory_child", +) +HOUSEHOLD_CATEGORIES = ("snap", "receives_snap", "tanf", "receives_tanf", "fdpir") +INCOME_TIERS = ((1.0, "FREE"), (1.5, "REDUCED"), (3.0, "PAID")) +# USDA's SY 2024-25 rates apply on January 1, 2025. Lunch uses the +# under-60-percent rate; breakfast uses the non-severe-need rate. +# https://www.govinfo.gov/content/pkg/FR-2024-07-10/pdf/2024-15175.pdf#page=4 +BREAKFAST_RATES = {"FREE": 2.37, "REDUCED": 2.07, "PAID": 0.39} +LUNCH_RATES = {"FREE": 4.43, "REDUCED": 4.03, "PAID": 0.42} +SCHOOL_DAYS = 180 + + +@pytest.fixture(scope="module") +def school_meal_system(): + return Simulation.default_tax_benefit_system_instance + + +@st.composite +def units(draw): + ratio, tier = draw(st.sampled_from(INCOME_TIERS)) + return { + "ages": draw(st.lists(st.integers(6, 17), min_size=1, max_size=3)), + "ratio": ratio, + "tier": tier, + "month": draw(st.sampled_from(MONTHS)), + "amount": draw(st.integers(1, 5_000)), + "added_in_k12": draw(st.booleans()), + } + + +def _person(age, in_k12): + return { + "age": {YEAR: age}, + "is_in_k12_school": {YEAR: in_k12}, + "is_head_start_eligible": {YEAR: False}, + "was_in_foster_care": {YEAR: False}, + **{ + name: {YEAR: False} + for name in CHILD_CATEGORIES + if name != "is_in_foster_care" + }, + "is_in_foster_care": dict.fromkeys(MONTHS, False), + } + + +def _situation(drawn_units): + people = {} + groups = {"spm_units": {}, "tax_units": {}, "families": {}, "households": {}} + records = [] + for unit_number, unit in enumerate(drawn_units): + variants = ( + "base", + "added", + *CHILD_CATEGORIES, + *HOUSEHOLD_CATEGORIES, + "is_head_start_eligible", + "was_in_foster_care", + ) + for variant in variants: + prefix = f"unit_{unit_number}_{variant}" + parent = f"{prefix}_parent" + people[parent] = _person(35, False) + members = [parent] + siblings = [] + for index, age in enumerate(unit["ages"]): + child = f"{prefix}_sibling_{index}" + people[child] = _person(age, True) + members.append(child) + siblings.append(child) + added = None + if variant != "base": + added = f"{prefix}_added" + people[added] = _person(5, unit["added_in_k12"]) + members.append(added) + if variant in CHILD_CATEGORIES or variant in ( + "is_head_start_eligible", + "was_in_foster_care", + ): + period = unit["month"] if variant == "is_in_foster_care" else YEAR + people[added][variant][period] = True + spm_unit = { + "members": members, + "school_meal_fpg_ratio": {YEAR: unit["ratio"]}, + "snap": dict.fromkeys(MONTHS, 0), + "tanf": {YEAR: 0}, + "fdpir": {YEAR: 0}, + "receives_snap": dict.fromkeys(MONTHS, False), + "receives_tanf": dict.fromkeys(MONTHS, False), + } + if variant in HOUSEHOLD_CATEGORIES: + period = YEAR if variant in ("tanf", "fdpir") else unit["month"] + value = True if variant.startswith("receives_") else unit["amount"] + spm_unit[variant][period] = value + groups["spm_units"][prefix] = spm_unit + groups["tax_units"][prefix] = {"members": members} + groups["families"][prefix] = {"members": members} + groups["households"][prefix] = { + "members": members, + "state_code": {YEAR: "AL"}, + "is_homeless": {YEAR: False}, + } + records.append( + { + "unit": unit, + "number": unit_number, + "variant": variant, + "members": members, + "siblings": siblings, + "added": added, + } + ) + return {"people": people, **groups}, records + + +def _check(drawn_units, system): + situation, records = _situation(drawn_units) + simulation = Simulation(situation=situation, tax_benefit_system=system) + person_index = {name: index for index, name in enumerate(situation["people"])} + categorical = np.asarray( + simulation.calculate("is_school_meal_categorically_eligible", YEAR), + dtype=bool, + ) + household_categorical = np.asarray( + simulation.calculate("meets_school_meal_categorical_eligibility", YEAR), + dtype=bool, + ) + tiers = { + meal: simulation.calculate( + f"school_meal_child_{meal}_tier", YEAR + ).decode_to_str() + for meal in ("breakfast", "lunch") + } + values = { + name: np.asarray(simulation.calculate(name, YEAR), dtype=float) + for name in ( + "school_meal_daily_subsidy", + "school_meal_net_subsidy", + "free_school_meals", + "reduced_price_school_meals", + ) + } + sibling_results = {} + for index, record in enumerate(records): + unit = record["unit"] + variant = record["variant"] + household = variant in HOUSEHOLD_CATEGORIES + assert household_categorical[index] == household + daily_total = 0 + net = free = reduced = 0 + school_children = 0 + for name in record["members"]: + person = person_index[name] + own_category = name == record["added"] and variant in CHILD_CATEGORIES + assert categorical[person] == (household or own_category) + expected_tier = "FREE" if household or own_category else unit["tier"] + for meal in tiers: + assert tiers[meal][person] == expected_tier + if not situation["people"][name]["is_in_k12_school"][YEAR]: + continue + school_children += 1 + daily = BREAKFAST_RATES[expected_tier] + LUNCH_RATES[expected_tier] + daily_total += daily + # Subtract the paid reimbursement once per child per meal. + annual = (daily - 0.39 - 0.42) * SCHOOL_DAYS + net += annual + free += annual if expected_tier == "FREE" else 0 + reduced += annual if expected_tier == "REDUCED" else 0 + expected = { + "school_meal_daily_subsidy": daily_total / school_children, + "school_meal_net_subsidy": net, + "free_school_meals": free, + "reduced_price_school_meals": reduced, + } + for name, amount in expected.items(): + np.testing.assert_allclose( + values[name][index], amount, atol=0.01, rtol=0, err_msg=variant + ) + siblings = [person_index[name] for name in record["siblings"]] + sibling_results[record["number"], variant] = ( + categorical[siblings], + tiers["breakfast"][siblings], + tiers["lunch"][siblings], + ) + for unit_number in range(len(drawn_units)): + base = sibling_results[unit_number, "base"] + for variant in ("added", *CHILD_CATEGORIES): + for before, after in zip(base, sibling_results[unit_number, variant]): + np.testing.assert_array_equal(before, after) + + +@settings( + max_examples=6, + deadline=None, + derandomize=True, + suppress_health_check=[HealthCheck.too_slow, HealthCheck.data_too_large], +) +@given(drawn_units=st.lists(units(), min_size=1, max_size=3)) +def test_school_meal_categorical_eligibility_invariants( + school_meal_system, drawn_units +): + _check(drawn_units, school_meal_system) diff --git a/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml new file mode 100644 index 00000000000..006eb9a05f3 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml @@ -0,0 +1,517 @@ +# 42 USC 1758(b)(12)(A)(iii); 7 CFR 245.6(b)(7)-(8): +# Head Start enrollment qualifies that child; SNAP qualifies every child. +# https://www.ecfr.gov/current/title-7/section-245.6#p-245.6(b)(8) +# The income ratio stays fixed to isolate categorical eligibility. +# At 300% FPG, a sibling pays; at 100% FPG, a sibling qualifies by income. +# Calendar 2026 contiguous rates, USDA SY 2025-26: +# https://www.govinfo.gov/content/pkg/FR-2025-07-24/pdf/2025-13879.pdf +# Free value per K12 child = (2.46 + 4.60 - 0.40 - 0.44) * 180 = 1,119.60. +# A four-year-old defaults outside K12, so contributes no school-meal value. +# A five-year-old defaults in K12. Each child counts once in the unit total. +# Mixed free/reduced annual value = 1,119.60 + 993.60 = 2,113.20. +# SSI can establish Head Start eligibility; 42 USC 1758(b)(12)(A) still +# requires Head Start enrollment before that child qualifies for school meals. +- name: Head Start enrollment qualifies a preschooler without changing an older sibling. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + participant: + age: 4 + is_enrolled_in_head_start: true + sibling: + age: 10 + spm_units: + unit: + members: + - parent + - participant + - sibling + snap: 0 + tanf: 0 + fdpir: 0 + school_meal_fpg_ratio: 3 + households: + home: + members: + - parent + - participant + - sibling + state_code: AL + output: + is_school_meal_categorically_eligible: + - false + - true + - false + school_meal_child_breakfast_tier: + - PAID + - FREE + - PAID + school_meal_child_lunch_tier: + - PAID + - FREE + - PAID + school_meal_net_subsidy: 0.0 + free_school_meals: 0.0 + reduced_price_school_meals: 0 +- name: Head Start enrollment qualifies only the enrolled school child at high income. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + participant: + age: 5 + is_enrolled_in_head_start: true + sibling: + age: 10 + spm_units: + unit: + members: + - parent + - participant + - sibling + snap: 0 + tanf: 0 + fdpir: 0 + school_meal_fpg_ratio: 3 + households: + home: + members: + - parent + - participant + - sibling + state_code: AL + output: + is_school_meal_categorically_eligible: + - false + - true + - false + school_meal_child_breakfast_tier: + - PAID + - FREE + - PAID + school_meal_child_lunch_tier: + - PAID + - FREE + - PAID + school_meal_net_subsidy: 1119.6 + free_school_meals: 1119.6 + reduced_price_school_meals: 0 +- name: A sibling still gets free meals through the income test. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + participant: + age: 5 + is_enrolled_in_head_start: true + sibling: + age: 10 + spm_units: + unit: + members: + - parent + - participant + - sibling + snap: 0 + tanf: 0 + fdpir: 0 + school_meal_fpg_ratio: 1 + households: + home: + members: + - parent + - participant + - sibling + state_code: AL + output: + is_school_meal_categorically_eligible: + - false + - true + - false + school_meal_child_breakfast_tier: + - FREE + - FREE + - FREE + school_meal_child_lunch_tier: + - FREE + - FREE + - FREE + school_meal_net_subsidy: 2239.2 + free_school_meals: 2239.2 + reduced_price_school_meals: 0 +- name: SNAP qualifies every child even when only one enrolls in Head Start. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + participant: + age: 5 + is_enrolled_in_head_start: true + sibling: + age: 10 + spm_units: + unit: + members: + - parent + - participant + - sibling + snap: 1 + tanf: 0 + fdpir: 0 + school_meal_fpg_ratio: 3 + households: + home: + members: + - parent + - participant + - sibling + state_code: AL + output: + is_school_meal_categorically_eligible: + - true + - true + - true + school_meal_child_breakfast_tier: + - FREE + - FREE + - FREE + school_meal_child_lunch_tier: + - FREE + - FREE + - FREE + school_meal_net_subsidy: 2239.2 + free_school_meals: 2239.2 + reduced_price_school_meals: 0 +- name: SNAP qualifies every child without Head Start enrollment. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + participant: + age: 10 + is_enrolled_in_head_start: false + sibling: + age: 10 + spm_units: + unit: + members: + - parent + - participant + - sibling + snap: 1 + tanf: 0 + fdpir: 0 + school_meal_fpg_ratio: 3 + households: + home: + members: + - parent + - participant + - sibling + state_code: AL + output: + is_school_meal_categorically_eligible: + - true + - true + - true + school_meal_child_breakfast_tier: + - FREE + - FREE + - FREE + school_meal_child_lunch_tier: + - FREE + - FREE + - FREE + school_meal_net_subsidy: 2239.2 + free_school_meals: 2239.2 + reduced_price_school_meals: 0 +- name: An enrolled child gets free meals while a sibling pays the reduced price. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + participant: + age: 5 + is_enrolled_in_head_start: true + sibling: + age: 10 + spm_units: + unit: + members: + - parent + - participant + - sibling + snap: 0 + tanf: 0 + fdpir: 0 + school_meal_fpg_ratio: 1.6 + households: + home: + members: + - parent + - participant + - sibling + state_code: AL + output: + is_school_meal_categorically_eligible: + - false + - true + - false + school_meal_child_breakfast_tier: + - REDUCED + - FREE + - REDUCED + school_meal_child_lunch_tier: + - REDUCED + - FREE + - REDUCED + school_meal_net_subsidy: 2113.2 + free_school_meals: 1119.6 + reduced_price_school_meals: 993.6 + school_meal_daily_subsidy: 6.71 +- name: is_in_foster_care qualifies only the child with that status. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + participant: + age: 10 + is_in_foster_care: + 2026-12: true + sibling: + age: 10 + spm_units: + unit: + members: + - parent + - participant + - sibling + snap: 0 + tanf: 0 + fdpir: 0 + school_meal_fpg_ratio: 3 + households: + home: + members: + - parent + - participant + - sibling + state_code: AL + output: + is_school_meal_categorically_eligible: + - false + - true + - false + school_meal_child_breakfast_tier: + - PAID + - FREE + - PAID + school_meal_child_lunch_tier: + - PAID + - FREE + - PAID + school_meal_net_subsidy: 1119.6 + free_school_meals: 1119.6 + reduced_price_school_meals: 0 +- name: is_homeless_child qualifies only the child with that status. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + participant: + age: 10 + is_homeless_child: true + sibling: + age: 10 + spm_units: + unit: + members: + - parent + - participant + - sibling + snap: 0 + tanf: 0 + fdpir: 0 + school_meal_fpg_ratio: 3 + households: + home: + members: + - parent + - participant + - sibling + state_code: AL + output: + is_school_meal_categorically_eligible: + - false + - true + - false + school_meal_child_breakfast_tier: + - PAID + - FREE + - PAID + school_meal_child_lunch_tier: + - PAID + - FREE + - PAID + school_meal_net_subsidy: 1119.6 + free_school_meals: 1119.6 + reduced_price_school_meals: 0 +- name: is_runaway_child qualifies only the child with that status. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + participant: + age: 10 + is_runaway_child: true + sibling: + age: 10 + spm_units: + unit: + members: + - parent + - participant + - sibling + snap: 0 + tanf: 0 + fdpir: 0 + school_meal_fpg_ratio: 3 + households: + home: + members: + - parent + - participant + - sibling + state_code: AL + output: + is_school_meal_categorically_eligible: + - false + - true + - false + school_meal_child_breakfast_tier: + - PAID + - FREE + - PAID + school_meal_child_lunch_tier: + - PAID + - FREE + - PAID + school_meal_net_subsidy: 1119.6 + free_school_meals: 1119.6 + reduced_price_school_meals: 0 +- name: is_migratory_child qualifies only the child with that status. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + participant: + age: 10 + is_migratory_child: true + sibling: + age: 10 + spm_units: + unit: + members: + - parent + - participant + - sibling + snap: 0 + tanf: 0 + fdpir: 0 + school_meal_fpg_ratio: 3 + households: + home: + members: + - parent + - participant + - sibling + state_code: AL + output: + is_school_meal_categorically_eligible: + - false + - true + - false + school_meal_child_breakfast_tier: + - PAID + - FREE + - PAID + school_meal_child_lunch_tier: + - PAID + - FREE + - PAID + school_meal_net_subsidy: 1119.6 + free_school_meals: 1119.6 + reduced_price_school_meals: 0 +- name: SSI makes a child Head Start eligible without establishing enrollment. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + employment_income: 60000 + receives_ssi: + 2026-01: true + ssi: 0 + participant: + age: 4 + ssi: 0 + sibling: + age: 10 + ssi: 0 + spm_units: + unit: + members: + - parent + - participant + - sibling + snap: 0 + tanf: 0 + fdpir: 0 + households: + home: + members: + - parent + - participant + - sibling + state_code: AL + output: + is_head_start_eligible: + - false + - true + - false + is_school_meal_categorically_eligible: + - false + - false + - false + school_meal_child_breakfast_tier: + - PAID + - PAID + - PAID + school_meal_child_lunch_tier: + - PAID + - PAID + - PAID + free_school_meals: 0 + reduced_price_school_meals: 0 diff --git a/policyengine_us/tests/policy/baseline/gov/usda/school_meals/meets_school_meal_categorical_eligibility.yaml b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/meets_school_meal_categorical_eligibility.yaml index 1a8805c24b9..42fc0365fdf 100644 --- a/policyengine_us/tests/policy/baseline/gov/usda/school_meals/meets_school_meal_categorical_eligibility.yaml +++ b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/meets_school_meal_categorical_eligibility.yaml @@ -26,7 +26,7 @@ output: meets_school_meal_categorical_eligibility: true -- name: Is homeless and is migratory child. +- name: Homelessness and migrant status qualify the child separately. period: 2022 input: snap: 0 @@ -38,9 +38,10 @@ is_migratory_child: true is_head_start_eligible: false output: - meets_school_meal_categorical_eligibility: true + meets_school_meal_categorical_eligibility: false + is_school_meal_categorically_eligible: true -- name: Is runaway child. +- name: Runaway status qualifies the child separately. period: 2022 input: snap: 0 @@ -52,9 +53,10 @@ is_migratory_child: false is_head_start_eligible: false output: - meets_school_meal_categorical_eligibility: true + meets_school_meal_categorical_eligibility: false + is_school_meal_categorically_eligible: true -- name: Is Head Start child. +- name: Head Start enrollment qualifies the child separately. period: 2022 input: snap: 0 @@ -62,11 +64,12 @@ fdpir: 0 was_in_foster_care: false is_homeless: false - is_runaway_child: true + is_runaway_child: false is_migratory_child: false - is_head_start_eligible: true + is_enrolled_in_head_start: true output: - meets_school_meal_categorical_eligibility: true + meets_school_meal_categorical_eligibility: false + is_school_meal_categorically_eligible: true - name: No participation in any programs. period: 2022 @@ -89,7 +92,8 @@ fdpir: [0, 1, 1, 0, 0, 0, 0, 0] is_homeless: [False, False, True, True, False, False, False, False] output: - meets_school_meal_categorical_eligibility: [True, True, True, True, False, False, False, False] + meets_school_meal_categorical_eligibility: [True, True, True, False, False, False, False, False] + is_school_meal_categorically_eligible: [True, True, True, True, False, False, False, False] - name: Reported SNAP receipt qualifies even when the modeled allotment is zero. period: 2022 @@ -120,3 +124,45 @@ is_head_start_eligible: false output: meets_school_meal_categorical_eligibility: true + +# 42 USC 1758(b)(12)(A)(iii) requires Head Start enrollment. +# 7 CFR 245.6(b)(8) limits that category to the enrolled child. +# Alabama, three people, 2026: FPG = 15,960 + 2 * 5,680 = 27,320. +# Head Start counts 26,000 in wages, below 27,320, so the preschooler +# meets its income test. School meals count 26,000 + 20,000 rent = 46,000. +# ceil(1.30 * 27,320) = 35,516 < 46,000 <= 50,542 = ceil(1.85 * 27,320). +# The older child qualifies for reduced-price meals through income alone. +- name: A preschooler's Head Start eligibility does not give a sibling free meals. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + employment_income: 26_000 + rental_income: 20_000 + ssi: 0 + preschooler: + age: 4 + ssi: 0 + sibling: + age: 10 + ssi: 0 + spm_units: + unit: + members: [parent, preschooler, sibling] + snap: 0 + tanf: 0 + fdpir: 0 + households: + household: + members: [parent, preschooler, sibling] + state_code: AL + output: + is_head_start_eligible: [false, true, false] + school_meal_countable_income: 46_000 + meets_school_meal_categorical_eligibility: false + school_meal_tier: REDUCED + # (SBP 2.16 + NSLP 4.20 - paid 0.84) * 180 * 1 = 993.60. + free_school_meals: 0 + reduced_price_school_meals: 993.60 diff --git a/policyengine_us/variables/gov/usda/school_meals/free_school_meals.py b/policyengine_us/variables/gov/usda/school_meals/free_school_meals.py index edc77291533..6dc9e7d5b8d 100644 --- a/policyengine_us/variables/gov/usda/school_meals/free_school_meals.py +++ b/policyengine_us/variables/gov/usda/school_meals/free_school_meals.py @@ -1,4 +1,7 @@ from policyengine_us.model_api import * +from policyengine_us.variables.gov.usda.school_meals.school_meal_daily_subsidy import ( + school_meal_daily_rate, +) class free_school_meals(Variable): @@ -18,26 +21,11 @@ class free_school_meals(Variable): ) def formula(spm_unit, period, parameters): - # Split the net subsidy by each meal's value above the paid rate, so - # each meal counts here only when its own tier is FREE. - state_group = spm_unit.household("state_group_str", period) - breakfast_tier = spm_unit("school_meal_breakfast_tier", period) - lunch_tier = spm_unit("school_meal_lunch_tier", period) - p_amount = parameters(period).gov.usda.school_meals.amount - breakfast_value = ( - p_amount.sbp[state_group][breakfast_tier.decode_to_str()] - - p_amount.sbp[state_group]["PAID"] + # Weight each school child's free meals by their value above paid. + free_value = school_meal_daily_rate( + spm_unit, period, parameters, net=True, tier="FREE" ) - lunch_value = ( - p_amount.nslp[state_group][lunch_tier.decode_to_str()] - - p_amount.nslp[state_group]["PAID"] - ) - free_breakfast = breakfast_tier == breakfast_tier.possible_values.FREE - free_lunch = lunch_tier == lunch_tier.possible_values.FREE - free_value = where(free_breakfast, breakfast_value, 0) + where( - free_lunch, lunch_value, 0 - ) - total_value = breakfast_value + lunch_value + total_value = school_meal_daily_rate(spm_unit, period, parameters, net=True) free_share = np.divide( free_value, total_value, diff --git a/policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py b/policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py new file mode 100644 index 00000000000..a686080b640 --- /dev/null +++ b/policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py @@ -0,0 +1,39 @@ +from policyengine_us.model_api import * + + +class is_school_meal_categorically_eligible(Variable): + value_type = bool + entity = Person + label = "Categorically eligible for free school meals" + definition_period = YEAR + documentation = ( + "Whether this person qualifies through the SPM unit's SNAP, TANF or " + "FDPIR participation, or their own Head Start enrollment, foster care, " + "homelessness, migrant status or runaway status. School meal values " + "also require K-12 attendance." + ) + reference = ( + "https://www.law.cornell.edu/uscode/text/42/1758#b_12_A", + "https://www.ecfr.gov/current/title-7/section-245.6#p-245.6(b)(7)", + "https://www.ecfr.gov/current/title-7/section-245.6#p-245.6(b)(8)", + ) + + def formula(person, period, parameters): + household_category = person.spm_unit( + "meets_school_meal_categorical_eligibility", period + ) + # Enrollment qualifies the participant, including an enrollee whose + # income exceeds the modeled Head Start income limit (USDA SP 40-2013). + head_start = person("is_enrolled_in_head_start", period) + foster = person("is_in_foster_care", period, options=[ADD]) > 0 + homeless = person("is_homeless_child", period) | person.household( + "is_homeless", period + ) + return ( + household_category + | head_start + | foster + | homeless + | person("is_migratory_child", period) + | person("is_runaway_child", period) + ) diff --git a/policyengine_us/variables/gov/usda/school_meals/meets_school_meal_categorical_eligibility.py b/policyengine_us/variables/gov/usda/school_meals/meets_school_meal_categorical_eligibility.py index 7076727c35f..dd51211a452 100644 --- a/policyengine_us/variables/gov/usda/school_meals/meets_school_meal_categorical_eligibility.py +++ b/policyengine_us/variables/gov/usda/school_meals/meets_school_meal_categorical_eligibility.py @@ -4,8 +4,12 @@ class meets_school_meal_categorical_eligibility(Variable): value_type = bool entity = SPMUnit - label = "School meal categorical eligibility" - documentation = "Whether this SPM unit is eligible for free school meal via participation in other programs" + label = "Household-wide school meal categorical eligibility" + documentation = ( + "Whether SNAP, TANF or FDPIR participation qualifies every child in " + "this SPM unit. Child-specific categories also apply through " + "is_school_meal_categorically_eligible." + ) definition_period = YEAR - reference = "https://www.law.cornell.edu/cfr/text/7/245.2" + reference = "https://www.ecfr.gov/current/title-7/section-245.6#p-245.6(b)(7)" adds = "gov.usda.school_meals.categorical_eligibility" diff --git a/policyengine_us/variables/gov/usda/school_meals/reduced_price_school_meals.py b/policyengine_us/variables/gov/usda/school_meals/reduced_price_school_meals.py index c6eef52021b..009b5dcc515 100644 --- a/policyengine_us/variables/gov/usda/school_meals/reduced_price_school_meals.py +++ b/policyengine_us/variables/gov/usda/school_meals/reduced_price_school_meals.py @@ -1,4 +1,7 @@ from policyengine_us.model_api import * +from policyengine_us.variables.gov.usda.school_meals.school_meal_daily_subsidy import ( + school_meal_daily_rate, +) class reduced_price_school_meals(Variable): @@ -17,26 +20,11 @@ class reduced_price_school_meals(Variable): ) def formula(spm_unit, period, parameters): - # Split the net subsidy by each meal's value above the paid rate, so - # each meal counts here only when its own tier is REDUCED. - state_group = spm_unit.household("state_group_str", period) - breakfast_tier = spm_unit("school_meal_breakfast_tier", period) - lunch_tier = spm_unit("school_meal_lunch_tier", period) - p_amount = parameters(period).gov.usda.school_meals.amount - breakfast_value = ( - p_amount.sbp[state_group][breakfast_tier.decode_to_str()] - - p_amount.sbp[state_group]["PAID"] + # Weight each school child's reduced-price meals by their net value. + reduced_value = school_meal_daily_rate( + spm_unit, period, parameters, net=True, tier="REDUCED" ) - lunch_value = ( - p_amount.nslp[state_group][lunch_tier.decode_to_str()] - - p_amount.nslp[state_group]["PAID"] - ) - reduced_breakfast = breakfast_tier == breakfast_tier.possible_values.REDUCED - reduced_lunch = lunch_tier == lunch_tier.possible_values.REDUCED - reduced_value = where(reduced_breakfast, breakfast_value, 0) + where( - reduced_lunch, lunch_value, 0 - ) - total_value = breakfast_value + lunch_value + total_value = school_meal_daily_rate(spm_unit, period, parameters, net=True) reduced_share = np.divide( reduced_value, total_value, diff --git a/policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py new file mode 100644 index 00000000000..bd238186f91 --- /dev/null +++ b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py @@ -0,0 +1,23 @@ +from policyengine_us.model_api import * +from policyengine_us.variables.gov.usda.school_meals.school_meal_tier import ( + SchoolMealTier, +) + + +class school_meal_child_breakfast_tier(Variable): + value_type = Enum + entity = Person + possible_values = SchoolMealTier + default_value = SchoolMealTier.PAID + label = "School breakfast tier for this child" + definition_period = YEAR + documentation = ( + "The SPM unit's income and state-policy breakfast tier, with free " + "breakfast for this child's own categorical eligibility." + ) + reference = "https://www.ecfr.gov/current/title-7/section-245.6#p-245.6(b)(8)" + + def formula(person, period, parameters): + tier = person.spm_unit("school_meal_breakfast_tier", period) + categorical = person("is_school_meal_categorically_eligible", period) + return where(categorical, SchoolMealTier.FREE, tier) diff --git a/policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py new file mode 100644 index 00000000000..cc3b0f230bf --- /dev/null +++ b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py @@ -0,0 +1,23 @@ +from policyengine_us.model_api import * +from policyengine_us.variables.gov.usda.school_meals.school_meal_tier import ( + SchoolMealTier, +) + + +class school_meal_child_lunch_tier(Variable): + value_type = Enum + entity = Person + possible_values = SchoolMealTier + default_value = SchoolMealTier.PAID + label = "School lunch tier for this child" + definition_period = YEAR + documentation = ( + "The SPM unit's income and state-policy lunch tier, with free " + "lunch for this child's own categorical eligibility." + ) + reference = "https://www.ecfr.gov/current/title-7/section-245.6#p-245.6(b)(8)" + + def formula(person, period, parameters): + tier = person.spm_unit("school_meal_lunch_tier", period) + categorical = person("is_school_meal_categorically_eligible", period) + return where(categorical, SchoolMealTier.FREE, tier) diff --git a/policyengine_us/variables/gov/usda/school_meals/school_meal_daily_subsidy.py b/policyengine_us/variables/gov/usda/school_meals/school_meal_daily_subsidy.py index 75dce29cd57..f24930f5103 100644 --- a/policyengine_us/variables/gov/usda/school_meals/school_meal_daily_subsidy.py +++ b/policyengine_us/variables/gov/usda/school_meals/school_meal_daily_subsidy.py @@ -1,6 +1,39 @@ from policyengine_us.model_api import * +def school_meal_daily_rate(spm_unit, period, parameters, *, net=False, tier=None): + """Average each school child's meal rates, optionally net of paid rates.""" + state_group = spm_unit.household("state_group_str", period) + child_state_group = spm_unit.project(state_group) + in_school = spm_unit.members("is_in_k12_school", period) + children = spm_unit.sum(in_school) + p_amount = parameters(period).gov.usda.school_meals.amount + result = 0 + for meal, program in (("breakfast", "sbp"), ("lunch", "nslp")): + rates = p_amount[program] + common_tier = spm_unit(f"school_meal_{meal}_tier", period).decode_to_str() + child_tier = spm_unit.members( + f"school_meal_child_{meal}_tier", period + ).decode_to_str() + common_rate = rates[state_group][common_tier] + child_rate = rates[child_state_group][child_tier] + if net: + common_rate = common_rate - rates[state_group]["PAID"] + child_rate = child_rate - rates[child_state_group]["PAID"] + if tier is not None: + common_rate = where(common_tier == tier, common_rate, 0) + child_rate = where(child_tier == tier, child_rate, 0) + # Preserve the common per-child rate for units without schoolchildren; + # their annual benefit remains zero. Inputs can still override it. + result = result + np.divide( + spm_unit.sum(where(in_school, child_rate, 0)), + children, + out=common_rate.copy(), + where=children > 0, + ) + return result + + class school_meal_daily_subsidy(Variable): value_type = float entity = SPMUnit @@ -8,9 +41,9 @@ class school_meal_daily_subsidy(Variable): label = "School meal subsidies per child per day" unit = USD documentation = ( - "Value of school meal subsidies per child per day: the School Breakfast " - "Program rate at the breakfast tier plus the National School Lunch " - "Program rate at the lunch tier." + "Average subsidy per K-12 child per day, using each child's breakfast " + "and lunch tiers. Units without schoolchildren retain their common " + "per-child rate and receive no annual school-meal value." ) reference = ( "https://www.law.cornell.edu/uscode/text/42/1773#e_1_A", @@ -18,11 +51,4 @@ class school_meal_daily_subsidy(Variable): ) def formula(spm_unit, period, parameters): - # Get state group and per-meal tiers for SPM unit. - state_group = spm_unit.household("state_group_str", period) - breakfast_tier = spm_unit("school_meal_breakfast_tier", period).decode_to_str() - lunch_tier = spm_unit("school_meal_lunch_tier", period).decode_to_str() - p_amount = parameters(period).gov.usda.school_meals.amount - nslp_per_child = p_amount.nslp[state_group][lunch_tier] - sbp_per_child = p_amount.sbp[state_group][breakfast_tier] - return nslp_per_child + sbp_per_child + return school_meal_daily_rate(spm_unit, period, parameters) diff --git a/policyengine_us/variables/gov/usda/school_meals/school_meal_tier.py b/policyengine_us/variables/gov/usda/school_meals/school_meal_tier.py index 30a3f124b66..3845b20014b 100644 --- a/policyengine_us/variables/gov/usda/school_meals/school_meal_tier.py +++ b/policyengine_us/variables/gov/usda/school_meals/school_meal_tier.py @@ -48,7 +48,7 @@ class school_meal_tier(Variable): entity = SPMUnit definition_period = YEAR documentation = ( - "School meal tier that applies to both breakfast and lunch: federal " + "Common SPM-unit tier for both breakfast and lunch: federal " "eligibility plus state coverage of both meals (universal free meals, " "reduced-price copay coverage and free-meal income limits above the " "federal limit). The federal free (130%) and reduced-price (185%) " @@ -59,7 +59,9 @@ class school_meal_tier(Variable): "exactly. State policies that cover only one meal apply in " "school_meal_breakfast_tier and school_meal_lunch_tier. FREE " "describes no family charge; it does not change the student's " - "federal reimbursement category." + "federal reimbursement category. Child-specific categorical " + "eligibility applies in school_meal_child_breakfast_tier and " + "school_meal_child_lunch_tier." ) reference = ( "https://www.law.cornell.edu/uscode/text/42/1758#b_1_A", diff --git a/policyengine_us/variables/household/demographic/person/is_enrolled_in_head_start.py b/policyengine_us/variables/household/demographic/person/is_enrolled_in_head_start.py index d17298976d4..7f7e4c56239 100644 --- a/policyengine_us/variables/household/demographic/person/is_enrolled_in_head_start.py +++ b/policyengine_us/variables/household/demographic/person/is_enrolled_in_head_start.py @@ -6,3 +6,11 @@ class is_enrolled_in_head_start(Variable): entity = Person label = "Enrolled in a Head Start or Early Head Start program" definition_period = YEAR + documentation = ( + "Whether this person enrolls in Head Start or Early Head Start. " + "Enrollment differs from modeled eligibility and hypothetical take-up." + ) + reference = ( + "https://www.law.cornell.edu/uscode/text/42/1758#b_12_A_iii", + "https://fns-prod.azureedge.us/sites/default/files/cn/SP40_CACFP11_SFSP13-2013os.pdf", + ) diff --git a/policyengine_us/variables/household/demographic/person/is_homeless_child.py b/policyengine_us/variables/household/demographic/person/is_homeless_child.py new file mode 100644 index 00000000000..1d780f3cf99 --- /dev/null +++ b/policyengine_us/variables/household/demographic/person/is_homeless_child.py @@ -0,0 +1,19 @@ +from policyengine_us.model_api import * + + +class is_homeless_child(Variable): + value_type = bool + entity = Person + default_value = False + label = "Child qualifies as homeless for school meals" + definition_period = YEAR + documentation = ( + "Whether a school liaison, shelter director or other authorized " + "official has identified this child as homeless under the " + "McKinney-Vento definition for school meal certification. This input " + "can identify one child when the whole household is not homeless." + ) + reference = ( + "https://www.ecfr.gov/current/title-7/section-245.2", + "https://www.law.cornell.edu/uscode/text/42/1758#b_12_A_iv", + ) diff --git a/policyengine_us/variables/household/demographic/person/is_in_foster_care.py b/policyengine_us/variables/household/demographic/person/is_in_foster_care.py index 2e4c2efac11..8d5d6f7365e 100644 --- a/policyengine_us/variables/household/demographic/person/is_in_foster_care.py +++ b/policyengine_us/variables/household/demographic/person/is_in_foster_care.py @@ -4,5 +4,11 @@ class is_in_foster_care(Variable): value_type = bool entity = Person - label = "Person is currently in a qualifying foster care institution" + label = "Person is currently in qualifying foster care" definition_period = MONTH + documentation = ( + "Whether an authorized agency or court currently places this person " + "in foster care, including placement with a caretaker household. " + "Prior foster care alone does not establish current placement." + ) + reference = "https://www.law.cornell.edu/uscode/text/42/1758#b_12_A_vii" From fa9194e290031e3eafeab7feaa2840aef18cf2b0 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Thu, 12 Nov 2026 01:15:36 -0500 Subject: [PATCH 02/11] Check child school meal eligibility across every state Co-Authored-By: Claude Opus 5.5 --- ...meal_categorical_eligibility_invariants.py | 145 +++++++++++++++--- ...is_school_meal_categorically_eligible.yaml | 47 ++++++ 2 files changed, 172 insertions(+), 20 deletions(-) diff --git a/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py b/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py index 0e3848089d6..edb8d54648e 100644 --- a/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py +++ b/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py @@ -2,12 +2,13 @@ Each draw runs independent SPM units together, reusing one read-only system. We vary siblings, income tiers, enrollment, K-12 attendance and receipt months. -The paired units hold their poverty ratios fixed when a child joins them. +The paired units hold their poverty ratios and poverty guidelines fixed +when a child joins them. An explicit example covers every state and DC. """ import numpy as np import pytest -from hypothesis import HealthCheck, given, settings +from hypothesis import HealthCheck, example, given, settings from hypothesis import strategies as st from policyengine_us import Simulation @@ -22,13 +23,89 @@ "is_migratory_child", ) HOUSEHOLD_CATEGORIES = ("snap", "receives_snap", "tanf", "receives_tanf", "fdpir") -INCOME_TIERS = ((1.0, "FREE"), (1.5, "REDUCED"), (3.0, "PAID")) +POVERTY_RATIOS = (1.0, 1.5, 3.0) +STATES = ( + "AL", + "AK", + "AZ", + "AR", + "CA", + "CO", + "CT", + "DE", + "FL", + "GA", + "HI", + "ID", + "IL", + "IN", + "IA", + "KS", + "KY", + "LA", + "ME", + "MD", + "MA", + "MI", + "MN", + "MS", + "MO", + "MT", + "NE", + "NV", + "NH", + "NJ", + "NM", + "NY", + "NC", + "ND", + "OH", + "OK", + "OR", + "PA", + "RI", + "SC", + "SD", + "TN", + "TX", + "UT", + "VT", + "VA", + "WA", + "WV", + "WI", + "WY", + "DC", +) # USDA's SY 2024-25 rates apply on January 1, 2025. Lunch uses the # under-60-percent rate; breakfast uses the non-severe-need rate. # https://www.govinfo.gov/content/pkg/FR-2024-07-10/pdf/2024-15175.pdf#page=4 -BREAKFAST_RATES = {"FREE": 2.37, "REDUCED": 2.07, "PAID": 0.39} -LUNCH_RATES = {"FREE": 4.43, "REDUCED": 4.03, "PAID": 0.42} +RATES = { + "CONTIGUOUS_US": { + "breakfast": {"FREE": 2.37, "REDUCED": 2.07, "PAID": 0.39}, + "lunch": {"FREE": 4.43, "REDUCED": 4.03, "PAID": 0.42}, + }, + "AK": { + "breakfast": {"FREE": 3.80, "REDUCED": 3.50, "PAID": 0.60}, + "lunch": {"FREE": 7.18, "REDUCED": 6.78, "PAID": 0.69}, + }, + "HI": { + "breakfast": {"FREE": 3.06, "REDUCED": 2.76, "PAID": 0.49}, + "lunch": {"FREE": 5.76, "REDUCED": 5.36, "PAID": 0.55}, + }, +} SCHOOL_DAYS = 180 +ALL_STATES_EXAMPLE = [ + { + "state": state, + "ages": [8, 15], + "ratio": 1.5, + "month": f"{YEAR}-07", + "amount": 100, + "added_in_k12": True, + } + for state in STATES +] @pytest.fixture(scope="module") @@ -38,11 +115,10 @@ def school_meal_system(): @st.composite def units(draw): - ratio, tier = draw(st.sampled_from(INCOME_TIERS)) return { + "state": draw(st.sampled_from(STATES)), "ages": draw(st.lists(st.integers(6, 17), min_size=1, max_size=3)), - "ratio": ratio, - "tier": tier, + "ratio": draw(st.sampled_from(POVERTY_RATIOS)), "month": draw(st.sampled_from(MONTHS)), "amount": draw(st.integers(1, 5_000)), "added_in_k12": draw(st.booleans()), @@ -102,6 +178,7 @@ def _situation(drawn_units): spm_unit = { "members": members, "school_meal_fpg_ratio": {YEAR: unit["ratio"]}, + "spm_unit_fpg": {YEAR: 10_000}, "snap": dict.fromkeys(MONTHS, 0), "tanf": {YEAR: 0}, "fdpir": {YEAR: 0}, @@ -117,7 +194,7 @@ def _situation(drawn_units): groups["families"][prefix] = {"members": members} groups["households"][prefix] = { "members": members, - "state_code": {YEAR: "AL"}, + "state_code": {YEAR: unit["state"]}, "is_homeless": {YEAR: False}, } records.append( @@ -151,6 +228,12 @@ def _check(drawn_units, system): ).decode_to_str() for meal in ("breakfast", "lunch") } + # These common SPM-unit tiers retain main's formulas for each state's + # income limits, universal meals and coverage of either meal's copay. + common_tiers = { + meal: simulation.calculate(f"school_meal_{meal}_tier", YEAR).decode_to_str() + for meal in ("breakfast", "lunch") + } values = { name: np.asarray(simulation.calculate(name, YEAR), dtype=float) for name in ( @@ -160,12 +243,20 @@ def _check(drawn_units, system): "reduced_price_school_meals", ) } + np.testing.assert_allclose( + values["free_school_meals"] + values["reduced_price_school_meals"], + values["school_meal_net_subsidy"], + atol=0.01, + rtol=0, + ) sibling_results = {} for index, record in enumerate(records): unit = record["unit"] variant = record["variant"] household = variant in HOUSEHOLD_CATEGORIES assert household_categorical[index] == household + region = unit["state"] if unit["state"] in ("AK", "HI") else "CONTIGUOUS_US" + rates = RATES[region] daily_total = 0 net = free = reduced = 0 school_children = 0 @@ -173,19 +264,23 @@ def _check(drawn_units, system): person = person_index[name] own_category = name == record["added"] and variant in CHILD_CATEGORIES assert categorical[person] == (household or own_category) - expected_tier = "FREE" if household or own_category else unit["tier"] + expected_tiers = { + meal: "FREE" if household or own_category else common_tiers[meal][index] + for meal in tiers + } for meal in tiers: - assert tiers[meal][person] == expected_tier + assert tiers[meal][person] == expected_tiers[meal] if not situation["people"][name]["is_in_k12_school"][YEAR]: continue school_children += 1 - daily = BREAKFAST_RATES[expected_tier] + LUNCH_RATES[expected_tier] - daily_total += daily - # Subtract the paid reimbursement once per child per meal. - annual = (daily - 0.39 - 0.42) * SCHOOL_DAYS - net += annual - free += annual if expected_tier == "FREE" else 0 - reduced += annual if expected_tier == "REDUCED" else 0 + for meal, expected_tier in expected_tiers.items(): + daily = rates[meal][expected_tier] + daily_total += daily + # Subtract the paid reimbursement once per child per meal. + annual = (daily - rates[meal]["PAID"]) * SCHOOL_DAYS + net += annual + free += annual if expected_tier == "FREE" else 0 + reduced += annual if expected_tier == "REDUCED" else 0 expected = { "school_meal_daily_subsidy": daily_total / school_children, "school_meal_net_subsidy": net, @@ -194,7 +289,11 @@ def _check(drawn_units, system): } for name, amount in expected.items(): np.testing.assert_allclose( - values[name][index], amount, atol=0.01, rtol=0, err_msg=variant + values[name][index], + amount, + atol=0.01, + rtol=0, + err_msg=f"{unit['state']} {variant}", ) siblings = [person_index[name] for name in record["siblings"]] sibling_results[record["number"], variant] = ( @@ -204,7 +303,12 @@ def _check(drawn_units, system): ) for unit_number in range(len(drawn_units)): base = sibling_results[unit_number, "base"] - for variant in ("added", *CHILD_CATEGORIES): + for variant in ( + "added", + *CHILD_CATEGORIES, + "is_head_start_eligible", + "was_in_foster_care", + ): for before, after in zip(base, sibling_results[unit_number, variant]): np.testing.assert_array_equal(before, after) @@ -216,6 +320,7 @@ def _check(drawn_units, system): suppress_health_check=[HealthCheck.too_slow, HealthCheck.data_too_large], ) @given(drawn_units=st.lists(units(), min_size=1, max_size=3)) +@example(drawn_units=ALL_STATES_EXAMPLE) def test_school_meal_categorical_eligibility_invariants( school_meal_system, drawn_units ): diff --git a/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml index 006eb9a05f3..f2bdd2951dc 100644 --- a/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml @@ -515,3 +515,50 @@ - PAID free_school_meals: 0 reduced_price_school_meals: 0 + +# 42 USC 1758(b)(12)(A)(vii) covers qualifying foster placement. +# Prior placement alone supplies no current foster category. +- name: Historical foster care alone does not qualify a child or sibling. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + participant: + age: 10 + was_in_foster_care: true + sibling: + age: 10 + spm_units: + unit: + members: + - parent + - participant + - sibling + snap: 0 + tanf: 0 + fdpir: 0 + school_meal_fpg_ratio: 3 + households: + home: + members: + - parent + - participant + - sibling + state_code: AL + output: + is_school_meal_categorically_eligible: + - false + - false + - false + school_meal_child_breakfast_tier: + - PAID + - PAID + - PAID + school_meal_child_lunch_tier: + - PAID + - PAID + - PAID + free_school_meals: 0 + reduced_price_school_meals: 0 From 12d1520a6e768751e669b7b194c2b5cbbc099a9b Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Thu, 12 Nov 2026 01:31:27 -0500 Subject: [PATCH 03/11] Encode child meal tier results Co-Authored-By: Claude Opus 5.5 --- .../gov/usda/school_meals/school_meal_child_breakfast_tier.py | 2 +- .../gov/usda/school_meals/school_meal_child_lunch_tier.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py index bd238186f91..bd4b8513747 100644 --- a/policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py +++ b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py @@ -20,4 +20,4 @@ class school_meal_child_breakfast_tier(Variable): def formula(person, period, parameters): tier = person.spm_unit("school_meal_breakfast_tier", period) categorical = person("is_school_meal_categorically_eligible", period) - return where(categorical, SchoolMealTier.FREE, tier) + return where(categorical, SchoolMealTier.FREE.index, tier) diff --git a/policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py index cc3b0f230bf..d0d3944fb21 100644 --- a/policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py +++ b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py @@ -20,4 +20,4 @@ class school_meal_child_lunch_tier(Variable): def formula(person, period, parameters): tier = person.spm_unit("school_meal_lunch_tier", period) categorical = person("is_school_meal_categorically_eligible", period) - return where(categorical, SchoolMealTier.FREE, tier) + return where(categorical, SchoolMealTier.FREE.index, tier) From 31460e1f9cb796f408dee170dd71e81a7523b072 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Thu, 12 Nov 2026 01:48:45 -0500 Subject: [PATCH 04/11] Set annual receipt flags in school meal properties Co-Authored-By: Claude Opus 5.5 --- ...meal_categorical_eligibility_invariants.py | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py b/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py index edb8d54648e..c4071c57444 100644 --- a/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py +++ b/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py @@ -186,9 +186,13 @@ def _situation(drawn_units): "receives_tanf": dict.fromkeys(MONTHS, False), } if variant in HOUSEHOLD_CATEGORIES: - period = YEAR if variant in ("tanf", "fdpir") else unit["month"] - value = True if variant.startswith("receives_") else unit["amount"] - spm_unit[variant][period] = value + if variant.startswith("receives_"): + # Core reads December for monthly stock inputs in annual + # calculations. Report receipt throughout the year. + spm_unit[variant] = dict.fromkeys(MONTHS, True) + else: + period = YEAR if variant in ("tanf", "fdpir") else unit["month"] + spm_unit[variant][period] = unit["amount"] groups["spm_units"][prefix] = spm_unit groups["tax_units"][prefix] = {"members": members} groups["families"][prefix] = {"members": members} @@ -253,8 +257,15 @@ def _check(drawn_units, system): for index, record in enumerate(records): unit = record["unit"] variant = record["variant"] + context = ( + f"{unit['state']} unit={record['number']} variant={variant} " + f"month={unit['month']} ratio={unit['ratio']}" + ) household = variant in HOUSEHOLD_CATEGORIES - assert household_categorical[index] == household + assert household_categorical[index] == household, ( + f"{context}: household eligibility={household_categorical[index]}, " + f"expected={household}" + ) region = unit["state"] if unit["state"] in ("AK", "HI") else "CONTIGUOUS_US" rates = RATES[region] daily_total = 0 @@ -263,13 +274,19 @@ def _check(drawn_units, system): for name in record["members"]: person = person_index[name] own_category = name == record["added"] and variant in CHILD_CATEGORIES - assert categorical[person] == (household or own_category) + assert categorical[person] == (household or own_category), ( + f"{context} person={name}: eligibility={categorical[person]}, " + f"expected={household or own_category}" + ) expected_tiers = { meal: "FREE" if household or own_category else common_tiers[meal][index] for meal in tiers } for meal in tiers: - assert tiers[meal][person] == expected_tiers[meal] + assert tiers[meal][person] == expected_tiers[meal], ( + f"{context} person={name} meal={meal}: " + f"tier={tiers[meal][person]}, expected={expected_tiers[meal]}" + ) if not situation["people"][name]["is_in_k12_school"][YEAR]: continue school_children += 1 @@ -293,7 +310,7 @@ def _check(drawn_units, system): amount, atol=0.01, rtol=0, - err_msg=f"{unit['state']} {variant}", + err_msg=context, ) siblings = [person_index[name] for name in record["siblings"]] sibling_results[record["number"], variant] = ( @@ -310,7 +327,11 @@ def _check(drawn_units, system): "was_in_foster_care", ): for before, after in zip(base, sibling_results[unit_number, variant]): - np.testing.assert_array_equal(before, after) + np.testing.assert_array_equal( + before, + after, + err_msg=f"unit={unit_number} variant={variant} sibling invariance", + ) @settings( From 5c21600443099baf2fa0e1dc9e477d99d1c19614 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Thu, 12 Nov 2026 01:52:20 -0500 Subject: [PATCH 05/11] Specify qualifying foster placements for meal eligibility Co-Authored-By: Claude Opus 5.5 --- .../household/demographic/person/is_in_foster_care.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/policyengine_us/variables/household/demographic/person/is_in_foster_care.py b/policyengine_us/variables/household/demographic/person/is_in_foster_care.py index 8d5d6f7365e..25b75d8a082 100644 --- a/policyengine_us/variables/household/demographic/person/is_in_foster_care.py +++ b/policyengine_us/variables/household/demographic/person/is_in_foster_care.py @@ -7,8 +7,9 @@ class is_in_foster_care(Variable): label = "Person is currently in qualifying foster care" definition_period = MONTH documentation = ( - "Whether an authorized agency or court currently places this person " - "in foster care, including placement with a caretaker household. " + "Whether an agency administering a State title IV-B or IV-E plan " + "currently holds responsibility for this person's foster care, or a " + "court currently places this person with a caretaker household. " "Prior foster care alone does not establish current placement." ) reference = "https://www.law.cornell.edu/uscode/text/42/1758#b_12_A_vii" From 386df66670eae8b5a9004f23d30ad905c8125571 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Thu, 12 Nov 2026 02:38:45 -0500 Subject: [PATCH 06/11] Preserve common meal tier inputs for household categories Co-Authored-By: Claude Opus 5.5 --- ...meal_categorical_eligibility_invariants.py | 53 +++++++++++++++++++ .../is_school_meal_categorically_eligible.py | 34 +++++++----- .../school_meal_child_breakfast_tier.py | 11 ++-- .../school_meal_child_lunch_tier.py | 11 ++-- 4 files changed, 89 insertions(+), 20 deletions(-) diff --git a/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py b/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py index c4071c57444..6a9f089c31b 100644 --- a/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py +++ b/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py @@ -4,6 +4,7 @@ We vary siblings, income tiers, enrollment, K-12 attendance and receipt months. The paired units hold their poverty ratios and poverty guidelines fixed when a child joins them. An explicit example covers every state and DC. +With computed common tiers, household categories give every child free meals. """ import numpy as np @@ -346,3 +347,55 @@ def test_school_meal_categorical_eligibility_invariants( school_meal_system, drawn_units ): _check(drawn_units, school_meal_system) + + +@settings(max_examples=6, deadline=None, derandomize=True) +@given( + breakfast=st.sampled_from(("FREE", "REDUCED", "PAID")), + lunch=st.sampled_from(("FREE", "REDUCED", "PAID")), +) +@example(breakfast="PAID", lunch="REDUCED") +def test_explicit_common_meal_tier_inputs_preserve_individual_overrides( + school_meal_system, breakfast, lunch +): + # Explicit common tier inputs override the household calculation. + # Individual categories still override those inputs for that child. + situation, records = _situation( + [ + { + "state": "AL", + "ages": [8, 15], + "ratio": 3.0, + "month": f"{YEAR}-07", + "amount": 100, + "added_in_k12": True, + } + ] + ) + common_tiers = {"breakfast": breakfast, "lunch": lunch} + for spm_unit in situation["spm_units"].values(): + spm_unit["meets_school_meal_categorical_eligibility"] = {YEAR: True} + for meal, tier in common_tiers.items(): + spm_unit[f"school_meal_{meal}_tier"] = {YEAR: tier} + simulation = Simulation(situation=situation, tax_benefit_system=school_meal_system) + categorical = np.asarray( + simulation.calculate("is_school_meal_categorically_eligible", YEAR), + dtype=bool, + ) + assert categorical.all() + person_index = {name: index for index, name in enumerate(situation["people"])} + for meal, common_tier in common_tiers.items(): + child_tiers = simulation.calculate( + f"school_meal_child_{meal}_tier", YEAR + ).decode_to_str() + for record in records: + for name in record["members"]: + own_category = ( + name == record["added"] and record["variant"] in CHILD_CATEGORIES + ) + expected = "FREE" if own_category else common_tier + assert child_tiers[person_index[name]] == expected, ( + f"meal={meal} common_tier={common_tier} " + f"variant={record['variant']} person={name}: " + f"tier={child_tiers[person_index[name]]}, expected={expected}" + ) diff --git a/policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py b/policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py index a686080b640..fb5474416b4 100644 --- a/policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py +++ b/policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py @@ -1,6 +1,24 @@ from policyengine_us.model_api import * +def _school_meal_child_categorical_eligibility(person, period): + """Return this person's individual school meal categorical eligibility.""" + # Enrollment qualifies the participant, including an enrollee whose + # income exceeds the modeled Head Start income limit (USDA SP 40-2013). + head_start = person("is_enrolled_in_head_start", period) + foster = person("is_in_foster_care", period, options=[ADD]) > 0 + homeless = person("is_homeless_child", period) | person.household( + "is_homeless", period + ) + return ( + head_start + | foster + | homeless + | person("is_migratory_child", period) + | person("is_runaway_child", period) + ) + + class is_school_meal_categorically_eligible(Variable): value_type = bool entity = Person @@ -22,18 +40,6 @@ def formula(person, period, parameters): household_category = person.spm_unit( "meets_school_meal_categorical_eligibility", period ) - # Enrollment qualifies the participant, including an enrollee whose - # income exceeds the modeled Head Start income limit (USDA SP 40-2013). - head_start = person("is_enrolled_in_head_start", period) - foster = person("is_in_foster_care", period, options=[ADD]) > 0 - homeless = person("is_homeless_child", period) | person.household( - "is_homeless", period - ) - return ( - household_category - | head_start - | foster - | homeless - | person("is_migratory_child", period) - | person("is_runaway_child", period) + return household_category | _school_meal_child_categorical_eligibility( + person, period ) diff --git a/policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py index bd4b8513747..55169f7011a 100644 --- a/policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py +++ b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py @@ -1,4 +1,7 @@ from policyengine_us.model_api import * +from policyengine_us.variables.gov.usda.school_meals.is_school_meal_categorically_eligible import ( + _school_meal_child_categorical_eligibility, +) from policyengine_us.variables.gov.usda.school_meals.school_meal_tier import ( SchoolMealTier, ) @@ -12,12 +15,14 @@ class school_meal_child_breakfast_tier(Variable): label = "School breakfast tier for this child" definition_period = YEAR documentation = ( - "The SPM unit's income and state-policy breakfast tier, with free " - "breakfast for this child's own categorical eligibility." + "The SPM unit's breakfast tier, including household categorical " + "eligibility, with free breakfast for this child's own categorical " + "eligibility. Explicit SPM-unit tier inputs apply to children " + "without an individual category." ) reference = "https://www.ecfr.gov/current/title-7/section-245.6#p-245.6(b)(8)" def formula(person, period, parameters): tier = person.spm_unit("school_meal_breakfast_tier", period) - categorical = person("is_school_meal_categorically_eligible", period) + categorical = _school_meal_child_categorical_eligibility(person, period) return where(categorical, SchoolMealTier.FREE.index, tier) diff --git a/policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py index d0d3944fb21..f7543d85bb4 100644 --- a/policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py +++ b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py @@ -1,4 +1,7 @@ from policyengine_us.model_api import * +from policyengine_us.variables.gov.usda.school_meals.is_school_meal_categorically_eligible import ( + _school_meal_child_categorical_eligibility, +) from policyengine_us.variables.gov.usda.school_meals.school_meal_tier import ( SchoolMealTier, ) @@ -12,12 +15,14 @@ class school_meal_child_lunch_tier(Variable): label = "School lunch tier for this child" definition_period = YEAR documentation = ( - "The SPM unit's income and state-policy lunch tier, with free " - "lunch for this child's own categorical eligibility." + "The SPM unit's lunch tier, including household categorical " + "eligibility, with free lunch for this child's own categorical " + "eligibility. Explicit SPM-unit tier inputs apply to children " + "without an individual category." ) reference = "https://www.ecfr.gov/current/title-7/section-245.6#p-245.6(b)(8)" def formula(person, period, parameters): tier = person.spm_unit("school_meal_lunch_tier", period) - categorical = person("is_school_meal_categorically_eligible", period) + categorical = _school_meal_child_categorical_eligibility(person, period) return where(categorical, SchoolMealTier.FREE.index, tier) From 480e9319574e5cb79e706af539dd88e82d149db4 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Fri, 13 Nov 2026 18:33:30 -0500 Subject: [PATCH 07/11] Keep household homelessness in the household meal list Congress defines a homeless child as one who lacks a fixed, regular and adequate nighttime residence (42 U.S.C. 11434a(2)(A)), so every child in a household that lacks one qualifies. is_homeless returns to the household-wide list, and the SPM unit's meal tier reads FREE for that household again. is_homeless_child stays the route for one child in a housed household. Move the child-specific categories into a parameter list. Congress added the foster clause in Pub. L. 111-296, effective October 1, 2010, so is_in_foster_care joins the list on that date. Cite uscode.house.gov and eCFR with section anchors, drop the dead FNS memo link, and restore the program-neutral is_in_foster_care label. Add cases for a homeless household and for a Head Start enrollee above the Head Start income limit. Co-Authored-By: Claude Opus 5.5 --- ...chool-meals-head-start-enrollment.fixed.md | 2 +- .../school_meals/categorical_eligibility.yaml | 14 +- .../child_categorical_eligibility.yaml | 31 ++++ ...meal_categorical_eligibility_invariants.py | 9 +- ...is_school_meal_categorically_eligible.yaml | 148 +++++++++++++++++- ...s_school_meal_categorical_eligibility.yaml | 33 +++- .../is_school_meal_categorically_eligible.py | 36 ++--- ...ets_school_meal_categorical_eligibility.py | 10 +- .../school_meal_child_breakfast_tier.py | 4 +- .../school_meal_child_lunch_tier.py | 4 +- .../person/is_enrolled_in_head_start.py | 4 +- .../demographic/person/is_homeless_child.py | 6 +- .../demographic/person/is_in_foster_care.py | 9 +- 13 files changed, 260 insertions(+), 50 deletions(-) create mode 100644 policyengine_us/parameters/gov/usda/school_meals/child_categorical_eligibility.yaml diff --git a/changelog.d/fix-school-meals-head-start-enrollment.fixed.md b/changelog.d/fix-school-meals-head-start-enrollment.fixed.md index fb949b432a8..5ef69675c16 100644 --- a/changelog.d/fix-school-meals-head-start-enrollment.fixed.md +++ b/changelog.d/fix-school-meals-head-start-enrollment.fixed.md @@ -1 +1 @@ -Limited Head Start, foster, homeless, migrant and runaway school-meal eligibility to each qualifying child, and required Head Start enrollment. +Limited Head Start, foster care, migrant, runaway and child-level homeless school-meal eligibility to each qualifying child, and required Head Start enrollment. Counted current foster care from October 2010 in place of past foster care, and added an is_homeless_child input and a child_categorical_eligibility parameter list. diff --git a/policyengine_us/parameters/gov/usda/school_meals/categorical_eligibility.yaml b/policyengine_us/parameters/gov/usda/school_meals/categorical_eligibility.yaml index 729a4845f41..a998d2ca0b4 100644 --- a/policyengine_us/parameters/gov/usda/school_meals/categorical_eligibility.yaml +++ b/policyengine_us/parameters/gov/usda/school_meals/categorical_eligibility.yaml @@ -1,4 +1,4 @@ -description: Program participation that qualifies every child in a family for free school meals. +description: USDA extends free school meals to every child in a family that receives one of these benefits or whose household lacks a fixed nighttime residence. values: 2009-09-01: @@ -7,6 +7,10 @@ values: - tanf # Temporary Assistance to Needy Families. Currently only available in CA and IL. - receives_tanf # Reported TANF receipt, for households the model gives a $0 benefit. - fdpir # Food Distribution Program on Indian Reservations. + # Congress defines a homeless child as one who lacks a fixed, regular and + # adequate nighttime residence (42 U.S.C. 11434a(2)(A)), so each child in + # a household that lacks one qualifies under 42 U.S.C. 1758(b)(12)(A)(iv). + - is_homeless metadata: unit: list @@ -14,8 +18,10 @@ metadata: label: Free school meals qualifying programs reference: - title: 7 CFR § 245.2 - Definitions - href: https://www.law.cornell.edu/cfr/text/7/245.2 + href: https://www.ecfr.gov/current/title-7/section-245.2 - title: 7 CFR § 245.6(b)(7)-(8) - Household and child categorical eligibility href: https://www.ecfr.gov/current/title-7/section-245.6#p-245.6(b)(7) - - title: 42 U.S. Code § 1758 - Program requirements - href: https://www.law.cornell.edu/uscode/text/42/1758#b_5 + - title: 42 U.S.C. 1758(b)(12)(A) - Categorical eligibility for free meals + href: https://uscode.house.gov/us/usc/119-124/t42/s1758/#b-12-A + - title: 42 U.S.C. 11434a(2) - Homeless children and youths + href: https://uscode.house.gov/us/usc/119-124/t42/s11434a/#2 diff --git a/policyengine_us/parameters/gov/usda/school_meals/child_categorical_eligibility.yaml b/policyengine_us/parameters/gov/usda/school_meals/child_categorical_eligibility.yaml new file mode 100644 index 00000000000..9d44af59c3a --- /dev/null +++ b/policyengine_us/parameters/gov/usda/school_meals/child_categorical_eligibility.yaml @@ -0,0 +1,31 @@ +description: USDA extends free school meals to a child who meets one of these conditions, without extending them to other children in the household. + +values: + # Clauses (iii) to (vi) predate this list's first date: Congress added + # clauses (iv) to (vi) in Pub. L. 108-265, section 107(a), effective + # July 1, 2004. + 2009-09-01: + - is_enrolled_in_head_start # 42 U.S.C. 1758(b)(12)(A)(iii). + - is_homeless_child # 42 U.S.C. 1758(b)(12)(A)(iv). + - is_runaway_child # 42 U.S.C. 1758(b)(12)(A)(v). + - is_migratory_child # 42 U.S.C. 1758(b)(12)(A)(vi). + # Congress added clause (vii) for foster children in Pub. L. 111-296, + # section 102(b), effective October 1, 2010 under section 445. + 2010-10-01: + - is_enrolled_in_head_start # 42 U.S.C. 1758(b)(12)(A)(iii). + - is_homeless_child # 42 U.S.C. 1758(b)(12)(A)(iv). + - is_runaway_child # 42 U.S.C. 1758(b)(12)(A)(v). + - is_migratory_child # 42 U.S.C. 1758(b)(12)(A)(vi). + - is_in_foster_care # 42 U.S.C. 1758(b)(12)(A)(vii). + +metadata: + unit: list + period: year + label: Free school meals child-specific categories + reference: + - title: 42 U.S.C. 1758(b)(12)(A) - Categorical eligibility for free meals + href: https://uscode.house.gov/us/usc/119-124/t42/s1758/#b-12-A + - title: 7 CFR § 245.6(b)(8) - Child-specific categorical eligibility + href: https://www.ecfr.gov/current/title-7/section-245.6#p-245.6(b)(8) + - title: "Pub. L. 111-296, sections 102(b) and 445 #page 5-6,84" + href: https://www.govinfo.gov/content/pkg/PLAW-111publ296/pdf/PLAW-111publ296.pdf#page=5 diff --git a/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py b/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py index 6a9f089c31b..d28df83c18a 100644 --- a/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py +++ b/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py @@ -23,7 +23,10 @@ "is_runaway_child", "is_migratory_child", ) -HOUSEHOLD_CATEGORIES = ("snap", "receives_snap", "tanf", "receives_tanf", "fdpir") +SPM_UNIT_CATEGORIES = ("snap", "receives_snap", "tanf", "receives_tanf", "fdpir") +# Each child in a household without a fixed nighttime residence counts as a +# homeless child (42 USC 11434a(2)(A)), so the household qualifies them all. +HOUSEHOLD_CATEGORIES = (*SPM_UNIT_CATEGORIES, "is_homeless") POVERTY_RATIOS = (1.0, 1.5, 3.0) STATES = ( "AL", @@ -186,7 +189,7 @@ def _situation(drawn_units): "receives_snap": dict.fromkeys(MONTHS, False), "receives_tanf": dict.fromkeys(MONTHS, False), } - if variant in HOUSEHOLD_CATEGORIES: + if variant in SPM_UNIT_CATEGORIES: if variant.startswith("receives_"): # Core reads December for monthly stock inputs in annual # calculations. Report receipt throughout the year. @@ -200,7 +203,7 @@ def _situation(drawn_units): groups["households"][prefix] = { "members": members, "state_code": {YEAR: unit["state"]}, - "is_homeless": {YEAR: False}, + "is_homeless": {YEAR: variant == "is_homeless"}, } records.append( { diff --git a/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml index f2bdd2951dc..98474f1059f 100644 --- a/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml @@ -9,8 +9,8 @@ # A four-year-old defaults outside K12, so contributes no school-meal value. # A five-year-old defaults in K12. Each child counts once in the unit total. # Mixed free/reduced annual value = 1,119.60 + 993.60 = 2,113.20. -# SSI can establish Head Start eligibility; 42 USC 1758(b)(12)(A) still -# requires Head Start enrollment before that child qualifies for school meals. +# PolicyEngine's Head Start eligibility counts SSI receipt, but +# 42 USC 1758(b)(12)(A)(iii) qualifies a child only through enrollment. - name: Head Start enrollment qualifies a preschooler without changing an older sibling. period: 2026 absolute_error_margin: 0.01 @@ -463,7 +463,7 @@ school_meal_net_subsidy: 1119.6 free_school_meals: 1119.6 reduced_price_school_meals: 0 -- name: SSI makes a child Head Start eligible without establishing enrollment. +- name: Modeled Head Start eligibility through SSI does not qualify an unenrolled child. period: 2026 absolute_error_margin: 0.01 input: @@ -562,3 +562,145 @@ - PAID free_school_meals: 0 reduced_price_school_meals: 0 + +# 42 USC 11434a(2)(A) defines a homeless child as one who lacks a fixed, +# regular and adequate nighttime residence, so every child in a household +# that lacks one qualifies at any income (1758(b)(12)(A)(iv)). +# At 300% FPG both children would otherwise pay. +# Free value = 2 children * (2.46 + 4.60 - 0.40 - 0.44) * 180 +# = 2 * 6.22 * 180 = 2,239.20. +- name: A homeless household gives every child free meals above the income limits. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + first_child: + age: 10 + second_child: + age: 12 + spm_units: + unit: + members: + - parent + - first_child + - second_child + snap: 0 + tanf: 0 + fdpir: 0 + school_meal_fpg_ratio: 3 + households: + home: + members: + - parent + - first_child + - second_child + state_code: AL + is_homeless: true + output: + meets_school_meal_categorical_eligibility: true + school_meal_tier: FREE + is_school_meal_categorically_eligible: + - true + - true + - true + school_meal_child_breakfast_tier: + - FREE + - FREE + - FREE + school_meal_child_lunch_tier: + - FREE + - FREE + - FREE + school_meal_daily_subsidy: 7.06 + free_school_meals: 2239.2 + reduced_price_school_meals: 0 + +# 42 USC 9840(a)(1)(B)(iii)(I) lets a program enroll children above the +# income limit, and 1758(b)(12)(A)(iii) covers every child enrolled under +# 9840(a)(1)(B). Alabama, three people, 2026: FPG = 15,960 + 2 * 5,680 +# = 27,320. Wages of 100,000 exceed it, so the five-year-old fails the +# Head Start income test, and no family member receives public assistance. +# The fixed 300% FPG ratio leaves the sibling paying. +# Free value = (2.46 + 4.60 - 0.40 - 0.44) * 180 = 1,119.60. +- name: Head Start enrollment qualifies a child above the Head Start income limit. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + employment_income: 100_000 + ssi: 0 + participant: + age: 5 + is_enrolled_in_head_start: true + ssi: 0 + sibling: + age: 10 + ssi: 0 + spm_units: + unit: + members: + - parent + - participant + - sibling + snap: 0 + tanf: 0 + fdpir: 0 + school_meal_fpg_ratio: 3 + households: + home: + members: + - parent + - participant + - sibling + state_code: AL + output: + is_head_start_eligible: + - false + - false + - false + school_meal_tier: PAID + is_school_meal_categorically_eligible: + - false + - true + - false + school_meal_child_breakfast_tier: + - PAID + - FREE + - PAID + school_meal_child_lunch_tier: + - PAID + - FREE + - PAID + free_school_meals: 1119.6 + reduced_price_school_meals: 0 + +# Pub. L. 111-296, section 102(b), added 42 USC 1758(b)(12)(A)(vii) for +# foster children, and section 445 makes it effective October 1, 2010. +# Calendar 2010 reads the list in force on January 1, 2010. +- name: Foster care does not qualify a child before the foster clause took effect. + period: 2010 + input: + age: 10 + is_in_foster_care: + 2010-12: true + snap: 0 + tanf: 0 + fdpir: 0 + output: + is_school_meal_categorically_eligible: false + +- name: Foster care qualifies a child once the foster clause took effect. + period: 2011 + input: + age: 10 + is_in_foster_care: + 2011-12: true + snap: 0 + tanf: 0 + fdpir: 0 + output: + is_school_meal_categorically_eligible: true diff --git a/policyengine_us/tests/policy/baseline/gov/usda/school_meals/meets_school_meal_categorical_eligibility.yaml b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/meets_school_meal_categorical_eligibility.yaml index 42fc0365fdf..7db98697bb1 100644 --- a/policyengine_us/tests/policy/baseline/gov/usda/school_meals/meets_school_meal_categorical_eligibility.yaml +++ b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/meets_school_meal_categorical_eligibility.yaml @@ -26,7 +26,9 @@ output: meets_school_meal_categorical_eligibility: true -- name: Homelessness and migrant status qualify the child separately. +# Each child in a household without a fixed nighttime residence counts as a +# homeless child (42 USC 11434a(2)(A)), so every child qualifies. +- name: Household homelessness qualifies every child. period: 2022 input: snap: 0 @@ -37,6 +39,33 @@ is_runaway_child: false is_migratory_child: true is_head_start_eligible: false + output: + meets_school_meal_categorical_eligibility: true + is_school_meal_categorically_eligible: true + +- name: Migrant status qualifies the child separately. + period: 2022 + input: + snap: 0 + tanf: 0 + fdpir: 0 + was_in_foster_care: false + is_homeless: false + is_runaway_child: false + is_migratory_child: true + is_head_start_eligible: false + output: + meets_school_meal_categorical_eligibility: false + is_school_meal_categorically_eligible: true + +- name: A homeless child qualifies separately from a housed household. + period: 2022 + input: + snap: 0 + tanf: 0 + fdpir: 0 + is_homeless: false + is_homeless_child: true output: meets_school_meal_categorical_eligibility: false is_school_meal_categorically_eligible: true @@ -92,7 +121,7 @@ fdpir: [0, 1, 1, 0, 0, 0, 0, 0] is_homeless: [False, False, True, True, False, False, False, False] output: - meets_school_meal_categorical_eligibility: [True, True, True, False, False, False, False, False] + meets_school_meal_categorical_eligibility: [True, True, True, True, False, False, False, False] is_school_meal_categorically_eligible: [True, True, True, True, False, False, False, False] - name: Reported SNAP receipt qualifies even when the modeled allotment is zero. diff --git a/policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py b/policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py index fb5474416b4..f13a1976ec5 100644 --- a/policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py +++ b/policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py @@ -1,22 +1,18 @@ from policyengine_us.model_api import * -def _school_meal_child_categorical_eligibility(person, period): +def _school_meal_child_categorical_eligibility(person, period, parameters): """Return this person's individual school meal categorical eligibility.""" - # Enrollment qualifies the participant, including an enrollee whose - # income exceeds the modeled Head Start income limit (USDA SP 40-2013). - head_start = person("is_enrolled_in_head_start", period) - foster = person("is_in_foster_care", period, options=[ADD]) > 0 - homeless = person("is_homeless_child", period) | person.household( - "is_homeless", period - ) - return ( - head_start - | foster - | homeless - | person("is_migratory_child", period) - | person("is_runaway_child", period) - ) + # Congress qualifies a child whom Head Start enrolls under 42 U.S.C. + # 9840(a)(1)(B) (42 U.S.C. 1758(b)(12)(A)(iii)). Programs may enroll + # children above the income limit under 9840(a)(1)(B)(iii), so + # enrollment qualifies the child here without an income test. + # Congress also qualifies a foster child whom a title IV-B or IV-E agency + # or a court has placed (1758(b)(12)(A)(vii)). The monthly input + # is_in_foster_care stands in for that placement, and one month of it + # qualifies the child for the year. + p = parameters(period).gov.usda.school_meals + return add(person, period, p.child_categorical_eligibility, options=[ADD]) > 0 class is_school_meal_categorically_eligible(Variable): @@ -26,12 +22,12 @@ class is_school_meal_categorically_eligible(Variable): definition_period = YEAR documentation = ( "Whether this person qualifies through the SPM unit's SNAP, TANF or " - "FDPIR participation, or their own Head Start enrollment, foster care, " - "homelessness, migrant status or runaway status. School meal values " - "also require K-12 attendance." + "FDPIR participation or the household's homelessness, or through their " + "own Head Start enrollment, foster care, homelessness, migrant status " + "or runaway status. School meal values also require K-12 attendance." ) reference = ( - "https://www.law.cornell.edu/uscode/text/42/1758#b_12_A", + "https://uscode.house.gov/us/usc/119-124/t42/s1758/#b-12-A", "https://www.ecfr.gov/current/title-7/section-245.6#p-245.6(b)(7)", "https://www.ecfr.gov/current/title-7/section-245.6#p-245.6(b)(8)", ) @@ -41,5 +37,5 @@ def formula(person, period, parameters): "meets_school_meal_categorical_eligibility", period ) return household_category | _school_meal_child_categorical_eligibility( - person, period + person, period, parameters ) diff --git a/policyengine_us/variables/gov/usda/school_meals/meets_school_meal_categorical_eligibility.py b/policyengine_us/variables/gov/usda/school_meals/meets_school_meal_categorical_eligibility.py index dd51211a452..fd71529f579 100644 --- a/policyengine_us/variables/gov/usda/school_meals/meets_school_meal_categorical_eligibility.py +++ b/policyengine_us/variables/gov/usda/school_meals/meets_school_meal_categorical_eligibility.py @@ -6,10 +6,14 @@ class meets_school_meal_categorical_eligibility(Variable): entity = SPMUnit label = "Household-wide school meal categorical eligibility" documentation = ( - "Whether SNAP, TANF or FDPIR participation qualifies every child in " - "this SPM unit. Child-specific categories also apply through " + "Whether SNAP, TANF or FDPIR participation, or the household's lack of " + "a fixed nighttime residence, qualifies every child in this SPM unit. " + "Child-specific categories also apply through " "is_school_meal_categorically_eligible." ) definition_period = YEAR - reference = "https://www.ecfr.gov/current/title-7/section-245.6#p-245.6(b)(7)" + reference = ( + "https://www.ecfr.gov/current/title-7/section-245.6#p-245.6(b)(7)", + "https://uscode.house.gov/us/usc/119-124/t42/s1758/#b-12-A", + ) adds = "gov.usda.school_meals.categorical_eligibility" diff --git a/policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py index 55169f7011a..1880f602d92 100644 --- a/policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py +++ b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_breakfast_tier.py @@ -24,5 +24,7 @@ class school_meal_child_breakfast_tier(Variable): def formula(person, period, parameters): tier = person.spm_unit("school_meal_breakfast_tier", period) - categorical = _school_meal_child_categorical_eligibility(person, period) + categorical = _school_meal_child_categorical_eligibility( + person, period, parameters + ) return where(categorical, SchoolMealTier.FREE.index, tier) diff --git a/policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py index f7543d85bb4..a3a7d2ab80a 100644 --- a/policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py +++ b/policyengine_us/variables/gov/usda/school_meals/school_meal_child_lunch_tier.py @@ -24,5 +24,7 @@ class school_meal_child_lunch_tier(Variable): def formula(person, period, parameters): tier = person.spm_unit("school_meal_lunch_tier", period) - categorical = _school_meal_child_categorical_eligibility(person, period) + categorical = _school_meal_child_categorical_eligibility( + person, period, parameters + ) return where(categorical, SchoolMealTier.FREE.index, tier) diff --git a/policyengine_us/variables/household/demographic/person/is_enrolled_in_head_start.py b/policyengine_us/variables/household/demographic/person/is_enrolled_in_head_start.py index 7f7e4c56239..1316ccb9942 100644 --- a/policyengine_us/variables/household/demographic/person/is_enrolled_in_head_start.py +++ b/policyengine_us/variables/household/demographic/person/is_enrolled_in_head_start.py @@ -11,6 +11,6 @@ class is_enrolled_in_head_start(Variable): "Enrollment differs from modeled eligibility and hypothetical take-up." ) reference = ( - "https://www.law.cornell.edu/uscode/text/42/1758#b_12_A_iii", - "https://fns-prod.azureedge.us/sites/default/files/cn/SP40_CACFP11_SFSP13-2013os.pdf", + "https://uscode.house.gov/us/usc/119-124/t42/s1758/#b-12-A-iii", + "https://uscode.house.gov/us/usc/119-124/t42/s9840/#a-1-B", ) diff --git a/policyengine_us/variables/household/demographic/person/is_homeless_child.py b/policyengine_us/variables/household/demographic/person/is_homeless_child.py index 1d780f3cf99..c8a6d4df211 100644 --- a/policyengine_us/variables/household/demographic/person/is_homeless_child.py +++ b/policyengine_us/variables/household/demographic/person/is_homeless_child.py @@ -11,9 +11,11 @@ class is_homeless_child(Variable): "Whether a school liaison, shelter director or other authorized " "official has identified this child as homeless under the " "McKinney-Vento definition for school meal certification. This input " - "can identify one child when the whole household is not homeless." + "identifies one child when the whole household is not homeless; " + "is_homeless covers a household without a fixed nighttime residence." ) reference = ( "https://www.ecfr.gov/current/title-7/section-245.2", - "https://www.law.cornell.edu/uscode/text/42/1758#b_12_A_iv", + "https://uscode.house.gov/us/usc/119-124/t42/s1758/#b-12-A-iv", + "https://uscode.house.gov/us/usc/119-124/t42/s11434a/#2", ) diff --git a/policyengine_us/variables/household/demographic/person/is_in_foster_care.py b/policyengine_us/variables/household/demographic/person/is_in_foster_care.py index 25b75d8a082..2e4c2efac11 100644 --- a/policyengine_us/variables/household/demographic/person/is_in_foster_care.py +++ b/policyengine_us/variables/household/demographic/person/is_in_foster_care.py @@ -4,12 +4,5 @@ class is_in_foster_care(Variable): value_type = bool entity = Person - label = "Person is currently in qualifying foster care" + label = "Person is currently in a qualifying foster care institution" definition_period = MONTH - documentation = ( - "Whether an agency administering a State title IV-B or IV-E plan " - "currently holds responsibility for this person's foster care, or a " - "court currently places this person with a caretaker household. " - "Prior foster care alone does not establish current placement." - ) - reference = "https://www.law.cornell.edu/uscode/text/42/1758#b_12_A_vii" From 266b356bf95e83834324f8e132063fc72c7d2e06 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 14 Nov 2026 09:27:14 -0500 Subject: [PATCH 08/11] Show the daily rate arithmetic for the homeless household case Co-Authored-By: Claude Fable 5.2 --- .../usda/school_meals/is_school_meal_categorically_eligible.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml index 98474f1059f..dcf5f157dc5 100644 --- a/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml @@ -567,6 +567,7 @@ # regular and adequate nighttime residence, so every child in a household # that lacks one qualifies at any income (1758(b)(12)(A)(iv)). # At 300% FPG both children would otherwise pay. +# Daily subsidy per child = 2.46 + 4.60 = 7.06. # Free value = 2 children * (2.46 + 4.60 - 0.40 - 0.44) * 180 # = 2 * 6.22 * 180 = 2,239.20. - name: A homeless household gives every child free meals above the income limits. From 903c29f31fce718eebafdb2d65da1caf4aaa1419 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 14 Nov 2026 13:39:06 -0500 Subject: [PATCH 09/11] Read each child category in its own periods Core's Population passes decode_enums to calculate_add whenever a formula gives options=[ADD], and Microsimulation.calculate_add accepts no such argument. The child-category helper gave that option, so a Microsimulation that calculated school meal eligibility raised a TypeError. The helper now reads each listed input in its own definition period and counts every month of a monthly one. Core answers an annual request for a monthly true-or-false input such as is_in_foster_care with December's value, so a plain annual read would drop a placement that ends before December. Add a Microsimulation test on a six-person dataset and a YAML case with a foster placement in March and no other month. Co-Authored-By: Claude Fable 5.2 --- ...meal_categorical_eligibility_invariants.py | 83 ++++++++++++++++++- ...is_school_meal_categorically_eligible.yaml | 49 +++++++++++ .../is_school_meal_categorically_eligible.py | 12 ++- 3 files changed, 142 insertions(+), 2 deletions(-) diff --git a/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py b/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py index d28df83c18a..ca495c818e9 100644 --- a/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py +++ b/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py @@ -5,14 +5,18 @@ The paired units hold their poverty ratios and poverty guidelines fixed when a child joins them. An explicit example covers every state and DC. With computed common tiers, household categories give every child free meals. +The last test reads each child's own category from a six-person +Microsimulation, which the YAML runner cannot build. """ import numpy as np +import pandas as pd import pytest from hypothesis import HealthCheck, example, given, settings from hypothesis import strategies as st -from policyengine_us import Simulation +from policyengine_us import Microsimulation, Simulation +from policyengine_us.data.dataset_schema import USSingleYearDataset YEAR = 2025 MONTHS = tuple(f"{YEAR}-{month:02d}" for month in range(1, 13)) @@ -402,3 +406,80 @@ def test_explicit_common_meal_tier_inputs_preserve_individual_overrides( f"variant={record['variant']} person={name}: " f"tier={child_tiers[person_index[name]]}, expected={expected}" ) + + +def _three_family_dataset(): + """Three Alabama families, each with one parent and one ten-year-old. + + Head Start enrolls the second family's child for the year. No family + receives SNAP, TANF or FDPIR, and each has income at 300% of the poverty + guideline, so a child without a category pays for meals. + """ + family_ids = np.arange(1, 4) + person_ids = np.arange(1, 7) + family_of = np.repeat(family_ids, 2) + person = pd.DataFrame( + { + "person_id": person_ids, + "person_household_id": family_of, + "person_tax_unit_id": family_of, + "person_spm_unit_id": family_of, + "person_family_id": family_of, + "person_marital_unit_id": person_ids, + "age": np.tile([35.0, 10.0], 3), + "is_enrolled_in_head_start": [False, False, False, True, False, False], + } + ) + spm_unit = pd.DataFrame( + { + "spm_unit_id": family_ids, + "snap": np.zeros(3), + "tanf": np.zeros(3), + "fdpir": np.zeros(3), + "school_meal_fpg_ratio": np.full(3, 3.0), + } + ) + household = pd.DataFrame( + { + "household_id": family_ids, + "state_fips": np.full(3, 1), + "household_weight": np.ones(3), + } + ) + return USSingleYearDataset( + person=person, + household=household, + tax_unit=pd.DataFrame({"tax_unit_id": family_ids}), + spm_unit=spm_unit, + family=pd.DataFrame({"family_id": family_ids}), + marital_unit=pd.DataFrame({"marital_unit_id": person_ids}), + time_period=YEAR, + ) + + +def test_child_categories_qualify_each_child_in_a_microsimulation(): + """A Microsimulation gives each child the result a household simulation gives. + + Core routes a formula's variable calls through Microsimulation's own + methods, and the cases above build household simulations. A foster + placement covers July and no other month for the third family's child, + and an annual read of the monthly input leaves July out. + """ + simulation = Microsimulation(dataset=_three_family_dataset(), dataset_end_year=YEAR) + simulation.set_input( + "is_in_foster_care", + f"{YEAR}-07", + np.array([False, False, False, False, False, True]), + ) + eligible = simulation.calculate("is_school_meal_categorically_eligible", YEAR) + assert np.asarray(eligible).tolist() == [False, False, False, True, False, True] + for meal in ("breakfast", "lunch"): + tiers = simulation.calculate(f"school_meal_child_{meal}_tier", YEAR) + assert np.asarray(tiers).tolist() == [ + "PAID", + "PAID", + "PAID", + "FREE", + "PAID", + "FREE", + ], meal diff --git a/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml index dcf5f157dc5..a6b6335f04e 100644 --- a/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml @@ -328,6 +328,55 @@ school_meal_net_subsidy: 1119.6 free_school_meals: 1119.6 reduced_price_school_meals: 0 +# A foster placement covers March 2026 and no other month, and one month of +# is_in_foster_care qualifies the child for the year. +# Free value = (2.46 + 4.60 - 0.40 - 0.44) * 180 = 6.22 * 180 = 1,119.60. +- name: One month of foster care before December qualifies the child for the year. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 35 + participant: + age: 10 + is_in_foster_care: + 2026-03: true + sibling: + age: 10 + spm_units: + unit: + members: + - parent + - participant + - sibling + snap: 0 + tanf: 0 + fdpir: 0 + school_meal_fpg_ratio: 3 + households: + home: + members: + - parent + - participant + - sibling + state_code: AL + output: + is_school_meal_categorically_eligible: + - false + - true + - false + school_meal_child_breakfast_tier: + - PAID + - FREE + - PAID + school_meal_child_lunch_tier: + - PAID + - FREE + - PAID + school_meal_net_subsidy: 1119.6 + free_school_meals: 1119.6 + reduced_price_school_meals: 0 - name: is_homeless_child qualifies only the child with that status. period: 2026 absolute_error_margin: 0.01 diff --git a/policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py b/policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py index f13a1976ec5..4607b148951 100644 --- a/policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py +++ b/policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py @@ -12,7 +12,17 @@ def _school_meal_child_categorical_eligibility(person, period, parameters): # is_in_foster_care stands in for that placement, and one month of it # qualifies the child for the year. p = parameters(period).gov.usda.school_meals - return add(person, period, p.child_categorical_eligibility, options=[ADD]) > 0 + # Core returns December's value when a formula asks for a monthly + # true-or-false input over a year, so this loop reads each input in its + # own periods and counts every month. + qualifying_periods = 0 + for variable in p.child_categorical_eligibility: + definition_period = person.entity.get_variable( + variable, check_existence=True + ).definition_period + for subperiod in period.get_subperiods(definition_period): + qualifying_periods = qualifying_periods + person(variable, subperiod) + return qualifying_periods > 0 class is_school_meal_categorically_eligible(Variable): From 5f40ecfde0eefac489cdebe53de7dde0bdf34d37 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 14 Nov 2026 13:52:17 -0500 Subject: [PATCH 10/11] End each test's foster placement the next month Core carries a monthly input forward to later months that have none, so December read as true in the March case and in the July Microsimulation test, and both passed under a plain annual read of the input. Each now sets the next month to false, so the placement covers one month alone. Co-Authored-By: Claude Fable 5.2 --- .../test_school_meal_categorical_eligibility_invariants.py | 5 ++++- .../school_meals/is_school_meal_categorically_eligible.yaml | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py b/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py index ca495c818e9..a5e7e240160 100644 --- a/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py +++ b/policyengine_us/tests/core/test_school_meal_categorical_eligibility_invariants.py @@ -463,7 +463,7 @@ def test_child_categories_qualify_each_child_in_a_microsimulation(): Core routes a formula's variable calls through Microsimulation's own methods, and the cases above build household simulations. A foster placement covers July and no other month for the third family's child, - and an annual read of the monthly input leaves July out. + and an annual read of the monthly input returns December's value. """ simulation = Microsimulation(dataset=_three_family_dataset(), dataset_end_year=YEAR) simulation.set_input( @@ -471,6 +471,9 @@ def test_child_categories_qualify_each_child_in_a_microsimulation(): f"{YEAR}-07", np.array([False, False, False, False, False, True]), ) + # Core carries the latest earlier monthly input forward, so the test sets + # August to false. + simulation.set_input("is_in_foster_care", f"{YEAR}-08", np.zeros(6, dtype=bool)) eligible = simulation.calculate("is_school_meal_categorically_eligible", YEAR) assert np.asarray(eligible).tolist() == [False, False, False, True, False, True] for meal in ("breakfast", "lunch"): diff --git a/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml index a6b6335f04e..3fbc5877021 100644 --- a/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/usda/school_meals/is_school_meal_categorically_eligible.yaml @@ -329,7 +329,8 @@ free_school_meals: 1119.6 reduced_price_school_meals: 0 # A foster placement covers March 2026 and no other month, and one month of -# is_in_foster_care qualifies the child for the year. +# is_in_foster_care qualifies the child for the year. Core carries the latest +# earlier monthly input forward, so the case sets April to false. # Free value = (2.46 + 4.60 - 0.40 - 0.44) * 180 = 6.22 * 180 = 1,119.60. - name: One month of foster care before December qualifies the child for the year. period: 2026 @@ -342,6 +343,7 @@ age: 10 is_in_foster_care: 2026-03: true + 2026-04: false sibling: age: 10 spm_units: From 731e0b9440ea63c645119604482b82b12c12c9ac Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 14 Nov 2026 16:53:56 -0500 Subject: [PATCH 11/11] Record the Head Start source conflict as a candidate Congress limits automatic free school meals to a child whom a Head Start program enrolls on a determination under 42 U.S.C. 9840(a)(1)(B) (42 U.S.C. 1758(b)(12)(A)(iii)). USDA defines a Head Start child as any child enrolled in a Head Start program (7 CFR 245.2). The model counts every enrollee and has no input for the basis of enrollment. Record the question as an open candidate in source_conflicts/candidates.yaml for the project lead to rule on. Co-Authored-By: Claude Fable 5.2 --- source_conflicts/candidates.yaml | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/source_conflicts/candidates.yaml b/source_conflicts/candidates.yaml index 9d02eda84fd..f3ca1b9810e 100644 --- a/source_conflicts/candidates.yaml +++ b/source_conflicts/candidates.yaml @@ -13780,6 +13780,68 @@ candidates: state: ruled note: Ruled October 2026; verify the worksheet version and whether claiming the rebate defeats the refund-only joint-return exception. +- id: us:school-meals-head-start-categorical-basis + program: school-meals + years: + from: 2007 + type: calendar + question: Does every child enrolled in a Head Start program qualify for free school meals (7 CFR 245.2), or only + a child whom the program enrolled on a determination under 42 U.S.C. 9840(a)(1)(B) (42 U.S.C. + 1758(b)(12)(A)(iii))? + sources: + - kind: statute + citation: 42 U.S.C. 1758(b)(12)(A)(iii) + url: https://uscode.house.gov/us/usc/119-124/t42/s1758/#b-12-A-iii + - kind: statute + citation: 42 U.S.C. 9840(a)(1)(B), (a)(2) and (d)(1) + url: https://uscode.house.gov/us/usc/119-124/t42/s9840/#a-1-B + - kind: statute + citation: Pub. L. 118-47, div. D, title II, sections 238 and 239 (42 U.S.C. 9840 note) + url: https://uscode.house.gov/us/usc/119-124/t42/s9840/#miscellaneous-note + - kind: regulation + citation: 7 CFR 245.2, definitions of "Categorically eligible" and "Head Start child" + url: https://www.ecfr.gov/current/title-7/section-245.2 + - kind: rulemaking + citation: 76 FR 22785, 22791 (April 25, 2011), interim rule, "Children Enrolled in Head Start Programs" + url: https://www.govinfo.gov/content/pkg/FR-2011-04-25/html/2011-9457.htm + readings: + statute: Congress makes a child automatically eligible when a Head Start program enrolls the child "on the basis + of a determination that the child meets the eligibility criteria prescribed under section 645(a)(1)(B) of the + Head Start Act". A child whom a program enrolls on any other basis gets no free meals through Head Start. + other: USDA defines a Head Start child as "a child enrolled as a participant in a Head Start program authorized + under the Head Start Act", with no condition on the basis of enrollment. Its definition of "Categorically + eligible" lists a Head Start child. In the preamble to the 2011 interim rule, USDA says section 29(c) of Pub. + L. 110-134 amended clause (iii) "to extend categorical eligibility for free meals and free milk to all Head + Start enrollees". + example: In is_school_meal_categorically_eligible.yaml, a five-year-old enrollee in a family at 300% of the + poverty guideline gets the free tier in 2026 and free meals worth (2.46 + 4.60 - 0.40 - 0.44) x 180 = + $1,119.60. If a program in a community of 1,000 or fewer people enrolled that child under its own criteria + (9840(a)(2)), the child would get the paid tier and $0 under the statute's reading. + pe_us: + follows: conflicting-source + code: + - policyengine_us/parameters/gov/usda/school_meals/child_categorical_eligibility.yaml + - policyengine_us/variables/gov/usda/school_meals/is_school_meal_categorically_eligible.py + - policyengine_us/variables/household/demographic/person/is_enrolled_in_head_start.py + prs: + - https://github.com/PolicyEngine/policyengine-us/pull/10838 + state: open + note: PE-US counts every Head Start enrollee as categorically eligible. child_categorical_eligibility.yaml lists + is_enrolled_in_head_start, and is_school_meal_categorically_eligible.py qualifies a person when that input is + true, with no income test. is_enrolled_in_head_start.py records enrollment in Head Start or Early Head Start. + The model has no input for the basis of enrollment, so the statute's reading would need one. Under 42 U.S.C. + 9840(a)(1)(B), programs enroll children whose families have income below the poverty line or qualify for public + assistance, homeless children and, within the shares clause (iii) allows, children who meet neither test. A + program can also enroll a child outside (a)(1)(B). Under 9840(a)(2), a program in a community of 1,000 or fewer + people sets its own criteria. Under 9840(d)(1), a tribe that enrolls every low-income child in its community + may enroll children who do not meet the low-income criteria. Under Pub. L. 118-47, div. D, sections 238 and + 239, enacted on March 23, 2024, a tribe or a migrant or seasonal program sets its own selection criteria. + Congress wrote the (a)(1)(B) basis into clause (iii) on December 12, 2007 (Pub. L. 110-134, section 29(c)(1)), + and the clause named the low-income criteria of section 645(a)(1)(A) before then. USDA added both 245.2 + definitions in the interim rule, effective June 24, 2011. is_school_meal_categorically_eligible.yaml pins the + model's reading for an enrollee at high income and for an enrollee above the Head Start income limit. An answer + should say whether the model keeps counting every enrollee, or takes a new input for enrollment on the (a)(1)(B) + basis and counts only those children. - id: us:se-plan-step-2-multiple-businesses program: income-tax years: