canopy-persons Data Model

For a contributor or privacy reviewer reading the persons schema: the tables below are the schema in effect after the migrations listed at the end, applied in order — the legacy household_members, addresses, income, assets and expenses tables no longer exist. Endpoint detail (the …/claims write surface, the as-of reads, the redact routes) is on the canopy-persons API page; the design is ADR-027 (valid-time facts) and ADR-036 (sealing). The shared event_outbox / event_inbox pair is described once on the data-models index. Source: migrations/.

Tables

Table Purpose

persons

One row per natural person. Plaintext demographics: first_name, middle_name, last_name, suffix, gender, race TEXT[], ethnicity, citizenship_status, language_preference (default 'en'), disability_status (nullable; the canopy_reference::DisabilityStatus vocabulary none / disabled / disabled_veteran / ssi_recipient), medicare_part_a_basis (nullable; canopy_reference::MedicarePartABasis: none / premium_free / premium_1818_aged / premium_1818a_working_disabled). Sealed PII: ssn_encrypted JSONB and date_of_birth_sealed JSONB NOT NULL each hold an ADR-036 SealedValue under its own per-person DEK (redaction_keys subject kinds ssn / date_of_birth, subject id = the person id), so the SSN can be shredded independently of the date of birth; no plaintext SSN or DOB column exists. A create binds created_at and updated_at, and an update binds updated_at, from one instant per write that also stamps every DEK the write mints; a soft delete binds updated_at from its caller’s instant (#2582), and a finalize compensation’s deactivation from its request’s instant (#2587). Every persons stamp therefore comes from the application clock, and the columns have no default since #2587, so an insert naming no stamp fails rather than mixing in the database clock. Soft-delete via active.

households

Household identity: name (optional caseworker label), effective_date / end_date, active. Membership is not on this table — see household_member_versions. Every stamp comes from the application clock, the one canopy-persons stamps its persons rows and versions with (#2582): a create binds created_at and updated_at from one instant, and a finalize compensation’s deactivation binds updated_at from its request’s instant. The columns have no default since #2587, so an insert naming no stamp fails rather than mixing in the database clock.

income_versions

Valid-time, append-only version corpus for income facts. Every version row carries version_id (PK), fact_id (the stable handle, ADR-025), person_id (FK → persons), the half-open window [valid_from, valid_to) (_valid_range CHECK (valid_to IS NULL OR valid_to > valid_from)), transaction time recorded_at / superseded_at (NULL = the current record-version; both bound by the store from the application clock — a correction’s recorded_at, or a finalize compensation’s instant, #2587), the attribution set author_type, author_id, claim_source, claim_status, origin, and proposed_value_sealed JSONB (the ADR-027 provenance blob, sealed under the same per-fact DEK since 20261209000000). Value columns: income_type, frequency (plaintext discriminators), amount JSONB NOT NULL and employer_name JSONB (sealed). income_versions_no_overlap EXCLUDE USING gist (fact_id WITH =, daterange(valid_from, valid_to, '[)') WITH &&) WHERE (superseded_at IS NULL AND claim_status LIKE 'accepted%') — no two current accepted versions of one fact overlap. The former amount >= 0 CHECK was dropped when the column was sealed (20260625130000). A held IEVS accept (#2546, ADR-027 Amendment 6) is a proposed row with claim_source = 'ievs', a worker author and origin = 'ievs:{discrepancy_id}': outside the EXCLUDE and every determination read, it is *pending while superseded_at IS NULL, and canopy-snap’s resolution consumes it by stamping superseded_at, promoting the linked one by appending an accepted version beside it.

asset_versions

Same shape as income_versions; value columns asset_type (plaintext; a canopy-reference AssetType token, held by the asset_versions_asset_type_vocabulary CHECK, #3335), value JSONB NOT NULL and description JSONB (sealed); asset_versions_valid_range, asset_versions_no_overlap.

expense_versions

Same shape; value columns expense_type, frequency (plaintext) and amount JSONB NOT NULL (sealed); expense_versions_valid_range, expense_versions_no_overlap.

address_versions

Same shape; value columns address_type (the native enum address_type ∈ {residential, mailing, substitute}, 20260630120000 and 20270326000000; substitute is the address an address-confidentiality program assigned the person, which canopy-notices mails to under a per-participant program and the FOIA export leaves out, #3439), city, state, zip, county_fips (plaintext), line_1 JSONB NOT NULL and line_2 JSONB (sealed); address_versions_valid_range, address_versions_no_overlap (per fact_id), and address_versions_residential_county (#3376): a residential row carries a five-digit county_fips; the route holds the code to the address's State and the served list. Attributed address events carry only the coarse plaintext columns — the street lives only here (ADR-004 / ADR-027).

household_member_versions

Same shape plus household_id (FK → households); value column relationship (plaintext). The sole membership store. Non-overlap is per (household_id, person_id): household_member_versions_no_overlap EXCLUDE USING gist (household_id WITH =, person_id WITH =, daterange(valid_from, valid_to, '[)') WITH &&) WHERE (superseded_at IS NULL AND claim_status LIKE 'accepted%') — a person is never seated twice in one household at once, but may be in two different households. It has no sealed value column; its per-fact DEK (household_member_version) is minted only when a provenance blob is written.

household_homelessness_versions

Household homelessness periods (#3144): version_id, fact_id, household_id (FK → households), the window [valid_from, valid_to) (household_homelessness_versions_valid_range as the siblings), recorded_at / superseded_at and the attribution set, and no value column: a version is the period itself. With no value there is no proposed value to keep, so the table has no proposed_value_sealed and no DEK subject. Non-overlap is per household: household_homelessness_versions_no_overlap EXCLUDE USING gist (household_id WITH =, daterange(valid_from, valid_to, '[)') WITH &&) WHERE (superseded_at IS NULL AND claim_status LIKE 'accepted%'), immediate, so a household holds one accepted period on any day; the store takes the household’s advisory lock before the fact’s, so two racing writes are refused rather than deadlocked. recorded_at has no default: the store binds it.

parent_child_versions

Parent–child facts (#3047): the same provenance shape (proposed_value_sealed from the start), with parent_person_id and child_person_id (both FK → persons) in place of person_id, and value column kind TEXT CHECK (kind IN ('natural','adoptive','step')). parent_child_versions_not_self CHECKs parent_person_id <> child_person_id; parent_child_versions_valid_range as the siblings. Non-overlap is per pair: parent_child_versions_no_overlap EXCLUDE USING gist (parent_person_id WITH =, child_person_id WITH =, daterange(valid_from, valid_to, '[)') WITH &&) WHERE (superseded_at IS NULL AND claim_status LIKE 'accepted%'), immediate, so one pair holds one kind at a time. recorded_at has no default: the store binds it. No sealed value column; its per-fact DEK (parent_child_version) is minted only when a provenance blob is written.

pregnancy_versions

Pregnancy facts (#3143): the address_versions provenance shape (proposed_value_sealed from the start) keyed by person_id (FK → persons); valid_from is the first day the pregnancy is in effect and valid_to the day it ended, NULL while it continues. One value column, value JSONB NOT NULL, seals the whole PregnancyFactValue (expected delivery date, fetus count, waiver of the WIC family-size increase) as one SealedValue under the fact DEK (pregnancy_version), so no part of it is plaintext and no CHECK reads it; the store refuses a fetus count outside 1 to 8 before it seals. pregnancy_versions_valid_range as the siblings. Non-overlap is per person: pregnancy_versions_no_overlap EXCLUDE USING gist (person_id WITH =, daterange(valid_from, valid_to, '[)') WITH &&) WHERE (superseded_at IS NULL AND claim_status LIKE 'accepted%'), immediate, so a person has one pregnancy at a time. recorded_at has no default: the store binds it. The pregnancy events carry no value at all (ADR-004 / ADR-027).

redaction_keys

The ADR-036 DEK store: dek_id (PK), wrapped_dek BYTEA (the DEK wrapped under the service KEK, AAD-bound; a 32-byte zero sentinel after shred), kek_version SMALLINT (which KEK wrapped it, so a KEK rotation re-wraps without touching ciphertext), subject_kind (income_version / asset_version / expense_version / address_version / household_member_version / parent_child_version / pregnancy_version / ssn / date_of_birth), subject_id, created_at (bound by ensure_fact_dek from its caller: a fact version’s recorded_at, or the persons write’s instant; no default since #2582), shredded_at (NULL = live; the redaction’s instant when set). Trigger canopy_redaction_keys_one_way_guard allows INSERT and exactly two live-row UPDATEs — the tombstone (wrapped_dek + shredded_at only) and the KEK rewrap (wrapped_dek replaced + kek_version strictly increased, 20261224000000, #2113); DELETE, TRUNCATE, un-tombstoning, any update of a tombstoned row and identity changes are rejected. uq_redaction_keys_live_subject (20261208000008) keeps at most one live DEK per subject. A tombstoned DEK makes every sealed value under it unrecoverable — the read surfaces redacted (or provenance_redacted for membership rows).

finalize_operation_generations

Generation gate of the applicant-finalize saga (ADR-038): PK (operation_id, generation), state TEXT CHECK (state IN ('active','cancelled')), created_at. A finalize-tagged write checks its row FOR SHARE before writing; an absent or cancelled generation refuses the write.

finalize_receipts

Transactional idempotency receipt of the same saga: PK (operation_id, generation, step_key), FK (operation_id, generation) → finalize_operation_generations, entity_kind, stable_id (the correction-surviving id — a person_id, household_id or fact_id, never a version_id), created_at. A replayed step conflicts on the PK and the handler returns the stored stable_id.

event_outbox / event_inbox

The shared MQ pair; columns, indexes, parking and retention are on the data-models index.

Extensions the migrations install: btree_gist (the UUID-equality half of the EXCLUDE constraints) and pg_trgm (the name search indexes).

Relationships

Diagram

redaction_keys is joined by convention (subject_kind, subject_id), not by a FOREIGN KEY, so a tombstone outlives the row it protected.

Cross-service identifiers (ADR-001 boundary)

canopy-persons sits at the bottom of the dependency graph: every program service holds application-level references into it (person_id, household_id) and it holds none out. Every REFERENCES in this schema is intra-database (the person_id / household_id FKs above, pregnancy_versions.person_id among them, the two parent_child_versions person FKs, and the finalize pair); callers pass ids over HTTP and canopy-persons resolves them.

Retention

canopy-persons holds PII (names, sealed DOB and SSN, sealed street addresses) and, since #3143, health information: pregnancy facts, whose expected delivery date, fetus count and waiver of the WIC family-size increase are sealed under each fact’s DEK (ADR-036) and shredded through the pregnancy kind of the fact redaction route. It holds no FTI. Retention is operator-driven and indefinite by default. Removal of PII is crypto-shred, not deletion: the SSN, the DOB, each fact’s value and its provenance blob sit under per-subject DEKs in redaction_keys, and the redact routes on the API page tombstone the DEK in one transaction with the audit event — the ciphertext stays where it is and is permanently unreadable (ADR-036). kek_version records which KEK wrapped each DEK, so a KEK rotation is a re-wrap of wrapped_dek, never a re-encryption of the sealed values. Soft-deletion (active = false) keeps rows for audit and late-arriving cross-program references.

Indexes

  • idx_persons_name — (last_name, first_name); idx_persons_active — partial WHERE active = true

  • idx_persons_first_name_trgm, idx_persons_last_name_trgm — GIN gin_trgm_ops, partial WHERE active = true (#1209): index-driven infix ILIKE name search

  • idx_income_versions_fact, idx_asset_versions_fact, idx_expense_versions_fact, idx_address_versions_fact, idx_household_member_versions_fact — (fact_id)

  • idx_income_versions_person_current, idx_asset_versions_person_current, idx_expense_versions_person_current, idx_address_versions_person_current, idx_household_member_versions_person_current — (person_id) WHERE superseded_at IS NULL, the as-of read hot path

  • idx_household_member_versions_household_current — (household_id) WHERE superseded_at IS NULL, the as-of household read

  • idx_household_homelessness_versions_fact — (fact_id); idx_household_homelessness_versions_household_current — (household_id) WHERE superseded_at IS NULL, the household’s homelessness read (#3144)

  • idx_parent_child_versions_fact — (fact_id); idx_parent_child_versions_parent_current and idx_parent_child_versions_child_current — (parent_person_id) and (child_person_id) WHERE superseded_at IS NULL, one per end of the as-of bulk read (#3047)

  • idx_pregnancy_versions_fact — (fact_id); idx_pregnancy_versions_person_current — (person_id) WHERE superseded_at IS NULL, the as-of read (#3143)

  • income_versions_pending_proposals_idx — (person_id, origin) WHERE claim_status = 'proposed' AND superseded_at IS NULL, the pending held-accept lookups (#2546)

  • the seven *_no_overlap EXCLUDE constraints — GiST, one per version table

  • every *_no_overlap EXCLUDE constraint — GiST, one per version table

  • idx_redaction_keys_subject — (subject_kind, subject_id); uq_redaction_keys_live_subject — unique (subject_kind, subject_id) WHERE shredded_at IS NULL

  • event_outbox_*, event_inbox_unprocessed_idx, idx_event_inbox_parked — the generated partial indexes, described on the data-models index

Migration files

  • 20260326000000_create_persons_tables.sql — persons, households, and the legacy household_members, addresses, income, assets, expenses (all five since dropped)

  • 20260402000000_add_constraints.sql — non-negative CHECKs and a unique active-membership index on the legacy tables (gone with them)

  • 20260406000000_add_disability_status.sql — persons.disability_status

  • 20260508000000_create_event_outbox.sql — generated (index page)

  • 20260516000000_create_event_inbox.sql — generated (index page)

  • 20260518004851_event_outbox_lease_columns.sql — generated (index page)

  • 20260604000000_create_fact_version_tables.sql — btree_gist; income_versions, asset_versions, expense_versions with their EXCLUDE constraints and indexes; the one-time backfill_fact_versions_v1() (#671)

  • 20260618000000_drop_legacy_fact_tables.sql — drops income, assets, expenses and the backfill function (#672)

  • 20260623000000_create_address_versions.sql — address_versions + backfill_address_versions_v1() (#683)

  • 20260624000000_create_household_member_versions.sql — household_member_versions + backfill_household_member_versions_v1() (#683)

  • 20260625000000_drop_legacy_address_household_member_tables.sql — drops addresses, household_members and both backfill functions (#890)

  • 20260625120000_create_redaction_keys.sql — redaction_keys and its one-way guard triggers (ADR-036)

  • 20260625130000_seal_fact_value_columns.sql — amount, employer_name, value, description, line_1, line_2 re-created as sealed JSONB; the numeric CHECKs dropped

  • 20260625140000_seal_persons_pii.sql — ssn_encrypted re-created as sealed JSONB; date_of_birth replaced by date_of_birth_sealed JSONB NOT NULL

  • 20260630120000_address_type_enum.sql — the address_type enum; address_versions.address_type converted (#892)

  • 20260713000000_event_outbox_hold.sql — generated (index page)

  • 20260714000000_create_finalize_operation_generations.sql — ADR-038 generation gate (#1047)

  • 20260714000001_create_finalize_receipts.sql — ADR-038 receipts (#1047)

  • 20260720000000_event_inbox_parking.sql — generated (index page)

  • 20260803000000_event_outbox_v7_pk_default.sql — generated (index page)

  • 20260815000000_event_outbox_claim_order_idx.sql — generated (index page)

  • 20260819000000_persons_name_trgm_gin.sql — pg_trgm; the two trigram indexes (#1209)

  • 20260904000000_event_outbox_parking.sql — generated (index page)

  • 20261208000008_redaction_keys_live_subject_uq.sql — tombstones superseded live DEKs, then uq_redaction_keys_live_subject (#1606)

  • 20261208000009_add_medicare_part_a_basis.sql — persons.medicare_part_a_basis (#1514)

  • 20261209000000_seal_proposed_value.sql — proposed_value replaced by proposed_value_sealed JSONB on all five version tables (#1615)

  • 20261224000000_redaction_keys_rewrap_guard.sql — canopy_redaction_keys_one_way_guard() admits the KEK rewrap (wrapped_dek replaced + kek_version strictly increased on a live row) beside the shred (#2113)

  • 20270117000000_redaction_keys_created_at_no_default.sql — drops the redaction_keys.created_at default: ensure_fact_dek binds created_at from its caller (the instant its write stamps the sealed row with), so an insert that names no created_at now fails instead of taking the database clock (#2582)

  • 20270117000001_households_stamps_no_default.sql — drops the households.created_at / updated_at defaults: the store binds both on create and a finalize compensation binds updated_at on deactivation, all from the application clock, so an insert that names no stamp now fails instead of taking the database clock (#2587)

  • 20270117000002_persons_stamps_no_default.sql — drops the persons.created_at / updated_at defaults: the store binds both on create and updated_at on update, soft delete and compensation, all from the application clock, so an insert that names no stamp now fails instead of taking the database clock (#2587)

  • 20270123000000_income_pending_proposals_index.sql — income_versions_pending_proposals_idx, the partial index over pending held IEVS accepts (#2546)

  • 20270217000000_create_parent_child_versions.sql — parent_child_versions, its CHECKs, its pair EXCLUDE and its three indexes (#3047)

  • 20270303000000_create_pregnancy_versions.sql — pregnancy_versions, its range CHECK, its per-person EXCLUDE and its two indexes (#3143)

  • 20270304000000_create_household_homelessness_versions.sql — household_homelessness_versions, its window CHECK, its household EXCLUDE and its two indexes (#3144)

  • 20270326000000_address_type_substitute.sql — the substitute value of the address_type enum (#3439)

  • 20270403000000_address_versions_residential_county.sql — the CHECK address_versions_residential_county, added validated; a database holding a residential row with no county fails it and is re-seeded (#3376)

The eight generated files are byte-identical copies of crates/canopy-mq/outbox-migrations/ (the data-models index). All migrations are forward-only per ADR-016.

NOTE
The header comment of 20261209000000_seal_proposed_value.sql says "ADR-004 §2025(e) keeps the raw IEVS figure snap-local". The statute half of that cite is superseded: 7 USC §2025(e) is the SSN section, and the restriction that keeps an IEVS-received figure to the program that received it is Social Security Act §1137, 42 USC §1320b-7(a)(5) — ADR-004 Amendment 6 (#2129). What the header describes is unchanged: ADR-004 sites the IEVS class in canopy-snap, so canopy-persons carries source = ievs provenance and never the figure (the ievs_accept_writes_verified_version_with_ievs_source_and_no_figure integration test). An applied migration is immutable, so the header text stands as written.
Edit this page · default