canopy-appeals Data Model

Cross-link: canopy-appeals API Reference · Source: migrations/

Tables

Table Purpose

appeal_requests

Fair-hearing request rows under 7 CFR 273.15. One row per hearing request. Carries the requestor (requestor_person_id), the CHECK-constrained program (typed Program vocabulary since #1098), the contested-record union (#1652: nullable determination_id / administrative_denial_id / rep_disqualification_id under the appeal_requests_contested_exactly_one CHECK — num_nonnulls(…) = 1; the admin arm additionally requires application_id via appeal_requests_admin_arm_has_application, since it is server-resolved from the denial record at filing; partial index idx_appeals_administrative_denial WHERE NOT NULL) plus optional application_id / notice_id / adverse_action_id (the id binding the appeal to an enrollment adverse action; NULL = narrative grievance), the request itself (request_date — server-stamped at filing, request_method), the hearing-scheduling triplet (hearing_scheduled_date, hearing_officer_id — TEXT since #1008, a referent holding the officer’s OIDC subject, decision_due_date — 60-day SOP per 7 CFR 273.15(c)(1), extendable via appeal_postponements; #1099 recomputed open rows off the wrong 90), the decision (decision_date, typed decision ∈ {upheld_agency, reversed_household, dismissed, legacy_unmapped} with the raw pre-#1099 value preserved in decision_legacy, decision_basis, decision_signed_date / decision_received_date — Chart B1’s case-action anchor — and decision_actor), the 7 CFR 273.15(j) dismissal fields (dismissal_basis ∈ {abandoned, federal_mass_change, untimely_request}, dismissal_good_cause), the withdrawal lifecycle block (withdrawal_method ∈ {written, oral}, withdrawal_stage ∈ {pre_submission, post_submission}, withdrawal_requested_date, withdrawal_confirmation_due, withdrawal_confirmation_sent_date, withdrawal_reinstate_by, withdrawal_finalized_date, withdrawal_actor; status gains withdrawal_pending, and ONLY finalization releases the enrollment stay), the cessation record (cb_cessation_reason ∈ {initial_decision, certification_end, federal_policy_change, mass_change, eligibility_change, withdrawal_finalized, final_decision} — withdrawal_finalized added by #1105 for the liable withdrawal disposition, final_decision by #1132 for the judicial outcome, cb_cessation_date — the ACTUAL stop date assessment windows end at), and the #1132 final-appeal block (decision_federal_policy_issue — the typed Chart B3 row-3 fact recorded at decision time, final_appeal_filed_date / final_appeal_actor / final_appeal_continuation — a timely filing with continuation supersedes the cessation back to NULL and re-grants the stay, final_appeal_decision ∈ {affirmed, reversed} with final_appeal_decision_received_date / final_appeal_decision_actor). Continued benefits are the #1098 Chart B2 election block: cb_election state machine (granted_timely / granted_reinstate / granted_legacy — pre-#1098 grant, no action binding or stay receipt — / pending_stay / pending_good_cause / waived / not_electable / not_applicable), plain continued_benefits_eligible (written by the election engine — replaced the pre-#1098 GENERATED column, whose request_date < adverse_action_effective_date rule could never fire for adequate notices), cb_waived (Form 118), cb_good_cause, cb_repayment_disclosed, cb_election_deadline, cb_reinstate_by (5 working days, adequate path), the persisted stay receipt (cb_stay_link_status ∈ {stayed, restayed, released, vetoed} — restayed is the #1263 final-appeal stay era, migration 20260821000000_restayed_receipt_status.sql; cb_stay_receipt_at), the continued_benefits_granted / continued_benefits_start_date / continued_benefits_end_date triple, and the post-decision overpayment hook (overpayment_amount, overpayment_claim_id).

appeal_postponements

#1099: household-requested postponements of the 60-day decision SOP. One append-only row per postponement (days > 0, reason, requested_by, created_at); each also advances the parent appeal’s decision_due_date.

appeal_timeline_events

Per-appeal event log. One row per state transition or operator note tied to an appeal — request received, hearing scheduled, hearing held, decision rendered, etc. Carries event_type, event_date, the actor pair recorded_by / recorded_by_service (#1008: a human’s OIDC subject or a service principal, exactly one — ck_appeal_timeline_events_recorded_by_one_actor, num_nonnulls(…) = 1), and free-text notes. Append-only.

cb_assessments (#1104)

The continued-benefits overpayment assessment as a recorded entity — replaces the overpayment_amount-as-sentinel model (a Decimal stamped iff > 0, which silently erased zero-dollar assessments; assessed_cents >= 0 and zero persists as a completed row with no claim projected). Window: window_start (CB start) to the RECORDED cessation_date + typed cessation_reason — never a formula. liable_person_id is the head-of-household snapshot (the adverse action’s recipient), immutable once written. The retention snapshot pins the enrollment state the assessment excluded retained issuances at: enrollment_id, lifecycle_revision, partial_retention, retained_through. status ∈ {computed, applied, void} — #1105: computed → applied flips when the program service’s *.overpayment_claimed acknowledgment lands (zero-dollar applies immediately: no claim to confirm); assessments still computed past the grace window are swept by the acknowledgment scanner (partial index idx_cb_assessments_unacked) and their claim event re-emitted. Since #1224 (ADR-001 Amendment 1 §B6-iii) both the acknowledgment and dead-action sweeps are PROGRESSING-CURSOR revisits: each orders by / advances its own mutable cursor (claim_reemitted_at / action_verified_at, NULLS FIRST so new rows jump the queue; partial indexes idx_cb_assessments_reemit / idx_cb_assessments_action_verify) — every active assessment is revisited within the configurable CANOPY_APPEALS__ASSESSMENT_REVISIT_SLA_SECS (default 1 day), where the pre-#1224 frozen ORDER BY created_at LIMIT 200 re-checked the same oldest rows forever. Rows past the SLA feed the canopy_appeals_assessments_past_revisit_sla alarm gauge. allocation_version bumps on allocation supersession (the household advisory lock is what serializes allocation rounds); voids carry voided_at + void_reason ∈ {veto, action_canceled, reallocation}. Partial UNIQUE (appeal_id) WHERE status <> 'void' — one active assessment per appeal; supersession = void + successor. Cross-service ids (adverse_action_id, enrollment_id) are application-level only (ADR-001).

cb_assessment_lines

Per-issuance itemization under an assessment. window lines carry the allocation (billed unless PAMMS-2415 retained or zero); post_cessation lines itemize issuances after the recorded cessation (itemized — recorded for Chart B1 claim-ability, never silently billed); already_billed marks window issuances another assessment holds; released frees a billed line when its assessment is voided (flipped in the void tx). Partial UNIQUE (issuance_id) WHERE disposition = 'billed' is the mechanical billable-once backstop: an issuance is billable once across ALL assessments, DB-enforced. UNIQUE (assessment_id, issuance_id); carries benefit_month, actual issued_at (the post-cessation classifier), amount_cents.

assessment_work

The #1105 worker’s queue (live since #1105), on the #1091 notice_work_items pattern: enqueued in the decision tx (decision_cessation / dismissed) or the fenced withdrawal-finalization tx (withdrawal_finalized — a liable disposition, which also records the cessation at the next issuance cycle), by the backfill sweep (backfill), or by an allocation displacement (reallocation — resets ONLY terminal items). Claimed FOR UPDATE SKIP LOCKED with a 10-minute stale-lease reclaim (claimed_at/claimed_by/heartbeat_at); attempts increments AT claim time so crash loops still converge on the 8-attempt budget; external HTTP outside any tx; the apply commits in one short tx under the per-household allocation lock. due_at carries the exponential backoff (60s·2^attempts, 6h cap) and the future-cessation / pending-EBT deferrals; terminal status ∈ {pending, done, failed} (failed is the operator surface — the backfill sweep never re-enqueues it) with a pruning index. UNIQUE (appeal_id) — a redelivered trigger can never mint a second assessment run; assessment_id links the result.

ipv_cases

Intentional Program Violation case file under 7 CFR 273.16. One row per IPV referral. Carries the subject (person_id, household_id), the program, the allegation (allegation_type ∈ {fraud, misrepresentation, concealment, trafficking}, allegation_description, evidence_summary), the referral (the actor pair referred_by / referred_by_service — #1008: the referring caseworker’s OIDC subject or the calling service, exactly one, ck_ipv_cases_referred_by_one_actor — and referred_at), the calculated overissuance_amount with the benefit months it covers (overissuance_first_month, overissuance_last_month, each a first of the month; ipv_cases_overissuance_period_with_amount holds amount and period present together or absent together, #3566, 20270410000000_ipv_overissuance_period.sql, which fails on a database holding an amount with no period), the referring worker's QC-origin attestation discovered_in_qc_review (#2444: whether a quality control review discovered the over-issuance; NULL only on a referral recorded before the column, which reads as unrecorded, never as false), and the ADH lifecycle (status ∈ {referred, adh_scheduled, adh_notice_sent, adh_completed, waiver_accepted, court_referred, disqualified, cleared, withdrawn}; adh_scheduled_date, adh_notice_sent_at, adh_decision, adh_decision_at). On a sustained IPV, disqualification_start_date / disqualification_end_date plus disqualification_offense_number (1st / 2nd / 3rd offense, drives the escalating penalty under 7 CFR 273.16(b)) and the historical prior_ipv_count are set.

ipv_timeline_events

Per-IPV-case event log. One row per state transition or operator note tied to an IPV case. Carries event_type, structured event_data (JSONB), occurred_at, and the actor pair recorded_by / recorded_by_service (#1008: exactly one — ck_ipv_timeline_events_recorded_by_one_actor). Append-only.

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-appeals both publishes and subscribes (boot.subscriber.subscribe(…​) in services/canopy-appeals/src/main.rs), 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-appeals.scheduler, canopy-appeals.reconciliation). Schema single-sourced in crates/canopy-db/scheduler-migrations/ and parity-gated by cargo xtask outbox-migrations; documented ONCE in the data-models index.

Relationships

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

Diagram

assessment_work.assessment_id points at cb_assessments without a FK (migration 20260727000000_cb_assessment_schema.sql); ipv_cases and appeal_requests are unrelated tables that share only the program vocabulary.

Cross-service FKs (ADR-001 boundary)

Per ADR-001, canopy-appeals holds no Postgres-level foreign keys to other services. Every UUID the schema holds that is not one of the intra-database FKs above is an application-level reference canopy-appeals trusts the upstream service to supply and never enforces in canopy_appeals: household and person ids (canopy-persons), application_id (canopy-applications), the contested-record union determination_id / administrative_denial_id / rep_disqualification_id (the program service / canopy-applications, #1652), notice_id (canopy-notices), adverse_action_id, enrollment_id and issuance_id (canopy-enrollment), liable_person_id, and overpayment_claim_id (the program service’s overpayment table). Worker identities are not UUIDs at all (#1008): hearing_officer_id and the subject half of each actor pair are TEXT OIDC subjects issued by the IdP, and the _service half names a service principal.

Retention

Retention floors (eCFR, checked 2026-09-16): continued-benefits records under 7 CFR 273.15(k) and IPV / ADH records under 7 CFR 273.16 are due-process artifacts with no archival ceiling. Operational retention is the maximum of (a) no less than 3 years from the month of origin of each record (7 CFR 272.1(f)), (b) the disqualification end date plus 3 years for IPV cases, and (c) any pending appeal or civil-rights proceeding referencing the row. Rows are not deleted in production; archive moves are operator-driven, never migration-driven (ADR-016). The FTI audit hash chain (ADR-014) does not apply — canopy-appeals stores no FTI. State series: Georgia Archives, DHS retention schedule (agency 144), series 1973-0344 "Fair Hearing Case Record Files", 3 years, for the hearing rows, and series 1973-0358A "Public Assistance and Food Stamp Suspected Fraud Closed Case Files", 3 years after determination that case is closed, uncollectible, or paid in full, for the IPV / ADH rows — https://www.georgiaarchives.org/records/agencyprint/144 (checked 2026-09-18). The hearing series does not exceed the federal 3-year floor, so 7 CFR 272.1(f) governs the hearing rows; the fraud series runs from case closure or collection rather than from the month of origin, so whichever of it and the federal window ends later governs an IPV row.

Indexes

  • idx_appeals_household — household-scoped appeal lookup

  • idx_appeals_status (partial, (status, decision_due_date) WHERE status IN ('pending','scheduled')) — the 60-day decision-clock work queue (7 CFR 273.15(c)(1); #1099)

  • idx_appeals_determination — appeals-by-determination lookup (notice cross-link)

  • idx_appeals_adverse_action (partial, WHERE adverse_action_id IS NOT NULL) — the per-action appeal lookup (#1098)

  • idx_appeals_pending_stay (partial, (created_at) WHERE cb_election = 'pending_stay' AND active) — the stay-receipt reconciliation scan (#1098)

  • idx_appeals_administrative_denial (partial, WHERE administrative_denial_id IS NOT NULL) — the admin-arm lookup of the contested union (#1652)

  • idx_appeal_timeline_appeal — per-appeal timeline scan, (appeal_id, event_date)

  • idx_appeal_postponements_appeal — per-appeal postponement list (#1099)

  • idx_ipv_cases_person — person-scoped IPV history

  • idx_ipv_cases_household — household-scoped IPV lookup

  • idx_ipv_cases_status (partial, WHERE active = true) — active-case work queue

  • idx_ipv_timeline_case — per-IPV-case timeline scan, (ipv_case_id, occurred_at)

  • idx_cb_assessments_one_active_per_appeal (UNIQUE partial, (appeal_id) WHERE status <> 'void') — one active assessment per appeal; supersession = void + successor (#1104)

  • idx_cb_assessments_household (partial, WHERE status <> 'void') — household-scoped active assessments

  • idx_cb_assessments_action — assessments by adverse action

  • idx_cb_assessments_unacked (partial, (updated_at) WHERE status = 'computed') — the acknowledgment scanner’s grace-window sweep (#1105)

  • idx_cb_assessments_action_verify (partial, (action_verified_at ASC NULLS FIRST) WHERE status <> 'void') — the dead-action sweep’s progressing cursor (#1224)

  • idx_cb_assessments_reemit (partial, (claim_reemitted_at ASC NULLS FIRST) WHERE status = 'computed') — the acknowledgment sweep’s progressing cursor (#1224)

  • idx_cb_lines_billable_once (UNIQUE partial, (issuance_id) WHERE disposition = 'billed') — the billable-once backstop: an issuance is billable once across all assessments

  • idx_cb_lines_assessment — per-assessment line list; the table also carries UNIQUE (assessment_id, issuance_id)

  • idx_assessment_work_due (partial, (due_at) WHERE status = 'pending') — the worker’s claim scan

  • idx_assessment_work_terminal (partial, (status, updated_at) WHERE status <> 'pending') — the pruning scan; appeal_id is also UNIQUE

  • 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_appeals_tables.sql — fair-hearing schema (appeal_requests with continued_benefits_eligible GENERATED STORED column, appeal_timeline_events; status + determination indexes)

  • 20260402000000_create_ipv_tables.sql — IPV / ADH schema (ipv_cases, ipv_timeline_events; status + allegation CHECK constraints)

  • 20260725000000_action_bound_filing.sql — #1098: adverse_action_id, the Chart B2 cb_* election block, the GENERATED continued_benefits_eligible replaced by a plain backfilled column, the program CHECK, and the pending-stay / per-action indexes

  • 20260726000000_decision_withdrawal_lifecycle.sql — #1099: decision signed/received dates + actor, the typed decision vocabulary (legacy values mapped, unknowns quarantined in decision_legacy / legacy_unmapped), 7 CFR 273.15(j) dismissal fields, the withdrawal lifecycle columns, the cessation record, the appeal_postponements table, and the 60-day due-date recompute for open rows

  • 20260727000000_cb_assessment_schema.sql — #1104: the cb_assessments / cb_assessment_lines / assessment_work entity trio — recorded-cessation windows, the billable-once partial unique, post-cessation itemization, the one-active-per-appeal partial unique, and the UNIQUE-per-appeal work queue

  • 20260728000000_assessment_worker_cutover.sql — #1105: withdrawal_finalized joins both cessation-reason CHECK vocabularies (a liable withdrawal disposition records a cessation), plus the acknowledgment scanner’s idx_cb_assessments_unacked partial index

  • 20260811000000_final_appeal_continuation.sql — #1132: the final-appeal block on appeal_requests (decision_federal_policy_issue, final_appeal_filed_date / final_appeal_actor / final_appeal_continuation, final_appeal_decision ∈ {affirmed, reversed} + its received date / actor); final_decision joins both cessation-reason CHECKs and final_decision_cessation joins the assessment_work.trigger_kind CHECK

  • 20260821000000_restayed_receipt_status.sql — #1263: restayed joins the cb_stay_link_status CHECK (stayed / restayed / released / vetoed) — the final-appeal stay era

  • 20260903000000_cb_assessment_sweep_cursors.sql — #1224 (ADR-001 Amendment 1 §B6-iii): the per-sweep progressing cursors (action_verified_at, claim_reemitted_at) + their NULLS FIRST partial indexes; transactional CREATE INDEX (not CONCURRENTLY — the sqlx migrator’s advisory lock deadlocks against CONCURRENTLY's snapshot wait)

  • 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

  • 20260906000000_appeal_contested_union.sql — the #1652 contested three-arm union: determination_id nullable, administrative_denial_id + rep_disqualification_id columns, the exactly-one and admin-arm-has-application CHECKs, the admin-arm partial index

  • 20270113000000_actor_subjects.sql — #1008: hearing_officer_id to TEXT; ipv_cases.referred_by (NOT NULL dropped), appeal_timeline_events.recorded_by and ipv_timeline_events.recorded_by to TEXT plus a _service column each and the three = 1 actor-pair CHECKs. Its guard refuses a database holding a timeline row with no recorded actor (every pre-#1008 timeline writer passed NULL) or a nil-UUID subject — the remedy is the reset it names, cargo xtask dev restart, never a backfill

  • 20270307002444_ipv_referral_qc_origin.sql — #2444: the nullable ipv_cases.discovered_in_qc_review, with no default and no backfill, so a referral from before it stays unrecorded

  • 20270330000000_appeal_wic_termination_arm.sql — #3387: the fourth contested arm appeal_requests.wic_termination_id (the exactly-one CHECK replaced to count it); wic_hold_state (held or released: the appeal's hold in canopy-wic as its last receipt reported it, NULL when it never held); wic_hold_command (release or cancel) and wic_hold_command_at, the command the appeal still owes canopy-wic and since when, set together (appeal_requests_wic_hold_command_at_check) and cleared by the receipt; appeal_requests_wic_hold_arm_check (only the WIC arm holds or owes); and the partial index idx_appeals_wic_hold_command_owed, the hold retry's queue

All migrations are forward-only per ADR-016.

Edit this page · default