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: |
starts after the last paid day |
voided, as before, and named in the pass’s one |
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 |
|---|---|
|
#1193 durable placement-termination tombstone: |
|
#2041 durable replacement link: one row per replacement placement ( |
|
#1632: financial’s authoritative case-assignment projection — placement’s #1213 table
mirrored ( |
|
#1313 U5: the persisted per-child IV-E verdict state — one row per |
|
#1313 U5: the invalidation SET — |
|
#1313 U5b: the claim build’s verdict-gate evidence — one row per disbursed per-diem
payment kept OUT of a claim’s totals ( |
|
Jurisdiction-specific daily payment rates by type and age range |
|
Foster care maintenance, adoption assistance, and guardianship assistance payments.
#1901: |
|
Corrections or supplements to payment amounts (e.g., clothing allowance).
#1901: |
|
#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 |
|
Aggregated IV-E/non-IV-E expenditures for federal fiscal claiming (CFS-2).
#1357: each row stamps the aggregation window it was generated over
( |
|
Kinship-subsidy agreement IDENTITY (GA 22.8/22.9; ADR-052) — immutable signed-artifact metadata, import provenance, predecessor lineage; |
|
Agreement signatories (caregiver / co-caregiver; never the child) |
|
Effective-dated immutable term revisions (amount + basis, review schedule, education extension, approval binding); half-open windows, close-only |
|
Business-effective status ledger (pending/active/suspended/terminated/withdrawn/declined + reason codes + approvals); the authoritative status record |
|
22.9 review chain (renewal_12mo/paper_6mo): three-state rows — completed / open slot / superseded — with cycle identity, derived |
|
Durable payment-repair feed (#1081/ADR-054): one live |
|
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. |
|
Durable per-diem handoff fact ledger (#1069 M3/ADR-055): one detection row per |
|
Conversion-batch ledger (#1071/ADR-057): one row per SHINES conversion run — |
|
Conversion-record staging ledger (#1071/ADR-057 D1/D4): one row per source record — |
|
Below-floor backpay batch ledger (#2223, plan |
|
Below-floor backpay record ledger (#2223): one agreement-month ( |
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_idis re-pointed to the replacement, whatever the agreement’s status; -
placement_started_onis re-snapshotted to the replacement’s start (the jurisdiction business date of itsstarted_at) ONLY for a pending SG / NRSG agreement that already carries the snapshot: the guardianship residence shape is the one shapesubsidy_agreements_program_snapshot_validlets 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.
fromandtoare local midnights on the jurisdiction clock,frombeforeto;as_ofis at least 5 minutes in the past. A failed check is abad-request400 naming the field. -
Predicate. A child is answered when it has a
paymentsrow withagreement_id IS NULL(a per diem, never a subsidy),statusissuedorcleared, an IV-E share atas_ofabove zero, andissued_atin[from, to)and at or beforeas_of. An absent child is (b)(18)no. -
As of (#2131 D1, D3). The share at
as_ofisround((net_amount − Σ amount of the approved adjustments whose approved_at > as_of) × ffp_rate, 2)whenive_eligible, else 0; with no approval afteras_ofit isffp_amount.statusneeds no history: a payment issued at or beforeas_ofwasissuedthen and can only becomecleared. Since #2185 the schema refuses every status change of anissuedorclearedpayment butissued→cleared(trg_payments_disbursed_moves_forward) and any change to an approved adjustment’spayment_id,amount,statusorapproved_at(trg_payment_adjustments_approved_history_fixed). No column reads current, so reads at oneas_ofagree on every page. -
Pages. Distinct
child_ids, ascending, at mostlimit(1..=1000) per page.nextis 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.
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
pendingorapproved);issuedorcleared→voidedis refused by the row guardtrg_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,statusandapproved_atnever 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_createdevent 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_atand its provenance pair), or arejectedverdict replaced by a fresh stage; terminal. Amaterializedrecord 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_byNULL means the record was freed without the supersede act: a batch abort (stagedorrejected), or a re-stage over a rejected verdict (rejectedonly)
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
stagedormaterializedrecord of the batch, then refuses unless no record is rejected, staged + materialized equalsexpected_count, the sorted record keys hash tomanifest_checksumand the(record_key, canonical_hash)pairs hash to the reviewedcontent_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_atand stages onefinancial.subsidy_backpay_batch_finalized(counts and the finalizing operator asuser_id, #2248) in the same transaction; a later pass replays the ledger’s report -
staging → aborted: under the batch lock, the batch’s
stagedandrejectedrecords flip tosupersededwithsuperseded_byNULL (no supersede act ran) and the batch stampsaborted_at;divergedandmaterializedrecords keep their status, and amaterializedrecord keeps its payment.finalizingandfinalizedrefuse (409batch-state): money consent has started
Indexes
| Index | Columns |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
partial |
|
partial |
|
partial |
|
partial |
|
|
|
partial UNIQUE |
|
partial UNIQUE |
|
partial UNIQUE |
|
|
|
partial UNIQUE |
|
partial |
|
partial UNIQUE |
|
partial UNIQUE |
|
partial |
|
partial UNIQUE |
|
|
|
partial UNIQUE |
|
|
|
partial UNIQUE |
|
|
|
partial UNIQUE |
|
|
|
partial |
|
partial UNIQUE |
|
partial UNIQUE |
|
UNIQUE |
|
partial UNIQUE |
|
partial |
|
UNIQUE |
|
|
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).