From 6e93ee2a214b108c4a01cdee3a195410b566b343 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Fri, 6 Nov 2026 10:46:07 -0500 Subject: [PATCH 1/5] Require an eligible activity for Colorado's child care program 8 CCR 1403-1 section 3.111(B)(1) requires adult caretakers and teen parents to take part in an eligible activity, and section 3.111(D) and (E) say which households qualify. co_ccap_eligible had no such test, so the model paid families with no earnings, study or other activity. co_ccap_activity_eligible adds the test, with the rule's federal minimum wage floor on earnings and its exempt paths for Colorado Works, protective services and homelessness. Part of #9289. Co-Authored-By: Claude Opus 5.5 --- changelog.d/co-ccap-activity-test.fixed.md | 1 + .../ccap/activity/earned_income_sources.yaml | 15 + .../co/ccap/co_ccap_activity_eligible.yaml | 597 ++++++++++++++++++ .../gov/states/co/ccap/co_ccap_eligible.yaml | 48 ++ .../tests/test_co_ccap_activity_properties.py | 238 +++++++ .../co/ccap/co_ccap_activity_eligible.py | 102 +++ .../gov/states/co/ccap/co_ccap_eligible.py | 7 +- 7 files changed, 1006 insertions(+), 2 deletions(-) create mode 100644 changelog.d/co-ccap-activity-test.fixed.md create mode 100644 policyengine_us/parameters/gov/states/co/ccap/activity/earned_income_sources.yaml create mode 100644 policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml create mode 100644 policyengine_us/tests/test_co_ccap_activity_properties.py create mode 100644 policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py diff --git a/changelog.d/co-ccap-activity-test.fixed.md b/changelog.d/co-ccap-activity-test.fixed.md new file mode 100644 index 00000000000..0ad57581171 --- /dev/null +++ b/changelog.d/co-ccap-activity-test.fixed.md @@ -0,0 +1 @@ +Require an eligible activity for Colorado's Child Care Assistance Program under 8 CCR 1403-1 section 3.111. diff --git a/policyengine_us/parameters/gov/states/co/ccap/activity/earned_income_sources.yaml b/policyengine_us/parameters/gov/states/co/ccap/activity/earned_income_sources.yaml new file mode 100644 index 00000000000..49e34da6180 --- /dev/null +++ b/policyengine_us/parameters/gov/states/co/ccap/activity/earned_income_sources.yaml @@ -0,0 +1,15 @@ +description: Colorado counts these income sources as earnings from employment or self-employment under the Child Care Assistance Program activity requirement. +values: + 2020-01-01: + - employment_income + - self_employment_income + - sstb_self_employment_income + - farm_operations_income + +metadata: + unit: list + period: year + label: Colorado CCAP activity requirement earned income sources + reference: + - title: 8 CCR 1403-1 Section 3.111(G)(1) and (2), employment and self-employed criteria + href: https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=36 diff --git a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml new file mode 100644 index 00000000000..45b93042e04 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml @@ -0,0 +1,597 @@ +# 8 CCR 1403-1 section 3.111(B)(1), (D), (E) and (G); 3.116(A); 3.119(D); 3.121(B)(3). +# Federal minimum wage $7.25: 40 hours for 52 weeks is 2,080 hours, so the floor is $15,080. +- name: Case 1, single parent with wages and no recorded hours meets the requirement. + period: 2026-01 + input: + people: + parent: + age: 30 + employment_income: 20_000 + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + co_ccap_activity_eligible: true + +- name: Case 2, single parent with no activity does not meet the requirement. + period: 2026-01 + input: + people: + parent: + age: 30 + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + co_ccap_activity_eligible: false + +- name: Case 3, wages exactly at the minimum wage floor for the hours worked meet the requirement. + period: 2026-01 + input: + people: + parent: + age: 30 + employment_income: 15_080 + weekly_hours_worked_before_lsr: 40 + weeks_worked: 52 + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + co_ccap_activity_eligible: true + +- name: Case 4, wages a dollar below the floor fail 3.111(G)(1)(b). + period: 2026-01 + input: + people: + parent: + age: 30 + employment_income: 15_079 + weekly_hours_worked_before_lsr: 40 + weeks_worked: 52 + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + co_ccap_activity_eligible: false + +- name: Case 5, the floor counts only the weeks worked, so $10,000 for 26 weeks at 40 hours passes. + period: 2026-01 + input: + people: + parent: + age: 30 + employment_income: 10_000 + weekly_hours_worked_before_lsr: 40 + weeks_worked: 26 + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + # 40 x 26 = 1,040 hours x $7.25 = $7,540 <= $10,000 + co_ccap_activity_eligible: true + +- name: Case 6, with no weeks reported, usual hours run the full year, so the same $10,000 fails. + period: 2026-01 + input: + people: + parent: + age: 30 + employment_income: 10_000 + weekly_hours_worked_before_lsr: 40 + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + co_ccap_activity_eligible: false + +- name: Case 7, self-employment income above the floor meets 3.111(G)(2). + period: 2026-01 + input: + people: + parent: + age: 30 + self_employment_income: 20_000 + weekly_hours_worked_before_lsr: 30 + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + # 30 x 52 = 1,560 hours x $7.25 = $11,310 <= $20,000 + co_ccap_activity_eligible: true + +- name: Case 8, a business loss fails 3.111(G)(2)(c). + period: 2026-01 + input: + people: + parent: + age: 30 + self_employment_income: -5_000 + weekly_hours_worked_before_lsr: 30 + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + co_ccap_activity_eligible: false + +- name: Case 9, a business loss does not erase wages. + period: 2026-01 + input: + people: + parent: + age: 30 + employment_income: 20_000 + self_employment_income: -30_000 + weekly_hours_worked_before_lsr: 40 + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + co_ccap_activity_eligible: true + +- name: Case 10, a full-time college student meets 3.111(G)(4). + period: 2026-01 + input: + people: + parent: + age: 30 + is_full_time_college_student: true + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + co_ccap_activity_eligible: true + +- name: Case 11, two parents who both work meet 3.111(D)(1)(c)(1). + period: 2026-01 + input: + people: + parent1: + age: 30 + employment_income: 20_000 + parent2: + age: 30 + employment_income: 20_000 + child: + age: 3 + spm_units: + spm_unit: + members: [parent1, parent2, child] + tax_units: + tax_unit: + members: [parent1, parent2, child] + households: + household: + members: [parent1, parent2, child] + state_code: CO + output: + co_ccap_activity_eligible: true + +- name: Case 12, one parent working and the other at home and able to provide care fail 3.111(D)(1)(c). + period: 2026-01 + input: + people: + parent1: + age: 30 + employment_income: 20_000 + parent2: + age: 30 + child: + age: 3 + spm_units: + spm_unit: + members: [parent1, parent2, child] + tax_units: + tax_unit: + members: [parent1, parent2, child] + households: + household: + members: [parent1, parent2, child] + state_code: CO + output: + co_ccap_activity_eligible: false + +- name: Case 13, one parent working and the other incapacitated meet 3.111(D)(1)(c)(3). + period: 2026-01 + input: + people: + parent1: + age: 30 + employment_income: 20_000 + parent2: + age: 30 + is_disabled: true + child: + age: 3 + spm_units: + spm_unit: + members: [parent1, parent2, child] + tax_units: + tax_unit: + members: [parent1, parent2, child] + households: + household: + members: [parent1, parent2, child] + state_code: CO + output: + co_ccap_activity_eligible: true + +- name: Case 14, an incapacitated single parent with no activity fails 3.111(E). + period: 2026-01 + input: + people: + parent: + age: 30 + is_disabled: true + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + co_ccap_activity_eligible: false + +- name: Case 15, two incapacitated parents with no activity fail, since neither is in an activity. + period: 2026-01 + input: + people: + parent1: + age: 30 + is_disabled: true + parent2: + age: 30 + is_disabled: true + child: + age: 3 + spm_units: + spm_unit: + members: [parent1, parent2, child] + tax_units: + tax_unit: + members: [parent1, parent2, child] + households: + household: + members: [parent1, parent2, child] + state_code: CO + output: + co_ccap_activity_eligible: false + +- name: Case 16, an incarcerated parent counts as absent under 3.111(D)(1)(b), so the working parent qualifies. + period: 2026-01 + input: + people: + parent1: + age: 30 + employment_income: 20_000 + parent2: + age: 30 + is_incarcerated: true + child: + age: 3 + spm_units: + spm_unit: + members: [parent1, parent2, child] + tax_units: + tax_unit: + members: [parent1, parent2, child] + households: + household: + members: [parent1, parent2, child] + state_code: CO + output: + co_ccap_activity_eligible: true + +- name: Case 17, a retired grandparent who files separately is not a caretaker under 3.103(C). + period: 2026-01 + input: + people: + grandparent: + age: 70 + parent: + age: 30 + employment_income: 20_000 + child: + age: 3 + spm_units: + spm_unit: + members: [grandparent, parent, child] + tax_units: + grandparent_tax_unit: + members: [grandparent] + parent_tax_unit: + members: [parent, child] + households: + household: + members: [grandparent, parent, child] + state_code: CO + output: + co_ccap_activity_eligible: true + +- name: Case 18, a working grandparent who files separately does not supply the claiming parent's activity. + period: 2026-01 + input: + people: + grandparent: + age: 60 + employment_income: 50_000 + parent: + age: 30 + child: + age: 3 + spm_units: + spm_unit: + members: [grandparent, parent, child] + tax_units: + grandparent_tax_unit: + members: [grandparent] + parent_tax_unit: + members: [parent, child] + households: + household: + members: [grandparent, parent, child] + state_code: CO + output: + co_ccap_activity_eligible: false + +- name: Case 19, the activity input covers job search and other activities the model does not track. + period: 2026-01 + input: + people: + parent: + age: 30 + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + meets_ccdf_activity_test: true + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + co_ccap_activity_eligible: true + +- name: Case 20, Colorado Works enrollment meets 3.116(A). + period: 2026-01 + input: + people: + parent: + age: 30 + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + is_tanf_enrolled: true + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + co_ccap_activity_eligible: true + +- name: Case 21, an eligible child under protective services exempts the household under 3.119(D). + period: 2026-01 + input: + people: + caretaker: + age: 50 + child: + age: 3 + receives_or_needs_protective_services: true + spm_units: + spm_unit: + members: [caretaker, child] + tax_units: + tax_unit: + members: [caretaker, child] + households: + household: + members: [caretaker, child] + state_code: CO + output: + co_ccap_activity_eligible: true + +- name: Case 22, an eligible child in foster care exempts the household under 3.118(A) and 3.119(D). + period: 2026-01 + input: + people: + caretaker: + age: 50 + child: + age: 3 + is_in_foster_care: true + spm_units: + spm_unit: + members: [caretaker, child] + tax_units: + tax_unit: + members: [caretaker, child] + households: + household: + members: [caretaker, child] + state_code: CO + output: + co_ccap_activity_eligible: true + +- name: Case 23, a family experiencing homelessness is exempt under 3.121(B)(3)(a). + period: 2026-01 + input: + people: + parent: + age: 30 + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + is_homeless: true + output: + co_ccap_activity_eligible: true + +- name: Case 24, a working parent with an eligible child receives the subsidy through the full pipeline. + period: 2026-01 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 30 + employment_income: 30_000 + child: + age: 3 + childcare_hours_per_day: 8 + spm_units: + spm_unit: + members: [parent, child] + spm_unit_pre_subsidy_childcare_expenses: 12_000 + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + county: DENVER_COUNTY_CO + output: + co_ccap_activity_eligible: true + co_ccap_eligible: true + # $1,000 a month less the $115.57 parent fee in court_supervision.yaml Case 5. + co_ccap_subsidy: 884.43 + +- name: Case 25, the same family with the same income from a pension receives nothing. + period: 2026-01 + input: + people: + parent: + age: 30 + pension_income: 30_000 + child: + age: 3 + childcare_hours_per_day: 8 + spm_units: + spm_unit: + members: [parent, child] + spm_unit_pre_subsidy_childcare_expenses: 12_000 + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + county: DENVER_COUNTY_CO + output: + co_ccap_activity_eligible: false + co_ccap_eligible: false + co_ccap_subsidy: 0 diff --git a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_eligible.yaml index 9d62bb51f3f..cde27d747c1 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_eligible.yaml @@ -7,6 +7,8 @@ co_ccap_is_in_re_determination_process: false co_ccap_re_determination_eligible: 2023-01: true + co_ccap_activity_eligible: + 2023-01: true state_code: CO output: co_ccap_eligible: @@ -21,6 +23,8 @@ co_ccap_is_in_re_determination_process: false co_ccap_re_determination_eligible: 2023-01: true + co_ccap_activity_eligible: + 2023-01: true state_code: CO output: co_ccap_eligible: @@ -35,6 +39,8 @@ co_ccap_is_in_re_determination_process: false co_ccap_re_determination_eligible: 2023-01: true + co_ccap_activity_eligible: + 2023-01: true state_code: CO output: co_ccap_eligible: @@ -49,6 +55,8 @@ co_ccap_is_in_re_determination_process: true co_ccap_re_determination_eligible: 2023-01: true + co_ccap_activity_eligible: + 2023-01: true state_code: CO output: co_ccap_eligible: @@ -63,6 +71,8 @@ co_ccap_is_in_re_determination_process: true co_ccap_re_determination_eligible: 2023-01: false + co_ccap_activity_eligible: + 2023-01: true state_code: CO output: co_ccap_eligible: @@ -77,6 +87,8 @@ co_ccap_is_in_re_determination_process: true co_ccap_re_determination_eligible: 2023-01: false + co_ccap_activity_eligible: + 2023-01: true state_code: CO output: co_ccap_eligible: @@ -91,6 +103,8 @@ co_ccap_is_in_re_determination_process: false co_ccap_re_determination_eligible: 2023-01: false + co_ccap_activity_eligible: + 2023-01: true state_code: CO output: co_ccap_eligible: @@ -105,7 +119,41 @@ co_ccap_is_in_re_determination_process: true co_ccap_re_determination_eligible: 2023-01: false + co_ccap_activity_eligible: + 2023-01: true state_code: CO output: co_ccap_eligible: 2023-01: false + +- name: Eligible at entry with no activity, then ineligible for cccap + period: 2023 + input: + co_ccap_is_in_entry_process: true + co_ccap_entry_eligible: + 2023-01: true + co_ccap_is_in_re_determination_process: false + co_ccap_re_determination_eligible: + 2023-01: false + co_ccap_activity_eligible: + 2023-01: false + state_code: CO + output: + co_ccap_eligible: + 2023-01: false + +- name: Eligible at re-determination with no activity, then ineligible for cccap + period: 2023 + input: + co_ccap_is_in_entry_process: false + co_ccap_entry_eligible: + 2023-01: false + co_ccap_is_in_re_determination_process: true + co_ccap_re_determination_eligible: + 2023-01: true + co_ccap_activity_eligible: + 2023-01: false + state_code: CO + output: + co_ccap_eligible: + 2023-01: false diff --git a/policyengine_us/tests/test_co_ccap_activity_properties.py b/policyengine_us/tests/test_co_ccap_activity_properties.py new file mode 100644 index 00000000000..19959414264 --- /dev/null +++ b/policyengine_us/tests/test_co_ccap_activity_properties.py @@ -0,0 +1,238 @@ +"""Invariants of Colorado's child care activity requirement. + +8 CCR 1403-1 section 3.111(B)(1) requires caretakers to take part in an eligible +activity, and (D) and (E) say which households qualify. + +1. A caretaker works when earnings are positive and at least the federal minimum + wage for the hours worked (3.111(G)(1)(b) and (G)(2)(d)). Without the exempt + paths, a household qualifies when a caretaker is in an activity and every other + caretaker is in an activity or incapacitated (3.111(D)(1)(c), 3.111(E)). +2. No family without the requirement receives a subsidy: co_ccap_eligible implies + co_ccap_activity_eligible, and co_ccap_subsidy is zero without it. +3. Raising a caretaker's earnings never removes eligibility while hours stay the + same. +4. An adult who files separately and claims no eligible child doesn't change the + answer, whatever that adult earns. +5. The exempt paths each qualify a family with no activity (3.116(A), 3.119(D), + 3.121(B)(3)(a), and the activity input). + +The YAML cases pin single families. These generate earnings, hours, weeks and +family makeups, which YAML can't express. +""" + +import pytest +from hypothesis import example, given, settings +from hypothesis import strategies as st + +from policyengine_us import Simulation + +YEAR = 2026 +MONTH = "2026-01" +MINIMUM_WAGE = 7.25 +WEEKS_IN_YEAR = 52 + +caretakers = st.fixed_dictionaries( + { + "wages": st.integers(min_value=0, max_value=60_000), + "business": st.integers(min_value=-30_000, max_value=60_000), + "hours": st.integers(min_value=0, max_value=70), + "weeks": st.integers(min_value=0, max_value=52), + "student": st.booleans(), + "disabled": st.booleans(), + } +) + + +def person_input(caretaker): + return { + "age": {YEAR: 30}, + "employment_income": {YEAR: caretaker["wages"]}, + "self_employment_income": {YEAR: caretaker["business"]}, + "weekly_hours_worked_before_lsr": {YEAR: caretaker["hours"]}, + "weeks_worked": {YEAR: caretaker["weeks"]}, + "is_full_time_college_student": {YEAR: caretaker["student"]}, + "is_disabled": {YEAR: caretaker["disabled"]}, + } + + +def simulate(caretakers, spm_unit=None, household=None, other_adult=None, child=None): + names = [f"caretaker{index}" for index in range(len(caretakers))] + people = {name: person_input(item) for name, item in zip(names, caretakers)} + people["child"] = {"age": {YEAR: 3}, **(child or {})} + family = names + ["child"] + tax_units = {"claiming": {"members": family}} + members = list(family) + if other_adult is not None: + people["other_adult"] = {"age": {YEAR: 60}, **other_adult} + tax_units["other"] = {"members": ["other_adult"]} + members.append("other_adult") + situation = { + "people": people, + "tax_units": tax_units, + "spm_units": { + "spm_unit": { + "members": members, + "spm_unit_pre_subsidy_childcare_expenses": {YEAR: 12_000}, + **(spm_unit or {}), + } + }, + "families": {"family": {"members": members}}, + "marital_units": {name: {"members": [name]} for name in people}, + "households": { + "household": { + "members": members, + "state_name": {YEAR: "CO"}, + **(household or {}), + } + }, + } + return Simulation(situation=situation) + + +def activity_eligible(simulation): + return bool(simulation.calculate("co_ccap_activity_eligible", MONTH)[0]) + + +def in_activity(caretaker): + earnings = max(caretaker["wages"], 0) + max(caretaker["business"], 0) + weeks = caretaker["weeks"] or WEEKS_IN_YEAR + floor = MINIMUM_WAGE * caretaker["hours"] * weeks + return caretaker["student"] or (earnings > 0 and earnings >= floor) + + +def rule_says_eligible(caretakers): + active = [in_activity(item) for item in caretakers] + covered = [ + is_active or item["disabled"] for is_active, item in zip(active, caretakers) + ] + return any(active) and all(covered) + + +@settings(max_examples=25, deadline=None) +@given(family=st.lists(caretakers, min_size=1, max_size=2)) +# A dollar below and exactly at the floor for 2,080 hours. +@example( + family=[ + { + "wages": 15_079, + "business": 0, + "hours": 40, + "weeks": 52, + "student": False, + "disabled": False, + } + ] +) +@example( + family=[ + { + "wages": 15_080, + "business": 0, + "hours": 40, + "weeks": 52, + "student": False, + "disabled": False, + } + ] +) +# An incapacitated caretaker alone, and beside a working caretaker. +@example( + family=[ + { + "wages": 0, + "business": 0, + "hours": 0, + "weeks": 0, + "student": False, + "disabled": True, + } + ] +) +@example( + family=[ + { + "wages": 20_000, + "business": 0, + "hours": 0, + "weeks": 0, + "student": False, + "disabled": False, + }, + { + "wages": 0, + "business": 0, + "hours": 0, + "weeks": 0, + "student": False, + "disabled": True, + }, + ] +) +def test_activity_requirement_follows_the_rule(family): + simulation = simulate(family) + assert activity_eligible(simulation) == rule_says_eligible(family) + + +@settings(max_examples=15, deadline=None) +@given(family=st.lists(caretakers, min_size=1, max_size=2)) +def test_no_family_without_the_requirement_receives_a_subsidy(family): + simulation = simulate(family) + eligible = bool(simulation.calculate("co_ccap_eligible", MONTH)[0]) + subsidy = float(simulation.calculate("co_ccap_subsidy", MONTH)[0]) + if not activity_eligible(simulation): + assert not eligible + assert subsidy == 0 + if eligible: + assert activity_eligible(simulation) + assert subsidy >= 0 + + +@settings(max_examples=15, deadline=None) +@given( + family=st.lists(caretakers, min_size=1, max_size=2), + raise_by=st.integers(min_value=1, max_value=40_000), +) +def test_more_earnings_never_remove_the_activity(family, raise_by): + before = activity_eligible(simulate(family)) + raised = [{**family[0], "wages": family[0]["wages"] + raise_by}] + family[1:] + after = activity_eligible(simulate(raised)) + assert after >= before + + +@settings(max_examples=15, deadline=None) +@given( + family=st.lists(caretakers, min_size=1, max_size=2), + other_earnings=st.integers(min_value=0, max_value=60_000), +) +def test_a_separate_filer_does_not_change_the_answer(family, other_earnings): + alone = activity_eligible(simulate(family)) + beside = simulate(family, other_adult={"employment_income": {YEAR: other_earnings}}) + assert activity_eligible(beside) == alone + + +NO_ACTIVITY = { + "wages": 0, + "business": 0, + "hours": 0, + "weeks": 0, + "student": False, + "disabled": False, +} + + +def test_a_family_with_no_activity_fails_without_an_exempt_path(): + assert not activity_eligible(simulate([NO_ACTIVITY])) + + +@pytest.mark.parametrize( + "path", + [ + {"spm_unit": {"is_tanf_enrolled": {MONTH: True}}}, + {"spm_unit": {"meets_ccdf_activity_test": {YEAR: True}}}, + {"household": {"is_homeless": {YEAR: True}}}, + {"child": {"receives_or_needs_protective_services": {YEAR: True}}}, + {"child": {"is_in_foster_care": {MONTH: True}}}, + ], +) +def test_each_exempt_path_qualifies_a_family_with_no_activity(path): + assert activity_eligible(simulate([NO_ACTIVITY], **path)) diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py new file mode 100644 index 00000000000..e9cba1bfb04 --- /dev/null +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py @@ -0,0 +1,102 @@ +from policyengine_us.model_api import * + + +class co_ccap_activity_eligible(Variable): + value_type = bool + entity = SPMUnit + label = "Meets the Colorado Child Care Assistance Program activity requirement" + definition_period = MONTH + defined_for = StateCode.CO + reference = ( + # 3.111(B)(1): caretakers must participate in an eligible activity. + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=31", + # 3.111(D)(1): eligible households with one or two caretakers. + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=33", + # 3.111(E): an incapacitated single caretaker with no activity. + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=35", + # 3.111(G): employment, self-employment, job search, education. + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=36", + # 3.116(A): Colorado Works participants. + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=63", + # 3.119(D): protective services households. + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=69", + # 3.121(B)(3): families experiencing homelessness. + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=72", + ) + + def formula(spm_unit, period, parameters): + p = parameters(period).gov.states.co.ccap.activity + person = spm_unit.members + year = period.this_year + # Clip each source so a business loss can't erase wages. + earnings = np.sum( + [max_(person(source, year), 0) for source in p.earned_income_sources], + axis=0, + ) + # 3.111(G)(1)(b) and (G)(2)(d) require gross income of at least the + # federal minimum wage for each hour worked. Weeks of zero mean none were + # reported, so usual hours apply to the full year. A person with earnings + # and no recorded hours passes, since no hours can pull the rate below + # the floor. + weeks = person("weeks_worked", year) + weeks_at_work = where(weeks > 0, min_(weeks, WEEKS_IN_YEAR), WEEKS_IN_YEAR) + # Pre-response hours avoid a circular dependency through labor supply + # responses. + annual_hours = person("weekly_hours_worked_before_lsr", year) * weeks_at_work + wage_floor = parameters(period).gov.dol.minimum_wage * annual_hours + works = (earnings > 0) & (earnings >= wage_floor) + # 3.111(G)(4) covers post-secondary education, training and basic + # education. The model can't see the lifetime week limits. + in_activity = works | person("is_full_time_student", year) + # 3.103(C) limits caretakers to the parents, guardians and those in loco + # parentis who contribute to the child's welfare, so the filers who claim + # an eligible child stand in for them. Another adult in the home doesn't + # count. 3.111(D)(1)(b) treats a caretaker who is involuntarily out of + # the home, as through incarceration, as absent. + eligible_child = person("co_ccap_child_eligible", period) + claims_eligible_child = person.tax_unit.sum(eligible_child) > 0 + caretaker = ( + person("is_tax_unit_head_or_spouse", year) + & claims_eligible_child + & ~person("is_incarcerated", period) + ) + # 3.111(D)(1)(c)(3) lets one caretaker be incapacitated when the other is + # in an activity, and 3.111(E) bars a single incapacitated caretaker with + # no activity. Disability stands in for the medical verification. + incapacitated = person("is_disabled", year) | person( + "is_incapable_of_self_care", year + ) + has_active_caretaker = spm_unit.sum(caretaker & in_activity) > 0 + no_inactive_caretaker = ( + spm_unit.sum(caretaker & ~in_activity & ~incapacitated) == 0 + ) + low_income_activity = has_active_caretaker & no_inactive_caretaker + # 3.116(A) treats Colorado Works participants in allowable work activities + # as in an eligible activity. Enrollment stands in for the individualized + # plan and referral. + colorado_works = spm_unit("is_tanf_enrolled", period) + # 3.118(A) and 3.119(D) exempt households with children placed in foster + # or kinship care under an open child welfare case. + protective_services = spm_unit.any( + eligible_child + & ( + person("receives_or_needs_protective_services", year) + | person("is_in_foster_care", period) + ) + ) + # 3.121(B)(3)(a) waives the activity during a stabilization period of at + # least 60 days. The model can't track that period, so the exemption + # lasts as long as the household's homeless flag. + homeless = spm_unit.household("is_homeless", year) + # This input covers job search (3.111(G)(3)), part-time study, substance + # use disorder treatment (3.111(G)(4)(a)(3)), the launch period for a new + # business (3.111(G)(2)(e)), temporary leave (3.111(D)(8) and (9)) and + # Child Welfare Child Care (3.120). + other_activity = spm_unit("meets_ccdf_activity_test", year) + return ( + low_income_activity + | colorado_works + | protective_services + | homeless + | other_activity + ) diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_eligible.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_eligible.py index 4db8a20a301..bc37eed38ac 100644 --- a/policyengine_us/variables/gov/states/co/ccap/co_ccap_eligible.py +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_eligible.py @@ -9,6 +9,7 @@ class co_ccap_eligible(Variable): "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=11042&fileName=8%20CCR%201403-1#page=17", "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=11042&fileName=8%20CCR%201403-1#page=19", "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=11042&fileName=8%20CCR%201403-1#page=31", + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=31", ) definition_period = MONTH defined_for = StateCode.CO @@ -23,6 +24,8 @@ def formula(spm_unit, period, parameters): "co_ccap_re_determination_eligible", period ) - return (in_entry_process & entry_eligible) | ( - in_re_determination_process & re_determination_eligible + activity_eligible = spm_unit("co_ccap_activity_eligible", period) + return activity_eligible & ( + (in_entry_process & entry_eligible) + | (in_re_determination_process & re_determination_eligible) ) From 84d27a45d968f32ac60492b1052b256087238ebb Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 9 Nov 2026 12:09:54 -0500 Subject: [PATCH 2/5] Update Colorado's activity test for the household parent fee #10721 charges the Denver family in Case 24 the $128 fee that court_supervision.yaml Case 5 computes, so the subsidy falls from $884.43 to $872. Co-Authored-By: Claude Opus 5.5 --- .../gov/states/co/ccap/co_ccap_activity_eligible.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml index 45b93042e04..f51c147285b 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml @@ -566,8 +566,8 @@ output: co_ccap_activity_eligible: true co_ccap_eligible: true - # $1,000 a month less the $115.57 parent fee in court_supervision.yaml Case 5. - co_ccap_subsidy: 884.43 + # $1,000 a month less the $128 parent fee in court_supervision.yaml Case 5. + co_ccap_subsidy: 872 - name: Case 25, the same family with the same income from a pension receives nothing. period: 2026-01 From d9721c191c16af6345c9fc8d6aa5a7a5d3d6079a Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Wed, 11 Nov 2026 13:53:11 -0500 Subject: [PATCH 3/5] Count caretakers by parent ids and tighten Colorado's activity paths Under 8 CCR 1403-1 section 3.111(D)(2), Colorado counts the adults who support a child or take on a parent's duties whatever their tax filing, so a parent that the child's parent ids name in the same SPM unit now counts as a caretaker beside the claiming filers. Under sections 3.111(D)(6) and 3.115(C), caretakers of children who receive basic cash assistance without them must meet the low-income test, so TANF receipt no longer exempts a family; Colorado Works participants under 3.116(A) set meets_ccdf_activity_test. Section 3.111(G)(4)(a)(1) counts training and post-secondary programs for a first bachelor's degree or less, full or part time. The new co_ccap_in_eligible_education defaults to school or college enrollment and lets users exclude a graduate student. The references now give one entry per document, with the 2023 edition and 45 CFR 98.20(a)(3) for earlier years. Co-Authored-By: Claude Opus 5.5 --- .../co/ccap/co_ccap_activity_eligible.yaml | 170 +++++++++++++++++- .../ccap/co_ccap_in_eligible_education.yaml | 44 +++++ .../tests/test_co_ccap_activity_properties.py | 73 ++++++-- .../co/ccap/co_ccap_activity_eligible.py | 87 ++++----- .../co/ccap/co_ccap_in_eligible_education.py | 26 +++ 5 files changed, 344 insertions(+), 56 deletions(-) create mode 100644 policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_in_eligible_education.yaml create mode 100644 policyengine_us/variables/gov/states/co/ccap/co_ccap_in_eligible_education.py diff --git a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml index f51c147285b..3f7d14b2e8e 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml @@ -1,4 +1,4 @@ -# 8 CCR 1403-1 section 3.111(B)(1), (D), (E) and (G); 3.116(A); 3.119(D); 3.121(B)(3). +# 8 CCR 1403-1 section 3.111(B)(1), (D), (E) and (G); 3.115(C); 3.116(A); 3.119(D); 3.121(B)(3). # Federal minimum wage $7.25: 40 hours for 52 weeks is 2,080 hours, so the floor is $15,080. - name: Case 1, single parent with wages and no recorded hours meets the requirement. period: 2026-01 @@ -210,7 +210,7 @@ output: co_ccap_activity_eligible: true -- name: Case 10, a full-time college student meets 3.111(G)(4). +- name: Case 10, a full-time college student meets 3.111(G)(4)(a)(1), which the model takes to be a first bachelor's degree or less. period: 2026-01 input: people: @@ -452,7 +452,7 @@ output: co_ccap_activity_eligible: true -- name: Case 20, Colorado Works enrollment meets 3.116(A). +- name: Case 20, TANF receipt alone does not meet the requirement, since 3.115(C) holds caretakers of children on basic cash assistance to the low-income test. period: 2026-01 input: people: @@ -472,7 +472,7 @@ members: [parent, child] state_code: CO output: - co_ccap_activity_eligible: true + co_ccap_activity_eligible: false - name: Case 21, an eligible child under protective services exempts the household under 3.119(D). period: 2026-01 @@ -595,3 +595,165 @@ co_ccap_activity_eligible: false co_ccap_eligible: false co_ccap_subsidy: 0 + +- name: Case 26, a graduate student is not in a first bachelor's degree program, so the student fails 3.111(G)(4)(a)(1). + period: 2026-01 + input: + people: + parent: + age: 30 + is_full_time_college_student: true + co_ccap_in_eligible_education: false + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + co_ccap_activity_eligible: false + +- name: Case 27, a part-time college student meets 3.111(G)(4)(a)(1), which sets no full-time requirement. + period: 2026-01 + input: + people: + parent: + age: 30 + is_part_time_college_student: true + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + co_ccap_activity_eligible: true + +- name: Case 28, a Colorado Works participant in allowable work activities meets 3.116(A) through the activity input. + period: 2026-01 + input: + people: + parent: + age: 30 + child: + age: 3 + spm_units: + spm_unit: + members: [parent, child] + is_tanf_enrolled: true + meets_ccdf_activity_test: true + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: CO + output: + co_ccap_activity_eligible: true + +- name: Case 29, a father whom the child's parent ids name counts as a caretaker under 3.111(D)(2) though he files separately, so his lack of activity blocks the working mother. + period: 2026-01 + input: + people: + mother: + person_id: 1 + age: 30 + employment_income: 30_000 + father: + person_id: 2 + age: 30 + child: + person_id: 3 + age: 3 + parent_1_id: 1 + parent_2_id: 2 + spm_units: + spm_unit: + members: [mother, father, child] + tax_units: + mother_tax_unit: + members: [mother, child] + father_tax_unit: + members: [father] + households: + household: + members: [mother, father, child] + state_code: CO + output: + co_ccap_activity_eligible: false + +- name: Case 30, the same father working supplies the activity beside an incapacitated mother under 3.111(D)(1)(c)(3). + period: 2026-01 + input: + people: + mother: + person_id: 1 + age: 30 + is_disabled: true + father: + person_id: 2 + age: 30 + employment_income: 30_000 + child: + person_id: 3 + age: 3 + parent_1_id: 1 + parent_2_id: 2 + spm_units: + spm_unit: + members: [mother, father, child] + tax_units: + mother_tax_unit: + members: [mother, child] + father_tax_unit: + members: [father] + households: + household: + members: [mother, father, child] + state_code: CO + output: + co_ccap_activity_eligible: true + +- name: Case 31, a working grandparent whom the mother's parent ids name is still not the child's caretaker, so the inactive mother fails. + period: 2026-01 + input: + people: + grandparent: + person_id: 1 + age: 60 + employment_income: 50_000 + mother: + person_id: 2 + age: 30 + parent_1_id: 1 + child: + person_id: 3 + age: 3 + parent_1_id: 2 + spm_units: + spm_unit: + members: [grandparent, mother, child] + tax_units: + grandparent_tax_unit: + members: [grandparent] + mother_tax_unit: + members: [mother, child] + households: + household: + members: [grandparent, mother, child] + state_code: CO + output: + co_ccap_activity_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_in_eligible_education.yaml b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_in_eligible_education.yaml new file mode 100644 index 00000000000..2bfd3f8e5dd --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_in_eligible_education.yaml @@ -0,0 +1,44 @@ +# 8 CCR 1403-1 section 3.111(G)(4): training, post-secondary education for a first +# bachelor's degree or less, and basic education. +- name: Case 1, a full-time college student counts. + period: 2026 + input: + is_full_time_college_student: true + age: 30 + state_code: CO + output: + co_ccap_in_eligible_education: true + +- name: Case 2, a part-time college student counts, since 3.111(G)(4)(a)(1) sets no full-time requirement. + period: 2026 + input: + is_part_time_college_student: true + age: 30 + state_code: CO + output: + co_ccap_in_eligible_education: true + +- name: Case 3, a teen parent in high school counts as in basic education under 3.111(G)(4)(b). + period: 2026 + input: + age: 17 + state_code: CO + output: + co_ccap_in_eligible_education: true + +- name: Case 4, an adult who is not enrolled does not count. + period: 2026 + input: + age: 30 + state_code: CO + output: + co_ccap_in_eligible_education: false + +- name: Case 5, the variable applies only in Colorado. + period: 2026 + input: + is_full_time_college_student: true + age: 30 + state_code: NM + output: + co_ccap_in_eligible_education: false diff --git a/policyengine_us/tests/test_co_ccap_activity_properties.py b/policyengine_us/tests/test_co_ccap_activity_properties.py index 19959414264..3bbbcbc8b39 100644 --- a/policyengine_us/tests/test_co_ccap_activity_properties.py +++ b/policyengine_us/tests/test_co_ccap_activity_properties.py @@ -4,17 +4,21 @@ activity, and (D) and (E) say which households qualify. 1. A caretaker works when earnings are positive and at least the federal minimum - wage for the hours worked (3.111(G)(1)(b) and (G)(2)(d)). Without the exempt - paths, a household qualifies when a caretaker is in an activity and every other + wage for the hours worked (3.111(G)(1)(b) and (G)(2)(d)), and studies when + enrolled in college full or part time (3.111(G)(4)). Without the exempt paths, + a household qualifies when a caretaker is in an activity and every other caretaker is in an activity or incapacitated (3.111(D)(1)(c), 3.111(E)). 2. No family without the requirement receives a subsidy: co_ccap_eligible implies co_ccap_activity_eligible, and co_ccap_subsidy is zero without it. 3. Raising a caretaker's earnings never removes eligibility while hours stay the same. -4. An adult who files separately and claims no eligible child doesn't change the - answer, whatever that adult earns. -5. The exempt paths each qualify a family with no activity (3.116(A), 3.119(D), - 3.121(B)(3)(a), and the activity input). +4. An adult who files separately, claims no eligible child and isn't named by the + child's parent ids doesn't change the answer, whatever that adult earns. +5. When the child's parent ids name both parents, tax filing doesn't change the + answer (3.111(D)(2)). +6. The exempt paths each qualify a family with no activity (3.119(D), + 3.121(B)(3)(a), and the activity input), and TANF receipt alone doesn't + (3.111(D)(6), 3.115(C)). The YAML cases pin single families. These generate earnings, hours, weeks and family makeups, which YAML can't express. @@ -38,6 +42,7 @@ "hours": st.integers(min_value=0, max_value=70), "weeks": st.integers(min_value=0, max_value=52), "student": st.booleans(), + "part_time": st.booleans(), "disabled": st.booleans(), } ) @@ -51,16 +56,37 @@ def person_input(caretaker): "weekly_hours_worked_before_lsr": {YEAR: caretaker["hours"]}, "weeks_worked": {YEAR: caretaker["weeks"]}, "is_full_time_college_student": {YEAR: caretaker["student"]}, + "is_part_time_college_student": {YEAR: caretaker.get("part_time", False)}, "is_disabled": {YEAR: caretaker["disabled"]}, } -def simulate(caretakers, spm_unit=None, household=None, other_adult=None, child=None): +def simulate( + caretakers, + spm_unit=None, + household=None, + other_adult=None, + child=None, + link_parents=False, + second_files_apart=False, +): names = [f"caretaker{index}" for index in range(len(caretakers))] people = {name: person_input(item) for name, item in zip(names, caretakers)} people["child"] = {"age": {YEAR: 3}, **(child or {})} family = names + ["child"] - tax_units = {"claiming": {"members": family}} + if link_parents: + # Ids start at 1, since 0 means an unknown parent. + for index, name in enumerate(family): + people[name]["person_id"] = {YEAR: index + 1} + for slot, index in zip(("parent_1_id", "parent_2_id"), range(len(names))): + people["child"][slot] = {YEAR: index + 1} + if second_files_apart and len(names) > 1: + tax_units = { + "claiming": {"members": [names[0], "child"]}, + "apart": {"members": names[1:]}, + } + else: + tax_units = {"claiming": {"members": family}} members = list(family) if other_adult is not None: people["other_adult"] = {"age": {YEAR: 60}, **other_adult} @@ -94,10 +120,13 @@ def activity_eligible(simulation): def in_activity(caretaker): + # Like the model, this divides all earnings by all hours: the inputs hold one + # figure for weekly hours, so a job and a business can't be timed apart. earnings = max(caretaker["wages"], 0) + max(caretaker["business"], 0) weeks = caretaker["weeks"] or WEEKS_IN_YEAR floor = MINIMUM_WAGE * caretaker["hours"] * weeks - return caretaker["student"] or (earnings > 0 and earnings >= floor) + studies = caretaker["student"] or caretaker.get("part_time", False) + return studies or (earnings > 0 and earnings >= floor) def rule_says_eligible(caretakers): @@ -204,7 +233,7 @@ def test_more_earnings_never_remove_the_activity(family, raise_by): family=st.lists(caretakers, min_size=1, max_size=2), other_earnings=st.integers(min_value=0, max_value=60_000), ) -def test_a_separate_filer_does_not_change_the_answer(family, other_earnings): +def test_an_unnamed_separate_filer_does_not_change_the_answer(family, other_earnings): alone = activity_eligible(simulate(family)) beside = simulate(family, other_adult={"employment_income": {YEAR: other_earnings}}) assert activity_eligible(beside) == alone @@ -216,8 +245,24 @@ def test_a_separate_filer_does_not_change_the_answer(family, other_earnings): "hours": 0, "weeks": 0, "student": False, + "part_time": False, "disabled": False, } +WORKING = {**NO_ACTIVITY, "wages": 30_000, "hours": 40, "weeks": 52} + + +@settings(max_examples=15, deadline=None) +@given(family=st.lists(caretakers, min_size=2, max_size=2)) +# A working mother and a father at home who files separately. +@example(family=[WORKING, NO_ACTIVITY]) +# An incapacitated mother and a working father who files separately. +@example(family=[{**NO_ACTIVITY, "disabled": True}, WORKING]) +def test_parent_ids_make_tax_filing_irrelevant(family): + together = activity_eligible(simulate(family, link_parents=True)) + apart = activity_eligible( + simulate(family, link_parents=True, second_files_apart=True) + ) + assert together == apart == rule_says_eligible(family) def test_a_family_with_no_activity_fails_without_an_exempt_path(): @@ -227,7 +272,6 @@ def test_a_family_with_no_activity_fails_without_an_exempt_path(): @pytest.mark.parametrize( "path", [ - {"spm_unit": {"is_tanf_enrolled": {MONTH: True}}}, {"spm_unit": {"meets_ccdf_activity_test": {YEAR: True}}}, {"household": {"is_homeless": {YEAR: True}}}, {"child": {"receives_or_needs_protective_services": {YEAR: True}}}, @@ -236,3 +280,10 @@ def test_a_family_with_no_activity_fails_without_an_exempt_path(): ) def test_each_exempt_path_qualifies_a_family_with_no_activity(path): assert activity_eligible(simulate([NO_ACTIVITY], **path)) + + +def test_tanf_receipt_alone_is_not_an_exempt_path(): + # Under 3.111(D)(6) and 3.115(C), caretakers of children who receive basic + # cash assistance must meet the low-income activity test. + tanf = {"spm_unit": {"is_tanf_enrolled": {MONTH: True}}} + assert not activity_eligible(simulate([NO_ACTIVITY], **tanf)) diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py index e9cba1bfb04..2b9d191ab9d 100644 --- a/policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py @@ -1,4 +1,7 @@ from policyengine_us.model_api import * +from policyengine_us.variables.household.demographic.person._parent_links import ( + co_resident_parent_indices, +) class co_ccap_activity_eligible(Variable): @@ -8,20 +11,11 @@ class co_ccap_activity_eligible(Variable): definition_period = MONTH defined_for = StateCode.CO reference = ( - # 3.111(B)(1): caretakers must participate in an eligible activity. - "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=31", - # 3.111(D)(1): eligible households with one or two caretakers. - "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=33", - # 3.111(E): an incapacitated single caretaker with no activity. - "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=35", - # 3.111(G): employment, self-employment, job search, education. - "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=36", - # 3.116(A): Colorado Works participants. - "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=63", - # 3.119(D): protective services households. - "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=69", - # 3.121(B)(3): families experiencing homelessness. - "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=72", + # PDF pages 2, 31, 33-37, 39-40, 63, 68-69, 72 + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=2", + # 2023 edition, section 3.105.1 + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=11042&fileName=8%20CCR%201403-1#page=14", + "https://www.ecfr.gov/current/title-45/subtitle-A/subchapter-A/part-98/subpart-C/section-98.20#p-98.20(a)(3)", ) def formula(spm_unit, period, parameters): @@ -37,7 +31,9 @@ def formula(spm_unit, period, parameters): # federal minimum wage for each hour worked. Weeks of zero mean none were # reported, so usual hours apply to the full year. A person with earnings # and no recorded hours passes, since no hours can pull the rate below - # the floor. + # the floor. The model records one figure for weekly hours, so a job and + # a business share it; meets_ccdf_activity_test covers a qualifying job + # beside unpaid or loss-making work. weeks = person("weeks_worked", year) weeks_at_work = where(weeks > 0, min_(weeks, WEEKS_IN_YEAR), WEEKS_IN_YEAR) # Pre-response hours avoid a circular dependency through labor supply @@ -45,20 +41,35 @@ def formula(spm_unit, period, parameters): annual_hours = person("weekly_hours_worked_before_lsr", year) * weeks_at_work wage_floor = parameters(period).gov.dol.minimum_wage * annual_hours works = (earnings > 0) & (earnings >= wage_floor) - # 3.111(G)(4) covers post-secondary education, training and basic - # education. The model can't see the lifetime week limits. - in_activity = works | person("is_full_time_student", year) + # 3.111(G)(4) covers training, post-secondary education for a first + # bachelor's degree or less, and basic education. The model can't see + # the lifetime week limits. + in_activity = works | person("co_ccap_in_eligible_education", year) # 3.103(C) limits caretakers to the parents, guardians and those in loco - # parentis who contribute to the child's welfare, so the filers who claim - # an eligible child stand in for them. Another adult in the home doesn't - # count. 3.111(D)(1)(b) treats a caretaker who is involuntarily out of - # the home, as through incarceration, as absent. + # parentis who contribute to the child's welfare, and 3.111(D)(2) counts + # them whatever their tax filing. The filers who claim an eligible child + # stand in for them, joined by any parent that the child's parent ids + # name in the same SPM unit. Without parent ids, a parent who files + # separately and claims no child doesn't count, and neither does another + # adult in the home. 3.111(D)(1)(b) treats a caretaker who is + # involuntarily out of the home, as through incarceration, as absent. eligible_child = person("co_ccap_child_eligible", period) claims_eligible_child = person.tax_unit.sum(eligible_child) > 0 - caretaker = ( - person("is_tax_unit_head_or_spouse", year) - & claims_eligible_child - & ~person("is_incarcerated", period) + claiming_filer = ( + person("is_tax_unit_head_or_spouse", year) & claims_eligible_child + ) + unit = spm_unit.members_entity_id + children = np.flatnonzero(eligible_child) + named_parents = [] + for parents in co_resident_parent_indices(person, year): + parent = parents[children] + resolved = parent >= 0 + same_unit = unit[np.where(resolved, parent, 0)] == unit[children] + named_parents.append(parent[resolved & same_unit]) + named_parents = np.concatenate(named_parents) + linked_parent = np.bincount(named_parents, minlength=person.count) > 0 + caretaker = (claiming_filer | linked_parent) & ~person( + "is_incarcerated", period ) # 3.111(D)(1)(c)(3) lets one caretaker be incapacitated when the other is # in an activity, and 3.111(E) bars a single incapacitated caretaker with @@ -71,10 +82,6 @@ def formula(spm_unit, period, parameters): spm_unit.sum(caretaker & ~in_activity & ~incapacitated) == 0 ) low_income_activity = has_active_caretaker & no_inactive_caretaker - # 3.116(A) treats Colorado Works participants in allowable work activities - # as in an eligible activity. Enrollment stands in for the individualized - # plan and referral. - colorado_works = spm_unit("is_tanf_enrolled", period) # 3.118(A) and 3.119(D) exempt households with children placed in foster # or kinship care under an open child welfare case. protective_services = spm_unit.any( @@ -88,15 +95,13 @@ def formula(spm_unit, period, parameters): # least 60 days. The model can't track that period, so the exemption # lasts as long as the household's homeless flag. homeless = spm_unit.household("is_homeless", year) - # This input covers job search (3.111(G)(3)), part-time study, substance - # use disorder treatment (3.111(G)(4)(a)(3)), the launch period for a new - # business (3.111(G)(2)(e)), temporary leave (3.111(D)(8) and (9)) and - # Child Welfare Child Care (3.120). + # This input covers job search (3.111(G)(3)), substance use disorder + # treatment (3.111(G)(4)(a)(3)), the launch period for a new business + # (3.111(G)(2)(e)), temporary leave (3.111(D)(8) and (9)), Child Welfare + # Child Care (3.120) and Colorado Works participants in allowable work + # activities under an individualized plan (3.116(A)). TANF receipt + # alone doesn't count: under 3.111(D)(6) and 3.115(C), caretakers of + # children who receive basic cash assistance without them must meet + # the low-income activity test. other_activity = spm_unit("meets_ccdf_activity_test", year) - return ( - low_income_activity - | colorado_works - | protective_services - | homeless - | other_activity - ) + return low_income_activity | protective_services | homeless | other_activity diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_in_eligible_education.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_in_eligible_education.py new file mode 100644 index 00000000000..951712ddc92 --- /dev/null +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_in_eligible_education.py @@ -0,0 +1,26 @@ +from policyengine_us.model_api import * + + +class co_ccap_in_eligible_education(Variable): + value_type = bool + entity = Person + label = "Enrolled in education or training that counts as a Colorado Child Care Assistance Program activity" + documentation = ( + "Enrollment in training, in a post-secondary program for a first " + "bachelor's degree or less, or in basic education. Defaults to " + "full-time school or college enrollment or part-time college " + "enrollment. The model has no record of degree level, so set this to " + "false for a graduate student or a second bachelor's degree." + ) + definition_period = YEAR + defined_for = StateCode.CO + # PDF pages 39-40 + reference = "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=39" + + def formula(person, period, parameters): + # 3.111(G)(4)(a)(1) counts enrollment in training or a post-secondary + # program for a first bachelor's degree or less, with no full-time + # requirement, and 3.111(G)(4)(b) counts basic education. + return person("is_full_time_student", period) | person( + "is_part_time_college_student", period + ) From c3f6ce56eb42bb149db2cda1ad062dab48b8ca03 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 30 Nov 2026 10:44:20 +0000 Subject: [PATCH 4/5] Apply Colorado child care activity rules to each eligible month Co-Authored-By: GPT-6.2 Sol --- changelog.d/co-ccap-activity-test.fixed.md | 2 +- .../ccap/activity/earned_income_sources.yaml | 6 +- .../activity/substance_use_treatment.yaml | 10 + .../co/ccap/co_ccap_activity_eligible.yaml | 359 +++++++++++++++++- .../ccap/co_ccap_in_eligible_education.yaml | 25 ++ .../gov/states/co/ccap/court_supervision.yaml | 2 + .../tests/test_co_ccap_activity_properties.py | 63 +-- .../co/ccap/co_ccap_activity_eligible.py | 167 ++++---- .../states/co/ccap/co_ccap_business_hours.py | 20 + .../states/co/ccap/co_ccap_business_profit.py | 22 ++ .../co_ccap_child_welfare_activity_waiver.py | 20 + .../ccap/co_ccap_education_weeks_remaining.py | 17 + .../co_ccap_homelessness_stabilization.py | 19 + .../co/ccap/co_ccap_in_eligible_education.py | 29 +- .../states/co/ccap/co_ccap_incapacitated.py | 18 + .../states/co/ccap/co_ccap_other_activity.py | 36 ++ .../gov/states/co/ccap/co_ccap_work_hours.py | 20 + .../gov/states/co/ccap/co_ccap_work_wages.py | 20 + 18 files changed, 728 insertions(+), 127 deletions(-) create mode 100644 policyengine_us/parameters/gov/states/co/ccap/activity/substance_use_treatment.yaml create mode 100644 policyengine_us/variables/gov/states/co/ccap/co_ccap_business_hours.py create mode 100644 policyengine_us/variables/gov/states/co/ccap/co_ccap_business_profit.py create mode 100644 policyengine_us/variables/gov/states/co/ccap/co_ccap_child_welfare_activity_waiver.py create mode 100644 policyengine_us/variables/gov/states/co/ccap/co_ccap_education_weeks_remaining.py create mode 100644 policyengine_us/variables/gov/states/co/ccap/co_ccap_homelessness_stabilization.py create mode 100644 policyengine_us/variables/gov/states/co/ccap/co_ccap_incapacitated.py create mode 100644 policyengine_us/variables/gov/states/co/ccap/co_ccap_other_activity.py create mode 100644 policyengine_us/variables/gov/states/co/ccap/co_ccap_work_hours.py create mode 100644 policyengine_us/variables/gov/states/co/ccap/co_ccap_work_wages.py diff --git a/changelog.d/co-ccap-activity-test.fixed.md b/changelog.d/co-ccap-activity-test.fixed.md index 0ad57581171..c47d0bfd7fc 100644 --- a/changelog.d/co-ccap-activity-test.fixed.md +++ b/changelog.d/co-ccap-activity-test.fixed.md @@ -1 +1 @@ -Require an eligible activity for Colorado's Child Care Assistance Program under 8 CCR 1403-1 section 3.111. +Require an eligible activity for Colorado child care assistance. Count reported basic education and technical training, assess co-resident caretakers, and use monthly verified work, approved activities, and waivers when available. diff --git a/policyengine_us/parameters/gov/states/co/ccap/activity/earned_income_sources.yaml b/policyengine_us/parameters/gov/states/co/ccap/activity/earned_income_sources.yaml index 49e34da6180..309e07c467c 100644 --- a/policyengine_us/parameters/gov/states/co/ccap/activity/earned_income_sources.yaml +++ b/policyengine_us/parameters/gov/states/co/ccap/activity/earned_income_sources.yaml @@ -11,5 +11,9 @@ metadata: period: year label: Colorado CCAP activity requirement earned income sources reference: - - title: 8 CCR 1403-1 Section 3.111(G)(1) and (2), employment and self-employed criteria + - title: "8 CCR 1403-1 Section 3.111(G)(1) and (2), employment and self-employed criteria #page 36-37" href: https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=36 + - title: 8 CCR 1403-1 Section 3.111(G)(1) and (2), December 2025 edition + href: https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12277&fileName=8%20CCR%201403-1#page=19 + - title: 9 CCR 2503-9 Section 3.905.1(G)(1) and (2), December 2019 edition + href: https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=8430&fileName=9%20CCR%202503-9#page=16 diff --git a/policyengine_us/parameters/gov/states/co/ccap/activity/substance_use_treatment.yaml b/policyengine_us/parameters/gov/states/co/ccap/activity/substance_use_treatment.yaml new file mode 100644 index 00000000000..34da423e5e3 --- /dev/null +++ b/policyengine_us/parameters/gov/states/co/ccap/activity/substance_use_treatment.yaml @@ -0,0 +1,10 @@ +description: Colorado counts qualifying substance use disorder treatment as a Child Care Assistance Program activity when this is true. +values: + 2015-01-01: false + 2026-07-01: true +metadata: + unit: bool + label: Colorado CCCAP substance use disorder treatment activity + reference: + - title: 8 CCR 1403-1 Section 3.111(G)(4)(a)(3) + href: https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12277&fileName=8%20CCR%201403-1#page=21 diff --git a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml index 3f7d14b2e8e..881a44c5c5d 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml @@ -1,6 +1,6 @@ # 8 CCR 1403-1 section 3.111(B)(1), (D), (E) and (G); 3.115(C); 3.116(A); 3.119(D); 3.121(B)(3). # Federal minimum wage $7.25: 40 hours for 52 weeks is 2,080 hours, so the floor is $15,080. -- name: Case 1, single parent with wages and no recorded hours meets the requirement. +- name: Case 1, single parent with wages and no recorded hours does not meet the requirement. period: 2026-01 input: people: @@ -20,7 +20,8 @@ members: [parent, child] state_code: CO output: - co_ccap_activity_eligible: true + # Positive wages divided by zero recorded hours give no verified rate. + co_ccap_activity_eligible: false - name: Case 2, single parent with no activity does not meet the requirement. period: 2026-01 @@ -91,7 +92,7 @@ output: co_ccap_activity_eligible: false -- name: Case 5, the floor counts only the weeks worked, so $10,000 for 26 weeks at 40 hours passes. +- name: Case 5, 26 weeks of earnings alone do not establish work in January. period: 2026-01 input: people: @@ -114,7 +115,8 @@ state_code: CO output: # 40 x 26 = 1,040 hours x $7.25 = $7,540 <= $10,000 - co_ccap_activity_eligible: true + # $10,000 / (26 × 40) is $9.62 per hour, with no evidence of January work. + co_ccap_activity_eligible: false - name: Case 6, with no weeks reported, usual hours run the full year, so the same $10,000 fails. period: 2026-01 @@ -239,9 +241,11 @@ parent1: age: 30 employment_income: 20_000 + weekly_hours_worked_before_lsr: 40 parent2: age: 30 employment_income: 20_000 + weekly_hours_worked_before_lsr: 40 child: age: 3 spm_units: @@ -264,6 +268,7 @@ parent1: age: 30 employment_income: 20_000 + weekly_hours_worked_before_lsr: 40 parent2: age: 30 child: @@ -288,9 +293,11 @@ parent1: age: 30 employment_income: 20_000 + weekly_hours_worked_before_lsr: 40 parent2: age: 30 is_disabled: true + co_ccap_incapacitated: true child: age: 3 spm_units: @@ -313,6 +320,7 @@ parent: age: 30 is_disabled: true + co_ccap_incapacitated: true child: age: 3 spm_units: @@ -335,9 +343,11 @@ parent1: age: 30 is_disabled: true + co_ccap_incapacitated: true parent2: age: 30 is_disabled: true + co_ccap_incapacitated: true child: age: 3 spm_units: @@ -360,6 +370,7 @@ parent1: age: 30 employment_income: 20_000 + weekly_hours_worked_before_lsr: 40 parent2: age: 30 is_incarcerated: true @@ -387,6 +398,7 @@ parent: age: 30 employment_income: 20_000 + weekly_hours_worked_before_lsr: 40 child: age: 3 spm_units: @@ -411,6 +423,7 @@ grandparent: age: 60 employment_income: 50_000 + weekly_hours_worked_before_lsr: 40 parent: age: 30 child: @@ -436,12 +449,12 @@ people: parent: age: 30 + co_ccap_other_activity: JOB_SEARCH child: age: 3 spm_units: spm_unit: members: [parent, child] - meets_ccdf_activity_test: true tax_units: tax_unit: members: [parent, child] @@ -474,7 +487,7 @@ output: co_ccap_activity_eligible: false -- name: Case 21, an eligible child under protective services exempts the household under 3.119(D). +- name: Case 21, an at-home referral alone gives no activity waiver. period: 2026-01 input: people: @@ -494,7 +507,8 @@ members: [caretaker, child] state_code: CO output: - co_ccap_activity_eligible: true + # Zero active caretakers and zero qualifying placements or authorizations. + co_ccap_activity_eligible: false - name: Case 22, an eligible child in foster care exempts the household under 3.118(A) and 3.119(D). period: 2026-01 @@ -505,6 +519,7 @@ child: age: 3 is_in_foster_care: true + co_ccap_child_welfare_activity_waiver: true spm_units: spm_unit: members: [caretaker, child] @@ -518,7 +533,7 @@ output: co_ccap_activity_eligible: true -- name: Case 23, a family experiencing homelessness is exempt under 3.121(B)(3)(a). +- name: Case 23, homelessness outside an authorized stabilization period gives no activity waiver. period: 2026-01 input: people: @@ -538,7 +553,8 @@ state_code: CO is_homeless: true output: - co_ccap_activity_eligible: true + # Zero active caretakers and zero authorized stabilization months. + co_ccap_activity_eligible: false - name: Case 24, a working parent with an eligible child receives the subsidy through the full pipeline. period: 2026-01 @@ -548,6 +564,7 @@ parent: age: 30 employment_income: 30_000 + weekly_hours_worked_before_lsr: 40 child: age: 3 childcare_hours_per_day: 8 @@ -647,13 +664,13 @@ people: parent: age: 30 + co_ccap_other_activity: COLORADO_WORKS child: age: 3 spm_units: spm_unit: members: [parent, child] is_tanf_enrolled: true - meets_ccdf_activity_test: true tax_units: tax_unit: members: [parent, child] @@ -672,6 +689,7 @@ person_id: 1 age: 30 employment_income: 30_000 + weekly_hours_worked_before_lsr: 40 father: person_id: 2 age: 30 @@ -703,10 +721,12 @@ person_id: 1 age: 30 is_disabled: true + co_ccap_incapacitated: true father: person_id: 2 age: 30 employment_income: 30_000 + weekly_hours_worked_before_lsr: 40 child: person_id: 3 age: 3 @@ -735,6 +755,7 @@ person_id: 1 age: 60 employment_income: 50_000 + weekly_hours_worked_before_lsr: 40 mother: person_id: 2 age: 30 @@ -757,3 +778,321 @@ state_code: CO output: co_ccap_activity_eligible: false + +- name: Separate service-business earnings meet the wage floor + period: 2026-01 + input: + people: + parent: {age: 30, sstb_self_employment_income: 15080, weekly_hours_worked_before_lsr: 40, weeks_worked: 52} + child: &activity_child {age: 3, childcare_hours_per_day: 8} + spm_units: &activity_single {family: {members: [parent, child]}} + tax_units: *activity_single + households: &activity_home {home: {members: [parent, child], state_code: CO}} + # $15,080 / (40 × 52) = $7.25 per hour. + output: {co_ccap_activity_eligible: true} + +- name: Net active farm earnings meet the wage floor + period: 2026-01 + input: + people: + parent: {age: 30, farm_operations_income: 15080, weekly_hours_worked_before_lsr: 40, weeks_worked: 52} + child: *activity_child + spm_units: *activity_single + tax_units: *activity_single + households: *activity_home + # $15,080 / (40 × 52) = $7.25 per hour. + output: {co_ccap_activity_eligible: true} + +- name: Fifty-two-week cap on an out-of-range weeks input + period: 2026-01 + input: + people: + parent: {age: 30, employment_income: 16000, weekly_hours_worked_before_lsr: 40, weeks_worked: 60} + child: *activity_child + spm_units: *activity_single + tax_units: *activity_single + households: *activity_home + # $7.25 × 40 × 52 = $15,080, below $16,000. + output: {co_ccap_activity_eligible: true} + +- name: A caretaker unable to care for themself alongside a working caretaker + period: 2026-01 + input: + people: + parent: &activity_worker {age: 35, employment_income: 30000, weekly_hours_worked_before_lsr: 40, weeks_worked: 52} + other: {age: 34, is_incapable_of_self_care: true} + child: *activity_child + spm_units: &activity_three {family: {members: [parent, other, child]}} + tax_units: *activity_three + households: &activity_three_home {home: {members: [parent, other, child], state_code: CO}} + # $30,000 > $15,080. One active and one presumed incapacitated. + output: {co_ccap_activity_eligible: true} + +- name: Child welfare waiver for an age-ineligible sibling does not waive the activity test + period: 2026-01 + input: + people: + parent: {age: 35} + other: {age: 15, co_ccap_child_welfare_activity_waiver: true} + child: *activity_child + spm_units: *activity_three + tax_units: *activity_three + households: *activity_three_home + # Age 15 exceeds the ordinary limit. Zero eligible children have a waiver. + output: {co_ccap_activity_eligible: false} + +- name: Two working parents qualify only in the child's SPM unit + period: 2026-01 + input: + people: + parent: {<<: *activity_worker, person_id: 1} + other: {<<: *activity_worker, person_id: 2} + child: &activity_linked_child {<<: *activity_child, person_id: 3, parent_1_id: 1, parent_2_id: 2} + spm_units: &activity_split {family: {members: [parent, child]}, apart: {members: [other]}} + tax_units: *activity_split + households: *activity_three_home + # Both earn $30,000 > $15,080. Only family contains the eligible child. + output: {co_ccap_activity_eligible: [true, false]} + +- name: Inactive co-resident father blocks eligibility across SPM units + period: 2026-01 + input: + people: + parent: {<<: *activity_worker, person_id: 1} + other: {age: 34, person_id: 2} + child: *activity_linked_child + spm_units: *activity_split + tax_units: *activity_split + households: *activity_three_home + # One of the two linked caretakers has neither an activity nor incapacity. + output: {co_ccap_activity_eligible: [false, false]} + +- name: Noncaretaking grandmother claims a linked teen parent and the teen's baby + period: 2026-01 + input: + people: + parent: {age: 17, person_id: 1, is_in_secondary_school: true} + other: {age: 60, person_id: 2} + child: {<<: *activity_child, person_id: 3, parent_1_id: 1} + spm_units: *activity_three + tax_units: *activity_three + households: *activity_three_home + # One linked caretaker, one basic education activity. + output: {co_ccap_activity_eligible: true} + +- name: Sole enrolled teen in the baby's tax unit qualifies without parent links + period: 2026-01 + input: + people: + parent: {age: 17, is_in_secondary_school: true} + child: *activity_child + spm_units: *activity_single + tax_units: *activity_single + households: *activity_home + # No adult filers. The only older member is the caretaker and is enrolled. + output: {co_ccap_activity_eligible: true} + +- name: Linked 17-year-old explicitly reported as unenrolled fails + period: 2026-01 + input: + people: + parent: {age: 17, person_id: 1, is_in_secondary_school: false} + child: {<<: *activity_child, person_id: 3, parent_1_id: 1} + spm_units: *activity_single + tax_units: *activity_single + households: *activity_home + # The linked caretaker has no reported school or other activity. + output: {co_ccap_activity_eligible: false} + +- name: Denver high school parent receives the full subsidy + period: 2026-01 + input: + people: + parent: {age: 19, is_in_secondary_school: true} + child: *activity_child + spm_units: &activity_denver_expenses + family: {members: [parent, child], spm_unit_pre_subsidy_childcare_expenses: 12000} + tax_units: *activity_single + households: &activity_denver {home: {members: [parent, child], state_code: CO, county: DENVER_COUNTY_CO}} + # One qualifying student. $12,000 / 12 − $0 fee = $1,000. + output: {co_ccap_activity_eligible: true, co_ccap_eligible: true, co_ccap_subsidy: 1000} + +- name: A job that begins in July does not qualify in January + period: 2026-01 + input: + people: + parent: + age: 30 + employment_income: 10000 + weekly_hours_worked_before_lsr: 40 + weeks_worked: 26 + co_ccap_work_hours: {"2026-01": 0, "2026-07": 160} + co_ccap_work_wages: {"2026-07": 1600} + child: *activity_child + spm_units: *activity_single + tax_units: *activity_single + households: *activity_home + # No January hours. July wages of $1,600 / 160 hours meet the $7.25 floor. + output: + co_ccap_activity_eligible: {"2026-01": false, "2026-07": true} + +- name: Approved job search preserves January care and stops after the authorized months + period: 2026-01 + input: + people: + parent: + age: 30 + employment_income: {2025: 20000, 2026: 0} + weekly_hours_worked_before_lsr: {2025: 40, 2026: 0} + co_ccap_other_activity: {"2026-01": JOB_SEARCH, "2026-02": JOB_SEARCH, "2026-03": JOB_SEARCH, "2026-04": JOB_SEARCH} + child: *activity_child + spm_units: + family: + members: [parent, child] + spm_unit_pre_subsidy_childcare_expenses: 12000 + co_ccap_is_in_entry_process: {"2026-01": false} + co_ccap_is_in_re_determination_process: {"2026-01": true} + tax_units: *activity_single + households: *activity_denver + # The December job met $20,000 / 2,080 > $7.25. January job search is + # authorized after job loss. $12,000 / 12 − $0 fee = $1,000. + output: + co_ccap_activity_eligible: {"2026-01": true, "2026-05": false} + co_ccap_eligible: {"2026-01": true, "2026-05": false} + co_ccap_subsidy: {"2026-01": 1000, "2026-05": 0} + +- name: A qualifying wage job is evaluated apart from a loss-making business + period: 2026-01 + input: + people: + parent: + <<: *activity_worker + employment_income: 7800 + self_employment_income: -1000 + co_ccap_work_hours: 40 + co_ccap_work_wages: 600 + co_ccap_business_hours: 120 + co_ccap_business_profit: -80 + child: *activity_child + spm_units: *activity_single + tax_units: *activity_single + households: *activity_home + # Annual wages: $7,800 / 520 hours = $15. January: $600 / 40 = $15. + # The 120 January hours in the separate loss-making business do not count. + output: {co_ccap_activity_eligible: true} + +- name: Self-employment uses CCCAP profit after verified allowable expenses + period: 2026-01 + input: + people: + parent: + age: 30 + self_employment_income: 12000 + weekly_hours_worked_before_lsr: 40 + weeks_worked: 52 + co_ccap_business_hours: 160 + co_ccap_business_profit: 1500 + child: *activity_child + spm_units: *activity_single + tax_units: *activity_single + households: *activity_home + # Annual: $12,000 tax profit + $6,000 equipment depreciation = $18,000. + # January CCCAP profit: $1,500 / 160 hours = $9.375, above $7.25. + output: {co_ccap_activity_eligible: true} + +- name: One dollar of earnings with no recorded hours fails the wage test + period: 2026-01 + input: + people: + parent: {age: 30, employment_income: 1} + child: *activity_child + spm_units: *activity_single + tax_units: *activity_single + households: *activity_home + # $1 ÷ zero recorded hours does not establish an hourly rate. + output: {co_ccap_activity_eligible: false} + +- name: Foster placement without an open case gives no activity waiver + period: 2026-01 + input: + people: + parent: {age: 30} + child: {<<: *activity_child, is_in_foster_care: true} + spm_units: *activity_single + tax_units: *activity_single + households: *activity_home + # Zero qualifying protective-services placements with open cases. + output: {co_ccap_activity_eligible: false} + +- name: Homelessness waives activity only during authorized stabilization + period: 2026-01 + input: + people: + parent: {age: 30} + child: *activity_child + spm_units: + family: + members: [parent, child] + co_ccap_homelessness_stabilization: {"2026-01": true} + tax_units: *activity_single + households: + home: {members: [parent, child], state_code: CO, is_homeless: {2026: true}} + # One authorized month passes. September has zero authorized time. + output: + co_ccap_activity_eligible: {"2026-01": true, "2026-09": false} + +- name: Disability alone does not excuse an inactive caretaker + period: 2026-01 + input: + people: + parent: *activity_worker + other: {age: 34, is_disabled: true} + child: *activity_child + spm_units: *activity_three + tax_units: *activity_three + households: *activity_three_home + # One of two caretakers works. The other can provide care. + output: {co_ccap_activity_eligible: false} + +- name: College ceases to qualify when all county-approved weeks are used + period: 2026-01 + input: + people: + parent: + age: 30 + is_full_time_college_student: true + co_ccap_education_weeks_remaining: {"2026-01": 1, "2026-02": 0} + child: *activity_child + spm_units: *activity_single + tax_units: *activity_single + households: *activity_home + # The remaining approved weeks fall from 1 to 0. + output: + co_ccap_activity_eligible: {"2026-01": true, "2026-02": false} + +- name: Colorado Works approval in one month does not continue all year + period: 2026-01 + input: + people: + parent: {age: 30, co_ccap_other_activity: {"2026-01": COLORADO_WORKS}} + child: *activity_child + spm_units: + family: {members: [parent, child], meets_ccdf_activity_test: {2026: true}} + tax_units: *activity_single + households: *activity_home + # There is one approved activity in January and zero in September. + output: + co_ccap_activity_eligible: {"2026-01": true, "2026-09": false} + +- name: Qualifying substance use treatment starts counting in July 2026 + period: 2026-01 + input: + people: + parent: {age: 30, co_ccap_other_activity: {"2026-06": SUBSTANCE_USE_TREATMENT, "2026-07": SUBSTANCE_USE_TREATMENT}} + child: *activity_child + spm_units: *activity_single + tax_units: *activity_single + households: *activity_home + # June precedes July 1. In July one qualifying treatment activity counts. + output: + co_ccap_activity_eligible: {"2026-06": false, "2026-07": true} diff --git a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_in_eligible_education.yaml b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_in_eligible_education.yaml index 2bfd3f8e5dd..40713bdf8c7 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_in_eligible_education.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_in_eligible_education.yaml @@ -22,6 +22,7 @@ period: 2026 input: age: 17 + is_in_secondary_school: true state_code: CO output: co_ccap_in_eligible_education: true @@ -42,3 +43,27 @@ state_code: NM output: co_ccap_in_eligible_education: false + +- name: A 19-year-old enrolled in high school is in basic education + period: 2026 + input: {age: 19, is_in_secondary_school: true, state_code: CO} + # One qualifying basic education program. + output: {co_ccap_in_eligible_education: true} + +- name: An adult in high-school equivalency is in basic education + period: 2026 + input: {age: 30, is_in_secondary_school: true, state_code: CO} + # One qualifying basic education program. + output: {co_ccap_in_eligible_education: true} + +- name: Technical training for a certificate qualifies + period: 2026 + input: {age: 30, technical_institution_student: true, state_code: CO} + # One qualifying technical program. + output: {co_ccap_in_eligible_education: true} + +- name: Age 17 alone supplies no evidence of enrollment + period: 2026 + input: {age: 17, is_in_secondary_school: false, state_code: CO} + # Zero reported education activities. + output: {co_ccap_in_eligible_education: false} diff --git a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/court_supervision.yaml b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/court_supervision.yaml index 1ce3460e0af..3f0b2dbbf17 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/court_supervision.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/court_supervision.yaml @@ -58,6 +58,7 @@ person1: age: 40 employment_income: 30_000 + weekly_hours_worked_before_lsr: 40 person2: age: 15 is_disabled: false @@ -112,6 +113,7 @@ person1: age: 40 employment_income: 30_000 + weekly_hours_worked_before_lsr: 40 person2: age: 15 is_disabled: false diff --git a/policyengine_us/tests/test_co_ccap_activity_properties.py b/policyengine_us/tests/test_co_ccap_activity_properties.py index 3bbbcbc8b39..eea02e34c8d 100644 --- a/policyengine_us/tests/test_co_ccap_activity_properties.py +++ b/policyengine_us/tests/test_co_ccap_activity_properties.py @@ -3,9 +3,10 @@ 8 CCR 1403-1 section 3.111(B)(1) requires caretakers to take part in an eligible activity, and (D) and (E) say which households qualify. -1. A caretaker works when earnings are positive and at least the federal minimum - wage for the hours worked (3.111(G)(1)(b) and (G)(2)(d)), and studies when - enrolled in college full or part time (3.111(G)(4)). Without the exempt paths, +1. Work with annual inputs requires recorded hours for ongoing work and earnings + at or above the federal minimum wage (3.111(G)(1)(b) and (G)(2)(d)). + Reported college, secondary school and technical enrollment can qualify + (3.111(G)(4)). Without the exempt paths, a household qualifies when a caretaker is in an activity and every other caretaker is in an activity or incapacitated (3.111(D)(1)(c), 3.111(E)). 2. No family without the requirement receives a subsidy: co_ccap_eligible implies @@ -16,8 +17,8 @@ child's parent ids doesn't change the answer, whatever that adult earns. 5. When the child's parent ids name both parents, tax filing doesn't change the answer (3.111(D)(2)). -6. The exempt paths each qualify a family with no activity (3.119(D), - 3.121(B)(3)(a), and the activity input), and TANF receipt alone doesn't +6. Child welfare and stabilization waivers and other approved monthly activities + qualify a family (3.119(D), 3.121(B)(3)(a)). TANF receipt alone doesn't (3.111(D)(6), 3.115(C)). The YAML cases pin single families. These generate earnings, hours, weeks and @@ -43,7 +44,9 @@ "weeks": st.integers(min_value=0, max_value=52), "student": st.booleans(), "part_time": st.booleans(), - "disabled": st.booleans(), + "secondary": st.booleans(), + "technical": st.booleans(), + "incapacitated": st.booleans(), } ) @@ -57,14 +60,16 @@ def person_input(caretaker): "weeks_worked": {YEAR: caretaker["weeks"]}, "is_full_time_college_student": {YEAR: caretaker["student"]}, "is_part_time_college_student": {YEAR: caretaker.get("part_time", False)}, - "is_disabled": {YEAR: caretaker["disabled"]}, + "is_in_secondary_school": {YEAR: caretaker.get("secondary", False)}, + "technical_institution_student": {YEAR: caretaker.get("technical", False)}, + "co_ccap_incapacitated": {MONTH: caretaker["incapacitated"]}, + "co_ccap_other_activity": {MONTH: caretaker.get("other_activity", "NONE")}, } def simulate( caretakers, spm_unit=None, - household=None, other_adult=None, child=None, link_parents=False, @@ -108,7 +113,6 @@ def simulate( "household": { "members": members, "state_name": {YEAR: "CO"}, - **(household or {}), } }, } @@ -125,14 +129,19 @@ def in_activity(caretaker): earnings = max(caretaker["wages"], 0) + max(caretaker["business"], 0) weeks = caretaker["weeks"] or WEEKS_IN_YEAR floor = MINIMUM_WAGE * caretaker["hours"] * weeks - studies = caretaker["student"] or caretaker.get("part_time", False) - return studies or (earnings > 0 and earnings >= floor) + studies = any( + caretaker.get(flag, False) + for flag in ("student", "part_time", "secondary", "technical") + ) + works = weeks == WEEKS_IN_YEAR and caretaker["hours"] > 0 and earnings >= floor + return studies or works def rule_says_eligible(caretakers): active = [in_activity(item) for item in caretakers] covered = [ - is_active or item["disabled"] for is_active, item in zip(active, caretakers) + is_active or item["incapacitated"] + for is_active, item in zip(active, caretakers) ] return any(active) and all(covered) @@ -148,7 +157,7 @@ def rule_says_eligible(caretakers): "hours": 40, "weeks": 52, "student": False, - "disabled": False, + "incapacitated": False, } ] ) @@ -160,7 +169,7 @@ def rule_says_eligible(caretakers): "hours": 40, "weeks": 52, "student": False, - "disabled": False, + "incapacitated": False, } ] ) @@ -173,7 +182,7 @@ def rule_says_eligible(caretakers): "hours": 0, "weeks": 0, "student": False, - "disabled": True, + "incapacitated": True, } ] ) @@ -182,10 +191,10 @@ def rule_says_eligible(caretakers): { "wages": 20_000, "business": 0, - "hours": 0, - "weeks": 0, + "hours": 40, + "weeks": 52, "student": False, - "disabled": False, + "incapacitated": False, }, { "wages": 0, @@ -193,7 +202,7 @@ def rule_says_eligible(caretakers): "hours": 0, "weeks": 0, "student": False, - "disabled": True, + "incapacitated": True, }, ] ) @@ -246,7 +255,7 @@ def test_an_unnamed_separate_filer_does_not_change_the_answer(family, other_earn "weeks": 0, "student": False, "part_time": False, - "disabled": False, + "incapacitated": False, } WORKING = {**NO_ACTIVITY, "wages": 30_000, "hours": 40, "weeks": 52} @@ -256,7 +265,7 @@ def test_an_unnamed_separate_filer_does_not_change_the_answer(family, other_earn # A working mother and a father at home who files separately. @example(family=[WORKING, NO_ACTIVITY]) # An incapacitated mother and a working father who files separately. -@example(family=[{**NO_ACTIVITY, "disabled": True}, WORKING]) +@example(family=[{**NO_ACTIVITY, "incapacitated": True}, WORKING]) def test_parent_ids_make_tax_filing_irrelevant(family): together = activity_eligible(simulate(family, link_parents=True)) apart = activity_eligible( @@ -272,14 +281,14 @@ def test_a_family_with_no_activity_fails_without_an_exempt_path(): @pytest.mark.parametrize( "path", [ - {"spm_unit": {"meets_ccdf_activity_test": {YEAR: True}}}, - {"household": {"is_homeless": {YEAR: True}}}, - {"child": {"receives_or_needs_protective_services": {YEAR: True}}}, - {"child": {"is_in_foster_care": {MONTH: True}}}, + {"caretakers": [{**NO_ACTIVITY, "other_activity": "JOB_SEARCH"}]}, + {"caretakers": [{**NO_ACTIVITY, "other_activity": "COLORADO_WORKS"}]}, + {"spm_unit": {"co_ccap_homelessness_stabilization": {MONTH: True}}}, + {"child": {"co_ccap_child_welfare_activity_waiver": {MONTH: True}}}, ], ) -def test_each_exempt_path_qualifies_a_family_with_no_activity(path): - assert activity_eligible(simulate([NO_ACTIVITY], **path)) +def test_each_approved_path_qualifies_a_family(path): + assert activity_eligible(simulate(**({"caretakers": [NO_ACTIVITY]} | path))) def test_tanf_receipt_alone_is_not_an_exempt_path(): diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py index 2b9d191ab9d..f86bd6cedf6 100644 --- a/policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.variables.household.demographic.person._parent_links import ( co_resident_parent_indices, + group_member_indices, ) @@ -11,97 +12,111 @@ class co_ccap_activity_eligible(Variable): definition_period = MONTH defined_for = StateCode.CO reference = ( - # PDF pages 2, 31, 33-37, 39-40, 63, 68-69, 72 + # PDF pages 1-3, 11, 15, 17-21, 24-25, 30, 35, 37-40, 48 + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12277&fileName=8%20CCR%201403-1#page=1", + # PDF pages 2, 31, 33-37, 39-40, 47-49, 63, 68-72 "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=2", - # 2023 edition, section 3.105.1 + # PDF pages 14-18 "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=11042&fileName=8%20CCR%201403-1#page=14", - "https://www.ecfr.gov/current/title-45/subtitle-A/subchapter-A/part-98/subpart-C/section-98.20#p-98.20(a)(3)", + "https://www.ecfr.gov/current/title-45/subtitle-A/subchapter-A/part-98/subpart-C/section-98.21#p-98.21(a)", ) def formula(spm_unit, period, parameters): - p = parameters(period).gov.states.co.ccap.activity + p = parameters(period).gov person = spm_unit.members year = period.this_year - # Clip each source so a business loss can't erase wages. + minimum_wage = p.dol.minimum_wage + + wages = person("co_ccap_work_wages", period) + work_hours = person("co_ccap_work_hours", period) + profit = person("co_ccap_business_profit", period) + business_hours = person("co_ccap_business_hours", period) + verified_hours = (work_hours >= 0) | (business_hours >= 0) + verified_work = ((work_hours > 0) & (wages >= work_hours * minimum_wage)) | ( + (business_hours > 0) & (profit >= business_hours * minimum_wage) + ) + + # Annual records can approximate ongoing work if they have hours and + # give no indication that work covers only part of the year. earnings = np.sum( - [max_(person(source, year), 0) for source in p.earned_income_sources], + [ + max_(person(source, year), 0) + for source in p.states.co.ccap.activity.earned_income_sources + ], axis=0, ) - # 3.111(G)(1)(b) and (G)(2)(d) require gross income of at least the - # federal minimum wage for each hour worked. Weeks of zero mean none were - # reported, so usual hours apply to the full year. A person with earnings - # and no recorded hours passes, since no hours can pull the rate below - # the floor. The model records one figure for weekly hours, so a job and - # a business share it; meets_ccdf_activity_test covers a qualifying job - # beside unpaid or loss-making work. weeks = person("weeks_worked", year) weeks_at_work = where(weeks > 0, min_(weeks, WEEKS_IN_YEAR), WEEKS_IN_YEAR) - # Pre-response hours avoid a circular dependency through labor supply - # responses. + # Pre-response hours avoid a circular labor-supply dependency. annual_hours = person("weekly_hours_worked_before_lsr", year) * weeks_at_work - wage_floor = parameters(period).gov.dol.minimum_wage * annual_hours - works = (earnings > 0) & (earnings >= wage_floor) - # 3.111(G)(4) covers training, post-secondary education for a first - # bachelor's degree or less, and basic education. The model can't see - # the lifetime week limits. - in_activity = works | person("co_ccap_in_eligible_education", year) - # 3.103(C) limits caretakers to the parents, guardians and those in loco - # parentis who contribute to the child's welfare, and 3.111(D)(2) counts - # them whatever their tax filing. The filers who claim an eligible child - # stand in for them, joined by any parent that the child's parent ids - # name in the same SPM unit. Without parent ids, a parent who files - # separately and claims no child doesn't count, and neither does another - # adult in the home. 3.111(D)(1)(b) treats a caretaker who is - # involuntarily out of the home, as through incarceration, as absent. - eligible_child = person("co_ccap_child_eligible", period) - claims_eligible_child = person.tax_unit.sum(eligible_child) > 0 - claiming_filer = ( - person("is_tax_unit_head_or_spouse", year) & claims_eligible_child + annual_work = ( + (weeks_at_work == WEEKS_IN_YEAR) + & (annual_hours > 0) + & (earnings >= minimum_wage * annual_hours) ) - unit = spm_unit.members_entity_id - children = np.flatnonzero(eligible_child) - named_parents = [] - for parents in co_resident_parent_indices(person, year): - parent = parents[children] - resolved = parent >= 0 - same_unit = unit[np.where(resolved, parent, 0)] == unit[children] - named_parents.append(parent[resolved & same_unit]) - named_parents = np.concatenate(named_parents) - linked_parent = np.bincount(named_parents, minlength=person.count) > 0 - caretaker = (claiming_filer | linked_parent) & ~person( - "is_incarcerated", period + works = where(verified_hours, verified_work, annual_work) + + studies = person("co_ccap_in_eligible_education", year) & ( + person("co_ccap_education_weeks_remaining", period) != 0 + ) + other = person("co_ccap_other_activity", period) + allowed_treatment = p.states.co.ccap.activity.substance_use_treatment + other_activity = (other != other.possible_values.NONE) & ( + (other != other.possible_values.SUBSTANCE_USE_TREATMENT) | allowed_treatment ) - # 3.111(D)(1)(c)(3) lets one caretaker be incapacitated when the other is - # in an activity, and 3.111(E) bars a single incapacitated caretaker with - # no activity. Disability stands in for the medical verification. - incapacitated = person("is_disabled", year) | person( - "is_incapable_of_self_care", year + present = ~person("is_incarcerated", period) + active = present & (works | studies | other_activity) + blocking = present & ~active & ~person("co_ccap_incapacitated", period) + + eligible_child = person("co_ccap_child_eligible", period) + low_income = child_caretakers_meet_activity( + person, year, active, blocking, p.states.co.ccap.age_limit ) - has_active_caretaker = spm_unit.sum(caretaker & in_activity) > 0 - no_inactive_caretaker = ( - spm_unit.sum(caretaker & ~in_activity & ~incapacitated) == 0 + child_welfare = person("co_ccap_child_welfare_activity_waiver", period) + stabilization = spm_unit("co_ccap_homelessness_stabilization", period) + return spm_unit.any(eligible_child & (low_income | child_welfare)) | ( + spm_unit.any(eligible_child) & stabilization ) - low_income_activity = has_active_caretaker & no_inactive_caretaker - # 3.118(A) and 3.119(D) exempt households with children placed in foster - # or kinship care under an open child welfare case. - protective_services = spm_unit.any( - eligible_child - & ( - person("receives_or_needs_protective_services", year) - | person("is_in_foster_care", period) - ) + + +def child_caretakers_meet_activity(person, year, active, blocking, child_age_limit): + # Attribute the result to the child even if a linked caretaker belongs to + # another SPM unit. Parent links take precedence over tax-filing roles. + first, second = co_resident_parent_indices(person, year) + linked = (first >= 0) | (second >= 0) + linked_active = ((first >= 0) & active[first]) | ((second >= 0) & active[second]) + linked_blocking = ((first >= 0) & blocking[first]) | ( + (second >= 0) & blocking[second] + ) + + # Fall back to co-resident filers. With no filer, infer a sole teen + # caretaker only when one older member can be distinguished from the child. + home = person.household.members_entity_id + row = np.arange(person.count) + filer = person("is_tax_unit_head_or_spouse", year) + age = person("age", year) + child = person("is_child", year) + has_filer = np.zeros(person.count, dtype=bool) + filer_active = np.zeros_like(has_filer) + filer_blocking = np.zeros_like(has_filer) + teen_count = np.zeros(person.count, dtype=int) + teen_active = np.zeros_like(has_filer) + for member in group_member_indices(person.tax_unit): + co_resident = (member >= 0) & (member != row) & (home[member] == home) + claims = co_resident & filer[member] + teen = ( + co_resident + & (age[member] >= child_age_limit) + & child[member] + & (age[member] > age) ) - # 3.121(B)(3)(a) waives the activity during a stabilization period of at - # least 60 days. The model can't track that period, so the exemption - # lasts as long as the household's homeless flag. - homeless = spm_unit.household("is_homeless", year) - # This input covers job search (3.111(G)(3)), substance use disorder - # treatment (3.111(G)(4)(a)(3)), the launch period for a new business - # (3.111(G)(2)(e)), temporary leave (3.111(D)(8) and (9)), Child Welfare - # Child Care (3.120) and Colorado Works participants in allowable work - # activities under an individualized plan (3.116(A)). TANF receipt - # alone doesn't count: under 3.111(D)(6) and 3.115(C), caretakers of - # children who receive basic cash assistance without them must meet - # the low-income activity test. - other_activity = spm_unit("meets_ccdf_activity_test", year) - return low_income_activity | protective_services | homeless | other_activity + has_filer |= claims + filer_active |= claims & active[member] + filer_blocking |= claims & blocking[member] + teen_count += teen + teen_active |= teen & active[member] + + unlinked = where( + has_filer, filer_active & ~filer_blocking, (teen_count == 1) & teen_active + ) + return where(linked, linked_active & ~linked_blocking, unlinked) diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_business_hours.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_business_hours.py new file mode 100644 index 00000000000..8d9faf7d3e0 --- /dev/null +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_business_hours.py @@ -0,0 +1,20 @@ +from policyengine_us.model_api import * + + +class co_ccap_business_hours(Variable): + value_type = float + entity = Person + label = "Verified Colorado CCCAP hours in self-employment" + documentation = ( + "Hours for the business the caretaker is verifying for this month. " + "Use the same period as the verified profit. Supply zero for a month " + "without that work. A missing value is represented by -1." + ) + definition_period = MONTH + defined_for = StateCode.CO + default_value = -1 + reference = "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12277&fileName=8%20CCR%201403-1#page=19" + + def formula(person, period, parameters): + # Verification applies to the reported month. + return person.filled_array(-1) diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_business_profit.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_business_profit.py new file mode 100644 index 00000000000..846b8c4cf1f --- /dev/null +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_business_profit.py @@ -0,0 +1,22 @@ +from policyengine_us.model_api import * + + +class co_ccap_business_profit(Variable): + value_type = float + entity = Person + label = "Verified Colorado CCCAP self-employment profit" + documentation = ( + "Gross receipts less CCCAP-allowable verified expenses for the hours " + "reported. For nonfarm businesses, exclude equipment depreciation " + "from expenses. Supply profit and hours for a qualifying business if " + "the caretaker has more than one." + ) + definition_period = MONTH + defined_for = StateCode.CO + unit = USD + # PDF pages 19, 24-25 + reference = "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12277&fileName=8%20CCR%201403-1#page=19" + + def formula(person, period, parameters): + # Verification applies to the reported month. + return person.filled_array(0) diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_child_welfare_activity_waiver.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_child_welfare_activity_waiver.py new file mode 100644 index 00000000000..8980c80c2dd --- /dev/null +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_child_welfare_activity_waiver.py @@ -0,0 +1,20 @@ +from policyengine_us.model_api import * + + +class co_ccap_child_welfare_activity_waiver(Variable): + value_type = bool + entity = Person + label = "Child has a Colorado CCCAP child welfare activity waiver" + documentation = ( + "The child has a county protective-services placement with an open " + "child welfare case, or the county has approved Child Welfare Child " + "Care for this month." + ) + definition_period = MONTH + defined_for = StateCode.CO + # PDF pages 37-39 + reference = "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12277&fileName=8%20CCR%201403-1#page=37" + + def formula(person, period, parameters): + # Verification applies to the reported month. + return person.filled_array(False) diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_education_weeks_remaining.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_education_weeks_remaining.py new file mode 100644 index 00000000000..f42a0745e0e --- /dev/null +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_education_weeks_remaining.py @@ -0,0 +1,17 @@ +from policyengine_us.model_api import * + + +class co_ccap_education_weeks_remaining(Variable): + value_type = int + entity = Person + label = "Approved Colorado CCCAP education weeks remaining" + documentation = ( + "County-approved weeks of care still available for the qualifying " + "education activity in this month. Use zero when the allotment is " + "exhausted. Leave unset when weeks are unknown or no limit applies." + ) + definition_period = MONTH + defined_for = StateCode.CO + default_value = -1 + # PDF pages 20-21 + reference = "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12277&fileName=8%20CCR%201403-1#page=20" diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_homelessness_stabilization.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_homelessness_stabilization.py new file mode 100644 index 00000000000..eac93f977f5 --- /dev/null +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_homelessness_stabilization.py @@ -0,0 +1,19 @@ +from policyengine_us.model_api import * + + +class co_ccap_homelessness_stabilization(Variable): + value_type = bool + entity = SPMUnit + label = "Colorado CCCAP homelessness stabilization is authorized" + documentation = ( + "The family is experiencing homelessness and has an authorized CCCAP " + "stabilization period covering this month." + ) + definition_period = MONTH + defined_for = StateCode.CO + # PDF pages 39-40 + reference = "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12277&fileName=8%20CCR%201403-1#page=39" + + def formula(spm_unit, period, parameters): + # Verification applies to the reported month. + return spm_unit.filled_array(False) diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_in_eligible_education.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_in_eligible_education.py index 951712ddc92..19743264bd0 100644 --- a/policyengine_us/variables/gov/states/co/ccap/co_ccap_in_eligible_education.py +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_in_eligible_education.py @@ -6,21 +6,26 @@ class co_ccap_in_eligible_education(Variable): entity = Person label = "Enrolled in education or training that counts as a Colorado Child Care Assistance Program activity" documentation = ( - "Enrollment in training, in a post-secondary program for a first " - "bachelor's degree or less, or in basic education. Defaults to " - "full-time school or college enrollment or part-time college " - "enrollment. The model has no record of degree level, so set this to " - "false for a graduate student or a second bachelor's degree." + "Defaults to reported secondary school or equivalent, technical " + "training, or full- or part-time college enrollment. Set to true " + "for other qualifying basic education or training and to false " + "for graduate school or a second bachelor's degree. Use " + "co_ccap_education_weeks_remaining to report when the county " + "allotment for the activity runs out." ) definition_period = YEAR defined_for = StateCode.CO - # PDF pages 39-40 - reference = "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=39" + reference = ( + # PDF pages 3, 20-21 + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12277&fileName=8%20CCR%201403-1#page=3", + # PDF pages 4, 39-40 + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=4", + ) def formula(person, period, parameters): - # 3.111(G)(4)(a)(1) counts enrollment in training or a post-secondary - # program for a first bachelor's degree or less, with no full-time - # requirement, and 3.111(G)(4)(b) counts basic education. - return person("is_full_time_student", period) | person( - "is_part_time_college_student", period + return ( + person("is_full_time_college_student", period) + | person("is_part_time_college_student", period) + | person("is_in_secondary_school", period) + | person("technical_institution_student", period) ) diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_incapacitated.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_incapacitated.py new file mode 100644 index 00000000000..4ea9cad66c2 --- /dev/null +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_incapacitated.py @@ -0,0 +1,18 @@ +from policyengine_us.model_api import * + + +class co_ccap_incapacitated(Variable): + value_type = bool + entity = Person + label = "Colorado CCCAP caretaker is unable to provide care" + documentation = ( + "Supply the medically verified determination that this caretaker " + "cannot care for the child in this month. Inability to provide " + "self-care is used as a proxy when the determination is unavailable." + ) + definition_period = MONTH + defined_for = StateCode.CO + reference = "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12277&fileName=8%20CCR%201403-1#page=17" + + def formula(person, period, parameters): + return person("is_incapable_of_self_care", period.this_year) diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_other_activity.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_other_activity.py new file mode 100644 index 00000000000..87c86fbd44f --- /dev/null +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_other_activity.py @@ -0,0 +1,36 @@ +from policyengine_us.model_api import * + + +class COCCAPOtherActivity(Enum): + NONE = "No other eligible activity" + JOB_SEARCH = "Approved job search after qualifying cessation" + PROTECTED_BREAK = "Protected break from an eligible activity" + BUSINESS_LAUNCH = "Approved self-employment launch" + COLORADO_WORKS = "Allowable Colorado Works activity under an individualized plan" + SUBSTANCE_USE_TREATMENT = "Qualifying substance use disorder treatment" + + +class co_ccap_other_activity(Variable): + value_type = Enum + possible_values = COCCAPOtherActivity + default_value = COCCAPOtherActivity.NONE + entity = Person + label = "Other approved Colorado CCCAP activity for the month" + documentation = ( + "Report an approved activity for the caretaker only in a month it " + "covers. Use job search after a qualifying cessation if the prior " + "determination and the authorized search period cover this month. " + "Use a protected break, business launch, Colorado Works plan, or " + "qualifying treatment only while the applicable conditions are met. " + "Treatment must be licensed, appropriately endorsed, and at intensive " + "outpatient level or higher. Approval can cover up to one year per " + "instance." + ) + definition_period = MONTH + defined_for = StateCode.CO + # PDF pages 18-21, 30, 35 + reference = "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12277&fileName=8%20CCR%201403-1#page=18" + + def formula(person, period, parameters): + # Verification applies to the reported month. + return person.filled_array(COCCAPOtherActivity.NONE.index) diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_work_hours.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_work_hours.py new file mode 100644 index 00000000000..060a8500e8a --- /dev/null +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_work_hours.py @@ -0,0 +1,20 @@ +from policyengine_us.model_api import * + + +class co_ccap_work_hours(Variable): + value_type = float + entity = Person + label = "Verified Colorado CCCAP hours at a wage job" + documentation = ( + "Hours for the wage job the caretaker is verifying for this month. Use " + "the same pay period as the reported wages. Supply zero for a month " + "without that work. A missing value is represented by -1." + ) + definition_period = MONTH + defined_for = StateCode.CO + default_value = -1 + reference = "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12277&fileName=8%20CCR%201403-1#page=19" + + def formula(person, period, parameters): + # Verification applies to the reported month. + return person.filled_array(-1) diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_work_wages.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_work_wages.py new file mode 100644 index 00000000000..b041db32e7f --- /dev/null +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_work_wages.py @@ -0,0 +1,20 @@ +from policyengine_us.model_api import * + + +class co_ccap_work_wages(Variable): + value_type = float + entity = Person + label = "Verified Colorado CCCAP gross wages at a job" + documentation = ( + "Gross wages for the job and pay period used for the verified hours. " + "Supply wages and hours for a qualifying job if the caretaker has " + "more than one." + ) + definition_period = MONTH + defined_for = StateCode.CO + unit = USD + reference = "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12277&fileName=8%20CCR%201403-1#page=19" + + def formula(person, period, parameters): + # Verification applies to the reported month. + return person.filled_array(0) From 8c4e219854799b8f53cd4423c037a2548407279c Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Tue, 1 Dec 2026 04:49:53 +0000 Subject: [PATCH 5/5] Preserve Colorado CCAP enrollment and attribute activity and charges Co-Authored-By: GPT-6.2 Sol --- changelog.d/co-ccap-activity-test.fixed.md | 2 +- .../co/ccap/co_ccap_activity_eligible.yaml | 110 ++++++++++++++- .../gov/states/co/ccap/co_ccap_subsidy.yaml | 22 +++ .../co/ccap/co_ccap_activity_eligible.py | 103 +------------- .../ccap/co_ccap_child_activity_eligible.py | 129 ++++++++++++++++++ .../co/ccap/co_ccap_in_eligible_education.py | 16 ++- .../gov/states/co/ccap/co_ccap_subsidy.py | 15 +- 7 files changed, 287 insertions(+), 110 deletions(-) create mode 100644 policyengine_us/variables/gov/states/co/ccap/co_ccap_child_activity_eligible.py diff --git a/changelog.d/co-ccap-activity-test.fixed.md b/changelog.d/co-ccap-activity-test.fixed.md index c47d0bfd7fc..532c091288d 100644 --- a/changelog.d/co-ccap-activity-test.fixed.md +++ b/changelog.d/co-ccap-activity-test.fixed.md @@ -1 +1 @@ -Require an eligible activity for Colorado child care assistance. Count reported basic education and technical training, assess co-resident caretakers, and use monthly verified work, approved activities, and waivers when available. +Require an eligible activity for Colorado child care assistance. Count reported basic education and technical training, include co-resident caretaker spouses when a parent link is missing, and evaluate monthly wage and business work separately. When only some eligible children meet the activity requirement, pay only for those children. diff --git a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml index 881a44c5c5d..de95ab0375a 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_activity_eligible.yaml @@ -977,7 +977,7 @@ spm_units: *activity_single tax_units: *activity_single households: *activity_home - # Annual wages: $7,800 / 520 hours = $15. January: $600 / 40 = $15. + # January wages: $600 / 40 hours = $15 per hour. # The 120 January hours in the separate loss-making business do not count. output: {co_ccap_activity_eligible: true} @@ -996,7 +996,7 @@ spm_units: *activity_single tax_units: *activity_single households: *activity_home - # Annual: $12,000 tax profit + $6,000 equipment depreciation = $18,000. + # The verified CCCAP profit is separate from the $12,000 annual tax profit. # January CCCAP profit: $1,500 / 160 hours = $9.375, above $7.25. output: {co_ccap_activity_eligible: true} @@ -1096,3 +1096,109 @@ # June precedes July 1. In July one qualifying treatment activity counts. output: co_ccap_activity_eligible: {"2026-06": false, "2026-07": true} + +- name: Denver teen parent with reported K-12 enrollment receives care + period: 2026-01 + input: + people: + parent: {age: 17, person_id: 1, is_in_k12_school: true} + child: &activity_one_parent_child {<<: *activity_child, person_id: 2, parent_1_id: 1} + spm_units: *activity_denver_expenses + tax_units: *activity_single + households: *activity_denver + # One enrolled caretaker. $12,000 / 12 - $0 fee = $1,000. + output: + co_ccap_in_eligible_education: {2026: [true, false]} + co_ccap_activity_eligible: true + co_ccap_eligible: true + co_ccap_subsidy: 1000 + +- name: Denver parent with reported full-time enrollment receives care + period: 2026-01 + input: + people: + parent: {age: 30, person_id: 1, is_full_time_student: true} + child: *activity_one_parent_child + spm_units: *activity_denver_expenses + tax_units: *activity_single + households: *activity_denver + # One enrolled caretaker. $12,000 / 12 - $0 fee = $1,000. + output: + co_ccap_in_eligible_education: {2026: [true, false]} + co_ccap_activity_eligible: true + co_ccap_eligible: true + co_ccap_subsidy: 1000 + +- name: The inactive stepfather counts alongside the linked mother + period: 2026-01 + input: + people: + parent: {age: 30, person_id: 1, tax_unit_role_input: HEAD, is_full_time_college_student: true} + other: {age: 32, person_id: 2, tax_unit_role_input: SPOUSE} + child: {<<: *activity_child, person_id: 3, tax_unit_role_input: DEPENDENT, parent_1_id: 1} + spm_units: + family: {members: [parent, other, child], spm_unit_pre_subsidy_childcare_expenses: 12000} + tax_units: *activity_three + households: *activity_three_home + # Both share custody and support the child. Only 1 of 2 caretakers qualifies. + output: {co_ccap_activity_eligible: false, co_ccap_eligible: false, co_ccap_subsidy: 0} + +- name: Zero business hours leave ongoing wage work eligible + period: 2026-01 + input: + people: + parent: {<<: *activity_worker, co_ccap_business_hours: 0} + child: *activity_child + spm_units: *activity_denver_expenses + tax_units: *activity_single + households: *activity_denver + # $30,000 / (40 × 52) > $7.25. $12,000 / 12 - $128 fee = $872. + output: {co_ccap_activity_eligible: true, co_ccap_eligible: true, co_ccap_subsidy: 872} + +- name: Zero wage hours leave ongoing business work eligible + period: 2026-01 + input: + people: + parent: {age: 30, self_employment_income: 15080, weekly_hours_worked_before_lsr: 40, weeks_worked: 52, co_ccap_work_hours: 0} + child: *activity_child + spm_units: *activity_single + tax_units: *activity_single + households: *activity_home + # The business earns $15,080 / (40 × 52) = $7.25 per hour. + output: {co_ccap_activity_eligible: true} + +- name: A verified wage month takes precedence over annual wage earnings + period: 2026-01 + input: + people: + parent: {<<: *activity_worker, co_ccap_work_hours: 0} + child: *activity_child + spm_units: *activity_single + tax_units: *activity_single + households: *activity_home + # Zero wage hours in January and $0 in business earnings give no qualifying work. + output: {co_ccap_activity_eligible: false} + +- name: A protected break counts only in the reported month + period: 2026-01 + input: + people: + parent: {age: 30, co_ccap_other_activity: {"2026-01": PROTECTED_BREAK}} + child: *activity_child + spm_units: *activity_single + tax_units: *activity_single + households: *activity_home + # One covered activity in January and zero in February. + output: {co_ccap_activity_eligible: {"2026-01": true, "2026-02": false}} + +- name: A business launch counts only in the approved month + period: 2026-01 + input: + people: + parent: {age: 30, co_ccap_other_activity: {"2026-01": BUSINESS_LAUNCH}} + child: *activity_child + spm_units: *activity_single + tax_units: *activity_single + households: *activity_home + # One approved activity in January and zero in February. + output: {co_ccap_activity_eligible: {"2026-01": true, "2026-02": false}} diff --git a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_subsidy.yaml b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_subsidy.yaml index ff9daf2d40f..23ac27b5ffa 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_subsidy.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/co/ccap/co_ccap_subsidy.yaml @@ -19,3 +19,25 @@ output: co_ccap_subsidy: 2022-12: 1_400 + +- name: A qualifying caretaker releases only their child's care charges + period: 2026-01 + input: + people: + parent: {age: 30, person_id: 1, is_full_time_college_student: true} + child: {age: 3, person_id: 2, parent_1_id: 1, pre_subsidy_childcare_expenses: 4800} + other: {age: 30, person_id: 3} + other_child: {age: 3, person_id: 4, parent_1_id: 3, pre_subsidy_childcare_expenses: 7200} + tax_units: + family: {members: [parent, child]} + other_family: {members: [other, other_child]} + spm_units: {family: {members: [parent, child, other, other_child]}} + households: {home: {members: [parent, child, other, other_child], state_code: CO, county: DENVER_COUNTY_CO}} + # Both children pass the age and dependency screen. Only the first child's + # caretaker qualifies, so pay $4,800 / 12 - $0 = $400 of the $1,000 bill. + output: + co_ccap_child_eligible: [false, true, false, true] + co_ccap_activity_eligible: true + co_ccap_parent_fee: 0 + co_ccap_eligible: true + co_ccap_subsidy: 400 diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py index f86bd6cedf6..01489cbe2f0 100644 --- a/policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_activity_eligible.py @@ -1,8 +1,4 @@ from policyengine_us.model_api import * -from policyengine_us.variables.household.demographic.person._parent_links import ( - co_resident_parent_indices, - group_member_indices, -) class co_ccap_activity_eligible(Variable): @@ -22,101 +18,4 @@ class co_ccap_activity_eligible(Variable): ) def formula(spm_unit, period, parameters): - p = parameters(period).gov - person = spm_unit.members - year = period.this_year - minimum_wage = p.dol.minimum_wage - - wages = person("co_ccap_work_wages", period) - work_hours = person("co_ccap_work_hours", period) - profit = person("co_ccap_business_profit", period) - business_hours = person("co_ccap_business_hours", period) - verified_hours = (work_hours >= 0) | (business_hours >= 0) - verified_work = ((work_hours > 0) & (wages >= work_hours * minimum_wage)) | ( - (business_hours > 0) & (profit >= business_hours * minimum_wage) - ) - - # Annual records can approximate ongoing work if they have hours and - # give no indication that work covers only part of the year. - earnings = np.sum( - [ - max_(person(source, year), 0) - for source in p.states.co.ccap.activity.earned_income_sources - ], - axis=0, - ) - weeks = person("weeks_worked", year) - weeks_at_work = where(weeks > 0, min_(weeks, WEEKS_IN_YEAR), WEEKS_IN_YEAR) - # Pre-response hours avoid a circular labor-supply dependency. - annual_hours = person("weekly_hours_worked_before_lsr", year) * weeks_at_work - annual_work = ( - (weeks_at_work == WEEKS_IN_YEAR) - & (annual_hours > 0) - & (earnings >= minimum_wage * annual_hours) - ) - works = where(verified_hours, verified_work, annual_work) - - studies = person("co_ccap_in_eligible_education", year) & ( - person("co_ccap_education_weeks_remaining", period) != 0 - ) - other = person("co_ccap_other_activity", period) - allowed_treatment = p.states.co.ccap.activity.substance_use_treatment - other_activity = (other != other.possible_values.NONE) & ( - (other != other.possible_values.SUBSTANCE_USE_TREATMENT) | allowed_treatment - ) - present = ~person("is_incarcerated", period) - active = present & (works | studies | other_activity) - blocking = present & ~active & ~person("co_ccap_incapacitated", period) - - eligible_child = person("co_ccap_child_eligible", period) - low_income = child_caretakers_meet_activity( - person, year, active, blocking, p.states.co.ccap.age_limit - ) - child_welfare = person("co_ccap_child_welfare_activity_waiver", period) - stabilization = spm_unit("co_ccap_homelessness_stabilization", period) - return spm_unit.any(eligible_child & (low_income | child_welfare)) | ( - spm_unit.any(eligible_child) & stabilization - ) - - -def child_caretakers_meet_activity(person, year, active, blocking, child_age_limit): - # Attribute the result to the child even if a linked caretaker belongs to - # another SPM unit. Parent links take precedence over tax-filing roles. - first, second = co_resident_parent_indices(person, year) - linked = (first >= 0) | (second >= 0) - linked_active = ((first >= 0) & active[first]) | ((second >= 0) & active[second]) - linked_blocking = ((first >= 0) & blocking[first]) | ( - (second >= 0) & blocking[second] - ) - - # Fall back to co-resident filers. With no filer, infer a sole teen - # caretaker only when one older member can be distinguished from the child. - home = person.household.members_entity_id - row = np.arange(person.count) - filer = person("is_tax_unit_head_or_spouse", year) - age = person("age", year) - child = person("is_child", year) - has_filer = np.zeros(person.count, dtype=bool) - filer_active = np.zeros_like(has_filer) - filer_blocking = np.zeros_like(has_filer) - teen_count = np.zeros(person.count, dtype=int) - teen_active = np.zeros_like(has_filer) - for member in group_member_indices(person.tax_unit): - co_resident = (member >= 0) & (member != row) & (home[member] == home) - claims = co_resident & filer[member] - teen = ( - co_resident - & (age[member] >= child_age_limit) - & child[member] - & (age[member] > age) - ) - has_filer |= claims - filer_active |= claims & active[member] - filer_blocking |= claims & blocking[member] - teen_count += teen - teen_active |= teen & active[member] - - unlinked = where( - has_filer, filer_active & ~filer_blocking, (teen_count == 1) & teen_active - ) - return where(linked, linked_active & ~linked_blocking, unlinked) + return spm_unit.any(spm_unit.members("co_ccap_child_activity_eligible", period)) diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_child_activity_eligible.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_child_activity_eligible.py new file mode 100644 index 00000000000..0d6cf427419 --- /dev/null +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_child_activity_eligible.py @@ -0,0 +1,129 @@ +from policyengine_us.model_api import * +from policyengine_us.variables.household.demographic.person._parent_links import ( + co_resident_parent_indices, + group_member_indices, +) + + +class co_ccap_child_activity_eligible(Variable): + value_type = bool + entity = Person + label = "Child meets Colorado CCAP eligibility and caretaker activity requirements" + definition_period = MONTH + defined_for = StateCode.CO + reference = ( + # PDF pages 1-3, 11, 15, 17-21, 24-25, 30, 35, 37-40, 48 + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12277&fileName=8%20CCR%201403-1#page=1", + # PDF pages 2, 31, 33-37, 39-40, 47-49, 63, 68-72 + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12658&fileName=8%20CCR%201403-1#page=2", + # PDF pages 14-18 + "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=11042&fileName=8%20CCR%201403-1#page=14", + "https://www.ecfr.gov/current/title-45/subtitle-A/subchapter-A/part-98/subpart-C/section-98.21#p-98.21(a)", + ) + + def formula(person, period, parameters): + p = parameters(period).gov + year = period.this_year + minimum_wage = p.dol.minimum_wage + + wages = person("co_ccap_work_wages", period) + work_hours = person("co_ccap_work_hours", period) + profit = person("co_ccap_business_profit", period) + business_hours = person("co_ccap_business_hours", period) + verified_work = ((work_hours > 0) & (wages >= work_hours * minimum_wage)) | ( + (business_hours > 0) & (profit >= business_hours * minimum_wage) + ) + + # Annual records approximate ongoing work for streams without monthly + # hours. Combined annual hours are an upper bound on each stream's hours. + earnings = np.sum( + [ + max_(person(source, year), 0) + * ( + work_hours < 0 + if source == "employment_income" + else business_hours < 0 + ) + for source in p.states.co.ccap.activity.earned_income_sources + ], + axis=0, + ) + weeks = person("weeks_worked", year) + weeks_at_work = where(weeks > 0, min_(weeks, WEEKS_IN_YEAR), WEEKS_IN_YEAR) + # Pre-response hours avoid a circular labor-supply dependency. + annual_hours = person("weekly_hours_worked_before_lsr", year) * weeks_at_work + annual_work = ( + (weeks_at_work == WEEKS_IN_YEAR) + & (annual_hours > 0) + & (earnings >= minimum_wage * annual_hours) + ) + works = verified_work | annual_work + + studies = person("co_ccap_in_eligible_education", year) & ( + person("co_ccap_education_weeks_remaining", period) != 0 + ) + other = person("co_ccap_other_activity", period) + allowed_treatment = p.states.co.ccap.activity.substance_use_treatment + other_activity = (other != other.possible_values.NONE) & ( + (other != other.possible_values.SUBSTANCE_USE_TREATMENT) | allowed_treatment + ) + present = ~person("is_incarcerated", period) + active = present & (works | studies | other_activity) + blocking = present & ~active & ~person("co_ccap_incapacitated", period) + + eligible_child = person("co_ccap_child_eligible", period) + low_income = child_caretakers_meet_activity( + person, year, active, blocking, p.states.co.ccap.age_limit + ) + child_welfare = person("co_ccap_child_welfare_activity_waiver", period) + stabilization = person.spm_unit("co_ccap_homelessness_stabilization", period) + return eligible_child & (low_income | child_welfare | stabilization) + + +def child_caretakers_meet_activity(person, year, active, blocking, child_age_limit): + # Attribute activity to the child even across SPM units. + first, second = co_resident_parent_indices(person, year) + linked = (first >= 0) | (second >= 0) + linked_active = ((first >= 0) & active[first]) | ((second >= 0) & active[second]) + linked_blocking = ((first >= 0) & blocking[first]) | ( + (second >= 0) & blocking[second] + ) + + # Fall back to co-resident filers. With no filer, infer a sole teen + # caretaker only when one older member can be distinguished from the child. + home = person.household.members_entity_id + row = np.arange(person.count) + filer = person("is_tax_unit_head_or_spouse", year) + age = person("age", year) + child = person("is_child", year) + has_filer = np.zeros(person.count, dtype=bool) + filer_active = np.zeros_like(has_filer) + filer_blocking = np.zeros_like(has_filer) + teen_count = np.zeros(person.count, dtype=int) + teen_active = np.zeros_like(has_filer) + for member in group_member_indices(person.tax_unit): + co_resident = (member >= 0) & (member != row) & (home[member] == home) + claims = co_resident & filer[member] + teen = ( + co_resident + & (age[member] >= child_age_limit) + & child[member] + & (age[member] > age) + ) + has_filer |= claims + filer_active |= claims & active[member] + filer_blocking |= claims & blocking[member] + teen_count += teen + teen_active |= teen & active[member] + + unlinked = where( + has_filer, filer_active & ~filer_blocking, (teen_count == 1) & teen_active + ) + # For a sole linked filer, the co-resident spouse or head in that + # filer's tax unit can be a second caretaker. A linked dependent's + # tax filers need not be the child's caretakers. + parent = where(first >= 0, first, second) + single_linked_filer = ((first >= 0) ^ (second >= 0)) & filer[parent] + linked_active |= single_linked_filer & filer_active[parent] + linked_blocking |= single_linked_filer & filer_blocking[parent] + return where(linked, linked_active & ~linked_blocking, unlinked) diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_in_eligible_education.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_in_eligible_education.py index 19743264bd0..e0b58fb1582 100644 --- a/policyengine_us/variables/gov/states/co/ccap/co_ccap_in_eligible_education.py +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_in_eligible_education.py @@ -6,8 +6,9 @@ class co_ccap_in_eligible_education(Variable): entity = Person label = "Enrolled in education or training that counts as a Colorado Child Care Assistance Program activity" documentation = ( - "Defaults to reported secondary school or equivalent, technical " - "training, or full- or part-time college enrollment. Set to true " + "Defaults to reported K-12, secondary school or equivalent, technical " + "training, full-time student, or full- or part-time college enrollment. " + "Set to true " "for other qualifying basic education or training and to false " "for graduate school or a second bachelor's degree. Use " "co_ccap_education_weeks_remaining to report when the county " @@ -23,9 +24,18 @@ class co_ccap_in_eligible_education(Variable): ) def formula(person, period, parameters): - return ( + enrollment = ( person("is_full_time_college_student", period) | person("is_part_time_college_student", period) | person("is_in_secondary_school", period) | person("technical_institution_student", period) ) + + # These legacy inputs also have age-based defaults. Count only + # the values supplied for this year. + branch = person.simulation.branch_name + for name in ("is_in_k12_school", "is_full_time_student"): + value = person(name, period) + if period in person.get_holder(name).get_input_periods(branch): + enrollment |= value + return enrollment diff --git a/policyengine_us/variables/gov/states/co/ccap/co_ccap_subsidy.py b/policyengine_us/variables/gov/states/co/ccap/co_ccap_subsidy.py index e1936345ec1..ef697241e4e 100644 --- a/policyengine_us/variables/gov/states/co/ccap/co_ccap_subsidy.py +++ b/policyengine_us/variables/gov/states/co/ccap/co_ccap_subsidy.py @@ -8,12 +8,23 @@ class co_ccap_subsidy(Variable): unit = USD definition_period = MONTH defined_for = "co_ccap_eligible" + # 8 CCR 1403-1 3.132(A), PDF page 69 + reference = "https://www.sos.state.co.us/CCR/GenerateRulePdf.do?ruleVersionId=12277&fileName=8%20CCR%201403-1#page=69" def formula(spm_unit, period, parameters): - expenses = add( - spm_unit, + person = spm_unit.members + charges = add( + person, period, ["pre_subsidy_childcare_expenses", "after_school_expenses"], ) + eligible_child = person("co_ccap_child_eligible", period) + activity_eligible = person("co_ccap_child_activity_eligible", period) + mixed_activity = spm_unit.any(activity_eligible) & spm_unit.any( + eligible_child & ~activity_eligible + ) + # Where the activity test splits coverage, pay only the passing + # children's charges. Other units keep their reported total bill. + expenses = spm_unit.sum(charges * (~mixed_activity | activity_eligible)) parent_fee = spm_unit("co_ccap_parent_fee", period) return max_(expenses - parent_fee, 0)