canopy-caps Data Model

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

Tables

Table Purpose

caps_applications

CAPS application intake records. One row per (application, child) pair. Carries the child’s age + special-needs flag, household size, optional provider_id (FK to caps_providers per #396), and the initial / continued eligibility-type flag that drives the SMI threshold lookup.

caps_determinations

Signed eligibility determinations per child. determination_status is CHECK-closed to approved / denied / sanctioned / withheld (caps_determinations_determination_status_verdict, #628). Carries the three CAPS gate flags (income_eligible, activity_eligible, age_eligible), the computed copayment_weekly_cents + authorized_weekly_hours, the denial_reasons text array on denial, ruleset_version for audit replay, the ADR-002 jws_token over the canonical signing payload, and the snapshot_hash (hex SHA-256 of the ADR-028 input snapshot, bound into the signature; NOT NULL since #911 — the pre-snapshot legacy rows were deleted with the ADR-028 §58 backstop). operation_id UUID is the canopy-eligibility operation the envelope signs, NULL for a direct caller’s determination (#3185), and signed_payload BYTEA the exact bytes jws_token covers, from which a replayed operation is answered (operation binding). Neither has a default; the writer binds the bytes on every row. CHECK caps_determinations_operation_signed_ck: a row naming an operation carries its signed_payload and its jws_token. Rows written before #3185 carry neither.

determination_snapshots (ADR-028)

Immutable determination input snapshots (#685). One row per child determination (PK = FK determination_id → caps_determinations(id)): the typed DeterminationSnapshot as a canonical snapshot JSONB blob (the child’s caps-eligibility rules_input + rules_output, the per-child gate results, resolved policy params, the corpus-hash of the child’s evaluation, and the household composition as the fact record), plus denormalized corpus_hash + as_of columns and the signing_kid (ADR-028 §53 key retention). policy_params.family_fee_edition names the [caps.family_fee] edition that priced the copayment by its effective_date, beside policy_params.smi_edition (#2226). policy_params.family_fee_weekly_cents (the whole family fee, 0 when no child is eligible), family_fee_children (n, the eligible children sharing it) and family_fee_allocation (divide_evenly or youngest_child) record what the child's copayment_weekly_cents share was allocated from (#3321). Append-only — a statement-level trigger blocks UPDATE/DELETE/TRUNCATE unless canopy.snapshot_maintenance is set. Re-verification deserialises the blob to the typed struct and re-hashes via RFC 8785 JCS (serde_json_canonicalizer since #1281; never over raw JSONB), comparing to caps_determinations.snapshot_hash. CAPS is non-FTI, so the snapshot does not join the ADR-014 chain. #679: each per-child blob also carries the self-explaining derivation_graph (the ruleset’s income, activity and age test firings and their eligible combination since #3079, + the Rust-side family-fee lookup, whose inputs are the household’s income and size since #2226) — schema_version: 3 (ADR-028 Amendment 2). Since #687 (ADR-036) the snapshot’s PII-bearing value leaves (money amounts, program_input, derived-graph node values) are AEAD-SealedValue envelopes hashed over ciphertext; schema_version is now uniformly 4.

redaction_keys (#687, ADR-036)

Per-value DEK store for crypto-shred redaction. One row per per-determination DEK: dek_id (PK), wrapped_dek BYTEA (the DEK wrapped under the service KEK = CANOPY_ENCRYPTION_KEY, AAD-bound, zero-sentinel after shred), kek_version, subject_kind / subject_id (e.g. determination_snapshot / the determination id), created_at (the determination’s decision instant, bound by the store; no default since #2475), shredded_at (NULL = live; non-NULL = redacted, at the redaction’s instant). Append + one-way-tombstone + KEK rewrap (wrapped_dek replaced and kek_version strictly increased on a live row, 20261224000000, #2113) only — a trigger rejects DELETE/TRUNCATE/un-tombstone/identity-mutation.

caps_authorizations

Provider authorization rows. One row per (determination, provider) — a single determination can spawn multiple authorizations over time (current active row + historical terminated rows from #398 seed lifecycle). FK to caps_determinations(id); FK to caps_providers(id) per #396. Carries weekly_hours, rate_cents_per_hour, and the per-row copayment_weekly_cents so the determination’s snapshot at issuance time is preserved. scholarship_type (#3182, nullable) is the type of care the scholarship authorizes, CHECK ∈ {full_time, part_time, before_after_school, variable_schedule} (the tokens of ScholarshipType); POST /v1/determine writes the child’s recorded care need’s type, NULL when none is recorded, and PUT /v1/authorizations/{id} sets or corrects it (#3183); rows written before #3183 keep it NULL. weekly_hours is written as the greatest tested parent’s recorded hours (#3183).

caps_authorization_notes (#2428)

The workers' notes on authorization changes, an append-only history: one row per noted PUT /v1/authorizations/{id} (change = update) or PUT /v1/authorizations/{id}/provider (provider_switch), written in the change’s transaction. FK authorization_id → caps_authorizations(id); note 1 to 2000 characters (CHECK), stored trimmed by the service; the actor is exactly one of actor (the worker’s OIDC subject) and actor_service (a system caller’s principal) (CHECK num_nonnulls = 1, each non-empty); created_at the changed authorization’s updated_at, the change’s own instant. A statement-level trigger refuses UPDATE and DELETE outright, and TRUNCATE unless canopy.audit_maintenance is set (the devstack reseed opens it), the quarantine_resolutions guard shape (#2061). GET /v1/authorizations/{id}/notes reads an authorization’s history in written order, on the index (authorization_id, created_at, id) (#2929).

caps_parent_activities (#3182)

Each parent’s activity standing, written by POST /v1/parent-activities (the worker-fact routes). Append-only: a change of standing is a new row with a later effective_date. id (CapsParentActivityId, app-supplied UUID v7), person_id, weekly_hours INTEGER NOT NULL (CHECK >= 0), verified BOOLEAN NOT NULL, unable_to_provide_care BOOLEAN NOT NULL (the claimed disability that keeps the parent from providing care), care_waiver_verification (nullable, CHECK ∈ {licensed_medical_statement, agency_documentation}, the tokens of CareWaiverVerification), effective_date DATE NOT NULL, recorded_by TEXT NOT NULL (the recording worker’s OIDC subject, from the bearer of the user-only create route), created_at TIMESTAMPTZ NOT NULL, the request’s decision instant, bound by the writer with no default. CHECK caps_parent_activities_waiver_needs_claim: a verification only beside the claim (care_waiver_verification IS NULL OR unable_to_provide_care). POST /v1/determine reads each named parent’s standing on its legal day (#3183).

caps_child_care_needs (#3182)

Each child’s need for care, written by POST /v1/child-care-needs. Append-only, as caps_parent_activities. id (CapsChildCareNeedId, app-supplied UUID v7), person_id, scholarship_type TEXT NOT NULL (CHECK ∈ {full_time, part_time, before_after_school, variable_schedule}, the tokens of ScholarshipType), has_documented_disability BOOLEAN NOT NULL, effective_date DATE NOT NULL, recorded_by TEXT NOT NULL, created_at TIMESTAMPTZ NOT NULL, bound as on caps_parent_activities. POST /v1/determine reads each child’s need on its legal day (#3183).

caps_asset_certifications (#3546)

What a family member certified about the household’s assets (45 CFR 98.20(a)(2)(ii)), written by POST /v1/asset-certifications (the certification routes). Append-only: a correction is a new row. id (CapsAssetCertificationId, app-supplied UUID v7), household_id UUID NOT NULL, certified_by_person_id UUID NOT NULL, within_limit BOOLEAN NOT NULL (the family’s assets do not exceed the federal limit), certified_on DATE NOT NULL, recorded_by TEXT NOT NULL (the recording worker’s OIDC subject), created_at TIMESTAMPTZ NOT NULL (the request’s decision instant; no default). No dollar figure is stored. POST /v1/determine reads the row certified latest on or before its legal day (standing_on, #3547).

caps_providers (#396)

Provider registry. provider_code UNIQUE; legal_name, optional license fields, status ∈ {active, inactive}. Soft-delete only — historical authorizations carry the FK, so a hard delete would break referential integrity. Partial-index on active rows for the default /v1/providers?status=active listing.

determination_verdicts (#2322)

canopy-eligibility’s verdict on each of this service’s determinations, one row per determination_id (PK), written by the verdict consumer (src/verdict_subscriber.rs) in the inbox transaction that releases or drops the determination’s held outbox rows (ADR-002 Amendment 7). verdict is recorded or disowned (CHECK determination_verdicts_verdict_check); a recorded verdict replaces a disowned one and nothing replaces a recorded one. received_at is the consumer’s read of the decision clock for the delivery, bound by the consumer (no default). No foreign key: the consumer records the verdict canopy-eligibility sent whether or not a determination row holds the id.

event_outbox, event_inbox

The generated ADR-018 / ADR-039 outbox and the generated consumer inbox, single-sourced in crates/canopy-mq/outbox-migrations/ — schema, indexes and migration files are described once in the data-models index. canopy-caps publishes through the outbox (canopy_mq::Publisher in services/canopy-caps/src), and its one consumer, the determination-verdict consumer (src/verdict_subscriber.rs, #2322), runs on event_inbox.

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.

Relationships

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

Diagram

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 constant OPERATION_SLOT in api/persist.rs, to the 409 operation_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/providers listing

  • idx_caps_providers_code — lookup support beside the provider_code UNIQUE 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 (migration 20261208000003)

  • 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_hash column + the immutable determination_snapshots table + its append-only trigger (#685; ADR-028)

  • 20260624140000_create_redaction_keys.sql — the per-service redaction_keys table + its one-way-tombstone trigger (#687, ADR-036)

  • 20260804000000_v7_pk_defaults.sql — #1173: drops the gen_random_uuid() (UUID v4) DEFAULT on caps_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 sets caps_determinations.snapshot_hash NOT NULL

  • 20261208000003_redaction_keys_live_subject_uq.sql — tombstones every older duplicate live DEK per subject, then adds the uq_redaction_keys_live_subject partial UNIQUE

  • 20261224000000_redaction_keys_rewrap_guard.sql — canopy_redaction_keys_one_way_guard() admits the KEK rewrap (wrapped_dek replaced + kek_version strictly increased on a live row) beside the shred (#2113)

  • 20270111000001_determination_status_check.sql — deletes any determination outside approved / denied / sanctioned with its snapshot (inside the canopy.snapshot_maintenance window) and its authorizations, then adds caps_determinations_determination_status_verdict (#628)

  • 20270117000000_redaction_keys_created_at_no_default.sql — drops the redaction_keys.created_at default: the shared canopy-db store binds created_at (the determination’s decision instant) and shredded_at (the redaction’s) from its caller, so an insert that names no created_at now fails instead of taking the database clock (#2475)

  • 20270202000000_caps_authorization_notes.sql — the append-only caps_authorization_notes table, 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_at and caps_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, and cargo xtask migrations-lint refuses a new clock default (#2589)

  • 20270215000000_determination_verdicts.sql — the determination_verdicts table and its verdict CHECK (#2322)

  • 20270308000000_caps_worker_facts.sql — the caps_parent_activities and caps_child_care_needs tables, their CHECKs and person indexes, and the nullable caps_authorizations.scholarship_type column (#3182)

  • 20270309000000_caps_determinations_operation.sql — caps_determinations.operation_id and signed_payload, caps_determinations_operation_signed_ck and caps_determinations_operation_subject_uq (#3185)

  • 20270324000000_determination_status_withheld.sql — ADR-052: replaces caps_determinations_determination_status_verdict so the list also admits withheld; no row is rewritten.

  • 20270402000000_caps_asset_certifications.sql — the caps_asset_certifications table and its household index (#3546)

All migrations are forward-only per ADR-016.

Edit this page · default