canopy-renewals Data Model
Cross-link: canopy-renewals API Reference · Source: migrations/
Tables
| Table | Purpose |
|---|---|
|
One row per SNAP certification period. |
|
The order-safe certification mirror of the enrolled-household continuation primitive: ONE row per ACCEPTED |
|
ONE row per renewal application ( |
|
Mid-certification change report ledger. One row per change reported by the household (or system-detected). Carries |
|
One row per mid-certification reported fact change that the materiality subscriber re-scored. When a worker authors an income/asset/expense/member fact during an active SNAP certification, canopy-renewals runs a non-persisting materiality dry-run (canopy-eligibility) against the determination-of-record’s frozen policy + pinned corpus and records the verdict diff here: |
|
One row per periodic-report CYCLE on a certification (PAMMS 3730, eff. June 2026; 7 CFR 273.12(a)(5)(iii)). A jurisdiction whose category rows are all change reporting, or never longer than six months, runs no periodic report and writes no row here (#3298); |
|
The veto/cancel re-determination worker queue: one row per DEAD periodic-report adverse action ( |
|
The generated ADR-018 / ADR-039 outbox and the generated consumer inbox (parked-state columns included), single-sourced in |
|
The fleet-wide idempotent-POST cache (#434 / #1463), created outside this service’s |
|
Wall-clock window fence for the service’s daily scheduler tick(s) ( |
|
The caseload-depth rollup — sole feed of |
|
Immutable federal-universe snapshot generation header (ADR-002 Amendment 1 — the #1213 bulk-cohort source): |
|
The frozen member rows, keyed |
Relationships
Intra-database foreign keys only (relationship-only; columns live in the Tables list):
snap_caseload_daily (keyed by rollup_date) and scheduler_runs reference no other table.
Cross-service FKs (ADR-001 boundary)
Per ADR-001, canopy-renewals holds no Postgres-level foreign keys to other services. Every UUID outside the intra-database FKs above is an application-level reference canopy-renewals trusts the upstream services (the canopy-eligibility orchestrator, canopy-snap, canopy-applications, canopy-persons, canopy-enrollment and canopy-notices) to supply and never enforces in canopy_renewals: household and person ids (canopy-persons), application_id / renewal_application_id / redetermination_application_id (canopy-applications), determination_id / renewal_determination_id / certifying_determination_id / previous_determination_id / continued_by_determination_id / baseline_determination_id / screen_determination_id (canopy-snap or canopy-eligibility), adverse_action_id (canopy-enrollment), notice_id (canopy-notices) and the source_event_id / noe_source_event_id envelope ids. The actor columns (processed_by, the two action_by pairs) are not UUIDs since #1008: they hold opaque OIDC subjects and service principals, never a reference into another service’s rows.
Retention
Retention floors (eCFR, checked 2026-09-16): certification periods are governed substantively by 7 CFR 273.14 (recertification) and 7 CFR 273.12 (reporting), and as records by 7 CFR 272.1(f) — no less than 3 years from the month of origin of each record; snap_certifications rows are kept for that window past certification_end_date and every child row (change reports, nudges, periodic-report cycles, adjustments) inherits it. State series: Georgia Archives, DHS retention schedule (agency 144), series 1976-0110 "Food Stamp Administrative Files", 3 years — https://www.georgiaarchives.org/records/agencyprint/144 (checked 2026-09-18); it does not exceed the federal 3-year floor, so 7 CFR 272.1(f) governs. Rows are not deleted in production except the two universe-snapshot tables, which the reaper prunes after CANOPY_RENEWALS__UNIVERSE_SNAPSHOT_RETENTION_DAYS, and snap_caseload_daily, which is recomputed over its serving window; archive moves are operator-driven, never migration-driven (ADR-016).
Indexes
-
idx_snap_certs_household— household-scoped cert lookup -
idx_snap_certs_status— list-by-status (recertification queue, expired sweep) -
snap_certs_one_active_per_household(partial UNIQUE,WHERE status IN ('active','recertifying') AND active = true— widened fromstatus = 'active'by #1728, rebuilt same-name in migration20261225000000) — at most one IN-FORCE certification per household (#973); a secondactiverow beside arecertifyingone is the pre-#973 bug -
idx_snap_certs_end_date— renewal-notice scheduler scan -
idx_snap_certs_end_date_id(compound,(certification_end_date ASC, id ASC)) — theGET /v1/renewals/snap/duekeyset order + cursor (#1204); supplies the(end_date, id)total order the single-columnidx_snap_certs_end_datecould not, removing the top-N Sort -
idx_snap_certs_interim_due(partial,WHERE interim_contact_due_date IS NOT NULL) — interim-contact queue -
idx_snap_certs_renewal_due_unnotified(partial,(certification_end_date ASC, id ASC) WHERE renewal_notice_sent_date IS NULL, #1198) — the scheduler’s fenced renewal-due drain; excludes fenced rows so each daily range-scan reads only the still-unfenced (newly-due) certs in the window (bounds the per-tick scan, not the index size — the index still covers every not-yet-fenced active cert) -
idx_snap_certs_expiration_notice_unnotified(partial,(certification_end_date ASC, id ASC) WHERE expiration_notice_sent_date IS NULL AND status IN ('active','recertifying') AND active = true, #792; the predicate widened to the in-force class by #1728 — arecertifyingcert still owes its NOE, 273.14(b)(1) is unconditional — rebuilt same-name in20261225000000) — the scheduler’s keyset NOE drain; the window is expressed sargably oncertification_end_date(all month arithmetic runs on thetodayparameter, never on the column), so the drain range-scans a bounded slice of the index: since #1629 that slice istoday .. first-of-next-next-month— the OPENING bound is still the 273.14(b)(1) month anchor, but the closing bound was replaced by "in force today", so a row the drain missed inside its window is still lettered (late) until the period lapses. The over-2-month guard (and, since #1661, thecertification_type <> 'expedited'belt) is applied as a residual filter -
snap_certs_one_per_determination(partial UNIQUE,(determination_id) WHERE active = true, #1661) — one certification per determination: the race belt behind the create path’s SELECT-guard (HTTP →409 certification_exists_for_determination; the inbox arm → nack → the redelivery’s SELECT-guard). Partial onactive(the soft-delete flag), not total:determination_idis NOT NULL and a total unique could not be fixed forward without deleting rows (ADR-016) -
uq_snap_certs_noe_source_event(partial UNIQUE,(noe_source_event_id) WHERE noe_source_event_id IS NOT NULL, #1661) — thenotice.dispatchedconsumer’s O(1) correlation lookup -
idx_snap_certs_interim_due_unnotified(partial,(interim_contact_due_date ASC, id ASC) WHERE interim_contact_due_date IS NOT NULL AND interim_contact_completed_at IS NULL AND interim_contact_notice_sent_date IS NULL, #1198) — the scheduler’s fenced interim-contact drain -
idx_snap_certs_continued_by(partial,(continued_by_determination_id) WHERE continued_by_determination_id IS NOT NULL, #1658) — the read-model lookup of the latest continuing determination (NOT the create-path guard) -
idx_snap_certs_renewal_application(partial,(renewal_application_id) WHERE renewal_application_id IS NOT NULL, #1728) — the renewal link lookup (WHERE renewal_application_id = $1): the filing consumer’s projection target and the reinstatement arm (#1730) locate the certification by its renewal application (no index existed on the column before) -
snap_cert_adj_one_per_determination_via(UNIQUE,(determination_id, applied_via), #1658) — continuation replay belt 1: one adjustment per (determination, half) -
snap_cert_adj_one_per_source_event(UNIQUE,(source_event_id), #1658) — continuation replay belt 2: one adjustment per envelope -
uq_snap_cert_adj_prior_noe_source_event(partial UNIQUE,(prior_noe_source_event_id) WHERE prior_noe_source_event_id IS NOT NULL, #1658) — the latenotice.dispatchedfallthrough’s O(1) lookup of a cleared NOE id -
idx_snap_cert_adj_cert_applied((certification_id, applied_at), #1658) — the per-certification adjustment history -
idx_snap_cert_adj_pending(partial,(household_id, certifying_determination_id) WHERE outcome = 'pending_certification', #1658) — the create path’s reconciliation scan -
idx_snap_pr_household— household-scoped cycle list (#1106) -
idx_snap_pr_due_initial(partial,WHERE status = 'scheduled') — the 15th-of-prior-month notice predicate (#1106) -
idx_snap_pr_due_combined(partial,WHERE status IN ('scheduled','notice_sent','form_incomplete')) — the 5th-of-due-month combined-notice predicate (#1106) -
idx_snap_pr_open(partial,WHERE status NOT IN ('processed','terminated','cancelled')) — the month-end closure / lapsed-VCL predicate (#1106) -
idx_snap_change_reports_cert— certification-scoped change list -
idx_snap_change_reports_household— household-scoped change list -
idx_snap_change_reports_screen_degraded(partial,(created_at) WHERE screen_status IN ('dry_run_unprocessable','eligibility_unavailable'), #1619) — the worker queue of reports whose 130%-FPL screen could not run -
idx_snap_change_reports_type— change-type analytics / reporting -
idx_snap_change_reports_program— #448 program-scoped routing -
idx_snap_change_reports_household_program— #448 composite for(household_id, program)worker-portal queries -
recert_nudges_household_idx— household-scoped nudge list;recert_nudges_pending_idx(partial,(certification_id) WHERE is_material = true AND action_taken IS NULL) — the worker’s pending queue (#680); the table also carriesUNIQUE (certification_id, source_event_id) -
pr_redeterminations_household_idx— household-scoped queue list;pr_redeterminations_pending_idx(partial,(certification_id) WHERE action_taken IS NULL) — the undecided queue (#1107); the table also carriesUNIQUE (adverse_action_id) -
idx_snap_universe_snapshots_created_at— the reaper’s age scan (#1470);snap_universe_snapshot_rowsis read through its(snapshot_id, seq)PK -
generated
event_outbox_*/event_inbox_*indexes — described once in the data-models index
Migration files
The eight event_outbox / event_inbox files (20260508000000, 20260516000000, 20260518004851, 20260713000000, 20260720000000, 20260803000000, 20260815000000, 20260904000000) are generated copies of crates/canopy-mq/outbox-migrations/ (cargo xtask outbox-migrations --write, parity-gated by --check); they are described once in the data-models index. The remaining files, in timestamp order:
-
20260401000000_create_renewals_tables.sql— original schema (snap_certifications, snap_change_reports; type / status / reporting / method CHECK constraints; cert + change indexes) -
20260512000000_add_program_to_renewals.sql— #448 multi-program support; addsprogramcolumn with DEFAULT'snap', relaxescertification_idto nullable, adds program-scoped indexes -
20260608000000_add_certification_terminated_at.sql— addsterminated_at TIMESTAMPTZ NULLtosnap_certificationsso the caseload-depth trend (#702) reconstructs "active as of past W" losslessly across early terminations (safe additive, no backfill) -
20260626000000_create_recert_nudges.sql— #680 recertification-nudge ledger:recert_nudgestable,UNIQUE (certification_id, source_event_id)idempotency key,triggering_fact_kind/action_takenCHECK constraints, household + pending-action partial indexes -
20260706000000_snap_cert_active_uniqueness.sql— #973 worker cert-create guards: expires pre-existing duplicate active certs (fix-forward), adds thesnap_certs_period_order_chkCHECK (end > start) and thesnap_certs_one_active_per_householdpartial unique index -
20260721000000_periodic_report_cohort_and_state.sql— #1106: addssnap_certifications.periodic_report_requiredwith the marker-delimited cohort backfill (pre-2026-03-02 assignment, > 6-month and < 36-month duration, live rows only — the backfill-parity test re-executes the marked statement against the Rust predicate) and createssnap_periodic_reportswith the status/form/VCL-window/calendar-order CHECKs, the per-due-month + per-generation unique keys, and the three predicate partial indexes -
20260722000000_pr_action_pipeline.sql— #1107:snap_periodic_reports.adverse_action_id(the 5th-of-month trigger’s minted action, cross-service id) + thepr_redeterminationsworker queue (trigger/action CHECKs, per-dead-action unique, household + pending partial indexes) -
20260723160000_certification_type_vocabulary.sql— #956: rebuildssnap_certs_type_check(DROP + ADD) with the declared MT-87 vocabularystandard/elderly_disabled/senior/abawd -
20260731000000_pr_reopen.sql— #1108:snap_periodic_reports.reopened_date+sop_due_datewith the paired-travel CHECK (snap_pr_reopen_pair_check) -
20260812000000_vcl_termination_trigger.sql— #1128 (Chart 3730.1 row 2):snap_periodic_reports.vcl_termination_triggered_date— stamped when the lapsed-VCL drain schedules (or adopts) the exempt termination action, so the cycle leaves the closure due set while its status staysvcl_pending -
20260818000000_snap_certs_due_keyset_idx.sql— #1204: adds the compoundidx_snap_certs_end_date_id (certification_end_date ASC, id ASC)backing the keyset-paginatedGET /v1/renewals/snap/due; transactional (NOT CONCURRENTLY — sqlx-migrator advisory-lock deadlock, #1196) -
20260819000000_snap_certs_notice_fences.sql— #1198: adds theinterim_contact_notice_sent_dateemission-fence column plus the two partial drain indexes (idx_snap_certs_renewal_due_unnotified,idx_snap_certs_interim_due_unnotified) so the daily scheduler emits each renewal-due / interim-contact-due event once, not once per tick; transactional (NOT CONCURRENTLY, same #1196 rationale) -
20260905000000_create_scheduler_runs.sql— the generated #1211 window-fence table (single-sourced incrates/canopy-db/scheduler-migrations/); documented once in the data-models index -
20261103000000_snap_caseload_daily.sql— #1218: the caseload-depth rollup table (table only — deliberately NO backfill; the endpoint 503s honestly until the boot-time probe materializes) -
20261116000000_snap_universe_snapshots.sql— #1470: thesnap_universe_snapshotsgeneration header +snap_universe_snapshot_rows(PK(snapshot_id, seq),ON DELETE CASCADE) andidx_snap_universe_snapshots_created_at -
20270107000000_universe_row_type_and_chain_head.sql— #806 U-C:snap_universe_snapshot_rowsgainscertification_type(NOT NULL, CHECK-held; pre-existing generations backfilledstandard, the default then dropped) andcontinued_by_determination_id(nullable) -
20261208000011_snap_certs_expiration_notice_fence.sql— #792: theexpiration_notice_sent_dateNOE emission fence + its partial drain index (the #1198 idiom); transactional (NOT CONCURRENTLY, the #1196 rationale) -
20261221000000_expedited_certification_substrate.sql— #1661: widenssnap_certs_type_checkwithexpedited(DROP+ADD, the 20260723160000 shape); addsdetermined_at; fixes forward duplicate active rows per determination (newest start wins, losers →active = false, marker-delimited) then creates thesnap_certs_one_per_determinationpartial UNIQUE; adds the NOE dispatch-correlation triple (noe_source_event_id+uq_snap_certs_noe_source_event,noe_dispatched_at,noe_dispatched_date) with thesnap_certs_noe_dispatch_after_stage_chkCHECK (dispatch only after staging); transactional (NOT CONCURRENTLY, the #1196 rationale) -
20261224000000_snap_certification_adjustments.sql— #1658: addssnap_certifications.continued_by_determination_id(+ theidx_snap_certs_continued_bypartial index) andcontinuation_watermark; createssnap_certification_adjustmentswith the outcome / applied_via / noe_action / interim_contact_action / new_type vocabulary CHECKs, the pending-row NULL-pairing CHECKs (certification_id,new_type,prior_end,prior_typeNULL iffpending_certification), the fence CHECKs (noe_fence_cleared = (prior_expiration_notice_sent_date IS NOT NULL), prior dispatch-after-stage,new_noe_source_event_idiffstaged_at_adjust) and the belt CHECK (non-applied outcomes never touch a fence), the two replay UNIQUEs, the partial UNIQUE onprior_noe_source_event_id, the(certification_id, applied_at)history index and the pending partial index; transactional (NOT CONCURRENTLY, the #1196 rationale) -
20261225000000_recertifying_in_force.sql— #1728:recertifyingjoins the in-force class — two SEPARATE same-name transactional rewrites (DROP + CREATE under the widenedstatus IN ('active','recertifying') AND active = truepredicate; each keeps its own uniqueness: the one-in-force fencesnap_certs_one_active_per_householdstays UNIQUE, the NOE fenceidx_snap_certs_expiration_notice_unnotifiedstays a plain keyset index) plus the newidx_snap_certs_renewal_application(CREATE INDEX IF NOT EXISTS— the #1196 out-of-band pre-create no-ops it; the two rebuilds cannot be pre-created because IF NOT EXISTS cannot express a predicate change); transactional, neverCONCURRENTLY(the #1196 rationale, carried verbatim in the file); no DDL on the table itself -
20261226000000_change_report_screen_provenance.sql— #1619: the 130%-FPL screen provenance onsnap_change_reports—screen_status(DEFAULTnot_applicable), the derived trioderived_household_size/derived_monthly_income/gross_income_limit, the policy pinscreen_determination_id/screen_corpus_hash/screen_params_digest, the informationalreported_monthly_income/reported_household_size, thesnap_change_reports_screen_status_chkandsnap_change_reports_screen_chkCHECKs, and the degraded-queue partial indexidx_snap_change_reports_screen_degraded -
20261227000000_snap_cert_supersede_reason.sql— #1822: addssnap_certifications.supersede_reasonwith the CHECK-held vocabulary (new_certification\|renewal_reinstatement\|record_back_refused; NULL allowed for pre-#1822 history), plus a column COMMENT. PlainALTER TABLE … ADD COLUMN(no default, no rewrite), transactional. -
20261228000000_snap_cert_senior_conversion.sql— #1800: adds the Senior-SNAP conversion quartet tosnap_certifications(converted_at,converted_on,conversion_reason,converted_by) under thesnap_cert_conversion_all_or_noneCHECK (num_nonnulls(…) IN (0, 4)), plus a COMMENT per column. No enumerated CHECK onconversion_reason— the vocabulary is the jurisdiction’s ruleset, not the schema’s. PlainALTER TABLE … ADD COLUMN(no default, no rewrite, no backfill: a pre-#1800 row was never converted), transactional. -
20261229000000_adjustment_certification_category.sql— #1703:snap_certification_adjustments.certification_category(TEXT, nullable) undersnap_cert_adj_category_vocab_chk(standard/elderly_disabled/senior/abawd; the list is dropped by the #2209 migration below).snap_certificationsgains no column. Plain ADD COLUMN — no default, no rewrite, no backfill (no pre-#1703 production history); transactional, NOT CONCURRENTLY (#1196). -
20270108000000_renewal_decisions.sql— the recorded in-period renewal decision: thesnap_renewal_decisionstable (the decision / type / status CHECKs, the approved-iff-period pair CHECK, the one-scheduled-per-household partial unique, the due index). -
20270111000001_determination_status_check.sql— #628: deletes anyrecert_nudgesrow whosebaseline_statusordry_run_statusis outsideapproved / denied / sanctioned, then addsrecert_nudges_baseline_status_verdictandrecert_nudges_dry_run_status_verdict -
20270113000000_actor_subjects.sql— #1008:recert_nudges.action_by,pr_redeterminations.action_byandsnap_change_reports.processed_byretypeUUID→TEXT(USING …::text, so a stored UUID becomes its text as a subject); the two queue tables gainaction_by_service TEXT. A guard then raises, namingcargo xtask dev restart, on a nudge or redetermination whoseaction_bydoes not match its decision (actioned with no actor, or undecided with one) or is the nil UUID, or on a nilprocessed_by— no actor is invented or dropped. Last, the four pair CHECKs (*_action_by_one_actor,*_action_by_iff_actioned), VALID. -
*_certification_type_vocabulary_pack_owned.sql— #2209: the certification vocabulary is pack data, so no CHECK may pin it. Dropssnap_certs_type_check,snap_cert_adj_new_type_vocab_chk,snap_cert_adj_category_vocab_chk,snap_renewal_decisions_type_checkand the inlinesnap_universe_snapshot_rows_certification_type_check, each replaced byCHECK (length(<col>) BETWEEN 1 AND 64)plus a column COMMENT naming[[snap.certification.categories]]as the authority;ALTER TABLE snap_certifications ALTER COLUMN certification_type DROP DEFAULT(the column stays NOT NULL — a writer must declare the type). Forward-only, no rewrite, no backfill; transactional, NOT CONCURRENTLY (#1196). -
20270213000000_decision_stamps_no_default.sql— #3015: drops the defaults of the two decision stamps every production INSERT now binds from its decision-clock instant:snap_periodic_reports.created_at(the go-live epoch’s source) andsnap_change_reports.reported_at. An insert that names no stamp now fails instead of taking the database clock, andcargo xtask migrations-lintrefuses a new clock default (#2589). Every other clock default stays; the file’s header names each, with its reason (#3007) -
20270324000000_determination_status_withheld.sql— ADR-052: replacesrecert_nudges_baseline_status_verdictandrecert_nudges_dry_run_status_verdictso the list also admitswithheld; no row is rewritten.
All migrations are forward-only per ADR-016.