canopy-renewals Data Model

Tables

Table Purpose

snap_certifications

One row per SNAP certification period. application_id is the canopy-applications id on EVERY writer — the HTTP create path since inception, the #1730 reinstatement arm, and the expedited arm since #1735 (which previously stored canopy-snap’s local id off SnapDeterminationCompleted.application_id; the applications id rides the same event as upstream_application_id, and an expedited approval without one is a producer defect the consumer nacks to the DLQ). Holds the certification_start_date / certification_end_date window, certification_type (caller-declared category, persisted verbatim — since #2209 a code of the booted pack’s [[snap.certification.categories]] (the pack’s jurisdiction.toml is the authority, named in the column comment; georgia standard / elderly_disabled / senior / abawd), validated at the handler against the pack’s worker_declarable rows and held only by the length CHECK length(certification_type) BETWEEN 1 AND 64 — the former snap_certs_type_check token list and the DEFAULT 'standard' are dropped, so an INSERT omitting it fails; #956 killed the period-length inference; plus the SYSTEM-minted expedited since #1661 — 7 CFR 273.2(i)(4) / PAMMS 3110, opened only by the determination.completed.snap consumer, refused with 422 on the manual endpoint), reporting_model (simplified vs change_reporting per 7 CFR 273.12(a)), the optional interim_contact_due_date + interim_contact_completed_at pair (mid-certification contact, derived only for a certification whose pack row sets interim_contact = true — georgia standard; #2209), and the renewal-cycle linkage (renewal_notice_sent_date, renewal_application_id, renewal_submitted_at, renewal_determination_id — the last with ONE writer since #1730: store::retire_renewed_certification, the reinstatement arm’s retire-by-id that expires the lapsed recertifying cert and stamps the reinstating determination; a non-reinstatement renewal approval never stamps it). The daily scheduler stamps renewal_notice_sent_date (renewal-due), interim_contact_notice_sent_date (interim-due), and expiration_notice_sent_date (#792 — the 7 CFR 273.14(b)(1) NOE, month-anchored window, >2-month certs only) in the same transaction as each event emit, so a due certification emits its event exactly once rather than once per daily tick across the whole lookahead window (#1198); interim_contact_completed_at records a worker completing the contact and is a distinct signal from the emission fence. Status moves through active → recertifying → terminated/expired — the recertifying leg gained its WRITER in #1728: the application.submitted filing consumer projects a recertification application onto its certification in ONE replay-safe UPDATE (status = 'recertifying', renewal_application_id, renewal_submitted_at = the application’s receipt instant), and recertifying joined the IN-FORCE class (store::IN_FORCE_CERT_STATUSES = active + recertifying: the cert is in force until its end date; every status = 'active' predicate was audited — the one-in-force fence, supersede, the in-force reads, the #1204 due-list pair, the overdue / interim feeds, the four continuation-primitive sites, the QC universe snapshot, the periodic-report joins + completion lock and the NOE drain + fence INCLUDE it; the renewal-due drain alone stays = 'active', the ONE EXCLUDE — the household already filed, so a withdrawn renewal leaves the signal suppressed and the cert recertifying for the rest of the period; a new filing is initial); an early termination also stamps terminated_at (the instant the case left the caseload), which the caseload-depth trend (#702) reads to reconstruct historical depth losslessly; a #1108 periodic-report reopen is the sanctioned inverse (reinstate_certification, the ONLY path away from terminated) — it restores active and CLEARS terminated_at, so the reopened cert counts in future depth buckets and a later re-termination stamps fresh instead of resurrecting the first instant. Creating a certification supersedes the household’s prior active certification (→ expired) in the same transaction, so at most one certification is IN FORCE (active / recertifying since #1728) per household at a time — enforced by the snap_certs_one_active_per_household partial unique index (a concurrent double-create loses the race and gets 409 Conflict) and by a non-empty-period snap_certs_period_order_chk CHECK (certification_end_date > certification_start_date, rejected 422 at the API) (#973). periodic_report_required (#1106) is the periodic-report cohort flag: set at creation (and backfilled by migration) for extended certifications assigned before the 2026-03-02 MT-87 phase-out (PAMMS 3730:21-23), false for anything at/after it, ≤6-month periods (3730:18), and certifications whose pack row sets periodic_reporting_waived = true (georgia senior — 3730:64 waives Senior SNAP; since #2209 keyed on the row’s flag at creation, never on the token’s name; the migration backfill retains its 36-month duration proxy because legacy rows carry no type label) — it gates ALL periodic-report machinery, and creating a successor certification cancels the superseded cert’s open cycles in the same transaction. #1661 adds: determined_at (the signed determination’s scoring instant — the event arm’s causal-guard ordering input; NULL on HTTP-minted rows); one certification per determination, enforced by the snap_certs_one_per_determination partial UNIQUE on determination_id WHERE active = true (partial because determination_id is NOT NULL and active is the soft-delete flag every read filters on — a total unique could not be fixed forward without deleting rows; the migration demotes duplicate losers to active = false, newest start date wins); and the Notice-of-Expiration dispatch correlation triple — noe_source_event_id (the pre-minted envelope id of the staged renewal.snap_expiration_notice_due row, stamped beside expiration_notice_sent_date by BOTH NOE arms: the >2-month drain and the ≤2-month at-certification arm), noe_dispatched_at + noe_dispatched_date (stamped set-once by the notice.dispatched consumer; the date is the notices-side legal-tz date, verbatim). Enqueue ≠ dispatched (#788): expiration_notice_sent_date says the letter was STAGED, noe_dispatched_at that it LEFT — only the pair is lapse evidence (noe::noe_evidence_dispatched). #1658 adds continued_by_determination_id (the LATEST continuing determination the continuation adjuster accepted for this cert — applied or no_change, overwritten each time; a read-model / audit column, NOT the create-path guard, which reads snap_certification_adjustments.determination_id) and continuation_watermark (the accepted event’s lifecycle_revision_after — the absolute-state CAS key: an older/equal arrival is stale and writes nothing); the adjuster also RE-STAMPS determined_at with the continuing determination’s instant (so the column reads "the latest applied determination’s instant"), may move certification_end_date / certification_type (on an in_cert_conversion continuation, expedited → the approval’s assigned category — ContinuationAppliedV1.certification_category, #1703 — through continuation::rules::desired_type; a conversion without one is refused to the DLQ) / interim_contact_due_date / periodic_report_required, and NULLs the NOE quartet or renewal_notice_sent_date per the continuation kind (#1658; the prior values are snapshotted on the adjustment row). #1822 adds supersede_reason — WHY an in-force row was superseded, a CHECK-held vocabulary (new_certification | renewal_reinstatement | record_back_refused): the ordinary retirement by a successor certification, the #1730 reinstatement arm’s retire-by-id of the renewed period, or the record-back refusal arm retiring a certification whose determination canopy-applications refused to record (409 postponement_not_open, #1707). All three writers of status = 'expired' stamp their token, so NULL means either "never superseded" or a row superseded before #1822 — never "superseded, reason unknown". A supersede is NOT a termination: terminated_at stays NULL and no notice is owed. #1800 adds the conversion quartet (the mid-period conversion of a convertible pack row — georgia Senior SNAP) — converted_at (the DB instant), converted_on (the worker-supplied effective date, inside the period and never ahead of the gated clock’s today), conversion_reason (the disqualifying change, validated against the JURISDICTION’s snap.certification.esap.conversion_reasons vocabulary at the handler, deliberately NOT a DB CHECK — the snap_adverse_actions.reason_code precedent — so a state adds its own by ruleset) and converted_by (the deciding worker, caller-asserted provenance for the 3725:136 letter, never authorization) — held all-or-none by snap_cert_conversion_all_or_none (num_nonnulls(…​) IN (0, 4)), so a half-stamped conversion cannot exist. A stamped row is a regular AU: certification_type reads the row’s converts_to (georgia standard; never a waived or convertible row, by the pack schema) and periodic_report_required is recomputed on the conversion arm (3730:65 — the phase-out is conversion_exempt_from_phase_out's call), while the period itself is untouched (3730:69-70). Only converted_by is withheld from the SnapCertification read model: staff identity has no business on the applicant-portal read. SNAP-only; per-program certification lifecycle for TANF/Medicaid/CAPS/WIC stays in each program’s own service.

snap_certification_adjustments (#1658)

The order-safe certification mirror of the enrolled-household continuation primitive: ONE row per ACCEPTED enrollment.continuation_applied / enrollment.continuation_terminated event — the complete history. outcome ∈ applied (the end / type moved) · no_change (desired state already held; the watermark still advanced) · stale (older/equal continuation_watermark, nothing written) · superseded_by_new_certification (the certifying determination’s cert is no longer active) · pending_certification (no cert yet for certifying_determination_id — certification_id, new_type, prior_end, prior_type NULL; the create path re-runs the row through the SAME adjuster and finalizes it IN PLACE in continuation_watermark order). Identity: household_id, certifying_determination_id (the cert key — snap_enrollments.determination_id), determination_id (the continuing one), person_id (the event’s head of household — the at-adjust NOE recipient) and basis_kind (the type-flip discriminator; both persisted so the reconciliation needs nothing the row does not carry), applied_via ∈ immediate / adverse_action_enacted, source_event_id (the envelope id). Replay belts: UNIQUE (determination_id, applied_via) (an extend_now_reduce_later determination is two events, one per half) and UNIQUE source_event_id. Desired/prior state: new_end (NOT NULL — the ABSOLUTE end; the terminated arm records the noticed terminated_date), new_type (NULL iff pending), prior_end / prior_type (NULL iff pending), the interim-contact pair + interim_contact_action ∈ unchanged / rescheduled / skipped_past, the periodic_report_required pair. NOE: noe_action ∈ none / released_to_drain / staged_at_adjust; noe_fence_cleared (CHECK-equal to prior_expiration_notice_sent_date IS NOT NULL) with the fence QUARTET snapshot (prior_expiration_notice_sent_date, prior_noe_source_event_id — partial UNIQUE, the late notice.dispatched fallthrough’s correlation key —, prior_noe_dispatched_at, prior_noe_dispatched_date; dispatch-after-stage CHECK inherited), new_noe_source_event_id (NOT NULL iff staged_at_adjust), prior_renewal_notice_sent_date (set when the renewal-due fence was cleared). Belt CHECK: stale / superseded_by_new_certification / pending_certification never touch a fence (noe_action = none AND noe_fence_cleared = false). continuation_watermark + determined_at + previous_determination_id mirror the event; applied_at is the DB instant (audit only). #1703 adds certification_category (TEXT NULL; since #2209 a pack-declared token under the length CHECK length(certification_category) BETWEEN 1 AND 64 — the snap_cert_adj_category_vocab_chk four-token list and new_type's snap_cert_adj_new_type_vocab_chk are dropped; the authority is the booted pack’s [[snap.certification.categories]], and expedited is never an assignment): the event’s assigned category as continuation::adjust::AdjustInput.certification_category, the type an in_cert_conversion applies (rules::desired_type) and what a pending_certification row re-derives it from at create-path reconciliation (AdjustInput::from_pending — never the certification’s current type). NULL on the terminated arm’s rows (their basis_kind is still in_cert_conversion) and on a non-conversion basis that carried none; an applied-arm conversion row is never NULL (AdjustInput::from_applied refuses the event before the household lock). FK certification_id → snap_certifications(id); every other id is cross-service (ADR-001).

snap_renewal_decisions

ONE row per renewal application (renewal_application_id PK = the event’s upstream_application_id) whose in-period recertification decision was signed under recert_approval: the recertifying certification it renews (certification_id, FK), the newest decision (determination_id, determined_at — the causal::supersedes inputs; decision ∈ approved | denied), the signed pair and the assigned category’s type (certification_start_date, certification_end_date, certification_type — a pack-declared token under a length CHECK since #2209 (snap_renewal_decisions_type_check dropped); present iff approved, the CHECK pair), head_of_household_person_id (the event’s NOA recipient — the shared writer’s NOE recipient), status ∈ scheduled | withdrawn | minted. The consumer records; the scheduler’s mint_due_renewals opens the certification at certification_start_date through cert_create::create_with_supersede (the old certification superseded past its end) and flips the row minted. The partial UNIQUE (household_id) WHERE status = 'scheduled' is the one-renewal-in-force rule; idx_snap_renewal_decisions_due (status, certification_start_date) serves the mint.

snap_change_reports

Mid-certification change report ledger. One row per change reported by the household (or system-detected). Carries reported_at, the reporting event time: no request carries a report date, so since #3015 every writer binds the recording request’s decision-clock instant (ChangeReportInsert.reported_at) and the column has no default. It also carries the report_method (phone / mail / in_person / online / system), change_type, free-text description, the requires_redetermination flag, and the optional redetermination_application_id that links back to canopy-applications when the change kicks off a new intake. Per #448 (multi-program upstream gaps), the program column (DEFAULT 'snap') routes non-SNAP change reports from the worker portal’s /v1/renewals/{program}/…​ endpoints; certification_id is now nullable so non-SNAP programs (which own their own certification tables in their own services) can record changes via a direct household_id reference. Since #1619 the row also records the 130%-FPL screen’s own inputs and provenance, so the flag is auditable rather than a bare boolean: screen_status (not_applicable / screened / dry_run_unprocessable / eligibility_unavailable), the derived decision inputs (derived_household_size, derived_monthly_income, gross_income_limit — all three taken from the canopy-eligibility dry-run that re-scored the household’s facts of record, never from the wire), the policy pin (screen_determination_id, screen_corpus_hash, screen_params_digest), and the informational reported_monthly_income / reported_household_size the caller supplied (provenance only — the screen never reads them). snap_change_reports_screen_status_chk pins the status vocabulary and snap_change_reports_screen_chk makes the verdict reproducible: a screened row must carry all its inputs AND satisfy requires_redetermination = (derived_monthly_income > gross_income_limit), while a degraded row must carry requires_redetermination = false. Legacy rows (all not_applicable) are deliberately outside the constraint’s scope, so it is total and immediately VALID. Since #1827 no canopy-renewals writer produces a not_applicable row with the flag raised: the periodic-report completion path — the last one that did, comparing the figures written on the 528 against a second FPL table local to canopy-renewals — now writes its income_change rows through the same dry-run screen, so on every row this service writes, not_applicable means "no screen ran, and nothing was raised". processed_by (with processed_at) is the processing worker’s opaque OIDC subject, TEXT since #1008 (a human-only act; no writer sets it today).

recert_nudges (#680, ADR-027 §6)

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: baseline_status / baseline_benefit_cents, dry_run_status / dry_run_benefit_cents (both statuses CHECK-closed to approved / denied / sanctioned / withheld since #628 — recert_nudges_baseline_status_verdict, recert_nudges_dry_run_status_verdict), benefit_delta_cents (cents; NULL on a denied side), and is_material (Decision F — a verdict flip, or both-approved with a delta >= the [snap.materiality] threshold). Idempotent on UNIQUE (certification_id, source_event_id) (Decision G — the triggering persons fact-change event id), so at-least-once delivery yields exactly one nudge. A material row triggers a renewal.material_change event → ChangeInCircumstancesNotice. triggering_fact_kind ∈ income / asset / expense / member; action_taken (filed_recert / dismissed, worker-set) is NULL while pending; since #1008 the actor is an optional pair taken from the action request’s bearer — action_by (TEXT, a human’s OIDC subject) and action_by_service (TEXT, a service principal) — held by two CHECKs: recert_nudges_action_by_one_actor (num_nonnulls(action_by, action_by_service) ⇐ 1) and recert_nudges_action_by_iff_actioned ((action_taken IS NULL) = (num_nonnulls(action_by, action_by_service) = 0)), so an actioned row names exactly one actor and a pending row none; notice_id is reserved for a future async link-back from canopy-notices. FK certification_id → snap_certifications(id); household_id / baseline_determination_id / source_person_id are cross-service references (no DB-level FK, ADR-001).

snap_periodic_reports (#1106)

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); snap_certifications.periodic_report_required is then false on every certification. generation is the 1-based cycle number (UNIQUE (certification_id, generation); the base rule mints one midpoint cycle per 3730:19 — the 6th month of a 12-month cert, the 12th of a 24-month; since #1127 a QUALIFYING earned-income change (persons-fact income_type in [snap.periodic_reporting].frequency_shift_earned_income_types) on a cohort cert mints the 3730:25-26 shifted-cadence generations in the materiality subscriber’s inbox tx — every frequency_shift_interval_months (6) from the cert start, strictly inside the period, future-serviceable due months only (an elapsed 15th-notice window is skipped outright, never tombstoned), generation numbers continuing from MAX under the cert FOR UPDATE lock, idempotent on the per-due-month unique (the midpoint collision is the designed no-op); #1800’s Senior-SNAP conversion mints the remainder of that SAME cadence through the same loop, on the convert handler’s transaction) and UNIQUE (certification_id, due_month) makes the daily materializer idempotent. The 3730 calendar is stored per cycle: initial_notice_due_date (15th of the prior month, 3730:83), combined_notice_due_date (5th of the due month, 3730:98 — that combined notice IS the adequate termination notice, 3730:100/:108), closure_due_date (end of the due month, 3730:76-79; last-prior-workday adjustment applied by the 5.2 closure executor). status walks scheduled → notice_sent → form_incomplete/form_complete → vcl_pending → verified → processed, with terminated (5.2 terminal consumer) and cancelled (cancel_reason = certification_superseded on recertification per 3730:21-23, calendar_elapsed_at_cutover when the cohort scan first saw the cert after its due month began, materializer_behind when the scan found a cohort cert whose midpoint the daily materializer should already have minted, or — since #1800 — converted_after_last_cycle when a Senior conversion lands after the period’s last future-serviceable due month, the one tombstone that records an EXPECTED absence of cycles rather than a pipeline failure). Form receipt records form_kind + form_received_date; the token is one of the booted pack’s [snap.periodic_reporting].accepted_form_kinds (Georgia: 528, or 297/508 covering all sections per 3730:117), validated at every write — since #2214 the pack owns the vocabulary and the column carries only snap_pr_form_kind_length_chk (1–64 characters); an incomplete form is NOT filed (3730:35) and keeps the cycle combined-notice-eligible. The VCL trio (vcl_sent_date, vcl_due_date, vcl_reason ∈ reported_change/discrepancy, vcl_detail) is CHECK-constrained to the ≥10-calendar-day minimum (3730:218). Every state stamp is preserved — the row is its own audit trail. Since #1107 the row also records adverse_action_id + combined_notice_sent_date when the 5th-of-month trigger mints the termination action (the stamp removes the cycle from the combined due list; STATUS is untouched so a late form still files). Since #1128 a lapsed VCL gets the same treatment (Chart 3730.1 row 2): the drain_vcl_closures scheduler leg stamps vcl_termination_triggered_date + adverse_action_id when it schedules (or, on a provenance-triple replay against a still-live nonfiler action, ADOPTS) the exempt termination — reason periodic_report_verification_failure under the periodic_report source, CB off by that row’s cb_available = false (3730:37; #2212) — and the stamp removes the cycle from the closure due set while STATUS stays vcl_pending, so a late verification still cures through verified → processed (whose completion tombstone cancels the in-flight action). Transition dates are server-stamped via the service’s single legal_today() funnel (never accepted from the wire); completion runs in ONE locked transaction (certification row FOR UPDATE in the same cert→cycle order as the supersede path) with its change-report rows and the renewal.snap_periodic_report_processed outbox event. Since #1108 a TERMINATED cycle can REOPEN inside the Chart 3730.1 30-day window: it rejoins the state machine (terminated → verified on the verification-cure arm, row 4, or terminated → form_complete on the late-filing arm, row 5 — the arm derived from vcl_sent_date, never claimed) and stamps reopened_date (the legal receipt; also the enrollment-side proration anchor — terminated_date survives as history) + sop_due_date (receipt + 5 workdays on the cure arm, receipt + 30 days on the late-filing arm; the pair CHECK-constrained to travel together, deadline ≥ receipt). created_at has no default since #3015: every writer binds its decision-clock instant (the daily pass’s in materialize_cycles, the materiality delivery’s in mint_frequency_shift_cycles, the convert request’s in mint_conversion_cycles). The legal month of its earliest value, on the pack’s [jurisdiction].timezone calendar, is the pipeline’s go-live epoch (pipeline_epoch_month, #1210), the month that splits calendar_elapsed_at_cutover from materializer_behind, so the epoch is decision-clock time. Since #3041 the service takes that month from the raw instant with canopy_common::clock::date_in, not with SQL date_trunc, which truncates in the session’s UTC and read a first pass on a month’s last evening as the next month.

pr_redeterminations (#1107)

The veto/cancel re-determination worker queue: one row per DEAD periodic-report adverse action (UNIQUE (adverse_action_id) — idempotent under at-least-once terminal-event delivery). trigger_kind ∈ action_vetoed (appeal veto) / action_cancelled (worker cancel); the paired cycle is stamped cancelled with a *_pending_redetermination reason in the same inbox tx. Worker decision = single conditional UPDATE (action_taken ∈ redetermined/dismissed, NULL-guarded — the first decision stands). Mirrors the recert-nudges worker-queue shape, including the #1008 optional actor pair (action_by subject + action_by_service principal, from the bearer) and its two CHECKs, pr_redeterminations_action_by_one_actor and pr_redeterminations_action_by_iff_actioned. NEVER an automatic re-trigger.

event_outbox, event_inbox

The generated ADR-018 / ADR-039 outbox and the generated consumer inbox (parked-state columns included), single-sourced in crates/canopy-mq/outbox-migrations/ — schema, indexes and migration files are described once in the data-models index. canopy-renewals both publishes and subscribes (canopy_mq::Subscriber in services/canopy-renewals/src/subscriber.rs; every consumer commits its domain write with the event_inbox.processed_at stamp), so event_inbox is live here.

idempotency_keys

The fleet-wide idempotent-POST cache (#434 / #1463), created outside this service’s migrations/ directory and described once in the data-models index.

scheduler_runs (#1211)

Wall-clock window fence for the service’s daily scheduler tick(s) (canopy-renewals.scheduler; since #1218 the canopy-renewals.caseload-rollup refresh job; since #1470 the canopy-renewals.universe-snapshot-reaper — UNIVERSE_SNAPSHOT_REAPER_JOB in services/canopy-renewals/src/scheduler.rs). Schema single-sourced in crates/canopy-db/scheduler-migrations/ and parity-gated by cargo xtask outbox-migrations; documented ONCE in the data-models index.

snap_caseload_daily (#1218)

The caseload-depth rollup — sole feed of GET /v1/renewals/caseload-trend (#1218). One row per evaluation day, a legal day in the jurisdiction’s [jurisdiction].timezone (#2592), with a terminated case still counted on each legal day that starts before its termination (rollup_date PK, household_count with a >= 0 CHECK, refreshed_at), recomputed in FULL over the serving window [anchor−735d, anchor+8d] (≈744 rows — the tiny serve table is the point) by the canopy-renewals.caseload-rollup window-fenced job (hourly probe, first tick at boot; manual twin POST /v1/renewals/caseload-rollup/refresh consumes the day’s window on success). The refresh is one atomic prune+upsert transaction using a sweep-line (gaps-and-islands per household, ±1 boundary events, running sum — O(certs·log certs), never O(days×certs)); full-window recomputation is what makes retroactive mutations (reopen clearing terminated_at; backdated inserts, which are UNBOUNDED) self-heal. Deliberately NO backfill and no retention beyond the window: absent/stale (>48 whole hours) coverage makes the endpoint 503 honestly rather than serve fabricated zeros; rows outside coverage are pruned each refresh. Equivalence to the legacy per-bucket predicate is oracle-pinned in store.rs tests.

snap_universe_snapshots (#1470)

Immutable federal-universe snapshot generation header (ADR-002 Amendment 1 — the #1213 bulk-cohort source): id (UUIDv7), active_on, row_count, created_at. A generation is frozen in ONE transaction with its rows and the count, so paging to exhaustion returns exactly row_count regardless of live-table churn. Ephemeral working sets, not provenance: the daily fenced reaper (canopy-renewals.universe-snapshot-reaper) deletes generations older than CANOPY_RENEWALS__UNIVERSE_SNAPSHOT_RETENTION_DAYS (default 30), served by idx_snap_universe_snapshots_created_at. It deletes in bounded batches (#2577): first the expired generations' member rows, 1 000 per statement, then the emptied generations. A reader paging an expired generation mid-sweep finds the rows at its cursor gone, or the generation ended before its row_count; the bulk worker fails either closed as universe drift. Migration 20261116000000_snap_universe_snapshots.sql.

snap_universe_snapshot_rows (#1470)

The frozen member rows, keyed (snapshot_id, seq) — seq is dense 1..row_count, minted at freeze time, so the PK IS the keyset. Each row carries certification_period_id, household_id, application_id and determination_id (the establishing determination — the supersession baseline), and since #806 U-C (migration 20270107000000_universe_row_type_and_chain_head.sql) certification_type (the MT-87 category as frozen, CHECK-held to the snap_certifications vocabulary — the bulk COLA admission excludes expedited) and continued_by_determination_id (the certification’s chain head, nullable — the bulk case’s baseline when present); both are copied verbatim from snap_certifications by the INSERT..SELECT (store::UNIVERSE_SNAPSHOT_ROWS_SQL). snapshot_id FKs to snap_universe_snapshots(id) ON DELETE CASCADE. The reaper deletes a generation’s rows itself, in batches, before the generation (#2577), so no one statement removes a whole universe.

Relationships

Intra-database foreign keys only (relationship-only; columns live in the Tables list):

Diagram

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 from status = 'active' by #1728, rebuilt same-name in migration 20261225000000) — at most one IN-FORCE certification per household (#973); a second active row beside a recertifying one 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)) — the GET /v1/renewals/snap/due keyset order + cursor (#1204); supplies the (end_date, id) total order the single-column idx_snap_certs_end_date could 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 — a recertifying cert still owes its NOE, 273.14(b)(1) is unconditional — rebuilt same-name in 20261225000000) — the scheduler’s keyset NOE drain; the window is expressed sargably on certification_end_date (all month arithmetic runs on the today parameter, never on the column), so the drain range-scans a bounded slice of the index: since #1629 that slice is today .. 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, the certification_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 on active (the soft-delete flag), not total: determination_id is 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) — the notice.dispatched consumer’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 late notice.dispatched fallthrough’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 carries UNIQUE (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 carries UNIQUE (adverse_action_id)

  • idx_snap_universe_snapshots_created_at — the reaper’s age scan (#1470); snap_universe_snapshot_rows is 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; adds program column with DEFAULT 'snap', relaxes certification_id to nullable, adds program-scoped indexes

  • 20260608000000_add_certification_terminated_at.sql — adds terminated_at TIMESTAMPTZ NULL to snap_certifications so 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_nudges table, UNIQUE (certification_id, source_event_id) idempotency key, triggering_fact_kind / action_taken CHECK 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 the snap_certs_period_order_chk CHECK (end > start) and the snap_certs_one_active_per_household partial unique index

  • 20260721000000_periodic_report_cohort_and_state.sql — #1106: adds snap_certifications.periodic_report_required with 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 creates snap_periodic_reports with 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) + the pr_redeterminations worker queue (trigger/action CHECKs, per-dead-action unique, household + pending partial indexes)

  • 20260723160000_certification_type_vocabulary.sql — #956: rebuilds snap_certs_type_check (DROP + ADD) with the declared MT-87 vocabulary standard / elderly_disabled / senior / abawd

  • 20260731000000_pr_reopen.sql — #1108: snap_periodic_reports.reopened_date + sop_due_date with 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 stays vcl_pending

  • 20260818000000_snap_certs_due_keyset_idx.sql — #1204: adds the compound idx_snap_certs_end_date_id (certification_end_date ASC, id ASC) backing the keyset-paginated GET /v1/renewals/snap/due; transactional (NOT CONCURRENTLY — sqlx-migrator advisory-lock deadlock, #1196)

  • 20260819000000_snap_certs_notice_fences.sql — #1198: adds the interim_contact_notice_sent_date emission-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 in crates/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: the snap_universe_snapshots generation header + snap_universe_snapshot_rows (PK (snapshot_id, seq), ON DELETE CASCADE) and idx_snap_universe_snapshots_created_at

  • 20270107000000_universe_row_type_and_chain_head.sql — #806 U-C: snap_universe_snapshot_rows gains certification_type (NOT NULL, CHECK-held; pre-existing generations backfilled standard, the default then dropped) and continued_by_determination_id (nullable)

  • 20261208000011_snap_certs_expiration_notice_fence.sql — #792: the expiration_notice_sent_date NOE emission fence + its partial drain index (the #1198 idiom); transactional (NOT CONCURRENTLY, the #1196 rationale)

  • 20261221000000_expedited_certification_substrate.sql — #1661: widens snap_certs_type_check with expedited (DROP+ADD, the 20260723160000 shape); adds determined_at; fixes forward duplicate active rows per determination (newest start wins, losers → active = false, marker-delimited) then creates the snap_certs_one_per_determination partial UNIQUE; adds the NOE dispatch-correlation triple (noe_source_event_id + uq_snap_certs_noe_source_event, noe_dispatched_at, noe_dispatched_date) with the snap_certs_noe_dispatch_after_stage_chk CHECK (dispatch only after staging); transactional (NOT CONCURRENTLY, the #1196 rationale)

  • 20261224000000_snap_certification_adjustments.sql — #1658: adds snap_certifications.continued_by_determination_id (+ the idx_snap_certs_continued_by partial index) and continuation_watermark; creates snap_certification_adjustments with 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_type NULL iff pending_certification), the fence CHECKs (noe_fence_cleared = (prior_expiration_notice_sent_date IS NOT NULL), prior dispatch-after-stage, new_noe_source_event_id iff staged_at_adjust) and the belt CHECK (non-applied outcomes never touch a fence), the two replay UNIQUEs, the partial UNIQUE on prior_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: recertifying joins the in-force class — two SEPARATE same-name transactional rewrites (DROP + CREATE under the widened status IN ('active','recertifying') AND active = true predicate; each keeps its own uniqueness: the one-in-force fence snap_certs_one_active_per_household stays UNIQUE, the NOE fence idx_snap_certs_expiration_notice_unnotified stays a plain keyset index) plus the new idx_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, never CONCURRENTLY (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 on snap_change_reports — screen_status (DEFAULT not_applicable), the derived trio derived_household_size / derived_monthly_income / gross_income_limit, the policy pin screen_determination_id / screen_corpus_hash / screen_params_digest, the informational reported_monthly_income / reported_household_size, the snap_change_reports_screen_status_chk and snap_change_reports_screen_chk CHECKs, and the degraded-queue partial index idx_snap_change_reports_screen_degraded

  • 20261227000000_snap_cert_supersede_reason.sql — #1822: adds snap_certifications.supersede_reason with the CHECK-held vocabulary (new_certification \| renewal_reinstatement \| record_back_refused; NULL allowed for pre-#1822 history), plus a column COMMENT. Plain ALTER TABLE … ADD COLUMN (no default, no rewrite), transactional.

  • 20261228000000_snap_cert_senior_conversion.sql — #1800: adds the Senior-SNAP conversion quartet to snap_certifications (converted_at, converted_on, conversion_reason, converted_by) under the snap_cert_conversion_all_or_none CHECK (num_nonnulls(…​) IN (0, 4)), plus a COMMENT per column. No enumerated CHECK on conversion_reason — the vocabulary is the jurisdiction’s ruleset, not the schema’s. Plain ALTER 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) under snap_cert_adj_category_vocab_chk (standard / elderly_disabled / senior / abawd; the list is dropped by the #2209 migration below). snap_certifications gains 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: the snap_renewal_decisions table (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 any recert_nudges row whose baseline_status or dry_run_status is outside approved / denied / sanctioned, then adds recert_nudges_baseline_status_verdict and recert_nudges_dry_run_status_verdict

  • 20270113000000_actor_subjects.sql — #1008: recert_nudges.action_by, pr_redeterminations.action_by and snap_change_reports.processed_by retype UUID → TEXT (USING …::text, so a stored UUID becomes its text as a subject); the two queue tables gain action_by_service TEXT. A guard then raises, naming cargo xtask dev restart, on a nudge or redetermination whose action_by does not match its decision (actioned with no actor, or undecided with one) or is the nil UUID, or on a nil processed_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. Drops snap_certs_type_check, snap_cert_adj_new_type_vocab_chk, snap_cert_adj_category_vocab_chk, snap_renewal_decisions_type_check and the inline snap_universe_snapshot_rows_certification_type_check, each replaced by CHECK (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) and snap_change_reports.reported_at. An insert that names no stamp now fails instead of taking the database clock, and cargo xtask migrations-lint refuses 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: replaces recert_nudges_baseline_status_verdict and recert_nudges_dry_run_status_verdict so the list also admits withheld; no row is rewritten.

All migrations are forward-only per ADR-016.

Edit this page · default