canopy-verification Data Model

For a contributor reading canopy_verification: the tables in effect, their policy-bearing columns and CHECKs, the one intra-database FK, and the complete migration inventory. Routes live on canopy-verification API Reference; source: migrations/.

Tables

Table Purpose

verifications

Verification work items — one row per task, written by the batch POST /v1/verifications/requests written-request endpoint (#1643), whose producers are canopy-applications' postponement saga and canopy-web’s request-verification action (canopy-eligibility’s registration was deleted with #628). Cross-service keys application_id / household_id / person_id (application-level only), verification_type (plain TEXT, no CHECK — the BFF’s jurisdiction allowlist is the only gate), requested_at (no DEFAULT since #1685: the writer stamps the decision-clock instant), due_date, and the completion lifecycle completed_at / completed_by / completed_by_service / notes. status CHECK pending / in_progress / completed / cancelled. The request-context columns (NULL on legacy rows, never backfilled): program (canopy-reference token, no CHECK), purpose CHECK eligibility_critical / deduction_only (derived server-side, never caller-supplied), the episode pair episode_kind CHECK intake / agency_pend / reopen / expedited_postponement / mid_certification + episode_id (ck_verifications_episode_pair: both or neither), notice_ref (checklist or covered_by_other_notice:<ref>), the dispatch pair checklist_event_id + request_dispatched_at, due_date_anchor CHECK requested / dispatched / caller (requested is provisional and display-only; only dispatched / caller due dates are enforceable), the pinned window response_days + policy_version (7 CFR 273.2(f); ck_verifications_provisional_window: a requested anchor always carries response_days), and the cancel columns cancelled_at / cancelled_by / cancelled_by_service / cancel_reason CHECK superseded_by_reopen / postponement_reverted / application_voided / requested_in_error / superseded_by_postponement, written by the cancel surfaces POST /v1/verifications/{id}/cancel and POST /v1/verifications/cancel-open (#1645). Since #1008 each actor is an optional pair (TEXT): completed_by / cancelled_by hold a human’s OIDC subject and completed_by_service / cancelled_by_service a service principal. ck_verifications_completed_by_one_actor / ck_verifications_cancelled_by_one_actor (num_nonnulls(…) ⇐ 1) forbid both, and ck_verifications_completed_by_with_act / ck_verifications_cancelled_by_with_act ((completed_at IS NULL) = (num_nonnulls(completed_by, completed_by_service) = 0), the same over cancelled_*) make an actor present exactly when the act happened. Open items dedup on the partial unique verifications_open_natural_key_v2_uq over (application_id, household_id, program, verification_type, COALESCE(person_id, zero-uuid)); purpose and episode are deliberately outside the key (purpose escalates monotonically; an older episode’s open row satisfies a newer episode’s need, and a covered-mode request with an earlier notice date adopts the episode in place — #1698). No soft-delete; terminal states are completed / cancelled.

ievs_hits

IEVS adapter callback results, one row per match: the cross-service application_id / household_id / person_id, the denormalized member_name, source, hit_type, hit_at, the raw adapter payload JSONB (the whole serialised adapter record — WageRecord, UiRecord, SsaSdxRecord or SsaBendexRecord from canopy-contracts-verification — written by persist_hit, services/canopy-verification/src/api/ievs.rs; NULL only on a serialise failure), and the review lifecycle status (CHECK unreviewed / reviewed / resolved / false_positive, default unreviewed), reviewed_at, reviewed_by (TEXT since #1008: a human-only act holding the reviewer’s OIDC subject) and notes. The four review columns are present in the schema (20260526001500_create_verification_tables.sql) but have no writer yet: store::record_ievs_hit binds none of them and no UPDATE ievs_hits exists in the tree, so every row stays unreviewed. Read by the worker dashboard’s IEVS-alerts panel (list_recent_ievs_hits, WHERE status = 'unreviewed').

verification_responses

Applicant/worker responses to a work item, written by POST /v1/verifications/{id}/respond — one row per attached document plus an optional text-only row, scoped to the verification’s own application_id. verification_id is the schema’s one DB-level FK (REFERENCES verifications(id)); document_id (→ canopy-applications application_documents, nullable for a text-only row), person_id, response_text, responded_at (no DEFAULT since #1685), responded_by_source CHECK applicant_portal / worker_intake.

event_outbox / event_inbox

Generated ADR-018 / ADR-039 outbox and inbox — documented once on the data-models index. canopy-verification binds two consumers over the inbox: application_document.acceptance_revoked (#1416 — reverts resolutions that stood on a revoked acceptance) and notice.dispatched (#1643 — re-anchors requested-anchored due dates to the checklist letter’s dispatch date plus the row’s pinned response_days; filtered to notice_type = 'verification-checklist').

idempotency_keys (runtime DDL)

The fleet idempotency cache, created before the migrator runs by canopy_db::ensure_idempotency_schema (canopy_api::bootstrap::apply_migrations_on; canopy-manage migrate apply makes the same call); shape owned by crates/canopy-db/src/idempotency_schema.rs.

_sqlx_migrations (sqlx’s history table) is present as in every service.

Relationships

Three domain tables. verification_responses hangs off verifications by FK; ievs_hits shares the cross-service household / person keys with verifications but no Postgres relationship. The outbox, inbox and idempotency tables are infrastructure with no relationship to the domain tables.

Diagram

Cross-service FKs (ADR-001 boundary)

canopy-verification holds no Postgres-level foreign key to another service. Every cross-service UUID column (application_id → canopy-applications; document_id → canopy-applications application_documents; household_id / person_id → canopy-persons) is an application-level reference only — the orchestrator and the worker BFF supply real ids, and existence is not enforced here. The worker columns are TEXT OIDC subjects (#1008), never UUIDs: reviewed_by names a human, and the completed_by / cancelled_by pairs name a human subject or a service principal, taken from the acting bearer.

Retention

canopy-verification’s domain tables (verifications, ievs_hits) record verification work items and IEVS match data — ievs_hits.payload holds the serialised adapter record itself (persist_hit, services/canopy-verification/src/api/ievs.rs), not metadata about it — but not FTI — the FTI-bearing IEVS audit trail lives in the legally-scoped program services (canopy-tanf / canopy-medicaid fti_audit_log per ADR-004 / ADR-014), and SSA SOLQ/BINDEX records are their own class, authorised to canopy-tanf, canopy-snap, canopy-medicaid and canopy-verification ([class.ssa_solq_bindex].authorised_services, compliance/data-tenancy-authorisation.toml) — not to those two services alone. canopy-verification holds no FTI or PHI at rest, so no Pub 1075 §9 / HIPAA at-rest retention floor applies to this database. SNAP record retention (7 CFR 272.1(f)) implies a 3-year case-record floor for the underlying SNAP record an IEVS match (42 USC §1320b-7; 7 CFR 272.8) verifies; the longest applicable program floor governs in multi-program deployments. Retention is operator-driven (archive moves, not migration-driven destructive changes — ADR-016 forward-only).

Indexes

  • idx_verifications_household_pending (partial, (household_id, requested_at DESC, id DESC) WHERE status = 'pending', #2336) — the per-household LATERAL of the caseload-scoped feed GET /v1/verifications/scoped (the worker dashboard’s "Pending verifications" panel), EXPLAIN-pinned

  • idx_verifications_household — household-scoped lookup of verification items

  • verifications_open_natural_key_v2_uq (partial UNIQUE, #1643) — open-item dedup, served by ON CONFLICT + read-back convergence

  • idx_verifications_checklist_pending_dispatch (partial, (checklist_event_id) WHERE due_date_anchor = 'requested') — the notice.dispatched re-anchor consumer’s lookup

  • idx_verifications_application_program ((application_id, program)) — the batch-context read, the cancel-open scope and the day-30 drain’s per-application join

  • idx_ievs_hits_recent — recent-hits feed, ordered hit_at DESC

  • idx_ievs_hits_unreviewed (partial, WHERE status = 'unreviewed') — the IEVS-alerts panel hot path

  • idx_ievs_hits_household — household-scoped lookup of IEVS hits

  • verification_responses_verification_idx ((verification_id, responded_at DESC)) — the per-verification response read-back

  • verification_responses_application_idx — application-scoped lookup of responses

  • 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 eight generated outbox/inbox files (20260508000000, 20260516000000, 20260518004851, 20260713000000, 20260720000000, 20260803000000, 20260815000000, 20260904000000) are ADR-039 copies of crates/canopy-mq/outbox-migrations/ (cargo xtask outbox-migrations --write, parity-gated by --check) and are documented once on the data-models index.

  • 20260526001500_create_verification_tables.sql — #519 + #522: verifications and ievs_hits with their partial indexes

  • 20260601000000_create_verification_responses.sql — verification_responses with its verification_id- and application_id-scoped indexes

  • 20260804000000_v7_pk_defaults.sql — #1173: drops the verification_responses.id gen_random_uuid() default so a missed app-supplied UUIDv7 bind fails loudly

  • 20261122000000_verifications_open_natural_key.sql — #1480: the original open-item natural-key partial unique on (application_id, household_id, verification_type)

  • 20261123000000_verification_request_context.sql — #1643: the request-context columns and CHECKs, the natural-key split (the legacy key narrowed to program IS NULL, the program- and person-aware verifications_open_natural_key_v2_uq added), and the dispatch-consumer / application-program indexes

  • 20261223000000_cancel_reason_superseded_by_postponement.sql — #1662: re-creates the closed cancel_reason CHECK with the fifth token superseded_by_postponement (re-created, never edited in place; no row changes)

  • 20261224000000_drop_legacy_open_natural_key.sql — #1676: drops the legacy program-NULL key verifications_open_natural_key_uq once #1644 removed both of its producers (index-only, no DML; the v2 key stays)

  • 20261225000000_drop_wall_clock_defaults.sql — #1685: drops the DEFAULT now() on verifications.requested_at and verification_responses.responded_at (NOT NULL stays) so a writer that omits the decision-clock stamp fails instead of misdating the row

  • 20261226000000_provisional_window_check.sql — #1674: adds ck_verifications_provisional_window (due_date_anchor <> 'requested' OR response_days IS NOT NULL) so the notice.dispatched re-anchor can never compute a NULL deadline (7 CFR 273.2(f))

  • 20270113000000_actor_subjects.sql — #1008: retypes worker_id, completed_by, cancelled_by and ievs_hits.reviewed_by to TEXT, adds completed_by_service / cancelled_by_service and the four optional-pair CHECKs. Its guard refuses a database holding an act with no recorded actor (a pre-#1008 service resolve or cancel stored NULL), an actor without its act, or a nil-UUID subject — the remedy is the reset it names, cargo xtask dev restart, never a backfill

  • 20270210000000_pending_by_household.sql — #2336: adds idx_verifications_household_pending, and drops verifications.worker_id with its two indexes (idx_verifications_worker_pending, idx_verifications_pending_unassigned, partial on worker_id IS NULL): no service writer ever set the column (only the devstack seed did), and a worker’s pending items are their assigned households' (#607). The index is a guarded CREATE INDEX IF NOT EXISTS, so a live deployment can pre-build it CONCURRENTLY

All migrations are forward-only per ADR-016.

Edit this page · default