canopy-caps Data Model
Cross-link: canopy-caps API Reference · Source: migrations/
Tables
| Table | Purpose |
|---|---|
|
CAPS application intake records. One row per (application, child) pair. Carries the child’s age + special-needs flag, household size, optional |
|
Signed eligibility determinations per child. |
|
Immutable determination input snapshots (#685). One row per child determination (PK = FK |
|
Per-value DEK store for crypto-shred redaction. One row per per-determination DEK: |
|
Provider authorization rows. One row per (determination, provider) — a single determination can spawn multiple authorizations over time (current |
|
The workers' notes on authorization changes, an append-only history: one row per noted |
|
Each parent’s activity standing, written by |
|
Each child’s need for care, written by |
|
What a family member certified about the household’s assets (45 CFR 98.20(a)(2)(ii)), written by |
|
Provider registry. |
|
canopy-eligibility’s verdict on each of this service’s determinations, one row per |
|
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):
redaction_keys has no DB-level relationship: (subject_kind, subject_id) names the sealed subject (determination_snapshot / the determination id) as an application-level pointer (migration 20260624140000_create_redaction_keys.sql).
Cross-service FKs (ADR-001 boundary)
Per ADR-001, canopy-caps holds no Postgres-level foreign keys to other services. The intra-database FKs are caps_authorizations.{determination_id,provider_id}, caps_authorization_notes.authorization_id → caps_authorizations(id) and determination_snapshots.determination_id → caps_determinations(id). The cross-service ids the tables carry — application_id (canopy-applications), household_id, child_person_id and the worker facts' person_id (canopy-persons) — are application-level foreign keys: canopy-caps trusts the orchestrator (canopy-eligibility) to supply real IDs but does not enforce existence in canopy_caps. This is the program-isolation contract; cross-service consistency is the orchestrator’s responsibility, not the program DB’s. The worker facts' recorded_by is the recording worker’s canopy subject (canopy-identity’s id for the worker, the delegation’s sub), stored as an opaque TEXT.
Retention
Retention floors (eCFR, checked 2026-09-16): CAPS does not handle FTI or PHI, so no Pub 1075 / HIPAA floor applies. CCDF records are retained 3 years from the day the Lead Agency submits its financial reports, longer while litigation or audit is open (45 CFR 98.90(e)). State series: Georgia Archives, DECAL retention schedule (agency 157), series 0469-06-003 "Childcare and Parent Services (CAPS)", 3 years after the end of the calendar year — https://www.georgiaarchives.org/records/agencyprint/157 (checked 2026-09-18); it matches the federal 3-year length and runs from calendar year-end rather than from the financial-report submission, so the later-ending of the two windows governs. caps_determinations, determination_snapshots, caps_authorizations, caps_authorization_notes, caps_parent_activities and caps_child_care_needs are retained indefinitely in production; archive moves are operator-driven, never migration-driven (ADR-016).
Indexes
-
idx_caps_applications_{app,household,child}— per-FK lookups -
idx_caps_applications_provider(partial,WHERE provider_id IS NOT NULL) — provider rollups across applications (#396) -
idx_caps_determinations_{application,household,child,status,effective}— list endpoints -
caps_determinations_operation_subject_uq— partial UNIQUE(operation_id, child_person_id) WHERE operation_id IS NOT NULL: one determination per claimed operation and child (#3185). canopy-caps maps a violation of it, matched by name through the constantOPERATION_SLOTinapi/persist.rs, to the 409operation_already_determined -
idx_determination_snapshots_as_of— input-snapshot lookup by evaluation date (ADR-028) -
idx_caps_authorizations_{determination,child,provider,status}— authorization-tab queries on the worker portal -
caps_authorization_notes_authorization—(authorization_id, created_at, id): an authorization’s notes in written order (#2428) -
idx_caps_parent_activities_person,idx_caps_child_care_needs_person—(person_id, effective_date DESC, created_at DESC): a person’s newest-first list and the standing on a date (#3182) -
idx_caps_asset_certifications_household—(household_id, certified_on DESC, created_at DESC): a household’s newest-first certification list and the certification standing on a date (#3546, #3547) -
idx_caps_providers_active(partial,WHERE status='active') — default/v1/providerslisting -
idx_caps_providers_code— lookup support beside theprovider_codeUNIQUE constraint -
idx_redaction_keys_subject—(subject_kind, subject_id)DEK lookup for seal / re-verify / shred (ADR-036) -
uq_redaction_keys_live_subject(UNIQUE partial,(subject_kind, subject_id) WHERE shredded_at IS NULL) — one live DEK per subject; the atomic get-or-create’s conflict target (migration20261208000003) -
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:
-
20260413000000_create_caps_tables.sql— original schema (caps_applications, caps_determinations, caps_authorizations) -
20260512000001_add_caps_providers.sql— #396 provider registry; drops pre-1.0 TEXT provider_id columns and re-adds them as UUID FKs -
20260622000000_create_determination_snapshots.sql—caps_determinations.snapshot_hashcolumn + the immutabledetermination_snapshotstable + its append-only trigger (#685; ADR-028) -
20260624140000_create_redaction_keys.sql— the per-serviceredaction_keystable + its one-way-tombstone trigger (#687, ADR-036) -
20260804000000_v7_pk_defaults.sql— #1173: drops thegen_random_uuid()(UUID v4) DEFAULT oncaps_providers.id; the application binds a v7 id at every INSERT -
20260810000000_snapshot_hash_not_null.sql— #911: deletes the pre-snapshot legacy determinations (and their authorizations) and setscaps_determinations.snapshot_hash NOT NULL -
20261208000003_redaction_keys_live_subject_uq.sql— tombstones every older duplicate live DEK per subject, then adds theuq_redaction_keys_live_subjectpartial UNIQUE -
20261224000000_redaction_keys_rewrap_guard.sql—canopy_redaction_keys_one_way_guard()admits the KEK rewrap (wrapped_dekreplaced +kek_versionstrictly increased on a live row) beside the shred (#2113) -
20270111000001_determination_status_check.sql— deletes any determination outsideapproved / denied / sanctionedwith its snapshot (inside thecanopy.snapshot_maintenancewindow) and its authorizations, then addscaps_determinations_determination_status_verdict(#628) -
20270117000000_redaction_keys_created_at_no_default.sql— drops theredaction_keys.created_atdefault: the shared canopy-db store bindscreated_at(the determination’s decision instant) andshredded_at(the redaction’s) from its caller, so an insert that names nocreated_atnow fails instead of taking the database clock (#2475) -
20270202000000_caps_authorization_notes.sql— the append-onlycaps_authorization_notestable, its index and its append-only guard trigger (#2428) -
20270209000000_decision_stamps_no_default.sql— drops the defaults of every stamp the service’s production INSERTs bind themselves:caps_determinations.created_at/updated_at,caps_authorizations.created_at/updated_at,determination_snapshots.created_atandcaps_providers.created_at/updated_at(the wall-clock instant of the provider write). An insert that names no stamp now fails instead of taking the database clock, andcargo xtask migrations-lintrefuses a new clock default (#2589) -
20270215000000_determination_verdicts.sql— thedetermination_verdictstable and itsverdictCHECK (#2322) -
20270308000000_caps_worker_facts.sql— thecaps_parent_activitiesandcaps_child_care_needstables, their CHECKs and person indexes, and the nullablecaps_authorizations.scholarship_typecolumn (#3182) -
20270309000000_caps_determinations_operation.sql—caps_determinations.operation_idandsigned_payload,caps_determinations_operation_signed_ckandcaps_determinations_operation_subject_uq(#3185) -
20270324000000_determination_status_withheld.sql— ADR-052: replacescaps_determinations_determination_status_verdictso the list also admitswithheld; no row is rewritten. -
20270402000000_caps_asset_certifications.sql— thecaps_asset_certificationstable and its household index (#3546)
All migrations are forward-only per ADR-016.