Plan: AFCARS Placement Capture I — Removal Episodes, Living-Arrangement Lifecycle, the Shared Ledger Core (#1963, P-B1 of #949)

Archive record

Merge requests: !1714 (U0 plan page + ADR-079 Proposed, Relates #1963) + !1715 (U1a golden, test-only, Relates #2015) + !1716 (U1a, Closes #2015) + !1717 (U1b, Closes #2016 / #2009) + !1718 (U2, Closes #2017) + !1719 (U3, Closes #2018 / #1778) + !1720 (U4, Closes #2019) + !1721 (U5, Closes #2020) + !1722 (U6a, Closes #2021) + !1723 (U6b, Closes #2022) + !1724 (U6c, Closes #2023) + !1725 (U7, Closes #2024) + !1726 (U8, Closes #2025; #1963 stays open for P-B2)

2026-09-26 — rev 4 approved in plan mode 2026-09-24 (rulings R-B1–R-B21 as recommended) after a five-lane census and its critic, a contextless round 1 (21 blockers), a two-verifier check over rev 2 (12 new defects), a verifier pass over rev 3, the maintainer’s gate on rev 3 (14 findings) and a verifier pass over rev 4; what landed — the ADR-078 correction model LIFTED into craig-ledger / craig-ledger-contracts (ADR-079, now Accepted: a generic event time and retired reason, opt-in first_recorded_at, table-owned codecs; the cases wire byte-identical by golden) and #2009 closed on it (every ledger act names its actor); removal episodes whose removal and exit answers are immutable first-recording response rows ((d)(1), (d)(2), (g)(1)–(g)(4); R14 by trigger), per-child non-overlap by btree_gist exclusions, and containment and the current instants held by two deferred constraint triggers; placements as episode-bound living arrangements with activated_at, cancel, retract, the historical record and the replacement protocol (financial voids first and re-anchors subsidy agreements); the exit as the one home of (g), with PlacementSubsidyEligibility.episode_exit, placement.episode_exited and financial’s guardianship witness moved onto it in three drained units (U6a–U6c), the last narrowing the end-reason set to four; the (d)(1), (d)(2), (e)(1), (g)(1)–(g)(4) element map; the release-audit key placement.afcars_released; placements.permanency_goal and the portal goal token retired (roster 7 → 6); one craig_cases floor (20260925120000) and four craig_placement floors (20260925130000, 20260925170000, 20260926120000, 20260926180000); three refuse-on-data units (U1b, U3, U6c). Follow-ups: #2026 (P-B2, closes #1963), #2027 (the §1355.42(a) population table, before P-D), #2028 (an intra-agency case move), #2029 (the hop’s case lifecycle), #2030 (a historical arrangement’s per-diem), #2041 (payments already issued on a retracted arrangement), #2046 / #2047 (a left_care ending without an exit); the defects and gaps the units found outside their scope are their own issues, #2031–#2040, #2042–#2045, #2048 and #2049. P-D’s input — a back-dated API removal is honestly tardy under R14 (§ Rollout + risks), the same-day plan rule and its test a_plan_on_a_same_day_exit_and_re_entry_goes_to_the_later_episode (D6 / R-B8), the population table (D6 / R-B9, #2027), the placement.afcars_released emitter (D6 / R-B11) and (g)(3) not_applicable from "no live exit" (D4); no P-E input.

Status

Done (2026-09-26) — !1726

Anchor What binds here

#1963; AFCARS 2020 Program (#949)

A5 (capture-first; immutable first-recording response timestamps), A6 (resolved instants), R2, R14 — errata requested (D6)

rulesets/federal/federal-afcars-2020.json 1.1.0 + the pinned CFR

every element key, value set and anchor quoted here is the dictionary’s; §1355.20 / §1355.41 / §1355.42 are pinned with the first dictionary rows that cite them (the P-A2 population issue #2027, D6)

ADR-078 D1

THE correction model — reused through a lift, never a copy

ADR-072 § Amendment — #949

federal text binding every jurisdiction lives in rulesets/federal/; state variance only in {j}-afcars-crosswalk

ADR-062, ADR-063 D3

claim_first first; a DROP or a write-breaking CHECK bumps schema_compat_floor in that migration’s own file

ADR-077 D6

a case-bound row carries the creation-time admin_unit stamp; NULL until the unit-only heal fills it; a root birth takes lock_case_assignment before its FOR SHARE projection read

ADR-037, ADR-076

the foster_home_portal roster (7 → 6); portal scope is ACTIVE placements in bound units

ADR-003

a key lands with its row; parsers and consumers before producers

ADR-079 (new, U0)

the shared ledger core (D1), the episode + response model (D2), the arrangement lifecycle (D3), the exit as the one home of (g)(1)–(g)(4) (D4)

P-B2 (new issue + page plans/afcars-placement-facts.adoc, its own gate)

the element capture on this model (D7)

Erratum (2026-09-24): U0 — cargo xtask rules afcars-manifest refuses a sources.toml [source] record that no dictionary row references (plan_rows, xtask/src/cmd/rules_afcars.rs), so a CFR section is pinned only together with a row that cites it: the pins move from U0 to the P-A2 population issue #2027 — §1355.42 with its population rows, §1355.20 / §1355.41 with the first row whose cell cites each. P-B1 quotes none of the three; the anchor row above and U0’s Units row are corrected to match.

This page lands as docs/modules/ROOT/pages/plans/afcars-placement-capture.adoc. ⁂ = a reading DFCS may rule otherwise, logged on #1073.

Context (census 2026-09-23, verified on main)

  • The file. Placement owns 68 element rows (54 from 2022-10-01, 14 group-(i) rows from 2028-10-01): 0 captured, 12 in the wrong shape, 46 absent, 10 reachable through caregiver bindings. §1355.43(b)(2) asks "the most recent information and all historical information" for (d)–(i): every removal, arrangement and exit is its own row. P-B1 answers (d)(1), (d)(2), (e)(1), (g)(1)–(g)(4).

  • Placement as built. placements is the only arrangement record: per-row removal_date DATE / removal_reason (written at create, never correctable), five CTW / reasonable-efforts columns (no reader; ctw_days_from_removal is a stored derivation), permanency_goal, status planned | active | ended, a client-supplied immutable started_at, no activation instant, no episode. Cancelling is planned → ended and publishes placement.ended (api/placements.rs:1237-1250). end_reason mixes arrangement moves with episode exits. Nothing prevents two concurrent active placements per child. craig_placement has never bumped its floor and has no btree_gist, no mutation trigger, no field registry.

  • Who reads it. financial binds placement.activated (billing from started_at, rate keyed on placement_type) and placement.ended (void + tombstone + two #1070 guardianship WARN arms, keyed by placement_id), and witnesses guardianship activation on the anchoring placement’s status = ended + end_reason = guardianship (subsidy_activate.rs:229-331). craig-web decodes PlacementView with strict enums. 44 PlacementBuilder calls (36 in placement, 8 outside) plus the raw-INSERT fixtures listed in the U3 issue create placements.

  • The ADR-078 cores are cases-private and DATE-typed (EventFacts::event_on() → Option<NaiveDate>, daterange windows, body dates against today) — ≈3,050 lines whose only cases couplings are the person-route helper, deny_pure_service, the claim glue (ClaimedCreate, parse_sub, hash_error, intents::ledger) and `LedgerRetiredReason’s court-order tokens.

  • Superseded premises. The portal goal label is never rendered (services/craig-portal/src/labels.rs:84-86); permanency_plans lives in craig_cases and its RETIRE-only trigger forbids a backfill; §1355.42 is unpinned federal text.

Design

D1 — The shared ledger core (R-B2)

U1a — the lift, behaviour-neutral. Two crates:

Crate Contents

crates/craig-ledger-contracts (no sqlx)

the wire: LedgerRow<K, F, R>, EventRow<K, F, R> (R = the retired-reason enum), the statement / correction / retraction / close request bodies, LedgerAsOfQuery, LedgerPeriodQuery, EventAsOfQuery<T> (T = the event time); cases keeps every name and schema by aliases (LedgerRow<K, F> = craig_ledger_contracts::LedgerRow<K, F, LedgerRetiredReason>, EventAsOfQuery = …<NaiveDate>)

crates/craig-ledger

the store traits (LedgerKey, StoredKey, StoredFacts, LedgerTable, WindowLedger, EventLedger), the window / event acts and reads, the SQLSTATE → typed-409 mapping, the claimed-act skeleton (ClaimedAct, claim_act, retract_with, RetractAct, the RoutePath trait — its impls stay per service, with a private Fresh / Replayed enum), and intents::ledger (LedgerScopes, EventScopes, spec_of)

  • Table-owned codecs (Rust coherence). No craig-ledger trait is implemented on a foreign type: each ledger declares a LOCAL, zero-sized table type in its own service (e.g. struct PersonDemographicsTable; in craig-cases) that implements the store traits with associated types — type Key and type RouteKey (e.g. PersonKey, owned by craig-cases-contracts), type Facts, type Time, type Reason — the key and facts COLUMNS, and the codec functions (bind_key, key_from_row, route_predicate, bind_route, bind_facts, facts_from_row, event_time(&Facts), inherit(&pred, &mut succ)); the stored row is parameterized by the table type (StoredRow<T>, its FromRow bounded on the table, not on a key type). U1a converts today’s impl StoredKey for PersonKey-style impls (e.g. store/person_demographics.rs:43) into those table impls — mechanical and behaviour-neutral; the orphan rule holds because every impl’s self type is local.

  • deny_pure_service moves to craig-api (a claims guard; cases' SSN routes and the core import it); parse_actor_sub / intent_hash_error already live in craig_api::request_claims. Every cases key type and RoutePath impl stays in craig-cases.

  • The event time is generic: the event table type’s type Time: EventTime is NaiveDate for every cases ledger (the body check "on or before today on the jurisdiction clock", unchanged) and DateTime<Utc> for the placement responses ("at or before now"); the at-anchor read compares in SQL on whichever type the column carries.

  • The core is reason-agnostic: an act passes its closed-set token; each service’s wire enum and each table’s CHECK close its set.

  • first_recorded_at is an opt-in store extension: EventLedger::FIRST_RECORDED: bool (cases false); when true the store selects first_recorded_at into the stored row (an Option<DateTime<Utc>> beside the wire row, never a field of EventRow) and the correction act reads the predecessor’s for the R14 guard (D2). Placement’s own wire type ResponseRow flattens EventRow and adds first_recorded_at. A placement ClaimedAct impl updates the episode’s current instants in its run step, after the response write.

  • The gate: the_lift_changes_no_cases_route_or_event_byte — a golden over the cases OpenAPI document and every cases ledger event payload, byte-identical before and after.

U1b — #2009 (option 1). A cases migration (-- devstack: wipe-before-apply on line 2; a refuse-on-data guard FIRST over any row with retired_at set AND any window row with effective_until set — neither has a truthful actor, and a row closed by an act is indistinguishable today from one born with an end; the floor bump LAST — an N−1 image’s retract would break the new CHECK; rollback = N−1 images AND a restore) adds retired_by UUID to every cases ledger row ((retired_at IS NULL) = (retired_by IS NULL)) and closed_at TIMESTAMPTZ + closed_by UUID to every window row (set together by a closing UPDATE only — the close act or a CHANGE’s implicit close: (closed_at IS NULL) = (closed_by IS NULL); a row born with effective_until has neither). Both trigger functions are re-created admitting those columns in the RETIRE / CLOSE shapes. Every writer sets them: the close act; a CHANGE’s implicit close of the open row (the change act’s actor); the correction’s retire of its predecessor; the retraction; and the court-order sweep’s retirement of review rows (store/child_review_events.rs:123, which bypasses the generic retire helper — the order act’s actor). LedgerRow serves retired_by, closed_at, closed_by; EventRow serves retired_by; every ledger event payload carries user_id (the effective actor, claims.acting_worker().sub); craig-security gains resource families for the three person-keyed cases events. The golden is re-blessed with exactly those deltas. Docs: an ADR-078 D1 amendment line, data-model-cases.adoc, the ADR-003 rows, CHANGELOG Changed. craig-security rolls before cases.

Erratum (2026-09-24): U1a (#2015) — the store traits are LedgerFilter<K> / LedgerTable / KeyedTable / WindowLedger / EventLedger / EventTime (RetiredReason in the contracts crate); Key, Facts and their codecs sit on LedgerTable, implemented by each ledger’s existing local marker type; a foreign list filter is a table LedgerFilter impl.

Erratum (2026-09-24): U1a (#2015) — EventAsOfQuery stays concrete (NaiveDate): utoipa’s IntoParams derive cannot take a generic field; placement declares its own instant-typed query.

Erratum (2026-09-24): U1a (#2015) — the moved skeleton includes Ctx and row_legs; LedgerRoute / EventRoute / the generic handlers stay in cases.

Erratum (2026-09-24): U1a (#2015) — R14 reads the SUCCESSOR’s first_recorded_at (equal to the chain root’s by the BEFORE INSERT trigger) in placement’s run; the core has no R14 hook.

Erratum (2026-09-24): U1a (#2015) — EventTime for DateTime<Utc> lands in U3 with its refusal; U1a landed in two MRs — the golden (test-only, battery-proven on the pre-lift code), then the lift.

Erratum (2026-09-25): P-B1 U1b (#2016) — D2’s retired* on removal_responses / exit_responses includes retired_by UUID
(retired_at IS NULL) = (retired_by IS NULL): P-B1 U1b’s shared refuse_event_row_mutation() body and the core RETIRE write it._

Erratum (2026-09-25): P-B1 U1b (#2016) — the floor bump’s reason is the re-created guards' refusal (23000) of every N−1 close / CHANGE / correction / retraction / sweep UPDATE, not the CHECK (a BEFORE ROW trigger fires first); the file is additive, so the bump is voluntary, and it is required.

D2 — The removal episode (R-B3, R-B4, R-B12, R-B15, R-B18, R-B19)

Table Columns (all TIMESTAMPTZ are instants; every reported date is BusinessClock::date_of on the jurisdiction clock)

removal_episodes (identity)

id UUID PK (v7, handler-minted) · child_id UUID NOT NULL · case_id UUID NOT NULL · admin_unit TEXT NULL (copied at birth from case_assignments) · removal_at TIMESTAMPTZ NOT NULL, exit_at TIMESTAMPTZ NULL (the CURRENT answers) · recorded_at / recorded_by UUID · retired_at / retired_by UUID / retired_reason (retracted) / retired_note

removal_responses (event ledger, FIRST_RECORDED)

id · episode_id · removal_at TIMESTAMPTZ d)(1 · removal_manner over RemovalManner (voluntary_placement_agreement | court_ordered_removal — A5’s "manner"; no element) · recorded_at DEFAULT now(), first_recorded_at, recorded_by, supersedes_id, retired_* (corrected | retracted)

exit_responses (event ledger, FIRST_RECORDED)

id · episode_id · exit_at g)(1 · exit_reason · transfer_agency_type · the same stamps — D4

  • Current instants. removal_episodes.removal_at / exit_at are written only by the acts, in their tx. The episode trigger admits exactly three UPDATE shapes: the two current instants; RETIRE; admin_unit NULL → value (the ADR-077 heal — the two placement inbox handlers and backfill-cross-service-assignment’s unit-fill pass cover the table, updating `removal_episodes BEFORE placements under the case advisory lock). A DEFERRABLE INITIALLY DEFERRED constraint trigger ck_episode_current_instants (skipping retired episodes) checks at commit that removal_at equals the live removal response’s (U3; U4 adds exit_at against the live exit response, NULL when none).

  • Deferred-trigger errors. Both deferred constraint triggers (this one and D3’s ck_arrangement_in_episode) RAISE SQLSTATE 23514 naming their trigger; the act maps a commit failure with that SQLSTATE and name to the typed 409 ARRANGEMENT_OUTSIDE_EPISODE (containment) or a 500 (the current-instant check is an internal invariant no request can trip).

  • Non-overlap per child: EXCLUDE USING gist (child_id WITH =, tstzrange(removal_at, exit_at, '[)') WITH &&) WHERE (retired_at IS NULL) (btree_gist created in U3); exit_at > removal_at (CHECK; typed 400 EXIT_BEFORE_REMOVAL) — so no empty range escapes it; an exit and a re-entry on one instant are adjacent.

  • Key + case: the child ("each removal of a child", §1355.44(d)(1)); case_id is the owning case for the episode’s life and every arrangement of the episode takes it (R-B19). A transfer of responsibility to ANOTHER agency is an exit ((g)(3) transfer_to_another_agency); a move to a different case of the same agency during an episode is not supported in P-B1 (a follow-up issue filed in U0; ⁂ #1073). #1804’s legal custody is a distinct cases fact (`/relate`d).

  • R14. recorded_at is DEFAULT now() and never read from a request (the request types carry no such field; an unknown key is ignored, the DB stamps it); the seed supplies its own. A BEFORE INSERT trigger sets first_recorded_at: a root’s own recorded_at, a successor’s predecessor’s first_recorded_at. (d)(2) / (g)(2) = the date of the live row’s first_recorded_at. A correction may not move the event date past the chain’s first_recorded_at date (400 RESPONSE_AFTER_RECORDING). A retraction ends a chain; a later exit is a new response with its own stamp (R-B18, ⁂ #1073).

  • The one live removal response is born with the episode (the open act inserts both through the core’s insert), is superseded by a correction, and is never retracted alone — the episode is.

  • Locks and the authority re-check — one order everywhere. Every episode or arrangement act runs claim_first → (a ROOT birth — the episode open, the historical episode, the arrangement create, the historical record — first takes lock_case_assignment) → the case’s case_assignments row FOR SHARE, COMPARED with the assignment PAIR the pre-transaction authz check consumed (the unit is the locked resource row’s own admin_unit, never the projection’s) — a change is 409 CONCURRENT_MODIFICATION (the #1187 / ADR-060 rule of validate_locked_placement, api/placements.rs:1255; episodes carry no assignment copy, so the projection read IS the re-check; a root birth takes the new row’s pair and admin_unit from it, as today) → the episode row FOR NO KEY UPDATE → the placement row → the foster home (the occupancy trigger’s order). The inbox heal takes the advisory lock → the projection → removal_episodes → placements — the same projection → episode → placement order, so no act and heal can deadlock.

  • A retracted episode is inert. Every act naming a retracted episode (a correction, an exit act, a retract, a create, a historical record) is 409 EPISODE_RETRACTED; the exclusions skip retired rows.

  • Acts (the lifted authority order: deny_pure_service, the authority check before the claim, body instants ≤ now, claim_first, the guard, the act, the event; client_request_id required on every write; a note is 1–1000 characters):

    Route + body Semantics

    POST /v1/placement/episodes {client_request_id, child_id, case_id, removal_at, removal_manner}

    the episode + its root removal response → 201 EpisodeRow; overlap → 409 EPISODE_OVERLAP. Membership is checked as the placement create checks it today — the cases placement-facts hop (an active child-role member now; a back-dated removal_at is admitted); the hop’s own prerequisites (422 child-dob-missing, its ICWA rules consult — 503 when craig-rules is down) are accepted for the open, as the first arrangement needs them anyway; the case’s lifecycle state is not consulted (a pre-existing property of the hop, filed in U0)

    POST /v1/placement/episodes/historical {client_request_id, child_id, case_id, removal_at, removal_manner, exit_at, exit_reason, transfer_agency_type?} (U4)

    a MISSED past episode, atomically: the episode + its root removal response + its root exit response in one tx, so the bounded range meets the exclusion (an open-then-exit pair would collide with any later episode); stamps are now() — a late entry is honestly tardy under R14; arrangements follow by historical record

    POST …/episodes/{id}/removal/{row_id}/corrections {client_request_id, removal_at, removal_manner}

    supersede that live response (404 ledger-row-not-found for a retired / superseded / foreign row); re-checks the exclusion and every arrangement’s containment

    POST …/episodes/{id}/retract {client_request_id, note}

    retire the episode and its live responses; 409 EPISODE_HAS_ARRANGEMENTS while a LIVE arrangement (planned, active, ended) references it

    POST …/episodes/{id}/exit, …/exit/{row_id}/corrections, …/exit/{row_id}/retract

    D4

    GET /v1/placement/children/{child_id}/episodes

    200 [EpisodeRow], newest first; a per-row Action::Read check (episodes carry no assignment denorms, so no scoped list)

    EpisodeRow = { id, child_id, case_id, removal_at, exit_at, recorded_at, removal: ResponseRow, exit: ResponseRow | null } (ResponseRow = the core EventRow flattened + first_recorded_at); every episode act answers the resulting EpisodeRow.

    Authority. The Placement resource type (no new type, no ruleset row): the ref carries the case’s assignment pair from case_assignments and the episode’s admin_unit; open = Action::Create, the other writes Action::Update.

  • Event. placement.episode_facts_changed { episode_id, child_id, case_id, ledger, row_id, act, user_id } — ledger ∈ removal_episodes | removal_responses | exit_responses, act ∈ recorded | corrected | retracted (the open is removal_episodes / recorded with row_id = the episode); ids, the act, the actor — never a fact value. Its ADR-003 row, a craig-security arm and a placement.episode resource family (episode_id); reporting’s placement.* validator treats it as a no-op.

Erratum (2026-09-24): U0, filing the unit issues — the historical episode (U4) is a root birth under Action::Create with the open’s membership check (the placement-facts hop, so a child whose case membership has ended cannot take one in P-B1) and answers 201 EpisodeRow; it publishes placement.episode_facts_changed for removal_episodes / recorded and for exit_responses / recorded, and from U6a placement.episode_exited (it records an exit); P-B1 gives it a CLI command and no web form.

Erratum (2026-09-25): U3 (#2018) — E1 (D2 deferred-trigger errors): each act ends run with SET CONSTRAINTS ck_arrangement_in_episode, ck_episode_current_instants IMMEDIATE, because a failure at COMMIT inside run_claimed_tx is ApiError::Db, a redacted 500 (crates/craig-api/src/lib.rs); the trigger functions raise with CONSTRAINT = '<name>', so the refusal is typed.

Erratum (2026-09-25): U3 (#2018) — E2 (D2 locks): the placement-row acts (the PUT, the cancel) re-check the row’s own pair and take no projection lock, in the order episode → placement → home; case.assignment_changed runs its unit heals (episodes first) before its reassigns; the backfill’s unit fill is autocommit per statement as built, with no advisory lock, and fills removal_episodes before placements.

Erratum (2026-09-25): U3 (#2018) — E4 (D2 wire): U3’s EpisodeRow omits exit (U4 adds it); the child list serves live episodes and a per-row Read denial drops the row; the open answers 201 on both a fresh open and a replay; an episode retract publishes one removal_episodes / retracted; the cancel answers PlacementCancelled.

Erratum (2026-09-25): U3 (#2018) — E8 (D2 families): the security family prefix is placement.episode (episode_id), and placement.cancelled gets its own family (placement_id)._

Erratum (2026-09-25): U4 (#2019) — F1 (D2 wire): EpisodeRow.exit is null exactly when exit_at is null, else the exit response its exit_at is from (the live one on a live episode, the one retired with it on a retracted episode; matched by retirement, never by recording order); the exit acts answer 200.

Erratum (2026-09-25): U4 (#2019) — F2 (D2 acts): an episode retract also retires its live exit and still publishes one removal_episodes / retracted; exit_at stays on the retired row.

Erratum (2026-09-25): U6a (#2021) — H3 (D2 / D4 events): placement.episode_exited is staged by the three exit acts and the historical episode (arrangement_ids empty); an episode retract, which also retires a live exit (F2), stages none.

D3 — Living arrangements (R-B5, R-B6, R-B16, R-B17, R-B20, R-B21)

placements rows ARE the living arrangements (the identity caregiver bindings, education records and financial anchors key).

  • Episode-bound (U3). episode_id UUID NOT NULL REFERENCES removal_episodes. CreatePlacementRequest drops case_id / child_id and requires episode_id; both are derived from the episode (the create refuses an exited episode — 409 EPISODE_CLOSED — and a retracted one — 409 EPISODE_RETRACTED, D2). The column keeps its name placement_type (the rate key, the eligibility input, the web decoder); its vocabulary and the non-conventional periods are P-B2’s.

  • Containment + non-overlap (U3). "An effective arrangement" means activated_at IS NOT NULL AND status <> 'retracted' everywhere in this page (the exclusion, containment, and the exit / correction re-checks — a retracted row, wrong by definition, never blocks anything). A constraint trigger ck_arrangement_in_episode on both tables, deferred to commit, skipping retired episodes: every effective arrangement satisfies started_at >= removal_at AND COALESCE(ended_at, 'infinity') ⇐ COALESCE(exit_at, 'infinity') (409 ARRANGEMENT_OUTSIDE_EPISODE). Per child, effective arrangements never overlap: EXCLUDE USING gist (child_id WITH =, tstzrange(started_at, ended_at, '[)') WITH &&) WHERE (activated_at IS NOT NULL AND status <> 'retracted') (409 ARRANGEMENT_OVERLAP) — the CFR’s arrangements are sequential (R-B16).

  • The (e)(1) exception. A child already in a living arrangement when responsibility arrives is recorded with that arrangement’s started_at = removal_at: the VPA or court order that provides responsibility is the removal (§1355.44(e)(1), (d)(1)); a child on the run at that moment is P-B2’s (runaway rows). (e)(1) maps to started_at alone.

  • activated_at (U3) — TIMESTAMPTZ, the DB instant of the activating statement, write-once (COALESCE), on BOTH activation paths: the birth-active create (the create’s default status is active, api/placements.rs:166, and it publishes placement.activated at once) and planned → active. started_at stays the business instant ((e)(1); the billing anchor) and on both paths must lie in [episode removal_at, the activation instant] (400 ACTIVATION_START_OUT_OF_RANGE — a future started_at never activates): the create checks the body’s value; UpdatePlacementRequest gains started_at, accepted only on planned → active (confirming the scheduled start). Immutable after activation.

  • Cancel (U3), retract and historical record (U5).

    Route + body Semantics

    POST /v1/placement/placements/{id}/cancel {client_request_id, note} (U3)

    planned → cancelled only: never in the file, a cohort, a bed or a bill; placement.cancelled { placement_id, episode_id, child_id, case_id, user_id }; financial binds nothing (a planned row never published placement.activated). U3 removes planned → ended

    POST …/placements/{id}/retract {client_request_id, note} (U5)

    active | ended → retracted (entered in error): kept as the record (ended_at / end_reason stay), out of the file, cohorts and occupancy; placement.retracted { placement_id, episode_id, child_id, case_id, retracted_from ∈ active | ended, user_id } — financial runs its placement.ended void + tombstone path (cause placement_retracted) and ships that consumer FIRST; 409 ARRANGEMENT_HAS_BINDINGS while an OPEN caregiver binding keys the arrangement (R-B17: an OPEN binding); an ended binding stays keyed to the retracted id (its reassociation to a replacement is P-B2’s, D7)

    POST /v1/placement/placements/historical {client_request_id, episode_id, placement_type, foster_home_id?, started_at, ended_at, end_reason} (U5)

    a MISSED past arrangement, born ended (activated_at = now()), into any live episode (open or exited) where containment and non-overlap hold; it runs no eligibility consult, no license / training / capacity gate (a record of the past, not an activation decision), leaves the #1724 provenance pair NULL and never occupies; placement.recorded { placement_id, episode_id, child_id, case_id, user_id }; it NEVER bills — its retroactive per-diem is the R-B20 financial follow-up (#1115 does not cover it)

    All three are claimed acts. Authority: cancel and retract are Action::Update on the placement’s ref; the historical record is Action::Create on the Placement ref built from the episode’s case (the case_assignments pair and admin_unit, as the create). An activated arrangement’s instants are corrected by retract + re-record (the live create for an open arrangement, the historical record for a past one).

  • The binding guard is two-sided (U3, U5). craig-placement’s caregiver-binding create on a PLACEMENT unit (api/caregivers.rs) locks the placement row FOR NO KEY UPDATE inside its claimed tx and admits only a planned or active placement (409 otherwise — today it refuses only ended, api/caregiver_units.rs:131, and inserts without the lock); the retract locks the same row before checking for an OPEN binding — so a concurrent bind and retract serialize, and a cancelled or retracted arrangement is never bindable.

  • The replacement protocol (U5, R-B21). A re-record (the live create or the historical record) may name replaces_placement_id: a RETRACTED arrangement of the same episode not yet replaced (partial unique index; 409 otherwise). placement.activated gains the optional replaces_placement_id and placement.recorded carries it; financial binds both (consumer first) and, for every subsidy agreement anchored on the retracted id, re-anchors it to the replacement in one audited act (financial.subsidy_anchor_replaced) — a correction, not a new enrollment, so the "anchor must be active" enrollment rule (subsidy_create_guardianship.rs:151) does not apply. For a PENDING agreement the re-anchor also re-snapshots placement_started_on from the replacement (the residence floor and ERR coverage read that snapshot); an ACTIVE agreement’s coverage never moves — its re-anchor raises the #1070-class WARN instead. The activation witness then judges the replacement. A retracted anchor never replaced raises the same WARN.

  • Columns + CHECKs. U3 (inside its refuse-on-data re-cut): activated_at TIMESTAMPTZ; cancelled_at TIMESTAMPTZ, cancelled_by UUID, cancel_note TEXT; the status CHECK becomes planned | active | ended | cancelled; (activated_at IS NOT NULL) = (status IN ('active', 'ended')); the cancel trio all-or-none with status = 'cancelled'; placements_ended_after_started becomes ended_at > started_at (a zero-length arrangement is an empty range the exclusion cannot see — refused, and validate_locked_placement refuses the equality typed); the existing ended-pairing CHECKs stay. The U3 seed sets activated_at on every seeded active / ended row. U5 (widening: every existing row satisfies the new set, so no refuse-on-data guard; the floor bump is voluntary — see Placement cutovers): retracted_at TIMESTAMPTZ, retracted_by UUID, retract_note TEXT; the status CHECK adds retracted; the activated pairing becomes status IN ('active', 'ended', 'retracted'); replaces_placement_id UUID NULL REFERENCES placements, unique WHERE replaces_placement_id IS NOT NULL AND status <> 'cancelled' (a cancelled planned replacement frees the slot); placements_ended_pairing and placements_end_reason_only_when_ended are replaced by status = 'ended' → ended_at IS NOT NULL, ended_at IS NOT NULL → status IN ('ended', 'retracted'), end_reason IS NULL OR status IN ('ended', 'retracted'); the retract trio all-or-none with status = 'retracted'. PlacementStatus gains each token in its unit and strum::VariantNames in U3.

  • Placement cutovers. The SQL widening is not the compatibility boundary: placement reads status through a strict enum (store/models.rs:84; end_reason is an Option<String> there), so an older placement replica cannot decode a row carrying a status it lacks. The two units that add one — U3 (cancelled) and U5 (retracted) — bump craig_placement’s floor (U3 as its destructive re-cut; U5 voluntarily), replace every placement replica before traffic, and name their rollback: N−1 images AND a restore. craig-web’s strict decoders roll before placement for U4 (left_care) and U5 (retracted); U3’s order and window are in Rollout.

  • placements.status stays a governed state token (its field audit covers every status write). craig-security’s arms ship before placement emits a new key; craig-web’s strict decoder ships before placement can write retracted (U5); for U3 see Rollout.

Erratum (2026-09-24): U0, filing the unit issues — R-B21 names both re-records, so the historical record’s body also takes the optional replaces_placement_id (as does the live create’s); an ineligible one (not a retracted arrangement of the same episode, or one already replaced) is 409 INVALID_REPLACEMENT. financial.subsidy_anchor_replaced is a routing key: its ADR-003 row and craig-security arm roll in U5’s security step. The never-replaced WARN is raised by financial’s placement.retracted consumer for each agreement anchored on the retracted id, in place of the end-reason-keyed #1070 arms (a retract carries no end reason).

Erratum (2026-09-25): U3 (#2018) — E3 (D2 / D3 DB twins): uq_removal_episodes_identity backs the composite FK (episode_id, child_id, case_id); uq_removal_responses_one_live holds one live response per episode; placements_started_by_activation holds started_at ⇐ activated_at, and activated_at is the transaction instant.

Erratum (2026-09-25): U3 (#2018) — E9 (D3 create): the create refuses in the order garde → deny_pure_service → episode lookup (404) → authz → shape.

Erratum (2026-09-25): U5 (#2020) — G1 (D3 columns): the two replaced ended CHECKs are three, placements_ended_has_ended_at, placements_ended_at_when_ended_or_retracted and placements_end_reason_when_ended_or_retracted; the FK is fk_placements_replaces … ON DELETE RESTRICT; the partial unique is the index uq_placements_one_replacement, an unmapped DB twin (every re-record checks eligibility under the episode lock).

Erratum (2026-09-25): U5 (#2020) — G2 (D3 historical record): placement.recorded also carries started_at (financial derives a pending agreement’s new placement_started_on from it, as from placement.activated); the act answers 201 PlacementRecorded, types placement_type / end_reason as the craig-reference enums, and checks ended_at ⇐ now() in its transaction against the instant activated_at stamps.

Erratum (2026-09-25): U5 (#2020) — G3 (D3 retract): the retract answers 200 PlacementRetracted (with retracted_from), refuses 400 before the binding 409, and does not re-check the episode’s retraction (unreachable: an episode retract needs no live arrangement).

Erratum (2026-09-25): U5 (#2020) — G4 (D3 replacement protocol): financial’s re-anchor runs last on every placement.activated outcome and on placement.recorded, as one attempt tx with one financial.subsidy_anchor_replaced per agreement (created_by = "system"); PENDING SG / NRSG agreements re-snapshot, ACTIVE / SUSPENDED move only the id and WARN, terminal agreements move only the id; the never-replaced WARN covers open agreements (pending, active, suspended); financial carries no migration.

D4 — The exit, the one home of (g)(1)–(g)(4) (R-B7)

  • exit_responses: exit_at ("an exit occurs when the title IV-E agency’s placement and care responsibility of the child ends", §1355.44(g)); exit_reason over the (g)(3) dictionary tokens EXCEPT not_applicable (TEXT under a CHECK; P-D answers not_applicable from "no live exit"); transfer_agency_type over the (g)(4) tokens, NOT NULL iff exit_reason = transfer_to_another_agency.

    Route + body Semantics

    POST …/episodes/{id}/exit {client_request_id, exit_at, exit_reason, transfer_agency_type?}

    409 EPISODE_HAS_OPEN_ARRANGEMENT while an OPEN arrangement (planned or active) exists; exit_at >= every effective arrangement’s ended_at (409 ARRANGEMENT_OUTSIDE_EPISODE); 409 EPISODE_ALREADY_EXITED when a live exit exists

    …/exit/{row_id}/corrections {client_request_id, exit_at, exit_reason, transfer_agency_type?}

    supersede (containment and the exclusion re-checked)

    …/exit/{row_id}/retract {client_request_id, note}

    re-open the episode; 409 LATER_EPISODE_EXISTS when the child has a later episode

    The arrangement that ends because responsibility ends takes the new end reason left_care (U4 adds it; web and security first); the exit tokens stay writable on end_reason until U6c.

  • The arrangement an exit leaves from is DERIVED, never stored: the episode’s latest effective arrangement by started_at. It is always current (a later historical record changes it; nothing goes stale), and it is what financial’s witness binds to (below).

  • Financial re-point — three units, no dual read in any service.

    • U6a — the exit becomes readable. PlacementSubsidyEligibility gains episode_exit: { exit_on, exit_reason } | null, served non-null ONLY when the anchoring placement IS its episode’s latest effective arrangement and that episode has a live exit — a placement the child left earlier (ended by disruption, say, before a move to B) gets null, whatever B’s exit says. Every exit act (record, correct, retract) publishes placement.episode_exited { episode_id, child_id, case_id, arrangement_ids (every live arrangement of the episode), current: { exit_on, exit_reason } | null, act_id, act_at, user_id } (the state after the act, the P-C plan-event shape; exit facts are not PII); financial binds it, and the GUARDIANSHIP branches of its two #1070 WARN functions (warn_stranded_err_anchors, warn_pending_guardianship_arms) take it as their trigger — finding agreements by child_id and arrangement_ids, and raising the same WARN when an active guardianship agreement’s episode exit is corrected away or retracted; their reason-blind and non-guardianship branches stay on placement.ended and skip end_reason = left_care (the placement.episode_exited arm owns an arrangement that ended because responsibility ended). craig-web’s one-step guardianship handoff (routes/placement/guardianship_handoff.rs) now ends the arrangement with end_reason = guardianship AND records a guardianship exit dated at the transfer, then terminates the ERR and activates the SG — a state both the old and the new witness accept. The witness itself is unchanged in U6a.

    • U6b — the witness moves. financial’s verify_ending_shape and enforce_guardianship_finalized_witness require the anchoring placement ended, episode_exit non-null (so the anchor IS the arrangement the child left care from), exit_reason == guardianship, and the anchor’s ended_on == exit_on (the child leaves the arrangement when guardianship is legalized — the handoff writes both at the transfer instant); transfer_on = exit_on, and the residence window stays the anchor’s own started_on .. ended_on. They no longer read end_reason. The eligibility projection’s caregiver evidence date moves with the witness: caregivers are filtered at exit_on whenever episode_exit is served (today at the placement’s ended_on, api/placements.rs:988). Data gate: U6a adds the SQL invariant guardianship_ending_without_exit (an ended latest effective arrangement with end_reason = guardianship in an episode with no live guardianship exit, or whose live guardianship exit’s date differs from the arrangement’s ended_on); U6b rolls only when it is EMPTY in the target environment — repair is a worker recording the exit (truthful); the devstack reseeds. Requires every craig-web at U6a (an older web records no exit); the two subsidy Playwright specs and financial’s sg_activate API fixtures record the exit.

    • U6c — the narrowing, after every pre-U6b financial is drained (an older financial still witnesses end_reason = guardianship): the six exit tokens leave PlacementEndReason (transfer, disruption, runaway, left_care remain); the web handoff and end form write left_care. The migration first REWRITES, audited, each exit-token end_reason to left_care where the arrangement is its episode’s latest effective arrangement and the episode has a live exit (truthful: the arrangement ended because responsibility ended, and the exit now carries the reason — the one sanctioned touch of an ended row’s end reason, pre-1.0); a refuse-on-data guard then refuses any remaining exit-token row (-- devstack: wipe-before-apply); the CHECK narrows; a voluntary floor bump (write-breaking for an N−1 image). Order: placement FIRST (after the rewrite and guard no row carries an exit token, so the narrowed web decoder can never meet one), then craig-web; in the window an older web’s end form and its U6a guardianship handoff cannot write an exit token (placement refuses it, 400) — accepted and stated.

Erratum (2026-09-24): U0, filing the unit issues — (1) guardianship_ending_without_exit’s date arm compares the two INSTANTS (`ended_at <> exit_at): a SQL invariant holds no jurisdiction clock, and instant inequality covers every date inequality (fail-closed); the handoff writes both at the one transfer instant, and a flagged same-day pair is repaired by a truthful exit correction to the arrangement’s end. (2) U6c’s rewrite is audited by one row per rewritten arrangement in placement_end_reason_rewrites (placement_id, from_reason, exit_response_id, rewritten_at), created by the same migration (a migration cannot publish an event; the crypto_field_rewrites precedent records a rewrite as rows). A retracted arrangement carrying an exit token is never rewritten (it has no truthful exit) and the guard refuses it: the devstack wipes, and no pre-1.0 environment holds production data. After U6c the handoff’s guardianship preflight keys on the exit reason it records.

Erratum (2026-09-25): U4 (#2019) — F3 (D2 / D4 refusals): EXIT_BEFORE_REMOVAL and LATER_EPISODE_EXISTS are the typed IMMEDIATE chk_removal_episodes_exit_after_removal (every episode write, including a removal correction onto a live exit) and excl_removal_episodes_child_window (the exit retract); EPISODE_ALREADY_EXITED and EPISODE_HAS_OPEN_ARRANGEMENT are pre-checks under the episode lock; the (g)(4) mismatch is a 422.

Erratum (2026-09-25): U4 (#2019) — F4 (D4 types): ExitReason and TransferAgencyType are craig-reference enums (the RemovalManner precedent), pinned to the dictionary and to the CHECKs.

Erratum (2026-09-25): U6a (#2021) — H1 (D4 handoff): the one-step handoff records the guardianship exit after the end and before the ERR termination, at the ONE transfer instant both writes carry (a date-only today clamped to min(noon UTC, now)); a transfer date after the jurisdiction’s business today is refused before the end; a refused exit stops the chain before any money act and leaves the arrangement ended with no exit, which guardianship_ending_without_exit flags until a worker records it.

Erratum (2026-09-25): U6a (#2021) — H2 (D4 data gate): guardianship_ending_without_exit is report-only (outside BLOCKING_INVARIANTS and the journey selectors): the battery’s fixtures and the manual Playwright arc end placements guardianship without an exit until U6b records it.

Erratum (2026-09-25): U6a (#2021) — H5 (D4 financial arms): the exit’s arm also raises the reason-blind and withdraw WARNs on a non-guardianship exit (it owns a left_care ending), the corrected-away / retracted WARN covers active AND suspended SG/NRSG, and the support-gap WARN needs no pending, active or suspended SG/NRSG.

Erratum (2026-09-25): U6b (#2022) — I1 (D4 data gate): guardianship_ending_without_exit stays report-only in the battery after U6b: it does not hold by construction (a plain guardianship end stands without its exit until a worker records it), so it does not join BLOCKING_INVARIANTS. It joins the journey selectors, and U6b’s rollout gate is the environment sweep, which stops on the invariant’s named FAIL line. This corrects H2’s "until U6b records it".

Erratum (2026-09-26): U6c (#2023) — J1 (D4 web): the end form states a guardianship transfer as left_care plus a guardianship-exit box (exit_reason = guardianship), which runs the SS6 gate and offers the one-step handoff; the plain left_care end records no exit (U6a’s plain-end rule).

Erratum (2026-09-26): U6c (#2023) — J2 (D4 guard): the migration SHARE-locks placements, removal_episodes and exit_responses for the file, audits before it rewrites, and follows D4’s REWRITE → guard order in one transaction. No API act repairs a non-latest or retracted exit-token row (a retract keeps end_reason); only a latest arrangement without a live exit is repairable, by recording the exit. The historical record refuses a removed token 422 (typed body); the PUT, 400.

Erratum (2026-09-26): U6c (#2023) — J6 (D4 financial arms): placement.ended raises nothing for left_care; a pre-U6c guardianship token is unknown and takes the reason-blind arms (log-only).

D5 — Registry, seed, docs, followers

  • Encryption (R-B13): every new column Plaintext; the ledgers are scheme-frozen by their triggers; the posture stays #2000.

  • The destructive re-cut (U3) refuses on ANY placements row (-- devstack: wipe-before-apply — … (#1963) on line 2; guard first; floor bump last): no synthesized episodes. It drops removal_date, removal_reason, the five CTW / reasonable-efforts columns and sibling_placements (U3 Closes #1778) (R-B14). Rollback = N−1 images AND a restore. The byte-equality test covers the two trigger-function copies: cases' U1b migration and placement’s U3 migration.

  • Seed (drawing nothing new; episode ids by Uuid::new_v5 — seed-only determinism, the permanency-plan precedent):

    Unit Derivation

    U3

    one episode per placed child, opened at its earliest arrangement start (court_ordered_removal); the ~20% of children with a history row keep both rows in that one episode, the active start drawn after the history end (today’s draws overlap); stamps within 30 days of each event (not tardy)

    U4

    a history row whose end reason is an exit reason closes the first episode (an exit recorded ≤ 30 days after, left_care on the row) and the active row opens a re-entry episode; one bless

  • Followers:

    Surface Unit Change

    craig-test-lib

    U3

    PlacementBuilder::new(episode) (the compiler finds all 44 calls); given_removal_episode; the typed client

    Playwright twin, k6

    U3

    an episode before every placement

    craig-web

    U3–U6c

    "Open removal episode" from the child; the new-placement form picks an open episode; cancel (U3); exit form (U4); retract / historical (U5); the guardianship handoff (U6a, U6c)

    craig-cli

    U3–U5

    craig placement episode open|correct|retract|exit…; create --episode-id; cancel (U3); retract, historical (U5)

    xtask backfill rig, SQL invariants, reporting’s zero-issue pin

    U3–U5

    episodes; the new statuses and keys

    docs

    per unit

    data-model-placement.adoc (canonical), state-machines.adoc, the implementation guide, ADR-003, a NEW deployment guide § AFCARS placement capture rollout; NCANDS reads no placement data — no follower

  • The element map (U3, U4): Mapping moves from craig-cases-fields::afcars to craig-reporting-contracts (a new regular dependency of craig-cases-fields and craig-placement-contracts); each map keeps its own stage enum — craig_placement_contracts::afcars declares PlacementCaptureUnit; U3 maps (d)(1), (d)(2), (e)(1) (their columns exist from U3); U4 adds (g)(1)–(g)(4) with the exit columns. Its tests live in craig-placement: a hermetic one loads the dictionary by path and checks shapes; a DB-backed one (#[ignore = "requires devstack"]) checks every mapped column exists in the migrated schema (placement has no registry). P-B2 completes it.

Erratum (2026-09-25): U3 (#2018) — E5 (D5 seed): history rows derive backwards, adjacent to the active start; the removal-response stamps are removal_at + 1 day by the seed admin.

Erratum (2026-09-25): U3 (#2018) — E7 (D5 followers): k6 creates no placement, so k6 has no change.

Erratum (2026-09-25): U4 (#2019) — F5 (D5 seed): the pinned byte-identity inputs draw no exit (their one history row ends transfer), so exit_responses is listed as unrendered there and its render is pinned in integration.rs; the re-entry episode’s id is v5 of (child, removal_episodes/re-entry ++ case).

Erratum (2026-09-25): U4 (#2019) — F7 (D5 byte-equality): the test’s matcher keys on FUNCTION refuse_event_row_mutation() RETURNS trigger, so an attaching migration never counts as a definer.

Erratum (2026-09-25): U5 (#2020) — G6 (D5 followers): the web historical record is its own page under the episode, with the replacement picker; the live create names replaces_placement_id from the web "Re-record" link on a retracted row or the CLI.

Erratum (2026-09-25): U5 (#2020) — G7 (D5 docs): ADR-052 D1 gains the anchor-replacement amendment, and ADR-003’s payments_voided cause list gains placement_retracted.

Erratum (2026-09-25): U6a (#2021) — H4 (D5 docs): ADR-056 gains the U6a amendment (the WARN trigger moves to the exit; the handoff records the exit).

Erratum (2026-09-26): U6c (#2023) — J3 (D5 followers): U6c’s web change also narrows the U5 historical-record form’s end-reason select; the seed draws a five-entry (end reason, exit) ending table in the retired END_REASONS order — byte-identical, no bless.

D6 — Superseded program premises (errata recorded in U0)

Premise Correction

A5: episode_id on P-C’s permanency_plans

not added (R-B8): P-D assigns a 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 — so a plan dated on an exit day belongs to that episode. A date inside TWO episodes (an exit and a re-entry on the same date — the instants admit it, a date cannot separate them — and so on for two or more) goes to the LATEST such episode, deterministically; ⁂ #1073 (DFCS may read it otherwise). §1355.44(f)(2) asks for the date each plan was established during each out-of-home care episode

A5: in_population_from on the episode

the 24-hour threshold is federal text (R-B9): a P-A2 dictionary erratum adds a population table citing the pinned §1355.42(a); placement stores instants; P-D evaluates

Erratum 2026-09-22: a placement-side projection for the portal goal label

the label is never rendered: the token is RETIRED with the column (R-B10) — roster 7 → 6 in U7: GOVERNED_FIELDS, the bundle roster, craig-state-ga/src/lib.rs:472-480, both field_ownership.toml, placement VALUE_KINDS / GOVERNED_TOKENS, api/governed.rs:127, api/placements.rs:140-143, portal FIELD_KEYS + both locales, web pending_changes.rs + locale, ADR-037 / ADR-076 / ADR-078 / shared-crates / rulesets.adoc / deployment-guide.adoc:1606 prose

A5: P-B adds the release-audit event

P-B1 lands the key only (R-B11): placement.afcars_released (strict: requestor service id and purpose — two closed tokens — child ids, count, the resolved from / to / as_of), its ADR-003 row and security arm; P-D’s afcars-export stages it in its own tx before responding, no-store

A5: "manner"

the removal response’s removal_manner (RemovalManner), a CRAIG fact with no element

P-B weight 8

P-B1 35, P-B2 ≈ 17

Erratum (2026-09-26): U7 (#2024) — K2 (D6 R-B10): the retirement also reached ADR-003’s placement.field* clause, the craig-cases-contracts plan-event doc, design/five-contracts.adoc, cli.adoc and the caseworker guide; the create intent became PlacementIntentV4; six placement API tests that used the goal as their harmless update now send the fact-free PUT {} (the three authz-recheck race tests read updated_at against created_at, and post_end_record_keeping_stays_writable compares updated_at before and after); the studio label map is pinned to the bundle roster._

D7 — What P-B1 does not do (P-B2)

The arrangement vocabulary and non-conventional periods as rows (with the kinship caregiving-unit identity and financial’s move semantics they force); per-arrangement facts (e)(2)–(e)(8); provider person facts (e)(9)–(e)(18) through bindings; removal facts (d)(3)–(d)(6)(ii); the (h) group and (h)(15); health / education; the sibling counts (b)(20) / (b)(21); group (i); the trial-home-visit exit reading (⁂); `tribe_established_order_of_preference’s owner; the element map’s completion and the cross-service partition test. P-B2 also owns the caregiver-history reassociation a replaced HOME-LESS arrangement needs: its ended bindings keep the retracted placement id, and today’s binding create refuses an ended replacement — P-B2’s kinship caregiving-unit identity (bindings keyed to a unit, not an arrangement) resolves it; until then such a replacement carries no caregiver history (a stated dependency on D3’s replacement protocol).

Units

Each MR Relates to #1963 and #949 and closes its own unit issue; U1b also closes #2009, U3 #1778; U8 does not close #1963 (P-B2 does). U0 also files three follow-ups: an intra-agency case move during an episode (R-B19, #2028); the placement-facts hop not consulting the case’s lifecycle state (pre-existing, #2029); and financial’s retroactive per-diem for a historical arrangement (#2030; R-B20 — #1115’s import path pays subsidy agreement months below its reconciliation floor, not placement per-diems, so until that issue lands a historical arrangement’s per-diem is paid outside CRAIG).

MR Issue Scope W

U0

—

this page (Active nav); ADR-079 Proposed; the unit issues, the P-B2 issue, the P-A2 population issue (which carries the §1355.42 pin, and §1355.20 / .41 wherever a population cell cites them); the program errata (D6)

1

U1a

#2015

THE LIFT (D1): the two crates, generic event time and reason, FIRST_RECORDED, deny_pure_service to craig-api; the golden

5

U1b

#2016

#2009 (D1): actor columns + CHECKs, trigger shapes, user_id payloads, security families, ADR-078 amendment; wipe

3

U2

#2017

THE RELEASE-AUDIT KEY (D6): contract, ADR-003 row, security arm

1

U3

#2018

EPISODES + THE RE-CUT (D2, D3, D5): btree_gist + the triggers; removal_episodes, removal_responses; the episode acts, GET, event; episode_id NOT NULL, activated_at, cancel (planned → ended removed), containment, per-child non-overlap; the drops
#1778; every creator; seed (one episode per child); the element map start

8

U4

#2019

EXITS (D4): exit_responses, the exit acts, re-entry, the historical episode, left_care; the (g) element-map rows; seed exits + re-entry

5

U5

#2020

RETRACT, HISTORICAL, REPLACEMENT (D3): the two acts and events, the replacement protocol with financial’s re-anchor (financial’s consumers first), the two-sided binding guard, the CHECK widening (a placement cutover, voluntary floor bump)

5

U6a

#2021

THE EXIT READABLE (D4): episode_exit (latest-arrangement only), placement.episode_exited + financial’s consumer and WARN branches, the web handoff, the guardianship_ending_without_exit invariant

2

U6b

#2022

THE WITNESS MOVES (D4): financial’s guardianship witness on the exit; specs + fixtures

2

U6c

#2023

THE END-REASON NARROWING (D4): after the drain; refuse-on-data; floor bump

1

U7

#2024

THE GOAL DROP (D6): placements.permanency_goal + the governed token; floor bump

1

U8

#2025

CLOSE-OUT: ADR-079 Accepted (as-built), data-model-placement.adoc complete for P-B1, the P-D / P-E inputs recorded

1

Weight 35 (P-B2 #2026 ≈ 17; the P-A2 population issue #2027). Every MR green alone; CHANGELOG per MR; // @axis: on every new test; each destructive migration names its rollback. U5 files the financial follow-up for payments already issued on a retracted arrangement.

Test matrix (by risk)

  • Evil (typed refusals):

    • a service principal on any episode route — 403;

    • an overlapping episode — 409 EPISODE_OVERLAP; an exit at or before its removal — 400 EXIT_BEFORE_REMOVAL;

    • an arrangement outside its episode — 409 ARRANGEMENT_OUTSIDE_EPISODE; overlapping another — 409 ARRANGEMENT_OVERLAP;

    • a create naming an exited episode — 409 EPISODE_CLOSED; any act naming a retracted episode — 409 EPISODE_RETRACTED;

    • a correction naming a retired, superseded or foreign response — 404; a removal correction past its first recording — 400 RESPONSE_AFTER_RECORDING;

    • an exit with an open arrangement, a second live exit, an exit retraction under a later episode — 409;

    • planned → ended, a cancel of an active row, a retract of a planned row — 409; a retract with an OPEN binding — 409 ARRANGEMENT_HAS_BINDINGS; an activation started_at out of range — 400 ACTIVATION_START_OUT_OF_RANGE;

    • an UPDATE of a response row other than RETIRE, an episode UPDATE outside its three shapes, any DELETE — refused by the triggers;

    • an episode removal_at disagreeing with its live response at commit — refused by ck_episode_current_instants.

  • Concurrency (tests/api/concurrent_transitions.rs): exit vs create; removal correction vs activation; two opens for one child; the inbox heal vs an activation (no deadlock); a reassignment between authorization and the lock (409 CONCURRENT_MODIFICATION); a binding create vs a retract of the same arrangement (one wins, never both).

  • Sad: transaction_dates_are_first_recording_timestamps_never_row_creation (program + #1963 AC) · a_retracted_exit_reopens_the_episode · a_same_instant_exit_and_re_entry_are_adjacent · a_cancelled_arrangement_is_in_no_cohort_and_no_bed · a_retracted_arrangement_voids_financial_first · activated_at_is_set_exactly_once · a_historical_arrangement_never_bills · a_middle_arrangement_is_corrected_by_retract_and_historical_record · an_exited_episode_arrangement_is_re_recorded_without_moving_g2 · a_retracted_arrangement_never_blocks_a_removal_correction · every_ledger_act_names_its_actor (#2009) · a_guardianship_exit_corrected_away_warns_in_financial · an_earlier_arrangement_never_witnesses_a_later_guardianship_exit · a_replacement_re_anchors_a_pending_agreement · a_missed_past_episode_inserts_before_a_later_one · a_future_started_at_never_activates_on_either_path · a_cancelled_or_retracted_arrangement_is_never_bindable · a_plan_on_a_same_day_exit_and_re_entry_goes_to_the_later_episode (a P-D input test, recorded) · u6b_requires_no_guardianship_ending_without_exit.

  • Happy: the_lift_changes_no_cases_route_or_event_byte (U1a) · the_trigger_functions_are_byte_equal_across_databases · the_guardianship_witness_reads_the_episode_exit · the_goal_token_is_gone_from_every_roster_pin · the_seeded_episodes_contain_their_arrangements.

  • Property, DB-backed (#[ignore = "requires devstack"], generated act sequences against the migrated schema): first_recorded_at_is_the_chain_root_under_any_supersede_sequence · arrangement_and_episode_windows_never_overlap_under_generated_acts.

  • Live: the placement e2e opens an episode, activates, ends, exits, re-enters; a cancel; a retract.

Erratum (2026-09-24): U0, filing the unit issues — 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 (validate_locked_placement, api/placements.rs:1280-1289), not a 409; the Evil list’s "409" for those three is corrected.

Erratum (2026-09-25): U6b (#2022) — I2 (Test matrix): u6b_requires_no_guardianship_ending_without_exit has two halves: placement’s (U6a, the invariant’s arms) and financial’s u6b_requires_no_guardianship_ending_without_exit_witness_arms (every witness refusal on a latest guardianship-ended arrangement is flagged). The gate’s premise holds in that direction only. A same-date instant mismatch is flagged yet admitted (erratum (1)), and an arrangement that is not its episode’s latest is refused yet never flagged — D4’s truthful refusal.

Erratum (2026-09-26): U6c (#2023) — J4 (D4 data gate / Test matrix): guardianship_ending_without_exit retires with its X1 pin, its journey selector and both halves of u6b_requires_no_guardianship_ending_without_exit (it matches nothing once the CHECK narrows): placement’s half is deleted, and financial’s drops its flagged assertions, keeps every witness refusal assertion and is renamed each_witness_refusal_arm_is_repaired_by_a_truthful_exit_act. The one-rule pin pairs the projection with the migration’s rewrite; U6b’s gate is run from the U6b release’s tree.

Erratum (2026-09-26): U7 (#2024) — K5 (Test matrix): the_goal_token_is_gone_from_every_roster_pin lives in services/craig-placement/src/field_ownership.rs and pins the contracts roster, the bundle roster, the value-kind table and both shipped owner maps to the six remaining tokens, never spelling the retired one (grep 1 covers the file); the bin’s token list is pinned to the bundle roster by the_governed_roster_is_one_spelling_everywhere.

Verification

  • Per MR: fmt, clippy, budgets at their locks (B1 at 7: new handlers in new modules under 500 lines — api/episodes.rs, api/exits.rs, api/arrangement_acts.rs), rules check, policy drift, contested-census, check-docs, plan-lint, validate-authz-coverage, the evil-corpus / contention / route-role / coverage-matrix gates per new route, the battery.

  • Close-out greps (active code; --glob '!/migrations/' --glob '!CHANGELOG.adoc' --glob '!docs/**'), each EMPTY:

    rg -n 'permanency_goal' services/craig-placement crates/craig-placement-contracts crates/craig-state-bundle crates/craig-state-ga \
      services/craig-portal services/craig-web services/craig-cli/src crates/craig-test-lib/src
    rg -n '\bremoval_date\b|\bremoval_reason\b|\bctw_finding(_date)?\b|ctw_days_from_removal|\breasonable_efforts(_date)?\b|sibling_placements' \
      services/craig-placement/src crates/craig-placement-contracts services/craig-cli/src services/craig-web crates/craig-test-lib/src \
      tools/craig-seed/src --glob '!**/routes/cases/ive_determination.rs'
    rg -n 'trait (LedgerKey|ClaimedAct|RetractAct|WindowLedger|EventLedger)|fn (claim_act|retract_with|deny_pure_service)' services/craig-cases/src

Erratum (2026-09-25): U3 (#2018) — E6 (Verification): close-out grep 2 also covers services/craig-placement/tests services/craig-cli/tests xtask/src, with --glob '!**/tests/constraints/removal_episodes_migration.rs' (the re-cut’s own test names the dropped columns to prove the drop, as the excluded migration does).

Erratum (2026-09-26): U7 (#2024) — K3 (Verification): close-out grep 1 also carries --glob '!**/tests/constraints/placement_goal_drop_migration.rs' (the drop’s own test names the dropped column to prove the drop, as E6’s exclusion does for the re-cut).

Erratum (2026-09-26): U7 (#2024) — K4 (Verification): the goal’s hyphenated locale keys and the e2e / CLI test trees are outside grep 1, so U7’s close-out also runs rg -n 'permanency-goal|goal-placeholder|goal-(reunification|adoption|guardianship|long-term-foster-care|emancipation|relative-placement|not-yet-established)' services/craig-web services/craig-portal and rg -n 'permanency_goal' tests/e2e services/craig-cli/tests, each empty but for the e2e retirement pin on #permanency_goal.

Rollout + risks

Unit Roll first → then

U1a

cases alone (behaviour-neutral)

U1b

craig-security → cases (the devstack wipes + reseeds)

U2

craig-security (the arm; no producer yet)

U3

craig-security → placement (refuse-on-data onto an empty DB, floor bump, every replica replaced before traffic; the devstack wipes + reseeds) → craig-web — in the window the old web cannot create a placement (the create contract changed) and meets no cancelled row unless the CLI cancels in the window (accepted: devstack-only before any production data)

U4

craig-security, craig-web (left_care, the exit form) → placement

U5

craig-security, craig-web (retracted), financial (placement.retracted, the re-anchor consumer) → placement (cutover: voluntary floor bump, every replica replaced)

U6a

craig-security → financial (placement.episode_exited consumer) → placement (episode_exit, the event, the invariant) → craig-web (the handoff records the exit)

U6b

every craig-web at U6a AND guardianship_ending_without_exit EMPTY → financial (the witness)

U6c

every financial at U6b (drained) → placement (refuse-on-data, floor bump) → craig-web

U7

craig-web, craig-portal → placement

Erratum (2026-09-24): U0, filing the unit issues — U6b’s caregiver evidence date is placement code, so U6b rolls financial (the witness) → placement (the evidence date): an older witness never reads caregivers at exit_on.

Erratum (2026-09-25): U4 (#2019) — F6 (Rollout U4 / D2): the migration is additive with no floor bump; ck_episode_current_instants also refuses a retired episode holding a live removal or exit response (D2’s inert rule as a DB twin), so a U3 replica’s retract of an exited episode in the mixed window fails closed.

Erratum (2026-09-25): U5 (#2020) — G5 (Rollout U5): every financial replica runs U5 before placement rolls (the shared queue binds for the fleet, and an N−1 replica consumes and drops the new keys); a financial rollback follows a placement rollback.

Erratum (2026-09-25): U6b (#2022) — I3 (Rollout U6b): a U6b rollback reverses the roll, craig-placement first. The gate reads the named invariant line, because the sweep exits non-zero on any violated craig-placement invariant.

Erratum (2026-09-26): U6c (#2023) — J5 (Rollout U6c): craig-financial (log-only: the placement.ended arm and the reworded A/D texts) rolls after placement; a U6c rollback rolls craig-web back first, then restores craig_placement under an N−1 craig-placement.

Erratum (2026-09-26): U7 (#2024) — K1 (Rollout U7): the drop bumps the floor (mandatory, ADR-063 D3) with no guard and no wipe marker, and every placement replica is replaced before traffic; field_ownership.toml rides the placement image, so a custom rulesets directory moves with it in both directions; a U7 rollback restores craig_placement, then rolls craig-placement to its U6c image, and craig-web / craig-portal may stay.

Risks: U3 moves every placement creator in one MR (the compiler finds the builder calls; the raw-INSERT fixtures are listed in its issue; the overlapping-fixture census is its first step); U1a touches all twelve cases ledgers (the golden pins the wire); a back-dated API removal is honestly tardy under R14 — P-D’s lifecycle e2e must expect it (a P-D input); retract + re-record can re-bill a first period and leaves issued payments (the U5 financial follow-up).

Rulings requested (recommendation first; U0 records each and D1–D7 are then binding)

# Recommendation Alternative

R-B1

split P-B into P-B1 (this page) and P-B2, each gated

one page (≈52 weight)

R-B2

lift the ADR-078 cores (generic event time + reason) into craig-ledger / craig-ledger-contracts; close #2009 option 1 in U1b

a placement copy; a lighter placement model

R-B3

an episode identity row + removal / exit response event ledgers; current instants on the episode, checked at commit

one row updated in place

R-B4

recorded_at DEFAULT now(), never from the API, seed-supplied; first_recorded_at by trigger

a trigger forcing now() (the seed would be tardy)

R-B5

cancel = planned only; retract = an activated row entered in error

cancel from active

R-B6

activated_at = the DB instant, write-once; started_at the business instant, confirmed at activation

one instant

R-B7

the exit refuses while an arrangement is open; (g)(3) / (g)(4) dictionary tokens on the exit; financial re-pointed, drained

the arrangement end reason as the exit’s home

R-B8

no episode_id on permanency_plans; P-D assigns by closed date interval, a same-day exit + re-entry date to the later episode (⁂)

a cases column + cases' first placement client

R-B9

the 24-hour threshold in the federal dictionary (P-A2 erratum)

a placement column

R-B10

retire the portal goal token with the column

a placement-side projection

R-B11

P-B1 lands the release-audit key; P-D emits

a stub emitter

R-B12

episodes reuse the Placement resource type

a new type + rulesets

R-B13

Plaintext + #2000

a placement field registry now

R-B14

drop the CTW / reasonable-efforts columns and sibling_placements

keep them

R-B15

the episode keyed by child; #1804 custody separate

key (child, case)

R-B16

activated arrangements never overlap per child (respite is not a second arrangement) ⁂

admit concurrent arrangements

R-B17

retract refused while an OPEN caregiver binding keys the arrangement; binding create admits only a planned / active placement, both under the placement row lock

cascade-end the binding

R-B18

a re-recorded exit after a retraction is a new response with its own (g)(2) ⁂

continue the retracted chain’s stamp

R-B19

an episode keeps one case for life: a transfer to ANOTHER agency is an exit g)(3; an intra-agency case move during an episode is a follow-up (⁂)

re-point the episode’s case now

R-B20

a historical arrangement never bills; its retroactive per-diem is a financial follow-up (unsupported in CRAIG until then; #1115 does not cover it)

bill on historical record

R-B21

a re-record names the retracted arrangement it replaces; financial re-anchors that anchor’s agreements

refuse to retract an arrangement a subsidy agreement anchors

Errata requested on the program page: D6’s table.

Review log

Round Vendor Resolved model Verdict

1

Anthropic — four fresh contextless lenses (implementer, adversarial domain, Q3/Q4 reader, anchor verifier; 87 anchors, 76 verified) over rev 1

Claude Opus 5.5

no-ship — 21 blockers folded into rev 2 (U1 split; the generic event time; the correction routes; the lifecycle routes, columns and CHECKs; the unit ordering; open / live defined; DB-backed property tests; the historical record act; the episode lock order; the (e)(1) exception; the exit-event emitters and the financial order; the ADR-077 heal; the close-out greps)

check

Anthropic — two fresh contextless verifiers over rev 2 (a blocker-by-blocker checklist; an adversarial implementer)

Claude Opus 5.5

no-ship — 19 of 21 fixed, 2 partial, 12 new defects; all folded into rev 3 (U6 split into U6a / U6b / U6c with the web handoff moved; U1b’s guard, floor bump and closed_at; the open’s prerequisites stated, the closed-case claim dropped; effective arrangements exclude retracted rows; R-B19 corrected to (g)(3)'s "another agency"; cancel moved into U3 so U5 only widens; the event payloads; first_recorded_at off EventRow; the generic signatures; the root-birth lock order; the historical act’s authz and gates; the deferred-trigger SQLSTATE)

verify

Anthropic — one fresh contextless verifier over rev 3

Claude Opus 5.5

SHIP — every earlier defect fixed; six one-line fixes applied (the weight total, ck_episode_current_instants skipping retired episodes, only the guardianship branches of the two WARN functions move, left_care beside the exit tokens until U6c, the floor-bump wording, the CLI-cancel window)

gate

maintainer (plan mode; rev 3 rejected 2026-09-24, rev 4 APPROVED 2026-09-24 with rulings R-B1–R-B21 as recommended)

—

rev 3: no-ship — 14 findings + 3 details folded into rev 4 (table-owned codecs for the orphan rule; the assignment re-check under the lock; the exit’s arrangement derived and the witness bound to it with ended_on == exit_on; the two-sided binding guard; the replacement protocol with financial’s re-anchor; the same-day plan rule; the historical episode; the caregiver evidence date; #1115’s real limit and a follow-up; U1b’s close-writers and guard; birth-active activation bounds; the U6b data gate; U6c placement-first; the placement cutovers; the staged element map; the retracted-episode refusal; the P-B2 reassociation dependency)

verify

Anthropic — one fresh read-only verifier over rev 4 against the 17 gate items

Claude Opus 5.5

no-ship — 15 resolved, 2 partial, 9 new defects; all fixed (the retracted-episode code in D3; the #1115 leftover; the U3 web order; U6c’s truthful rewrite; ended_at > started_at; the pending agreement’s re-snapshot; the left_care WARN skip; OPEN bindings; replaces_placement_id’s slot; the route-key codec; the unit comparison; the invariant’s date arm; two-or-more same-day episodes; `arrangement_ids)

2

open — run by the maintainer through another vendor’s model

open

open

Edit this page · latest