Plan: Persist each TANF determination’s assistance unit and serve family composition (#3048)

Status: Done (2026-10-29) — !1835
Epic: none (prerequisite P2 of Plan: TANF work participation rate — weekly averages, the recorded young-child standard and family type (#2316, #2315, #2975); unblocks #2975, the last open T1 item)
Issues: #3048 (T2, parent) · U1 → #3084 (w5) · U2 → #3085 (w3) · follow-ups F1 → #3086, F2 → #3087
Branches: feat/tanf-determination-au-members

This is a Design + Scope plan: GitLab owns tracking, the child issues carry the implementer brief, and the plan freezes when U1 starts.

Erratum (2026-10-29): D2 also refuses a repeated member id with 422 member_person_id_invalid (it would otherwise hit the unit table’s primary key as a 500), and an edge whose kind is outside natural | adoptive | step with 422 parent_child_kind_invalid. The dependent-child age is the named constant DEPENDENT_CHILD_AGE (42 USC 606(a)(1)(A)), since the pack has no TANF key for it; D6’s minor reads the pack’s [tanf.wpr].work_requirement_age_min.

Erratum (2026-10-29): the route’s authorization is a hand-kept row in authorization-inventory.adoc (route-authz audits canopy-web routes only), and the edits reach a few files outside the unit lists: compliance/action-coverage-allowlist.toml, compliance/input-requirements/tanf.toml, the test UTC-today allowlist, and a canopy-contracts-tanf dev-dependency on canopy-eligibility.

Erratum (2026-10-29): U2’s route infra test carries a member whose 18th birthday falls inside the report month, so a read judged at the month’s first day rather than its last fails it; the first draft had none, and that mutation survived.

Context

canopy-tanf has an assistance-unit composer nobody calls. compose_tanf_au (services/canopy-tanf/src/au_composition.rs:39) applies PAMMS 1205’s standard filing unit, the SSI, IV-E and relative-care exclusions, the PAMMS 1345 penalties and the PAMMS 1620–1632 deeming rules to a TanfMemberContext of nineteen inputs (:15-36) and returns an AssistanceUnit of AuMember { person_id, relationship, status } with AuMemberStatus Included, Excluded, Penalized or Deemed (crates/canopy-common/src/au_composition.rs:32). compliance/action-catalogue/tanf.toml:292 records it as unwired, and a determination persists no members: persist_determination (services/canopy-tanf/src/determine.rs:1078) writes the determination, its snapshot DEK, the sealed input snapshot and the FTI chain entry in one transaction, nothing about the unit.

The determine request carries, per member, person_id, relationship, age, disability_status and date_of_birth (crates/canopy-common/src/household.rs:27, ApplicationMember), plus applicant_person_id, the head (crates/canopy-contracts-tanf/src/determine.rs:24). canopy-eligibility assembles it from GET /v1/households/{id}/full with the income, asset and expense groups (services/canopy-eligibility/src/orchestrator.rs:383-410) and passes the context to TANF unchanged (services/canopy-eligibility/src/mappers/mod.rs:116). Since #3047 (!1833) that read can also return the parent_child fact group: each household member’s parent–child relations with a kind (crates/canopy-contracts-persons/src/batch.rs:48-50).

canopy-reporting’s ACF-199 fold keys on the month’s determination roll (services/canopy-reporting/src/worker/tanf.rs:8-45) but types each family from the household roster: family_type (tanf.rs:1078) counts members whose relationship is not "child" as adults. The WPR plan’s D8 (Plan: TANF work participation rate — weekly averages, the recorded young-child standard and family type (#2316, #2315, #2975), lines 129–136) makes its U5 depend on #3048 answering, per determination and month, each unit member’s work_eligible (45 CFR 261.2(n)), minor, head_of_household and parent_of: [{ child_id, kind }], and says that until #2974 saves the work-requirement evaluation, a member a case-by-case SSI or SSDI exclusion would remove is reported work-eligible.

canopy-tanf already reads dates of birth from canopy-persons at read time rather than storing them: week_standard::fetch_dates_of_birth (services/canopy-tanf/src/participation/week_standard.rs:120-128) calls persons:batchGet with no projection (the person core carries date_of_birth) and answers 502 persons_unavailable when the call fails. Its bulk routes admit system callers with principal.admit(&super::SYSTEM) and cap ids at 500 (services/canopy-tanf/src/api/work_requirement_handlers.rs:857-873, batch_work_standards).

Rulings (maintainer, 2026-10-29)

  • Q1, the composer’s inputs: ship with the seven inputs recorded today. The twelve exclusion and penalty flags no service records default to false, which keeps the member in the unit: fail-closed for reporting (the member counts toward a denominator rather than vanishing). Each default is listed in D3 with the issue that will capture the fact. Rejected: holding #3048 until the twelve facts exist (T1’s last item would wait on a dozen intake issues), and refusing every determination with an unknown flag (no household could supply them).

Scope

In scope:

  • The orchestrator threads parent–child edges to TANF.

  • canopy-tanf composes the unit at determination time from the recorded inputs and persists it with the determination.

  • POST /v1/determinations/family-composition:batchGet for canopy-reporting.

  • Docs and the CHANGELOG.

Out of scope:

  • Capturing the twelve defaulted facts (their issues in D3).

  • Saving the work-requirement evaluation and the case-by-case SSI/SSDI exclusions (#2974).

  • Changing the benefit computation to use the composed unit (the grant still uses household_size; switching it is F1 (#3086), since it changes amounts and needs its own policy check).

  • canopy-reporting’s consumption of the route (the WPR plan’s U5, #2975).

Design

D1 — the edges reach TANF. fetch_household_context (orchestrator.rs:383) adds BatchGetField::ParentChild to its projection. The eligibility ApplicationContext (crates/canopy-contracts-eligibility/src/determine.rs:345) gains parent_child: Vec<ParentChildEdge>, where ParentChildEdge { parent_person_id: Uuid, child_person_id: Uuid, kind: String } is the household’s current edges deduplicated across members (each relation appears on both ends of the bundle). TANF’s ApplicationContext (crates/canopy-contracts-tanf/src/determine.rs:24) gains the same field. Both are required, not defaulted: pre-1.0, one producer. The other program contracts deserialise their own structs and ignore the field (none is deny_unknown_fields); SNAP and Medicaid gain nothing here. kind is the closed ParentChildKind vocabulary as a string on this wire, parsed by TANF.

D2 — composing at determination. A new services/canopy-tanf/src/au_composition/inputs.rs builds Vec<TanfMemberContext> from the request:

  • person_id parsed from the member’s string; an unparseable one refuses the determination 422 member_person_id_invalid before any write (fail-closed; canopy-persons mints every id, so only a direct caller can send one);

  • relationship, age from the member;

  • is_dependent_child: age < 18 (the member’s age at evaluation; the 18-year-old-in-school rule is not recordable yet and stays out). A member with no age is neither a dependent child nor, unless an edge says so, a parent of one, and so lands Excluded with the reason age unrecorded, visible in the persisted row. canopy-persons requires a date of birth, so the orchestrator always derives an age; only a direct caller can omit it;

  • is_parent_of_dependent: the member is the parent, by any kind, of a member who is a dependent child;

  • is_stepparent: the member’s only edges to dependent children are step;

  • receives_ssi: disability_status == "ssi_recipient" (canopy_reference::DisabilityStatus);

  • the twelve others false (D3).

determine calls compose_tanf_au after the eligibility evaluation and before persist_determination, and DeterminationRows carries the unit. The composition does not change the grant: the benefit computation keeps household_size (F1).

D3 — the defaulted inputs, named. The twelve flags and the TANF issue that will capture each fact: is_enumeration_failure (#807, tanf.intake.enumeration-penalty); is_immunization_failure, is_school_attendance_failure, is_prenatal_failure (#815, the PAMMS 1345–1370 personal-responsibility penalties); is_felony_conviction, is_drug_felony, is_fleeing_felon (#822, PAMMS 1387); is_ineligible_parent, is_ineligible_spouse (#809, deeming); is_sponsored_alien (#810, sponsor deeming); is_foster_care_ive and is_relative_care_subsidy (no issue named them: F2, #3087). The module doc of inputs.rs carries this table. A member kept by default is Included, and nothing records "unknown": the default is the regulation’s, not a guess, and a re-determination after capture recomposes by rule.

D4 — the tables. Migration services/canopy-tanf/migrations/<stamp>_tanf_determination_au_members.sql:

  • tanf_determination_au_members (determination_id UUID NOT NULL REFERENCES tanf_determinations(id), person_id UUID NOT NULL, relationship TEXT NOT NULL, status TEXT NOT NULL CHECK (status IN ('included','excluded','penalized','deemed')), reason TEXT, deemer_type TEXT, head_of_household BOOLEAN NOT NULL, PRIMARY KEY (determination_id, person_id)), with a CHECK that reason is present exactly when status is excluded or penalized and deemer_type exactly when deemed;

  • tanf_determination_au_parents (determination_id UUID NOT NULL, parent_person_id UUID NOT NULL, child_person_id UUID NOT NULL, kind TEXT NOT NULL CHECK (kind IN ('natural','adoptive','step')), PRIMARY KEY (determination_id, parent_person_id, child_person_id), FOREIGN KEY (determination_id, parent_person_id) REFERENCES tanf_determination_au_members, FOREIGN KEY (determination_id, child_person_id) REFERENCES tanf_determination_au_members), the edges among unit members, every kind, so a reader applies its own kind list ([tanf.wpr].two_parent_parent_kinds).

No date of birth, no name: the rows are composition only. store::create_determination_au inserts both in persist_determination's transaction, after the determination row. head_of_household is person_id == applicant_person_id.

D5 — the route. POST /v1/determinations/family-composition:batchGet (crates/canopy-contracts-tanf/src/paths.rs), body FamilyCompositionBatchRequest { determination_ids: Vec<DeterminationId>, month: NaiveDate } where month is a first-of-month date (422 otherwise; ids capped at 500, 422 over). Response Vec<FamilyComposition { determination_id, members: Vec<FamilyMember> }> in request order, an unknown id omitted (the caller’s universe is the determination roll it drained, so a miss is its own inconsistency to report). FamilyMember { person_id, receives_assistance, work_eligible, minor, head_of_household, parent_of: Vec<ParentOf { child_id, kind }> }, where parent_of lists the member’s edges to unit members who are minors in that month. Admission super::SYSTEM. The handler reads both tables for the ids, then persons:batchGet for the distinct person ids with no projection (the core carries date_of_birth), as fetch_dates_of_birth does, and answers 502 persons_unavailable if that fails; a person canopy-persons does not return is reported minor: false with a WARN naming the ids (fail-closed: an unknown age never makes a child).

D6 — the per-month answers.

  • minor: the date of birth plus 18 years is after the month’s last day.

  • receives_assistance: status included.

  • work_eligible (261.2(n)): (receives_assistance || parent_of_recipient_child) && !(minor && !head_of_household), where parent_of_recipient_child is an edge to a unit member who is included and a minor in the month. This reports a non-recipient parent (excluded, penalized or deemed) as work-eligible, a recipient adult or minor head as work-eligible, a non-recipient non-parent (a caretaker relative not in the grant) as not, and a minor parent who is not head as not. The 261.2(n)(2)(i) caregiver exclusion and the case-by-case SSI/SSDI exclusions are not applied: the first has no recorded fact, the second is #2974’s, and both report work-eligible until then, as the WPR plan says. The function is pure (family_composition::work_eligible) and unit-tested per clause.

D7 — docs. canopy-tanf API Reference (the route, the request’s new field), canopy-tanf Data Model (the two tables), canopy-eligibility API Reference (the context’s new field), Canopy Service Catalog, compliance/action-catalogue/tanf.toml:292 (the composer is wired; the defaulted inputs stay listed as gaps), the OpenAPI snapshots for tanf and eligibility, and the CHANGELOG.

Units (weights by complexity) — U1 → U2, one MR

Weights: 1 trivial · 2 small · 3 medium · 5 large · 8 very large. One unit = one child issue. Both land in one MR, one commit per unit, under the maintainer’s standing direction to batch issues touching the same code; U2’s route has nothing to serve before U1 persists the unit.

U1 (w5) — compose and persist the unit

Files: services/canopy-eligibility/src/orchestrator.rs; crates/canopy-contracts-eligibility/src/determine.rs; crates/canopy-contracts-tanf/src/determine.rs; services/canopy-tanf/src/{au_composition.rs, au_composition/inputs.rs (new), determine.rs, store/mod.rs, store/models.rs}; services/canopy-tanf/migrations/<stamp>_tanf_determination_au_members.sql; compliance/action-catalogue/tanf.toml; the docs pages in D7 for the context and the tables; CHANGELOG.adoc.

D1 to D4, D7’s share. Tests:

  • Inputs (unit): a two-parent household with a child yields two parents-of-dependent and one dependent child; a step-parent with no other edge is is_stepparent; an ssi_recipient member is receives_ssi; an adult with no edges is neither; every defaulted flag is false.

  • Orchestrator (infra): the TANF request carries the household’s edges once each, and SNAP’s request is unchanged.

  • Determination (infra, canopy-tanf): a determination persists one member row per request member with the composer’s status and reason, head_of_household only for the applicant, and one edge row per edge among members; an edge to a person outside the request is dropped; the rows commit with the determination and none exist for a determination that failed to commit.

  • Contract: roundtrip proptest for the new fields.

Mutations named in the child issue: the edge dedup dropped (duplicate rows → the primary key fails, so the test asserts the count instead); head_of_household from relationship instead of the applicant; receives_ssi from disability_status == "disabled".

U2 (w3) — serve family composition

Files: crates/canopy-contracts-tanf/src/{paths.rs, family_composition.rs (new), lib.rs}; services/canopy-tanf/src/api/{mod.rs, family_composition.rs (new)}; services/canopy-tanf/src/store/mod.rs; crates/canopy-test-lib/src/clients/tanf.rs; the OpenAPI snapshot; the docs pages in D7 for the route; CHANGELOG.adoc.

D5 and D6. Tests:

  • work_eligible (unit, per clause): a recipient adult → true; a recipient minor head → true; a recipient minor not head → false; a non-recipient parent of a recipient minor child → true; a non-recipient parent whose only child is 18 in the month → false; a non-recipient non-parent → false.

  • minor (unit): born on the month’s last day 18 years earlier → not minor; born the day after → minor.

  • Route (infra): two determinations and a month: members in request order with the D6 answers from real persons dates of birth; parent_of lists only minors; an unknown id is omitted; 501 ids → 422; a non-first-of-month month → 422; a caseworker principal → 403; canopy-persons unreachable → 502; a member canopy-persons does not return (a person id with no persons row, seeded directly into the unit table) is minor: false and the response still answers.

  • Contract: roundtrip proptest for the request and response, and a key pin for the path.

Mutations: minor computed at the month’s first day instead of the last (the boundary test); work_eligible's minor-not-head clause dropped; parent_of listing adult children; an absent date of birth read as a minor.

Verification

  1. cargo xtask test — the unit and integration lanes pass (see Testing); canopy-tanf’s and canopy-eligibility’s integration lanes run the new infra tests on the devstack.

  2. cargo xtask dev restart (the U1 migration), then cargo xtask e2e; the TANF journeys still determine.

  3. cargo xtask migrations-lint, cargo xtask api-docs --update for tanf and eligibility, and the route-authz gate.

  4. cargo xtask validate — the pre-push battery is green.

  5. Close: the MR carries Closes #3048 and both children; the close note names the merge SHA, F1 and F2, and that #2975 is unblocked.

Documentation Updates

  • Antora canonical pages — api/canopy-tanf.adoc, data-models/canopy-tanf.adoc, api/canopy-eligibility.adoc, Service Catalog

  • compliance/action-catalogue/tanf.toml — the composer’s gap row

  • CHANGELOG.adoc — entries under == Unreleased (U1 Added, U2 Added)

  • No ADR change

Risks

  • The defaulted flags. A household with an uncaptured exclusion is reported with that member in the unit: fail-closed for the denominator and silent per household. Mitigation: D3 names each fact’s issue; the persisted reason shows the rule applied; a re-determination after capture recomposes.

  • The benefit still uses household_size. The persisted unit and the grant can disagree for an excluded member: fail-open for the amount, as today. Mitigation: F1, which changes amounts and needs its own policy check.

  • A date of birth canopy-persons cannot return. minor: false with a WARN, fail-closed for typing: the member can only make a family less likely to be child_only.

  • A stale unit. Composition is per determination. A child who turns 18 is handled per month by D6, but a parent fact recorded after the determination waits for the next determination, as every other input does: fail-closed and silent for typing (the family is typed from fewer parents than it has). Mitigation: the WPR extract keys on the month’s determination roll, so a re-determination recomposes; a worker who records a parent for a live TANF case re-runs the determination, as for any new fact.

Review log

round vendor resolved model verdict

1

Anthropic

claude-fable-5-1

FLAGS (2): the stale-unit risk named no fail mode; the header omitted F2; D2 left an absent age and an unparseable person id undecided; several cited files unsupplied as review context. Fixed in the draft.

2

Google

gemini-4-argon

FLAGS (2): the same risk; U2 named no contract test, and no test pinned the absent-date-of-birth → minor: false rule. Fixed in the draft.

Edit this page · default