ADR-079: AFCARS Placement Capture — The Shared Ledger Core, Removal Episodes with First-Recording Responses, the Living-Arrangement Lifecycle and the Exit as the Home of (g)

Status

Accepted (2026-09-26). The plan landed as P-B1 of the #949 program (epic &99; the first of P-B’s two gated pages, #1963) in thirteen MRs — U0 !1714 (the plan page + this ADR, Proposed 2026-09-24), U1a !1715 (the golden, test-only) and !1716 (#2015, the lift), U1b !1717 (#2016, closes #2009), U2 !1718 (#2017), U3 !1719 (#2018, closes #1778), U4 !1720 (#2019), U5 !1721 (#2020), U6a !1722 (#2021), U6b !1723 (#2022), U6c !1724 (#2023), U7 !1725 (#2024) and U8 !1726 (#2025, the close-out); plan: AFCARS Placement Capture I (#1963). Drafted FIRST per the draft-first path as U0 of #1963. The plan page was approved in plan mode on 2026-09-24 as rev 4 after a five-lane census and its critic, a contextless round 1 (21 blockers), a two-verifier check pass over rev 2, a verification pass over rev 3, the maintainer’s 14-finding gate on rev 3 and a verification pass over rev 4; rulings R-B1–R-B21 were approved as recommended. The As-built notes under the decisions record where the merged tree differs from the text as approved (each traces to a plan-page erratum, except the strict act bodies under D2, which no erratum recorded). D1–D4 are the plan’s D1–D4. P-B’s element capture (the arrangement vocabulary, per-arrangement and provider facts, removal facts, the (h) group, health / education, group (i)) is P-B2’s (#2026) and P-B3’s (#2052), each on its own page and gate (§ Amendment (2026-09-26, #2026); P-B3’s: § Amendment (2026-09-28, #2052), Accepted 2026-09-30). P-B3’s close-out (!1761) completes P-B and closes #1963. The class-3 columns read as of as_of (the record stamps, the fact and health revisions) are § Amendment (2026-10-05, #2131), Accepted 2026-10-05.

Context

The AFCARS 2020 out-of-home care file (45 CFR 1355.44, as transcribed into rulesets/federal/federal-afcars-2020.json 1.1.0) assigns placement 68 element rows. §1355.43(b)(2) asks "the most recent information and all historical information" for groups (d)–(i): every removal, every living arrangement and every exit is its own row. The 2026-09-23 census found none captured: placements is the only arrangement record, carrying a per-row removal_date DATE and removal_reason written at create and never correctable, five CTW / reasonable-efforts columns no reader consumes, a per-placement permanency_goal, status planned | active | ended, a client-supplied immutable started_at and no activation instant. Cancelling a planned placement is planned → ended and publishes placement.ended; end_reason mixes arrangement moves with episode exits; nothing prevents two concurrent active placements for one child. There is no removal episode, so there is no home for the removal date d)(1, the date the removal was first recorded d)(2, the exit g)(1, the date it was first recorded g)(2, the exit reason g)(3 or the transfer agency type g)(4. Program R14 requires each "transaction date" to be the instant the response was FIRST recorded, immutable under correction.

craig_placement has never bumped its schema_compat_floor and has no btree_gist, no row-mutation trigger and no field registry. financial binds placement.activated (billing from started_at, the rate keyed on placement_type) and placement.ended (void, tombstone and two #1070 guardianship WARN arms), and witnesses guardianship activation on the anchoring placement’s status = ended + end_reason = guardianship. craig-web and craig-placement both decode status through strict enums.

ADR-078 D1’s correction model (window and event ledgers; supersede / retire / close; the btree_gist exclusion; the two refusal triggers) is implemented in about 3,050 lines private to craig-cases, typed to DATE event times and to `LedgerRetiredReason’s court-order tokens; P-C’s ledger rows carry no retiring or closing actor (#2009).

Constraints the design inherits: claim_first is the first statement of every write’s tx (ADR-062); a DROP or a write-breaking CHECK bumps the floor in that migration’s own file (ADR-063 D3); a case-bound row carries the creation-time admin_unit stamp and a root birth takes lock_case_assignment before its FOR SHARE projection read (ADR-077 D6); the #1187 / ADR-060 rule re-checks the authorizing assignment under the row lock; federal text binding every jurisdiction lives in rulesets/federal/ (ADR-072 § Amendment — #949); a routing key lands with its row, parsers and consumers before producers (ADR-003).

Decision

D1 — The ADR-078 correction model is lifted into shared crates, not copied

Two crates hold it: craig-ledger-contracts (no sqlx; the wire — LedgerRow<K, F, R>, EventRow<K, F, R>, the statement / correction / retraction / close bodies, the as-of and period queries, the RetiredReason trait, and a CONCRETE EventAsOfQuery (as_of: Option<NaiveDate>: utoipa’s IntoParams derive cannot take a generic field, so placement declares its own instant-typed query)) and craig-ledger (the store traits LedgerFilter<K>, LedgerTable, KeyedTable, WindowLedger, EventLedger and EventTime, the window / event acts and reads, the SQLSTATE → typed-409 mapping, the claimed-act skeleton and the ledger intent scopes). craig-cases keeps every public name and schema by type aliases. Each ledger declares a LOCAL, zero-sized table type in its own service that implements the store traits with associated key, route-key, facts, time and reason types and owns its codecs (key_from_row, bind_facts, facts_from_row, event_time, inherit, and a LedgerFilter impl for every identity it filters or locks by — its key, its route key, a foreign list filter), so no shared trait is ever implemented on a foreign type and the orphan rule holds. The event time is generic through EventTime (NaiveDate for every cases ledger, DateTime<Utc> for the placement responses); the core is reason-agnostic (each service’s wire enum implements RetiredReason, and each table’s CHECK closes the retired-reason set); first_recorded_at is an opt-in store extension (EventLedger::FIRST_RECORDED) served beside, never inside, EventRow. deny_pure_service moves to craig-api. A golden over the cases OpenAPI document and every cases ledger event payload proves the lift byte-neutral.

#2009 closes on the lifted core (option 1): every cases ledger row gains retired_by, every window row closed_at + closed_by (set only by a closing UPDATE — the close act or a CHANGE’s implicit close), every ledger event payload carries user_id, and every writer — including the court-order sweep’s retirement of review rows — names its actor. The migration refuses on any retired or closed row (none has a truthful actor) and bumps the floor last.

Why hard to reverse. Two services' ledgers, their triggers and their wire now share one implementation and one trait surface; un-sharing means two divergent copies of the correction model, the exact drift the lift exists to prevent.

As-built (#2015, U1a; #2016, U1b): the moved claimed-act skeleton (crates/craig-ledger/src/act.rs: Ctx, RoutePath, ClaimedAct, RetractAct, row_legs) carries no R14 hook — placement’s run reads the SUCCESSOR’s first_recorded_at, equal to the chain root’s by the BEFORE INSERT trigger — and LedgerRoute, EventRoute and the generic handlers stay in craig-cases (services/craig-cases/src/api/ledgers/). EventTime for DateTime<Utc> landed in U3 with its at-or-before-now refusal (crates/craig-ledger/src/store/mod.rs); deny_pure_service lives in crates/craig-api/src/guards.rs. U1a landed in two MRs: the golden the_lift_changes_no_cases_route_or_event_byte (services/craig-cases/tests/api/ledger_lift_golden.rs, battery-proven on the pre-lift code), then the lift. U1b’s migration (services/craig-cases/migrations/20260925120000_ledger_actors.sql) is additive, yet its floor bump is required: the re-created guards refuse (23000) every N−1 close, CHANGE, correction, retraction and sweep UPDATE, because a BEFORE ROW trigger fires before the CHECK. The shared refuse_event_row_mutation() body and the core RETIRE also write retired_by on placement’s two response ledgers. The byte-equality test the_trigger_functions_are_byte_equal_across_databases (services/craig-placement/tests/constraints/removal_episodes_migration.rs) keys on the FUNCTION refuse_event_row_mutation() RETURNS trigger line, so a migration that only attaches the guard never counts as its definer. ADR-078 § D1 Amendment records the cases side.

D2 — A removal episode is an identity row; its removal and exit answers are immutable first-recording responses

removal_episodes is the identity row, keyed by the child ("each removal of a child", §1355.44(d)(1)) with one owning case for life, carrying the CURRENT removal_at / exit_at instants (TIMESTAMPTZ; every reported date is the jurisdiction-clock date of an instant). The answers themselves are EVENT-ledger rows on the lifted core: removal_responses d)(1) and the removal manner, a CRAIG fact with no element) and exit_responses ((g)(1), (g)(3), (g)(4. recorded_at is DEFAULT now() and never read from a request; a BEFORE INSERT trigger sets first_recorded_at to a root’s own recorded_at and a successor’s predecessor’s, so (d)(2) and (g)(2) are the date of the live row’s first_recorded_at and no correction can move them; a correction may not move the event date past the chain’s first recording. A deferred constraint trigger proves at commit that the episode’s current instants equal its live responses'. Per child, live episodes never overlap (EXCLUDE USING gist on tstzrange(removal_at, exit_at, '[)'), exit_at > removal_at). A missed past episode is inserted atomically with both boundaries. Every episode or arrangement act takes one lock order — claim_first → (a root birth: lock_case_assignment) → the case’s case_assignments row FOR SHARE, compared with the pair authorization consumed (409 CONCURRENT_MODIFICATION) → the episode → the placement → the foster home — which the ADR-077 inbox heal shares. A retracted episode is inert (409 EPISODE_RETRACTED). Episodes reuse the Placement resource type.

Why hard to reverse. The episode is the unit every (d) and (g) row, every arrangement, P-D’s plan-to-episode assignment and financial’s guardianship witness key; the immutable first-recording stamps cannot be reconstructed once a mutable design has overwritten them.

As-built (#2018, U3; #2019, U4; #2021, U6a): services/craig-placement/migrations/20260925130000_removal_episodes_recut.sql creates btree_gist, removal_episodes and removal_responses and bumps craig_placement’s floor for the first time (uq_removal_episodes_identity backs the arrangements' composite FK (episode_id, child_id, case_id); uq_removal_responses_one_live holds one live response per episode); U4’s 20260925150000_exit_responses.sql is additive with no bump. The fact-bearing act bodies (the open, the removal correction, the exit record or correction, the historical episode, the cancel) are strict (deny_unknown_fields, crates/craig-placement-contracts/src/episodes.rs): a client-sent recorded_at is refused, not ignored as the plan’s R14 text put it, and the DB still stamps every recorded_at. The episode and exit retractions reuse the lenient craig_ledger_contracts::LedgerRetractRequest, which ignores an unknown key; a retraction writes no response row, so nothing it ignores is stored. Each act ends its run with SET CONSTRAINTS ck_arrangement_in_episode, ck_episode_current_instants IMMEDIATE, because a failure at COMMIT inside the claimed transaction would be a redacted 500: ck_arrangement_in_episode then answers the typed 409 ARRANGEMENT_OUTSIDE_EPISODE, and ck_episode_current_instants stays a 500 (an internal invariant no request can trip). EXIT_BEFORE_REMOVAL and LATER_EPISODE_EXISTS are the typed IMMEDIATE chk_removal_episodes_exit_after_removal and excl_removal_episodes_child_window; EPISODE_ALREADY_EXITED and EPISODE_HAS_OPEN_ARRANGEMENT are pre-checks under the episode lock; a (g)(4) mismatch is a 422. ck_episode_current_instants also refuses a retired episode that holds a live removal or exit response (the inert rule as a DB twin). The placement-row acts (the PUT, the cancel) re-check the row’s own assignment pair and take no projection lock (episode → placement → home); case.assignment_changed runs its unit heals, episodes first, before its reassigns; the backfill’s unit fill is autocommit per statement. EpisodeRow.exit is null exactly when exit_at is null, else the exit response its exit_at is from (on a retracted episode, the one retired with it). The open answers 201 on a fresh open and on a replay, the exit acts 200; the child list serves live episodes, and a per-row Read denial drops the row. An episode retract also retires its live exit, keeps exit_at on the retired row and publishes one removal_episodes / retracted. The historical episode (POST /v1/placement/episodes/historical, services/craig-placement/src/api/exits.rs) is a root birth under Action::Create with the open’s membership check; it publishes placement.episode_facts_changed for removal_episodes and for exit_responses, and has a CLI command and no web form. placement.episode_exited (crates/craig-placement-contracts/src/events.rs) is staged by the three exit acts and by the historical episode (with arrangement_ids empty), never by an episode retract. craig-security resolves every placement.episode_ key by episode_id.

D3 — Placements are episode-bound living arrangements with an explicit lifecycle

Every placements row names its episode (episode_id NOT NULL) and takes the episode’s case and child. activated_at is the DB instant of the activating statement, write-once on both activation paths (a birth-active create and planned → active); started_at stays the business instant ((e)(1), the billing anchor) and must lie in [the episode’s removal_at, the activation instant]. An effective arrangement (activated_at IS NOT NULL AND status <> 'retracted') lies inside its episode (a deferred constraint trigger) and never overlaps another of the same child (EXCLUDE USING gist; ended_at > started_at). Cancel is planned → cancelled only (never in the file, a cohort, a bed or a bill; planned → ended is removed); retract is active | ended → retracted for a row entered in error (kept as the record, voided in financial first); a MISSED past arrangement is born ended by a historical record that never bills, gates nothing and never occupies. A re-record may name the retracted arrangement it replaces, and financial re-anchors that anchor’s subsidy agreements to the replacement as an audited correction. Caregiver-binding creation on a placement unit and the retract both lock the placement row: a cancelled or retracted arrangement is never bindable, and a retract is refused while an OPEN binding keys it. The status additions (cancelled, retracted) are placement cutovers: placement’s own strict decoder makes each a floor bump with every replica replaced.

Why hard to reverse. Bindings, education records, financial anchors and the file’s (e) rows all key the arrangement identity and its states; a later change to what "effective" means re-derives every cohort, bed count and bill.

As-built (#2018, U3; #2020, U5): U3’s re-cut (20260925130000_removal_episodes_recut.sql) refuses on any existing placement, drops removal_date, removal_reason, the five CTW / reasonable-efforts columns and sibling_placements (closing #1778), and adds placements_started_by_activation (started_at ⇐ activated_at; activated_at is the transaction instant). The create refuses in the order garde → deny_pure_service → the episode lookup (404) → authz → shape, and the cancel answers PlacementCancelled; an invalid transition (planned → ended, a cancel of a row that is not planned, a retract of a row that is not active or ended) is the existing typed 400 INVALID_STATE_TRANSITION. U5’s 20260925170000_retracted_arrangements.sql is additive with a voluntary floor bump. The two replaced ended CHECKs became three (placements_ended_has_ended_at, placements_ended_at_when_ended_or_retracted, placements_end_reason_when_ended_or_retracted); the replacement FK is fk_placements_replaces … ON DELETE RESTRICT; the partial unique uq_placements_one_replacement is an unmapped DB twin (every re-record checks eligibility under the episode lock). BOTH re-records take replaces_placement_id, and an ineligible one is 409 INVALID_REPLACEMENT. The retract (services/craig-placement/src/api/arrangement_acts/status_acts.rs) answers 200 PlacementRetracted with retracted_from and refuses 400 before the binding 409. The historical record (services/craig-placement/src/api/arrangement_acts/historical.rs) answers 201 PlacementRecorded, types placement_type / end_reason as the craig-reference enums and checks ended_at ⇐ now() in its transaction; placement.recorded carries started_at. craig-security resolves placement.cancelled, placement.retracted and placement.recorded by placement_id. financial (services/craig-financial/src/inbox/anchor_replacement.rs) re-anchors last on every placement.activated outcome and on placement.recorded, in one attempt transaction with one financial.subsidy_anchor_replaced per agreement (created_by = "system"): a PENDING SG / NRSG agreement re-snapshots placement_started_on, an ACTIVE or SUSPENDED one moves only the id and WARNs, and a terminal one moves only the id. Its placement.retracted consumer raises the never-replaced WARN for every open agreement anchored on the retracted id. financial carries no migration, and every financial replica runs U5 before placement rolls. ADR-052’s #2020 amendment and ADR-003’s payments_voided cause placement_retracted record the financial side. Payments already issued on a retracted arrangement are #2041; a historical arrangement’s per-diem stays outside CRAIG (#2030, ruled 2026-10-06; see Consequences).

D4 — The exit is the one home of (g)(1)–(g)(4); financial’s guardianship witness moves onto it

An exit is recorded on the episode (refused while an arrangement is open, or when a live exit exists), never on an arrangement’s end reason; the arrangement that ends because responsibility ends takes the end reason left_care. The arrangement an exit leaves from is DERIVED — the episode’s latest effective arrangement by started_at — and never stored. financial moves in three drained units: U6a serves episode_exit on the eligibility read (non-null only for that latest arrangement) and publishes placement.episode_exited, with the guardianship WARN branches bound to it and a guardianship_ending_without_exit invariant; U6b’s witness requires the anchoring placement ended, a live guardianship exit, and the anchor’s ended_on == exit_on, with transfer_on = exit_on and the caregiver evidence date at exit_on, rolling only when the invariant is EMPTY; U6c truthfully rewrites each exit-token end reason to left_care where a live exit exists, refuses the remainder and narrows the end-reason set, placement first.

Why hard to reverse. Financial’s activation decision, the (g) rows and P-D’s exit cohorts all read the exit; a second home for the exit reason on the arrangement would reintroduce the ambiguity the move removes.

As-built (#2019, U4; #2021, U6a; #2022, U6b; #2023, U6c): ExitReason and TransferAgencyType are craig-reference enums (crates/craig-reference/src/enums.rs, the RemovalManner precedent), pinned to the dictionary and to chk_exit_responses_exit_reason, which never admits (g)(3) not_applicable. U6a serves PlacementSubsidyEligibility.episode_exit (crates/craig-placement-contracts/src/subsidy.rs). craig-web’s one-step handoff (services/craig-web/src/routes/placement/guardianship_handoff.rs) records the guardianship exit after the end and before the ERR termination, at the ONE transfer instant both writes carry (a date-only today is clamped to min(noon UTC, now)); it refuses a transfer date after the jurisdiction’s business today before the end, and it stops before any money act when the exit is refused. financial’s placement.episode_exited arms (services/craig-financial/src/inbox/guardianship_warns.rs) also raise the reason-blind and withdraw WARNs on a non-guardianship exit; the corrected-away / retracted WARN covers ACTIVE and SUSPENDED SG / NRSG, and the support-gap WARN needs no pending, active or suspended SG / NRSG. ADR-056’s #2021, #2022 and #2023 amendments record the financial and web side. guardianship_ending_without_exit compared the two INSTANTS (ended_at <> exit_at), stayed report-only (never in BLOCKING_INVARIANTS), joined the journey selectors at U6b and gated U6b through the environment sweep’s named FAIL line. U6b rolled financial (the witness, enforce_guardianship_finalized_witness in services/craig-financial/src/api/subsidy_activate.rs), then placement (the caregiver evidence date); a U6b rollback reverses that roll. U6c’s 20260926120000_end_reason_narrowing.sql SHARE-locks placements, removal_episodes and exit_responses for the file, audits each rewrite in the append-only placement_end_reason_rewrites before it rewrites, then runs the refuse-on-data guard and narrows the CHECK, in one transaction, bumping the floor last; PlacementEndReason is transfer | disruption | runaway | left_care. The web end form states a guardianship transfer as left_care plus a guardianship-exit box, and a plain left_care end records no exit; the historical record refuses a removed token 422, the PUT 400. Under the narrowed CHECK guardianship_ending_without_exit matched nothing, so it retired with its pin, its journey selector and placement’s half of u6b_requires_no_guardianship_ending_without_exit; financial’s half is now each_witness_refusal_arm_is_repaired_by_a_truthful_exit_act. placement.ended raises nothing for left_care, and a pre-U6c guardianship token takes the reason-blind, log-only arms. craig-financial rolls after placement, and a U6c rollback rolls craig-web back first, then restores craig_placement under an N−1 craig-placement. A report-only invariant for a left_care ending without an exit is #2046; the plain left_care end recording the exit is #2047. As built (2026-10-06, #2047): every web left_care end states its exit — the (g)(3) reason, and the (g)(4) agency type on a transfer, refused before any upstream call when incomplete — and craig-web records it with the existing exit act right after the end, on the ended row’s episode at the end’s one instant. A refused exit leaves the arrangement ended without one, and the API and the CLI can still end left_care without one.

Consequences

  • Pre-1.0 Changed / Removed per unit: the create contract (episode_id required; case_id / child_id derived), the cancel route replacing planned → ended, the new statuses, left_care, the removal / CTW / reasonable-efforts columns and sibling_placements dropped (#1778), the ledger actor columns (#2009), PlacementSubsidyEligibility.episode_exit, the narrowed end-reason set, and placements.permanency_goal with the portal goal token (U7, #2024: the drop services/craig-placement/migrations/20260926180000_placement_goal_drop.sql bumps the floor with no guard, the foster_home_portal roster goes from seven tokens to six, and the create intent is PlacementIntentV4). Three units refuse on existing data — U1b (a retired ledger row, or a window row with an end), U3 (any placement row), U6c (an exit-token row the audited rewrite leaves) — pre-1.0; the devstack wipes and reseeds once per such unit.

  • Every new column is Plaintext. The (d)(4) removal circumstances, trafficking, health and ICWA columns stay Plaintext by decision: ADR-049 § Amendment — #2000 (ruled 2026-10-06) settles the R-B13 deferral.

  • No P-B1 table (removal_episodes, removal_responses, exit_responses, placement_end_reason_rewrites) or added column is an ADR-037 governed token. Verified at the close-out: GOVERNED_FIELDS (crates/craig-placement-contracts/src/field_ownership.rs) holds six tokens, and placements.status is the one placement token.

  • P-D’s inputs (#1965; P-B1 implements none of them):

    • a back-dated API removal is honestly tardy under R14 — its (d)(2) is the date it was first recorded — so P-D’s lifecycle e2e must expect it (plan § Rollout + risks);

    • the same-day plan rule (plan D6 / R-B8, ⁂ #1073): P-D assigns a permanency plan by its established_on DATE to the episode whose closed date interval [removal date, exit date] (jurisdiction clock; an open episode’s upper bound is unbounded) contains it, and a date inside two or more episodes goes to the LATEST; no episode_id lands on permanency_plans. Its input test a_plan_on_a_same_day_exit_and_re_entry_goes_to_the_later_episode is P-D’s (plan § Test matrix), recorded, not implemented in P-B1;

    • the population table (plan D6 / R-B9): the 24-hour threshold is federal text; the P-A2 dictionary erratum #2027 — which also carries the §1355.20 / .41 / .42 pins (plan § Status, erratum 2026-09-24) — adds a population table citing the pinned §1355.42(a); placement stores instants and P-D evaluates. As built (#2027), only §1355.42 is pinned — no population cell rests on §1355.20 or §1355.41;

    • the release-audit emitter (plan D6 / R-B11): P-B1 landed only the key placement.afcars_released (U2, #2017 — its strict payload in crates/craig-placement-contracts/src/events.rs, its ADR-003 row and craig-security arm); P-D’s afcars-export stages it in its own transaction before responding, no-store;

    • (g)(3) not_applicable (plan D4): exit_reason excludes it; P-D answers it from "no live exit".

  • The plan names no P-E (#1966) input.

  • A historical arrangement’s retroactive per-diem stays outside CRAIG (ruled 2026-10-06, #2030; R-B20 stands): CRAIG writes only an arrangement’s first-period per-diem, on placement.activated, which a historical record never emits, and later periods are paid outside it (#1115 pays subsidy agreement months, not placement per-diems). Payments already issued on a retracted arrangement are #2041, which the ruling leaves unaffected.

Open questions

  • ⁂ #1073: arrangements never overlap per child (respite is not a second arrangement); a re-recorded exit after a retraction carries its own (g)(2); a plan dated on a same-day exit + re-entry belongs to the later episode.

  • Resolved (2026-10-06, #2028): an open episode never moves to another case of the same agency. D2’s one owning case for life (R-B19) is final as CRAIG’s best reading (⁂ #1073): an in-agency transfer is a worker reassignment on the same case, a transfer to another agency is the (g)(3) exit, and the case status transferred means another jurisdiction. The episode row guard keeps refusing a case_id UPDATE.

  • Resolved (2026-10-06, #2029): the placement-facts hop refuses a closed or transferred case (409 case-closed), relayed by every placement consumer. See ADR-073 § Amendment (2026-10-06, #2029).

Alternatives considered

  • A placement copy of the correction model, or a lighter placement-only model — rejected: two implementations of one doctrine drift, and the lighter model loses the correction / retraction audit the file’s history needs.

  • One episode row updated in place — rejected: R14’s first-recording stamps must survive correction.

  • A trigger forcing recorded_at = now() — rejected: the seed would be tardy; the request surface carries no stamp instead.

  • The arrangement end reason as the exit’s home — rejected: an exit belongs to the episode, and the end reason mixed moves with exits.

  • Cancel admitted from active — rejected: an activated arrangement was real or was an error; cancel is for what never happened.

  • episode_id on P-C’s permanency_plans — rejected: cases would need its first placement client, and a date interval decides.

  • A placement-side projection of the portal goal label — rejected: the label is never rendered; the token is retired.

  • Refusing to retract an arrangement a subsidy agreement anchors — rejected: an error must be correctable; the replacement protocol re-anchors instead.

Amendment (2026-09-26, #2026) — the arrangement vocabulary, setting identity and the element map (Accepted, 2026-09-27)

Standing. Proposed 2026-09-26 with the approved plan AFCARS Placement Capture II (#2026) (P-B2 of #949, epic &99; rev 2, approved in plan mode 2026-09-26; rulings R-B22–R-B28, R-B32 and R-B34–R-B36 as recommended). Accepted 2026-09-27 at that plan’s close-out. The plan landed in nine MRs — U0 !1728 (the plan page and these amendments), U1 !1730 (#2054), U2 !1731 (#2055), U3 !1732 (#2056), U4 !1733 (#2057), U5 !1734 (#2058), U6 !1735 (#2059), U7 !1736 (#2060) and U8 !1737 (#2061, the close-out). The As built notes below record where the merged tree differs from the text as approved; each traces to a plan-page erratum or a unit’s recorded decision. P-B3 (#2052, AFCARS Placement Capture III) amends this ADR again for the element capture.

What changes. The plan’s D1–D6 and D11 are recorded here:

  • D1 — one rule for where a fact lives. A fact lives on the row of its pinned grain, in the ledger class that row already has: per arrangement a placements column (the setting, its identity and the (e)(3) flags never change — retract
    re-record); per removal / exit a response column (a correction; (d)(2) / (g)(2) never move); per episode a P-B3 event ledger; per child a P-B3 window ledger; a person’s fact stays in cases, reached through a person placement names. Every stored closed set is a craig-reference enum pinned to its dictionary set and its CHECK; at rest Plaintext; nothing joins the ADR-037 foster_home_portal surface.

  • D2 — providers, the vocabulary, setting identity (R-B23, R-B36). foster_homes.provider_kind is family_home | congregate_facility (immutable; license_type NOT NULL iff family_home): a congregate provider is a foster_homes row, not a separate registry, so occupancy, the capacity guard, per-diem billing and the activation consult hold unchanged. PlacementType is foster_family_home plus the 14 (e)(4) tokens verbatim (trial_home_visit → placed_at_home), with no crosswalk, in three classes: family, congregate, non-caregiving. (e)(3) is six ffh_type_<category> columns, NOT NULL iff family; (e)(2) is a generated column. Every caregiving arrangement names its setting identity — a family row a family_home provider or a kinship household, a congregate row a congregate_facility provider, a non-caregiving row neither (chk_placements_setting_identity and a provider-kind trigger; 400 SETTING_PROVIDER_MISMATCH).

  • D3 — non-conventional periods are rows (R-B25). A run, whereabouts unknown, a trial home visit and a juvenile-justice, medical or psychiatric stay are arrangements with that (e)(4) setting under D3’s containment and non-overlap; is_caregiving() is false for exactly those six. Their activation runs neither the cases placement-facts hop nor the matching consult, and financial logs them without staging missing_foster_home. Respite is still not a row.

  • D4 — the kinship household (R-B26). A case-less, admin_unit-scoped, immutable kinship_households row is the identity of a home-less family arrangement (placements.kinship_household_id); siblings of two cases in one relative home share it; it is read and bound as a home (FosterHome / FosterHomeCaregiver refs). Caregiver bindings key foster_home_id XOR kinship_household_id, and one person’s bindings on one unit never overlap (EXCLUDE; 409 CAREGIVER_BINDING_OVERLAP). ADR-076 D5 is amended (its § Amendment (2026-09-26, #2026)).

  • D5 — financial (R-B24, R-B27). The rate class is state-bundle data over the setting and the (e)(3) flags, returning today’s payment types; ERR qualifies on a family anchor with the relative or kin flag and without the licensed flag; SG / NRSG creates refuse a non-caregiving anchor. The residence run of a caregiving arrangement — the maximal sequence of its episode’s effective arrangements, each starting on the jurisdiction date the previous one ended, caregiving at both ends, every caregiving member naming the arrangement’s setting identity, non-caregiving members only between — is derived at read time and never stored, carried by an event or moved (ADR-052’s re-anchor is unchanged); the subsidy-eligibility read serves it as residence for an effective caregiving anchor. ADR-056’s residence window is the run (its § Amendment (2026-09-26, #2026)).

  • D6 — provider facts through bindings (R-B28). (e)(9)–(e)(18) are no column: the first two distinct persons bound to the arrangement’s identity on its (e)(1) date, ordered by role (primary, co), effective_from, created_at, id, and their cases facts at that date. Placement’s export answers the two slot person ids; cases' persons/afcars-export admits them (P-D, #1965).

  • D11 — the element map. Mapping gains Person and Derived; placement owns 67 rows (OWNED_ELEMENTS), 18 are owned elsewhere (OWNED_ELSEWHERE: P-D, P-E), and a rules check partition finding holds 57 + 67 + 18 = 142. (b)(20) / (b)(21) are placement-owned and derived by P-D (R-B32); (h)(14) is P-E’s (R-B34).

This AMENDS D4 (R-B27). D4’s derived exit arrangement stays the base — episode_exit is served for the episode’s latest effective arrangement (:186, "non-null only for that latest arrangement") — and is also served for an arrangement whose residence run’s last member is that arrangement: an earlier arrangement of the same run is witnessed; one of another setting identity, or across a gap, still gets null. The witness’s "the anchor’s ended_on == exit_on`" (:188`) becomes residence.ended_on == exit_on, and the activation’s residence floor reads residence.started_on in place of the placement_started_on snapshot, which stays the ERR coverage start. It SUPERSEDES D3’s binding lock (:148-150): the binding create no longer locks a placement row and the retract no longer refuses on an open binding (P-B1’s ARRANGEMENT_HAS_BINDINGS and the retract’s binding 409, :168, retire) — no binding keys an arrangement.

As built (U1–U5, U7; #2054–#2058, #2060). D11 (U1): the map is craig_placement_contracts::afcars (OWNED_ELEMENTS, 67 keys; AFCARS_CAPTURE_STAGE = B2U5 since U5; LAST_UNIT = B3U5); OWNED_ELSEWHERE (18) lives in craig_reporting_contracts::afcars_capture; P-B1’s stage variants are B1U3 / B1U4. The rules check partition finding (xtask/src/cmd/afcars_partition.rs) holds 142 = 57 + 67 + 18 and reports P3 skipped until placement reaches LAST_UNIT. CARDINALITY_TABLES gains no kinship_households row: (b)(21) is Derived over placements columns (plan erratum, U5). D2 (U2, U3): provider_kind is immutable by trigger (trg_foster_homes_provider_kind_immutable; an update naming another kind is 400 structural-mismatch) and the matching query requires it. U2’s migration widens with no guard, its floor bump still required (an N−1 insert omits the column), and it rolls placement first (plan erratum). A congregate provider is refused by the binding create and the training record (422); the portal has no refusal of its own, since a portal act reaches a unit only through a current binding. craig-reference’s SettingClass, with PlacementType::setting_class() / is_caregiving(), is the one class table. The provider-kind trigger is ck_placements_setting_provider_kind (400 setting-provider-mismatch); a non-caregiving row naming a provider is 400 structural-mismatch and a congregate row without one 400 required-field-missing. A family body with ffh_types: [] is admitted (six does_not_apply); an absent one is 400. craig-security rolls nothing for U3 (plan erratum). D3 (U4): both activation paths skip on !is_caregiving(), never on a missing home; financial’s skip is the first arm of its billing target (an info log, no quality signal). D4 (U5): the migration runs in place (no wipe) behind a four-shape guard; P-B1’s retract binding refusal and the invariant placement_retracted_with_open_binding.sql are gone (ADR-076 § Amendment, its as-built note). Seed (U7): the devstack seed binds a primary on every family home (plus a co on each that accepts sibling groups) and on every kinship household, from the earlier of the home’s licensed_at and the unit’s first seeded arrangement’s start. Consequences, beyond the list below: U2 made provider_kind required on the matching query; U3 added ffh_types to the subsidy-eligibility read, which ERR’s rule reads; U5 added kinship_household_id to the placement row, the placement.created event and the historical record’s PlacementRecorded answer (the placement.recorded event does not carry it). "Refuse on existing data" is U3’s guard over any placements row (a devstack wipe) and U5’s over its four shapes only.

As built (U6, #2059). craig-placement reads the episode’s effective arrangements in ONE statement (store::exit_responses::episode_arrangements, which replaces the P-B1 latest_arrangement_exit) and derives the run in a DB-free fn (residence::residence_run); the wire type is craig_placement_contracts::subsidy::ResidenceRun. episode_exit is served when the anchor is the last effective row or the run’s last member is. The #2023 rewrite’s "latest effective" rule stays pinned as history, apart from the run read.

Consequences. Pre-1.0 Changed / Removed per unit: provider_kind and the NULL-able license_type (U2); the placement_type re-cut, ffh_types on the bodies and on placement.activated / placement.recorded, and the rate-class read (U3, devstack wipe + reseed); caregiver bindings re-keyed from placement_id to kinship_household_id, PortalUnitKind / Unit::Placement → KinshipHousehold (U5); PlacementSubsidyEligibility.residence (U6). U3 and U5 refuse on existing data and bump the floor last in their own files; U2 bumps it with no guard. Every new column is Plaintext; nothing is governed. The plan’s ⁂ readings are logged on #1073; its P-D inputs on #1965. The pre-existing authorize-before-transaction race on binding end, invitation issue / revoke and identity revoke is #2053.

Amendment (2026-09-28, #2052) — the element capture (Accepted, 2026-09-30)

Standing. Proposed 2026-09-28 with the approved plan AFCARS Placement Capture III (#2052) (P-B3 of #949, epic &99; rev 2, approved in plan mode 2026-09-28 after a contextless round 1 (ship, 14 non-blocking findings) and the maintainer’s round 2 (13 findings, folded); rulings R-B29–R-B31 and R-B33 as recommended). Accepted 2026-09-30 at that plan’s close-out, which completes P-B and closes #1963. The plan landed in eight MRs — U0 !1742 (the plan page and this amendment), U1 !1743 (#2080), U2 !1754 (#2081), U3 !1755 (#2082), U4 !1758 (#2083), U5 !1759 (#2084), U6 !1760 (#2085) and U7 !1761 (#2086, the close-out). The text below records the merged tree, not the page as approved.

What changes. The plan’s D1–D6, as built:

  • D1 — per-arrangement facts (U1). (e)(5)–(e)(8) and (i)(5)–(i)(8) are sixteen nullable placements columns (NULL = unanswered), carried flat on the create and historical bodies, the placement read and the historical record’s PlacementRecorded answer. The placements PUT’s optional arrangement_facts is the complete state of all sixteen, on a planned, active or ended row (any other row is 400 invalid-state-transition, a row of a retracted episode 409 episode-retracted); a facts-only PUT stages no event and no field audit (nothing is governed). A fact its setting or a sibling fact does not admit is 400 structural-mismatch; (i)(8)'s gate is one family CHECK. No read of cases' ICWA projection gates the (i) inputs.

  • D2 — removal facts and trafficking (U2, U3; R-B29). (d)(3), (d)(4), (i)(1) and (i)(4) are 43 nullable removal_responses columns, so the removal response’s supersede chain carries them; the (i)(1)(ii) gate and the (i)(1)(iii) denial family (one CHECK) are 400 structural-mismatch. (d)(5)–(d)(6)(ii) live in two episode event ledgers on the lifted core — keyed episode_id with many roots, P-C D1’s supersedes_id / retired_reason / retired_note / retired_by columns, refuse_event_row_mutation() attached: episode_trafficking_statements (a statement is the complete state known on stated_on; a prior_reported_on after it is 400 ledger-fact-date-after-event, a CHECK behind the act’s refusal) and trafficking_law_enforcement_reports (one row per report; its dated ?as_of= list reads through craig-ledger’s `event::live_through). Every act answers 200, stages no audit event and publishes ONE placement.episode_facts_changed (EpisodeLedger gains both tables). An episode retract retires both ledgers' live rows in its transaction and stays ONE removal_episodes / retracted event; the replaced check_episode_current_instants() refuses a live row of either under a retired episode.

  • D3 — the adoption / guardianship exit (U4; R-B30). (h) less (h)(14) and (i)(10)–(i)(13) are 21 nullable exit_responses columns under two one-way family CHECKs — every (h) column only on an adoption or guardianship exit, every (i) column only on an adoption exit — beside the (h)(15) count-or-flag CHECK, the (i)(12) gate and the (i)(13) family gate (each 400 structural-mismatch). Two slot columns name the adoptive parents as cases persons (no FK); (h)(3)–(h)(12) map to their cases facts through the slots. A second slot without a first, a repeated person or a slot naming the child is 422 (the exit and its correction compare the child after authorize, through EpisodePath.child_id; the historical episode its body’s child_id). A fresh act naming a slot proves each exists with ONE cases-projection display_names read after the ADR-062 precheck — 422 no such person, 503 person-lookup-unavailable while cases is down; a replay answers from its claim before any cross-service read.

  • D4 — child facts (U5, U6; R-B31, R-B33). (b)(9) is health_records.health_assessment (BOOLEAN NOT NULL DEFAULT false), a visit flag required on the health create and optional on its PUT, mapped over the record’s visit date and its episode’s instants (NAMED_OVERRIDES; P-D evaluates it). (b)(10)–(b)(12) and (b)(14) live in two per-child window ledgers, child_health_facts (the (b)(10) leaves gated on child_has_a_diagnosed_condition by one family CHECK) and child_education_facts — placement’s first window ledgers, guarded by its first refuse_fact_row_mutation(), authorized on a child-keyed HealthRecord / EducationRecord ref; every act answers 200 and stages no event. The Tribe’s order of preference is two cases child_icwa_facts columns, tribe_order_foster_care and tribe_order_adoptive (one per 25 U.S.C. 1915(c) order), each only under court_determination = yes_icwa_applies: the garde body gate answers 422 validation-failed, so the two CHECKs are a belt with no typed mapper.

  • D5 — names. The twenty category columns over Postgres’s 63-byte limit take pinned <prefix>_<slug> names (eight in U1, five in U2, seven in U4); the element test admits a slug only for such a column.

  • D6 — no new key is dropped. Each idempotency intent a growing body feeds is replaced by its next version, with no dual decode — PlacementIntentV7 and HistoricalPlacementIntentV4 (U1), OpenEpisodeIntentV2, CorrectRemovalIntentV2 and HistoricalEpisodeIntentV2 (U2), ExitIntentV2 and HistoricalEpisodeIntentV3 (U4), HealthIntentV2 (U5) — and U6 re-pins cases' child_icwa_facts record and correct intents; a claim minted before a unit and replayed with a post-unit body is 409 idempotency-conflict. The new ledger acts hash through craig-ledger’s `spec_of (the event ledgers) and statement_spec (the window ledgers). Every key the plan adds is required on every create, historical, exit and correction body that carries it — null means unanswered, an absent key is 422 validation-failed — so an N−1 writer is refused rather than erasing; a web form carrying a fact block refuses a stale page through its facts_rev (b3u1, b3u2, b3u4, b3u6).

This extends D1 (placement’s lifted core gains two event and two window ledger tables) and D2 / D4 (the removal and exit responses gain their element columns; the exit’s family CHECKs are one-way, unlike chk_exit_responses_transfer_paired). With it placement reaches LAST_UNIT (B3U5, at U5) and maps every owned key, so the partition finding holds 142 = 57 + 67 + 18 with P3 over both maps.

Consequences. Pre-1.0 Changed per unit: the placement create and historical bodies (U1); the episode open, historical and removal-correction bodies and EpisodeRow.removal (U2); EpisodeLedger, the ledger set of placement.episode_facts_changed (U3); the exit, exit-correction and historical bodies and EpisodeRow.exit (U4); the health create body (U5); cases' IcwaFacts bodies (U6). U2, U3, U4 and U6 bump the floor voluntarily, each last in its own file — an N−1 correction would supersede the new answers with NULLs (U2, U4, U6), an N−1 episode retract would be refused at commit (U3). U1 and U5 do not bump: an N−1 writer never names the new columns (U1’s stay NULL, which every CHECK admits; U5’s DEFAULT false fills an N−1 health create, so it stays). Every new column is Plaintext; nothing is governed. #2000 ruled both of its holds on 2026-10-06: the sensitive columns stay Plaintext (ADR-049 § Amendment — #2000), and a facts PUT that changes a fact is attributed on its revision (§ Amendment #2131 D5, superseded_by). The plan’s ⁂ readings are logged on #1073, its P-D inputs on #1965; (h)(14) is P-E’s (#1966).

Amendment (2026-10-05, #2131) — the class-3 columns read as of as_of (Accepted, 2026-10-05)

Standing. Proposed 2026-10-05 with the approved plan AFCARS Source History (#2131) (of #949, epic &99; approved in plan mode 2026-10-05 after a contextless round 1 (no-ship, 2 blockers fixed, 17 findings folded), the maintainer’s round 2 (5 findings folded), a three-pass fold check and a closure check; rulings R-H1–R-H9 as recommended). Accepted 2026-10-05 at that plan’s close-out. The plan landed in six MRs — U0 !1814 (the plan page and these amendments), U1 !1815 (#2186), U2 !1816 (#2187), U3 !1817 (#2188), U4 !1818 (#2189) and the close-out (U5, #2190). The text below records the merged tree; its one As built note is under D4. The cases side is ADR-078's own amendment for #2131.

What changes. The plan’s placement-side decisions:

  • D1 — never edited in place (U3; R-H1). started_at is fixed at activation, so P-D1’s class-2 fence covers it; placement_type, the six ffh_type_* flags and the setting (foster_family_home, foster_home_id, kinship_household_id) are fixed at insert, as § Amendment #2026 D1 already rules (retract + re-record). Each leaves class 3 with no code.

  • D4 — write-once record stamps (U2; R-H5). placements.ended_recorded_at and caregiver_bindings.ended_recorded_at (TIMESTAMPTZ, on no response body) hold the DB instant of the statement that wrote the end or cancel, under four named CHECKs: placements_ended_recorded_pairing, caregiver_bindings_recorded_pairing, placements_ended_recorded_after_activation (>= activated_at) and caregiver_bindings_recorded_after_creation (>= created_at). update_placement and end_binding stamp statement_timestamp(), never now(), which an end begun before a racing activation would stamp before activated_at; the born-ended historical insert stamps now(), its own activated_at. The backfill takes the proven lower bound (activated_at, created_at), so a legacy end reads as known from activation and no past period moves. ARRANGEMENTS_SQL and both CAREGIVER_SLOTS_SQL predicates read CASE WHEN ended_recorded_at ⇐ $as_of THEN <end> END: an end or cancel recorded after as_of reads open. As built (U2, #2187): a placement cancel writes no end, so it leaves ended_recorded_at NULL; the cancel that is stamped is a binding’s (ended_on = effective_from). CAREGIVER_SLOTS_SQL takes the as-of end once, in a CROSS JOIN LATERAL, and both predicates read it.

  • D5 — prior-value revisions (U3; R-H2, R-H3). placement_fact_revisions (placement_id and the sixteen facts) and health_record_revisions (health_record_id, visit_date, health_assessment) are narrow (the parent’s types and nullability, no copied CHECKs), Plaintext and insert-only: placement’s refuse_revision_mutation() refuses UPDATE, DELETE and TRUNCATE for every role. update_arrangement_facts and update_health_record move their UPDATE into a CTE whose RETURNING carries the prior columns through Postgres 18’s old; a second CTE inserts them, stamped superseded_at = clock_timestamp() after the row lock, only when an export column changed. The export (ARRANGEMENTS_SQL’s facts, kind 7’s key predicate, `VISITS_SQL) reads the earliest revision superseded after as_of through a LEFT JOIN LATERAL, else the live row. No backfill: a row’s history starts with U3’s migration. Since #2000 (ruled 2026-10-06): a placement_fact_revisions row also carries superseded_by UUID NOT NULL, the acting worker (parse_actor_sub(claims.acting_worker())) whose facts PUT superseded its values, bound into the same revision INSERT. Migration 20261008120000_placement_fact_revision_actor.sql refuses on any existing revision (nothing recorded names its worker) and bumps the floor, required (an N−1 facts edit omits the column). Since #2231 (ruled 2026-10-08): a health_record_revisions row carries the same superseded_by UUID NOT NULL, the acting worker whose health PUT superseded its visit pair, bound by update_health_record into its revision INSERT. Migration 20261008130000_health_record_revision_actor.sql refuses on any existing revision and bumps the floor, required (an N−1 health edit omits the column).

  • The floor (R-H9). U2 bumps it as required (an N−1 end breaks the pairing CHECK), U3 voluntarily under ADR-063 D3 (an N−1 edit leaves no revision); each bumps last in its own file, and every placement replica is replaced before traffic.

This amends D3 (an arrangement’s end now carries two instants: ended_at the business instant, ended_recorded_at when it was written) and § Amendment (2026-09-28, #2052) D1: the sixteen facts stay a full-state PUT that stages no event and no audit, but their prior values are now kept. No wire shape changes.

Amendment — #2999 (2026-11-08): the configuration layers left CRAIG’s source

ADR-087 U4 (#2955) moved the configuration layers out of CRAIG’s source. A rulesets/<j>/<file> path above now names <file> in layer <j>: the federal, Georgia and Texas layers are the craig-config-{federal,georgia,texas} repositories, pinned in config-sources.lock and fetched to target/config/layers/<j>/ by cargo xtask config fetch, and the synthetic testonia layer is fixtures/config/testonia/. The decision above is unchanged.

Edit this page · latest