Data Model: Case Management
Overview
The case management service tracks the full lifecycle from hotline referral through case closure.
Closed cases are read-only below the case row (#1631). Every case-parented write —
household add, contact create/update/delete, plan create/update/approve, task
create/update/delete, court order create/update/delete, contact-attachment delete, both
upload routes (refused before an attempt is born; an attempt that outlives the closure fails
terminally as target_gone through the attempt machine), IV-E determination, and the record
and close acts of the P-C case-route ledgers (the child-fact ledgers, ICWA, parental-rights actions, permanency plans and
review events), and the legal-status acts that open, change or close a custody episode (an until record included) — passes ONE
store choke point,
require_case_open, inside its own transaction: the case row is locked FOR UPDATE and the
write refuses with a typed 409 case-closed unless the case is open (closed and
transferred both refuse). Holding the row lock for the rest of the write makes the gate
race-free against a concurrent closure, and the refusal rolls the whole transaction back —
the ADR-062 claim included, so a retried client_request_id is not burned. The case row’s
OWN edits are not gated here (reopening is refused separately as INVALID_STATE_TRANSITION);
inbox/worker writes and screening-review assignment stay allowed on closed cases. The one
deliberate exception on a case-parented table: a P-C case-route ledger’s CORRECTION and
RETRACTION are admitted on a closed or transferred case (they amend the record of what was true,
not the case’s lifecycle — The child-fact ledgers and the sibling ledger (#1992, ADR-078)). The legal-status ledger widens it by two acts
that open nothing: a history row (a not-in-custody status naming no episode) and the custody-episode
retract also pass on a closed or transferred case (#2342, Custody episodes and the legal-status ledger (#2342, ADR-081, plan custody-episodes-doe-slds D2 + D3)). The reverse also
holds: a case cannot become closed or transferred while one of its custody episodes is open (409
custody-open, a database trigger).
The placement-facts read (#2029). The placement-facts projection
(GET /v1/cases/cases/{case_id}/children/{child_id}/placement-facts, ADR-073) refuses a closed or
transferred case with the same typed 409 case-closed. It is decided after the acting worker’s
case: read check (a refused caller still reads 403 and learns nothing of the status) and before the
one-clock rule, membership, the date of birth and the ICWA consult. The check takes no lock
(refuse_unless_open): the read has no write to lock, and craig-placement holds no case lock, so a case
can close between the read and placement’s commit. craig-placement relays the 409 unchanged on every
route that reads the projection.
Recorders name the acting worker (#2214). No craig-cases write records 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() (ADR-028, ADR-062), the lifted worker, or the token’s own subject when nothing is lifted.
That covers the contact, case-plan (create and approval), referral (conversion), follow-up, safety-assessment and
report-person-link recorder columns, and the case.plan_approved approved_by and the case.report_converted /
report-person link user_id event payload keys (user_id since #2211; was converted_by / linked_by /
unlinked_by). Each name column is the acting worker’s username. A caller-named subject (a case’s or an
investigation’s assigned worker, a case supervisor) is named only when it IS the acting worker, else NULL (#1366; the
investigation open since #2320). Writes that record a relayed
or copied actor (craig-exchange’s body.requested_by, an upload attempt’s created_by) and the system auto-link
(linked_by NULL) are unchanged. 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-cases/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 (after
#2016, #2031 and #2231; #2740 removed parse_sub / parse_actor_sub).
Lock order: persons before cases (#1680). Two row-lock families meet in this schema — the
person row (lock_person, FOR NO KEY UPDATE; every UPDATE persons takes the same strength,
since the table has no unique index beyond its primary key) and the case row (require_case_open,
lock_case_for_screening, and the two sorted ORDER BY id FOR UPDATE fan-outs). A writer that
needs both takes the PERSON first: update_person, the SSN clear, the two link-time SSN
promotions (report-person link, SSN promotion), and the SSA outcome transaction (person lock at
its step 2, before the fact inserts and the review-item fan-out).
Writers that hold a case row and then INSERT a person-referencing row (household add, IV-E child
verdicts) take only an FK KEY SHARE on the person, which FOR NO KEY UPDATE does not exclude —
they never wait on a person writer, so the person writer’s later case lock cannot close a cycle.
SELECT … FROM persons … FOR UPDATE is therefore forbidden in service code (a KEY SHARE parks
behind it and the fan-out deadlocks: 40P01, the victim a 500). Columns with REFERENCES
persons(id): allegations.victim_id/perpetrator_id, case_household.person_id,
report_persons.person_id, ssa_benefit_facts.person_id, ssa_screening_outcomes.person_id,
ive_determination_children.person_id, screening_decision_evaluations.person_id,
person_demographic_facts.person_id, the five child_*_facts.person_id,
person_siblings.person_a / person_b, person_parentage_facts.person_id,
child_parents.person_id / parent_person_id, parental_rights_actions.person_id /
parent_person_id, permanency_plans.person_id, child_review_events.person_id,
contact_revisions.visited_child_id, and contacts.visited_child_id.
Its 42 domain tables (source of truth: services/craig-cases/migrations/) organize around the
intake-to-permanency workflow: persons, reports and screening, referrals, investigations, cases,
plans, contacts, and court orders, plus the encryption-lineage anchors.
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.
Tables
| Table | Purpose |
|---|---|
|
The public-report lifecycle rows relocated from craig-intake (ADR-017 Step 3) — the
stateless edge forwards here; screened via |
|
Report screening decisions (single-parent supersession chains; the effective leaf drives
convert — #767 write-side prevention); since #1746 also |
|
One row per subject a screening decision’s rules consult evaluated (#1672): a |
|
Report disposition follow-ups (the ADR-017 Step 3 trio’s third table): caseworker actions attached to non-terminal dispositions (screened-out-and-referred, I&R) |
|
ADR-019 report-entry ↔ person links — evidence-grade rows recording each deliberate
link (auto-link at convert or worker confirmation) between |
|
Supporting documents for reports (mirrors |
|
Mandated-reporter JWS replay-defense ledger (Plan C F-005): seen |
|
ADR-048 §D3 key↔data lineage anchor (singleton: KCV + canary + |
|
#1025/#1395 per-field scheme lineage — the authoritative record of which at-rest scheme
each allowlisted field’s data was written under; insert/equal-only, written by the
migrate gate’s |
|
#1399 U1 field-scheme rewrite ledger — the durable provenance of every |
|
Shared person registry — children, parents, reporters, perpetrators. Read surface (#1847, ADR-076): the service-only batched display-name projection ( |
|
A person’s external identifiers (#1806, plan |
|
One conversation with the jurisdiction’s person index per person (#3192), kept for fifteen minutes: the case and worker it was opened by, what the jurisdiction’s rules allowed for the index’s answer, and whether a registration or a selection was begun from it. No value a candidate carried is stored — see The person-index conversation (#3192) |
|
The candidates of one inquiry as a keyed digest of each id (the |
|
The demographics ledger (P-C U1b, #1991, ADR-078 D1) — one row per window of a person’s five demographic facts (the eight race answers, ethnicity, the two tribal-membership answers, tribal affiliation) with the correction model’s provenance columns; a row is never deleted, and its only admitted updates are a CLOSE (an open row gains |
|
Where a person lives (#3192): one row per window of the administrative unit (in Georgia, the county) a person lives in, under the same correction model and guards as the demographics ledger. A move is a CLOSE of the open row and a new statement. Written only through the four acts under |
|
The sibling ledger (P-C U2, #1992, ADR-078 D1) — one row per window of a sibling link between two persons, stored as the ordered pair |
|
The parentage ledger (P-C U4, #1994, ADR-078 D1) — one row per window of a child’s two (c)(1) / (c)(2) indicators: |
|
The parent-link ledger (P-C U4, #1994, ADR-078 D1) — one row per window of a directed link from a child ( |
|
Hotline intakes — born ONLY by converting a screened report (#1746); the DERIVED
|
|
Specific abuse/neglect allegations linked to a referral, victim, and perpetrator. |
|
Field investigations opened from screened-in referrals; |
|
Structured safety decisions produced by the rules engine during investigation. Each row holds the facts the worker
attested ( |
|
Ongoing case management records opened after substantiated investigation. |
|
Household composition — persons linked to a case with role and caregiver flag.
At most one ACTIVE row per |
|
A child-fact ledger (P-C U2, #1992, ADR-078 D1), keyed |
|
A child-fact ledger (P-C U2, #1992), keyed |
|
A child-fact ledger (P-C U2, #1992), keyed |
|
A child-fact ledger (P-C U2, #1992), keyed |
|
A child-fact ledger (P-C U3, #1993, ADR-078 D3), keyed |
|
The parental-rights ledger (P-C U4, #1994, ADR-078 D1 / plan D5) — the first EVENT ledger, keyed |
|
The permanency-plan ledger (P-C U5, #1995, ADR-078 D1 / plan D6) — an EVENT ledger keyed |
|
The review-event ledger (P-C U5, #1995, ADR-078 D1 / plan D6) — an EVENT ledger keyed |
|
A child’s custody episode (#2342, ADR-081 D2): one in-custody run, owned by one case for life, with |
|
The legal-status ledger (#2342, ADR-081 D2, ADR-078 D1) — an EVENT ledger keyed |
|
Case plans: strengths/needs assessment, approval tracking and tasks. The per-child permanency plan lives on |
|
Action items within a case plan assigned to workers or families |
|
Visitation and contact logs with narrative documentation. A home, office or school visit may name the child visited and where ( |
|
A contact’s prior visit trio, one row per update that changed it, naming the acting worker whose update superseded it ( |
|
Files attached to contacts — stored in object storage, metadata in DB |
|
Legal orders with findings, hearing dates, and uploaded documents. A |
|
SSA benefit assertions (#1466 B5-U2, ADR-065 §D4 — provenance class,
INSERT-only, indefinite-hold pending DFCS). The |
|
One row per screened member (#1466 B5-U2 — the D20 projection):
outcome category ( |
|
#1557 (D3, ADR-066 §D7): the IV-E determination ACT of record — the fleet’s first
persisted eligibility determination. Since hard-checks U6 (#1313) the act row carries
NO verdict: the ruleset identity |
|
#1313 U6: the role-bearing WITNESSED SNAPSHOT — one row per child the act
determined: |
|
#1557 (UD5): notify-never-re-evaluate — ONE open item per case (partial
unique WHERE not dismissed; the #1172 standing-alert ON CONFLICT bump), opened
post-determination only, by same-tx writers serialized on the case row
lock: the outcome fan-out ( |
|
#1557: the cases-local run-invalidation marker (per-run, first-write-wins), written by the widened inbox consumer’s claim tx; the determination tx’s in-tx witness re-check consults it — delivered invalidations refuse, undelivered ones surface via the worklist on eventual delivery. |
|
ADR-062 §U upload-attempt tombstones (SU2 #1248): one immutable row per client
upload operation, id = the client-held request id; generation-fenced CAS
state machine + replay decision table live in |
Screening decisions and their evaluations (#1672)
screening_decisions carries, beside the eight legacy columns, seven NOT NULL provenance
columns, written together by the act:
rule_set_name / rule_set_revision / rule_set_version (the {j}-intake-screening
revision the act consulted — pinned by the surface read, never by the evaluate response),
attested_facts (the worker’s bounded fact map, verbatim), screening_context (the
server-derived report-level facts as sent to rules: allegation_type + its source,
is_initial_decision, the prior’s disposition and role, the proposed disposition, the
derived actor_role — tokens and booleans only, never report text), disposition_admissible
and admissibility_basis (the admissibility conjunction over the decision’s evaluations and
the basis that decided it). #1672 added them nullable under the all-or-none CHECK
screening_decision_provenance_all_or_none, so an N−1 replica’s eight-column INSERT kept
working through the rollout. The contract migration
20261106120000_screening_decision_provenance_contract (#1695, schema_compat_floor bumped)
made them NOT NULL and dropped the CHECK. The API’s ScreeningDecision and
EffectiveDisposition bodies carry all seven as required, non-null fields (#2962). A
database still holding a NULL-provenance row
refuses that migration and names the column: no consult is invented and no decision is
deleted (its id is held by referrals.authorizing_decision_id,
disposition_follow_ups.decision_id and supersedes_id). Before 1.0 only dev and test
databases hold such rows, and cargo xtask dev reseed is the remedy. The contract migration
20261104120000_screening_actor_role_contract (#1697, schema_compat_floor bumped) rewrote
the legacy actor_role tokens those rows carried to the mapping tokens: cicc and
caseworker → cicc_intake, county_supervisor → county_director.
screening_decision_evaluations snapshots one row per evaluated subject: a child row per
flagged victim child, or per listed child when the report flags none (child_is_victim =
false, so a binding row can hold on it) — jsonb_index = the slot in the report’s children
array, never negative; the unique index keys the report row on the -1 sentinel — or ONE
report row for a report listing no children. Each carries the evidence the document sent — person_id
(the ONE linked person, NULL when none or when two persons link to the slot),
child_age, age_source (linked_person_dob / report_dob / report_age /
linked_ambiguous / absent / unparseable / future / implausible; a CHECK mirrors
the enum), child_is_victim — the rules-side evaluation_id (a pointer into
craig_rules.rule_evaluations, no FK across databases), the neutral outputs
(screening_decision, referral_type, disposition_admissible) and
jurisdiction_outputs (the ruleset’s REQUIRED non-neutral, non-basis outputs — tokens and
booleans only; the bases, free text and numbers stay on the rules-side single copy,
ADR-058 / #1130). person_id … ON DELETE SET NULL: the evidence outlives the pointer.
v_effective_disposition selects the seven provenance columns after the legacy nine.
Two requests with the same client_request_id that both pass the unlocked ADR-062
precheck both consult rules; claim_first admits exactly one and the other replays the
committed row. The loser’s evaluation set stays on the rules side as an orphan — joinable
by context_type = 'screening-decision', context_id = report_id; a refused act (400 /
403 / 409 / 422 / 500 / 503) likewise leaves rules-side rows and NO cases-side row.
Response priority, deadline and timeliness (#895)
referrals (migration 20260910120000_referral_response_priority, DESTRUCTIVE — priority and
chk_referrals_priority dropped, schema_compat_floor bumped): response_priority TEXT NOT NULL is
the jurisdiction ruleset’s token, rolled up at conversion by {j}-response-priority over the
effective decision’s per-child response_priority evaluation rows (Georgia IMMEDIATE |
PRIORITY_24HR | STANDARD | NONE, Texas P1 | P2 | NONE — NONE is a VERDICT). Four provenance
columns ride beside it under the referral_response_provenance_all_or_none CHECK:
response_priority_basis (the roll-up row’s basis, verbatim), response_priority_rule_set_name,
response_priority_rule_set_revision, response_priority_evaluation_id (the rules-side
rule_evaluations row — cross-database, no FK). Rows that pre-date the cutover were backfilled with
the sentinel UNDERIVED (never NONE) through a DEFAULT the same migration drops again, with NULL
provenance: an UNDERIVED referral that has an authorizing_decision_id is rolled up lazily by the
first investigation open (a compare-and-set WHERE response_priority = 'UNDERIVED'); one without a
decision can never derive and stays UNDERIVED for good. screened_in / screen_out_reason were
dropped by #1752: a referral’s existence is its screened-in outcome, and authorizing_decision_id names
the decision.
screening_decisions.attested_response_priority (same migration, additive, nullable): the token the
recording worker attested at the decision act — validated against the intake-screening surface’s
output enum minus NONE (422 otherwise) and hashed into the decision’s ADR-062 intent
(the decision request, hashed whole: ADR-062 § #2310). Whether it counts is the roll-up arm’s decision by the decision’s actor
role (Georgia: cicc_supervisor | county_director | regional_fps on a screened-in decision; a
cicc_intake attestation is recorded but rolls up to NONE).
reports.created_by / reports.received_at_attested (20260909120000_report_receipt_attribution,
additive): created_by UUID is the acting worker’s Keycloak sub when a HUMAN posted the report (a
worker JWT, or the BFF’s X-Craig-Actor worker) and NULL on the intake-edge / partner path — a
security-realm identity, no FK; received_at_attested BOOLEAN NOT NULL DEFAULT false is TRUE when
received_at is the caller’s attested actual receipt (the staff phone-intake path) and FALSE when the
column default stamped the submission instant. The receipt is the anchor every response window derives
from.
reports.reporter_anonymous (20261022120000_reports_reporter_anonymous, additive, #2209):
reporter_anonymous BOOLEAN NOT NULL DEFAULT false is set from intake’s anonymous flag (valid only
with concerned_citizen: craig-cases refuses any other reporter type with a 422 naming
reporter_anonymous; the flag is part of the report’s intent digest when true). A concerned citizen who reports anonymously may still volunteer contact
details so staff can follow up (the p28 team’s request); for a flagged report the redacted set is the
typed reporter_first_name / reporter_last_name / reporter_phone plus, inside raw_submission,
reporter_email, reporter_street, reporter_city, reporter_state, reporter_zip and
reporter_county. GET /v1/cases/reports/{id} omits them and conversion does not copy them onto the
referral. POST /v1/cases/reports/{id}/reporter-contact/reveal returns them: the handler checks read
and then authz action reveal on the same report (a reveal is never wider than a read); reveal is
allowed for supervisors and admins only (every other role, service callers included, is denied; in
texas-authz-report a regional director is denied even when she also holds supervisor), and each
reveal stages a case.report_contact_revealed audit event before the response. A
report that is not anonymous answers a typed 409 (report-not-anonymous). Not covered: the SHINES reporterInfo payload (follow-up
happens in SHINES) and the create-response echo to the submitting service. No backfill.
investigations (20260911120000_investigation_response_window, additive): response_due_at is no
longer caller-typed — the open derives it from the referral’s token through {j}-response-window and
craig_common::deadline. Five window-provenance columns are held as a SET by
investigation_response_provenance_all_or_none ((response_priority IS NULL) = (<column> IS NULL) for
each): response_priority (the token the window was consulted for), response_due_basis,
response_rule_set_name, response_rule_set_revision, response_evaluation_id — all NULL on rows
opened before the cutover (their deadline was typed; no ruleset stands behind it). Five override
columns are written only by POST /v1/cases/investigations/{id}/response-deadline:
response_due_original (the derived deadline before the FIRST override — constant across later ones),
response_due_overridden_at, response_due_overridden_by (the acting worker’s sub, no FK),
response_due_overridden_reason (nullable on its own — the jurisdiction’s arm decides whether a reason
is required) and response_due_override_evaluation_id; the at / by / original / evaluation four are a
SET under investigation_response_override_all_or_none.
v_investigations is every investigations column plus the read-time band response_timeliness
(and, since 20260916140000, admin_unit appended LAST — the append-only rule below):
CASE
WHEN first_contact_at IS NULL AND now() < response_due_at THEN 'on_track'
WHEN first_contact_at IS NULL THEN 'overdue'
WHEN first_contact_at <= response_due_at THEN 'met'
ELSE 'met_late'
END AS response_timeliness
Every investigation READ — get, list, the NCANDS extract, the re-select after create / update /
override — selects from the view (RETURNING * on the base table cannot produce the band); the
craig-cases-fields investigations registry table and the search entity are both bound to the view
(the planner requires them equal), and RESPONSE_TIMELINESS is a plaintext Equality field behind the
closed four-token set (?timeliness=). The band is never written back — a later first_contact_at or
an override re-bands the next read.
MAINTENANCE RULE: SELECT i.* was expanded when the view was CREATED (20260911120000), and
20260916140000 re-created it with the EXPLICIT column list in that expansion order (the
dropped-and-re-added assigned_worker of 20260508180000 sits after assigned_worker_name) plus
admin_unit at the end. Any later ALTER TABLE investigations that adds, drops or retypes a column
MUST CREATE OR REPLACE VIEW v_investigations in the SAME migration, reproducing that list and
appending the new column AFTER admin_unit (append-only select list — CREATE OR REPLACE refuses
a renamed or reordered existing column; the v_effective_disposition re-creation in
20260906120000_screening_decision_provenance.sql is the precedent) — otherwise the view silently
serves the old column set and the row model fails to decode.
investigations_closed_has_disposition (20261015120000_investigation_closed_disposition, additive, no
floor bump, #1764): CHECK (status <> 'closed' OR disposition IS NOT NULL), validated on add, the DB twin of
the PUT handler’s 400 investigation-disposition-required. No column changes, so v_investigations is not
re-created. A refuse-on-data guard runs first, under the table’s ACCESS EXCLUSIVE lock: a closed row with no
disposition refuses the file with its count, an inspect query and the remedy (devstack: reseed; elsewhere record
each determination), because closed_no_finding is a determination, never a default. An N-1 craig-cases still
sends a disposition-less close, which the CHECK now refuses as a redacted 500.
Administrative-unit stamp and the canonical-name belt (#1901, ADR-077)
investigations.admin_unit (20260916140000_investigation_admin_unit, additive, nullable, no floor
bump): the ORIGINATING REFERRAL’s admin_unit — its county (ruling R4 on the plan page; Texas'
assignment_area is a region token and is never the stamp). The open copies it from the referral row
the handler already loaded (never re-fetched, never the body’s assignment_area), and the same
migration backfilled every earlier row FROM referrals — TOTAL, because referral_id is NOT NULL and
referrals.admin_unit is plaintext NOT NULL. The column stays nullable at the schema: NULL means
"outside every unit scope" (ADR-077 D5 fail-closed) and can only come from a raw writer that skipped
the column, which the BLOCKING investigation_admin_unit_from_referral invariant reports. Partial
index idx_investigations_admin_unit … WHERE admin_unit IS NOT NULL serves the D5 list bind U2
(#1903) adds. The wire: Investigation.admin_unit (create echo, get, list — omitted when NULL).
This is the cases-side leg of the D6 stamp program; the placement / financial projections
(case_assignments.admin_unit) and their resource stamps are on
Data Model: Placement and Data Model: Financial & Claims.
The belt (ADR-077 D2): CreateCaseRequest.admin_unit and CreateReportRequest.admin_unit are
validated against the deployment jurisdiction’s administrative-unit table when that jurisdiction
resolves to a US state / territory (craig_reference::fips::State::from_jurisdiction_key), and the
row stores the CANONICAL AdminUnit::name — the lookup is case-insensitive (harris → Harris), an
unknown name is the typed 400 invalid-enum-value on admin_unit (craig-intake’s SAD-11 shape). The
rewrite runs BEFORE the authz attrs, the ADR-062 intent digest and the case-number derivation, so a
replay of the same non-canonical body digests identically and case_number derives from the canonical
name; the referral conversion copies the STORED canonical value from the report row. A jurisdiction
without a FIPS table (the testonia fixture) keeps the string as sent. Pre-1.0 Changed.
case.assignment_changed now carries admin_unit (a plain string read from the same CAS-locked
cases row as the pair snapshot). It is NOT an identity key: consumers read it OPTIONALLY (a retained
pre-upgrade six-key envelope is still applied; absent = NULL) and fill their projections unit-only —
the #1084 hard-required posture stays on the identity keys alone.
The demographics ledger and the ledger correction model (#1991, ADR-078)
person_demographic_facts (migration 20260922150000_person_demographic_facts, DESTRUCTIVE —
persons.race, persons.ethnicity and persons.tribal_affiliation dropped, schema_compat_floor
bumped; -- devstack: wipe-before-apply): the first ledger of the ADR-078 D1 correction model and the
shape every later P-C fact ledger reuses. The migration refuses to run while any persons row still
holds one of the three values (the message names cargo xtask dev reseed); rollback is the N−1 images
AND a database restore. It enables btree_gist and grants nothing (the cases posture).
The five facts — every key is on the wire and null means unanswered (missing stays missing):
| Column(s) | Values | AFCARS |
|---|---|---|
|
|
(b)(7) |
|
|
(b)(8) |
|
|
(b)(4)(i) |
|
|
(c)(3), (c)(4) |
|
text, ≤ 255 characters |
(b)(4)(ii) |
Provenance (D1): id; person_id (FK persons, ON DELETE RESTRICT); the window
[effective_from, effective_until) (effective_until NULL = open); recorded_at (DEFAULT now())
and recorded_by (the acting worker); supersedes_id (FK to the corrected predecessor row,
ON DELETE RESTRICT); retired_at, retired_reason (corrected / retracted /
order_corrected / order_deleted — the closed D1 set), retired_note and retired_by (the acting
worker whose act retired the row — a correction, a retraction or a court-order sweep; set with
retired_at); closed_at + closed_by (when a closing act ended the window, and the acting worker who
did — the close, or a CHANGE’s implicit close of the open row; set together by that closing UPDATE only,
so a row born with effective_until, a BACKFILL, has neither). A correction inserts its successor, and
an INSERT never carries closed_*: a closed row’s closer lives on the chain’s closed predecessor after a
correction (follow supersedes_id). A row is live while retired_at is NULL. Every column is Plaintext in the field registry (a DEFAULT_REGISTRY
table) and the table is never on the scheme ALLOWLIST — its scheme is frozen (the COMMENT ON says
so).
The DB twins: named CHECKs chk_person_demographic_facts_* — the window is ordered; the eight race
columns are all-or-none; ethnicity and the two membership columns are in their token sets;
tribal_affiliation is at most 255 characters; retired_at and retired_reason are both set or both
NULL; retired_reason is in the D1 set; retired_note only on a retired row; a row never supersedes
itself. The actor pairs (#2016): chk_<table>_retired_by_paired — (retired_at IS NULL) = (retired_by IS
NULL) — on all twelve ledgers, and chk_<table>_closed_paired — (closed_at IS NULL) = (closed_by IS
NULL) — on the nine window ledgers. The INSERT-side rule that a row born with effective_until has no
closed_* is app-enforced (no ledger INSERT lists those columns), not a CHECK. excl_person_demographic_facts_window (EXCLUDE USING gist (person_id WITH =,
daterange(effective_from, effective_until, '[)') WITH &&) WHERE (retired_at IS NULL)) — no two live
rows of one person overlap; uq_person_demographic_facts_one_open — at most one open live row per
person; uq_person_demographic_facts_one_successor — a row is superseded at most once;
idx_person_demographic_facts_person_window (person_id, effective_from) serves the reads.
Rows are never deleted, and never edited beyond a CLOSE or a RETIRE. The trigger person_demographic_facts_refuse_mutation (BEFORE
UPDATE OR DELETE) runs refuse_fact_row_mutation(): a DELETE is always refused, and an UPDATE is
admitted only as a CLOSE (an open row gains effective_until + closed_at + closed_by, and nothing
else changes) or a RETIRE (a live row gains retired_at + retired_reason + retired_by, optionally
retired_note, and nothing else changes). Each arm requires its actor: a CLOSE without closed_by or a
RETIRE without retired_by is refused, and a closed row’s closed_* or a retired row’s retired_by is
never rewritten. The same migration creates refuse_event_row_mutation() (RETIRE only) once, for the
three event ledgers to attach — parental_rights_actions (The parent ledgers and parental rights (#1994, ADR-078 D1, plan D5)), permanency_plans and
child_review_events (The permanency ledgers (#1995, ADR-078 D1, plan D6)). Both raise integrity_constraint_violation naming the
table and ADR-078 D1. Migration 20260925120000_ledger_actors (#2016) re-creates both functions with the
actor columns above (CREATE OR REPLACE keeps each OID, so all twelve triggers keep firing, and it
re-issues both COMMENT ON FUNCTION texts); the event body is the text craig-placement copies
byte-for-byte (P-B1 U3).
Migration 20260925120000_ledger_actors (P-B1 U1b, #2016; -- devstack: wipe-before-apply) is
additive. Its statement order is fixed so that a refusal leaves nothing of it applied:
-
The refuse-on-data guard, FIRST: the migration raises while ANY ledger row is retired or ANY window row has
effective_untilset — no recorded fact names who retired or closed it, and a row an act closed is indistinguishable from one born with an end, so nothing is invented; the message namescargo xtask dev reseed. -
retired_by UUIDon all twelve ledgers andclosed_at TIMESTAMPTZ+closed_by UUIDon the nine window ledgers, with the two paired CHECKs above (no FK, therecorded_byposture). Each isPlaintextin the field registry. -
refuse_fact_row_mutation()andrefuse_event_row_mutation()re-created, then their twoCOMMENT ON FUNCTIONtexts. -
The
schema_compat_floorbump to20260925120000, LAST. The file is additive, so the bump is voluntary, and it is required: the re-created guards refuse every N−1 close / CHANGE / correction / retraction / sweep UPDATE (23000). Rollback is N−1 images AND a database restore.
The acts (craig-cases; each write is an ADR-062 claimed transaction keyed by the body’s
client_request_id, claim scope cases.person_demographics.<act>):
| Route | Effect |
|---|---|
|
Record a COMPLETE statement of the five facts (a |
|
Retire the named live row as |
|
Retire the named live row as |
|
Set |
|
The live row whose window contains |
|
The history read (#1992): every live row in force at any point of |
Every act, both GETs included, refuses a pure service principal first (403 — the history read denies
services outright); authz is Action::Update on the person resource for the writes and Action::Read
for the GETs. There is no case-open guard (these are person routes). The typed errors (the fleet ledger
set every later P-C ledger reuses): a body date after today on the jurisdiction clock is the 400
ledger-date-after-today; an effective_until not after effective_from (a POST, a correction’s
resolved bounds, a close date) is the 400 ledger-window-invalid; a {row_id} that is absent, retired,
another person’s, or (close only) not open is the 404 ledger-row-not-found with nothing written; an
unknown person is a typed 404 naming the person; a write that would overlap a live window or open a second
row (SQLSTATE 23P01 on the exclusion, 23505 on the one-open index) is the 409
ledger-window-overlap. Each committed act publishes case.person_demographics_changed with
person_id, row_id, act (recorded / corrected / retracted / closed) and user_id (the
act’s acting worker, claims.acting_worker(); #2016) — no fact value rides the event.
One generic core (#1992). The store acts, the act plumbing and the authority prologue are written
once for every P-C ledger: craig_ledger::store::window holds the five act compositions (record-change,
record-backfill, correct, retract, close) and the reads (the row by id, the current row, the at-date
and overlap reads — the window predicate defined once), every SQL string rendered from the ledger’s
compile-time table, constraint and column names; api::ledgers holds the generic record /
correct / retract / close / read / history handlers and the route prologues; a ledger
declares only its table, its key, its facts and its route. The demographics ledger is the first
ledger on the core (same routes, same behavior); every later window ledger — the
child-fact and sibling ledgers, ICWA and the two
parent ledgers — is on it too, and the three event ledgers are on its event twin,
craig_ledger::store::event (The parent ledgers and parental rights (#1994, ADR-078 D1, plan D5)). One read-side difference: the core reports an off-vocabulary token or a
partial race set in a stored row as a decode error where U1b read it as unanswered — both are
unreachable behind the CHECKs.
Readers: the person create / get / PUT serve the current row (open and live) to human principals
(see the persons row); the NCANDS collection (GET /v1/cases/ncands-export) reads each victim’s row
in force at the referral’s received_at date on the jurisdiction clock, batched in one round trip —
NcandsExportRow.victim_race is RaceResponses, victim_ethnicity the five-value Ethnicity. The AFCARS persons export reads
this ledger as it stood at the request’s as_of (a row recorded after it is invisible, one retired after it reads live, one closed
after it reads open), at period_end for a child key and at each anchor for an adult key, never tribal_affiliation for an adult
(#2121).
AFCARS element → column map (craig_cases_fields::afcars::AFCARS_ELEMENT_COLUMNS at
AFCARS_CAPTURE_STAGE = U5, the last capture unit; the test every_owned_leaf_maps_to_its_full_column_set holds its key set
EQUAL to the owned keys whose unit is at or before the stage — at U5 the COMPLETE owned set — and checks each mapping against the
dictionary’s atom and the field registry; the two Named entries are the plan’s cross-table named
overrides, which the test’s NAMED_OVERRIDES pins to exactly the (c)(1) and (c)(2) keys and exactly
their columns — #1994. Because no unit follows U5, the two stage-bound tests were retargeted by #1995:
at_the_last_unit_every_owned_key_is_due (formerly a_key_after_the_stage_has_no_mapping) and the
unit test ownership_is_by_unit assert every owned key’s unit is at or before the stage rather than
probe a later key):
| Element key | Mapping | Column(s) |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
the (c)(1) columns (the second legally-responsible parent) + |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The (a)(1)–(a)(4) header facts (state agency, report period, local agency, record number) are not
captured columns: P-D’s projection supplies them from jurisdiction config, the period, cases.admin_unit
and the record-number scheme.
The residence ledger (#3192)
person_residences (migration 20261202090000_person_residences, additive): where a person lives, as a
person-keyed window ledger of the correction model. A row states one fact, admin_unit:
the administrative unit the person lives in from effective_from (in Georgia, the county). It is the county a
person index is given when the person is registered with it. No street address is held.
The unit is stored as the jurisdiction’s canonical unit name, as a case’s and a report’s are (ADR-077). Where the
deployment’s jurisdiction is a US state, the name is matched against its units without regard to case, and a name
that is no unit of it is refused 400 invalid-enum-value on admin_unit; a jurisdiction with no table of units
keeps the name as sent. The request’s idempotency intent is taken over the canonical name, so a retry that spells
the same unit in another case replays the stored row.
The guards are the ledger family’s: live windows of one person never overlap (excl_person_residences_window), at
most one row is open (uq_person_residences_one_open), a row has at most one successor, and
refuse_fact_row_mutation() admits only the CLOSE and the RETIRE, each naming its worker. Six routes under
/v1/cases/persons/{id}/residences are the family’s: record (POST), correct, retract and close a row, the
at-date read (GET) and the period read (GET …/history). A person who moves has the open row closed on the day they left
and a new statement recorded from that day. Each act is human-only (a pure service principal is refused 403),
authorized as the person update is, and publishes case.person_residences_changed with ids and the act only.
The child-fact ledgers and the sibling ledger (#1992, ADR-078)
Five more window ledgers on the demographics ledger’s correction model — the
same provenance columns, DB twins, never-deleted rows, acts, fleet typed errors and generic core; this
section records only what differs. Migration 20260923120000_child_fact_ledgers is ADDITIVE (five new
tables; no drop, no schema_compat_floor bump, no wipe line), creates no function (each table’s
trigger attaches U1b’s refuse_fact_row_mutation()), and grants nothing. Every column is Plaintext
in the field registry (DEFAULT_REGISTRY then carried eleven tables — eighteen since The permanency ledgers (#1995, ADR-078 D1, plan D6), twenty since Custody episodes and the legal-status ledger (#2342, ADR-081, plan custody-episodes-doe-slds D2 + D3)) and each table’s COMMENT ON
records that its scheme is frozen. The parenting facts (child_parenting_facts) are Plaintext by decision, not deferral:
ADR-049 § Amendment — #2000 (ruled
2026-10-06) keeps the sensitive non-identifier facts of cases and placement — parenting, health, the (d)(4) removal
circumstances, trafficking and ICWA — Plaintext, and no ledger column moves to Opaque.
The four case ledgers are keyed (person_id, case_id) — case_id (FK cases, ON DELETE
RESTRICT) sits beside person_id: one child’s facts in one case. Every key is on the wire and null
means unanswered (missing stays missing):
| Ledger (route segment) | Column | Values | AFCARS |
|---|---|---|---|
|
|
|
(b)(13)(i) |
|
|
(b)(13)(ii) |
|
|
|
(b)(13)(iii) |
|
|
|
|
(b)(15) |
|
a date, the first of its month; present exactly when |
(b)(15)(i) |
|
|
|
(b)(15)(ii) |
|
|
|
(b)(16)(i) |
|
|
a date, the first of its month; present exactly when |
(b)(16)(ii) |
|
|
|
|
(b)(17) |
|
|
(b)(17)(i)–(viii) |
|
|
|
an integer, 0–999 |
(b)(19) |
Each within-element gate above (the parenting pair, a dependent without its yes gate, a month that
is not the first of its month, a partial or unwanted source set) is refused as a 422 on the body before
anything is written; the DB CHECK is the belt. An unanswered prior_adoption, prior_guardianship
or support_status admits no dependent; the parenting rule binds only when both of its answers are
given.
person_siblings is keyed by the pair (person_a, person_b) (both FK persons, ON DELETE
RESTRICT), stored ordered — CHECK (person_a < person_b) — whichever side the recording route named.
It has no domain columns: a row is the link and its window. The pair is the row’s identity, so a
correction moves only the window; a link recorded against the wrong person is RETRACTED and
re-recorded, and a link that ended is CLOSED.
The DB twins (per table, as the demographics ledger’s): named CHECKs chk_<table>_* — the window is
ordered, each vocabulary column is in its token set, the gates of the table above (NULL-safe, with
the unanswered-gate and both-answered rules just stated), total_siblings in 0–999, the pair order,
and the provenance CHECKs; excl_<table>_window — no two live rows of one identity ((person_id, case_id),
or the pair) overlap; uq_<table>_one_open — at most one open live row per identity;
uq_<table>_one_successor; a read index (case_id, person_id, effective_from) on the four case
ledgers, and on person_siblings a second index (person_b, effective_from) beside the pair’s so the
either-side read is indexed. The trigger <table>_refuse_mutation on each table admits only a CLOSE or
a RETIRE.
The acts (each write an ADR-062 claimed transaction keyed by the body’s client_request_id, claim
scope cases.<table>.<act> with <act> = record / correct / retract / close):
| Route | Effect |
|---|---|
|
Record a COMPLETE statement of the ledger’s facts — a CHANGE without |
|
Correct, retract or close the named live row of this child in this case, as the demographics acts. |
|
The live row in force at |
|
The history read: every live row in force at any point of |
|
Record a link from the path person to |
|
The row acts on a link with the path person on EITHER side; a correction body carries only the bounds. |
|
The live links in force at |
|
Every live link with the path person on either side in force at any point of |
Authority on the case routes. A pure service principal is refused first (403, the GETs included);
then the body is validated (422); the case must exist (404) and authz is Action::Update on the CASE
resource for the writes, Action::Read for the GETs; then the body dates (the fleet 400s). Inside the
claimed transaction, a RECORD or a CLOSE passes require_case_open (409 case-closed on a closed or
transferred case); a CORRECTION or a RETRACTION does not — the lifecycle of the case does not freeze
the record of what was true, so a wrong fact on a closed case is still corrected or retracted. Every
act, and both GETs, then requires {child_id} to be — or to have been — a child-role
case_household member of the case (an inactive membership counts, so a late entry for an ended
membership is admitted): otherwise the 400 child-not-in-case (field child_id) with nothing
written. A {row_id} of another child or another case is the 404 ledger-row-not-found.
Authority on the sibling routes is the person routes' (as the demographics ledger): service refused
first, Action::Update / Action::Read on the path person, no case-open guard.
Typed errors: the fleet ledger set (ledger-date-after-today, ledger-date-before-minimum (#2461),
ledger-window-invalid, ledger-row-not-found, ledger-window-overlap, ledger-not-a-change) plus the reused 400
child-not-in-case, the 409 case-closed, and the sibling self-link 400 bad-request.
Events (ids and the act only — no fact value): each committed act on a case ledger publishes
case.child_facts_changed with case_id, child_id, ledger (the table name), row_id, act
(recorded / corrected / retracted / closed) and user_id (the acting worker; #2016) — one routing key for seven case ledgers: these four,
child_icwa_facts (The ICWA ledger (#1993, ADR-078 D3, ADR-073 § Amendment)), parental_rights_actions (The parent ledgers and parental rights (#1994, ADR-078 D1, plan D5)) and
child_review_events (The permanency ledgers (#1995, ADR-078 D1, plan D6)) — every case ledger but permanency_plans, whose acts publish
case.permanency_plan_established; an event ledger has no closed, and a review row a court
order’s update or delete retires publishes order_corrected / order_deleted. Each act on
person_siblings publishes case.person_siblings_changed with person_a, person_b, row_id, act
and user_id.
The ICWA ledger (#1993, ADR-078 D3, ADR-073 § Amendment)
One more case ledger on the child-fact ledgers' model — keyed (person_id,
case_id), the same frame, provenance, DB-twin families, acts, authority, typed errors and event as the
four case ledgers; this section records only what differs. The route segment is icwa-facts
(/v1/cases/cases/{case_id}/children/{child_id}/icwa-facts), the claim scopes are
cases.child_icwa_facts.<act>, and every column is NULL until answered:
| Column | Values | Element | Gate CHECK |
|---|---|---|---|
|
|
2022 (b)(3) |
— |
|
|
2028 (b)(3)(i)–(ii) |
— |
|
|
(b)(3)(iii) |
— |
|
|
(b)(3)(iv)–(vi) |
— |
|
|
(b)(3)(vii) |
— |
|
|
(b)(4)(iii)–(iv) |
date ← |
|
|
2022 (b)(5)(i)–(ii) |
date ← |
|
|
2022 (b)(6) / 2028 (b)(5)(ii) |
NO gate on
|
|
|
2028 (b)(5)(i) — notice "prior to the first child custody proceeding" (#2004) |
|
|
|
2028 (b)(5)(iii), the same qualifier (#2004) |
— |
|
|
none since #2004 — the unqualified (b)(5)(iii) answer: stored, read by nothing, NULL on every row written since |
— |
|
|
(b)(6)(i)–(iii) |
date, text ← |
|
|
(i)(9) |
← |
|
|
(i)(5)(v) — the Tribe’s order "for foster care or pre-adoptive placements" |
← |
|
|
(i)(10)(iv) — the Tribe’s order for adoptive placements |
← |
|
date |
the date the Tribe established its (i)(5)(v) order (plan |
← |
|
date |
the date the Tribe established its (i)(10)(iv) order |
← |
The gates are one-way (the four case ledgers' dependents are "present exactly when"): a dependent may be present
only when its gate holds the enabling token, and a gate stands without its dependent — a discovery date not yet known,
active efforts not yet judged (the dictionary’s required arm is P-D’s missing-data count, never a capture refusal).
An unanswered gate admits no dependent. The DB twin is NULL-safe,
CHECK (<dependent> IS NULL OR <gate> IS NOT DISTINCT FROM '<token>') (a bare = '<token>' would pass on a NULL
gate); the body twin (present_only_if) refuses the same statement as a 422 before anything is written. The one
exception, on new writes only (#2004): an order of preference yes needs its date — present_iff, the 422
validation-failed bound to facts.tribe_order_<x>_on on every record and correction body, the documented exception
to "never a capture refusal". Its DB twin stays one-way
(CHECK (<date> IS NULL OR <order> IS NOT DISTINCT FROM 'yes')), so a yes stored before #2004 without a date stays
valid: it reads, closes and retracts, and only a correction restating it must add the date. tribes_notified and
determination_tribe are 1–255 characters (CHECK (<column> IS NULL OR char_length(<column>) BETWEEN 1 AND 255); an
empty string is not an answer). The five dates (the discovery, notice and determination dates and the two Tribe-order
dates) are fact dates: a date after today on the jurisdiction clock is the typed 400 ledger-date-after-today bound
to that field; a fact date is not checked against the row’s window.
The Tribe’s order of preference (P-B3 U6, #2085; R-B33). Two
columns, because 25 U.S.C. 1915(c) lets a Tribe’s resolution set either order alone. Both keys are REQUIRED on every
icwa-facts record and correction body (craig_validation::required_nullable; present, null = unanswered): a body
missing one is 422 validation-failed, never a NULL. The ruleset predicate tribe_established_order_of_preference
holds iff craig-reporting’s stored tribe_order_in_force is yes — ICWA applying by the period-end court
determination, the period-end tribe_order_foster_care (for (i)(5)) or tribe_order_adoptive (for (i)(10)) yes,
established (tribe_order_*_on) on or before the arrangement’s (e)(1) or the exit date (#2273, #2274;
Reporting); U6 maps no AFCARS key, so the element → column table gains no row. Migration
20260930150000_tribe_order_of_preference is ADDITIVE with a voluntary schema_compat_floor bump; both columns are
Plaintext and SCHEME-FROZEN like the rest of the ledger.
The qualified notices (#2004, plan afcars-2028-series D4). 2028 (b)(5)(i) and (b)(5)(iii) ask whether notice went
out prior to the first child custody proceeding; a notice sent after it is 2022 (b)(6) yes but 2028 (b)(5)(i)
no. So each is its own attested yes | no column — tribe_notified_before_first_proceeding (its yes only beside
tribe_notified = yes, garde yes_only_if; no stands alone) and
parent_or_indian_custodian_notified_before_first_proceeding (no gate) — and tribe_notified answers 2022 (b)(6)
alone. A date-derived answer was rejected: 25 U.S.C. 1912(a) asks for notice received and a waiting period, which a
sent date and a hearing date cannot establish. Legacy answers are never reinterpreted: nothing copies
tribe_notified or the unqualified parent_or_indian_custodian_notified into a qualified column, so a pre-#2004 row
reports 2028 (b)(5)(i) and (b)(5)(iii) blank — counted missing — until re-answered; the unqualified column and its
CHECK stay, unread, and every row written since stores it NULL. All four new keys (the two notices, the two order
dates) are REQUIRED on every body (present, null = unanswered). Migration
20261011120000_icwa_qualified_notices_and_order_dates is ADDITIVE (no backfill, no wipe line) with a voluntary
schema_compat_floor bump (an N−1 image would write the four answers NULL); every column Plaintext, SCHEME-FROZEN.
Migration 20260923140000_child_icwa_facts is DESTRUCTIVE — the contrast with U2’s additive one. It
carries the -- devstack: wipe-before-apply line and, in one file: a guard that refuses to apply
(tagged #1993 ICWA ledger, naming cargo xtask dev reseed) while any persons.icwa_eligible row is
true — a synthesized ledger row would guess WHICH ICWA fact the flag meant; the table, with the U2
frame, the value CHECKs, the gate and text CHECKs, excl_child_icwa_facts_window,
uq_child_icwa_facts_one_open, the one-successor index, the read index and a trigger attaching the
existing refuse_fact_row_mutation() (no new function); ALTER TABLE persons DROP COLUMN
icwa_eligible; and, last, the MANDATORY schema_compat_floor bump (an N−1 image writes the dropped
column). Rollback is N−1 images AND a database restore. Every column is Plaintext in the field
registry (DEFAULT_REGISTRY then carried twelve tables — eighteen since The permanency ledgers (#1995, ADR-078 D1, plan D6), twenty since Custody episodes and the legal-status ledger (#2342, ADR-081, plan custody-episodes-doe-slds D2 + D3)) and the table’s COMMENT ON records that its
scheme is frozen. The ICWA facts, and the (i)(2)–(i)(3) findings on parental_rights_actions, are Plaintext by the
same decision (The child-fact ledgers and the sibling ledger (#1992, ADR-078)).
The one reader: the ICWA-status consult. craig-cases' placement-facts projection (the
ADR-073 read), after its membership gate,
reads the case’s CURRENT row for the child — the open, live row; a closed or retracted ledger reads as
no row, every input null — and ALWAYS evaluates the federal ruleset federal-icwa-status
(the federal layer’s federal-icwa-status.json, cited to 25 CFR 23.107) through craig-rules: POST
/v1/rules/evaluate, context_type = icwa-status, context_id = the case id, the acting worker
relayed, budget ICWA_STATUS_BUDGET = 2 s, input court_determination, reason_to_know,
icwa_applies (null when unanswered). Its answer is icwa_person: court_determination =
yes_icwa_applies → true; no_icwa_does_not_apply → false; otherwise reason_to_know = yes OR
icwa_applies = yes; no row → false. A rules 403 for the relayed worker is the typed 403
rules-consult-denied; a consult craig-rules never answers (unreachable, or the 2 s budget elapsing) is
the fail-closed 503 service-unavailable naming the ruleset and, on an elapse, the budget (#1800); a rules 503 /
504 passes through; any other failure, or an output that does not decode, is a 500. icwa_case still reads
cases.icwa_flag (the case-level triage flag carried from the referral), which a court determination
does not override; the PlacementFacts wire is unchanged.
Events: case.child_facts_changed with ledger = "child_icwa_facts" — the family event, no new
routing key.
The parent ledgers and parental rights (#1994, ADR-078 D1, plan D5)
Migration 20260923160000_parents_and_parental_rights is ADDITIVE (three new tables; no drop, no
schema_compat_floor bump, no wipe line) and creates no function: the two person ledgers' triggers
attach U1b’s refuse_fact_row_mutation(), and parental_rights_actions is the FIRST table to attach
refuse_event_row_mutation(). It grants nothing. Every column is Plaintext in the field registry
(DEFAULT_REGISTRY then carried fifteen tables — eighteen since The permanency ledgers (#1995, ADR-078 D1, plan D6), twenty since Custody episodes and the legal-status ledger (#2342, ADR-081, plan custody-episodes-doe-slds D2 + D3)) and each table’s COMMENT ON records that its scheme
is frozen. On all three tables the subject child is person_id and the parent is parent_person_id
(both FK persons, ON DELETE RESTRICT).
The two person ledgers
person_parentage_facts and child_parents are window ledgers on the
demographics ledger’s model: the same frame, provenance, DB-twin families,
four acts plus the two GETs, person-route authority (a pure service principal refused first,
Action::Update / Action::Read on the path person, no case-open guard) and fleet typed errors.
This part records only what differs. Each write is an ADR-062 claimed transaction under the ledger’s
own claim scopes (services/craig-cases/src/api/intents/parents.rs).
| Ledger (route) | Column | Values | AFCARS |
|---|---|---|---|
|
|
|
(c)(1), (c)(2) |
|
|
(c)(2) |
|
|
|
the parent; never the child itself |
(c)(1)–(c)(5) |
|
|
(c)(1)–(c)(5) |
|
|
|
(c)(1), (c)(2) |
The child_parents twins. chk_child_parents_role holds the four tokens.
chk_child_parents_putative_no_legal_responsibility is role <> 'putative_parent' OR
legal_responsibility IS NOT TRUE; it is NULL-safe, so an unanswered flag passes, and the body’s garde
twin refuses the same statement as a 422. chk_child_parents_not_self is parent_person_id <>
person_id. excl_child_parents_window and uq_child_parents_one_open apply per (child, parent): a
child may have several parents in force at once, but one parent never has two overlapping live links
to the same child. idx_child_parents_child_parent_window serves the child-first reads and the
parent-not-linked probe.
The child_parents acts. The record body carries client_request_id, parent_person_id,
effective_from, optional effective_until, role and legal_responsibility. A parent_person_id
equal to the path child is the typed 400 bad-request (field parent_person_id) before any write,
and a missing child or parent is 404. The (child, parent) pair is the row’s identity. A correction
body therefore CARRIES parent_person_id beside the statement, and it must be the named row’s parent:
a row of another parent is the 404 ledger-row-not-found with nothing written. A link recorded
against the wrong parent is retracted and re-recorded. Retract and close address the row by its id
alone. GET …/parents?as_of= returns the live links in force at as_of sorted by the parent order
(below): a 200 array, empty when there is none, never 204. GET …/parents/history?from=&to= is the
overlap history, newest first. person_parentage_facts has no route-specific rule: its six routes
behave like the demographics routes (the as_of GET is 200 row or 204).
Events (ids and the act only): each committed act on either person ledger publishes
case.person_parents_changed with child_id, ledger (person_parentage_facts \|
child_parents), row_id, act (recorded / corrected / retracted / closed) and user_id (the
acting worker; #2016).
The parent order (plan D5; craig_cases::afcars_parents::parent_order) sorts by role rank
(mother, father, legal_guardian, putative_parent), then effective_from, recorded_at, id.
The order is total, so no tie depends on read order. It is a CRAIG convention: the CFR’s "first" and
"second" carry no meaning.
parental_rights_actions: the first event ledger
The event frame. Rows are keyed (person_id, case_id, parent_person_id): the child’s actions within
one case (FK cases, ON DELETE RESTRICT), per parent. An event has no window, so the table has no
effective_from / effective_until, no overlap exclusion and no one-open index. An event’s identity
is its row id, and a parent may carry several live rows (a petition, then the termination). The
provenance columns are D1’s: id, recorded_at, recorded_by, supersedes_id, retired_at,
retired_reason, retired_note, retired_by (#2016; no closed_* — an event has no window). A row is
live while retired_at is NULL.
| Column | Values | AFCARS |
|---|---|---|
|
|
— |
|
|
(c)(5) |
|
date; |
(c)(5)(i) |
|
|
(c)(5)(i) |
|
date; |
(c)(5)(ii) |
|
FK |
— |
|
|
2028 (i)(2)(i)–(iii) |
|
|
2028 (i)(3)(i)–(iii) |
not_applicable is the CFR’s own ASSESSED response (no termination or modification). It carries no
petition, no termination date and no ICWA finding. A death IS admitted on it, because a death is a fact
independent of any termination. NO row means MISSING (blank), never not_applicable.
effective_on resolution. On a not_applicable row, effective_on is the assessment date and the
body must state it. On a voluntary / involuntary row it is the EARLIEST of petition_filed_on,
terminated_on and died_on: the body omits it or states exactly that date (any other date is a
422). The store writes the resolved date, the row always reads it back, and it is a fact date: after
today on the jurisdiction clock is the 400 ledger-date-after-today.
The DB twins (each NULL-safe; each with a garde twin on the body that refuses the same statement as a 422 before anything is written):
-
chk_parental_rights_actions_kind:kindis one of the three tokens. -
…_died_on_iff_deceased:died_onis present exactly whenparent_deceased. -
…_termination_has_a_date: avoluntary/involuntaryrow carries at least one of its three dates, soeffective_onis always defined. -
…_effective_on_earliest: a termination row’seffective_onis the earliest of those dates. -
…_not_applicable_no_termination: anot_applicablerow has no petition and no termination date (a death and a court order are admitted). -
…_involuntary_flags/…_voluntary_flags: the other kind’s three flags are NULL. Together they leave anot_applicablerow with no flag at all. -
One token CHECK per flag, plus the provenance CHECKs.
uq_parental_rights_actions_one_successor ensures a row is corrected at most once.
idx_parental_rights_actions_case_child_parent serves the history and the at-anchor read. The trigger parental_rights_actions_refuse_mutation runs refuse_event_row_mutation().
A DELETE is always refused, and an UPDATE is admitted only as a RETIRE: an event has no window to
close.
The acts (claim scope cases.parental_rights_actions.<act>, <act> = record / correct /
retract; there is no close and no separate history route):
| Route | Effect |
|---|---|
|
Record one action. The body ( |
|
Retire the named live row as |
|
Retire the named live row as |
|
The event history: every live row, newest first by the order key |
|
The at-anchor read: per parent, the row in force at |
Authority follows the case routes:
-
A pure service principal is refused first (403, the GET included).
-
The body is validated (422).
-
The case must exist (404), and authz is
Action::Updateon the case for the writes,Action::Readfor the GET. -
The body dates are checked,
effective_onincluded. -
Inside the claimed transaction, a RECORD passes
require_case_open(409case-closed). A correction or a retraction does not: a wrong action on a closed case is still corrected or retracted. -
{child_id}must be, or have been, achild-role member of the case (400child-not-in-case).
Then, on record AND correct, the ledger’s cross-table rules run in this order, each a typed 400 with nothing written:
-
parent-not-linked(fieldparent_person_id): the parent must hold a live (retired_at IS NULL)child_parentsrow for the child, open OR closed, with no date bound. A link is routinely closed at or after the termination, and the action stays enterable and correctable. -
parental-rights-order-invalid(fieldcourt_order_id): acourt_order_id, when given, must be an ACTIVE court order of THIS case withorder_type = termination_of_parental_rights, read inside the transaction. It is admitted on anot_applicablerow too, because an order denying termination is evidence of the assessment. A court order soft-deleted after the action was recorded leavescourt_order_idin place: the court-order act writes no action rows. -
icwa-flags-without-determination(fieldterminated_on, oreffective_onwhen no termination date is stated): if any of the six findings is answered, the case’schild_icwa_factsrow in force atterminated_onmust carrycourt_determination = yes_icwa_applies; with no termination date (a pending termination) the row in force at the resolvedeffective_onis read instead. The findings belong to the termination itself (89 FR 96589, §1355.44(i)(2)(ii)-(iii); #2006), so a petition filed before the determination is admitted when the termination comes after it. This is an at-date read, so a historical action keeps its findings after the determination changes, and stays correctable while the date the gate reads stays inside ayes_icwa_appliesrow. A correction that dates the termination after the determination stopped applying is refused, even though ICWA applied at the petition.
Events: case.child_facts_changed with ledger = "parental_rights_actions", act recorded /
corrected / retracted and user_id (the acting worker; #2016). This is the case ledgers' family event; there is no new routing key.
The event core (#1994; U5’s event ledgers reuse it, with one generalization):
-
craig_ledger::store::eventholds the event acts.recordinserts alone.correctlocks the live row, retires it ascorrectedand inserts under the predecessor’s stored key, with the factsEventLedger::inheritderives from the predecessor (#1995; it replacedwith_event_on). The default inherits nothing: the rights facts always resolve their date. The plan facts keep an omittedestablished_on; the review facts keep an omittedheld_onand always the predecessor’scourt_order_id. -
It also holds the two reads:
historyandat_anchor(DISTINCT ONthe stored key, the event date on or before the anchor, the ledger’s order). Every SQL string is rendered from compile-time identifiers. -
api::ledgers::eventsholds the genericrecord_event/correct_event/retract_event/list_eventhandlers in the D1 authority order. A ledger declares its table, event-date column, order key, key, facts, route and its cross-tablecheck. -
The row acts both ledger classes share (lock a live row, retire it, read it, retract it) are one generic copy over
craig_ledger::store::LedgerTable.
The (c) projection
P-D reads the projection. U4 ships it as the pure, DB-free module craig_cases::afcars_parents, which
returns typed cells, never dictionary tokens. It is tier 3 (the order’s totality, the at-anchor
reconstruction) plus the plan’s D1 code map; the federal arms stay in federal-afcars-2020.
-
(c)(1) / (c)(2) read the
child_parentsrows in force at the anchor whoselegal_responsibilityistrue, in the parent order. An unanswered flag is not counted (fail-closed), so a seeded link, whose flag is unanswered, projects blank. A parent’s year is D2’s rule on the parent’s ownpersonsrow:birth_year, elseyear_of_birth_declared.-
(c)(1) is the first row’s year, else
abandonedwhenparents_abandoned, else blank. -
(c)(2) is the second row’s year, else
not_applicablewhensole_legal_parentistrue, elseabandonedwhenparents_abandoned, else blank. -
The
abandonedandnot_applicablearms fire only when the ROW is absent: a present row whose parent has no year projects blank. -
No parentage row in force at the anchor reads as
parents_abandoned = falseandsole_legal_parentnot assessed.
-
-
(c)(3) / (c)(4) are
tribal_member, in force at the anchor on the demographics ledger, of the firstmother(resp.father) row in force at the anchor in the same order, REGARDLESS oflegal_responsibility. No such row projects blank. -
(c)(5) covers every parent with a live
child_parentsrow whoseeffective_fromis on or before the anchor, of any role (the CFR asks "biological, legal and/or putative"). The link may be in force at the anchor or have ended before it: a terminated parent’s closed link stays in the file. Parents are ordered by the parent order over each parent’s latest such row. Per parent, the row in force is the at-anchor read’s.-
No row projects blank.
-
A
not_applicablerow projectsnot_applicablewith (i) and (ii) blank. This includes a parent who died with no termination. -
On a
voluntary/involuntaryrow, the parent is deceased at the anchor only whenparent_deceasedanddied_onis on or before the anchor. (c)(5)(i) isdeceasedwhen the parent is deceased at the anchor, elsepetition_filed_on. (c)(5)(ii) isdied_onwhen the parent is deceased at the anchor, elseterminated_on. -
A component date after the anchor projects blank. For example, a petition on file with the termination still pending at the anchor answers (c)(5)(i) and leaves (c)(5)(ii) blank.
-
The permanency ledgers (#1995, ADR-078 D1, plan D6)
Migration 20260923180000_permanency_ledgers is DESTRUCTIVE (-- devstack: wipe-before-apply). Its
statement order is fixed so that a refusal rolls back ALL of U5 in one transaction:
-
The refuse-on-data guard, FIRST: the migration raises while ANY
case_plansrow exists (a per-case goal cannot be honestly split into per-child plans); the message namescargo xtask dev reseed. -
permanency_plans, thenchild_review_events(columns in the field-registry order). Each table attaches U4’srefuse_event_row_mutation()(the file creates no function) and carries aCOMMENT ONnaming its CURRENT order and that its scheme is frozen. -
The
contactsvisit columns and their three CHECKs (below). -
ALTER TABLE case_plans DROP COLUMN permanency_goal; its CHECKchk_case_plans_permanency_goaldrops with the column. -
The MANDATORY
schema_compat_floorbump to20260923180000, LAST: an N−1 image writes the dropped column. Rollback is N−1 images AND a database restore.
Every column of the two ledgers and of contacts is Plaintext in the field registry.
DEFAULT_REGISTRY then carried EIGHTEEN tables (twenty since Custody episodes and the legal-status ledger (#2342, ADR-081, plan custody-episodes-doe-slds D2 + D3)): contacts joined with the
two ledgers, because every new column takes a FieldSpec (plan D8).
Both ledgers are event ledgers on the U4 event core with the rights ledger’s frame
(the provenance columns, retired_reason over corrected / retracted / order_corrected /
order_deleted, the four frame CHECKs, a …_one_successor unique index, and the trigger admitting only
a RETIRE). They are keyed (person_id, case_id): the child (FK persons) within one case (FK cases),
both ON DELETE RESTRICT. This part records only what differs.
| Ledger (route segment) | Column | Values | AFCARS |
|---|---|---|---|
|
|
the seven fleet |
(f)(1) |
|
|
(f)(2) |
|
|
|
|
(f)(3) / (f)(4) |
|
|
(f)(3) / (f)(4) |
|
|
FK |
— |
Orders. The CURRENT plan is the live row with the latest (established_on, recorded_at, id). The
history (GET …) returns every live row in that order, newest first: established_on DESC, recorded_at
DESC, id DESC for plans and held_on DESC, recorded_at DESC, id DESC for reviews. The at-anchor read
(GET …?as_of=) returns the row in force at as_of: the first, in the same order, among the live rows
dated on or before it. An empty plan ledger means no plan is established. idx_permanency_plans_case_child
(case_id, person_id, established_on) and idx_child_review_events_case_child (case_id, person_id,
held_on) serve the reads. idx_child_review_events_live_order (court_order_id, partial on court_order_id
IS NOT NULL AND retired_at IS NULL) serves the order sweep.
The acts (claim scopes cases.permanency_plans.<act> and cases.child_review_events.<act>, <act> =
record / correct / retract) are the rights ledger’s routes under
/v1/cases/cases/{case_id}/children/{child_id}/permanency-plans and …/review-events: POST records,
POST …/{row_id}/corrections supersedes, POST …/{row_id}/retract retires with a note, and GET lists
the history or reads at as_of. Authority is the case-child order of the rights ledger: a pure service
principal refused first (403, the ledger GET included — the ONE service read is craig-financial’s
…/permanency-plans/current, below), 422 for the body, the case (404) and its authz, the body
dates (after today is the 400 ledger-date-after-today; a NEW event without its event date is the typed 400
bad-request naming established_on / held_on), require_case_open on a RECORD only (409 case-closed;
a correction or retraction is admitted on a closed case), and the child a child-role member of the case,
now or before (400 child-not-in-case). A row of another child or case is the 404 ledger-row-not-found
with nothing written. Neither ledger has a cross-table rule.
The service read (P-C U6a, #1996, ADR-078 D4 / plan D7).
GET /v1/cases/cases/{case_id}/children/{child_id}/permanency-plans/current?as_of= is the ONE service read of
P-C data: the plan in force for craig-financial’s guardianship activation, which passes the derived transfer
date. Authority is require_service_caller() then service_id() == "craig-financial" (the handler’s allowlist of
one, not a ruleset row), before any read: a human (the assigned caseworker and an admin included) or any other
service is 403; a financial token carrying a lifted actor is admitted (the outer token is the identity). as_of is
REQUIRED and not capped at today (a transfer date may lie ahead); a missing as_of or an unknown query parameter
is refused. Past the guard and the query, the read answers ONLY 200 or 204: the at-anchor read above takes
the one row in force at as_of and serves CurrentPermanencyPlan (event_id, plan, established_on; craig-cases-contracts, lenient on decode), or
204 when none. There is no case-existence 404 and no membership 400: an unknown case or a non-member child
holds no live row (every write requires membership) and answers 204. Both answers carry Cache-Control:
no-store. The act and history routes above still refuse craig-financial like every service principal.
Corrections inherit (EventLedger::inherit). A correction that omits the event date keeps the
predecessor’s (established_on, held_on). A review correction ALWAYS keeps the predecessor’s
court_order_id, so the order’s later update or delete still retires the successor.
The plan event. Every committed plan act publishes case.permanency_plan_established in its claimed
transaction, with action established (a record), corrected or retracted. The payload
(deny_unknown_fields) carries:
-
event_id: the acted row — the new row, the correction’s successor, or the retracted row. -
person_id,case_id, and the acted row’splanandestablished_on. -
supersedes_id: a correction’s predecessor, elsenull. -
act_id: a fresh UUIDv7.act_at: the act’s clock. -
current: the child’s CURRENT plan after the act (event_id,plan,established_on), ornullwhen no live row remains. -
user_id: the act’s acting worker (claims.acting_worker()), the LAST key (#2016).
The consumer rule: per (person_id, case_id), apply the LATEST message by (act_at, act_id) and hold
its current. A retraction’s message therefore outranks the established message of the row it retracts.
The rule holds because of the per-case plan lock: the publish locks the case row FOR NO KEY UPDATE (held
to commit), THEN reads current and clock_timestamp() as act_at, and only then mints act_id. Acts on
one case’s plans serialize, and each act’s clock follows the one before it. FOR NO KEY UPDATE leaves other
writers' foreign-key checks (FOR KEY SHARE) unblocked. A record already holds the case row FOR UPDATE
from the case-open gate.
The review events publish the family event case.child_facts_changed with ledger =
"child_review_events" and act recorded / corrected / retracted — or, for an order-driven retirement,
order_corrected / order_deleted, one message per retired row. Those two acts widen the family event’s
act vocabulary. Every message carries user_id (#2016): the acting worker of the review act, or, for a
sweep, of the court-order act. The review share lock: inside the claimed transaction, after the claim and the route’s
guard and before anything is written, the review ledger’s record and correct take the case row FOR KEY
SHARE (a record already holds it FOR UPDATE from the case-open gate). A direct correction therefore
serializes against an order update or delete, both of which hold the case row FOR UPDATE through the
case-open guard, and the order sweep sees the committed successor.
court_order_id is provenance, never stated by a request. Only the court-order act writes it. A record or
correction body carrying one is a 422 (the field is read-only on the wire), so no request attaches a row to an
order’s sweep. Every response carries it.
The court-order hearing act. CourtOrderType::hearing_kind is the one type-to-kind map: review_hearing →
periodic_review, permanency_hearing → permanency_hearing, every other type none. A court-order create
or update states the hearing as hearing: { held_on, children } (1–25 children, each once).
-
Create. A hearing type without
hearingis the typed 400court-order-hearing-required; any other type with one is the typed 400court-order-hearing-not-admitted(bothfield = hearing).hearing.held_onafter today is the 400ledger-date-after-today. Inside the order’s claimed transaction, after the order row, the act writes ONE review row per named child through the event core’srecord(kind=hearing_kind,held_on,court_order_id= the order), each publishingrecorded. A child that is not, and never was, achild-role member of the order’s case is the 400child-not-in-case(fieldhearing.children) and NOTHING is written — no order either. -
Update (
If-Match). Inside the transaction the order row is locked at the expected version, and the resolved type is the body’s or the stored one. A resolved non-hearing type withhearingis refused ascourt-order-hearing-not-admitted. A resolved hearing type that differs from the stored type and comes withouthearingis refused ascourt-order-hearing-required(a change between the two hearing types needs one too). A statedhearingretires the order’s rows (order_corrected) and then writes the new set. Leaving a hearing type for a non-hearing type retires them (order_corrected). Any other update sweeps nothing: a court-name edit never supersedes a direct correction. -
Delete retires the order’s rows (
order_deleted). -
The sweep retires EVERY live row carrying the order’s id, naming the order act’s acting worker (
claims.acting_worker()) as each row’sretired_by(#2016) —UPDATE … SET retired_at = now(), retired_reason = $2, retired_by = $3 WHERE court_order_id = $1 AND retired_at IS NULL RETURNING *, which the trigger admits row by row — corrected successors included. An update that sweeps, or a delete, therefore supersedes a direct correction of its rows.
The court-order act is case-parented, so a closed case refuses it (409 case-closed) while a row’s direct
correction stays admitted. No rule relates held_on to the order’s order_date (plan D6 names none).
The court-order create / update / delete and the contact create / update refuse a pure service principal
first (403): every route that writes P-C data does (ADR-078 D1).
The order’s recorder (#2031). court_orders.recorded_by / recorded_by_name (both on the CourtOrder
wire) are the acting worker’s sub and preferred_username (claims.acting_worker(), ADR-062). For a
BFF-lifted token that is the worker, never the service principal — the same subject as the order’s claim
and its hearing’s review rows. The actor token carries no full name, so recorded_by_name is the username,
as on a direct token. Rows written before #2031 keep theirs. The order’s update writes no recorder column,
its document upload names the acting worker as the attempt’s created_by, and its delete names the acting
worker as the swept review rows' retired_by.
The contacts visit. Two nullable columns: visited_child_id (FK persons, ON DELETE RESTRICT) and
location (childs_residence / other_location) — AFCARS (f)(5) (the contact’s occurred_at) and (f)(6).
The DB twins:
-
chk_contacts_location_domain:locationis NULL or one of the two tokens. -
chk_contacts_visit_pair: both columns are set or neither is. -
chk_contacts_visit_type: a visited child only on ahome_visit/office_visit/school_visitcontact (ContactType::admits_visit, the one truth-table predicate).
The wire is the pair object visit: { visited_child_id, location }, so a half pair is unrepresentable.
On create, visit is optional. On update, an omitted visit leaves the stored pair, null clears it, and
a value sets it. The truth table is checked on the RESULTING row before the claim: the resolved type (the
body’s or the stored one) with a resolved live visit it does not admit is the typed 400 bad-request
(field = visit). The update never clears implicitly, so a change to a non-visit type must send visit:
null. Inside the transaction, after require_case_open, a set visit’s child must be a child-role member
of the contact’s case, active or not (400 child-not-in-case, field visit.visited_child_id). A CHECK
violation on the three constraints maps to the same typed 400, as the race backstop. Responses carry both
columns (null when unset).
case_plans without the goal. The per-case permanency_goal column is gone. The per-child plan is the
permanency_plans ledger, and case.plan_created carries case_plan_id and case_id only.
Custody episodes and the legal-status ledger (#2342, ADR-081, plan custody-episodes-doe-slds D2 + D3)
Migration 20261013120000_custody_episodes is ADDITIVE (no wipe marker, no schema_compat_floor bump, ADR-063 D3;
plan Rollout 1). It creates the two tables, the episode row guard, the deferred instants trigger and the cases closure
trigger, and attaches U4’s existing refuse_event_row_mutation() to the ledger. Every column of both tables is
Plaintext in the field registry (DEFAULT_REGISTRY now carries TWENTY tables), and both are scheme-frozen: each row
trigger refuses the crypto rewrite tool’s in-place UPDATE, so no column may join the rewrite ALLOWLIST. Every
reference is ON DELETE RESTRICT.
Migration 20261106140000_legal_status_chain_seq bumps schema_compat_floor (#2353): it adds chain_seq, back-fills
it, re-states the deferred instants trigger’s order arm on it, and bumps the floor last, because an N−1 replica inserts no
chain_seq (refused by its NOT NULL) and orders a day by chain_root_id. The back-fill keeps every existing row’s
order: within each child, chains are numbered from 1 in chain_root_id order, and every row of a chain takes its
root’s number. Stop every N−1 craig-cases replica before applying it; rollback past it is roll-forward.
custody_episodes — one in-custody run of a child, owned by one case for life (the ADR-079 removal-episode shape):
| Column / constraint | Meaning |
|---|---|
|
UUIDv7, the episode’s stable identity (an outbound bind’s stage id) |
|
FK |
|
|
|
the opening act’s clock and acting worker |
|
the RETIRE: |
|
|
|
|
idx_custody_episodes_case (case_id, child_id) serves the case read and idx_custody_episodes_child_live (child_id,
partial on live) the act’s lock. There is no updated_at column: a touch would break the guard’s shape comparison.
The row guard (trg_custody_episodes_row_guard, function refuse_custody_episode_row_mutation()) refuses a DELETE
and admits an UPDATE only as (1) the instants of a LIVE episode (every other column unchanged) or (2) a RETIRE naming
retired_by; anything else raises integrity_constraint_violation. A retired episode is inert.
legal_status_facts — an event ledger on the U4 event core with the rights ledger’s frame (the
provenance columns, the four frame CHECKs, uq_legal_status_facts_one_successor, legal_status_facts_refuse_mutation
admitting only a RETIRE), keyed (person_id, case_id) (the shared CaseChildKey). What differs:
| Column / constraint | Meaning |
|---|---|
|
a token of the active StateBundle’s legal-status vocabulary, checked at write;
|
|
|
|
|
|
the original’s own id, kept by every correction ( |
|
|
|
NULL = a history row; else the episode an in-custody or closing row belongs to, through
|
|
FK |
|
|
uq_legal_status_facts_one_live_close allows at most one live closing row per episode. idx_legal_status_facts_case_child
(case_id, person_id, effective_on) serves the history and at-anchor reads, idx_legal_status_facts_live_episode
(episode_id, partial on live rows that name one) an episode’s rows, and idx_legal_status_facts_live_history
(person_id, effective_on, partial on live rows that name NO episode) the containment check, which reads a child’s history
rows across cases. idx_legal_status_facts_live_order (court_order_id, partial on live rows that name one; migration
20261014120000_legal_status_order_rows, additive) serves the court-order restatement and sweep. A correction inherits
the predecessor’s chain_root_id, chain_seq, episode_id and court_order_id (EventLedger::inherit); its token, date and note
are its own.
The deferred instants trigger ck_custody_episode_current_instants (two CONSTRAINT TRIGGER`s, `DEFERRABLE INITIALLY
DEFERRED: on custody_episodes after insert or an update of the instants or retired_at, and on legal_status_facts after
insert or update). At commit, or at SET CONSTRAINTS … IMMEDIATE, a LIVE episode must agree with its live rows:
custody_from is the earliest live in-custody effective_on (none fails), custody_until the live closing row’s (NULL when
none), and no live in-custody row orders after the closing row by (effective_on, chain_seq). A retired episode and a
history row are skipped. It raises check_violation naming the constraint; every act runs it IMMEDIATE before it returns,
so it is an internal invariant no request can trip (a disagreement is a redacted 500), and a direct instant UPDATE fails
at commit.
The cases closure trigger trg_cases_refuse_close_with_open_custody (BEFORE UPDATE OF status, function
refuse_case_close_with_open_custody(), VOLATILE so a read-committed retry sees an open committed while it waited on the
row lock) refuses closed / transferred while a live episode of the case is open, raising check_violation with
constraint ck_case_custody_open. The case update maps it to the typed 409 custody-open (CaseUpdateError); any other
writer, an older replica included, gets it as a 500, never a closed case with open custody. The case row lock serializes a
close with a racing open.
Order and reads. Rows order by (effective_on, chain_seq); the status in force on a day is the last live row on or
before it. GET /v1/cases/cases/{case_id}/children/{child_id}/legal-statuses returns every live row newest first
(effective_on DESC, chain_seq DESC, id DESC), or with ?as_of= the row in force on that day. Each row’s facts carry
chain_seq.
GET /v1/cases/cases/{case_id}/custody-episodes[?child_id=] returns the case’s episodes, live AND retired, by child_id,
then custody_from DESC, id DESC (a child_id that is not a child-role member of the case is the 400 child-not-in-case).
The acts (claim scopes cases.legal_status_facts.record / correct / retract and cases.custody_episodes.retract, ADR-062
idempotent; a replay answers the original):
-
POST …/children/{child_id}/legal-statusesrecords and answers 201{ row, episode }(a replay answers 201 too). It states its intent: an in-custody status naming noepisode_idOPENS an episode (409custody-episode-overlapon any live episode of the child, this case or another); naming one, it is a CHANGE in that open episode; a not-in-custody status naming one CLOSES it; naming none, it is a HISTORY row, refused while the child has an open episode in this case (409custody-episode-open, naming it).until: { status_token, effective_on }on an in-custody status naming no episode records a closed historical episode in one act (two rows; a one-day episode passes; a malformeduntilis a 422). A named episode that is closed, retired or another case’s is the 409custody-not-open. -
POST …/legal-statuses/{row_id}/correctionsrestates a live row within its class (a class flip is the 422custody-class-flip) and keeps its episode and place; the instants follow. -
POST …/legal-statuses/{row_id}/retract(anote) retires one row: (i) another live in-custody row remains, so the instants follow; (ii) it was the last live in-custody row, so the whole episode retires as below, this row included; (iii) it is the closing row: 409custody-close-not-retirable(correct the close, or retract the episode; a closed episode never reopens). -
POST …/children/{child_id}/custody-episodes/{episode_id}/retract(anote) retires the episode (retracted, the note on the episode) and, in the same transaction, every live row of it asepisode_retracted; those rows are the snapshot an outbound removal reports, and the court-order sweep retires live rows only, so it never touches them. Another case’s or a retired episode is the plain 404.
Court-order writes (#1804, plan D4). CreateCourtOrderRequest and UpdateCourtOrderRequest carry an optional
custody: { children, status_token, effective_on } (CourtOrderCustody; 1-25 children each named once, else the 422
validation failure; each a child-role member of the order’s case, now or before, else the 400 child-not-in-case on
custody.children). It is
admitted like a worker act’s status (the vocabulary 422s on custody.status_token, the 400 ledger-date-after-today on
custody.effective_on) and then:
-
the order writes one row per child,
court_order_idset, in the order’s own transaction (after its hearing rows); -
each row takes the intent the child’s custody in the case implies: an open episode in this case makes it a change (an in-custody status) or a close (a not-in-custody one); with none, it opens an episode or is a history row;
-
an update with
custodyrestates per child: a child named again has its live order row corrected within its class (422custody-class-flip; a row already stating the same token and date is left as is, no event), a child no longer named has its row retired asorder_corrected, a newly named child gets a new row; an update withoutcustodytouches no row; -
a delete retires every live row the order wrote as
order_deleted; -
every retirement follows rules (i)–(iii) above: the instants follow, an episode left without an in-custody row is retracted (its
retired_notenames the order and the reason, ids only), and a closing row refuses the WHOLE order act with 409custody-close-not-retirable, nothing written; -
one lock call covers every child the act touches, in child-id order, after the order’s case row, so two orders naming the same children in opposite orders never deadlock; each child’s rules read only its own episodes;
-
the events reuse the five keys and the act tokens (
recorded/corrected/retracted), and every event of one order act shares oneact_id/act_at.
After every act the episode rule holds: an episode’s live rows are its in-custody rows, then at most one closing row ordered
after each of them, and no live history row lies inside a live episode’s span, in either direction (a history row dated
inside one, or an open, until or date move that would wrap an existing one); else 409 custody-row-out-of-order.
Authority is the case-child order: a pure service principal 403, 422 for the body, the case (404) and case: update
(403), then the vocabulary — an empty one (a stub bundle) is the 422 legal-status-vocabulary-missing on all four acts, an
unknown token the 422 legal-status-unknown — then a date after today (400 ledger-date-after-today), the claim, and
inside it require_case_open (409 case-closed) on an open, a change, a close or an until record only; a history row, a
correction and both retracts pass on a closed or transferred case. The child must be a child-role member of the case, now
or before (400 child-not-in-case). The reads take case: read.
The lock order (plan D2 and its erratum, ADR-081 D3): the claim, the case row (FOR UPDATE from require_case_open on a
lifecycle act, else FOR KEY SHARE), then a transaction-scoped advisory lock per named child in child-id order, then the
named children’s live episodes in every case in one FOR UPDATE statement ordered by id. A child with no live episode has no
row to lock, so the advisory lock is what serializes two cases' acts on one child; the loser of two racing opens then meets
the winner’s episode and answers the typed 409, never a deadlock 500.
Events. Every committed act stages its transitions in the claimed transaction: case.custody_opened / _closed /
_retracted / _close_corrected and case.legal_status_changed, ids-only (CustodyEventPayload; ADR-003 is the catalogue
row, implementation-guide.adoc the payloads). A replay stages none.
The AFCARS persons export (P-D1, #2121, #2122)
P-D1 built POST /v1/cases/persons/afcars-export (#2121; #2122 added
the ledger kinds) for the bare craig-reporting service principal alone; any other caller is 403.
-
Keys. A child key is
(person_id, case_id), an adult key(person_id, role)withrolecaregiveroradoptive_parent. A call takes at most 500 keys and 10 000 anchors, andlimit(1..=1000) bounds rows. The cursor carries a SHA-256 digest of the body barafterandlimit, so another body’s cursor is refused. -
Rows.
not_found,personanddemographic_window, then, for a child key only,parent_cells,parenting_window,prior_permanency_window,assistance_window,sibling_count_window,icwa_window,permanency_plan,review_event,sibling_linkandvisit, under thekindtag. An unknown person, or a child key whose person is not achild-role member of its case atas_of(added_at ⇐ as_of, #2189), is onenot_foundrow that releases nothing. Only a child oradoptive_parentkey’spersonrow carries a date of birth, through a DOB-only decrypt (thepersonsrow above). -
Parent action dates and the ICWA keys (#2004). Each
parent_setentry also carriesterminated_onandpetition_filed_on— the rights row’s own dates, eachnullunless the row in force isvoluntary/involuntaryand the date is on or before the period end; never a date of death (c5iisubstitutes that,terminated_ondoes not). Theicwa_windowrow carries the two notices before the first proceeding and the two order dates, never the unqualified parent notice. -
As of. Every ledger row is normalized to how it stood at
as_ofbefore use, including the rows behindparent_cells. A child membership counts when itsadded_atis at or beforeas_of(#2131 D2), a case’sadmin_unitis fixed at the case’s creation (D1), and a contact exists by itscreated_at/deleted_atand reads its visit trio as it stood atas_of(below). Onlypersonsreads current: a correction landing mid-walk answers on the pages read after it (D6, ⁂ on #1073). Within a page every statement reads oneREPEATABLE READ READ ONLYsnapshot (#2422), so a commit landing mid-page is wholly seen or wholly unseen by that page. -
Contact revisions (#2131 D5).
contact_revisionsholds a contact’s prioroccurred_at,visited_child_id(FKpersons) andlocation, theversionthat held them (UNIQUE (contact_id, version)) andsuperseded_at;contact_idisON DELETE RESTRICT, indexed(contact_id, superseded_at, id). The contact update writes one row in its own statement when the trio changed (a narrative-only edit or a CAS miss writes none), stampedclock_timestamp()after the row lock. The export reads a contact’s earliest revision superseded afteras_of, else the row.refuse_revision_mutation()refuses every UPDATE, DELETE and TRUNCATE (every column plaintext and scheme-frozen). The history starts with migration20261005140000: an edit made before it kept no prior value. Since #2231 a revision also names its worker:superseded_by UUID NOT NULLis the acting worker (claims.acting_worker(); the handler refuses a pure service principal) whose update superseded the trio, bound into the same revision INSERT, no FK (therecorded_byposture). Migration20261008140000_contact_revision_actor.sql(-- devstack: wipe-before-apply) refuses to apply while any revision exists (nothing recorded names the worker behind one; the contact PUT stages no event), adds the column NOT NULL with no default, and bumpsschema_compat_floorto20261008140000LAST (required: an N−1 contact edit omits the column). Rollback is N−1 images AND a database restore. The export never readssuperseded_by. -
Audit. A page that releases a person stages one
case.person_pii_exportednaming each row’s key person, the parents behind eachparent_cellsrow and, indate_of_birth_person_ids, those whose date it released.Cache-Control: no-store.
Person identifiers (#1806, plan custody-episodes-doe-slds D5)
person_identifiers holds a person’s external identifiers, one row per identifier under a kind the active
StateBundle declares (StateBundle::identifier_kinds(); Georgia: gtid, ten ASCII digits, and empi (#2428, the
EMPI client identifier IES names dhr_client_number), nine, both ⁂ #1073; the Texas stub declares none, so every act
there is 422 identifier-kind-unknown). Migration 20261014130000_person_identifiers.sql, additive, no
schema_compat_floor bump.
-
Columns.
person_id(FKpersons,ON DELETE RESTRICT),kind(a bundle token,^[a-z][a-z0-9_]{0,15}$),value(CGEF ciphertext of the format-checked value, never trimmed) besidevalue_hmac, itsBlindIndexdigest under the"person_identifier"field domain (NULL only keyless),effective_from/effective_until(DATE, inclusive; the write boundary refuses a date after today on the jurisdiction clock, 422identifier-dates-invalid, and the CHECK refuses an end before the start),provenance,recorded_at/recorded_by,ended_at/ended_by(paired witheffective_until), and the retire quartetretired_at/retired_by/retired_reason(retracted) /retired_note. -
Provenance (#3192, migration
20261202110000_person_identifier_provenance.sql). How the value was established:worker_attested(a worker typed and attested it through the record route),partner_matched(the jurisdiction’s person index returned it and a worker selected that candidate) orpartner_assigned(the index assigned it at a registration). The record route takes no provenance and always writesworker_attested(a body carrying one is refused 422, the request denying unknown members); the other two are written only by the person-index conversation. The identifiers panel shows it as "Source". -
Live and the uniques. Live = neither retired nor ended. Two partial UNIQUEs over live rows:
uq_person_identifiers_person_kind_live (person_id, kind)anduq_person_identifiers_kind_value_live (kind, value_hmac). Either answers 409person-identifier-duplicate, whose detail names neither the value nor a person. KeylessOptionalleavesvalue_hmacNULL, so the per-value unique does not bite there (no key, no index; production and both harnesses are keyed). An ended value may be recorded again, on any person. -
Row guard.
refuse_person_identifier_row_mutation()refuses every DELETE and admits an UPDATE only as the END of a live row (effective_untilwith its ender) or a RETIRE namingretired_by. There is noupdated_at. The table is scheme-frozen: the trigger refuses the crypto rewrite tool’s in-place UPDATE, sovaluejoins its allowlist only with a trigger arm. -
Demographics guard and its twin. A record needs a person with a date of birth and non-blank first and last names, checked under the person row lock (422
person-demographics-incomplete, fieldperson_id). A personPUTthat would blank either name of a person holding a live identifier is 409person-identifier-live(the detail namesfirst_nameorlast_name), judged under the same lock (api/persons_locked.rs). -
Lock order. The record claims, then takes
lock_person(FOR NO KEY UPDATE), then inserts; end and retract claim, then lock the identifier rowFOR UPDATE(neither locks the person; the claim’s guard only reads that it exists); the person update takeslock_person, then readsperson_holds_live. No act takes a case lock, so the persons-before-cases order gains no edge. -
Routes and authority. Five routes under
/v1/cases/persons/{id}/identifiers, each refusing a pure service caller (deny_pure_service) and inheriting the person’s authority exactly:GET(PersonRead; every row, masked to its last four),POST(record, PersonUpdate),…/{identifier_id}/endand…/retract(PersonUpdate) and…/reveal(PersonApprove; GA admin and supervisor). The three acts are ADR-062 idempotent under the claim scopescases.person_identifiers.record,.endand.retract(entity kindperson_identifier); the record’s intent hashes the keyed digest throughblind_digest, never the value. -
Events. Ids only, the strict
PersonIdentifierEventPayload(identifier_id,person_id,kind,act, a v7act_id,user_id):case.person_identifier_recordedon a record,case.person_identifier_endedon an end or a retract (actsays which). A reveal stages and commits acase.person_pii_exportedwrapper (purpose = person_identifier_reveal, theidentifier_id, the kind, the revealing worker asuser_id) before the value is decrypted, and answersCache-Control: no-store. See ADR-003. -
Outbound (#2343). craig-exchange reads a GTID only on the custody arms of the outbound projection (the ADR-075 amendment); each read stages the
outbound_principalsrelease wrapper first, and the wrapper never carries the GTID. The Medicaid-application arms (#3193) release the live identifier of the kind the bundle names for an application, under the same wrapper (see Partner reports on a Medicaid application (#3193)). The DOE-SLDS identifier legs admitkind = gtidonly, so recording or ending an EMPI is no DOE occurrence (#2428). -
Seed. The seeder derives one live identifier per declared kind (Georgia: a GTID and an EMPI) per distinct seeded child with a date of birth (no new draw);
xtask verify-seedand the key lineage’s lineage-absent scan cover the table.
The person-index conversation (#3192)
A worker on a case asks the jurisdiction’s person index (in Georgia, the EMPI) who a member of the household is,
selects a candidate it answered, or has it register the person as new. craig-cases holds the conversation, since it
holds the case and the person; craig-exchange makes each call of the index
(Asking a person index). Migration
20261202120000_person_index_inquiries.sql, additive, no schema_compat_floor bump.
-
Routes and authority.
POST /v1/cases/cases/{id}/persons/{person_id}/index-inquiries(the ask),…/{inquiry_id}/selectand…/{inquiry_id}/register. Each refuses a pure service caller, needs CaseUpdateon the case, and answers 404 unless the person is an active member of that case’s household: a person has no owner to check, so the case is the authority. A deployment whose bundle names noperson_index_identifier_kind, or that has no field key, refuses every act 409person-index-unconfigured. -
The ask. Refused 409 when the person already holds a live identifier of the index’s kind (
person-index-person-identified), when the sex is not recorded (person-index-facts-missing), or within a minute of a registration begun for the person (person-index-registration-in-flight). It sends the first name, the last name, the sex and the date of birth, and no SSN. It then consults the jurisdiction’s ruleset<jurisdiction>-person-index-choiceoncountandtop_score, under the acting worker’s relayed authority. The ruleset answersselection_open,selectable_from(the lowest selectable score; present exactly when selection is open) andregistration_open; an answer in any other shape is a redacted 500 (the log names the ruleset) and keeps nothing. The response carries the candidates as the index described them, each marked selectable or not, whether registration is open, and which of the four facts a registration sends are missing. An ask is not replayed: a repeated ask is a new inquiry. -
What is kept. One
person_index_inquiriesrow per person (uq_person_index_inquiries_person), replacing the earlier one:case_id,asked_by,selectable_from(NULL = no candidate may be selected),registration_open,expires_at(fifteen minutes after the ask, on the database’s clock),registering_atandselecting_at. Beside it, oneperson_index_inquiry_candidatesrow per candidate:id_digest(theperson_identifiersblind index of the candidate’s id) andscore. A candidate the index answered twice is kept once, at its lower score. No name, date, residence, SSN digit or plain id of a candidate is written to any table. -
Select. Body
client_request_id,index_id. The inquiry must be the person’s, opened from this case, unexpired and not registering; the id’s digest must be one the row holds, at or aboveselectable_from(else 409person-index-choice-refused); the id must fit the kind (422identifier-format-invalid). craig-cases tells the index first (the participation) and then, in one transaction, records the identifier aspartner_matchedand deletes the inquiry. An index that was not told records nothing: craig-exchange’s refusal is relayed, its failure is a 503, and the inquiry stays to select from again. -
Register. Body
client_request_id. Open only when the row says so and the person’s record holds the sex, the date of birth, how it was verified and a residence in force today (else 409person-index-facts-missing, the detail naming the facts by token). The row is markedregistering_atbefore craig-exchange is called, and the mark is never cleared: an id that comes back is recorded aspartner_assignedand the inquiry deleted; any failure records nothing and leaves the row registering, so the worker asks again and a registration that landed is then found and selected. The index holds the person from the registration, so no participation follows. -
One kind of act per inquiry. A select marks the row
selecting_atbefore the index is told, and a row a selection was begun from sends no registration (409person-index-choice-refused); a row a registration was begun from admits no selection. So a select and a register made from one answer at the same moment send only one of them (chk_person_index_inquiries_one_kind_of_act). Every act also checks, inside its own transaction, that the person still holds no live identifier of the kind. -
Lock order. The ask’s check-and-replace and the register’s check-and-mark each take a transaction-scoped advisory lock keyed on the person (
person-index-inquiry:<person id>), so an ask never replaces a row a registration was just begun from. A select and a register lock the inquiry rowFOR UPDATE; none takes a person or a case lock until the record, which is the identifier record’s own (claim, thenlock_person). No transaction is open while the index is called. -
Idempotency. Select and register claim under the scopes
cases.person_index.selectand.register(entity kindperson_identifier); the select’s intent hashes the id’s keyed digest, never the id. A replay answers the recorded identifier before the index is called, so a retried act tells the index nothing twice. -
Events. Each release of the person’s facts stages and commits a
case.person_pii_exportedwrapper before craig-exchange is called (purpose=person_index_match,person_index_registrationorperson_index_participation; the person, the case and the acting worker; no fact that was sent and nothing the index answered), so a release whose outcome is never learnt is on the trail. The recorded identifier stagescase.person_identifier_recordedas any record does. -
Sweep. The
person-index-sweepworker deletes expired rows every five minutes. An act refuses an expired row whether or not the sweep has reached it. -
The worker’s page. On a case’s Household tab, where the jurisdiction names a person index, a writer on an open case has "Ask the person index" on each member who is in the household now. The answer swaps into that member’s row (
POST /cases/{id}/household/{person_id}/person-indexin craig-web): each candidate’s name, date of birth, last four of the SSN, residence and score, with a choice wherever one may be selected (already made when there is exactly one), and "Register as new" where registration is open; a fact a registration still lacks is named with a link to the page it is recorded on (the residence page for where the person lives, the person edit page for the other three; that page gained its Sex select for this, since the index is asked with the sex). The answer is rendered in that response and nowhere else: a fragment underCache-Control: no-store, with no flash, cookie, redirect or log line carrying any of it. Select and register are plain forms that return to the Household tab (#household) with the outcome, a refusal’s reason shown as craig-cases gave it. The page is English, like the rest of craig-web; every string is in the catalog (cases-person-index-*), for the Spanish worker catalog (#3181) to translate with the rest.
Initial Medicaid applications (#1807, plan partner-auth-medicaid-application D6 + D7)
medicaid_applications holds the Initial Medicaid Application a worker submits for a child in custody: one row per
submitted application on the child’s custody episode in a case, at most one live per episode. Migration
20261017120000_medicaid_applications.sql, additive, no schema_compat_floor bump.
-
Columns.
case_id(FKcases) andchild_id(FKpersons), bothON DELETE RESTRICT;episode_id(the child’s open custody episode in the case at submit);citizenship_status(CGEF ciphertext, field classOpaque, no blind-index sibling: nothing looks it up; its four tokens are the write boundary’s check, so the CHECK asks presence only);prior_medical_assistance(yes/no/unknown);legal_admin_unit(the canonical admin-unit namevalidate_admin_unitaccepted);submitted_on(DATE, the jurisdiction’s business date ofsubmitted_at, derived from the same instant — a client never sends it);submitted_at/submitted_by; and the retire quartetretired_at/retired_by/retired_reason(retracted) /retired_note. There is noupdated_at. Cases otherwise encrypts identifiers only;citizenship_statusidentifies no one but is an immigration status, so it is sealed at rest all the same and never leaves in an error, an event or a log. -
Live and the unique. Live = not retired. The partial UNIQUE
uq_medicaid_applications_episode_live (episode_id) WHERE retired_at IS NULLanswers 409medicaid-application-exists; a retract frees the episode for a new submit. There is no liveness trigger: an episode later closed or retracted keeps its application (D6), and TP-3’s assembly checks the episode. -
Composite FK.
fk_medicaid_applications_episode (episode_id, child_id, case_id)onto the custody episode’suq_custody_episodes_identity (id, child_id, case_id)— the targetlegal_status_factsalready references — so the episode is the child’s, in that case. -
Row guard.
refuse_medicaid_application_row_mutation()refuses every DELETE and admits an UPDATE only as the RETIRE of a live row namingretired_reasonandretired_by. The table is scheme-frozen likeperson_identifiers: the trigger refuses the crypto rewrite tool’s in-place UPDATE, socitizenship_statusjoins its allowlist only with a trigger arm. -
The EMPI gate.
StateBundle::medicaid_application_identifier_kind()(defaultNone) names the identifier kind a submit requires: Georgiaempi; the Texas stub none, so a Texas submit is ungated. Boot refuses a gate kind the bundle’sidentifier_kinds()does not declare. A child without a live identifier of the gate kind is 422medicaid-application-identifier-missing, fieldchild_id. -
Lock order. A retract claims, then locks the live row
FOR UPDATE, then retires it; a submit’s insert may wait on it through the partial UNIQUE, never the reverse. The identifier END / RETRACT locks only the identifier rowFOR UPDATEand takes no case, advisory or episode lock, so a submit that takes the identifierFOR SHARElast closes no cycle with it. A submit, inside its claim and after a membership-only guard read, takes:-
the case
FOR KEY SHARE; -
the child’s advisory lock (two submits for one child serialize here, so the second meets the first’s committed row at the UNIQUE — no pre-check read);
-
the child’s open episode in this case
FOR SHARE; -
the child’s live identifier of the gate kind
FOR SHARE(none when ungated); -
the insert.
-
-
Routes and authority. The two acts live under
/v1/cases/cases/{case_id}/children/{child_id}/medicaid-applications:POST(submit, 201) and…/{application_id}/retract(POST, 200), each under caseupdate. The two reads are case-level (B-E2):GET /v1/cases/cases/{case_id}/medicaid-applications(an optionalchild_idfilter) and…/{application_id}, each under caseread. Each of the four refuses a pure service caller (deny_pure_service); craig-exchange reads an application through the outbound projection and writes what the partner said through one service-only route (see Partner reports on a Medicaid application (#3193)). The acts are ADR-062 idempotent under the claim scopescases.medicaid_applications.submitand.retract(entity kindmedicaid_application); the submit’s intent hashes the citizenship token’s keyed digest (keyed_token_digest), never the token. -
Refusals (a submit, in the order a request meets them; a retract answers 404
ledger-row-not-foundfor no live application of that id for the child in the case, beside the shared rows 2, 3, 4, 6 and 7):# Where Status / problem type Field 1
the JSON body (
deny_unknown_fields, e.g.submitted_on)422
validation-failedthe unknown field
2
deny_pure_service403
—
3
the body’s length validation
422
validation-failedthe field
4
the case: missing / not authorized
404
not-found/ 403—
5
a token outside its vocabulary, or a county not of the deployment’s state (the detail never echoes the input)
422
validation-failedcitizenship_status/prior_medical_assistance/legal_admin_unit6
the claim
409
idempotency-conflict(another body) / the replay—
7
the child is not a child-role household member of the case
400
child-not-in-casechild_id8
no open custody episode in the case
409
custody-not-open—
9
no live identifier of the gate kind
422
medicaid-application-identifier-missingchild_id10
the partial UNIQUE
409
medicaid-application-exists—
-
Events. Ids only, the strict (
deny_unknown_fields) eight-keyMedicaidApplicationEventPayload(application_id,child_id,case_id,episode_id,act, a v7act_id,act_at,user_id):case.medicaid_application_submittedon a submit (act_at=submitted_at),case.medicaid_application_retractedon a retract (act_at=retired_at); a replay stages none, and no event carries the citizenship status. No consumer in craig-exchange (no trigger-matrix row names the keys; the IES bind, #1822 in TP-3, owes an idempotent backfill of every earlier submit); reporting’scase.*queue receives both as no-ops; craig-security audits them as acreate/updateofmedicaid_application. See ADR-003. -
Seed. None: the seed writes no custody episode, so no application.
xtask verify-seedleaves the table offSEEDED_TABLESon purpose while the encryption registry covers the column; the at-rest proof is the devstack testcitizenship_status_rests_encrypted_and_stays_out.
Partner reports on a Medicaid application (#3193)
An application is referred to the medical-assistance agency that decides it. The agency answers the referral with
its own reference for the application (a receipt) and later reports where the application stands (an outcome).
craig-exchange keeps neither: it posts each to craig-cases, and medicaid_application_reports is where they rest.
Migration 20261203190000_medicaid_application_reports.sql, additive, no schema_compat_floor bump.
ADR-091 records why the partner calls in.
-
Columns.
application_id(FKmedicaid_applications,ON DELETE RESTRICT);interface(the partner interface that reported it, as its adapter-kind token);kind(receipt/outcome);partner_reference(the partner’s reference for the application, plaintext: an outcome is matched to its receipt on it);partner_case_reference,program_id,status(pending/approved/denied/closed) andreported_on, each present only when an outcome states it;received_at(the database’s clock);exchange_transaction_id(the craig-exchange transaction that carried the report; no foreign key, the row is in another service’s database).program_id, the id the partner’s program gave the child, is CGEF ciphertext (field classOpaque, no blind-index sibling: nothing looks a report up by it). It is stored nowhere else. -
One receipt. The partial UNIQUE
uq_medicaid_application_reports_receipt (application_id) WHERE kind = 'receipt'holds one receipt per application. A CHECK keeps a receipt to its reference alone. -
Row guard.
refuse_medicaid_application_report_mutation()refuses every UPDATE and DELETE: a newer outcome is a new row, and an application’s latest outcome from an interface is the one with the greatest id. The table is scheme-frozen asmedicaid_applicationsis: the guard refuses the crypto rewrite tool’s in-place UPDATE. -
The write.
POST /v1/cases/medicaid-applications/partner-reportsadmits the service callercraig-exchangealone (a service principal, that identity, no delegated channel), and answers that before it judges the body. A receipt names its application by id. An outcome names a person by an identifier kind and value and the application by the receipt’s reference: the route finds the one person holding that identifier live (by the blind index ofperson_identifiers.value), then that person’s application whose receipt came from the sameinterfacewith the same reference. It then locks the application’s rowFOR UPDATE, as a retraction does, and compares and stores under that lock.Answer ( outcome)Status When applied201
the report is stored
replayed200
it equals the application’s latest report of its kind from that interface (a receipt: the application’s one receipt); nothing is stored
unknown200
a receipt names no application; or an outcome’s identifier is held live by no one person, or its reference matches no receipt from that interface; nothing is stored
withdrawn200
the application has been retracted; nothing is stored
—
409
medicaid-referral-receipt-conflicta receipt for an application that holds one under another reference or from another interface; nothing is stored, and the detail names neither reference
-
The read.
MedicaidApplication.reportscarries an application’s reports in stored order on both application reads and on every act’s answer, under the application’s own authorization (caseread), the program id decrypted. No other route reads them. -
Outbound. craig-exchange reads an application as a stage of the outbound projection:
GET /v1/cases/medicaid-applications/{id}/outbound-principalsand…/{person_id}, admitted as every outbound arm is (thecraig-exchangeservice identity alone) and audited by theoutbound_principalsrelease wrapper (stage_kind = medicaid_application). The stage is the application (statussubmittedorretracted; a retracted one is served) with the custody facts of the episode it was submitted on and its own facts (the day it was submitted, the citizenship status decrypted for that response only, prior medical assistance, the legal administrative unit). Its one principal is the child, with the live identifier of the kindStateBundle::medicaid_application_identifier_kind()names, decrypted for that response only; none when the bundle names no kind or the child holds no live identifier of it. The open-stages walk answers, forkind = medicaid_application, the submitted applications that hold no receipt. -
Events. Each stored report stages
case.medicaid_application_report_receivedin the write’s transaction: the strictMedicaidApplicationReportReceivedPayload(report_id,application_id,child_id,case_id,kind,interface,exchange_transaction_id,received_at), with nothing the partner stated. craig-security audits it as anupdateofmedicaid_applicationby the posting service. A replay, anunknownand awithdrawnstage none. See ADR-003. -
Seed. None, as for applications; the at-rest proof of
program_idis the devstack testthe_program_id_is_sealed_at_rest.