canopy-applications Data Model
For a contributor or intake-workflow implementer reading canopy_applications: every table in the effective schema with its policy-bearing columns and CHECKs, the intra-database relationships, and the complete migration inventory. Routes and handler behaviour live on canopy-applications API Reference; source: migrations/.
Actor columns (#1008). Every worker-attribution column is TEXT holding an opaque OIDC subject (never a UUID by contract, compared byte for byte). A service-reachable act is a pair: <col> (the human’s subject) + <col>_service (the calling service’s principal). A mandatory act’s pair CHECK is num_nonnulls(<col>, <col>_service) = 1; an optional act’s is ⇐ 1 and ties attribution to the act (present exactly when the act happened). A human-only act and a referent are a bare subject column. No nil-UUID sentinel remains.
Tables
| Table | Purpose and policy columns |
|---|---|
|
Root intake record, one row per submission: |
|
One row per (application, program). |
|
One row per interview appointment (7 CFR 273.2(e)(3)); scheduling columns are write-once — a change is a superseding row ( |
|
One row per procedural denial (7 CFR 273.2(h)(2)): |
|
The (h)(3) agency-fault pend episodes: |
|
Append-only reopen episodes of a procedural denial (7 CFR 273.2(h)(2); 273.14(e)(2) for arm R): |
|
A supervisor’s audited attestation of a cure date: |
|
One saga row per episode ( |
|
Expedited postponed-verification episodes of a SNAP row (7 CFR 273.2(i)(4)(iii); |
|
The postponement saga, same shape as |
|
The day-30 disposition ledger, one row per (application, program, legal run day): |
|
Authorized-representative designations per household (7 CFR 273.2(n); ACA §1413): |
|
The per-program authority grant: PK |
|
The 7 CFR 273.2(n)(4) SNAP representation bar, person-scoped: |
|
Notice provenance for a bar, one row per staged fan-out event: |
|
Per-worker case assignment — the source of truth other services gate assignment-scoped reads on (Pub 1075 AC-6). |
|
Per-program intake sections, one active row per |
|
The applicant-facing Application ID ( |
|
argon2id hash of the applicant’s 12-digit passcode ( |
|
The client-side-encrypted Apply draft: |
|
24-hour pending lost-credential recovery: |
|
Applicant/worker uploads: the object-store |
|
The durable finalize-saga record, one row per reserved application id (no FK to the draft, which the final transaction deletes): |
|
Local skip-cache of the persons-side finalize receipts: PK |
|
Generated ADR-018 / ADR-039 outbox and inbox — documented once on the data-models index. |
|
The daily-scheduler window fence ( |
|
The fleet idempotency cache, created before the migrator runs by |
_sqlx_migrations (sqlx’s history table) is present as in every service.
Relationships
Intra-database foreign keys are ordinary here — twenty-five REFERENCES across eight parent tables. The rule ADR-001 imposes is only that no FK crosses a service boundary. The credential and saga tables keyed on the reserved application id (application_id_codes, passcode_hashes, application_drafts, finalize_operations) deliberately carry no FK to applications, because they exist before the application row does. household_assignments, day30_shadow_findings, rep_disqualifications (a parent only), scheduler_runs, the outbox, inbox and idempotency tables carry no FK of their own.
Cross-service FKs (ADR-001 boundary)
canopy-applications holds no Postgres-level foreign key to another service. household_id, submitted_by, representative_person_id and person_id name canopy-persons rows, and the actor and worker_id columns name OIDC subjects; all are application-level references — the orchestrator and the BFFs supply real ids, and existence is not enforced. application_programs.determination_id points into the program service’s database (canopy-snap / -tanf / -medicaid / -caps / -wic). applications.renews_certification_id (#1728) points into canopy-renewals' snap_certifications and is validated fail-closed at filing through the renewals HTTP read; the renewals side mirrors the link in snap_certifications.renewal_application_id.
Retention
canopy-applications holds no FTI or PHI; no Pub 1075 or HIPAA floor applies at this layer. The program floors, checked 2026-09-16 on the LII mirror (the eCFR refused this host): SNAP program records no less than 3 years from the month of origin (7 CFR 272.1(f)); TANF under the HHS uniform administrative requirements, 3 years from submission of the final financial report (2 CFR 200.334, adopted for HHS awards by 2 CFR 300.1; 45 CFR part 75 was removed effective 2025-10-01, 89 FR 80055); Medicaid, for as long as the case is active plus 3 years (42 CFR 431.17, 89 FR 22865). The longest applicable floor governs in a multi-program deployment. Retention is operator-driven (archive moves, not migration-driven destructive change — ADR-016 forward-only).
Indexes
-
applications—applications_household_idx;applications_status_idx,applications_submitted_by_received_at_idx,applications_received_at_idx(partial,WHERE active; #402);uq_applications_one_renewal_per_certification(unique partial,WHERE application_kind = 'recertification'; a 23505 is the 409renewal_already_filed) -
application_programs—application_programs_unique(unique partial,WHERE active);application_programs_program_active_idx;idx_application_programs_workflow_clock(the day-30 scan substrate);idx_application_programs_expedited_downgrade;idx_application_programs_active_reopen;idx_application_programs_active_postponement;idx_application_programs_post_lapse_candidates(partial,WHERE status = 'approved' AND determination_basis_kind = 'expedited_postponed') -
application_interviews—interviews_open_row_uq(one open appointment per(application_id, context)),interviews_superseded_by_uq,uq_interviews_nomi_event;idx_interviews_application;idx_interviews_nomi_scan,idx_interviews_nomi_scan_od(the two NOMI drain legs) -
administrative_denials—administrative_denials_initial_episode_uq,administrative_denials_episode_uq,administrative_denials_idempotency_uq;idx_administrative_denials_application -
application_agency_pends—app_pends_application_idx -
reopen family —
reopen_episodes_one_open,reopen_episodes_idempotency_key,reopen_episodes_application_idx,reopen_attestations_application_idx,reopen_sagas_due_idx -
postponement family —
postponement_episodes_one_open,postponement_episodes_idempotency_key,postponement_episodes_application_idx,postponement_episodes_determination_idx,postponement_episodes_conversion_determination_idx,postponement_sagas_due_idx -
day30_shadow_findings—idx_day30_shadow_run_day(plus the table’sUNIQUE (application_id, program, run_day)) -
representatives family —
auth_reps_household_idx,auth_reps_person_idx;rep_disq_one_open_bar,rep_disq_pending_idx,rep_disq_in_effect_idx, therep_disq_no_overlapEXCLUDE;rep_scope_suspended_by_idx;rep_disq_notice_recipients_disq_idx,rep_disq_one_initial_rep_letter -
household_assignments—household_assignments_active_uniq,household_assignments_by_worker_active,household_assignments_by_household_active -
application_sections—application_sections_unique,application_sections_app_program_idx,application_sections_last_edited_by_idx -
credentials, drafts, recovery —
application_id_codes_code_idx;passcode_hashes_active_per_app;application_drafts_expires_idx;recovery_pending_active_per_app,recovery_pending_reveal_due_idx -
application_documents—application_documents_app_idx,application_documents_person_idx,application_documents_pending_idx,application_documents_scan_due_idx -
finalize_operations—finalize_operations_stuck_idx,finalize_operations_unreleased_idx -
event_outbox_*/event_inbox_*— the generated partial indexes, documented once on the data-models index;idx_idempotency_keys_created_at— runtime DDL beside its table
Migration files
The generated files — the eight outbox/inbox migrations (20260508000000, 20260516000000, 20260518004851, 20260713000000, 20260720000000, 20260803000000, 20260815000000, 20260904000000) and 20260905000000_create_scheduler_runs.sql — are documented once on the data-models index.
-
20260401000000_create_applications_tables.sql—applications,application_programs,authorized_representativesand their first indexes -
20260510000000_add_list_filter_indexes.sql— #402: the caseload-search partial indexes -
20260511000000_create_household_assignments.sql— #408:household_assignments -
20260601000000_create_application_sections.sql—application_sections -
20260601000001_extend_applications_status.sql—applications_status_check+application_programs_status_check -
20260602000000_create_application_id_codes.sql— ADR-026:application_id_codes -
20260602000001_create_passcode_hashes.sql— ADR-026:passcode_hashes -
20260602000002_extend_applications_notify_columns.sql—notify_email/notify_phone_e164 -
20260603000000_create_application_drafts.sql— ADR-026:application_drafts -
20260604000000_extend_applications_recovery_gate.sql— #634:confidentiality+recovery_locked -
20260604000001_create_recovery_pending.sql—recovery_pending -
20260605000000_create_application_documents.sql—application_documents -
20260714000000_create_finalize_operations.sql— ADR-038:finalize_operations -
20260714000001_create_finalize_steps.sql— ADR-038:finalize_steps -
20260722000000_finalize_steps_address_kind.sql—finalize_steps.remote_kindCHECK gainsaddress -
20260722000001_document_rejected_by.sql— #1009:application_documents.rejected_by -
20260723170000_v7_pk_defaults.sql— #1173: drops theiddefaults onhousehold_assignmentsandrecovery_pending(UUIDv7 bound at insert) -
20260808000000_v7_pk_defaults_remainder.sql— #1173: the same onapplication_sections,application_id_codes,passcode_hashes,application_documents -
20261106000000_document_scan_quarantine.sql— ADR-042 (#1006): the scan-queue columns, the seven state-machine CHECKs, thependingdefault, the legacy backfill,application_documents_scan_due_idx -
20261107000000_ufound_clock_split.sql— #1637:legal_filed_date/legal_filed_basis, the three-clock split onapplication_programs(the conflatedprocessing_deadlinedropped),idx_application_programs_workflow_clock -
20261124000000_application_interviews.sql— #1638:application_interviewsand its unique / chain-read indexes -
20261125000000_interview_nomi_stamps.sql— #1641:miss_kind,nomi_staged_at,nomi_source_event_id,uq_interviews_nomi_event,idx_interviews_nomi_scan -
20261126000000_sms_opt_in.sql— #1639:applications.sms_opt_in -
20261127000000_nomi_on_demand_scan.sql— #1639:idx_interviews_nomi_scan_od -
20261129000000_nomi_dispatched_stamp.sql— #1642:application_interviews.nomi_dispatched_at -
20261201000000_administrative_denials.sql— #788:administrative_denials, its uniques,application_programs.administrative_denial_id+ the either/or truth CHECK -
20261215000000_day30_shadow.sql— #1653:day30_shadow_findings,idx_day30_shadow_run_day,application_programs.disposition_reserved_at -
20261216000000_rep_program_scopes.sql— #1664:rep_kind/ organization columns,rep_disqualifications(btree_gist EXCLUDE),authorized_representative_program_scopes+ the all-programs backfill,auth_reps_person_idx -
20261218000000_rep_disqualification_notice_recipients.sql— #1666:rep_disqualification_notice_recipients -
20261219000000_day30_enforce.sql— #1654:application_agency_pends,application_programs.expedited_downgraded_at+ its index,day30_shadow_findings.applied -
20261220000000_reopen_substrate.sql— #1655:application_reopen_episodes,reopen_cure_attestations,reopen_sagas, theapplication_programsreopen/void columns and thevoidedstatus token -
20261221000000_reopen_activation.sql— #1656:application_reopen_episodes.idempotency_key,application_programs.voided_letter_event_id,application_interviews.waived_at -
20261222000000_reopen_void_audit.sql— #1656:closed_reasongainssuperseded_by_reopen;application_reopen_episodes.reopened_by_service+ck_reopen_episodes_actor_named(NOT VALID; restated VALID by20270113000000) -
20261223000000_postponement_episodes.sql— #1662:application_postponement_episodes,postponement_sagas,application_programs.active_postponement_episode_id+determination_basis_kind -
20261226000000_postponement_conversion_claim.sql— #1660: the conversion claim pair + settle triple and their CHECKs; the saga step CHECK gainsdispatch_conversion -
20261227000000_post_lapse_flag_index.sql— #1663:idx_application_programs_post_lapse_candidates -
20261228000000_application_kind.sql— #1728: the renewal identity onapplications,ck_applications_kind,ck_applications_renewal_identity,uq_applications_one_renewal_per_certification;ck_day30_findings_appliedadmitskind_deferred -
20261229000000_interview_context_recert.sql— #1729:ck_interviews_contextwidened tointake / recert+ the backfill of chains on recertification rows -
20261230000000_reopen_episode_kind.sql— #1731:application_reopen_episodes.kind, the namedck_reopen_episode_arm(A / B / R),ck_reopen_episode_kind_arm -
20261231000000_filing_receipt_rule_basis.sql— #1853:ck_applications_legal_filed_basisgainscalendar_day_receipt -
20270101000000_interview_completed_by.sql— #1734:applications.interview_completed_by_uuid -
20270102000000_administrative_denials_reopen_right_nullable.sql— #1997:reopen_deadline_dateDROP NOT NULL, the non-SNAP history correction,ck_administrative_denials_snap_reopen_right -
20270113000000_actor_subjects.sql— #1008: the 14 actor columns retyped toTEXTsubjects in one ordered, guarded pass — drop every CHECK naming a retyped column, retype (actor_uuid→actor,interview_completed_by_uuid→interview_completed_by, new_servicecolumns), rewrite a nil subject beside a named service to NULL + that service, a guard that aborts namingcargo xtask dev restarton any row nobody can attribute (a historicsystemdenial, a NULL interview actor, a nil subject with no service, an unattributed completion or cancel) and on any row whose UUID a service account’ssubmay have filled (everyapplication_sectionsrow — canopy-web’s section proxy wrote as its service identity — and every cancelledrep_disqualificationsrow — the service arm recorded the caller’ssub), then every CHECK re-added over the pair, all VALID -
20270114000000_reopen_pointer_on_live_row.sql— #2703: repairs any open reopen episode an inactive program row still points at (closedincomplete_closed,settled_at = now(), pointer cleared), then addsck_application_programs_reopen_pointer_live -
20270203000000_application_reported_income.sql— #2231:applications.reported_anyone_works+reported_income_sources,applications_reported_income_sources_check,applications_reported_income_pair_check -
20270212000000_decision_stamps_no_default.sql— #3014: drops the defaults of every decision stamp the service’s production INSERTs bind themselves:applications.submitted_at/received_at,administrative_denials.denied_at,application_agency_pends.pended_atandapplication_interviews.created_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) -
20270301000000_determination_projection.sql— #3202:application_programs.determination_request_idandrecord_back_refusal -
20270302000000_document_type_pack_owned.sql— #3497:application_documents.document_typeloses its list of codes (a length check, 1 to 64, replaces it); the pack's[[intake.document_types]]is the authority. -
20270303000000_reported_income_sources_pack_owned.sql— #3498:applications_reported_income_sources_checkis dropped; the pack's[[intake.reported_income_sources]]is the authority. The pair check stays.
All migrations are forward-only per ADR-016.