Plan: county is required on a residential address (#3376)
Status: Done (2026-11-23) — two units; every writer sends a residential address's county, and canopy-persons and the database refuse one without
Closes: #3376 (by U2)
Issues: #3376 (parent) · U1 #3551 · U2 #3552
This is a Design + Scope plan: GitLab owns tracking, the unit issues carry the implementer brief, and the plan freezes when U1 starts.
Problem
county_fips is optional on a canopy-persons address. The finalize saga writes every applicant address with county_fips: None (services/canopy-applications/src/finalize_saga.rs, address_fact), the worker form offers a free-text "County FIPS" box that may be blank, and nothing derives it.
Federal policy presumes the agency knows a household’s area: 7 CFR 273.24(f) waives the ABAWD time limit by area of residence, and 273.3(a) ties a household to a project area. #3331’s ABAWD waiver areas cannot be built on a county that may be absent.
Decisions (maintainer)
-
2026-11-11: county is required on every residential address, chosen from a list at intake and on the worker form. It is not derived from the ZIP. The ABAWD counter gets no unknown-county branch.
-
2026-11-23: the list is canopy-reference’s county table (
admin_units_for_state) for the State the pack names in[jurisdiction].fips_state_code, narrowed by the pack’s existing[jurisdiction].fips_county_codeswhen that is non-empty. No new pack table. -
2026-11-23: a residential address in another State still needs a county, validated against that State’s table. The jurisdiction’s narrowed list applies only when the address is in the jurisdiction’s State. The non-resident denial path is kept.
-
2026-11-23: existing rows are not migrated. No deployment holds real rows before 1.0; a database CHECK is added validated, and a database holding a residential row with no county must be re-seeded.
Design
The rule
The stored value stays the existing five-digit county_fips: the State’s two-digit FIPS code followed by the county’s three-digit code.
One pure function in canopy-reference, counties::residential_county(state: &str, county_fips: Option<&str>) → Result<&'static AdminUnit, CountyError>:
CountyError |
When |
|---|---|
|
No county, or an empty one. |
|
|
|
Not five digits, the first two are not the State’s FIPS code, or the last three name no unit of that State. |
One loader in canopy-common beside load_jurisdiction_timezone, load_jurisdiction_counties(snapshot) → Result<JurisdictionCounties>: the jurisdiction’s State and its served units (the whole State’s table when fips_county_codes is empty). It refuses at load a fips_county_codes entry that names no unit of the State. JurisdictionCounties::admits(state, unit) is true for any unit of another State, and for a unit of the jurisdiction’s State only when it is served.
Mailing and substitute addresses are untouched: their county_fips stays optional and unchecked.
An application may still be filed with no address at all (7 CFR 273.2 does not condition filing on one; build_finalize_address in services/canopy-portal/src/pages/apply.rs sends null when every address field is blank). The rule binds an address that is given: a residential address always has a county.
U1: every writer sends a county
No reader refuses yet, so this unit changes no stored result.
-
Contracts:
FinalizeAddressgains a requiredcounty_fips: String. -
canopy-applications: loads
JurisdictionCountiesat boot (refusing to start when it does not load) and carries it to the finalize handler beside the pack lists it already holds.address_factpasses the county through; the finalize pre-check (check_fact_shapecall site inapi/mod.rs) runsresidential_countyandadmits, so a bad county is 422 before any canopy-persons write:county_required,county_state_unknown,county_not_in_state,county_not_served. -
canopy-portal: loads
JurisdictionCountiesand[jurisdiction].admin_unit_labelat server boot (jurisdiction.rsload_strings). The apply wizard’s address step gains a "County" select, labelled byadmin_unit_label, after State. The served list and the label reach the client as two new shell attributes,data-canopy-countiesanddata-canopy-admin-unit-label, as the document types do (jurisdiction.rs,csp.rs).build_finalize_addresskeeps its all-blank skip, with the county among the fields it reads: all blank sendsnull; a partly filled address, a missing county included, is the existing "finish your address" error; a complete one sendscounty_fips. When the State typed is another State, the client fetches that State’s list from a new portal server route,GET /reference/counties/{state}(public, static reference data, 404 for an unknown code). A saved draft without a county resumes with the field empty. -
canopy-web: loads
JurisdictionCountiesat boot and hands it to the address tab. The address forms replace the free-text box with a select of the jurisdiction’s served counties plus an "Another State" choice that reveals a five-digit code box.parse_address_valuerefuses a residential address with no county inline, before any upstream call. -
canopy-cli:
addresshelp says--county-fipsis required for a residential address; the CLI stays a thin sender and canopy-persons refuses. -
In-tree senders. The rule for U1: every site that sends a residential address claim to canopy-persons, or a finalize address, names a real county of the address’s State; a mailing or substitute sender is left alone; a site that only builds a read-shape
Addressfor a consumer’s test is left alone. Found by searchingmainforcounty_fips: None,"county_fips": nulland every caller of the claim route; the implementer re-runs both searches, since the list is a snapshot:-
Residential claim senders to change:
crates/canopy-test-lib/src/residence.rs(two sites); canopy-renewalssrc/pr_pipeline.rs(test seeder); canopy-personstests/(persons_test,finalize_control_test,finalize_receipt_test,fact_version_writes_test,fact_version_reads_test,batch_expansion_test,fact_event_emission_test) andsrc/store/dek_stamp_infra_tests.rs; canopy-noticestests/notices_test.rs(the two residential sites);tools/canopy-clirequest-body and path tests andtests/cli_test.rs;tests/e2e/lib/given/snap.tsandtests/e2e/lib/helpers.ts;services/canopy-applications/tests/common/mod.rsand every finalize body in that crate’s tests. -
persons_test.rshas a helper taking the address type as a parameter: it sends a county when the type is residential. Its insta snapshot is updated by hand. -
Mailing senders, unchanged: canopy-applications' five
*_http_test.rsfiles, canopy-appealscontested_union_test.rs,tests/e2e/lib/given/persons.ts, canopy-notices' mailing sites. -
Read-shape builders, unchanged: canopy-eligibility
orchestrator.rstests, canopy-web case-detail tests, canopy-noticesrecipient.rs,subscriber.rsandworker.rs, the contracts crates' own tests.
-
-
canopy-seed: its three address sites write
fips_state_code + "001"; they take the first served unit ofload_jurisdiction_countiesinstead, so the code is a real unit in every pack.
U2: canopy-persons refuses, and the database holds it
-
claim_address(services/canopy-persons/src/api/mod.rs): after the shape validation, a claim whosevalue.address_typeisresidentialmust passresidential_countyandadmits. Refusals are 422 with the four codes above, each naming the fieldcounty_fipsand not the value. A correction (fact_idpresent) is held to the same rule, and so is a finalize-tagged claim (a_finalize_tagged_claim_without_a_county_is_refused). -
canopy-persons loads
JurisdictionCountiesat boot and refuses to start when it does not load. -
Migration: a CHECK named
address_versions_residential_county, added validated: the address type is notresidential, orcounty_fipsis five digits. The database cannot hold the county table, so it checks presence and shape; the handler checks membership. -
Address.county_fipson the read shape stays optional (a mailing address has none).
U2 is stacked on U1 and closes #3376.
Config repositories
No pack changes. fips_county_codes gains its first reader: an entry naming no unit of the State now refuses boot. Georgia’s is empty; the agents are told on merge.
Tests
| Category | Tests |
|---|---|
Unit (canopy-reference) |
|
Unit (canopy-common) |
|
Contract (wire) |
|
canopy-applications |
|
canopy-persons (postgres) |
|
Boot |
|
canopy-web |
Form parse cases; routed: a residential form with no county is refused with no upstream call; the select lists the served counties; the "Another State" code reaches the typed body. |
canopy-portal |
The county and label attributes are stamped and decoded; |
canopy-seed |
Every seeded residential address carries a served unit’s code. |
Regression |
|
Not run locally (the car’s): persons_test, the canopy-applications finalize stack tests, the e2e apply and address journeys.
Risks
| Risk | Mode | Mitigation |
|---|---|---|
A sender still writes a residential address with no county after U2. |
fail-closed |
canopy-persons answers 422 and the CHECK refuses the row; U1 changes every in-tree sender first, and the car’s stack tests exercise them. |
A database with county-less residential rows meets the migration. |
fail-closed |
The migration fails and the service does not start; the changelog says to re-seed (decision 4). |
A deployment that narrows |
fail-closed |
That is decision 2; the refusal is coded |
An applicant picks the wrong county. |
silent |
A worker corrects it on the address form; the county is shown beside the address on the case. |
The portal’s other-State fetch fails. |
fail-closed |
The select stays empty and the step does not advance; the applicant can retry. |
canopy-reference’s table is out of date for a State. |
fail-closed |
A real county is refused until the table is corrected; the table is Census data in source, fixed by a release. |
Scope
| Unit | Work | Status |
|---|---|---|
U1 |
The rule function and the loader; every writer sends a county: finalize contract and pre-check, portal select and route, worker form, CLI help, test and e2e senders, seed. |
Done (2026-11-23) |
U2 |
canopy-persons refusal and boot load, the CHECK migration; closes #3376. |
Done (2026-11-23) |
Out of scope: #3331’s ABAWD waiver areas, which this unblocks.
Delivery
-
Doc pages:
api/canopy-persons.adoc,data-models/canopy-persons.adoc,api/canopy-applications.adoc,api/canopy-web.adoc,services.adoc,rulesets.adoc(fips_county_codesnow read),authorization-inventory.adocif the portal route is listed there. -
CHANGELOG.adoc== Unreleased: one entry per unit; U2’s states the re-seed. -
This plan page with its nav entry, merged before U1.
-
The close: U2’s MR closes #3376; the merge SHAs are noted on it and #3331 is told it is unblocked.
Errata
-
Erratum (2026-11-23): the loader lives in canopy-reference beside the rule (
residence_county::JurisdictionCounties::load), not in canopy-common, so the table, the rule and the pack read are one module; its tests are there too. -
Erratum (2026-11-23): the rule is
JurisdictionCounties::check(state, county_fips), over the free functionresidence_county::residential_county;admitstakes the unit alone. -
Erratum (2026-11-23): the applicant portal and canopy-web refuse to boot on a pack with no
[jurisdiction].admin_unit_label, since both label the choice with it. -
Erratum (2026-11-23): the portal's wizard gates no step, so an address without a county is refused at submit by
build_finalize_address, as any partly filled address is, not at step 1. -
Erratum (2026-11-23): a service's
mainis not unit-tested; the boot refusal is pinned at the loader (a_served_county_naming_no_unit_refuses_to_load,the_loader_reads_the_packs_jurisdiction_table) and, for canopy-web, bya_pack_listing_an_unknown_county_refuses_the_load_by_name. -
Erratum (2026-11-23): the CHECK tests
county_fips IS NOT NULLbeside the five-digit pattern, since a CHECK passes on NULL and the pattern alone admitted a county-less row. -
Erratum (2026-11-23): canopy-persons' refusals are one table-driven test,
a_residential_claim_without_a_usable_county_is_refused_naming_the_field, with a case for each name the plan listed;a_mailing_row_without_a_county_is_storedis the last assertion ofa_residential_row_without_a_county_violates_the_check. -
Erratum (2026-11-23): the worker form's other-State choice is the select's empty option beside an always-shown code box, with no script.