Data Model: Placement
Overview
The placement service manages foster homes, removal episodes and the living arrangements (placements) inside
them, and kinship evaluations.
Foster home occupancy is derived automatically by a database trigger (#761): a home’s current_occupancy
always equals the count of its placements in active status, recomputed on every placement insert/delete and
on any update that changes foster_home_id or status (#1161 — an update changing neither is a provable
no-op for the count, so the WHEN guard skips the recompute and its home-row lock instead of serializing
unrelated placement writes behind open same-home transactions).
It therefore stays correct across all transitions — create, planned → active, end, and (#2018) cancel — and
cannot drift. A cancel moves planned → cancelled: the WHEN guard still fires on the status change, but a
planned row never occupied a bed, so the recount leaves the count unchanged. #2020: a retract of an
active row decrements the home (it leaves active), a retract of an ended row recounts unchanged, and a
historical record inserts an ended row, so the INSERT recount leaves the count unchanged and even a full
home admits it.
The trigger locks the home row (PERFORM … FOR UPDATE) in its own statement before the recount (#1117):
under READ COMMITTED, a recompute UPDATE that instead blocked on the home row directly would resume via
EvalPlanQual with its original statement snapshot — writing a COUNT that predates the very commit it waited
for (the #1056 stale-clobber forensics: a third transaction re-wrote occupancy 2 after two endings had
committed). Lock-first forces the wait before the counting statement begins, so the recount’s snapshot
always postdates the peer’s commit. Any future COUNT-maintaining trigger must follow this lock-first shape
(deterministic pin: tests/constraints/occupancy_recompute_race.rs).
Activation (create-active or planned → active) is capacity-guarded under a SELECT … FOR UPDATE lock.
Since #2018 both activation paths stamp activated_at = now() write-once (the transaction’s instant), and
both refuse a start outside [removal_at, now()] of the placement’s removal episode with the 400
activation-start-out-of-range (see Removal episodes, exits and living arrangements (P-B1, #2018–#2024, ADR-079 D2–D4)).
As a DB-level backstop (#861), CHECK (current_occupancy >= 0 AND current_occupancy ⇐ max_capacity) and
CHECK (max_capacity >= 0) reject any write — from any present or future writer — that would drive occupancy
negative or past licensed capacity.
Cross-service references to cases.cases(id) and cases.persons(id) are stored as plain UUIDs — no foreign key constraints across databases.
Sensitive facts (#2000). craig-placement keeps no field registry and encrypts no column. Its sensitive
non-identifier facts — health (child_health_facts, health_records, health_record_revisions), the (d)(4) removal
circumstances (removal_responses.circumstance_*), trafficking (the two ledgers) and ICWA (the group
(i) columns of placements, placement_fact_revisions, removal_responses and exit_responses) — are Plaintext by
decision, not deferral: ADR-049 § Amendment —
#2000 (ruled 2026-10-06). The guarded tables among them stay scheme-frozen.
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 |
|---|---|
|
Licensed foster care providers — a family home or, since #2055, a congregate facility
( |
|
Training records for foster parents (pre-service, CPR, trauma-informed, etc.); the three staff writes re-check the home’s unit under the home’s lock (#2075, Training writes and home-target decisions (#2075)) |
|
#1641: the once-per-key expiry notice ledger — |
|
#2018 (ADR-079 D3): a child’s living arrangement inside one removal episode — |
|
Relative/kinship placements evaluated during the matching process. #1901: carries the same
|
|
#2018 (ADR-079 D2): one removal of a child under a case — the current |
|
#2018 (ADR-079 D2): the removal event ledger (FIRST_RECORDED) — the removal instant and its
|
|
#2019 (ADR-079 D4): the exit event ledger (FIRST_RECORDED), the one home of AFCARS (g)(1)–(g)(4) — the
exit instant, its |
|
#2082: the (d)(5)–(d)(6)(i) event ledger — a statement dated |
|
#2082: the (d)(6)(ii) event ledger — one row per report to law enforcement, dated |
|
#2023 (ADR-079 D4): the audit of the one sanctioned touch of an ended row’s end reason — one row per
arrangement the U6c migration rewrote to |
|
#2188 (plan |
|
Educational enrollment and IEP/Section 504 tracking per child (Phase 4 expansion); #1909 (b): the custody-unit stamp
|
|
#3188: what a partner (an education agency) reported about a child’s schooling. One live row per child and partner interface; written only by the service-only partner-report route and read only through its own view-only read. See Partner-reported education records (#3188). |
|
#3188: the craig-exchange listings announced as ended ( |
|
Health visits, immunizations, diagnoses, and overdue-appointment tracking per child (Phase 4 expansion); since
#2084 the (b)(9) visit flag |
|
#2188: the prior visit — one row per health-record PUT that changed |
|
#2084: the (b)(10) per-child WINDOW ledger — |
|
#2084: the (b)(11), (b)(12), (b)(14) per-child WINDOW ledger — |
|
Uploaded documents (licenses, home-study reports, background checks) per foster home, stored in object storage via
|
|
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 |
|
#1213: the event-projected authoritative case assignment
( |
case_id))`
( |
|
|
#1848 (ADR-076 D5–D7): the caregiver binding ledger — a CAREGIVING UNIT (exactly one of
|
|
#2058 (P-B2 U5): the case-less setting identity of a home-less family arrangement — |
|
#1848: hashed one-time enrollment codes issued on a binding — |
|
#1848: the Keycloak subject ↔ person enrolment a redemption creates — ONE live identity per
|
|
#634 (ADR-037 §6, ADR-076 D10): the propose-approve queue of the |
Recorder attribution (#2033, ADR-028). Every row a staff act creates names the ACTING worker:
placements.created_by / created_by_name (the live create and the historical record),
education_records.recorded_by / recorded_by_name, health_records.recorded_by / recorded_by_name and
kinship_options.recorded_by. The values are the sub and preferred_username of claims.acting_worker(); under a
BFF-lifted token that is the worker, never the service principal. The actor token carries no full name, so a
*_name is the username, as on a direct token. Rows written before #2033 keep theirs.
Providers (P-B2 U2, #2055). Migration 20260927100000_foster_home_provider_kind WIDENS the schema — it adds
foster_homes.provider_kind (family_home | congregate_facility, NOT NULL, no default, every existing row family_home,
immutable by trigger trg_foster_homes_provider_kind_immutable) and makes license_type NULL iff congregate_facility
(chk_foster_homes_license_type_iff_family) — and ends with a voluntary floor bump. A congregate provider takes no
caregiver binding and records no training (both 422); the portal reaches a provider only through a binding, so it is
closed to a congregate provider too. The update refuses a kind change and a license_type on a congregate provider (400
structural-mismatch). Matching filters by the required provider_kind. The with-home consult, occupancy, the capacity
guard and per-diem billing are unchanged.
Setting vocabulary and identity (P-B2 U3, #2056). Migration 20260927120000_placement_setting_vocabulary re-cuts
placements.placement_type (chk_placements_placement_type) to foster_family_home plus the 14 federal (e)(4) tokens
verbatim, with no crosswalk; it refuses any existing placements row (dev: cargo xtask dev reseed) and bumps the floor.
craig-reference PlacementType::setting_class() sorts every setting into one of three classes (SettingClass):
-
family —
foster_family_home; names afamily_homeprovider or, with none, a kinship household (Kinship households (P-B2 U5, #2058)); -
congregate — the three
group_home_*tokens,residential_treatment_center,qualified_residential_treatment_program,child_care_institution,child_care_institution_shelter_care,supervised_independent_living; names acongregate_facilityprovider; -
non-caregiving (D3) —
runaway,whereabouts_unknown,placed_at_home,juvenile_justice_facility,medical_or_rehabilitative_facility,psychiatric_hospital; names no provider.PlacementType::is_caregiving()isfalsefor exactly these six.
A family row carries the six (e)(3) flags ffh_type_licensed_home, ffh_type_therapeutic_foster_family_home,
ffh_type_shelter_care_foster_family_home, ffh_type_relative_foster_family_home, ffh_type_pre_adoptive_home,
ffh_type_kin_foster_family_home (applies | does_not_apply; NOT NULL iff family, chk_placements_ffh_types_iff_family);
the wire carries them as ffh_types, the list of categories that apply. foster_family_home ((e)(2), yes | no) is
GENERATED from placement_type. chk_placements_setting_identity (re-cut by #2058) requires exactly one of
foster_home_id / kinship_household_id on a family row, a foster_home_id and no household on a congregate row, and
neither on a non-caregiving row; the BEFORE trigger ck_placements_setting_provider_kind requires a named home’s provider_kind to
be the class’s (SQLSTATE 23514 with the constraint name). The create and historical acts refuse before the database does,
in this order (all 400):
-
a family setting without
ffh_types—required-field-missing(an empty list when no category applies); -
ffh_typeson a congregate or non-caregiving setting —structural-mismatch; -
a category named twice in
ffh_types—structural-mismatch; -
a congregate setting without a
foster_home_id—required-field-missing; -
a non-caregiving setting naming a
foster_home_id—structural-mismatch.
A named home of the wrong provider kind is 400 setting-provider-mismatch, checked on the home row the act holds FOR
UPDATE; the arrangement-write mapping answers a constraint or trigger hit (23514) as 400 — the provider-kind trigger
as setting-provider-mismatch, the setting-identity and ffh_types checks as structural-mismatch (belts the
pre-checks above reach first). Since #2058 a caregiver binding keys a foster home or a kinship household, never a
placement (Kinship households (P-B2 U5, #2058)).
Non-caregiving activation (P-B2 U4, #2057). A non-caregiving arrangement (plan D3, R-B25) — a run (runaway),
whereabouts unknown, a trial home visit (placed_at_home), or a juvenile-justice, medical or psychiatric stay — is an
ordinary row. It names no setting identity, sits under the episode’s containment and the child’s non-overlap like any
row (a child on the run when responsibility arrives is a runaway row with started_at = removal_at), and ends by an
ordinary end_reason. Its activation, on the birth-active create and on planned → active alike, runs neither the
craig-cases placement-facts read nor a craig-rules consult: the #1724 provenance pair stays NULL, and a rules or cases
outage never blocks recording it. The child’s membership was proven when the episode opened, so for these six settings
the activation no longer re-checks cases' case read, the child’s membership, the DOB or ICWA (accepted, R-B25),
nor the case’s lifecycle state (#2029: a closed case does not refuse it).
craig-financial bills nothing for it and stages no financial.payment_generation_skipped; a caregiving home-less
activation still stages missing_foster_home. Respite is not a row (R-B16), nor is a short stay while the base
arrangement is held open (#1073).
Kinship households (P-B2 U5, #2058)
A kinship household is the case-less setting identity of a home-less family arrangement (plan
afcars-placement-facts D4): every foster_family_home row with no foster_home_id names one in
placements.kinship_household_id. The household belongs to no case, so siblings of two cases placed with the same
relatives share one household, and its caregivers are bound to it once.
The table. kinship_households: id (UUID PK), admin_unit (TEXT NOT NULL, fixed at mint), created_by (UUID, the
minting actor), created_at. The BEFORE trigger trg_kinship_households_immutable refuses every UPDATE and DELETE: a
household has no lifecycle, and placements and bindings reference it ON DELETE RESTRICT. Migration
20260928120000_kinship_households.sql mints one household per existing home-less family row of any status (its id,
admin_unit, created_by and created_at are the row’s) and refuses, before any change, a binding keying anything but
such a row, such a row with a NULL admin_unit or a non-UUID created_by, and two overlapping bindings of one person on
one unit.
The choice. The create (POST /v1/placement/placements) and the historical record both take an optional
kinship_household: {"existing": <id>} reuses a household, {"new": {"admin_unit"?}} mints one, and an absent choice
reuses the replaced row’s household on a re-record (replaces_placement_id) and mints one otherwise. The minted unit is
the episode’s admin_unit stamp; while the stamp is NULL it is the body’s new.admin_unit, run through the foster-home
canonical-name belt. The refusals:
-
400
structural-mismatchonkinship_household— a choice on any row but a home-lessfoster_family_homeone; -
400
structural-mismatchonkinship_household.new.admin_unit— a body unit when the episode is stamped; -
400
required-field-missingonkinship_household.new.admin_unit— no stamp and no body unit (a household without a unit is unrepresentable, so an absent choice on an unstamped episode is refused too, unless it re-records a household row, whose household it reuses); -
409
invalid-kinship-household—existingnames no household (the FK hit in the transaction answers the same); -
403 —
existingnames a household the actor cannot read.
The unit source is a RISK: a household minted after a case transfer carries the episode’s unit, a migrated household its row’s.
Authority. A household is a home. Its reads authorize foster_home refs (admin_unit, no assignment pair); a
binding act on it authorizes a foster_home_caregiver ref of the same home shape. No caregiving-unit ref carries a
case’s assignment pair, so a Texas supervisor holds no binding authority on any caregiving unit; a Texas regional
director holds it only on the units in her bound counties, through the unit CHECK on the ref’s admin_unit (#1928,
ADR-077 D7).
The routes. GET /v1/placement/kinship-households/{id} (200, 403, 404) and
GET /v1/placement/kinship-households?person_id= — the households whose bindings name the person, paged, under the
foster-home list scope; person_id is required (400 required-field-missing: no unfiltered enumeration). Both refuse a
pure service principal (403).
Bindings. caregiver_bindings.kinship_household_id replaces placement_id (caregiver_bindings_unit_xor, the
open-person unique caregiver_bindings_household_person_open). The EXCLUDE excl_caregiver_bindings_person_unit_window
keeps one person’s bindings on one unit from overlapping (409 caregiver-binding-overlap; a second OPEN binding still
answers 409 duplicate-resource from the unique). A cancel (ended_on = effective_from) is an empty range and overlaps
nothing. A binding keys the household, not an arrangement, so a cancelled, retracted or ended arrangement leaves its
household’s bindings as they are, and no open binding blocks a retract.
Arrangement facts (P-B3 U1, #2080)
The arrangement’s own AFCARS facts, (e)(5)–(e)(8) and (i)(5)–(i)(8) (plan afcars-placement-elements D1), are sixteen
nullable TEXT columns on placements (migration 20260929100000_arrangement_facts.sql); NULL = unanswered, and every
column is Plaintext. Each token set is a CHECK (<col> IN (…)); each gate on a nullable column is IS NOT DISTINCT FROM
(a bare = passes on a NULL gate). Four columns of each of (i)(5) / (i)(8) carry their plan D5 slug, since the
<prefix>_<category> name exceeds 63 bytes.
| Column | Element | Tokens (CHECK) | Gate (CHECK) |
|---|---|---|---|
|
(e)(5) |
|
|
|
(e)(6) |
free text, 1–255 characters, trimmed ( |
|
|
(e)(7) |
|
|
|
(e)(8) |
|
|
|
(i)(5) |
|
none (ungated by setting until #1073) |
|
(i)(6) |
the five (i)(5) categories plus |
none (ungated by setting until #1073) |
|
(i)(7) |
|
|
|
(i)(8) |
|
|
Required keys. The create (POST /v1/placement/placements), the historical record and the read carry the sixteen keys
flat (craig_placement_contracts::arrangements::ArrangementFacts, #[serde(flatten)]; the key list is
ARRANGEMENT_FACT_KEYS). On a write every key must be present and null = unanswered (craig_validation::required_nullable):
a body missing a key is refused 422 validation-failed at the extractor (missing field ), before any claim
is read. A bad token is serde’s 422 too, so the token CHECKs stay unmapped.<key>
The PUT. PUT /v1/placement/placements/{id} takes an optional arrangement_facts: absent or null = unchanged;
present = the complete state of all sixteen keys, which replaces every column. It edits a planned, active or
ended row only (else 400 invalid-state-transition on arrangement_facts), and a row of a retracted episode is 409
episode-retracted, as a status change is. Nothing here is governed: the edit stages no event and no field audit. It is
attributed on the revision it records (superseded_by, below; #2000); an identical PUT changes no fact and records none.
Prior values (#2188, plan afcars-source-history D5). When a facts PUT changes any of the sixteen columns, the same
statement (update_arrangement_facts, a CTE over Postgres 18’s RETURNING old) inserts the sixteen it replaced into
placement_fact_revisions, stamped superseded_at = clock_timestamp() after the row lock, so a later edit always sorts
after the one it waited on. An identical PUT lands and records nothing; no trigger writes a revision. The table
(migration 20261005130000_placement_revisions.sql) is id UUID PRIMARY KEY DEFAULT uuidv7(), placement_id
(REFERENCES placements ON DELETE RESTRICT), the sixteen facts as nullable TEXT with no copied CHECK, and
superseded_at TIMESTAMPTZ NOT NULL, superseded_by UUID NOT NULL (#2000: the acting worker — claims.acting_worker(),
so under craig-web the relayed worker — whose facts PUT superseded the values, bound into the same INSERT; no FK, the
recorded_by posture), indexed on (placement_id, superseded_at, id). refuse_revision_mutation()
(trg_placement_fact_revisions_insert_only, trg_placement_fact_revisions_no_truncate) refuses UPDATE, DELETE and
TRUNCATE for every role (integrity_constraint_violation), so the table is SCHEME-FROZEN; every column is Plaintext.
No backfill: an edit made before the migration kept no prior value. The migration bumped schema_compat_floor.
Migration 20261008120000_placement_fact_revision_actor.sql (#2000; -- devstack: wipe-before-apply) added
superseded_by: it refuses to apply while any revision exists (nothing recorded names the worker behind one), adds
the column NOT NULL with no default, and bumps schema_compat_floor to 20261008120000 LAST (required: an N−1 facts
edit omits the column). Rollback is N−1 images AND a database restore.
Refusal order. The create, the historical record and the PUT (against the row’s immutable placement_type) share one
pure check, refuse_arrangement_facts, which trims arrangement_jurisdiction in place and then refuses, in this order
(all 400 structural-mismatch, naming the field):
-
a blank
arrangement_jurisdictionafter the trim (sendnullwhen unanswered); -
an
arrangement_jurisdictionover 255 characters after the trim; -
an
arrangement_locationthat disagrees with the setting —runaway_or_whereabouts_unknownexactly on arunawayorwhereabouts_unknownsetting (fieldarrangement_location); -
an
arrangement_jurisdictionwithout anout_of_state_or_out_of_tribal_service_areaorout_of_countryarrangement_location; -
a
foster_parents_marital_statusorrelationship_to_foster_parentsoff afoster_family_homesetting (field: that column); -
an
icwa_good_causeunlessicwa_preference_metisplacement_does_not_meet_icwa_placement_preferences; -
any
icwa_good_cause_basis_<category>answer unlessicwa_good_causeisyes(fieldicwa_good_cause).
The arrangement-write mapping answers a gate hit (23514) the same way, with the same detail and field (the text CHECK as rule 2); these are belts the pre-check reaches first.
The (i) block by setting. (i)(5)–(i)(8) are admitted on a row of any setting: no gate ties them to the setting class until #1073 rules which settings an ICWA placement preference applies to. Only their sibling gates (rules 6 and 7) hold.
Removal facts (P-B3 U2, #2081)
The removal’s own AFCARS facts, (d)(3), (d)(4), (i)(1) and (i)(4) (plan afcars-placement-elements D2), are forty-three
nullable TEXT columns on removal_responses (migration 20260929110000_removal_facts.sql); NULL = unanswered, and
every column is Plaintext. Each token set is a CHECK (<col> IN (…)) named chk_removal_responses_<col>, except nine
(d)(4) CHECKs named chk_removal_responses_circumstance_<short tail> (the full name would exceed 63 bytes); each gate on
a nullable column is IS NOT DISTINCT FROM (a bare = passes on a NULL gate). Two (d)(4) columns
(circumstance_caretakers_impairment_physical_emotional, circumstance_family_conflict_orientation_gender_identity)
and all three (i)(1)(iii) columns carry their plan D5 slug, since the <prefix>_<category> name exceeds 63 bytes.
| Column | Element | Tokens (CHECK) | Gate (CHECK) |
|---|---|---|---|
|
(d)(3) |
|
none |
|
(d)(4) |
|
none |
|
(i)(1)(i) |
|
none |
|
(i)(1)(ii) |
|
|
|
(i)(1)(iii) |
|
|
|
(i)(4) |
|
none |
Required keys. The episode open (POST /v1/placement/episodes), the historical episode, the removal correction and
EpisodeRow.removal carry the forty-three keys flat (craig_placement_contracts::episodes::RemovalFacts; the key list
is REMOVAL_ANSWER_KEYS, and RemovalFacts::unanswered builds a removal with every answer null). On a write every
key must be present and null = unanswered (craig_validation::required_nullable): a body missing a key is refused
422 validation-failed at the extractor (missing field ), before any claim is read.<key>
Refusals. The three writes share one pure check, refuse_removal_facts, which refuses (both 400
structural-mismatch, field icwa_transfer_denied) an icwa_transfer_denied answer without an
icwa_transfer_requested of yes first, then any icwa_denial_<reason> answer without an icwa_transfer_denied of
yes. The removal-response write mapping answers a gate hit (23514) the same way; it is a belt the pre-check reaches
first. A bad token is serde’s 422, so the token CHECKs stay unmapped.
The correction is the complete state. A removal correction restates every answer: one it sends as null is cleared
on the successor row. The successor keeps the removal’s (d)(2) first_recorded_at.
Not gated. Whether (i)(1)(i) and (i)(4) apply at all turns on the (b)(6)(i) ICWA applicability, a craig-cases fact placement cannot read; that applicability is P-D’s.
Trafficking (P-B3 U3, #2082)
The episode’s AFCARS trafficking facts, (d)(5)–(d)(6)(ii) (plan afcars-placement-elements D2), live on two event
ledgers from migration 20260930100000_trafficking_ledgers.sql, each keyed by episode_id (FK to removal_episodes,
ON DELETE RESTRICT): episode_trafficking_statements (a statement dated stated_on holding five nullable answers,
NULL = unanswered) and trafficking_law_enforcement_reports (one row per report of the in-care victimization to law
enforcement, dated reported_on). Each carries the lifted core’s row columns (recorded_at, recorded_by,
supersedes_id, retired_at, retired_reason ∈ corrected | retracted, retired_note, retired_by): a correction
supersedes and retires its predecessor, at most once. An episode holds many roots on each ledger (no one-live index).
Both are insert-only except a RETIRE naming its retirer (refuse_event_row_mutation()), and both carry the
ck_episode_current_instants constraint trigger. Each gate on a nullable column is IS NOT DISTINCT FROM.
| Column | Element | Tokens | Gate (CHECK) |
|---|---|---|---|
|
(d)(5) |
|
none |
|
(d)(5)(i) |
|
|
|
(d)(5)(ii) |
a date |
|
|
(d)(6) |
|
none |
|
(d)(6)(i) |
|
|
|
(d)(6)(ii) |
a date, one row per report |
none (P-D applies the (d)(6)(i) gate) |
Required keys. Every statement body (the record and the correction,
craig_placement_contracts::trafficking::TraffickingStatementRequest, deny_unknown_fields) carries stated_on and
every answer key (TRAFFICKING_ANSWER_KEYS); null = unanswered. A body missing an answer key is refused 422
validation-failed at the extractor, before any claim is read. A report body (TraffickingReportRequest) carries
reported_on. An all-null statement is admissible: nothing was known yet on stated_on.
Refusals. Every record and correction runs the pure checks (api/trafficking/rules.rs) before its claim: 400
ledger-date-after-today (a stated_on or reported_on after the jurisdiction’s today); 400
ledger-fact-date-after-event (a prior_reported_on after its stated_on); then 400 structural-mismatch naming the
leaf answered without its parent’s yes (prior_reported, prior_reported_on or in_care_reported). The statement
write mapping answers a gate or bound hit (23514) the same way; it is a belt the pre-check reaches first. A bad token is
serde’s 422. Every act on a retracted episode is 409 episode-retracted; a correction or retract naming a row that is
not a live row of the episode’s ledger is 404 ledger-row-not-found.
A statement is the complete state known on its stated_on. A changed answer is a new statement; a correction restates
every answer, and one it sends as null is cleared on the successor row.
Reads. GET /v1/placement/episodes/{id}/trafficking answers every live statement, latest-dated first; with
?as_of= it answers the statement in force on that date (the live statement with the latest stated_on ≤ as_of, at
most one; store::event::at_anchor). GET /v1/placement/episodes/{id}/trafficking-reports answers every live report,
latest-dated first; with ?as_of= every live report dated ≤ as_of, newest first (store::event::live_through,
EventThroughQuery).
No cross-ledger gate. A report may stand while the statement in force answers (d)(6)(i) no: a report is a fact, and
P-D’s applicability, not an act rule, applies the (d)(6)(i) gate to (d)(6)(ii) at export.
The episode retract retires the live rows of both ledgers as retracted, with the retract’s note, in its one
transaction, and still publishes ONE removal_episodes / retracted event.
The anchor (⁂ #1073). For a reporting period P-D reads the latest live statement with stated_on ≤ the period’s
to, and every live report dated ≤ it.
Sensitivity. Plaintext by decision ([sensitive-facts]; ADR-049 § Amendment — #2000); the trafficking
answers are PII (plan A6).
The adoption / guardianship exit (P-B3 U4, #2083)
The adoption / guardianship exit’s own AFCARS facts, (h) less (h)(14) and (i)(10)–(i)(13) (plan
afcars-placement-elements D3), are twenty-one nullable columns on exit_responses (migration
20260930120000_adoption_exit_facts.sql); NULL = unanswered, and every column is Plaintext. Each token set is a
CHECK (<col> IN (…)) named chk_exit_responses_<col>, except seven CHECKs named with a short tail (the full name would
exceed 63 bytes): chk_exit_responses_adoptive_available_other_indian_families,
chk_exit_responses_adoptive_available_tribe_order, chk_exit_responses_adoptive_basis_parents_request,
chk_exit_responses_adoptive_basis_child_request, chk_exit_responses_adoptive_basis_no_suitable_placement,
chk_exit_responses_adoptive_basis_extraordinary_needs and chk_exit_responses_adoptive_basis_sibling_attachment. Each
gate on a nullable column is IS NOT DISTINCT FROM (a bare = passes on a NULL gate). Three (i)(10) columns
(adoptive_icwa_available_extended_family, adoptive_icwa_available_tribe_members,
adoptive_icwa_available_tribe_order_of_preference) and four (i)(13) columns (adoptive_icwa_good_cause_basis_parents_request,
adoptive_icwa_good_cause_basis_no_suitable_placement, adoptive_icwa_good_cause_basis_extraordinary_needs,
adoptive_icwa_good_cause_basis_sibling_attachment) carry their plan D5 slug, since the <prefix>_<category> name
exceeds 63 bytes.
| Column | Element | Tokens (CHECK) | Gate (CHECK) |
|---|---|---|---|
|
(h)(1) |
|
|
|
(h)(2) |
|
the (h) family CHECK |
|
(h)(3)–(h)(7) |
a craig-cases person id ( |
the (h) family CHECK |
|
(h)(8)–(h)(12) |
a craig-cases person id ( |
the (h) family CHECK; |
|
(h)(13) |
|
the (h) family CHECK |
|
(h)(15) |
|
the (h) family CHECK; |
|
(h)(15) |
|
the (h) family CHECK; never beside |
|
(i)(10) |
|
|
|
(i)(11) |
|
the (i) family CHECK |
|
(i)(12) |
|
the (i) family CHECK; |
|
(i)(13) |
|
the (i) family CHECK; |
Required keys. The exit (POST /v1/placement/episodes/{id}/exit), the exit correction, the historical episode’s exit
and EpisodeRow.exit carry the twenty-one keys flat beside exit_at / exit_reason / transfer_agency_type
(craig_placement_contracts::episodes::ExitFacts; the key list is EXIT_ANSWER_KEYS, and ExitFacts::unanswered builds
an exit with every answer null). On a write every key must be present and null = unanswered
(craig_validation::required_nullable): a body missing a key is refused 422 validation-failed at the extractor
(missing field ), before any claim is read. <key> transfer_agency_type stays optional.
Refusals. The three writes share one pure check, refuse_exit_facts (api/exit_facts.rs), which refuses, each 400
structural-mismatch and in this order: an (h) answer on an exit that is neither an adoption nor a guardianship
(field exit_reason); an (i) answer on an exit that is not an adoption (field exit_reason); a siblings_in_home
count beside siblings_not_applicable (field siblings_not_applicable); an adoptive_icwa_good_cause unless
adoptive_icwa_preference_met is placement_does_not_meet_icwa_placement_preferences (field
adoptive_icwa_good_cause); an adoptive_icwa_good_cause_basis_<category> answer unless adoptive_icwa_good_cause is
yes (field adoptive_icwa_good_cause, the family gate’s). A (h)(15) count outside 0–999 and a false
siblings_not_applicable are 422 validation-failed (serde and garde), as is a bad token, so the token, range and
indicator CHECKs stay unmapped. refuse_adoptive_slots then refuses, each 422 on the slot’s field (the binding create’s
shape), a second slot without a first, a second naming the first’s person, and either slot naming the episode’s child
(the child refusal). A slot craig-cases does not know is 422 no such person; a fresh act naming a slot while
craig-cases is down is 503 person-lookup-unavailable (fail-closed; retry). The exit-response write mapping
(map_exit_response_write) answers a family, gate or slot CHECK hit (23514) the same way; it is a belt the pre-checks
reach first.
The adoptive slots. first_adoptive_parent_person_id and second_adoptive_parent_person_id name craig-cases persons,
with no FK (another database). A fresh exit, correction or historical episode naming one checks every named person through
the cases projection with one display-names read (verify_adoptive_slots), after the ADR-062 precheck: a committed
exit or correction replays from its claim before any cross-service read, so a replay answers while craig-cases is down.
A body naming no slot reads nothing. The second slot is the other member of the couple and need not adopt.
The correction is the complete state. An exit correction restates every answer: one it sends as null is cleared on
the successor row, so a correction to another reason carries none of the (h) or (i) answers its reason does not admit.
An (h)-only correction republishes placement.episode_exited with an unchanged current; craig-financial’s
log-only WARN on it is accepted.
Captured, never derived. (h)(13) and (h)(15) are the worker’s answers, recorded on the exit, never computed from other
rows (⁂ #1073). (h)(14) is P-E’s (OWNED_ELSEWHERE).
Child facts: health and education (P-B3 U5, #2084)
The child’s AFCARS health and education facts, (b)(9)–(b)(12) and (b)(14) (plan afcars-placement-elements D4), land in
migration 20260930140000_child_facts.sql: (b)(9) is a visit flag on health_records; (b)(10)–(b)(12) and (b)(14) live on
two per-child WINDOW ledgers, child_health_facts and child_education_facts (R-B31: window ledgers, not columns on the
update-in-place records). The migration is additive.
(b)(9) — the health assessment. health_records.health_assessment (BOOLEAN NOT NULL DEFAULT false) records that
the visit was a health assessment. POST /v1/placement/health REQUIRES it (a bool; a missing key or a null is 422
validation-failed); PUT /v1/placement/health/{id} takes it optional (absent or null = unchanged); every health read
serves it. The create’s idempotency intent is the request itself (ADR-062 § #2310), so it includes health_assessment. The DEFAULT stays: an
N−1 replica’s create omits the column and records false. The report rule is episode-bounded, a Named override:
(b)(9) is yes iff an active health_records row flagged health_assessment has its visit_date within the episode
the record reports, from removal_at to the earlier of exit_at and the anchor (P-D evaluates it, #1965, joining on
child_id and dropping retired episodes).
Prior visits (#2188). When PUT /v1/placement/health/{id} changes visit_date or health_assessment, the same
statement (update_health_record) inserts the prior pair into health_record_revisions (id uuidv7, health_record_id
REFERENCES health_records ON DELETE RESTRICT, visit_date DATE NOT NULL, health_assessment BOOLEAN NOT NULL,
superseded_at TIMESTAMPTZ NOT NULL, superseded_by UUID NOT NULL; index (health_record_id, superseded_at, id)),
stamped clock_timestamp() after the row lock. A gate miss and an edit leaving the pair unchanged (a notes-only PUT)
record nothing. The same guard as placement_fact_revisions (trg_health_record_revisions_insert_only,
trg_health_record_revisions_no_truncate).
The visit’s worker (#2231). superseded_by is the acting worker (claims.acting_worker(): the relayed worker when a
service relays the PUT) whose edit superseded the pair, bound into the same revision INSERT; no FK (the recorded_by
posture). It attributes a visit_date or health_assessment edit, which placement.health.updated does not (its
payload is health_record_id alone) and the field audit does only when the same PUT changes next_due_date. Migration
20261008130000_health_record_revision_actor.sql (-- devstack: wipe-before-apply) added it: it refuses to apply while
any revision exists (no revision records its worker, and no recorded fact joins to one by key), adds the column NOT
NULL with no default, and bumps schema_compat_floor to 20261008130000 LAST (required: an N−1 health edit omits the
column). Rollback is N−1 images AND a database restore.
The window ledgers. Each is keyed by child_id (a craig-cases person, no FK: another database) and holds a window
[effective_from, effective_until) (effective_until NULL = open; chk_<table>_window_ordered) with the lifted core’s
row columns (recorded_at, recorded_by, supersedes_id, closed_at, closed_by, retired_at, retired_reason ∈
corrected | retracted, retired_note, retired_by). Every answer is nullable, NULL = unanswered, and each gate on a
nullable column is IS NOT DISTINCT FROM.
| Column | Element | Tokens (CHECK) | Gate (CHECK) |
|---|---|---|---|
|
(b)(10) |
|
none |
|
(b)(10) |
|
|
|
(b)(11) |
|
none |
|
(b)(12) |
seventeen tokens: |
none |
|
(b)(14) |
|
none |
Required keys. Every record and correction body (craig_placement_contracts::child_facts::ChildFactsRecordRequest /
ChildFactsCorrectRequest over HealthFacts or EducationFacts, deny_unknown_fields) carries client_request_id,
the window bounds and every answer key (HEALTH_FACT_KEYS, twelve; EDUCATION_FACT_KEYS, three); null = unanswered.
A body missing an answer key, or naming an unknown one, is refused 422 validation-failed at the extractor, before any
claim is read; a bad token is serde’s 422. A correction’s omitted bound is copied from its predecessor.
The acts. POST /v1/placement/children/{child_id}/health-facts records a window: with no effective_until it is a
CHANGE (the open window closes where the new one starts), with one a BACKFILL of a free period.
POST …/health-facts/{row_id}/corrections restates a live row (the successor supersedes it, retired corrected, at most
once), …/{row_id}/retract retires it retracted with a note, and …/{row_id}/close ends the open window at
effective_until (on or before today). The education acts are the twins under …/education-facts. Every act answers
200 and is claimed (ADR-062): a record or correction hashes its bounds and facts whole (craig_ledger::intents::statement_spec).
Each is authorized HealthRecord / EducationRecord Update on the child id (a read, Read); placement holds no
person row, so no case-open guard applies.
Refusals. The pure checks run before the claim: 400 ledger-date-after-today (a bound after the jurisdiction’s
today); 400 ledger-window-invalid (an unordered window); for health, 400 structural-mismatch naming
condition_status when a condition_<category> is answered without a child_has_a_diagnosed_condition status
(api/child_facts/rules.rs; the write mapping answers a family-gate hit, 23514, the same way — a belt the pre-check
reaches first). A window overlapping a live window, or a second open window, is 409 ledger-window-overlap; a CHANGE
dated on or before the open window’s start is 400 ledger-not-a-change (the detail names the corrections path); a
correction, retract or close naming a row that is not a live row of the child’s ledger is 404 ledger-row-not-found.
Reads. GET /v1/placement/children/{child_id}/health-facts?as_of= (and …/education-facts) answers the live window in
force on as_of (default: today on the jurisdiction clock) — 200 with the row, or 204 when none. There is no history
route.
The guard. Both ledgers are insert-only except a CLOSE naming its closer or a RETIRE naming its retirer:
refuse_fact_row_mutation() (placement’s first copy of the ADR-078 D1 fact-ledger guard) refuses a DELETE and any other
UPDATE. excl_<table>_window keeps a child’s live windows apart and uq_<table>_one_open admits one open window per
child (both mapped to 409 ledger-window-overlap); uq_<table>_one_successor corrects a row at most once.
Sensitivity. Plaintext by decision ([sensitive-facts]; ADR-049 § Amendment — #2000); the health answers
are PII (plan A6). No event is published for any act (plan D4).
Caregiver ledger locks (#2053)
Lock order. Every act on an existing binding — the end, the invitation issue (after its claim_first), the
invitation revoke and the identity revoke — takes its unit first: the foster home row FOR SHARE, then the binding
FOR NO KEY UPDATE or the invitation / identity FOR UPDATE. A kinship household takes no lock: its admin_unit is
fixed at mint. SHARE waits for a home update’s FOR NO KEY UPDATE and admits a sibling act’s SHARE and a child insert’s
FK KEY SHARE. No home locker (the home update, the placement create and transitions, the arrangement acts, the
training trigger, the expiry sweep, a field-proposal accept) takes a ledger row, and the §U upload finalizer (ledger
rows, then the home’s KEY SHARE through its home_documents insert) is compatible with SHARE, so the order cannot
cycle. The binding create takes no unit lock.
The re-check. Each act authorizes a foster_home_caregiver ref read before its transaction, then re-reads the home’s
admin_unit under the lock: a unit moved in between is 409 concurrent-modification ("re-read and retry"), never a
commit under the stale ref.
Identity revoke. An identity is person-wide (one live identity per person_id), so
DELETE /v1/placement/caregivers/{id}/identity needs update on the binding’s unit AND on every unit where the person
holds an open binding — in effect or not yet (daterange(effective_from, ended_on, '[)') meets [today, ∞); an ended
binding or a cancel does not count). Any deny is 403 and nothing changes. Under the locks it re-reads that set: a binding
gained meanwhile on a unit it did not check is 409 concurrent-modification; a binding ended meanwhile is not. It is
the one request path that locks several homes, and takes them in ascending id order; a later multi-home locker must too.
Home-document delete lock (#2232)
DELETE /v1/placement/homes/{home_id}/documents/{doc_id} authorizes a home_document ref that carries the home’s
admin_unit, read before its transaction. The transaction’s first statement locks the foster home row FOR SHARE (the
Caregiver ledger locks (#2053) lock) and re-reads admin_unit: a unit moved in between is 409 concurrent-modification ("re-read
and retry"), and the document row and its blob stay as they were. The soft delete of the home_documents row follows
under that lock; the blob half runs after commit. The ref’s other live attribute, license_status, is consulted by no
shipped ruleset, so the compare covers admin_unit alone
(ADR-060 D5 is the trigger that extends it).
Lock order. The home, then the document row: while the delete waits for the home it holds nothing, and once it holds
the home it waits only on the document row. No other home locker (the home update, the placement create and
transitions, the arrangement acts, the training trigger, the expiry sweep, a field-proposal accept, the caregiver-ledger
acts) takes a home_documents row; the blob-janitor’s stamp takes no home lock; the §U finalizer’s insert takes the
home’s FK KEY SHARE, which SHARE admits. The order cannot cycle. The staff upload is a create and takes no unit lock
(the #2053 precedent); list and download are reads.
Training writes and home-target decisions (#2075)
The three training writes (POST /v1/placement/homes/{id}/training, PUT and DELETE /v1/placement/training/{id})
and the accept and reject of a proposal whose target is a foster home authorize a foster_home ref that carries the
home’s admin_unit, read before their transaction. Each re-reads admin_unit under a lock on the home row in its write
transaction: a unit moved in between is 409 concurrent-modification ("re-read and retry") and nothing is written — no
training row is inserted or changed, and no claim, field value or decision commits. The ref’s other live attribute,
license_status, is consulted by no shipped ruleset, so the compare covers admin_unit alone (as on
the home-document delete; ADR-060 D5 is the
trigger that extends it).
The training lock. A training write takes the home FOR NO KEY UPDATE as its transaction’s first domain statement
(the record: right after claim_first): the strength trg_foster_home_training_lock_home already takes on every row
it writes — no new lock strength, now taken first; a no-op or zero-row write now takes it too. A FOR SHARE first (the
caregiver-ledger lock) would deadlock two training writes on one home when each trigger upgraded
it. Recording training is an act on an existing home, authorized as update on it, so unlike the staff document upload
it re-checks.
The decision lock. A decision keeps the #1909 (b) order — claim_first, the proposal FOR UPDATE, then the target
home FOR NO KEY UPDATE (the accept writes the home) — and compares the home’s admin_unit with the one the check read.
Lock order. A training write: (claim_first) → the home → its training row. A decision: claim_first → the proposal
→ the home. No other home locker (the home update, the placement create and transitions, the arrangement acts, the
expiry sweep, the caregiver-ledger acts, the home-document delete) takes a training row or a proposal row, the portal
propose and the inbox heal take no home, and no path now takes a training row before its home, so neither order can
cycle.
Child-keyed records: the custody-unit stamp (#1909 b, ADR-077 D5/D6)
Migration 20261009120000_child_record_unit_stamp.sql (plan child-record-unit-stamp U1, #2233). education_records
and health_records each gain admin_unit TEXT NULL and unit_episode_id UUID NULL (REFERENCES removal_episodes
(id) ON DELETE RESTRICT), with two partial indexes per table: idx_<table>_admin_unit (admin_unit) WHERE admin_unit
IS NOT NULL (the unit-scoped list binds) and idx_<table>_unit_heal (unit_episode_id) WHERE admin_unit IS NULL (the
heals' join). Both columns are Plaintext. On the wire admin_unit is a nullable string on both record views (the
Placement shape); unit_episode_id is a column only — no model field reads it and it never reaches the wire.
The source. A record’s stamp is the child’s latest live episode — not retracted, the greatest removal_at (the open
episode when there is one, since a child’s live windows never overlap) — and that episode’s admin_unit. A child with
no live episode gives NULL/NULL (an unsourced record, which no heal fills); an episode with no unit yet gives a NULL
unit with unit_episode_id set. The create is never refused for either. The education placement_id never sources the
unit: it is caller-supplied and unchecked against child_id.
The child lock. lock_child_episodes takes pg_advisory_xact_lock(hashtext('child-episodes:' || child_id)). Every
caller of the four episode writers takes it in its route guard, after the case-level locks and the pair compare and
before any episode row lock: the open and the historical episode (which insert the episode) through the open’s guard;
the removal correction, the retraction and the three exit acts through the episode guard, before its FOR NO KEY
UPDATE (the trafficking acts share that guard and take it too). A create handler reads the selection unlocked before
its transaction; inside it, after claim_first, the create takes the child lock, re-reads the selection FOR SHARE
and inserts the record with that episode and its live unit. A selection that moved in between — another episode, or
one appearing or vanishing — is 409 concurrent-modification ("re-read and retry") and writes nothing; the same
episode whose unit was filled in between stamps the filled unit.
The heal. Both case-assignment inbox handlers run, right after the episode heal and in the same transaction, one
unit-only statement per table: SET admin_unit = e.admin_unit from the record’s source episode of the case, only where
the record’s unit is NULL and the episode’s is not. craig-manage backfill-assignments runs the two legs
after its episode leg and fills a record with the case’s unit only when its source episode carries that unit (the
inbox heal covers a source stamped otherwise). The create’s FOR SHARE makes an episode fill wait for a racing
create’s commit, so the record heal that follows sees the record. No other SQL writes the column.
Backfill and invariant. The migration sets both columns on every existing record from the child’s live episode with
the greatest removal_at at or before the record’s created_at (best-effort; none = NULL/NULL), then bumps
schema_compat_floor to 20261009120000 as its last statement (voluntary, taken: an N−1 replica inserts unsourced
records and writes episodes without the child lock). Rollback is N−1 images AND a restore. The BLOCKING invariant
child_record_admin_unit_from_episode (severity high, grace 0 s) reports a sourced record whose admin_unit is
distinct from its source episode’s — a missed heal or a differing stamp. It reads no timestamp, so a later recut cannot
trip it.
Authorization (U2, #2234). Every check on education_record / health_record carries the record’s stamp as
attrs.admin_unit through ONE builder per type (api/child_records.rs; a NULL stamp leaves the key absent, never
Null): the read, update and delete refs read the row; a create’s check and field consult carry the unit of the
child’s latest live episode read before the transaction; a field-proposal decision loads the target record first,
soft-deleted included, and an absent record is 404 before the check; the child-fact routes carry the child’s latest
live episode unit. A create replay answers the stored record only after read on its ref (403 otherwise). The three
lists (GET /v1/placement/education, /health, /health/overdue) bind a unit scope as
($n::TEXT[] IS NULL OR admin_unit = ANY($n)) in page and count — a NULL stamp never matches; the worker and
supervisor scopes keep the empty page (#1912); the portal’s record reads bind none. Re-checks (ADR-060). The update
and the soft delete lock the live row FOR NO KEY UPDATE and compare its admin_unit with the pre-read the check
consumed; a field-proposal accept and reject lock the target record FOR NO KEY UPDATE (soft-deleted included) under
the held proposal lock and compare its stamp with the one the check consumed (a foster-home target is locked the same
way and its admin_unit compared, Training writes and home-target decisions (#2075)); a child-fact act takes the child lock, re-reads the child’s
latest live episode FOR SHARE and compares its id and whether its unit is filled with what the check read. A
difference is 409 concurrent-modification and nothing is written.
Lock order. A record create: claim_first → the child lock → the episode FOR SHARE → its record. An episode writer:
claim_first → the case-level locks → the child lock → the episode. The inbox heal: the case lock → the projection →
the episodes → the records → the placements, never the child lock. The inbox waits on a create only at the episode row
(its UPDATE waits behind the create’s FOR SHARE); a create holding that share lock then needs only its own new record
row, the FK KEY SHARE on the episode it already holds and on the education placement_id (which conflicts only with
FOR UPDATE, which nothing takes on placements), and its outbox and audit inserts — none of which the heal holds. No
path takes the child lock while holding an episode or record row, so the order cannot cycle. A child-fact act:
claim_first → the child lock → the episode FOR SHARE → its window rows. The update and the delete lock only the
record; a decision locks the proposal, then the target. The arrangement acts lock the episode FOR NO KEY UPDATE
without the child lock, so a child-fact act’s FOR SHARE waits on them; they take no child lock, record or proposal.
None takes the child lock while holding an episode or record row, and nothing locks a proposal or an episode after a
record, so the order still cannot cycle with the heal.
Removal episodes, exits and living arrangements (P-B1, #2018–#2024, ADR-079 D2–D4)
Migration 20260925130000_removal_episodes_recut.sql. A removal episode is the unit of care; every
placement is a living arrangement inside one. The migration is REFUSE-ON-DATA (it raises on any existing
placements row and synthesizes no episode), drops removal_date, removal_reason, ctw_finding,
ctw_finding_date, ctw_days_from_removal, reasonable_efforts, reasonable_efforts_date and the
dormant sibling_placements table (#1778) without moving values, installs btree_gist (both window
EXCLUDEs compare the child_id UUID with = in a GiST index), and bumps craig-placement’s
schema_compat_floor to 20260925130000 as its last statement. Every new column is Plaintext.
Migration 20260925150000_exit_responses.sql (#2019, ADR-079 D4) is ADDITIVE: it creates
exit_responses, replaces the check_episode_current_instants() body (attaching its constraint trigger to
the new table), and widens chk_placements_end_reason to a superset. No existing row can fail it and an
N−1 craig-placement neither writes an exit nor decodes end_reason strictly, so it has no refuse-on-data
guard and does not bump schema_compat_floor. Every new column is Plaintext.
Migration 20260925170000_retracted_arrangements.sql (#2020, ADR-079 D3) is a WIDENING: it adds the retract
trio retracted_at / retracted_by / retract_note and replaces_placement_id, widens
placements_status_vocab and placements_activated_pairing by retracted, adds
placements_retract_all_or_none, replaces placements_ended_pairing and
placements_end_reason_only_when_ended with the three ended CHECKs below, and adds fk_placements_replaces
and uq_placements_one_replacement. Every existing row satisfies the new set, so it has no refuse-on-data guard
and no devstack wipe marker. It bumps schema_compat_floor to 20260925170000 as its last statement
(voluntary, and required: an N−1 craig-placement decodes status through the strict PlacementStatus enum and
cannot read a retracted row). Rollback is N−1 images AND a restore. Every new column is Plaintext.
Migration 20260926120000_end_reason_narrowing.sql (#2023, ADR-079 D4) is DESTRUCTIVE and refuses on
data. It SHARE-locks placements, removal_episodes and exit_responses for the file. It then REWRITES
each exit-token end_reason (reunification, adoption, aging_out, guardianship, emancipation,
death) to left_care where the arrangement is its episode’s latest effective arrangement (by
started_at, then id; activated and not retracted) and the live episode holds a live exit, recording one
placement_end_reason_rewrites row per rewritten arrangement; nothing else of the row changes. Its guard
then refuses on ANY remaining exit-token row, retracted rows included. It narrows
chk_placements_end_reason and bumps schema_compat_floor to 20260926120000 as its last statement
(voluntary: an N−1 craig-placement would meet the narrowed CHECK as a 500). The file is one transaction,
so a refusal applies nothing. Rollback is N−1 images AND a restore. Every new column is Plaintext.
Migration 20260926180000_placement_goal_drop.sql (#2024, plan D6 R-B10; ADR-079 § Consequences) is
DESTRUCTIVE: it drops placements.permanency_goal without moving a value (a child’s permanency plan lives
on craig-cases' permanency_plans, ADR-078 D4), and the column’s single-column CHECK
chk_placements_permanency_goal drops with it. It has no refuse-on-data guard. It waits at most 10 s for
its lock and bumps schema_compat_floor to 20260926180000 as its last statement (mandatory, ADR-063 D3:
an N−1 craig-placement reads and writes the column). The governed token placements.permanency_goal
leaves the foster_home_portal roster (seven tokens → six). Rollback is N−1 images AND a restore.
removal_episodes — id, child_id, case_id, admin_unit (the ADR-077 stamp, NULL until filled),
removal_at TIMESTAMPTZ NOT NULL, exit_at (on a live episode, its live exit response’s; NULL while the child is in care),
recorded_at / recorded_by,
and the RETIRE columns retired_at / retired_by / retired_reason / retired_note. No updated_at (a
touch would break every shape comparison). CHECKs: chk_removal_episodes_exit_after_removal (exit_at >
removal_at), …_retired_paired and …_retired_by_paired (all-or-none with retired_at),
…_retired_reason (only retracted), …_retired_note (a note only on a retired row). UNIQUE (id,
child_id, case_id) is the composite FK target. excl_removal_episodes_child_window: EXCLUDE USING gist
(child_id WITH =, tstzrange(removal_at, exit_at, '[)') WITH &&) WHERE (retired_at IS NULL) — a child’s
live episodes never overlap (409 episode-overlap). The range is half-open, so an exit and a re-entry
(the child’s next episode) on one instant are adjacent, not overlapping. The row guard refuse_episode_row_mutation()
refuses DELETE and admits an UPDATE only as (1) the current instants (removal_at, exit_at) on a live
episode, (2) a RETIRE naming its retirer, or (3) the admin_unit fill (state-free, so a retracted episode
heals too). An episode is keyed by the child ("each removal of a child", §1355.44(d)(1)) and keeps its case_id for life;
every arrangement of the episode takes it through fk_placements_episode. A transfer of responsibility to another
agency is an exit (transfer_to_another_agency); a move to another case of the same agency during an episode is
not supported, a final ruling (2026-10-06, #2028; ADR-079 § Open questions): an in-agency transfer is a worker
reassignment on the same case. #1804’s legal custody is a separate craig-cases fact.
removal_responses — the removal event ledger: episode_id (FK, ON DELETE RESTRICT), removal_at d)(1,
removal_manner (CHECK: voluntary_placement_agreement or court_ordered_removal, the RemovalManner
vocabulary), recorded_at / recorded_by, first_recorded_at d)(2, supersedes_id (self-FK; CHECK never
itself), the RETIRE columns (retired_reason ∈ corrected or retracted, paired as on the episode) and the removal
answers (Removal facts (P-B3 U2, #2081)).
FIRST_RECORDED: the BEFORE INSERT trigger removal_responses_first_recorded_at() sets a root’s
first_recorded_at to its recorded_at and copies a correction’s from the response it supersedes, which
must belong to the same episode (INTO STRICT refuses otherwise). refuse_event_row_mutation() (the
craig-cases ADR-078 D1 text, byte-for-byte) refuses DELETE and admits an UPDATE only as a RETIRE.
Partial uniques: uq_removal_responses_one_successor (supersedes_id) and uq_removal_responses_one_live
(episode_id WHERE retired_at IS NULL) — one live response per episode.
exit_responses (#2019) — the exit event ledger, the one home of AFCARS (g)(1)–(g)(4): episode_id
(FK, ON DELETE RESTRICT), exit_at g)(1, exit_reason g)(3); CHECK: the eight ExitReason tokens reunify_with_parents_legal_guardians, live_with_other_relatives, adoption, emancipation, guardianship, runaway_or_whereabouts_unknown, death_of_child, transfer_to_another_agency — never not_applicable, which a report answers from "no live exit"), transfer_agency_type ((g)(4); CHECK: the seven TransferAgencyType tokens state_title_iv_e_agency, tribal_title_iv_e_agency, indian_tribe_or_tribal_agency_non_iv_e, juvenile_justice_agency, mental_health_agency, other_public_agency, private_agency; chk_exit_responses_transfer_paired holds it NOT NULL exactly when exit_reason is transfer_to_another_agency), recorded_at / recorded_by, first_recorded_at ((g)(2, supersedes_id (self-FK; CHECK never itself) and the RETIRE columns (retired_reason ∈
corrected or retracted, retired_at / retired_reason / retired_by paired, a note only on a
retired row). FIRST_RECORDED as on removal_responses: the BEFORE INSERT trigger
exit_responses_first_recorded_at() sets a root’s first_recorded_at to its recorded_at and copies a
correction’s from the exit it supersedes, which must belong to the same episode. refuse_event_row_mutation()
is attached (not re-defined): insert-only except a RETIRE. Partial uniques:
uq_exit_responses_one_successor (supersedes_id) and uq_exit_responses_one_live (episode_id WHERE
retired_at IS NULL) — one live exit per episode. An exit retraction ends its chain: an exit recorded
after it is a new root response with its own first_recorded_at (R-B18). #2083 adds the twenty-one nullable
adoption / guardianship exit answers — (h)(1), (h)(2), the two adoptive-parent slots for (h)(3)–(h)(12), (h)(13), (h)(15)
and (i)(10)–(i)(13) — with their token CHECKs, the (h) and (i) family CHECKs on exit_reason, the slot, siblings and
good-cause gates; see The adoption / guardianship exit (P-B3 U4, #2083).
R14 (both response ledgers). recorded_at is DEFAULT now() and no act body carries it (the open, removal
correction, exit record or correction and historical bodies are strict, deny_unknown_fields, so a client-sent
recorded_at is refused, never stored; the two retractions reuse the lenient LedgerRetractRequest and write no
response row); the seed supplies its own. A correction may not move the event date past the date of the chain’s first_recorded_at (400
response-after-recording). A late entry through the API — an open with a past removal_at, or a historical
episode, whose stamps are now() too — is therefore honestly tardy: its (d)(2) / (g)(2) are the recording dates.
placement_end_reason_rewrites (#2023) — the audit of the one sanctioned end-reason rewrite:
placement_id (PK, FK placements (id) ON DELETE RESTRICT), from_reason (CHECK
chk_placement_end_reason_rewrites_from_reason: the six exit tokens reunification, adoption,
aging_out, guardianship, emancipation, death), exit_response_id (FK exit_responses (id) ON
DELETE RESTRICT, the live exit that carries the reason) and rewritten_at (default now()). The trigger
trg_placement_end_reason_rewrites_append_only (refuse_end_reason_rewrite_mutation()) refuses every
UPDATE and DELETE with SQLSTATE 23000, for every role, the owner included; the migrate gate revokes INSERT,
UPDATE, DELETE and TRUNCATE from every non-owner grantee on every successful verdict (#2337; the migration’s
own revoke names only the devstack role craig_placement_app). Only migration
20260926120000_end_reason_narrowing.sql writes it, and the service never reads it.
ck_episode_current_instants (constraint trigger, DEFERRABLE INITIALLY DEFERRED, on
removal_episodes, removal_responses, exit_responses and (#2082) both trafficking ledgers): at COMMIT a
live episode’s removal_at equals its live removal response’s and its exit_at equals its live exit
response’s (NULL when it has none); a retired episode is inert — it holds no live removal, exit or
trafficking row, or the trigger refuses.
placements (the arrangement) — new columns episode_id UUID NOT NULL, activated_at, cancelled_at,
cancelled_by, cancel_note; index idx_placements_episode. #2020 adds retracted_at, retracted_by,
retract_note and replaces_placement_id (all Plaintext), the FK fk_placements_replaces and the
partial unique index uq_placements_one_replacement. Constraints (as of #2020):
-
fk_placements_episode:(episode_id, child_id, case_id) REFERENCES removal_episodes (id, child_id, case_id) ON DELETE RESTRICT— the placement’s child and case are the episode’s. -
placements_status_vocab:planned,active,ended,cancelled,retracted(#2020 widened it). -
placements_activated_pairing:(activated_at IS NOT NULL) = (status IN ('active', 'ended', 'retracted'))— a retracted row keeps itsactivated_at. -
placements_started_by_activation:activated_at IS NULL OR started_at ⇐ activated_at. -
placements_cancel_all_or_none: the three cancel columns are all set exactly whenstatus = 'cancelled'. -
placements_retract_all_or_none(#2020): the retract trioretracted_at/retracted_by/retract_noteis all set exactly whenstatus = 'retracted'. -
placements_ended_has_ended_at(#2020; with the next two it replaces #1583’splacements_ended_pairingandplacements_end_reason_only_when_ended):status <> 'ended' OR ended_at IS NOT NULL— an ended row always carries its end instant. -
placements_ended_at_when_ended_or_retracted(#2020):ended_at IS NULL OR status IN ('ended', 'retracted')— a retract of an ended row keepsended_atas the record. -
placements_end_reason_when_ended_or_retracted(#2020):end_reason IS NULL OR status IN ('ended', 'retracted')— likewiseend_reason. -
fk_placements_replaces(#2020):replaces_placement_id REFERENCES placements (id) ON DELETE RESTRICT. -
uq_placements_one_replacement(#2020, partial unique index):(replaces_placement_id) WHERE replaces_placement_id IS NOT NULL AND status <> 'cancelled'— at most one non-cancelled replacement per retracted arrangement (a cancelled planned replacement frees the slot). It is the unmapped DB twin of the API’s 409invalid-replacement, which refuses first under the episode lock; a write that reaches the index keeps the house error mapping. -
placements_ended_after_started: nowended_at IS NULL OR ended_at > started_at(a zero-length arrangement is refused; the PUT refuses it first, a generic400bad request). -
excl_placements_child_arrangement:EXCLUDE USING gist (child_id WITH =, tstzrange(started_at, ended_at, '[)') WITH &&) WHERE (activated_at IS NOT NULL AND status <> 'retracted')— a child’s effective arrangements never overlap (409arrangement-overlap). Effective means activated and not retracted: a retracted row keeps itsactivated_atbut leaves the exclusion (andck_arrangement_in_episode), so its instants are free for the re-record. -
ck_arrangement_in_episode(constraint trigger, deferred, fired by a placement write and by a change to the episode’sremoval_at/exit_at): an activated arrangement of a live episode starts at or afterremoval_atand ends at or beforeexit_at(an open end needs an open exit); 409arrangement-outside-episode. The exit acts moveexit_at, so they re-run it. -
chk_placements_end_reason(#2019 widened it, #2023 narrowed it):end_reasonis NULL or one oftransfer,disruption,runaway,left_care.left_careends the arrangement because the agency’s placement and care responsibility ended; the reason the child left care lives only on the episode’s exit (ADR-079 D4). -
placements_ended_recorded_pairing(#2187):(ended_at IS NULL) = (ended_recorded_at IS NULL).ended_recorded_at(TIMESTAMPTZ, Plaintext, in no response body) is the DB instant of the statement that wroteended_at: the ending PUT stampsstatement_timestamp()(COALESCEd, write-once), a historical recordnow()(its ownactivated_at). Migration20261005120000_end_record_stampsbackfilled every earlier end withactivated_at(a binding’s withcreated_at) and bumpedschema_compat_floor. -
placements_ended_recorded_after_activation(#2187):ended_recorded_at >= activated_at. The PUT stampsstatement_timestamp(), notnow(): an end whose transaction began before a racing activation runs its UPDATE after the locked read that saw the activation.
The writers run SET CONSTRAINTS ck_arrangement_in_episode, ck_episode_current_instants IMMEDIATE
(store::removal_episodes::check_deferred) before staging their events, so neither fires at COMMIT, where a
failure would be a redacted 500 (ADR-079 D2, plan erratum E1). Both trigger functions raise SQLSTATE 23514
naming their constraint: ck_arrangement_in_episode answers the typed 409 arrangement-outside-episode;
ck_episode_current_instants stays a redacted 500, because the acts write an episode and its responses in
step and a disagreement is a server defect no request can trip.
Lock order. claim_first → (the episode open, the historical episode and the placement create: the
per-case advisory lock) → (the episode and exit acts and the placement create: the projection FOR SHARE
re-read and pair compare) → (the episode, exit and trafficking acts, the open and the historical episode
included: the child-episode advisory lock, Child-keyed records: the custody-unit stamp (#1909 b, ADR-077 D5/D6)) → the episode FOR NO KEY UPDATE (every act but the open and the historical
episode, which insert it) → the placement → the foster
home. The PUT, the cancel and the retract (#2020) lock episode → placement (→ home) and take no
projection lock: the placement row carries its own assignment pair, re-compared under its lock. The
retract checks no caregiver binding (#2058: a binding keys the kinship household, not the arrangement); an
active → retracted flip decrements the home through the occupancy trigger, after the placement lock. The historical record (#2020) takes the root-birth order of the placement create: the
per-case advisory lock and the projection re-read, then the episode, then (when it names
replaces_placement_id) the replaced placement, then the foster home. The live create’s replacement check
locks the replaced placement at the same point, after the episode and before the home.
The replacement chain (#2020, R-B21). A re-record — the live create or the historical record — may name
in replaces_placement_id only a retracted arrangement of the same episode that no non-cancelled row
already replaces; anything else is one 409 invalid-replacement, so ids cannot be probed across episodes.
A retracted replacement still holds its slot, so a second correction names the retracted replacement,
not the original: X ← Y ← Z. Financial re-anchors a subsidy agreement along the chain, X → Y, then Y → Z.
Acts and routes (full contracts: craig-placement API):
| Route | Act |
|---|---|
|
Open: the episode and its root removal response in one transaction. 400 |
|
Correct the live removal response: the successor supersedes and retires it and the episode’s
|
|
Retract an episode entered in error: its live removal response, its live exit response (if any) and the
episode are retired |
|
Record the exit (#2019): the root exit response, and the episode’s |
|
Correct the live exit response: the successor supersedes and retires it and the episode’s |
|
Retract the live exit response entered in error (with a note): it is retired |
|
Record an already-ended episode (#2019): the episode, its root removal response and its root exit
response in one transaction; 201 on a fresh call and on its replay. 400 |
|
The child’s live episodes, each with its live removal response and its live exit response ( |
|
Cancel a |
|
Retract an |
|
Record a missed past arrangement (#2020): born |
|
Now requires |
|
Moves only |
Every write above except the PUT also answers 403 for a pure service principal (before any lookup), 409
concurrent-modification when the case assignment changed between the authorization check and the lock, 409 on
an ADR-062 client_request_id reuse with a different body, and 422 on a missing client_request_id. The open
and the historical episode (and a caregiving birth-active create or planned → active) relay craig-cases'
placement-facts refusals (400 child-not-in-case / placement-facts-clock-drift, 409 case-closed for a
closed or transferred case (#2029), 422 child-dob-missing) and answer 503 when craig-cases does not answer
that read. The lifecycle check is advisory: placement holds no case lock, so a case can close between the read and
the write’s commit. The acts that read no facts stay admitted on a closed case: a non-caregiving activation, a
birth-planned create, the historical arrangement record (POST /v1/placement/placements/historical), the exit
act, the plain end, and the removal and exit corrections. A replay of a committed act still answers its stored row
after the case closes, because the replay precheck runs before the read.
Every episode act answers the resulting EpisodeRow { id, child_id, case_id, admin_unit, removal_at, exit_at,
recorded_at, removal, exit } — 201 for the open and the historical episode (a fresh call and its replay alike), 200 for
the other acts. removal and exit are ResponseRow`s: the shared event row (its id, `episode_id, the facts and the
provenance) flattened beside first_recorded_at. exit is null exactly when exit_at is null; otherwise it is the
exit response exit_at is from — the live one on a live episode, the one retired with it on a retracted episode.
admin_unit is the unit the episode is stamped with (ADR-077 D6), null until craig-placement’s case-assignment
projection knows the case (#2065). The open, correction, exit and historical bodies are strict (deny_unknown_fields);
the two retractions reuse the lenient LedgerRetractRequest and write no response row; the answers are lenient.
Authority: an episode is authorized as a Placement (no new resource type, no ruleset row) over the case’s
case_assignments pair and the episode’s admin_unit — for the open and the historical episode, which have no
episode row yet, the case’s current unit, the one the new episode is stamped with. Those two are Action::Create,
every other episode and exit write Action::Update; the child list checks Action::Read per episode and omits a
denied row. The cancel and the retract are Action::Update on the placement (dual-state check); the historical
record is Action::Create on the episode’s case, as the create.
Events (each staged in the act’s transaction through the outbox; ids, closed tokens and instants only, never a
removal fact; placement.episode_exited alone carries the exit’s date and reason (fleet vocabulary, not PII);
deny_unknown_fields):
placement.episode_facts_changed { episode_id, child_id, case_id, ledger, row_id, act, user_id } — one per
episode, exit or (#2082) trafficking act (ledger is removal_episodes, removal_responses,
exit_responses, episode_trafficking_statements or trafficking_law_enforcement_reports; act is
recorded, corrected or retracted; the open and the episode retraction name the episode, a correction
its successor response, an exit record its root exit response, an exit retraction the retired exit
response, a trafficking record the new row, its correction the successor and its retraction the retired
row; an episode retraction that also retires a live exit or live trafficking rows still publishes only its
removal_episodes / retracted event), except the historical episode, which publishes two
(removal_episodes / recorded naming the episode, then exit_responses / recorded naming its exit
response) — and
placement.cancelled { placement_id, episode_id, child_id, case_id, user_id } (the note stays on the row).
#2020 adds placement.retracted { placement_id, episode_id, child_id, case_id, retracted_from, user_id }
(retracted_from is active or ended; the note stays on the row) and placement.recorded { placement_id,
episode_id, child_id, case_id, started_at, replaces_placement_id?, user_id } — the historical record’s one
lifecycle event (no placement.created, placement.activated or placement.ended; the #634
placement.field_written audit of its status is staged beside it). placement.activated gains an
optional field replaces_placement_id, present only when the activated row re-records a retracted
one, so a plain activation carries no such key.
#2056 (plan afcars-placement-facts D2, D5): placement.activated carries placement_type as the federal setting token
(foster_family_home or an (e)(4) token) and gains the optional ffh_types (the applying (e)(3) categories, omitted off a
family row), and placement.recorded becomes { placement_id, episode_id, child_id, case_id, started_at, placement_type,
ffh_types?, replaces_placement_id?, user_id }; craig-financial derives the rate class from the pair. #2058 adds
kinship_household_id to placement.created (not to placement.recorded).
#2021 adds placement.episode_exited { episode_id, child_id, case_id, arrangement_ids, current: { exit_on,
exit_reason } | null, act_id, act_at, user_id } — one per exit record, correction and retraction and one from the
historical episode (an episode retraction publishes none), staged after the act’s
placement.episode_facts_changed; current is the episode’s live exit after the act (null after a retraction),
arrangement_ids every live arrangement (planned, active, ended, by started_at then id; empty for a historical
episode), act_at the act’s clock_timestamp() under the episode lock. Strict at its top level; current is the
lenient EpisodeExit the subsidy-eligibility read also serves.
#2017 (plan D6, R-B11) lands the routing key placement.afcars_released: the
AFCARS release audit, strict payload { requestor, purpose, child_ids, child_count, from, to, as_of } —
requestor the closed token craig-reporting, purpose the closed token afcars-2020 federal reporting,
child_ids the released children, child_count their number, and the resolved report window and read instant
(never a placement fact). craig-security parses it (read, placement).
#2119 (P-D1 of #1965) adds its emitter, the service-only GET /v1/placement/afcars-export. It stages one event per
non-empty page. child_ids is the page’s distinct children, ascending. The event is staged in the page’s read
transaction, before the no-store body is built. An empty page stages none.
AFCARS export reads (#2119, #2120). The export reads removal_episodes, removal_responses, exit_responses and
placements, all as of the request’s as_of. #2120 adds episode_trafficking_statements,
trafficking_law_enforcement_reports, child_health_facts, child_education_facts, caregiver_bindings and
health_records, read the same way. Each table falls in one of two as-of classes, and two column sets read through
their revisions:
-
Class 1, the ledger rows (
removal_episodes,removal_responses,exit_responses): a row is live whenrecorded_at ⇐ as_ofand it is not retired by then (retired_atnull or afteras_of). -
Class 2, the arrangements (
placements): a row counts whenactivated_at ⇐ as_ofand it is not retracted by then (status <> 'retracted'orretracted_atafteras_of). Planned and cancelled rows have noactivated_at, so they drop out. An arrangement’sended_atcounts only whenended_recorded_at ⇐ as_of(#2187); an end recorded later reads open, and an end written before the stamp migration reads as known fromactivated_at. -
Revisions (#2188): an arrangement’s sixteen facts and a health record’s
visit_dateandhealth_assessmentread as they stood atas_of: the earliestplacement_fact_revisions/health_record_revisionsrow withsuperseded_at > as_of(bysuperseded_at, thenid), else the live row. A revision’s NULL is an answer, never COALESCEd. The history starts with migration20261005130000_placement_revisions.started_at(fixed at activation, which class 2 fences),placement_type, theffh_type_*columns and the setting (fixed at insert) are never edited in place, so no placement column reads current and the pages of one walk agree.
The cohort is closed at from: a child is in when a live removal falls before to and its live exit is absent or
not before from. The cohort uses the live responses' instants, never the episode row’s current ones. An episode’s
exit is served only when its exit_at is before to. Rows come in (child_id, kind, row_id) order. The export
answers no _note, created_by, cancelled_by or retracted_by column: the narrow row structs omit them. The episode
and exit reads load the whole response row and serialize only its element columns; the arrangement read never selects them.
The #2120 tables, by class (plan afcars-pipeline-sources D3):
| Table | Class | Live at as_of when |
Reads current |
|---|---|---|---|
|
1 |
|
nothing (insert-only) |
|
1 + close |
the same; |
nothing |
|
2 |
|
nothing ( |
|
2 |
|
nothing ( |
|
2 |
as above |
nothing ( |
Window normalization. A health or education window closed after as_of reads open: the export serves
effective_until as null when closed_at > as_of, and every in-force test treats such a window as open.
The five appended kinds (#2120). After episode (1) and arrangement (2) come five more. Ordinals are append-only
and the cursor version stays 0x01. to_d is the local date of to on the jurisdiction clock, and period_end is
the day before to_d. An episode here is a live removal (before to) of a cohort child; an exit is answered when its
exit_at is before to. Each kind’s anchor:
-
trafficking_statement(3): per episode, the one latest statement live atas_ofwithstated_onbeforeto_d(latest bystated_on, thenrecorded_at, thenid). Its facts are raw; the (d)(6)(i) gate is reporting’s. -
law_enforcement_report(4): every report live atas_ofwithreported_onbeforeto_d. -
health_window(5): the health window in force atperiod_end. -
education_window(6): the education window in force atperiod_end, and the one in force at the local date of each answered exit withexit_atat or afterfrom. -
health_assessment_visit(7): every visit flaggedhealth_assessmentatas_of, existing atas_ofand dated (as atas_of) beforeto_d, from the removal’s local date through the answered exit’s local date (inclusive at both ends; an unanswered exit leaves the window open). The row carries onlyvisit_date, as atas_of(#2188); reporting holdsremoval_atandexit_atand decides (b)(9).
A key reached through two anchors or two episodes is served once. No kind 3–7 row selects retired_note,
retired_by, recorded_by, closed_by, notes, diagnosis, treatment_plan, medications, provider_name,
recorded_by_name or immunization_name.
The arrangement’s slots (#2120, P-B2 D6). An arrangement row also carries first_caregiver_person_id and
second_caregiver_person_id, the (e)(9)–(e)(13) and (e)(14)–(e)(18) persons; both serialize as null, never skipped.
They are filled for a foster_family_home arrangement only; any other placement type (including a congregate row with a
foster_home_id) answers null / null. With d the local date of started_at, a binding counts when it is on the
arrangement’s unit (the same foster_home_id or kinship_household_id), was created by as_of, and covers d
half-open: effective_from ⇐ d AND (ended_on IS NULL OR ended_on > d) AND ended_on IS DISTINCT FROM effective_from,
with ended_on read as of as_of (CASE WHEN ended_recorded_at ⇐ as_of THEN ended_on END, #2187: an end or cancel
recorded later reads open).
The covering bindings run primary first, then by effective_from, created_at and id; the first two distinct
persons fill First and Second, and fewer persons leave the rest null. This is the Caregiver slots rule below,
fenced at as_of.
The setting on the eligibility read (#2056, plan afcars-placement-facts D5). PlacementSubsidyEligibility also serves
ffh_types, the applying (e)(3) categories, exactly for a foster_family_home setting (typed: an unknown category fails
the decode; serde-defaulted); craig-financial’s ERR rule reads them.
The exit, read (#2021, ADR-079 D4). GET /v1/placement/placements/{id}/subsidy-eligibility (PlacementSubsidyEligibility) gains the additive
episode_exit { exit_on, exit_reason } | null: the episode’s live exit, served when the placement is its
episode’s latest effective arrangement (by started_at, then id; activated and not retracted — the arrangement
an exit leaves from is derived, never stored) or, since #2059, its residence run’s last member is; null
otherwise; exit_on is the jurisdiction’s business date of exit_at. #2022: with ?as_of= absent, the read’s caregivers are evaluated at exit_on whenever
episode_exit is served, else at the placement’s evidence date (the business date while planned/active,
ended_on once ended), never ahead of the business date; craig-financial’s guardianship witness requires
residence.ended_on == exit_on (#2059; the placement’s ended_on before) and takes exit_on as the transfer. U6a’s report-only invariant
guardianship_ending_without_exit stated the same "latest effective" rule for U6b’s data gate (#2022). #2023
retired it: after the narrowing no arrangement can end guardianship, so it matched nothing by construction.
The #2023 migration’s rewrite states that latest-effective rule instead (pinned apart from the projection’s run
read by a unit test since #2059); it requires no ended_on == exit_on match, so a rewritten row need not
satisfy the witness.
#2046: the report-only invariant left_care_ending_without_exit (severity medium, grace 0 s) lists each live
episode’s latest effective arrangement (that same rule) that ended left_care while the episode holds no live exit;
any live exit clears it, whatever its reason or instant (ck_arrangement_in_episode already holds the exit at or
after the end). It stays outside BLOCKING_INVARIANTS: an API or CLI left_care end records no exit, and a web end
whose exit act was refused (#2047) leaves the arrangement ended without one. Journeys enforce it in their footprint
(journey_sweep::SELECTORS). Until the exit is recorded, the witness refuses the anchor (NO_EXIT).
The residence run (#2059, plan afcars-placement-facts D5, R-B27; ADR-079 and ADR-056 § Amendment (2026-09-26, #2026)).
The subsidy-eligibility read gains the additive residence { started_on, ended_on, arrangement_ids } | null
(ResidenceRun). For an effective caregiving placement X it is the maximal sequence of X’s episode’s effective arrangements,
by started_at then id, containing X, whose first and last members are caregiving, whose caregiving members all name X’s
setting identity (foster_home_id or kinship_household_id), and in which each member starts on the jurisdiction date
the previous one ended (date_of(next.started_at) = date_of(prev.ended_at)); non-caregiving members sit only between.
started_on is the first member’s start, ended_on the last member’s end (null while open), arrangement_ids the
members in order — never a unit id; null for a planned, cancelled, retracted or non-caregiving placement. It is derived on
every read from ONE statement over the episode’s effective arrangements (store::exit_responses::episode_arrangements,
then the DB-free residence::residence_run), so a correction, retraction, historical record or replacement changes it at
once; nothing stores it, no event carries it, and no agreement moves (ADR-052’s re-anchor is unchanged). The read’s caregivers,
dated exit_on whenever the exit is served, are the run’s: every caregiving member names X’s identity. A run or hospital
row between caregiving members counts inside the run’s span (⁂ #1073). craig-financial’s residence floor measures from
residence.started_on; SG / NRSG creates refuse a non-caregiving anchor (422 subsidy-anchor-not-caregiving).
AFCARS element → column map (craig_placement_contracts::afcars::AFCARS_ELEMENT_COLUMNS at
AFCARS_CAPTURE_STAGE = B3U5 (= LAST_UNIT), written in the shared craig_reporting_contracts::afcars_capture::Mapping with
its own PlacementCaptureUnit stage enum — one variant per landing unit, B1U3 … B3U5; OWNED_ELEMENTS names
all 67 keys placement owns, each on its unit: (d)(1), (d)(2) and (e)(1) at B1U3, (g)(1)–(g)(4) at B1U4,
(e)(9)–(e)(18) and (b)(20) at B2U1, (e)(2)–(e)(4) at B2U3, (b)(21) at B2U5, (e)(5)–(e)(8) and (i)(5)–(i)(8) at
B3U1, (d)(3), (d)(4), (i)(1) and (i)(4) at B3U2, (d)(5)–(d)(6)(ii) at B3U3, (h)(1)–(h)(13), (h)(15) and
(i)(10)–(i)(13) at B3U4, (b)(9)–(b)(12), (b)(14) at B3U5).
craig-placement’s tests/afcars_elements.rs checks each entry against its dictionary row’s atom and cardinality
(every_due_key_maps_to_a_column_its_dictionary_row_fits; an Each column is <prefix>_<category>, or, only where that
name exceeds 63 bytes, a non-empty <prefix>_<slug> that fits — the P-B3 D5 slug rule,
an_unneeded_or_overlong_slug_is_a_problem), probes that at the last unit every owned key is mapped
(at_the_last_unit_every_owned_key_is_mapped), pins the stored exit token sets to the dictionary’s less
not_applicable, and, against a migrated devstack, checks that every mapped placement column exists with a type
its atom admits and that every Derived placement input exists. cargo xtask rules check’s AFCARS partition finding (`xtask/src/cmd/afcars_partition.rs, plan D11) holds every dictionary key in exactly one of craig-cases' and craig-placement’s OWNED_ELEMENTS and OWNED_ELSEWHERE (142 = 57 + 67 + 18), every listed key in the dictionary, a map at its LAST_UNIT complete, and every Person / Derived cases half registered; placement’s map is held complete (P3) from P-B3 U5 (LAST_UNIT = B3U5, #2084). Every reported date is the column’s instant on the jurisdiction clock
(BusinessClock::date_of). P-B3 (#2052) completes the map:
| Element key | Mapping | Column |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
first caregiver slot → |
|
|
the same five facts, second caregiver slot |
|
|
first adoptive slot ( |
|
|
first adoptive slot → |
|
|
first adoptive slot → its seven |
|
|
first adoptive slot → |
|
|
first adoptive slot → |
|
|
second adoptive slot ( |
|
|
second adoptive slot → |
|
|
second adoptive slot → its seven |
|
|
second adoptive slot → |
|
|
second adoptive slot → |
|
|
cases |
|
|
the (b)(20) inputs plus |
Caregiver slots (plan afcars-placement-facts D6, R-B28). (e)(9)–(e)(18) are no column. On a family arrangement’s (e)(1)
date d, the covering bindings of its setting identity (foster_home_id or kinship_household_id) are those with
effective_from ⇐ d AND (ended_on IS NULL OR ended_on > d) AND ended_on IS DISTINCT FROM effective_from. Slots are
distinct persons: each person takes its first covering binding by role (primary, then co), effective_from,
created_at, id, and the first two persons in that order fill First and Second (excl_caregiver_bindings_person_unit_window
makes one person’s overlap unrepresentable). A caregiver bound after d is not reported for that arrangement (⁂ #1073);
an adult’s abandoned race or ethnicity is P-D missing data. A non-family arrangement has no slot. P-D’s export computes
the slots (#1965); one_person_fills_one_slot pins distinct persons and the devstack seed gives every seeded family
arrangement a first slot at its start (#2060).
Person slots (plan afcars-placement-elements D3, #2083). (h)(3)–(h)(12) are no column of their own: the live exit’s
first_adoptive_parent_person_id names the person whose five cases facts answer (h)(3)–(h)(7), and
second_adoptive_parent_person_id the person for (h)(8)–(h)(12) (PersonVia::Column, where the caregiver slots use a
binding window). Each is a craig-cases person id with no FK, verified against the cases projection when a fresh act
names it; neither may name the episode’s child, and a second needs a first and names another person (the second is the
other member of the couple and need not adopt). (h)(3) / (h)(8) are a date element, so they read the full
persons.date_of_birth: a declared year alone leaves them missing. The (h)(4)–(h)(7) / (h)(9)–(h)(12) facts are the
caregiver slots' (the ethnicity—oohc_h6 / ethnicity—oohc_h11 and sex—oohc_h7 / sex—oohc_h12 crosswalks serve
(h)). The devstack seed derives an adoption or guardianship exit’s slots from the leaving family home’s caregivers (the
primary first, a co second); an exit leaving a kinship household or a congregate row has none.
The (e)(1) exception: a child already in a living arrangement when the agency’s responsibility arrives is
recorded with that arrangement’s started_at = removal_at — the voluntary placement agreement or court order
that gives responsibility is the removal (§1355.44(e)(1), (d)(1)). A child on the run at that moment is
P-B2’s (runaway rows).
The AFCARS export (P-D1, #2119, #2120)
P-D1 built GET /v1/placement/afcars-export (#2119; #2120 added the fact
kinds). Its full read rules are under Removal episodes, exits and living arrangements (P-B1, #2018–#2024, ADR-079 D2–D4). Only the bare craig-reporting service principal may call it:
any other caller, or a relayed (channel) token, is 403 before any read.
-
Cohort. Each child with an episode live at
as_ofwhose removal is beforetoand whose exit is absent or not beforefrom.fromandtoare local midnights;as_ofis at least 5 minutes in the past. -
Rows.
episode,arrangement,trafficking_statement,law_enforcement_report,health_window,education_windowandhealth_assessment_visit, under thekindtag, in(child_id, kind, row_id)order.limitbounds rows (1..=1000);nextis an opaque cursor over the last row, present only when the page is full. -
As of. Ledger rows read as they stood at
as_of. Arrangements, caregiver bindings and health records are fenced on their stamps, and so are the two ends (ended_recorded_at, #2187). The arrangement facts and a health record’s visit read through their prior-value revisions (#2188). No placement column reads current, so the pages of one walk agree. A page’s statements run in oneREPEATABLE READtransaction (#2422), so a commit landing mid-page is wholly seen or wholly unseen by that page. -
Audit. Each non-empty page stages one
placement.afcars_releasedin its read transaction:requestor,purpose,child_ids(the page’s distinct children),child_count,from,to,as_of. The body isCache-Control: no-store.
Partner-reported education records (#3188)
Migration 20261129140000_education_partner_reports.sql (plan lifecycle-journeys
D4). An education agency’s report about a child is kept apart from education_records. A worker’s record is read by
caregivers through the portal, open to their change proposals and scoped by admin unit; the partner’s data is view
only, for the staff assigned to the child. So it has its own table, its own authorization resource type
(education_partner_report) and no route in common with the worker’s record.
-
A report lives as long as its listing. craig-exchange admits a partner’s record only under an open listing: a row of its recipient ledger, the child as this deployment named them to the partner under one custody episode.
education_partner_reports.listing_idis that row’s id. A listing ends once (custody closes, the identifier the partner knows the child by ends, the child leaves the stage), and craig-exchange stagesexchange.listing_endedin the transaction that ends it. -
The write.
POST /v1/placement/education/partner-reportsadmits only the barecraig-exchangeservice principal. In one transaction it answerslisting_ended(200) for a listing recorded inended_partner_listings,stale(200) when the child’s live row for the interface is as of a later day or is this same report, andapplied(201) otherwise: the held facts on a later day move the row’sas_of(and itslisting_id, when the child was listed again), and different facts withdraw the row assupersededand insert a new one.received_atis when the facts were first received, so a row is one stretch of unchanged facts. The body carries no idempotency key: posting a report twice leaves one row. -
The end of a listing. The inbox handler of
exchange.listing_endedrecords the listing inended_partner_listingsand withdraws the live rows under it aslisting_ended. -
Either order. The write and the handler both take
pg_advisory_xact_lockon the child (education-partner-reports:<child>) and then on the listing (partner-listing:<listing>). A report that waits behind its listing’s end finds the listing recorded and is refused; an end that waits behind a report finds the row and withdraws it. The child lock also keeps two posts from racing to be the one live row, whichuq_education_partner_reports_live((child_id, interface) WHERE withdrawn_at IS NULL) holds in the database. -
The read.
GET /v1/placement/education/partner-reports?child_id=answers the child’s live rows after areadcheck oneducation_partner_report. The check’s ref carries the worker and supervisor of the child’s case: thecase_assignmentsrow of the case of the child’s latest live removal episode. A child with no live episode, or one whose case the projection does not know, has neither, so only a rule keyed on a role alone admits. The check runs before the read, so a refused caller learns nothing about whether a report exists. -
Events.
placement.education_report_received(report_id,child_id,listing_id,interface,as_of; the posting service’s create, or its update when the report moved a held row) andplacement.education_report_withdrawn(the same ids,interfaceandreason; the posting service’s act when its report superseded the row, the system’s when the listing ended). Neither carries a school, a district or a grade. -
Nothing else reaches the rows. The worker’s education list, the caregiver portal’s projection, the field-proposal flow and the unit heals read and write
education_recordsonly.
Every column is Plaintext: a school’s name, a district and a grade for a child id; no name, date of birth or identifier value.
Key Indexes
-
idx_placements_case— find placements by case -
idx_placements_child— find placements by child -
idx_placements_foster_home— find placements by home -
idx_placements_foster_home_active— #1132 partial index(foster_home_id) WHERE status = 'active': the occupancy recompute -
idx_placements_status— filter by placement status -
idx_placements_created_at/idx_foster_homes_created_at— #3170(created_at): the placement list’s and the home list’s default sort (ORDER BY created_at DESC LIMIT n), read in index order so a page’s cost does not grow with the table -
idx_placements_episode— #2018(episode_id): an episode’s arrangements (the retraction’s arrangement probe, the episode-sideck_arrangement_in_episodescan) -
idx_placements_kinship_household— #2058 partial(kinship_household_id) WHERE kinship_household_id IS NOT NULL: a household’s arrangements (the portal child scope, the internal bindings read) -
excl_placements_child_arrangement— #2018 GiST exclusion(child_id =, tstzrange(started_at, ended_at, '[)') &&) WHERE activated_at IS NOT NULL AND status <> 'retracted': a child’s effective arrangements never overlap (409arrangement-overlap) -
uq_placements_one_replacement— #2020 partial UNIQUE(replaces_placement_id) WHERE replaces_placement_id IS NOT NULL AND status <> 'cancelled': at most one non-cancelled replacement per retracted arrangement (the unmapped DB twin of 409invalid-replacement, whosereplacement_takenprobe reads the same predicate) -
idx_removal_episodes_child/idx_removal_episodes_case— #2018(child_id, removal_at DESC)for the child’s episode list,(case_id)for the case-keyed heals -
excl_removal_episodes_child_window— #2018 GiST exclusion(child_id =, tstzrange(removal_at, exit_at, '[)') &&) WHERE retired_at IS NULL: a child’s live episodes never overlap (409episode-overlap) -
uq_removal_responses_one_successor/uq_removal_responses_one_live— #2018 partial UNIQUE(supersedes_id) WHERE supersedes_id IS NOT NULL(a response has at most one successor) and(episode_id) WHERE retired_at IS NULL(one live removal response per episode) -
uq_exit_responses_one_successor/uq_exit_responses_one_live— #2019 partial UNIQUE(supersedes_id) WHERE supersedes_id IS NOT NULL(an exit response has at most one successor) and(episode_id) WHERE retired_at IS NULL(one live exit response per episode) -
idx_foster_homes_admin_unit— admin-unit-based home search (county/tribal region) -
idx_foster_homes_status— license status filtering (matching algorithm) -
foster_homes_active_license_expires_idx— #1641 partial index(license_expires) WHERE license_status = 'active': the effective-status derivation’s scan and the expiry sweep’s candidate selection -
foster_home_training_type_expires_idx— #1641 partial index(foster_home_id, training_type, expires_at) WHERE active: the #1642 currency derivation AND the sweep’s training candidate selection (GROUP BY (foster_home_id, training_type),HAVING max(expires_at) ⇐ today + lead_days) -
foster_home_expiry_notices_once_per_key— #1641 UNIQUE(foster_home_id, kind, expires_on, COALESCE(training_type, '')): the once-per-key notice ledger;foster_home_expiry_notices_home_idxis the FK-side per-home index (the cascade delete and per-home lookups) -
idx_kinship_options_case— kinship options by case -
idx_placements_assigned_worker/idx_kinship_options_assigned_worker— partial indexes(assigned_worker_sub) WHERE assigned_worker_sub IS NOT NULL: the assigned-worker list scope -
idx_placements_supervisor_sub/idx_kinship_options_supervisor_sub— #1367 partial indexes(supervisor_sub) WHERE supervisor_sub IS NOT NULL: the supervisor list scope -
idx_placements_admin_unit/idx_kinship_options_admin_unit— #1901 partial indexes(admin_unit) WHERE admin_unit IS NOT NULL: the U2 (#1903)admin_unit = ANY($n)list binds of the unit scopes (theassigned_worker_subprecedent);case_assignments.admin_unithas none — the projection is read bycase_id(PK) only -
idx_education_records_child— educational history by child -
uq_education_partner_reports_live— #3188 partial unique(child_id, interface) WHERE withdrawn_at IS NULL: one live partner report per child and interface -
idx_education_partner_reports_listing— #3188 partial(listing_id) WHERE withdrawn_at IS NULL: the withdrawal on a listing’s end -
idx_health_records_child— health visit history by child -
idx_health_records_next_due— partial index onnext_due_date < now()for the overdue-appointments endpoint -
idx_education_records_admin_unit/idx_health_records_admin_unit— #1909 (b) partial indexes(admin_unit) WHERE admin_unit IS NOT NULL: the unit-scoped list binds -
idx_education_records_unit_heal/idx_health_records_unit_heal— #1909 (b) partial indexes(unit_episode_id) WHERE admin_unit IS NULL: the unit heals' join -
idx_placement_fact_revisions_placement_superseded/idx_health_record_revisions_record_superseded— #2188(<parent>_id, superseded_at, id): the export’s as-of probe (the earliest revision superseded afteras_of) -
excl_child_health_facts_window/excl_child_education_facts_window— #2084 GiST exclusion(child_id =, daterange(effective_from, effective_until, '[)') &&) WHERE retired_at IS NULL: a child’s live windows never overlap (409ledger-window-overlap) -
uq_child_health_facts_one_open/uq_child_education_facts_one_open— #2084 partial UNIQUE(child_id) WHERE effective_until IS NULL AND retired_at IS NULL: at most one live open window per child (409ledger-window-overlap) -
uq_child_health_facts_one_successor/uq_child_education_facts_one_successor— #2084 partial UNIQUE(supersedes_id) WHERE supersedes_id IS NOT NULL: a row is corrected at most once -
idx_child_health_facts_child_window/idx_child_education_facts_child_window— #2084(child_id, effective_from): the open-row, at-date and overlap reads per child -
idx_home_documents_foster_home— documents by foster home -
caregiver_bindings_home_person_open/caregiver_bindings_household_person_open(#2058; wascaregiver_bindings_placement_person_open) — #1848 partial UNIQUE(unit, person_id) WHERE ended_on IS NULL: one OPEN binding per caregiver per unit (a second create is the typed 409);caregiver_bindings_person_idxserves the portal scope join -
excl_caregiver_bindings_person_unit_window— #2058 GiST exclusion(COALESCE(foster_home_id, kinship_household_id) WITH =, person_id WITH =, daterange(effective_from, ended_on, '[)') WITH &&): one person’s bindings on one unit never overlap (409caregiver-binding-overlap; created after the open-person unique, so a second OPEN binding still answers 409duplicate-resource; a cancel is an empty range) -
portal_invitations_open_by_binding— #1848 partial index(binding_id) WHERE redeemed_at IS NULL AND revoked_at IS NULL: the end-binding cascade and the "newest open invitation" projection -
portal_invitations_create_request_id— #1848 UNIQUE: the ADR-062 one-time-secret LIFETIME backstop (a replayedclient_request_idcan never mint a second code once the 30-day claim window has pruned the claim) -
caregiver_identities_subject_live/caregiver_identities_person_live— #1848 partial UNIQUEWHERE revoked_at IS NULL: one live portal identity per subject and per person (the enrolment 409) -
pending_edits_fhp_one_open— #634 partial UNIQUE(target_id, field) WHERE decision = 'pending': one OPEN proposal per governed field of a row — a second propose while one waits is the typed 409field-proposal-pending(the store maps the violation by constraint NAME); a decision frees the slot -
pending_edits_fhp_queue— #634(decision, proposed_at): the staff queueGET /v1/placement/field-proposals?decision=(oldest first) -
pending_edits_fhp_unit— #634(unit_id, decision, proposed_at): the portal unit detail’sproposalsride-along (pending rows + those decided in the last 30 days)