ADR-078: AFCARS Cases Capture — The Three Capture Classes, the Correction Model, the Demographics Ledger, the ICWA Superset and the Per-Child Plan Ledger
Status
Accepted (2026-09-23). The plan landed as P-C of the #949 program (epic &99) in ten MRs — U0 !1701 (the plan page + this
ADR, Proposed 2026-09-22), U1a !1703 (#1990), U1b !1704 (#1991), U2 !1705 (#1992), U3 !1706 (#1993), U4 !1707 (#1994),
U5 !1708 (#1995), U6a !1709 (#1996), U6b !1710 (#1997) and U7 !1711 (#1998, the close-out); plan:
AFCARS Cases Capture (#1964). Drafted FIRST per the
draft-first path as U0 of #1964. The plan page was approved in plan mode on 2026-09-22 as rev 3
after a four-lane census, a contextless round 1 (23 blockers), the maintainer’s 27-finding gate on rev 2 and three
contextless verification passes over rev 3; rulings R-C1–R-C11 were approved as recommended. The As-built notes under the
decisions record where the merged tree differs from the text as approved (each traces to a plan-page erratum or a named
commit). The decisions keep this ADR’s own numbering: D1 is the plan’s D1, D2 its D2, D3 its D4 and D4 its D6. The
class-3 columns read as of as_of (the contact revisions, the household fence, persons reaffirmed current-state) are
§ Amendment (2026-10-05, #2131), Accepted 2026-10-05.
Context
The AFCARS 2020 out-of-home care file (45 CFR 1355.44, as transcribed into rulesets/federal/federal-afcars-2020.json by P-A2)
asks cases for 45 child / parent / permanency rows in force from 2022-10-01, the 17-row 2028 ICWA re-cut and seven per-child
group-(i) rows. The 2026-09-22 census found 7 captured, 19 in the wrong shape and 19 absent: persons.race holds one of five
tokens where the CFR asks eight yes / no answers; persons.ethnicity holds the legacy code 3 (unable_to_determine) where the CFR
distinguishes unknown, abandoned and declined; persons.gender holds the CFR’s sex; persons.icwa_eligible BOOLEAN NOT
NULL DEFAULT false cannot say "no" from "unasked"; parents are household rows with no child link and no per-parent
termination; the permanency goal lives per CASE on case_plans and per PLACEMENT on placements where the CFR asks each plan per
CHILD with its date; contacts names neither the child visited nor the location. None of these carries history, so a later
value overwrites the answer the file needed at an earlier period end (program A5 / A6).
Constraints the design inherits: every write boundary is claim_first inside execute_claimed_tx (ADR-062); every cases column
takes a FieldSpec and the registry is normative (ADR-048 / ADR-049); a DROP bumps schema_compat_floor in its own file
(ADR-063 D3); the authz-case and authz-person rulesets admit generic service reads, so a read route that does not deny pure
services is open to every service; require_case_open guards every case mutation and a closed case is never reopened
(open → closed | transferred only); the fleet’s effective-dating precedents are subsidy_agreement_terms (half-open windows,
close-only mutation) and ssa_benefit_facts (immutable rows, supersedes_id); the re-cut precedent is disposition_recut.sql
(refuse-on-data, wipe-before-apply, floor bump last).
Decision
D1 — Three capture classes under ONE correction model
Identity facts (sex, date_of_birth + its indicator, year_of_birth_declared) stay on persons, mutated in place under the
audited update: a later write is a correction of an identity, never a dated change. Facts whose value holds over a period are
WINDOW ledgers ([effective_from, effective_until), half-open) keyed by the person, the parent pair, the sibling pair or (person,
case); dated occurrences are EVENT ledgers. Every ledger row carries id (v7), recorded_at / recorded_by, supersedes_id
(one successor per row), retired_at / retired_reason (a closed set: corrected | retracted | order_corrected |
order_deleted) / retired_note. The correction model is the same four acts on every ledger: POST (a new fact — on a window
ledger an open-ended POST is a CHANGE that closes the open row first, a POST carrying effective_until is a BACKFILL),
/{id}/corrections (a superseding row with the complete corrected state; the predecessor is retired FIRST, then the successor
inserted), /{id}/retract (retired without replacement), /{id}/close (window ledgers). Non-overlap is a DATABASE fact: EXCLUDE
USING gist (<identity> WITH =, daterange(effective_from, effective_until, '[)') WITH &&) WHERE (retired_at IS NULL)
(btree_gist); two triggers admit exactly the CLOSE and RETIRE UPDATE shapes on window tables and RETIRE only on event tables,
and refuse every DELETE. Reads consider non-retired rows; at an anchor d a window row is in force when effective_from ⇐ d <
effective_until; an event row by its own date; the current row is the latest by the ledger’s order key with id as the final
key. The predecessor of a correction is read FOR UPDATE and must carry exactly the route + body identity — a row of another case,
child or parent is a 404, nothing written. Every P-C route, read and write, opens with deny_pure_service; NEW / CHANGE / CLOSE on
case routes take require_case_open(tx) after claim_first; corrections and retractions are admitted on a closed case (the
record may always be corrected); person routes take no case-open guard. Every dictionary leaf has its own captured column; the
projection derives nothing across elements — consistency is the §1355.46 validator’s. The element → column map is code
(AFCARS_ELEMENT_COLUMNS in craig-cases-fields, staged by AFCARS_CAPTURE_STAGE), mirrored in data-model-cases.adoc.
Why hard to reverse. The window / event split, the exclusion constraint and the trigger admission shapes are the contract every
reader and every correction in the fleet will assume; changing them later means rewriting history rows. Ledger columns are
scheme-frozen at Plaintext: the triggers admit no other UPDATE shape, so the ADR-049 rewrite-scheme tool’s per-row UPDATE …
SET <base> … would be refused on them; moving a ledger column to Opaque would first need an extra admission (a live
crypto_field_rewrites row for TG_TABLE_NAME under current_user, the scheme_rewrite_fence() owner test) and a
RewriteTarget per column. #2000 (ruled 2026-10-06, ADR-049 § Amendment — #2000) moves none, so
neither exists.
As-built (#1991, U1b; #1992, U2; #1994, U4; #1995, U5; #1996, U6a): the acts and reads are written ONCE per class — store::window_ledger
(U2; U1b’s demographics ledger moved onto it) and store::event_ledger (U4), sharing the lock-live / retire / retract / replay
reads through one LedgerTable supertrait and one claimed-act skeleton (ClaimedAct, retract_with) — and
api::ledgers runs the authority order once: deny_pure_service, the route authority before any claim, the body dates on
the jurisdiction clock, then ONE claimed transaction (claim_first, the route guard, the store act, the event). Each act
on every ledger but permanency_plans publishes an ids-only event — never a fact value; consumers re-read the authz-gated
ledger: case.person_demographics_changed, case.child_facts_changed (one key for the seven other case-keyed ledgers),
case.person_siblings_changed and case.person_parents_changed; a plan act publishes D4’s
case.permanency_plan_established, which carries the plan and current. All five are catalogued in
ADR-003. One carve-out from
"every P-C route opens with deny_pure_service`": D4’s projection is service-ONLY (`require_service_caller()
service_id == "craig-financial", 403 for every other principal before any read). The map: (a)(1)–(a)(4) are header facts
P-D supplies, not captured columns; the (b)(7) race atom is Mapping::Each over eight BOOLEAN columns; (c)(1) / (c)(2)
take a fifth variant, Mapping::Named, pinned to exactly those two keys; AFCARS_CAPTURE_STAGE is U5, so all 57 owned
keys are mandatory. EffectiveRegistries carries no ledger field (no boundary consumes an all-plaintext registry);
DEFAULT_REGISTRY carries every ledger and contacts — eighteen tables. A child is never its own parent
(chk_child_parents_not_self), and the (c)(5) parent set is every linked parent, of any role, whose link began on or before
the anchor.
Lifted (#2015): the D1 cores now live in craig-ledger (store::window, store::event, the store traits, the
claimed-act skeleton) and craig-ledger-contracts (the shared wire), per ADR-079 D1.
Amendment (2026-09-25, P-B1 U1b, #2016 — closes #2009). Every ledger row carries retired_by (CHECK (retired_at IS NULL)
= (retired_by IS NULL)) and every window row closed_at + closed_by (CHECK (closed_at IS NULL) = (closed_by IS NULL);
set together only by a closing UPDATE — the close act or a CHANGE’s implicit close; a row born with effective_until has
neither). The two trigger functions are re-created: CLOSE admits effective_until + closed_at + closed_by, RETIRE admits
retired_at + retired_reason + retired_by (+ retired_note), and each arm requires its actor. Every writer names its
actor — the close, a CHANGE’s implicit close, a correction’s retire of its predecessor, the retraction, and the court-order
sweep’s retirement of review rows (the order act’s actor). LedgerRow serves retired_by / closed_at / closed_by,
EventRow retired_by, each actor beside its instant (… supersedes_id, closed_at, closed_by, retired_at, retired_by,
retired_reason, retired_note; the event row without closed_*); the five ledger event keys carry user_id (the acting
worker), and craig-security resolves the three person-keyed keys' resource ids
(ADR-003).
Amendment (2026-10-01, #2132). The window acts that insert a row or move a window (CHANGE, BACKFILL, CORRECTION, CLOSE) first
take a transaction-scoped advisory lock on the ledger table and the stored identity, then any row lock. The predecessor read
FOR UPDATE cannot order two FIRST opens (no row exists yet): both would insert, wait on each other inside the exclusion check,
and one would die in a deadlock (a 500). Identity before row is the one lock order; a RETRACTION only frees a window and takes no
identity lock. This is ADR-052 D3’s per-identity lock, applied to the window class.
D2 — Demographics as an effective-dated ledger
person_demographic_facts (window ledger keyed person_id) carries the eight race_* responses (all-or-none), the five-value
ethnicity, tribal_member_or_eligible (the child leaf (b)(4)(i)), tribal_member (the parent leaf (c)(3) / (c)(4)) and
tribal_affiliation; persons.race / ethnicity / tribal_affiliation are dropped behind refuse-on-data. A demographics POST
is a complete statement of the five facts. The person GET serves the CURRENT row’s keys to human principals and NO demographic key
to a service principal; the history read denies services outright. gender → sex fleet-wide; dob_estimated_abandoned and
year_of_birth_declared join persons (the declared year refused beside a date; ADR-041 amended: a parent’s or a caregiver’s
YEAR reaches the federal file, never the date — the child’s (b)(1) and the adoptive parents' (h)(3) / (h)(8) dates reach it only through
the DOB-narrowed, audited persons/afcars-export, ADR-041 § Amendment 2026-10-01, #2121).
Why hard to reverse. Every follower (intake, SHINES, the partner mappers, NCANDS, matching, web, CLI, seed, the crosswalk tables) moves to the new wire and the old columns are gone; a reversal is a second fleet-wide migration.
As-built (#1990, U1a; #1991, U1b): the person CREATE refuses race / ethnicity / tribal_affiliation exactly as the
PUT does (the typed 400 demographics-via-ledger) — the ledger is the one write path; PersonResponse omits the
demographic keys for a service principal; NCANDS reads each victim’s demographics row in force at the referral’s receipt,
in one round trip. Outside migration history, the retired unable_to_determine survives only as test literals — the
refusal tests (intake validation, the craig-web demographics BFF, the CLI) and craig-web’s intake-report view, which pins its
unanswered reading — and the craig-reference VARIANTS test doc. The persons side is recorded in ADR-041 § Amendment (2026-09-22) and ADR-051 § Amendments (#1990, the
federal-export route removed).
D3 — ICWA at the 2028 superset; the matching derivation is determination-first
child_icwa_facts (window ledger keyed (person, case)) carries every 2022 and 2028 ICWA leaf as its own column with the
applicability arms as CHECKs; persons.icwa_eligible is dropped behind refuse-on-data over existing true rows. Placement
matching’s icwa_person (ADR-073 § Amendment) reads the case’s current row: court_determination = yes_icwa_applies → true;
no_icwa_does_not_apply → false; otherwise reason_to_know = yes OR icwa_applies = yes; no row → false (25 CFR 23.107(b)(2):
a child with reason to know is treated as an Indian child UNTIL the court determines otherwise). cases.icwa_flag keeps feeding
icwa_case.
The precedence is the federal decision ruleset federal-icwa-status (rulesets/federal/federal-icwa-status.json, cited to 25 CFR
23.107), which craig-cases' placement-facts projection consults through craig-rules under the acting worker (P-C U3, #1993).
Why hard to reverse. The superset is one migration; serving the 2022 shape from it is a projection rule, but a 2022-only capture could never serve the 2028 rows without a second re-cut of a live ledger.
As-built (#1993, U3): placement-facts consults federal-icwa-status under ICWA_STATUS_BUDGET = 2 s inside placement’s
facts-read budget; a closed or retracted ledger reads as no row (every input null); the realm-flat readonly auditor, whose
rule-evaluation rows do not let it create an evaluation, now receives the typed 403 rules-consult-denied from
placement-facts (placement’s cases client re-emits it typed). The gate CHECKs are one-way and NULL-safe (<dependent> IS NULL
OR <gate> IS NOT DISTINCT FROM '<token>', garde present_only_if), and tribe_notified is ungated. ADR-073 § Amendment
(2026-09-23) records the matching side.
D4 — Per-child permanency plans replace the per-case goal
permanency_plans (event ledger keyed (person, case)): each plan established is a new root with its date; the current plan is
the latest by (established_on, recorded_at, id). case_plans.permanency_goal is dropped behind refuse-on-data over existing
case plans (a per-case goal cannot be honestly split into per-child plans). Every act publishes
case.permanency_plan_established with the event identity, the act identity (act_id, act_at) and the authoritative current
state, so a consumer projects without a call. Financial’s guardianship activation reads the cases plan through the ONE service
read (…/permanency-plans/current?as_of=, allowlist of one, PLAN_S2S_BUDGET 4 s under an activation-route assert at 19 s);
PlacementSubsidyEligibility.permanency_goal is removed after the financial drain (U6b), and P-B drops the placement column.
Why hard to reverse. The activation decision and P-B’s column drop both depend on the cases ledger being the one home.
As-built (#1995, U5; #1996, U6a; #1997, U6b): act_at is the clock read after the plan act locks the case row FOR NO KEY
UPDATE (then current, then act_id), so a child’s acts order as they commit; a direct review record or correction takes
the case row FOR KEY SHARE, serializing against a court order’s sweep (a retraction is serialized by the row lock); a
review’s court_order_id is provenance only the court-order act writes — always kept by a correction
(EventFacts::inherit), refused on requests (422), served on every row; deny_pure_service also opens the three
court-order acts and the contact create / update (a contact delete by a pure service is refused by the case ruleset’s
service DENY row); the CLI is craig case permanency-plans / craig case review-events. The projection answers exactly
200 / 204 — no case 404 and no membership 400 (a non-member child holds no row) — and its as_of is required and
not capped at today; financial’s CasesClient::current_permanency_plan reads 204 as none and every other status but
200, 404 included, as an error, so activation fails closed with a 503 naming the leg. U6b removed
PlacementSubsidyEligibility.permanency_goal from the contract and its producer, and a financial test pins that an older
placement’s leftover key still decodes during the drain; the rollout order, the drain and the rollback are the
deployment guide's § AFCARS cases capture rollout (#1964).
Consequences
-
Pre-1.0
Changed/Removedper unit: thesexrename, the demographics wire and the person PUT,icwa_eligible,case_plans.permanency_goal,persons/federal-export,PlacementSubsidyEligibility.permanency_goal, the court-orderhearingrequirement. Three units refuse on existing data (pre-1.0; the devstack wipes + reseeds once per such unit). -
Every new column is
Plaintext(the cases posture: identifiers only). The parenting and ICWA facts stayPlaintextby decision: ADR-049 § Amendment — #2000 (ruled 2026-10-06) settles the R-C10 deferral. -
No P-C table or column lands on an ADR-037 governed surface; the caregiver portal shows none of the new facts (P-B needed no projection: ADR-079 retired the portal goal token with the placement column, P-B1 U7 #2024). Verified at the close-out:
GOVERNED_FIELDS(crates/craig-placement-contracts/src/field_ownership.rs) held the same seven tokens, none a P-C table or column (six since #2024), and craig-cases carries no field-ownership code. -
The ledger events carry no actor key and the retract / close acts write no actor column, so the actor of a retraction or a close is recorded only for the claim-retention window (
request_claims.created_by_sub) — #2009 — closed by #2016 (§ D1 Amendment). -
The close-out grep for
gender(crates/craig-cases-*/src,services/craig-cases/src) is EMPTY at U7; the list below is the fleet residue outside its scope. It exempts partner wire fields named by their specs (recorded at U1a, #1990). The SOURCE read (the CRAIG person’ssex) renames; the emitted partner key does not:-
CAPS —
craig-partner-capstypes.rsgender(CAPS-1.1.29CSEX) and its mock; -
CPRS —
craig-partner-cprsCprsGenderand thegenderfield (types.rs,lib.rs, the mock), and craig-exchangetriggers/legs.rs’s partner-side `CprsGenderimport, the request’sgender:field anddecoded.gender; -
IES —
craig-partner-iestypes.rsgenderand its mock; -
WIC —
craig-partner-wictypes.rsgenderand its mock; -
the partner crates' round-trip / property tests over those fields, and their
xtask/axis-coverage-opt-out.txtrow; -
doc-only mentions in
craig-partner-empi,-smileand-tcmtypes.rs(their fields are alreadysex_cd/client_sex_cd/cd_person_sex); -
the retired key’s refusal tests and the #1990 rename-provenance comments — the CLI’s refused
--gender, intake validation, the typed-contract tests, craig-exchange’s person mapping,rules_afcars’ registry pin — which name `genderto prove it is gone; -
outside code: the partner specs under
interfaces/, archived plans,CHANGELOG.adochistory, the staticmock/screens/mockups and the Keycloak realm’s OIDCgenderuser-attribute mapper (unrelated to the person record).
-
-
The dictionary’s (c)(5)(i)–(ii) deceased-parent arms are corrected as the P-A2 follow-up #1999 before P-D reads the rows.
Open questions
-
⁂ #1073: the parents' "first" / "second" ordering (a convention here);
emancipation → unmappedon (f)(1); whether a deceased parent with no termination should reportdeceasedunder (c)(5)(i) (the "leave blank" instruction is followed). -
The authorized mechanism for correcting facts of a TRANSFERRED case beyond the record corrections admitted here — none is needed for AFCARS; recorded for the case-lifecycle owner.
Alternatives considered
-
History rows for every fact including identity facts — rejected: sex and date of birth are corrected, not dated.
-
Synthesizing ledger rows from
persons.race,icwa_eligibleandcase_plans.permanency_goalby migration — rejected: each is a policy guess (the seven unselected race categories; which ICWA fact the flag meant; which children a case goal covered); refuse-on-data is the fleet’s re-cut precedent and no production data exists. -
A single
abandonedfact fanned into six elements — rejected: the CFR asks each element separately; the validator owns consistency. -
Keeping
PermanencyGoalper case beside the per-child ledger — rejected: two homes for one fact. -
A financial derivation for (b)(17) — rejected: four of the eight sources are outside financial’s ledger; capture-first.
Amendment (2026-10-05, #2131) — the class-3 columns read as of as_of (Accepted, 2026-10-05)
Standing. Proposed 2026-10-05 with the approved plan AFCARS Source History (#2131) (of #949, epic &99; approved in plan mode 2026-10-05 after a contextless round 1 (no-ship, 2 blockers fixed) and the maintainer’s round 2 (no-ship, 5 findings folded); rulings R-H1–R-H9 as recommended). Accepted 2026-10-05 at that plan’s close-out. The plan landed in six MRs — U0 !1814 (the plan page and these amendments), U1 !1815 (#2186), U2 !1816 (#2187), U3 !1817 (#2188), U4 !1818 (#2189) and the close-out (U5, #2190). The text below records the merged tree. Per R-H6 it records the cases side; ADR-079 § Amendment (2026-10-05, #2131) the facts, health and end stamps.
What changes. P-D1 (#1965) D3 left the cases route’s class 3 reading current, so a walk could mix time across pages. The plan’s cases-side decisions give each such column an outcome:
-
D1 —
cases.admin_unitis reclassified (R-H1). The case create is its one writer and no UPDATE sets it, so the current value is the value atas_of; it leaves the class-3 sentence with no code. -
D2 —
case_householdis fenced onadded_at(R-H7). Its one writer is an INSERT withadded_at DEFAULT now().child_membershipstakes the page’sas_ofand addsh.added_at ⇐ as_of, so the membership read is class 2: a membership added afteras_ofgives that key’snot_foundrow. No schema; the seed rendersadded_atas its case’sopened_at. -
D5 —
contact_revisions(R-H2, R-H3). A narrow, plaintext, insert-only table of the prior visit trio:id(v7),contact_id(ON DELETE RESTRICT), the supersededversion(UNIQUE (contact_id, version)),occurred_at(NOT NULL),visited_child_id(REFERENCES persons(id) ON DELETE RESTRICT, as oncontacts),location, andsuperseded_at TIMESTAMPTZ NOT NULL(no default), indexed on(contact_id, superseded_at, id).refuse_revision_mutation()refuses every UPDATE, DELETE and TRUNCATE for every role, so the table is SCHEME-FROZEN and no column joinsresolve::ALLOWLIST.update_contact’s UPDATE moves into a CTE whose `RETURNINGadds the prior trio through Postgres 18’sold; a second CTE inserts the revision only when the trio changed, stampedclock_timestamp()after the row lock (nevernow()), so a later edit always sorts after the one it waited on. A CAS miss and a narrative-only edit write none; no trigger writes data.VISITS_SQLresolves each contact of the key’s case through its earliest revision superseded afteras_of(LEFT JOIN LATERAL … ORDER BY superseded_at, id LIMIT 1; a revision’s NULL is an answer, neverCOALESCE`d), then filters on the as-of `visited_child_idandoccurred_at < to, so a re-pointed visit answers under its as-of child. No backfill: the history starts with this release. Since #2231 (ruled 2026-10-08): acontact_revisionsrow also carriessuperseded_by UUID NOT NULL, the acting worker (parse_actor_sub(claims.acting_worker());deny_pure_servicerefuses a pure service first) whose contact PUT superseded its trio, bound into the same revision INSERT. Migration20261008140000_contact_revision_actor.sqlrefuses on any existing revision (nothing recorded names its worker: the contact PUT stages no event) and bumps the floor, required (an N−1 contact edit omits the column). -
D6 —
personsstays current-state (R-H4). D1 of this ADR, identity facts corrected in place, is reaffirmed: a person PUT ofsex, the encrypted date of birth and its indicator,year_of_birth_declaredor a parent’sbirth_yearis a correction, never a dated change, so no prior value is kept (a history would carry DOB ciphertext into the crypto registry and key rotation). A correction reaches every later read: a replay never differs and a fresh generate carries it, but one landing mid-walk answers on the pages read after it, sopersonsis the one cases table where reads at oneas_ofcan disagree. The reading is logged ⁂ on #1073. After U4 it is the cases route’s whole class 3.
Consequences. Pre-1.0 Changed (the answers move) and Added (contact_revisions, with its deploy note), both in U4,
whose migration bumps the floor last, voluntarily under ADR-063 D3 (an N−1 edit leaves no revision; R-H9). The new columns
are Plaintext; nothing is governed.
Amendment — #2999 (2026-11-08): the configuration layers left CRAIG’s source
ADR-087 U4 (#2955) moved the configuration layers out of CRAIG’s source. A rulesets/<j>/<file> path above now names
<file> in layer <j>: the federal, Georgia and Texas layers are the craig-config-{federal,georgia,texas}
repositories, pinned in config-sources.lock and fetched to target/config/layers/<j>/ by cargo xtask config
fetch, and the synthetic testonia layer is fixtures/config/testonia/. The decision above is unchanged.