Plan: Pregnancy and homelessness facts for SNAP and WIC (#3070, #3072, #3073)

Status: Done (2026-10-31) — U1–U5 (#3143–#3147) merged
Epic: &63
Issues: #3070, #3072, #3073 (T2, parents) · #3143 U1 (w5) · #3144 U2 (w3) · #3145 U3 (w3) · #3146 U4 (w3) · #3147 U5 (w5)
Branches: feat/pregnancy-homelessness-facts

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-31): MemberFull gains a required pregnancies field, so U1 also touches the struct literals and JSON fixtures of every crate that reads the household bundle, the redaction kinds (pregnancy is shreddable) and finalize compensation (a worker’s pregnancy counts as a non-finalize fact). The fact id is PregnancyId, after AddressId.

Erratum (2026-10-31): a correction splits a pregnancy fact into several windows, so D3’s pregnancy_end_date is the valid_to of a fact’s last window, grouped by fact, not of any one version.

Erratum (2026-10-31): the SNAP pregnancy exception is 7 CFR 273.24(c)(6) in the current rule (89 FR 102362), not (c)(1)(iv) as decision 1 and D3 cite. A crypto-shredded pregnancy feeds neither member field, as a shredded income does not. The overpayment replay’s members carry no pregnancy (#3149).

Context

Three #858 splits share one shape: capture a fact, keep it as a dated canopy-persons fact, and thread it through canopy-eligibility’s orchestrator to a program.

  • SNAP (#3070). A pregnant adult is an exception to the ABAWD time limit (7 CFR 273.24(c)(1)(iv)), but nothing records pregnancy. classify_by_facts (services/canopy-snap/src/certification_period.rs) tests only disability, a dependent child and age, so a pregnant adult reads as a non-exempt ABAWD.

  • WIC (#3072, #3073). wic_worker_fact_gaps (services/canopy-eligibility/src/mappers/mod.rs) refuses WIC with input_unsatisfiable for six worker facts. Three of them are expected_delivery_date and pregnancy_end_date (the certification-period anchors, 7 CFR 246.7(g)(1)(i)–(iii)) and homeless (the 246.7(j)(8) notice lead, services/canopy-wic/src/terminations.rs). Fetus count is absent everywhere, though 7 CFR 246.7(d)(2)(vii) uses it: a pregnant woman meets the income guideline if it would be met with her family increased by the number of embryos or fetuses in utero, the same size may be used for her categorically eligible family members, and the applicant may waive the increase.

  • Today. canopy-persons has no generic attribute table. Each fact family has its own valid-time versions table with a GiST exclusion constraint, append/close_* store functions, ADR-027 provenance, ADR-036 sealed values, and staged events (services/canopy-persons/src/store/address_versions.rs is the closest per-person precedent; parent_child_versions.rs shows the subject lock taken before the fact lock, #3111/#3112/#3131). The orchestrator reads one get_household_full bundle as of the legal day (orchestrator.rs fetch_household_context). canopy-web’s worker intake already captures homeless in the special_circumstances section (SpecialCircumstancesPayload, crates/canopy-contracts-applications/src/sections.rs, saved through save_section_upstream in services/canopy-web/src/api/applications.rs), but it stays in application_sections and never reaches canopy-persons. The portal’s finalize (FinalizeRequest, crates/canopy-contracts-applications/src/finalize.rs, run by services/canopy-applications/src/finalize_saga.rs) carries flat income, asset and expense vectors and asks nothing about homelessness. No surface captures pregnancy. The orchestrator builds no WIC context at all: map_context(Program::Wic, …) answers InputUnsatisfiable(wic_worker_fact_gaps()) unconditionally, and compliance/input-requirements/wic.toml classifies each WIC field by the source the mapper will draw it from (source_class), with gap_issue on the ones no source yet holds.

WIC stays undispatchable after this plan, because the other three gaps (participant category, nutritional risk, breastfeeding) belong to #769. This plan clears its half and gives SNAP its exemption now.

Decisions (best effort, cited; AGENTS.md: a policy question is answered in the pack)

  1. SNAP: the ABAWD exception only. 273.24(c)(1)(iv) names pregnancy. 273.7(b)(1)'s work-registration exemptions do not, so pregnancy does not touch work-registration fitness. WorkRegistrationExemption::PregnantThirdTrimester (sections.rs) stays unbound.

  2. Pregnancy as of a day. A member is pregnant on day D when an accepted pregnancy version covers D: valid_from ⇐ D < valid_to, where valid_to is the date the pregnancy ended (birth or loss), open while it continues.

  3. WIC fetus count. 246.7(d)(2)(vii): a pregnant woman meets the income guideline if her family, increased by her fetuses, would, and the same increased size may be used for her categorically eligible family members. canopy’s WIC economic unit is the household, so the household’s income test uses household_size plus the fetus counts of its pregnant participants who have not waived. The waiver is the applicant’s election, recorded on the pregnancy fact.

  4. Food packages. Under 246.10(e)(5), fetus count splits Food Package V into V-A (singleton) and V-B (two or more fetuses). canopy stores only the package family, so V-A/V-B stays #1525’s subpackage work, which this plan’s fetus count now unblocks.

  5. Homelessness absent means not homeless. The worker intake asks special_circumstances.homeless explicitly, and saving that section claims a true into canopy-persons. With no accepted version covering the day, WIC gets homeless: false. Pending every household that was never asked would leave WIC undispatchable for the commonest case.

  6. Sensitive values are sealed. The expected delivery date, the fetus count and the waiver are sealed under the fact DEK (ADR-036), like an address’s street lines. The valid-time dates stay plaintext, as every corpus’s do. Events carry no sealed value (coarse, as AddressClaimedEvent).

  7. Applicant-portal capture is out of scope. Capture is the worker intake section (homeless) and worker actions (both facts). A follow-up issue adds the portal questions and, with them, a homeless field on FinalizeRequest that finalize claims. #3073’s "claimed at finalize" assumed the portal asked; it does not, so this plan claims at the worker section save instead.

  8. The generic context carries the pregnancy. ApplicationMember gains pregnancy: Option<MemberPregnancy> (the open pregnancy as of the day: expected delivery date, fetus count, waiver) and pregnancy_end_date (the latest ended one), and ApplicationContext gains homeless: bool. They ride the mTLS dispatch to every program as date_of_birth and disability_status do. SNAP reads only pregnancy.is_some(); Medicaid (the pregnant-women MAGI group) and TANF (a pregnant woman’s assistance unit) will want the rest, and #769’s WIC mapper consumes it from here.

Scope

In scope: the two corpora and their routes, events, reads and CLI; the claim of homeless from the worker intake section; the orchestrator threading; SNAP’s exemption; WIC’s three gap fields and the fetus-count income increase; worker actions in canopy-web; docs, compliance manifests and tests.

Out of scope: the #769 WIC gaps and WIC dispatch; Food Package V-A/V-B (#1525); portal capture and the finalize claim (follow-up); pregnancy for TANF or Medicaid (their own issues if needed).

Design

D1 — The pregnancy corpus (canopy-persons)

Migration <next>_create_pregnancy_versions.sql: pregnancy_versions with the shared corpus columns (version_id, fact_id, person_id, valid_from DATE NOT NULL, valid_to DATE NULL, recorded_at, superseded_at, ADR-027 provenance, proposed_value_sealed) and one sealed value column (a SealedValue holding PregnancyFactValue { expected_delivery_date: NaiveDate, fetus_count: u8 (1..=8), family_size_increase_waived: bool }). The constraint is EXCLUDE USING gist (person_id WITH =, daterange(valid_from, valid_to, '[)') WITH &&) WHERE (superseded_at IS NULL AND claim_status LIKE 'accepted%'), so a person has one pregnancy at a time.

store/pregnancy_versions.rs mirrors address_versions.rs (append_address_version, close_address_version): append_pregnancy_version and close_pregnancy_version(end_date). Each takes a person-subject lock (lock_pregnancy_subject(person_id), key canopy-persons.fact_version.pregnancy.person.{person}) before lock_fact, the #3112/#3131 order.

Routes (services/canopy-persons/src/api/mod.rs, a new services/canopy-persons/src/api/pregnancy.rs): * POST /v1/persons/{id}/pregnancies → 201 Pregnancy; * DELETE /v1/pregnancies/{fact_id}?end_date= → 200, the close, recording the end. Writer roles as for addresses. Events pregnancy.claimed and pregnancy.closed (coarse: person, fact, valid-time window, no value) go in events.rs and the RabbitMQ ACL. BatchGetField::Pregnancies on get_household_full (crates/canopy-contracts-persons/src/batch.rs) returns each member’s pregnancies covering or ending before the as-of day, opened under the DEK for system callers that hold read access.

D2 — The homelessness corpus (canopy-persons)

Migration <next>_create_household_homelessness_versions.sql: household_homelessness_versions, keyed by household_id, with no value column (a version is a homeless period) and the same exclusion shape on household_id. store/homelessness_versions.rs takes a household-subject lock before lock_fact.

Routes: POST /v1/households/{id}/homelessness → 201; DELETE /v1/households/{id}/homelessness/{fact_id}?end_date= → 200. Events household.homelessness_claimed and household.homelessness_closed. BatchGetField::Homelessness on get_household_full.

The worker intake claim lives in canopy-web (D5): saving a special_circumstances section with homeless: true claims a homelessness version from the section’s effective date through the worker’s delegation, with ADR-027 provenance naming the worker and claim_source intake, the way the fact editors write facts (services/canopy-web/src/persons_write.rs). A second save with homeless: true while a version is open claims nothing (the include says one is open). homeless: false while one is open closes it at the save date; otherwise it claims nothing.

D3 — Orchestrator threading and SNAP

fetch_household_context requests Pregnancies and Homelessness and fills decision 8’s fields: MemberPregnancy from the accepted version covering the as-of day (decision 2), pregnancy_end_date from the latest version whose valid_to is on or before it, and homeless from an accepted homelessness version covering it. MemberContext (crates/canopy-contracts-eligibility/src/determine.rs) and canopy-snap’s request (crates/canopy-contracts-snap/src/determine.rs) carry the member fields.

classify_by_facts returns (AbawdStatus::IsNot, "pregnant") after the disability check, citing 273.24(c)(1)(iv). The reason string is recorded wherever the other classify_by_facts reasons are (the ABAWD identification on the determination; services/canopy-snap/tests/snap_test.rs pins them).

WIC gets no mapper here, because #769’s three facts are still unsourceable, so map_context(Program::Wic, …) keeps answering InputUnsatisfiable. What changes is the gap list: wic_worker_fact_gaps shrinks to the #769 three, and in wic.toml the expected_delivery_date, pregnancy_end_date and homeless rows move from source_class = "worker-fact" with a gap_issue to source_class = "persons", naming the context field each is drawn from. The input-coverage gate keeps the manifest and the WIC schema in step. #769’s mapper then reads decision 8’s fields; nothing in this plan is dead code, since SNAP consumes pregnancy and the orchestrator’s own tests pin the rest.

D4 — WIC fetus count

WicParticipantContext (crates/canopy-contracts-wic/src/determine.rs) gains fetus_count: Option<u8> and family_size_increase_waived: bool (two wic.toml rows, source_class = "persons", nested_in = "participants"). canopy-wic’s economic-unit step (services/canopy-wic/src/determine.rs, where income_threshold = wic_params.monthly_income_threshold(hh_size) is computed once before the rules call) gains income_family_size(hh_size, &context.participants) per decision 3, cited, and feeds that size to monthly_income_threshold. The ruleset and the threshold params are unchanged. The sealed program input records both sizes, so a reviewer can see the increase that applied.

D5 — Worker actions and the intake claim (canopy-web)

Mirroring the address editor (services/canopy-web/src/api/address.rs), the case detail offers: * record pregnancy on a member: EDD, fetus count, waiver; * end pregnancy: end date; * record homelessness and end homelessness on the household. These go through the persons routes with the worker’s bound session, the same roles and roster binding (ProvenPerson::on_roster, services/canopy-web/src/persons_write.rs), and the CSRF and copy patterns. The special_circumstances section save (save_section_upstream, services/canopy-web/src/api/applications.rs) claims or closes the homelessness fact per D2 after the section is stored, so a failed persons write leaves the section saved and reports the failure, as the fact editors do. The CLI (ADR-007) gains canopy person pregnancy add|end (tools/canopy-cli/src/cmd/person.rs) and canopy household homelessness add|end (cmd/household.rs) in U1 and U2.

Risks

Risk Mode Mitigation

A pregnancy not recorded leaves a pregnant adult non-exempt.

silent

The same as today. The worker action and the intake follow-up close it; the ABAWD reason shows pregnant when it applies.

A household never asked about homelessness gets the ordinary notice lead.

silent

Decision 5. The intake asks; a worker can record it later.

The fetus-count increase is applied when the applicant waived it.

silent

The waiver is on the fact and is read per participant; a unit test per arm.

Sensitive pregnancy values leak through events or logs.

silent

Sealed values and coarse events; an event-shape test asserts no value field.

Units (weights by complexity) — U1 ‖ U2 → U3 → U4 ‖ U5 (U5 after U2)

Weights: 1 trivial · 2 small · 3 medium · 5 large · 8 very large. One unit = one independently shippable MR = one child issue.

U1 (w5) — The pregnancy corpus

Files: services/canopy-persons/migrations/<next>_create_pregnancy_versions.sql, services/canopy-persons/src/store/{pregnancy_versions.rs (new), mod.rs}, services/canopy-persons/src/api/{pregnancy.rs (new), mod.rs}, services/canopy-persons/src/events.rs, crates/canopy-contracts-persons/src/{pregnancy.rs (new), batch.rs, events.rs, lib.rs}, devstack/rabbitmq/definitions.json, xtask/mq-topology-allow.toml, tools/canopy-cli/src/cmd/person.rs, docs/modules/ROOT/pages/{api,data-models}/canopy-persons.adoc, tooling/canopy-cli.adoc, CHANGELOG.adoc

D1. Tests: store infra, append and close, the remnant re-tile, and one pregnancy per person (mutation: drop the exclusion’s person_id); concurrency, two new pregnancies for one person wait on the subject lock and are refused 23P01 (mutation: lock another key); the sealed value round-trips and the raw column holds no plaintext EDD; contract, a roundtrip proptest of Pregnancy, the claim request and the event (mutation: rename a field) and an event-shape test that no value field exists (mutation: add one); the Pregnancies include as of a day; the routes' authz and 201; the CLI’s body and path tests.

U2 (w3) — The homelessness corpus

Files: services/canopy-persons/migrations/<next>_create_household_homelessness_versions.sql, services/canopy-persons/src/store/{homelessness_versions.rs (new), mod.rs}, services/canopy-persons/src/api/{homelessness.rs (new), mod.rs}, services/canopy-persons/src/events.rs, crates/canopy-contracts-persons/src/{homelessness.rs (new), batch.rs, events.rs}, devstack/rabbitmq/definitions.json, xtask/mq-topology-allow.toml, tools/canopy-cli/src/cmd/household.rs, the persons API and data-model pages, CHANGELOG.adoc

D2’s corpus. Tests: store infra, append and close and one open period per household (mutation: drop the exclusion’s household_id); concurrency, two new periods for one household wait on the subject lock and are refused 23P01 (mutation: lock another key); contract, a roundtrip proptest of the wire types and the events (mutation: rename a field); the Homelessness include as of a day; the routes' authz and 201; the CLI’s body and path tests.

U3 (w3) — Threading, the SNAP exemption, three WIC gaps cleared

Files: services/canopy-eligibility/src/{orchestrator.rs, mappers/mod.rs}, crates/canopy-common/src/household.rs, crates/canopy-contracts-eligibility/src/determine.rs, crates/canopy-contracts-snap/src/determine.rs, services/canopy-snap/src/certification_period.rs, compliance/input-requirements/wic.toml, the eligibility and snap API pages, the OpenAPI snapshots, CHANGELOG.adoc

D3. Tests: unit, classify_by_facts exempts a pregnant member before age and after disability (mutation: drop the arm); orchestrator infra, pregnancy is Some only inside the window, pregnancy_end_date is the latest ended one, and homeless follows the household version (mutation: ⇐ on valid_to; read the earliest ended one); unit, map_context(Program::Wic, …) names exactly the #769 three (mutation: keep homeless); the input-coverage gate passes with the moved rows; contract round-trips of the changed MemberContext and SNAP request. Closes #3070.

U4 (w3) — WIC’s fetus-count family size

Files: crates/canopy-contracts-wic/src/determine.rs, services/canopy-eligibility/src/mappers/mod.rs, services/canopy-wic/src/determine.rs, the WIC parity table (services/canopy-wic/src/determine_gate_parity_tests.rs), docs/modules/ROOT/pages/api/canopy-wic.adoc, federal-requirements.adoc (the 246.7(d)(2)(vii) row), CHANGELOG.adoc

D4. Tests: unit, income_family_size adds the fetuses of each pregnant participant who did not waive and nothing for one who did or for a non-pregnant participant (mutation: ignore the waiver; add for a non-pregnant participant); parity rows, an over-income household becomes income-eligible with two fetuses and not when waived; contract, a roundtrip proptest of the widened WicParticipantContext (mutation: rename a field); the input-coverage gate with the two new rows. Closes #3072.

U5 (w5) — Worker actions and the intake claim

Files: services/canopy-web/src/api/{pregnancy.rs (new), homelessness.rs (new), applications.rs, mod.rs} (routes mounted from the new modules so services/canopy-web/src/api/mod.rs stays within its B1 budget, as the held worklist does), services/canopy-web/src/persons_write.rs, templates, route tests, tests/e2e/specs/worker-pregnancy-homelessness.spec.ts, docs/modules/ROOT/pages/api/canopy-web.adoc, authorization-inventory.adoc, CHANGELOG.adoc

D5. Tests: route, each action posts the right body to the right persons route with the bound session, off-roster refused (mutation: drop the roster binding); route, saving special_circumstances with homeless: true claims once, a repeat claims nothing, and false closes an open version (mutation: claim on every save); e2e, a worker records a pregnancy and the household’s next SNAP determination shows the pregnant ABAWD reason. Closes #3073.

Verification

  1. cargo xtask test.

  2. cargo xtask dev restart after U1 and U2 (migrations), then cargo xtask e2e — specs/worker-pregnancy-homelessness.spec.ts.

  3. cargo xtask mq-topology, route-authz audit, call-graph, api-docs, migrations-lint, quality-budgets.

  4. Each unit’s named mutations fail their tests.

  5. cargo xtask validate is green.

  6. Delivery: each unit merges with Closes on its child issue; U3’s MR also closes #3070, U4’s #3072 and U5’s #3073; the last of them closes this plan (Status Done, archived, plan-lint --done).

Documentation Updates

  • api/ and data-models/ pages for canopy-persons, canopy-eligibility, canopy-snap, canopy-wic and canopy-web; services.adoc; authorization-inventory.adoc; tooling/canopy-cli.adoc

  • federal-requirements.adoc — 273.24(c)(1)(iv), 246.7(d)(2)(vii), 246.7(j)(8)

  • CHANGELOG.adoc — an entry per unit

Review log

round vendor resolved model verdict

1

Anthropic

claude-fable-5-1 (gadhs/pi’s plan review at exit_plan_mode)

FLAGS — the plan assumed a WIC context mapper the orchestrator does not have; an enum and a contract path were misnamed; named files not supplied. Fixed: D3 now trims the gap list and moves the manifest rows instead, and decision 8 carries the facts in the generic context.

2

Google

gemini-4-argon (pi’s integrated second-vendor review)

FLAGS — contract tests unnamed for the new wire types; the closing issues unstated; the same missing mapper; wic.toml rows must move to persons, not be dropped; the income threshold is computed in Rust before the rules call. Fixed in U1–U5 and D4.

Edit this page · default