Data Model: Financial & Claims

Overview

The financial service manages foster care maintenance payments, adoption and guardianship assistance, Title IV-E eligibility tracking, payment adjustments, and federal fiscal claiming records for CFS-2 submission.

Rate tables define jurisdiction-specific daily rates by payment type and age range. Payments are generated from placements (per-diem origin) and — since #1068/ADR-053 — from active subsidy agreements (monthly subsidy origin) and approved through the same multi-step workflow. Adjustments modify payment amounts with supervisor approval. Claiming records aggregate issued payments for federal reimbursement.

The federal FFP figure payments.ffp_amount is a GENERATED ALWAYS column (#861): the DB derives it as CASE WHEN ive_eligible THEN round(net_amount * ffp_rate, 2) ELSE 0 on every write, so no handler computes or writes it and the IV-E claim can never drift from net_amount/ffp_rate/eligibility. DB-level backstops (#861, extended by #1583) additionally reject malformed writes from any writer: on payments, CHECK (period_end >= period_start), CHECK (ffp_rate >= 0 AND ffp_rate ⇐ 1), CHECK (day_count >= 1), the origin-conditional rate sign CHECK (daily_rate >= 0 AND (agreement_id IS NOT NULL OR daily_rate > 0)) (#1583 upgraded the old >= 0 twin), the money-consistency pair CHECK (gross_amount = round(daily_rate * day_count, 2)) (placement-origin) and CHECK (net_amount = gross_amount + adjustments), and the status vocabulary; on rate_tables, CHECK (age_min ⇐ age_max), CHECK (effective_date ⇐ end_date), CHECK (daily_rate > 0 AND daily_rate ⇐ 1000000), and the 0..=21 age-range pair; claiming_records carries totals-additivity, status-vocabulary, and submit/accept stamp-lattice CHECKs. The #1583 migration comments record the deliberate won’t-enforce residues (net-sign family — pending #1601).

Since #1068 (ADR-053) payments is a NULLABLE-ORIGIN table: placement-origin rows carry the NOT-NULL case_id/placement_id/foster_home_id trio, subsidy-origin rows carry agreement_id + term_id (the term REVISION that priced the row — composite-FK-pinned to the same agreement) with a NULL placement pair (case_id optional — post-case children); payments_origin_exclusive admits exactly those two shapes. Subsidy rows are UNIT-MONTH rows: one exact calendar month (payments_subsidy_calendar_month) with day_count = 1 and daily_rate = gross_amount = the monthly award (payments_subsidy_unit_month) — the per-diem day×rate reading never applies — and are structurally never IV-E (payments_subsidy_never_ive; TANF-funded per 22.8). At most one LIVE subsidy row exists per agreement-month: the key is payments_one_subsidy_per_agreement_month_v2 on (agreement_id, payment_month) (the F9 month-identity GENERATED column) — a partial unique EXCLUDING voided rows, because the ADR-053 correction protocol voids a stale undisbursed month and regenerates it under the freed key. The legacy (agreement_id, period_start) twin that covered old replicas' ON CONFLICT targets through the rolling deploy was dropped by the #1106 contract step, which also raised schema_compat_floor to #1069 M1’s version — recording that a pre-M1 binary (whose conflict target no longer exists) is incompatible with the post-drop schema. No released binary is newly refused: pre-M1 binaries predate verify-only boot and were already VersionMissing-refused against any ahead database.

Placement-origin (per-diem) rows carry the OPPOSITE uniqueness semantics (#1179): payments_one_perdiem_per_placement_period on (placement_id, period_start) WHERE agreement_id IS NULL is a LIFETIME key with no status filter — a voided row still holds it. It is a replay guard, not a correction protocol: placement.activated is at-most-once per placement (no re-activation transition exists), so a key collision is always a replayed/duplicate execution — and because placement.ended (since #2020 also placement.retracted) can void the row while an ended or retracted placement can never re-emit placement.activated, a voided-exclusive key would let a stale replay mint a fresh payment nothing ever voids again. The placement.activated consumer inserts through ON CONFLICT … DO NOTHING against this key and stages its payment_created event iff the row was actually inserted. The companion payments_dedupe_repairs ledger (same migration) records any rows the one-time fail-closed dedupe removed.

What a placement’s end does to its per-diem (#3189). The caregiver is paid for the days the child was in the home. placement.ended carries the end instant; craig-financial dates it on the jurisdiction’s business calendar, as it dates the start, and takes the last paid day: the day before the end, or the end day itself where the jurisdiction’s perdiem_pays_end_day setting says so (Multi-Jurisdiction Extensibility). Each undisbursed (pending or approved) per-diem of the placement is then settled against that day:

The row What the end does

ends on or before the last paid day

nothing: every day of it was in care.

runs past the last paid day

shortened in place: period_end becomes the last paid day, and day_count, gross_amount and net_amount are recomputed at the row’s own rate. The row is written pending with its approval stamps cleared, whatever it was, since an approval was for the larger amount. One financial.payment_period_shortened event names the row. The lifetime key is untouched: the row keeps its period_start.

starts after the last paid day

voided, as before, and named in the pass’s one financial.payments_voided. A child placed and gone on one day, where the end day is unpaid, is this case.

A row whose approved adjustments exceed what its days in care are worth is voided rather than shortened: payments_net_non_negative admits no negative net. An end that carries no end date (an envelope older than #1123) cannot count days and voids every undisbursed row. A retraction voids every undisbursed row whatever days it covers: the placement never happened. Issued and cleared rows are never touched by either consumer. Only the ended placement’s own rows are settled: a respite stay or a concurrent per diem of the same child is paid on its own terms.

Money already disbursed for days after the end (#3199). An issued or cleared per-diem whose period runs past the last paid day has paid for days the child was not in the home, and the end leaves it as it is. The end keeps the last paid day on the placement’s tombstone (placement_terminations.last_paid_day), and the report-only invariant perdiem_disbursed_past_placement_end names each such row with that day and how many of the row’s own days come after it: all of them, for a row that starts after that day. It does not judge a retracted placement (perdiem_disbursed_on_retracted_placement lists those), an end that carried no end date, or an ending recorded before the column existed. The row is corrected by a person, with a payment adjustment (#1078); when a submitted or accepted claim covers it, the adjustment’s approval is refused (409 claimed-payment-frozen, #1357). Whether CRAIG should stage that adjustment itself, and what it does about a claimed row, is not decided: #3199 holds it.

A shortened or voided per-diem re-opens the subsidy question for the months it covered (the perdiem_change enqueue). Exclusivity judges whole months, so a month in which the per-diem keeps a paid day still has no subsidy row, exactly as when the per-diem was disbursed before the end.

Recorders name the acting worker (#2321). No craig-financial recorder (a who-acted column or an event’s actor key) names the request token’s own sub / preferred_username: under a BFF-lifted token that token is craig-web’s service principal, so a staff write names claims.acting_worker() or the claim’s effective actor (ADR-028, ADR-062), the lifted worker, or the token’s own subject when nothing is lifted. #2321 brought the adjustment writes in line with the payment lifecycle stamps (#978): payment_adjustments.requested_by / requested_by_name / approved_by / approved_by_name (the resolver, on approval and on denial) and the financial.adjustment_created / financial.adjustment_resolved created_by. Each name column is the acting worker’s username. A pending adjustment’s withdrawal hard-deletes the row, so its only record is financial.adjustment_deleted, whose user_id is the withdrawing worker (#2496). Since #2522 the Claims fields are private and crates/craig-test-lib/tests/acting_identity_census.rs pins it: the token’s own identity is read only through a bearer() accessor, each such read under services/craig-financial/src is pinned with its reason, and a recorded worker is claims.worker_subject(), which reads the claims.acting_worker() view, never the bare claims (#2740 removed parse_sub / parse_actor_sub).

Tables

The catalog below covers the domain tables. The fleet-standard platform tables also live in this schema and are documented centrally: event_outbox / event_inbox / event_inbox_collisions (ADR-022 and the ADR-062 §A attempt machine), request_claims (ADR-062 §B), and schema_compat_floor (ADR-063). A claim’s actor is the ADR-085 D3 column pair (#2740): request_claims.created_by_sub holds a worker’s UUID and created_by_sub_service a service’s service:<name> encoding, with a CHECK that exactly one is set.

Table Purpose

placement_terminations

#1193 durable placement-termination tombstone: placement.ended records the ending even when it arrives BEFORE placement.activated (out-of-order delivery/replay), so the later activation cannot mint a live payment nothing would ever settle. Since #3189 the tombstone keeps the end instant the event carried (ended_at, the first delivery’s; NULL for a retraction, for an end that carried none, and for a tombstone older than the column), and an activation consumed after the end bills the days in care: its first period runs from the start through the last paid day, the same day the end shortens a row to, so either order of the two events leaves the same row. It bills nothing for a retraction, for an end with no ended_at, and for an end that leaves no paid day. Since #2020 placement.retracted writes the same tombstone, with a NULL end_reason (a retraction is not an ending). Since #2041 the retraction also sets retracted_at (first delivery wins), on a tombstone it wrote or on one an earlier ending wrote, which keeps its end_reason and event_id. NULL means no retraction recorded. The void’s cause still rides financial.payments_voided. Since #3189 the tombstone is also the end marker the subsidy_err_ended_placement_anchor invariant reads: an end no longer leaves every per-diem voided, so "all rows voided" stopped meaning "the placement ended". Since #3199 it also keeps the last day the placement is paid for (last_paid_day), worked out when the end is consumed from the jurisdiction’s calendar and its end-day setting; NULL for a retraction, for an end that carried no end instant, and for a tombstone older than the column. A placement that began and ended on one unpaid end day has a last paid day before its first day. The report-only invariant perdiem_disbursed_past_placement_end reads it.

placement_replacements

#2041 durable replacement link: one row per replacement placement (placement_id PK) naming the retracted arrangement it replaces (replaces_placement_id, R-B21), written by the re-anchor tail of placement.activated and placement.recorded (ON CONFLICT DO NOTHING, recorded_at). FK-free, like the tombstone. No UNIQUE on replaces_placement_id: placement’s uq_placements_one_replacement owns that rule.

case_assignments

#1632: financial’s authoritative case-assignment projection — placement’s #1213 table mirrored (case_id PK, assigned_worker_sub NOT NULL, supervisor_sub, assignment_revision, and since #1901 the nullable admin_unit). case.created seeds revision 0 and heals money rows still at revision 0 FROM it; case.assignment_changed upserts it as its first write under the strictly-greater revision guard (lock order: the pay-exclusion lock of every child with an agreement on the case, child id ascending (#2042), then the per-case advisory lock, then the projection row, then the money rows parents first — subsidy_agreements → payments → payment_adjustments, each handler finishing one table before the next (#1922), the order of the subsidy generator, which holds an agreement FOR UPDATE before it voids or inserts that agreement’s payments). The child locks come first because the subsidy generator locks one child’s agreements in its own order under that child’s lock, and the per-diem birth and create_agreement_active take the child lock before the case lock. A child whose first agreement on the case commits between the handler’s child read and its re-read under the case lock fails that attempt, and the redelivery locks it. The per-diem birth path reads it FOR SHARE under the child lock and stamps whichever of {projection, placement.activated payload snapshot} carries the higher revision; birth and both writers serialize on a per-case transaction advisory lock (the projection row may not exist yet, so FOR SHARE alone cannot) — so a per-diem no longer waits for the case’s next reassignment: it is born with the pair, or case.created heals it. Backfill: craig-manage backfill-assignments seeds it alongside placement’s. #2417: two more writers take that order. The backfill writes a case’s subsidy_agreements rows in one transaction under the same child locks (ascending), the per-case lock and the same re-read, issuing the lock statements from its own copies (a test holds them equal to the service’s). The conversion import (import_agreement_history) takes its child’s pay-exclusion lock first, then its family history locks, then, before its first agreement row, the per-case lock when the record names a case, and holds them to commit, so the re-read under the case lock is complete for imported agreements as for native ones. #3075: create_agreement_active and the import take the pay-exclusion lock before any history lock, because a reinstatement (transition_status, terminated to active) holds the pay-exclusion lock and the agreement row before it takes its (child, program) history lock; the creators used to take the history locks first, and the two could deadlock. #3079: create_guardianship_agreement takes the pay-exclusion lock first as well. It took none, and its identity insert key-share locks a named predecessor’s row, which waits on that predecessor’s reinstatement (FOR UPDATE) while the reinstatement waits on a guardianship history lock the creation holds. All three creators now share one order: pay-exclusion, history, case, agreement rows. #1901 (ADR-077 D6) — the unit: admin_unit is the case’s administrative unit as cases published it. The admin_unit key is OPTIONAL on both events (retained pre-upgrade envelopes — undrained outbox rows, queued deliveries, admin replays — must still apply their pair; the unit is not an identity key and is never revision-ordered): case.created’s conflict arm became a unit-only `DO UPDATE SET admin_unit … WHERE admin_unit IS NULL (the pair and the revision are never touched by it), case.assignment_changed writes COALESCE(EXCLUDED.admin_unit, admin_unit) under the revision guard (an envelope without the key never clears a set unit). Absent = NULL = fail-closed (a NULL stamp matches no unit scope) until a unit-bearing event or the backfill’s revision-independent unit-fill pass writes it. Every root birth with a case_id copies the unit from this row under the same per-case lock: the per-diem (BirthStamp::admin_unit), create_agreement_active and create_guardianship_agreement (each after its pay-exclusion + family locks); child births copy their parent under a parent-row lock (the generator’s FOR UPDATE OF a, create_adjustment’s `FOR SHARE on the payment). The generator never takes the case lock (it holds the agreement rows the heals wait on — a cycle). Both handlers run SEPARATE unit-only heals (HEAL_UNIT_*: SET admin_unit = ca.admin_unit WHERE … admin_unit IS NULL, never the pair or the revision; the pair predicates are byte-identical to before), parents first — subsidy_agreements → payments → payment_adjustments (via the payments JOIN) — one table at a time (#1922): case.created runs a table’s unit-only heal after the seed and then its pair heal; case.assignment_changed runs a table’s unit-only heal right after that table’s reassign.

ive_child_verdicts

#1313 U5: the persisted per-child IV-E verdict state — one row per (case_id, child_id) (the PK), applied from eligibility.evaluated by revision UPSERT-CAS (WHERE excluded.revision > current.revision), so out-of-order/duplicate deliveries converge instead of rewinding. invalidated flags rows whose revision sits in the invalidation set. The per-diem INSERT path prices from this table; the U5b claim gate consumes invalidated. LIVE since hard-checks U6 (#1313, 2026-09-02): cases emits one event per witnessed child in the determination act tx.

ive_invalidated_revisions

#1313 U5: the invalidation SET — (case_id, revision) pairs recorded by the case.ive_determination_invalidated consumer. A verdict arriving after its invalidation lands pre-flagged; one arriving before is flagged by the consumer — both orders converge.

claim_exclusions

#1313 U5b: the claim build’s verdict-gate evidence — one row per disbursed per-diem payment kept OUT of a claim’s totals (reason IN ('content-differs', 'verdict-invalidated')), persisted in the build tx and rendered on the claim detail. PK (claim_id, payment_id); CASCADE with the claim, RESTRICT on the payment. The gate is CONTENT-compare over (ive_eligible, ffp_rate) vs the current verdict, scoped to agreement_id IS NULL rows (subsidy money is structurally never IV-E and never gated); content-EQUAL rows restamp ive_revision in place instead (bookkeeping — ffp_amount is GENERATED from other columns, so a restamp cannot move money). claiming_records.never_determined_count counts included rows with no verdict pair.

rate_tables

Jurisdiction-specific daily payment rates by type and age range

payments

Foster care maintenance, adoption assistance, and guardianship assistance payments. #1901: admin_unit (nullable, partial index) is the authz scope stamp — a per-diem copies it from the case_assignments projection at birth, a subsidy payment from its FOR UPDATE-locked agreement; the unit-only heal fills a NULL stamp, never rewrites a set one. #2185: the row guard trg_payments_disbursed_moves_forward (refuse_disbursed_payment_status_change(), BEFORE UPDATE OF status) refuses every status change of an issued or cleared payment but issued → cleared for every role, the owner included (SQLSTATE 23000): a disbursed row is never voided and never rewound to pending or approved, and no writer does either #2223: backpay_record_id (nullable, FK to backpay_records ON DELETE RESTRICT) is the one-directional payment-to-record link for a backpay-materialized subsidy payment: unique where set (payments_backpay_record_unique, so one payment per record ever, a voided payment keeping its link) and allowed only on a subsidy-origin row (payments_backpay_subsidy_origin); every other writer leaves it NULL. #2224: written only by the backpay finalize, through the generator’s persist_backpay_payment, in the transaction that flips its record materialized

payment_adjustments

Corrections or supplements to payment amounts (e.g., clothing allowance). #1901: admin_unit copied from the parent payment, whose row create_adjustment now locks FOR SHARE (an adjustment born while a unit heal holds the payment waits and inherits the healed unit); healed through the payments JOIN. #2185: an approved row’s payment_id, amount, status and approved_at never change. The row guard trg_payment_adjustments_approved_history_fixed (refuse_approved_adjustment_history_edit(), BEFORE UPDATE OF those four) refuses any IS DISTINCT FROM change to them for every role, the owner included (SQLSTATE 23000); admin_unit and the assignment trio (assigned_worker_sub, supervisor_sub, assignment_revision) stay writable for the inbox heals and reassignment

payments_dedupe_repairs

#1179 one-time-migration audit ledger: each per-diem duplicate the fail-closed dedupe deleted (canonical id, duplicate id, prior status, full row snapshot, reason — incl. a note when a published payment_created had already left the system)

claiming_records

Aggregated IV-E/non-IV-E expenditures for federal fiscal claiming (CFS-2). #1357: each row stamps the aggregation window it was generated over (period_start/period_end, both-or-neither by CHECK) — the claim_totals_drift invariant recomputes the totals over that window and queues any drift (report-only operator queue); submitted/accepted claims FREEZE their covered payments (adjustment approval refuses 409 claimed-payment-frozen; the amendment vehicle is #1073); SUBMISSION of a stale or windowless draft refuses 409 claim-totals-stale (draft-gated — regeneration is the remedy)

subsidy_agreements

Kinship-subsidy agreement IDENTITY (GA 22.8/22.9; ADR-052) — immutable signed-artifact metadata, import provenance, predecessor lineage; current_status is a projection of the interval ledger. #1901: admin_unit is read from the case_assignments projection (FOR SHARE under the per-case lock) inside the two native create transactions; imports and case-less agreements stay NULL (R3); healed unit-only by case_id

subsidy_agreement_parties

Agreement signatories (caregiver / co-caregiver; never the child)

subsidy_agreement_terms

Effective-dated immutable term revisions (amount + basis, review schedule, education extension, approval binding); half-open windows, close-only

subsidy_agreement_status_intervals

Business-effective status ledger (pending/active/suspended/terminated/withdrawn/declined + reason codes + approvals); the authoritative status record

subsidy_agreement_reviews

22.9 review chain (renewal_12mo/paper_6mo): three-state rows — completed / open slot / superseded — with cycle identity, derived approval_level, the supervisor pair, and exact outcome linkage (resulting_term_id / resulting_interval_id, same-agreement composite FKs). See ADR-054

subsidy_reconcile_queue

Durable payment-repair feed (#1081/ADR-054): one live (agreement, month) pair per coverage-changing mutation, cause-tagged (transition/term_append/reinstatement, plus perdiem_change #1069 M1 and create_active #1069 M2 — the one-shot ERR creation’s backdated birth months ride the same durable queue), drained by the #1068 generator inside its run lease. Settled rows (processed_at IS NOT NULL) prune at the service’s outbox retention window (#1129 A3 / ADR-058); live rows and the dead-letter operator queue never age out. The drain re-checks each pair against the reconcile floor of its run’s jurisdiction business date (#2228): a pair whose month the floor has passed is settled and counted queue_retired_below_floor in the run report (one WARN), neither generated nor reconciled (nothing is voided; a stale undisbursed row there is the operator’s, through the payment correction path). Below-floor months belong to the backpay path

subsidy_sweep_runs

Durable sweep run records (state machine observed/previewed/executing/completed/failed/expired, execute-token digest, affected ids + counters + errors) — DDL lands with #1094; the U4 sweep (#1096) writes them. mode_per_diem_handoff snapshots the leg-3 consent knob per run (#1069 M3; DEFAULT false backfills historical rows truthfully — no run before the migration could enforce the leg)

subsidy_perdiem_handoffs

Durable per-diem handoff fact ledger (#1069 M3/ADR-055): one detection row per (agreement, payment), stamped by the enforcing run and — after a state-office reinstatement — the correction. Rows are never deleted

subsidy_import_batches

Conversion-batch ledger (#1071/ADR-057): one row per SHINES conversion run — source_system vocabulary (shines), snapshot_date (the named review baseline), cutover_month (month-start CHECK, > snapshot), expected_count (1..50000), manifest_checksum (sha256 over the sorted reference/hash pairs), state machine staging|finalizing|finalized|aborted with terminal-timestamp shape CHECKs

subsidy_import_records

Conversion-record staging ledger (#1071/ADR-057 D1/D4): one row per source record — external_reference, the IMMUTABLE canonical_payload + canonical_hash (the replay evidence; post-finalize replays compare HERE, never against mutable live rows), state staged|rejected|materialized|superseded, persisted warnings/blockers, and agreement_id once materialized (shape CHECK). The live ledger is untouched until finalize

backpay_batches

Below-floor backpay batch ledger (#2223, plan backpay-import-path U1): floor_month is the reconcile floor frozen at creation (month-start CHECK; never updated; every staged, materialized or diverged record month sits strictly before it, and a fresh stage of a month at or above it records a rejected row with at_or_above_frozen_floor; a pair that already has a live record answers from that record first), expected_count (1..50000), manifest_checksum (sha256-hex shape CHECK), created_by / created_by_name, state machine staging|finalizing|finalized|aborted with terminal-timestamp shape CHECKs (finalized_at, aborted_at); staging → finalizing at the finalize gate, and settle moves it back to staging (diverged records, or a manifest key no longer materialized, none staged) or to finalized (#2224). Abort (#2225, the #1071 shape) is allowed only while staging and is refused once finalizing (409 batch-state): it flips the batch’s staged and rejected records to superseded (freeing the pairs the staged ones hold) and stamps aborted_at; a replay on an aborted batch answers it unchanged. Abort never unpays: materialized records and their payments stay (void or adjust them individually); supersede each diverged record to free its month

backpay_records

Below-floor backpay record ledger (#2223): one agreement-month (agreement_id, month-start payment_month) per row in a batch, staged_by (the stage proof’s approver), the stage-judged priced row frozen as canonical_payload + canonical_hash (all-or-none; required on staged/materialized/diverged, NULL on rejected), typed blockers (the stage refusals on rejected; on diverged the finalize diff: judged_row_changed per changed field, canonical_hash_mismatch, at_or_above_frozen_floor, the judged refusal’s token, live_subsidy_row per live payment, or unpublishable_event (#2827)), state staged|rejected|materialized|diverged|superseded. One ADR-074 provenance pair per authorized act: stage (authority_rule_set_id / authority_revision), supersede (superseded_authority_*, beside superseded_by / superseded_at), finalize (finalized_authority_*, stamped by both finalize outcomes: required once materialized_at is set, and set on diverged (#2224)). Live-pair identity: one live record (staged, materialized or diverged) per (agreement_id, payment_month) across all batches (backpay_records_live_pair); rejected and superseded rows free the pair. Records carry no payment-id column (a live_subsidy_row blocker names the live payment in blockers); payments.backpay_record_id points here. Guarded by the BLOCKING invariant subsidy_backpay_bounds: a live backpay payment pays a month below its batch’s frozen floor, never before its agreement’s cutover, and matches its materialized record (#2224)

The five subsidy_agreement* tables form a close-only temporal ledger with a single-writer store (craig_financial::subsidy::store) — see ADR-052 for the window semantics, coverage predicate, and blocking invariants, and ADR-054 for the review chain
verified-office authority (proof-typed writers; nothing approval-shaped is caller-supplied). The store primitives (transition, term append, schedule / complete / reschedule-supersede) land with #1094; the mutation API arrives with U2 (#1095), creation with the eligibility flows (ERR landed with #1069 M2; the SG/NRSG two-step + witnessed activation with #1070/ADR-056; the #1071/ADR-057 closed-cohort conversion import’s substrate — proof-typed materialization over the staging ledger below — with MR-A, its staging/finalize surface with MR-B).

Hard-checks U2 and backpay U-LE add two nullable, all-or-none groups to subsidy_agreements, written only at the two checked enrollment boundaries (ERR create; guardianship activation): the age-check provenance quartet (age_evaluation_id, age_rule_set_revision, dob_used, age_basis_date — CHECK subsidy_agreements_age_provenance_all_or_none) and the late-enrollment witness triple (late_evaluation_id, late_rule_set_revision, late_months_before_floor — CHECK subsidy_agreements_late_witness_all_or_none, count strictly positive; NULL = on-time). Both cite the rules-side rule_evaluations row of the ONE per-request <j>-subsidy-eligibility consult (ADR-072 tier 1).

#1069 M2 (ADR-055) adds six nullable columns to subsidy_agreements — written only by native creation (originally the one-shot ERR create; since #1070 the two-step guardianship create shares placement_started_on, relationship_evidence_key, and the F8 pair); all six are NULL for imports and every pre-existing row. The clock snapshot placement_started_on
foster_home_approval_due (the first day of the qualifying placement and the policy-derived 120-day approval due date) is both-or-neither and forward-running for ERR — originally CHECK subsidy_agreements_approval_clock_valid, reworked by #1070 into the three-shape subsidy_agreements_program_snapshot_valid below. One later writer exists: the #2020 re-anchor (below) re-points placement_id, and re-snapshots placement_started_on for a pending SG / NRSG agreement only. custody_evidence_key / relationship_evidence_key are UNVERIFIED evidence references — object-store keys recorded as supplied; existence is deliberately NOT verified (a recorded ADR-055 non-goal). The F8 idempotency pair create_request_id + create_request_hash (client-supplied request id
canonical-payload SHA-256 hex) is paired by CHECK (subsidy_agreements_create_request_pair) so a replay row can never exist half-keyed, and backed by the partial unique below — the endpoint checks BEFORE volatile dependencies, and the unique turns a two-writers race into a typed replay, never a double enrollment.

#1070 (ADR-056) adds five more nullable columns to subsidy_agreements — the native SG/NRSG guardianship flow is the only writer; all five are NULL for ERR, imports (#1071), and every pre-existing row. The CREATE step (the two-step PENDING mint) writes caregiver_assessment_evidence_key (UNVERIFIED evidence reference: the approved kinship assessment / foster-home evaluation) alongside the shared residence snapshot + F8 pair; the witnessed ACTIVATION writes the rest atomically with the pending → active interval: guardianship_transfer_on (the child’s guardianship exit date, which the witness requires to equal the end date of the anchor’s residence run — #2022, #2059; the transfer proxy, ⁂ #1073; the first Active interval opens here), payments_begin_month (the F2 money boundary: max(month after transfer, month after TANF termination) — the generator pays nothing before it), court_order_evidence_key (UNVERIFIED reference: the permanent-guardianship court order), and tanf_terminated_on (operator ATTESTATION, unverified — CRAIG holds no TANF data). Three CHECKs shape the columns: the ERR-only approval-clock CHECK is DROPPED and replaced by the three-shape program snapshot subsidy_agreements_program_snapshot_valid — all-NULL (legacy/import) | the ERR clock pair (both set, due > start) | the guardianship residence shape (program IN ('sg','nrsg') ∧ placement_started_on set ∧ clock column NULL — SG has no 120-day clock); subsidy_agreements_guardianship_flow_shape couples the flow (a transfer snapshot exists ONLY on a flow-created family agreement with the full activation record — residence snapshot, F8 key, court evidence, money boundary, transfer >= placement_started_on (#2066: the transfer may fall ON the anchor’s first day, because the residence floor reads the run and the run’s last member may start on the exit day; the store refuses a transfer before it as a 400 before the write), and the F1 strict signed_at < transfer); and subsidy_agreements_payments_begin_month_valid pins the boundary to a month START strictly after a PRESENT transfer (TANF can only push it later, and the explicit presence arm avoids a silent > NULL pass). The F12 family-exclusivity partial unique (subsidy_agreements_one_open_guardianship_family, below) is the race backstop. Two REPORT-ONLY invariants watch the flow’s facts, keyed on the flow-written columns so legacy/seed rows never fire: sg_transfer_matches_activation (transfer = the earliest Active interval’s start, plus a flow-scoped completeness arm keyed on Active-interval EXISTENCE — a later termination cannot hide the gap — and a snapshot-without-any-Active bypass arm) and sg_no_payment_before_boundary (no live payment with payment_month < payments_begin_month). #2059 retired sg_residence_floor: the activation’s floor measures from craig-placement’s live residence run, which financial does not store (#2067 stores only the start that admitted the activation, below), so no stored-column check is equivalent.

#2067 adds one nullable column, written only by the witnessed activation in the UPDATE that writes the transfer: residence_started_on, the first day of the anchor’s residence run that the activation measured the residence floor from (craig-placement’s residence.started_on, read before the transaction; P-B2 D5). craig-placement derives the run at read time, so a later correction, retraction or historical record moves the live run; the stored day stays the one that admitted the activation, and an exact replay writes nothing. placement_started_on stays the anchor’s own start (the ERR coverage start). NULL before activation, on ERR and imported rows, and on an agreement activated before #2067 or by a pre-#2067 binary — never backfilled: the admitting start was not recorded. CHECK subsidy_agreements_residence_start_valid: present only beside the transfer, and on or before it (the transfer is the run’s end day). The agreement detail (GET /v1/financial/subsidy-agreements/{id}) serves it as residence_started_on.

#2020 (the ADR-052 anchor-replacement amendment) adds no column and no migration; it adds one writer of the anchor. A placement entered in error is retracted, and its replacement names it in replaces_placement_id on placement.activated or placement.recorded. On either event, in the consuming attempt’s transaction (ADR-062), the re-anchor (inbox/anchor_replacement.rs) takes the replacement child’s pay-exclusion lock, locks that child’s agreements still anchored to the retracted id (FOR UPDATE, in id order), and moves each one:

  • placement_id is re-pointed to the replacement, whatever the agreement’s status;

  • placement_started_on is re-snapshotted to the replacement’s start (the jurisdiction business date of its started_at) ONLY for a pending SG / NRSG agreement that already carries the snapshot: the guardianship residence shape is the one shape subsidy_agreements_program_snapshot_valid lets change alone. An ERR snapshot is paired with its approval clock, and an all-NULL (legacy / import) shape stays NULL — the re-anchor never fabricates a snapshot;

  • nothing else moves: no interval, term or coverage. An active or suspended agreement, a pending one moved without a re-snapshot, or a move onto a replacement that is itself already terminated raises one manual-review WARN (#1070-class).

Each moved agreement stages one financial.subsidy_anchor_replaced (agreement_id, from_placement_id, to_placement_id, agreement_status, the present-only previous_started_on / placement_started_on pair on a re-snapshot, created_by = system). An agreement on the retracted id that names another child is logged at ERROR and left in place (R-B21 makes it unreachable). The act is replay-idempotent: after the first commit no same-child row names the retracted id. Until the replacement lands, placement.retracted logs one WARN per live agreement anchored to the retracted id, and a pending guardianship agreement on it cannot activate: the activation witness refuses a retracted anchor with a detail naming the re-anchor remedy.

Disbursed money on a retracted arrangement (#2041). The retract voids only undisbursed per-diems. The report-only invariant perdiem_disbursed_on_retracted_placement names the rest from the two facts above. Arm retracted: each issued or cleared per-diem of a placement whose tombstone carries retracted_at. Arm replacement_overlap: each live per-diem of a replacement whose period overlaps an issued or cleared per-diem of the arrangement it replaces, same child (the #1179 key cannot see across the two ids; only an activation bills, so only a live replacement can produce one). Disbursed rows are never auto-corrected, and the #1028 manual void refuses them (400 disbursed-payment-void): the remedy is a payment adjustment (#1078), never a clawback. When a submitted or accepted claim covers the row, the adjustment’s approval is refused (409 claimed-payment-frozen, #1357): that post-claim correction is the amendment vehicle, a DFCS decision (#1073). Limits: a replacement of a replacement is compared with its own predecessor only (an older disbursed row is still named by arm retracted), and an active subsidy agreement re-anchored to a replacement keeps its coverage, a manual review on the re-anchor WARN (#1070-class), not an arm here.

#1071 (ADR-057) adds the conversion substrate (migration 20260725090000_subsidy_import_ledger.sql): the two staging tables above, plus ONE column on subsidy_agreements — payment_cutover_month, the machine money boundary written by the materializing identity insert (SHINES pays every month strictly before it, CRAIG from it onward; the generator’s BeforeCutover rule enforces CRAIG’s side on the scheduled, manual, AND reconcile paths). Two CHECKs shape it: subsidy_agreements_cutover_iff_imported (present exactly when source_system is set — provenance all-or-none extends to the money boundary) and subsidy_agreements_cutover_month_start. Family exclusivity widens to the full taxonomy (ADR-057 D8): the #1070 guardianship one-open index is RECREATED over ('sg','nrsg','ersg','enrsg') and a NEW relative-care one-open index covers ('rcs','ercs') — safe pre-1.0 because import is the only path that can mint enhanced/relative-care rows. idx_subsidy_agreements_import_batch (partial, WHERE import_batch_id IS NOT NULL) serves batch reconciliation. Four BLOCKING invariants guard the substrate: subsidy_active_missing_review_slot (every active/suspended head holds a live renewal slot, plus a paper slot for non-ERR programs when the head terms carry a paper anchor — scoped to imported rows and any row whose review chain already exists, so a native row whose chain never materialized is exempt), subsidy_terms_cover_active (every Active interval priced from its first day), subsidy_closed_cohort_qualifying_date (rcs/ercs first received before 2014-01-01, ersg/enrsg before 2014-08-01 — earliest Active start, signed_at fallback), and subsidy_cutover_iff_imported (the DDL shape plus the money consequence: no live payment before the cutover).

#1072 adds the UAS payment classification (migration 20260725160000_subsidy_uas_classification.sql): subsidy_agreements.uas_code TEXT NOT NULL — derived by the service at the only write boundaries (native create + conversion import) from the active state bundle’s effective-dated vocabulary as of the write’s business date, immutable thereafter (as-of snapshot: a vocabulary change never re-derives a row) — and payments.uas_code TEXT, denormalized from the AGREEMENT at the generator’s single insert site (deliberately outside the RowShape derivation compare, so vocabulary changes can never void/regenerate rows). The migration backfilled pre-#1072 rows with GA literals (every historical row is GA-shaped — subsidy writes have been jurisdiction-gated since the table’s birth), drift-pinned against the GA bundle by uas_backfill_matches_the_georgia_bundle. Shapes: subsidy_agreements_uas_code_nonblank and payments_uas_iff_subsidy_origin ((uas_code IS NULL) = (agreement_id IS NULL) — per-diem billing rows have no enrollment to classify). One new BLOCKING invariant: subsidy_payment_uas_consistent (a payment’s code always equals its agreement’s).

subsidy_perdiem_handoffs (#1069 M3/ADR-055) is the durable "per diem began" fact ledger: a mutable billing row is not the fact — the payment can be voided, repriced, or re-pointed after the sweep acted on it. Columns: agreement_id (FK subsidy_agreements ON DELETE CASCADE, like every agreement child table — production never deletes agreements; a dev/test delete takes the ledger with it), payment_id (FK payments), perdiem_started_on (the per diem’s period_start as detected — the F6 termination truth date, max’d with head start + 1 day at enforcement), detected_run_id and nullable enforced_run_id (both FK subsidy_sweep_runs), and the correction pair corrected_at
correction_note. Its writers are the M3 sweep engine and store: detection inserts once per (agreement, payment) on every scheduled sweep scan (subsidy_perdiem_handoffs_once UNIQUE); leg-3 enforcement stamps enforced_run_id (NULL while detected-only — knob off, or an operator acted manually); a state-office reinstatement out of a per_diem_begins termination stamps corrected_at + correction_note on every uncorrected fact on the agreement (the per diem itself must be voided/ended first). A note cannot exist unstamped (CHECK subsidy_perdiem_handoffs_note_shape). Rows are never deleted.

The AFCARS (b)(18) read (P-D1, #2123)

P-D1 built GET /v1/financial/afcars-facts (#2123), craig-financial’s first service-only route. Only the bare craig-reporting service principal may call it; any other caller, or a relayed (channel) token, is 403 before any read.

  • Query. from and to are local midnights on the jurisdiction clock, from before to; as_of is at least 5 minutes in the past. A failed check is a bad-request 400 naming the field.

  • Predicate. A child is answered when it has a payments row with agreement_id IS NULL (a per diem, never a subsidy), status issued or cleared, an IV-E share at as_of above zero, and issued_at in [from, to) and at or before as_of. An absent child is (b)(18) no.

  • As of (#2131 D1, D3). The share at as_of is round((net_amount − Σ amount of the approved adjustments whose approved_at > as_of) × ffp_rate, 2) when ive_eligible, else 0; with no approval after as_of it is ffp_amount. status needs no history: a payment issued at or before as_of was issued then and can only become cleared. Since #2185 the schema refuses every status change of an issued or cleared payment but issued → cleared (trg_payments_disbursed_moves_forward) and any change to an approved adjustment’s payment_id, amount, status or approved_at (trg_payment_adjustments_approved_history_fixed). No column reads current, so reads at one as_of agree on every page.

  • Pages. Distinct child_ids, ascending, at most limit (1..=1000) per page. next is an opaque cursor over the last child id, present only when the page is full.

  • No audit. The page carries ids only: no audit key and no transaction. The body is Cache-Control: no-store.

ER Diagram

rate_tablesuuididPKtextjurisdictiontextpayment_typeintegerage_minintegerage_maxnumericdaily_ratedateeffective_datedateend_datenullablebigintversionIf-Match CAS counter (ADR-062 §G3)timestamptzcreated_atpaymentsuuididPKuuidcase_idnullable; FK to craig_casesuuidchild_idFK to craig_casesuuidplacement_idnullable; FK to craig_placementuuidfoster_home_idnullable; FK to craig_placementuuidagreement_idnullable; FK subsidy_agreements (#1068)uuidterm_idnullable; composite FK subsidy_agreement_termsuuidbackpay_record_idnullable; FK backpay_records RESTRICT, unique where set, subsidy rows only (#2223)textpayment_typedateperiod_startdateperiod_endnumericdaily_rateintegerday_countnumericgross_amountnumericadjustmentsnumericnet_amountbooleanive_eligibleexplicit at every write (#1313 U5 dropped the false DEFAULT)numericffp_rateexplicit at every write (#1313 U5 dropped the 0 DEFAULT)bigintive_revisionnullable; the verdict revision priced under (#1313 U5); NULL = never determinednumericffp_amountGENERATEDtextstatuspending|approved|issued|cleared|voidedtextapproved_bynullabletextapproved_by_namenullabletimestamptzapproved_atnullabletextissued_bynullabletextissued_by_namenullabletimestamptzissued_atnullabletextcleared_bynullabletextcleared_by_namenullabletimestamptzcleared_atnullabletextvoided_bynullable; manual void only (#1028)textvoided_by_namenullabletimestamptzvoided_atnullabletextvoid_reasonnullable; row-only, never on eventstextcreated_bytimestamptzcreated_attimestamptzupdated_atuuidassigned_worker_subnullable; authz denorm (Plan A D6)uuidsupervisor_subnullable; authz denorm (#1084)bigintassignment_revision#1312 ordering guardtextadmin_unitnullable; unit stamp at birth, healed unit-only (#1901)payment_adjustmentsuuididPKuuidpayment_idFKtextreasonnumericamounttextrequested_bytextapproved_bynullabletimestamptzapproved_atnullabletextstatuspending|approved|deniedtimestamptzcreated_atuuidassigned_worker_subnullable; authz denormuuidsupervisor_subnullable; authz denorm (#1084)bigintassignment_revision#1312 ordering guardtextadmin_unitnullable; copied from the parent payment FOR SHARE (#1901)claiming_recordsuuididPKtextclaiming_periodtextpayment_typenumerictotal_expenditurenumericive_eligible_amountnumericffp_claimednumericnon_ive_amountnumericccwis_operations_costtextstatusdraft|submitted|acceptedtimestamptzsubmitted_atnullabledateperiod_startnullable; aggregation window (#1357)dateperiod_endnullable; both-or-neither CHECKtimestamptzcreated_athas

The subsidy-agreement ledger (ADR-052) is a separate cluster:

subsidy_agreementsuuididPKuuidchild_idcases.personsuuidcase_idnullabletextprogramerr|sg|nrsg|ersg|enrsg|rcs|ercstextcurrent_statusprojection of interval headtextform_numberdatesigned_attextsource_systemimport provenance, all-or-noneuuidpredecessor_agreement_idFKnullable, uniqueuuidassigned_worker_subnullableuuidsupervisor_subnullable (#1084)textadmin_unitnullable; from the projection at create, NULL for imports (#1901)dateplacement_started_onnullable; residence snapshot (#1069/Ю pending sg/nrsg re-anchor re-snapshots, #2020)datefoster_home_approval_duenullable; ERR-only clock duetextcustody_evidence_keynullable; UNVERIFIED store keytextrelationship_evidence_keynullable; UNVERIFIED store keyuuidcreate_request_idnullable; F8 pair, partial uniquetextcreate_request_hashnullable; payload SHA-256 hexdateguardianship_transfer_onnullable; activation snapshot (#1070)dateresidence_started_onnullable; admitting residence-run start (#2067)datepayments_begin_monthnullable; F2 money boundary (#1070)textcourt_order_evidence_keynullable; UNVERIFIED store keydatetanf_terminated_onnullable; operator attestation (#1070)textcaregiver_assessment_evidence_keynullable; UNVERIFIED store keydatepayment_cutover_monthnullable; iff imported (#1071)subsidy_import_batchesuuididPKtextsource_systemvocabulary: shinesdatesnapshot_datethe review baseline (#1071)datecutover_monthmonth start, > snapshotintegerexpected_count1..50000textmanifest_checksumsha256 hextextstatusstaging|finalizing|finalized|abortedsubsidy_import_recordsuuididPKuuidbatch_idFKtextexternal_referencelive-unique across batchesjsonbcanonical_payloadimmutable replay evidencetextcanonical_hashsha256 hextextstatusstaged|rejected|materialized|supersededjsonbwarningsjsonbblockersuuidagreement_idnullable; set when materializedbackpay_batchesuuididPKdatefloor_monthreconcile floor frozen at creation (#2223)integerexpected_count1..50000textmanifest_checksumsha256 hextextstatusstaging|finalizing|finalized|abortedbackpay_recordsuuididPKuuidbatch_idFKuuidagreement_idFKdatepayment_monthmonth start; live-unique per agreementtextstaged_bythe stage proof approverjsonbcanonical_payloadnullable; the stage-judged priced row, NULL on rejectedtextcanonical_hashnullable; sha256 hex, paired with the payloadtextstatusstaged|rejected|materialized|diverged|supersededjsonbblockerstyped BackpayBlocker listuuidauthority_rule_set_idnullable; stage provenance pair (ADR-074)uuidsuperseded_authority_rule_set_idnullable; supersede provenance pairuuidfinalized_authority_rule_set_idnullable; finalize provenance pair (U2)subsidy_agreement_partiesuuididPKuuidagreement_idFKuuidperson_idcases.persons, never the childtextrolecaregiver|co_caregiversubsidy_agreement_termsuuididPKuuidagreement_idFKintegerrevisioncontiguous 1..ndateeffective_fromhalf-open windowdateeffective_untilnullable = opennumericmonthly_amountdaterenewal_review_duedatepaper_review_dueNULL for ERRtextapproved_bytextapproval_levelsubsidy_agreement_status_intervalsuuididPKuuidagreement_idFKtextstatus6-token vocabularydateeffective_frombusiness timedateeffective_untilnullable = opentextreason_coderequired for reason statusestextapproved_bysubsidy_agreement_reviewsuuididPKuuidagreement_idFKtextreview_typerenewal_12mo|paper_6mointcyclechain identity, >= 1datedue_onstatutory data, never shifteddatecompleted_onnullable; open slot when NULLtextapproval_levelderived office | system | NULLtextsupervisor_approved_bypair with _atuuidresulting_term_idFKcomposite, same agreementuuidresulting_interval_idFKcomposite, same agreementtimestamptzsuperseded_atall-or-none with _by/_reasonsubsidy_perdiem_handoffsuuididPKuuidagreement_idFKON DELETE CASCADEuuidpayment_idFK paymentsdateperdiem_started_onF6 truth dateuuiddetected_run_idFK subsidy_sweep_runsuuidenforced_run_idnullable = detected-onlytimestamptzcorrected_atnullabletextcorrection_notenullable; requires corrected_atsigned byterm revisionsstatus ledgerreviews (22.9)handoff facts (#1069 M3)predecessor (re-application)stages (#1071)materialized as (#1071)stages (#2223)agreement-month of (#2223)

State Machines

Payment Status

pending → approved → issued → cleared
    pending | approved → voided
  • pending: Payment calculated, awaiting supervisor approval

  • approved: Supervisor approved, queued for issuance

  • issued: Payment disbursed to foster parent/provider

  • cleared: Payment confirmed received/settled

  • voided: Payment cancelled before disbursement (from pending or approved); issued or cleared → voided is refused by the row guard trg_payments_disbursed_moves_forward (#2185), as is any rewind of a disbursed payment

Adjustment Status

pending → approved
pending → denied
  • pending: Adjustment requested, awaiting supervisor review

  • approved: Adjustment approved, payment net_amount updated; terminal, and its payment_id, amount, status and approved_at never change (trg_payment_adjustments_approved_history_fixed, #2185)

  • denied: Adjustment rejected

Claiming Record Status

draft → submitted → accepted
  • draft: Claim generated, expenditures aggregated, under review

  • submitted: Claim submitted to ACF for federal reimbursement

  • accepted: Claim accepted by ACF

Backpay Record Status

staged → materialized | diverged    (finalize, U2)
staged → superseded                 (the supersede act)
rejected → superseded               (a fresh stage of the pair in the same batch)
diverged → superseded               (the supersede act)
materialized → superseded           (the supersede act)
staged → superseded                 (batch abort, #2225)
rejected → superseded               (batch abort, #2225)
  • staged: the stage act judged the agreement-month payable and froze the priced row; live. Supersede is refused once its batch has left staging

  • rejected: the stage act refused the month with typed blockers; no payload, never finalized; frees the pair

  • materialized: finalize wrote its payment, the payment_created event and the flip in one transaction, stamping the finalize pair (U2); live

  • diverged: finalize’s fresh judgment, the frozen row’s hash, the frozen floor or a live subsidy row on the child-month disagreed with the frozen row (U2); the diff is in blockers, the finalize pair is stamped, no payment exists; live, holding the pair until it is superseded

  • superseded: freed by the supersede act (stamping superseded_by, superseded_at and its provenance pair), or a rejected verdict replaced by a fresh stage; terminal. A materialized record supersedes only while no non-voided payment references it: an undisbursed payment is voided first, a disbursed one is corrected through a payment adjustment and its record stays. superseded_by NULL means the record was freed without the supersede act: a batch abort (staged or rejected), or a re-stage over a rejected verdict (rejected only)

Backpay Batch Status

staging → finalizing        (the finalize gate, U2)
finalizing → finalizing     (settle: staged records remain; the next pass resumes)
finalizing → staging        (settle: none staged, but a record diverged or a manifest key is not materialized)
finalizing → finalized      (settle: every manifest key materialized)
staging → aborted           (the abort act, #2225; refused once finalizing)
  • staging → finalizing: under the batch lock, the gate refuses a finalizer who staged a staged or materialized record of the batch, then refuses unless no record is rejected, staged + materialized equals expected_count, the sorted record keys hash to manifest_checksum and the (record_key, canonical_hash) pairs hash to the reviewed content_checksum (ruling F1)

  • finalizing (resume): the gate re-runs only the stager-not-finalizer check, not the manifest legs; stage refuses a fresh record and a staged record cannot be superseded, so no record joins the verified set

  • finalizing → staging: no record staged, but one diverged, or fewer records are materialized than expected_count (a manifest key superseded off while finalizing, ruling F-B of 2026-10-08); no summary event. The operator supersedes, re-stages and finalizes again, and the gate re-verifies

  • finalized: stamps finalized_at and stages one financial.subsidy_backpay_batch_finalized (counts and the finalizing operator as user_id, #2248) in the same transaction; a later pass replays the ledger’s report

  • staging → aborted: under the batch lock, the batch’s staged and rejected records flip to superseded with superseded_by NULL (no supersede act ran) and the batch stamps aborted_at; diverged and materialized records keep their status, and a materialized record keeps its payment. finalizing and finalized refuse (409 batch-state): money consent has started

Indexes

Index Columns

idx_payments_case

payments(case_id)

idx_payments_child

payments(child_id)

idx_payments_foster_home

payments(foster_home_id)

idx_payments_status

payments(status)

idx_payments_period

payments(period_start, period_end)

idx_payments_perdiem_by_child

partial payments(child_id, period_start, id) WHERE agreement_id IS NULL AND status <> 'voided' — leg 3’s access path: the scan and the enforce-time re-verify both want "earliest live placement-origin payment for a child" (#1069 M3)

idx_payments_admin_unit

partial payments(admin_unit) WHERE admin_unit IS NOT NULL — serves the unit-scoped list’s admin_unit = ANY($n) bind (#1901 lays the column and index; the bind itself is ADR-077 D5, a later unit of the plan); the assigned_worker_sub precedent’s shape — a NULL stamp is matched by no scope, so it is never indexed

idx_payment_adjustments_admin_unit

partial payment_adjustments(admin_unit) WHERE admin_unit IS NOT NULL (#1901)

idx_subsidy_agreements_admin_unit

partial subsidy_agreements(admin_unit) WHERE admin_unit IS NOT NULL (#1901)

idx_claiming_period

claiming_records(claiming_period)

subsidy_agreements_one_open_per_child_program

partial UNIQUE subsidy_agreements(child_id, program) WHERE current_status NOT IN (terminal) — one open episode

subsidy_agreements_import_replay_key

partial UNIQUE subsidy_agreements(source_system, external_reference) — idempotent import

subsidy_agreements_one_successor

partial UNIQUE subsidy_agreements(predecessor_agreement_id) — no lineage branching

idx_subsidy_agreements_{child,case,status,worker,supervisor}

subsidy_agreements filter columns (worker/supervisor partial NOT NULL)

subsidy_agreements_create_request_id

partial UNIQUE subsidy_agreements(create_request_id) WHERE create_request_id IS NOT NULL — F8 backstop: one agreement per create request; a two-writers race becomes a typed replay, never a double enrollment (#1069 M2)

subsidy_agreements_err_clock

partial subsidy_agreements(foster_home_approval_due) WHERE program = 'err' AND current_status = 'active' — the operator clock queue: active ERR agreements ordered by approval due date (#1069 M2)

subsidy_agreements_one_open_guardianship_family

partial UNIQUE subsidy_agreements(child_id) WHERE program IN ('sg', 'nrsg', 'ersg', 'enrsg') AND current_status IN ('pending', 'active', 'suspended') — family exclusivity: at most ONE open guardianship-family enrollment per child (alternative classifications of the same enrollment, not parallel programs). Created by #1070 (F12, sg/nrsg), RECREATED by #1071/ADR-057 D8 over all four family tokens (safe pre-1.0 — import is the only path that can mint the enhanced variants); the store takes family history locks in the canonical order first, so racing writers serialize before this backstop fires

subsidy_agreements_one_open_relative_care_family

partial UNIQUE subsidy_agreements(child_id) WHERE program IN ('rcs', 'ercs') AND current_status IN ('pending', 'active', 'suspended') — the relative-care family’s one-open backstop (#1071/ADR-057 D8)

idx_subsidy_agreements_import_batch

partial subsidy_agreements(import_batch_id) WHERE import_batch_id IS NOT NULL — batch reconciliation queries were full-table scans (#1071 G10)

subsidy_import_records_live_reference

partial UNIQUE subsidy_import_records(external_reference) WHERE status IN ('staged', 'materialized') — one LIVE claim per source record across ALL batches; superseded/rejected rows free the key for corrections and re-imports (#1071/ADR-057 D4)

idx_subsidy_import_records_batch

subsidy_import_records(batch_id, status) — the finalize keyset loop + batch reconciliation listing (#1071)

backpay_records_live_pair

partial UNIQUE backpay_records(agreement_id, payment_month) WHERE status IN ('staged', 'materialized', 'diverged') — one LIVE record per agreement-month across ALL batches; rejected/superseded rows free the pair, a diverged record holds it until superseded (#2223)

idx_backpay_records_batch

backpay_records(batch_id, status) — per-batch record scans by status, for the finalize loop and batch reads U2 and U-AUTHZ add (#2223)

payments_backpay_record_unique

partial UNIQUE payments(backpay_record_id) WHERE backpay_record_id IS NOT NULL — one payment per backpay record, ever; a voided payment keeps its link (#2223)

idx_subsidy_agreement_parties_person

subsidy_agreement_parties(person_id) — the foster-parent portal’s payments projection reads subsidy rows BY PARTY (the bound persons' agreements, once per admitted portal request); the table’s UNIQUE (agreement_id, person_id) key cannot be entered by person alone and every other read is by agreement (#1852; additive — no floor bump)

subsidy_agreement_{terms,intervals}_one_open

partial UNIQUE (agreement_id) WHERE effective_until IS NULL — at-most-one open head each

idx_subsidy_agreement_{terms,intervals}_window

(agreement_id, effective_from) — as-of scans

idx_subsidy_agreement_reviews_due

partial (due_on) WHERE completed_on IS NULL AND superseded_at IS NULL — global due-work scan (superseded slots leave the scan, #1094)

subsidy_agreement_reviews_one_open

partial UNIQUE (agreement_id, review_type) WHERE completed_on IS NULL AND superseded_at IS NULL — one open slot per type, race-free replay target

subsidy_agreement_reviews_cycle_live

partial UNIQUE (agreement_id, review_type, cycle) WHERE superseded_at IS NULL — one live-or-completed row per cycle (supersession history keeps its cycle). The old (agreement_id, review_type, due_on) unique is DROPPED (pre-1.0): statutory due dates are data, never shifted for key collisions

subsidy_agreement_intervals_agreement_id_id_key

UNIQUE subsidy_agreement_status_intervals(agreement_id, id) — the composite-FK target resulting_interval_id needs (terms-side mirror pre-existed)

subsidy_reconcile_queue_live

partial UNIQUE subsidy_reconcile_queue(agreement_id, month) WHERE processed_at IS NULL — one live pair; enqueue replays no-op (ON CONFLICT DO NOTHING)

idx_subsidy_reconcile_queue_pending

partial subsidy_reconcile_queue(enqueued_at) WHERE processed_at IS NULL — the generator drain’s fetch order

subsidy_perdiem_handoffs_once

UNIQUE subsidy_perdiem_handoffs(agreement_id, payment_id) — detect-once: one fact per (agreement, payment) forever (#1069 M3)

idx_subsidy_perdiem_handoffs_agreement

subsidy_perdiem_handoffs(agreement_id) — correction stamping + operator lookups walk by agreement (#1069 M3)

Cross-Service References

The financial service references entities from other services by UUID (no foreign keys across databases):

  • payments.case_id → craig_cases.cases.id

  • payments.child_id → craig_cases.persons.id

  • subsidy_agreements.child_id → craig_cases.persons.id

  • subsidy_agreements.case_id → craig_cases.cases.id

  • subsidy_agreements.placement_id → craig_placement.placements.id

  • subsidy_agreement_parties.person_id → craig_cases.persons.id

The four subsidy references are walked by craig-manage reconcile (cross-service reconciliation). * payments.placement_id → craig_placement.placements.id * payments.foster_home_id → craig_placement.foster_homes.id

Rate Lookup and the Rate Class

Rate table lookups use jurisdiction (the one the configuration layers name, CRAIG_CONFIG_SOURCE) and the arrangement’s rate class to match the daily rate for the child’s age (#2056, plan afcars-placement-facts D5). The class is a RateClass token (foster_care, kinship, therapeutic, pre_adoptive, group_home, residential, supervised_independent_living): the token the per-diem lookup matches against rate_tables.payment_type and stamps on the per-diem’s payments.payment_type (a subsidy row carries subsidy_<program>). On placement.activated, rate_class (services/craig-financial/src/rate_class.rs) derives it from the setting and its (e)(3) ffh_types under the state bundle’s rate_class_policy(). A family home takes the first category in the policy’s precedence that applies, else the family default; a congregate setting takes its listed class. The default policy, TODAYS_PAYMENT_TYPES, reads pre-adoptive, then therapeutic, then licensed (foster_care), then relative or kin (kinship), else foster_care. A non-caregiving setting has no class and bills nothing, with no quality signal (#2057); a homed caregiving setting the policy leaves unclassed stages financial.payment_generation_skipped with no_applicable_rate, as a missing rate row does.

ERR (the subsidy program) does not read the rate class. An ERR agreement qualifies on a foster_family_home anchor that carries one of the bundle policy’s err_qualifying_home_types and none of its err_disqualifying_home_types (SubsidyPolicySpec; qualifies_for_err, services/craig-financial/src/subsidy/policy.rs; the licensed-home disqualifier is a #1073 reading). The ERR create refuses any other anchor (400). A re-anchor (#2020) onto a replacement that fails the rule still moves the agreement; a live one raises a manual-review WARN (#1070-class).

Edit this page · latest