canopy-reporting Data Model
#1456 (ADR-004): every table and function in this schema is owned by
canopy_reporting_owner (NOLOGIN); the runtime connects as the restricted
canopy_reporting_app login holding only the enumerated per-object grants
(migrations 20261111000000/20261111000001). The sealed extract is never
UPDATEd and the six generation-scoped tables are DELETE-able only through
the SECURITY DEFINER reporting_janitor_reap fn, which re-verifies
superseded/abandoned-past-retention eligibility inside the definer.
Cutover/rollback: security-operations.
Cross-link: canopy-reporting API Reference · Source: migrations/
Tables
| Table | Purpose |
|---|---|
|
FNS-388 SNAP monthly state activity report header (7 CFR 272.11). One row per (generation_id, report_month) — uniqueness moved onto the output generation by the #1202 run substrate; readers resolve the month’s PUBLISHED generation and serve only its row. Carries the aggregate household / individual / benefit counts, expedited + elderly/disabled splits, initial-cert vs recert split (classified by the LEGAL receipt month — never the UTC one, #1584), the calculated |
|
FNS-7176 Quality Control universe snapshot (7 CFR Part 275). One row per (generation_id, household, snapshot_date) — uniqueness moved onto the output generation by the #1202 run substrate; readers resolve the date’s PUBLISHED generation and filter by it. Carries the full deduction stack used in the QC review (earned-income / standard / dependent-care / medical / shelter / child-support) and the resulting |
|
ACF-199 monthly TANF case snapshot. One row per (generation_id, report_month, case_id) — uniqueness moved onto the output generation by the #1202 run substrate; readers resolve the month’s PUBLISHED generation (or the latest published, when no month is given) and serve only its rows. One family row per assistance unit (household) per month (#3052): |
|
One row per member of W and full week of a partial-month ACF-199 family (#3194), keyed |
|
One row per member of W of an ACF-199 family (#2975), keyed |
|
ACF-196 quarterly TANF financial report. Composite unique on |
|
Monthly Work Participation Rate calculation. One row per |
|
T-MSIS eligibility file rows (42 CFR 431 / 42 CFR 433). One row per (generation_id, report_month, enrollment_id) — uniqueness moved onto the output generation by the #1202 run substrate; readers resolve the month’s PUBLISHED generation (or latest) and serve only its rows. Encrypted at rest (#1256, ADR-004 Amendment 3): only the engine-evaluated keys are plaintext columns — |
|
The ADR-036 crypto-shred key store (#1256): KEK-wrapped per-subject DEKs. |
|
CMS-64 quarterly expenditure report. Composite unique on |
|
CMS-416 annual EPSDT report. Composite unique on |
|
Permanent generation-provenance rows of the durable report-run substrate (the archived report-run-generations plan) with atomic staged→published promotion; |
|
The guarded, token-fenced job table — |
|
The materialized per-run universe ( |
|
The generated ADR-018 / ADR-039 outbox and the generated consumer inbox, single-sourced in |
|
The fleet-wide idempotent-POST cache (#434 / #1463), created outside this service’s |
Relationships
Intra-database foreign keys only (relationship-only; columns live in the Tables list):
tanf_acf196_reports, tanf_wpr_calculations and medicaid_cms64_reports carry no generation_id and no FK (their natural keys are the fiscal quarter / report month); redaction_keys.subject_id names a report generation as an application-level pointer (subject_kind = 'report_generation').
Cross-service FKs (ADR-001 boundary)
canopy-reporting is a downstream aggregator and holds no Postgres-level FKs to other services. Every UUID that points outside canopy_reporting is an application-level reference: snap_qc_universe.household_id / certification_id (canopy-persons, canopy-snap), tanf_acf199_snapshots.case_id (canopy-tanf), medicaid_tmsis_eligibility_extracts.person_id / enrollment_id (canopy-persons, canopy-enrollment). (snap_monthly_reports.generated_by is not a UUID since #1008: it holds an opaque OIDC subject, never a reference into another service’s rows.) The aggregator pulls data via the program services' HTTP APIs (no cross-database joins) per ADR-001.
Retention
Retention floors (eCFR, checked 2026-09-16): federal-submission records are retained per federal partner. SNAP (FNS-388 / FNS-7176): no less than 3 years from the month of origin of each record (7 CFR 272.1(f)). TANF (ACF-199 / ACF-196 / WPR): no program-specific retention section exists — the HHS award-record floor is 3 years from submission of the final financial report (2 CFR 200.334, applied to HHS awards by 2 CFR 300.1; 45 CFR part 75 was removed effective 2025-10-01, 89 FR 80055, and the older 45 CFR 92.42 no longer exists). Medicaid (T-MSIS / CMS-64 / CMS-416): 3 years from submission of the final expenditure report, and beyond that while audit findings are unresolved (42 CFR 433.32(b)–(c)). State series: Georgia Archives, DHS retention schedule (agency 144), series 1976-0110 "Food Stamp Administrative Files", 3 years, for the SNAP submissions, and series 1975-0080 "Medicaid Eligibility Report Files" (monthly reports: retain until verification of the following month’s report; annual report: 5 years or after audit questions resolved, whichever is longer) for the Medicaid eligibility reports — https://www.georgiaarchives.org/records/agencyprint/144 (checked 2026-09-18). The SNAP series does not exceed the federal floor, so 7 CFR 272.1(f) governs; the Medicaid monthly term is shorter than the 3-year 42 CFR 433.32(b) floor, which therefore governs the monthly submissions, while the 5-year annual term exceeds it, so the state series governs an annual one. In practice rows are retained indefinitely in production; the only DELETE path is reporting_janitor_reap over superseded / abandoned generations, and archive moves are operator-driven, never migration-driven (ADR-016).
Indexes
-
snap_monthly_reports_generation_month_uq(unique) — one row per (generation, report_month); replacedidx_snap_monthly_reports_monthwhen uniqueness moved onto the output generation (#1202 backfill migration) -
idx_snap_qc_universe_snapshot— per-snapshot listing -
idx_snap_qc_universe_household— per-household lookup -
snap_qc_universe_generation_household_snapshot_uq(unique) — one row per (generation, household, snapshot); replacedidx_snap_qc_universe_household_snapshotwhen uniqueness moved onto the output generation (#1202 backfill migration). Also the keyset ride for the generation-scoped paginated QC-universe reads (#1202): each page (WHERE generation_id = $1 [AND household_id > $3] ORDER BY household_id LIMIT $2) is a contiguous index range — seek, read one page, stop -
idx_snap_qc_universe_snapshot_household— the #1221(snapshot_date, household_id)keyset composite the pre-generation reads rode; retained for snapshot-scoped scans -
tanf_acf199_generation_month_case_uq(unique) — one case-snapshot per (generation, month, case); replacedtanf_acf199_month_casewhen uniqueness moved onto the output generation (#1202 backfill migration) -
tanf_acf199_month— per-month listing -
tanf_acf196_fy_quarter_cat(unique) — composite uniqueness on quarterly financial report key -
tanf_wpr_month(unique) — single WPR row per report_month -
medicaid_tmsis_generation_month_enrollment_uq(unique) — one extract row per (generation, month, enrollment); replacedmedicaid_tmsis_month_enrollmentwhen uniqueness moved onto the output generation (#1202 backfill migration) -
medicaid_tmsis_cms416_universe_idx— the(report_month, chip_indicator, person_id)composite the CMS-416 local-universe drain rides (half-open report-year range +chip_indicator = false+person_idkeyset order, EXPLAIN-pinned; #1202); replaced the prefix-redundant single-columnmedicaid_tmsis_month(dropped in20261101000004) -
medicaid_tmsis_person— per-person lookup -
medicaid_cms64_fy_quarter_cat_pop(unique) — composite uniqueness on CMS-64 row key -
medicaid_cms416_generation_year_age_uq(unique) — one row per (generation, report_year, age_group); replacedmedicaid_cms416_year_agewhen uniqueness moved onto the output generation (#1202 backfill migration) -
report_generations_published_uq(UNIQUE partial,(report_kind, period_date) WHERE state = 'published') — one published generation per kind and period (#1202) -
report_runs_active_target_uq(UNIQUE partial,(report_kind, period_date) WHERE state IN ('queued','running')) — ONE active run per target;report_runs_queued_idx(partial,(requested_at) WHERE state = 'queued') — the claim scan;report_runs_reclaim_idx(partial,(claim_expires_at) WHERE state = 'running') — the stale-claim reclaim;report_runs_reap_idx(partial,(finished_at) WHERE state IN ('done','error')) —report_run_reap -
idx_redaction_keys_subject—(subject_kind, subject_id)DEK lookup;uq_redaction_keys_live_subject(UNIQUE partial,WHERE shredded_at IS NULL) — one live DEK per generation, the atomic get-or-create’s conflict target (#1256) -
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 service-owned files, in timestamp order:
-
20260401000000_create_reporting_tables.sql— SNAP FNS-388 monthly reports + FNS-7176 QC universe snapshot -
20260409000000_tanf_medicaid_reporting_tables.sql— TANF ACF-199 monthly snapshots, ACF-196 quarterly financial, WPR calculations; Medicaid T-MSIS eligibility extracts, CMS-64 quarterly expenditures, CMS-416 annual EPSDT -
20260723120000_qc_stub_fields_nullable.sql— #1155: the QC stub fields (expedited_service,work_registration_exempt_count,ievs_match_completed) nullable + historical values NULLed (unknown is NULL, never a fabricated false/0) -
20260805000000_v7_pk_defaults.sql— #1173: drops thegen_random_uuid()(UUID v4)idDEFAULT on the six TANF / Medicaid output tables; the application binds a v7 id at every INSERT -
20260813000000_acf199_childcare_funded.sql— #1169:tanf_acf199_snapshots.childcare_funded(BOOLEAN NOT NULL DEFAULT false) — the two-parent 55-hour WPR standard input -
20260820000000_qc_universe_keyset_index.sql— the(snapshot_date, household_id)keyset composite for the paginated QC-universe reads (#1221; transactional NOT CONCURRENTLY per the #1196 rationale) -
20261101000000_report_generations.sql+20261101000001_report_runs.sql+20261101000002_report_run_universe_and_legacy_backfill.sql— the #1202/#1203 durable report-run substrate (plan report-run-generations): thereport_generationspublication model, the guardedreport_runsjob table, the materializedreport_run_universe,generation_idon all five output tables with uniqueness moved to (generation_id, natural key), and the legacy published-generation backfill. Backfilled legacy generations are pure DATA —run_idNULL (surfaced asprovenance.run_id = null),build_version/params_hash'legacy'; thelegacy_generation_idwrite-path helper that stamped the synchronous extracts' rows was deleted in #1202/#1203 with its last consumers (every kind now writes through the run pipeline’s staged generations) -
20261101000003_abawd_household_unverified_legacy_null.sql— #1202:snap_qc_universe.abawd_householdnullable + DEFAULT dropped + ALL historical values NULLed — outage-fabricatedfalseis indistinguishable from sourcedfalse; NULL = "unverified legacy" -
20261101000004_cms416_universe_index.sql— #1202/#1203: addsmedicaid_tmsis_cms416_universe_idx (report_month, chip_indicator, person_id)for the CMS-416 local-universe drain and DROPS the prefix-redundantmedicaid_tmsis_month -
20261110000000_reporting_redaction_keys.sql— the ADR-036redaction_keysstore (#1256): per-generation DEKs + one-way tombstone + live-subject unique index -
20261110000001_seal_restricted_reporting_stores.sql— #1256: addserror_codevaluesadmin_reset/crypto_failure; the quiesced fresh-start reset (terminalize in-flight tmsis/cms_416 runs, supersede tmsis generations, clear their universe rows + derived CMS-64/416 rows); reshapesmedicaid_tmsis_eligibility_extracts(drop the 11 plaintext attribute columns, addrestricted_payload) -
20261110000002_abandon_failed_run_generations.sql— #1462: re-createsreport_run_finalizeandreport_run_claimso a run that terminalizes toerrormarks its generationabandoned, letting the janitor reap its output, universe and sealed-extract rows -
20261111000000_least_privilege_roles.sql— #1456 (ADR-004): createscanopy_reporting_owner(NOLOGIN) andcanopy_reporting_app, moves every table and function to the owner, revokes PUBLIC, and grants the app role only the enumerated verbs (SELECT / INSERT on the output tables, UPDATE also ontanf_wpr_calculationsandreport_generations, full DML onreport_runsandidempotency_keys, SELECT / UPDATE / DELETE onevent_outbox) -
20261111000001_janitor_security_definer.sql— #1456:reporting_janitor_reap(uuid, int)asSECURITY DEFINERowned bycanopy_reporting_owner— the only DELETE path over the generation-scoped tables; it re-verifies superseded / abandoned-past-retention eligibility inside the definer -
20261129000000_grant_outbox_insert_to_app.sql— #1404 (Pub 1075 §9): grantsINSERTonevent_outboxtocanopy_reporting_app— the reporting-access audit stream makes canopy-reporting a publisher -
20261204000000_snap_submission_update_grant.sql— #1335: column-scopedUPDATE (submission_status, submitted_at, fns_confirmation_number)onsnap_monthly_reportsfor the app role — the FNS-388 submission lifecycle; report figures stay immutable to the service -
20261205000000_honest_federal_field_dispositions.sql—medicaid_cms416_reports.total_member_monthsandtanf_acf199_snapshots.months_other_statesdrop NOT NULL + DEFAULT: an unsourced figure is NULL, never a fabricated 0 (the #1155 precedent) -
20261207000000_enqueue_pins_atomic.sql— #1343: drops the seven-argumentreport_run_enqueueand re-creates it taking the CMS-416 input-generation pins as a jsonb array, written in the same statement set that creates the generation + run (no pin-less window for a claiming worker) -
20261208000000_acf199_young_child.sql— #1771:tanf_acf199_snapshots.young_child(BOOLEAN NOT NULL DEFAULT false) — the single-parent young-child WPR standard input -
20261224000000_redaction_keys_rewrap_guard.sql— #2113:canopy_redaction_keys_one_way_guard()admits the KEK rewrap (wrapped_dekreplaced +kek_versionstrictly increased on a live row) beside the shred -
20270111000001_determination_status_check.sql— #628: deletes anytanf_acf199_snapshotsrow whosecase_statusis outsideapproved / denied / sanctioned, then addstanf_acf199_snapshots_case_status_verdict -
20270113000000_actor_subjects.sql— #1008:snap_monthly_reports.generated_byretypesUUID→TEXT(USING …::text) and gainsgenerated_by_service TEXT; a guard raises, namingcargo xtask dev restart, on a row whosegenerated_byis NULL (a pipeline write that named no service) or the nil UUID — no author is invented; thensnap_monthly_reports_generated_by_one_actor, VALID. The table-levelSELECT, INSERTgrant covers the new column; the column-scoped UPDATE grant is untouched -
20270117000000_redaction_keys_created_at_no_default.sql— #2582: drops theredaction_keys.created_atdefault; the restricted store’s get-or-create bindscreated_atfrom its caller, so an insert that names nocreated_atnow fails instead of taking the database clock -
20270118000000_app_no_temporary.sql— #2573 (ADR-004): revokes TEMPORARY on the database from PUBLIC, and TEMPORARY and CREATE on it fromcanopy_reporting_app, so the runtime login can create no temporary table and no schema of its own name to shadow a table it reads by unqualified name; a closing audit refuses either privilege by any path -
20270119000000_batched_reaps.sql— #2963: replacesreport_run_reap(int)andreporting_janitor_reap(uuid, int)with batch functions the worker calls in a loop, each call committing on its own.report_run_reap(older_than_days, after, batch)deletes up tobatchterminal runs past the 7-day floor and returns(removed, last_id).reporting_janitor_reap(generation, retention_days, batch)deletes up tobatchof the generation’s output and universe rows, re-verifying its eligibility on every call, and returns(output_rows, universe_rows). The batch is 1 to 10 000; ownership and grants are unchanged -
20270214000000_acf199_weekly_hours.sql— #2316:tanf_acf199_snapshotsdropstotal_work_hoursandcore_activity_hours(monthly totals the WPR compared with weekly standards) and addsaverage_weekly_total_hoursandaverage_weekly_core_hours(NUMERIC(6,2)) andassisted_whole_month(BOOLEAN), each commented with its 45 CFR 261.31 / 261.32 / 261.22(d) / 261.24(d) role. Earlier rows hold NULL in all three; the table-level grants cover the new columns -
20270214000001_acf199_work_standard_refusal.sql— #2315:report_runs.error_codeadmitspolicy_input_missing;report_runsgainserror_reason(TEXT) anderror_person_id(UUID) underreport_runs_policy_refusal_named;report_run_finalizeis dropped and re-created withp_error_reasonandp_error_person_id(ownercanopy_reporting_owner, EXECUTE tocanopy_reporting_appalone);tanf_acf199_snapshots.young_childis re-commented to the recorded basis (42 USC 607(c)(2)(B)) -
20270311000000_acf199_adult_full_weeks.sql— #3194:tanf_acf199_snapshotsgainsfull_week_count(INTEGER, CHECK>= 0, NULL for a whole-month family); createstanf_acf199_snapshot_adult_weeks(ownercanopy_reporting_owner; SELECT and INSERT tocanopy_reporting_app; no clock default). -
20270219000000_acf199_family_type.sql— #2975:tanf_acf199_snapshotsdropsyoung_childand gainswork_eligible_count(INTEGER, CHECK>= 0; NULL on earlier rows); createstanf_acf199_snapshot_adults(ownercanopy_reporting_owner; SELECT and INSERT tocanopy_reporting_app; no clock default). Asingle_parentrow extracted earlier has no member rows and counts in no WPR numerator until its month is rerun -
20270324000000_determination_status_withheld.sql— ADR-052: replacestanf_acf199_snapshots_case_status_verdictso the list also admitswithheld; no row is rewritten.
All migrations are forward-only per ADR-016.