canopy-eligibility Data Model
Cross-link: canopy-eligibility API Reference · Source: migrations/
Tables
| Table | Purpose |
|---|---|
|
Root orchestration record. One row per cross-program eligibility run, keyed by |
|
The determinations of record (ADR-002 Amendment 5): one row per program envelope whose signature verified and that bound to its dispatch; |
|
One row per envelope the orchestrator did not record: its signature did not verify, or it verified and did not bind (the claimed program, application or household differs from the dispatch, a SNAP/TANF envelope names a subject, a Medicaid or CHIP envelope does not sign the dispatch’s claimed operation, or on the bulk arm the case’s supersession link or the run’s pins differ). |
|
The append-only operator ledger over |
|
The append-only operator ledger over determinations whose completion events a program service holds because canopy-eligibility never recorded them (ADR-002 Amendment 8): one row per adopt or drop, written in the transaction that stages its verdict (an adopt’s |
|
The #788 claim ledger for the interactive/order arms: one row per claimed |
|
One claimed determination operation per order epoch and program, on the order ledger: |
|
The durable single-case order substrate — ADR-002 Amendment 1’s Order arm (#575). One row per requester-identified async determination order; |
|
Assembled cross-program result for one run. One row per |
|
One row per bulk run: state machine ( |
|
One row per cohort member: |
|
THE durable ledger: |
|
Append-only attempt audit: real attempts carry a partial-unique ordinal per
|
|
The operator ledger: actor, actual privilege, reason, from/to states, typed detail. Immortal. A row commits in the transaction that makes the transition it records (#3242). |
|
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):
determination_orders, determination_order_operations and determination_operations carry no FK (determination_order_operations keys by the order’s origin and links to determination_operations.id by value): determination_orders.eligibility_request_id links the admitted run, and cohort_case_results.determination_id / program_determinations.operation_id / quarantine_resolutions.determination_id / held_determination_resolutions.determination_id link across tables by value only (migrations 20261120000000, 20261125000000, 20261204000000, 20270112000000, 20270301000000).
Cross-service FKs (ADR-001 boundary)
Per ADR-001 no foreign key crosses a service boundary; the only DB-level FKs are the intra-database ones drawn above. Every UUID that points outside canopy_eligibility — application_id (canopy-applications) and household_id (canopy-persons) on eligibility_requests, program_determinations, quarantined_determinations, combined_results, cohort_cases and determination_orders, person_id on program_determinations, and the origin_ref / successor_determination_id correlation ids — is an application-level reference: canopy-eligibility trusts the caller and the BFFs to supply real IDs but does not enforce existence. Per ADR-002 the orchestrator never persists raw program inputs: program_determinations stores only each program service’s signed, JWS-verified determination envelope, and quarantined_determinations only the signed bytes of an envelope it refused.
Retention
Retention floors (eCFR, checked 2026-09-16): canopy-eligibility holds no FTI or PHI — the envelopes it persists are program outputs (ADR-002), so the Pub 1075 / HIPAA floors live with the program services (canopy-tanf, canopy-medicaid). The program floors that govern the envelopes: SNAP program records no less than 3 years from the month of origin of each record (7 CFR 272.1(f)); Medicaid the active case plus a minimum of 3 years (42 CFR 431.17(c)(1)) and fiscal records 3 years from submission of the final expenditure report, longer while audit findings are unresolved (42 CFR 433.32(b)–(c)); TANF has no program-specific retention section — the HHS award-record floor is 3 years from 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); CCDF 3 years from submission of the financial reports (45 CFR 98.90(e)). The longest applicable floor governs a multi-program deployment. State series, one per program (Georgia Archives, checked 2026-09-18): DHS retention schedule (agency 144) — https://www.georgiaarchives.org/records/agencyprint/144 — series 1976-0110 "Food Stamp Administrative Files" (3 years) for SNAP, 1973-0476 "Public Assistance Authorization Files" (3 years or until resolution of audit, whichever is longer) for TANF and 1982-0547 "Public Assistance Client Medical Eligibility Closed Case Files" (Central Medical Eligibility Office, 3 years after the client is no longer eligible for assistance) for Medicaid; DECAL retention schedule (agency 157) — https://www.georgiaarchives.org/records/agencyprint/157 — series 0469-06-003 "Childcare and Parent Services (CAPS)" (3 years after the end of the calendar year) for CCDF. Each state series matches its federal floor’s 3-year length and differs only in trigger (audit resolution, end of eligibility, calendar year-end), so the later-ending of the state and federal windows governs each envelope. Rows are not deleted in production; archive moves are operator-driven, never migration-driven (ADR-016).
Indexes
-
idx_eligibility_requests_application— request lookup by application -
idx_eligibility_requests_household— request lookup by household -
idx_eligibility_requests_status— status filter on the orchestration queue -
idx_unique_pending_request(unique, partial,WHERE status IN ('pending','in_progress'), migration 20260402000000) — prevents duplicate concurrent runs for the same(application_id, household_id) -
idx_program_determinations_request— per-run determination fan-in -
idx_program_determinations_program— program filter across determinations -
idx_program_determinations_application— determination lookup by application -
idx_program_determinations_household_determined_at(migration 20260804000000) — newest-first case-status lookup per household (#1196; the history is append-only and unbounded, so this read must stay index-scan class) -
idx_program_determinations_household_program_determined_at(migration 20260804000000) — the #694 program-scoped case-status variant; also the leading-column match for the #2178 newest-per-program read (LATEST_DETERMINATIONS_BY_HOUSEHOLD_SQL, whoseid DESCtiebreak the index does not carry — its EXPLAIN pin indetermination_index_scan_test.rsallows the resulting sort) -
idx_program_determinations_alert_status_v2(partial,(determined_at DESC, id DESC) WHERE status IN ('denied', 'sanctioned'), rebuilt by migration 20270111000000 without the oldAND signature_verifiedterm and the four pruned tokens) — cross-program alerts panel feed; superseded the status-onlyidx_program_determinations_alert_status(20260804000000, dropped by 20260819000000); the predicate must stay in lockstep withlist_recent_alert_determinationsor the planner stops substituting it (pinned by the EXPLAIN regression test indetermination_index_scan_test.rs) -
idx_program_determinations_alert_household(partial,(household_id, determined_at DESC, id DESC)with the same alert predicate, rebuilt by 20270111000000) — the household-scoped alerts variant -
idx_quarantined_determinations_received(received_at, id)— the open-worklist keyset;idx_quarantined_determinations_household(household_id)— the supersession probe (#2061) -
quarantine_resolutions_one_per_revision(UNIQUE(quarantined_id, revision));quarantine_resolutions_one_dismiss(UNIQUE partial,(quarantined_id) WHERE action = 'dismiss') — at most one dismiss per envelope;quarantine_resolutions_one_promotion(UNIQUE partial,(quarantined_id) WHERE action = 'reverify' AND determination_id IS NOT NULL) — at most one promotion per envelope (#2061) -
held_determination_resolutions_determination_id_key(UNIQUE(determination_id)) — one resolution per determination (#3065) -
idx_combined_results_request— combined result by run -
idx_combined_results_application— combined result by application -
idx_combined_results_household— combined result by household -
idx_eligibility_requests_bulk_case(partial,WHERE bulk_case_id IS NOT NULL) andidx_unique_pending_bulk_case(UNIQUE partial,(bulk_case_id) WHERE status IN ('pending','in_progress')) — the #1213 bulk pair: one live request per cohort case -
idx_eligibility_requests_origin(partial,(origin_source, origin_ref) WHERE origin_ref IS NOT NULL) — the #1504 order-to-request correlation -
program_determinations_request_program_subject_uniq(UNIQUE NULLS NOT DISTINCT (eligibility_request_id, program, person_id), migration 20260616120000) — one determination row per subject per (request, program) (ADR-035 Decision 6) -
program_determinations_operation_subject_uq(UNIQUE partial,(operation_id, person_id) NULLS NOT DISTINCT WHERE operation_id IS NOT NULL) — an operation settles into at most one row per subject (#2673; it replaced #788’sprogram_determinations_operation_uqon(operation_id), which would refuse the second subject of a canopy-medicaid dispatch now that every subject’s envelope signs the operation; a household program’s NULL subject keeps one row per operation) -
cohort_runs_single_active_uq(UNIQUE partial over the constant(1),WHERE state NOT IN ('completed','completed_with_failures','canceled','failed')) — the fleet holds ONE active cohort run -
cohort_cases_state_idx(run_id, state);cohort_cases_due_idx(partial,(run_id, next_attempt_at) WHERE state IN ('pending','failed_retryable')) — the dispatcher’s due scan;cohort_cases_dispatched_idx(partial,WHERE state = 'dispatched') — the stale-dispatch re-arm;cohort_cases_failures_idx(partial,(run_id, seq) WHERE state IN ('failed_terminal','skipped_superseded')) — the failure listing -
cohort_case_attempts_real_uq(UNIQUE partial,(case_id, phase, dispatch_generation, attempt_no) WHERE attempt_no IS NOT NULL) — one real attempt per ordinal;cohort_case_attempts_breaker_idx(partial,(run_id, phase, finished_at DESC, id DESC)excluding yields and late-dropped settles) — the failure-rate breaker window -
cohort_run_actions_run_idx(run_id, created_at)— the operator ledger read -
determination_orders_due_idx(partial,(next_attempt_at) WHERE state IN ('pending','failed_retryable') AND attempt_started_at IS NULL) — the order sweep;determination_orders_claimed_idx(partial,WHERE attempt_started_at IS NOT NULL) — the stale-claim re-arm; the table also carriesUNIQUE (origin_source, origin_ref)(#1504) -
determination_operations_open_uq(UNIQUE partial,(application_id, program) WHERE settled_at IS NULL) — ONE open claim per pair (#788) -
determination_order_operations_epoch_uq(UNIQUE,(origin_source, origin_ref, program_epoch, program)) — one operation per order epoch and program (#2652) -
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:
-
20260326000000_create_eligibility_tables.sql— original orchestrator schema (eligibility_requests,program_determinations,combined_results) plus base lookup indexes -
20260402000000_add_constraints.sql—eligibility_requests_status_checkclosed-set status constraint +idx_unique_pending_requestpartial unique index (test-coverage-audit hardening) -
20260616000000_add_person_id_to_program_determinations.sql— ADR-035 Slice 1 (#857): nullableprogram_determinations.person_idper-subject column; NULL = household-level subject (SNAP/TANF), never the head’s id -
20260616120000_add_program_determination_subject_unique.sql— ADR-035 Decision 6:program_determinations_request_program_subject_uniq,UNIQUE NULLS NOT DISTINCT (eligibility_request_id, program, person_id)— one determination row per subject per (request, program) -
20260804000000_pd_lookup_indexes.sql— the three #1196program_determinationslookup indexes. Deliberately transactional (NOTCONCURRENTLY): sqlx serializes concurrent migrators on a per-database advisory lock, and a second booting replica blocks on it holding the very snapshotCONCURRENTLYwaits out — a reproduced hard deadlock whose victim can be the build itself, stranding an INVALID index behindIF NOT EXISTS. Operators upgrading an already-huge live table pre-create the same indexesCONCURRENTLYout of band (verifypg_index.indisvalid), and the migration no-ops -
20260819000000_alert_indexes_scoped_and_verified.sql— #596:idx_program_determinations_alert_status_v2(addsAND signature_verified+ anid DESCtiebreak to the alert predicate) and the household-scopedidx_program_determinations_alert_household; drops the superseded v1idx_program_determinations_alert_status. Non-CONCURRENTLYfor the same advisory-lock rationale as 20260804000000 -
20261120000000_cohort_runs.sql— #1213: the cohort-run substrate —cohort_runs,cohort_cases,cohort_case_results,cohort_case_attempts,cohort_run_actions(+ the single-active-run partial unique);eligibility_requestsgainsbulk_case_id/bulk_program_epoch;program_determinationsgainstrigger/policy_target(the five cohort rows in the Tables list) -
20270107000000_cohort_runs_excluded_expedited.sql— #806:cohort_runs.excluded_expedited(BIGINT NOT NULL DEFAULT 0, CHECK ≥ 0) — the universe rows excluded at admission -
20261125000000_determination_orders.sql— #1504: thedetermination_orderstable + its due / stale-claim partial indexes;eligibility_requestsgains theorigin_source/origin_refcorrelation pair (both-or-neither CHECK + partial index) -
20261203000000_pd_policy_target_provenance.sql— #1479:program_determinations.evaluated_as_of DATE— the #1467 attestation’s evaluation date; no backfill (NULL = no signed attestation arrived) -
20261204000000_uprov_b_determination_operations.sql— #788: thedetermination_operationsclaim ledger + open-claim partial unique;program_determinationsgains the nullable provenance trio (effective_date_basis,benefit_effective_date,operation_id+ its partial-unique);cohort_casesgains the bulk mint trio (stamped write-once at the claim; since #806 the claim mints the operation id andfreeze_provenancestamps the basis + anchor after the live read) -
20270101000000_program_extension.sql— #1709:program_determinations.program_extension JSONB NULL— the signed envelope’s program-specific payload persisted as it arrived (medicaidassigned_coa, snapfollowing_month), so the verified envelope stays reconstructable from the row; NULL = pre-#1709 / no-extension / bulk-adopted, never backfilled -
20270102000000_signed_envelope_columns.sql— #1764: the last signed inputs the row could not supply —program_determinationsgainssnapshot_hash TEXT NOT NULL,denial_reason_codes TEXT[]andprevious_determination_id UUID.snapshot_hashlands NOT NULL because the envelope field is a requiredString; the cutover is the one canopy-snap’s20260810000000_snapshot_hash_not_null.sqlset in #911 — clear thecohort_case_resultsledger rows that point at them (no FK exists ondetermination_id), then delete everyprogram_determinationsrow lacking the hash, thenSET NOT NULL. On any pre-#1764 database that empties both tables: no production data exists pre-1.0 and the devstack re-seeds. No FK, no CHECK, no backfill -
20270111000000_quarantined_determinations.sql— #2061: a delete cutover —cohort_case_resultsthenprogram_determinationsare emptied (no stored row carries the bytes that verified; devstacks refill through the e2e reseed);program_determinationsgainssigned_payload BYTEA NOT NULLand dropssignature_verified; the two alert partial indexes are rebuilt onstatus IN ('denied', 'sanctioned'); thequarantined_determinationstable with its two indexes -
20270111000001_determination_status_check.sql— #628: deletes anyprogram_determinationsrow outsideapproved / denied / sanctioned(itscohort_case_resultsrows first) and addsprogram_determinations_status_verdict; clears an out-of-vocabularycohort_casespreview (the pair, its amounts andpreviewed_atgo NULL; the case stays) and adds the two preview CHECKs -
20270112000000_quarantine_resolutions.sql— #2061: thequarantine_resolutionsledger with its CHECKs, unique indexes and append-only trigger -
20270113000000_determination_order_operations.sql— #2652: thedetermination_order_operationsorder-ledger table (v7operation_idPK, the per-(origin, epoch, program) unique) that pins every execution of an order epoch to one claimed operation per program -
20270207000000_program_determinations_operation_subject.sql— #2673:program_determinations_operation_uqon(operation_id)becomesprogram_determinations_operation_subject_uqon(operation_id, person_id) NULLS NOT DISTINCT, one row per operation and subject -
20270208000000_quarantine_dispatched_operation.sql— #2319:quarantined_determinations.dispatched_operation_id UUID(nullable, no backfill), the dispatch’s claimed operation a reverify binds -
20270211000000_decision_stamps_no_default.sql— drops the defaults of every decision stamp the service’s production INSERTs bind from the run’s instant:program_determinations.received_at/created_at,combined_results.assembled_at/created_atandquarantined_determinations.received_at(bound byquarantine_bytessince #3013). An insert that names no stamp now fails instead of taking the database clock, andcargo xtask migrations-lintrefuses a new clock default (#3013). The file’s header lists the clock defaults that stay -
20270301000000_held_determination_resolutions.sql— #3065: theheld_determination_resolutionsledger with its CHECKs, its uniquedetermination_idand its append-only trigger -
20270302000000_determination_operations_request.sql— #3065:determination_operations.eligibility_request_id UUID(nullable, no FK, no backfill), the claiming run’s request, which a held adoption routes by -
20270324000000_determination_status_withheld.sql— ADR-052: replacesprogram_determinations_status_verdictand the twocohort_cases_preview_*_status_verdictconstraints so the list also admitswithheld; no row is rewritten. -
20270325000000_program_determination_extension.sql— ADR-052: addsprogram_determinations.extension(JSONB, nullable), the signed envelope's record of the extension module that took part, so the row still rebuilds to the signed bytes.NULLis an envelope no module took part in.
All migrations are forward-only per ADR-016.