Plan: Custody Episodes and the DOE-SLDS Bind — legal status as a first-class fact (#1804, #1806, #1821)
- Archive record
- Status
- Context (census 2026-10-12 on
main) - Scope
- Restated acceptance
- Design
- D1 — Vocabulary as bundle data (U1)
- D2 — The episode and the history (U2; F2 A, F9)
- D3 — Acts, reads, events, lifecycle (U2; F11 A)
- D4 — Court-order writes (U3; F4)
- D5 — Person identifiers and the GTID (U4; F6 G-a, F7, F8)
- D6 — The custody stage in the projection (U5)
- D7 — The DOE-SLDS legs (U6; F12)
- D8 — Web (U7; F10)
- Forks (the maintainer rules each at approval; rec = recommended)
- Units — each its own MR, one epic
- Test matrix (each row red on
main) - Rollout and risks
- Review log
Archive record
Merge requests: !1904 (U0 plan page + ADR-081, Relates #1804) + !1906 (U1, Closes #2341) + !1909 (U2, Closes #2342) + !1912 (U3, Closes #1804) + !1918 (U4, Closes #1806) + !1921 (U5, Closes #2343) + !1925 (U7, Closes #2344); the close-out !1926 (U6, Closes #1821)
2026-10-15 — approved in plan mode after a contextless round 1 (no-ship, 6 blockers fixed) and the maintainer’s round 2 on GPT Astra (no-ship, 13 findings fixed). What landed: the 24-code legal-status vocabulary as bundle data (U1); custody episodes and the legal-status ledger, five events, the case-close trigger (U2); court orders write the children’s custody rows (U3); the GTID as an encrypted person identifier, demographics first, with an audited reveal (U4); the custody stage in the outbound projection (U5); the six DOE-SLDS legs: the GTID pin, per-child order, the predecessor wait, the reentry skip, per-type wire validation, the GTID-free acknowledgement store, the consent knob default off (U6); the web legal-status panel and person identifiers (U7). Follow-ups stay open: #1073 (the DFCS readings), #1813, #2345-#2348.
Status
Done (2026-10-15) — !1926
Erratum (2026-10-13): before the live episodes' FOR UPDATE, each act takes a transaction-scoped advisory lock per named child in child-id order, so two cases' acts on one child serialize (a child with no live episode has no row to lock).
Erratum (2026-10-13): a court-order update that names a child again with its live order row’s own token and date leaves that row as is (no successor, no event).
Erratum (2026-10-14): the reveal’s case.person_pii_exported wrapper names the revealing worker as user_id (an #2211 actor key), not requested_by, which the census holds as CONTEXT for a service release; under it a human reveal would audit with no actor.
Erratum (2026-10-14): a custody read whose identifier names no GTID row of the child serves no GTID; "else" applies only when identifier is absent.
Erratum (2026-10-15): exchange’s custody and stage reads did not take U5’s identifier; U6 adds it to all four custody and stage read functions and to read, not to OutboundReads::stage_principal alone.
Erratum (2026-10-15): the INC’s spent wait is held predecessor-unsettled inside its resolve transaction, under the child lock, not at the worker’s last attempt; the worker’s after-dispatch hold skips that class. Likewise an occurrence skipped as superseded-by-reentry leaves its admission dismissed with that reason.
Erratum (2026-10-15): impl TriggerRuntime stays at its 16-method cap and the resolve, close, record, supersede and release bodies do not grow, so the DOE passes are free functions (services/craig-exchange/src/triggers/doe_passes.rs, services/craig-exchange/src/triggers/legs/doe_slds.rs).
Erratum (2026-10-15): exchange had no read for D6’s person → open-episode arm; U6 adds OutboundReads::person_custody_stages. A catch-up or custody-keyed DOE admission takes its child from the custody stage’s principal; subject_person_id is required only for the identifier legs.
Erratum (2026-10-15): AckOutcome::Accepted carries the body to store, and the stored DOE acknowledgement is transaction_id, status and received_at only.
Erratum (2026-10-15): craig-exchange gains a direct dependency on craig-partner-doe-slds (it reached the adapter only through the bundle registry) and a mock-featured dev-dependency for its in-crate DOE tests.
Erratum (2026-10-15): an INC re-stages at assembly only behind a live DOE record of the child on an OLDER stage (episode ids are uuidv7(), so < is creation order), not on any other stage: matching a newer stage let two episodes' live INCs re-stage behind each other forever.
Erratum (2026-10-15): "errors classify as CPRS’s" is one generic classifier over the transport’s PartnerFailureView, not a copy; a DOE bad status carries no body digest.
Erratum (2026-10-15): "requires `gtid`" is a minimum length of one; the wire type validated only a maximum, so an empty GTID passed.
Erratum (2026-10-15): the entry also requires the Out-of-Care date (legal_status_end_date) on an OUC, per the catalogue’s OUC row (cat/:492).
Erratum (2026-10-15): the devstack DOE partner row already existed and the seed links no partner to an agreement, so U6 adds no seed row; each devstack test installs its own partner and agreement (the DSA chain is per test).
Erratum (2026-10-15): the two devstack DOE tests need no nextest filter change (the existing outbound_triggers:: clause matches them); only the in-crate triggers::doe_legs_tests module gains a clause.
Erratum (2026-10-15): the coverage matrix is a generated snapshot; U6 adds its two devstack tests to the untagged list rather than regenerating it.
Erratum (2026-10-15): U6 also amends ADR-075 decision 9 (the DOE key is the child) and updates ADR-003 and the implementation guide’s custody rows, which the diff would otherwise make false.
Erratum (2026-11-06): #2353, ruled Option A. D2’s in-day order is (effective_on, chain_seq), not chain_root_id (F9’s "ids being v7" no longer orders a day). A v7 is monotonic only within one process, so under replica clock skew a same-day close recorded after a change could sort first and be refused. chain_seq is a per-child number: an original takes the next one under D2’s per-child advisory lock, and a correction keeps its root’s. Migration 20261106140000_legal_status_chain_seq back-fills existing rows in chain_root_id order and bumps the floor.
Glossary. This page is docs/modules/ROOT/pages/plans/archive/custody-episodes-doe-slds.adoc. ⁂ marks a reading DFCS may rule otherwise, logged on
#1073 (it confirms a reading, it does not gate the build). D = design, F = fork, U = merge request, AC = a restated criterion. "The fix lane"
= #1815, #1837, #1838. "Same-partner recipient" = a row of exchange_outbound_recipients for the same DOE partner. :line prefixes: cases/ =
services/craig-cases/src/, cc/ = crates/craig-cases-contracts/src/, ex/ = services/craig-exchange/src/, doe/ =
crates/craig-partner-doe-slds/src/types.rs, cat/ = docs/modules/ROOT/pages/interfaces/doe-slds-interface.adoc, otp/ =
docs/modules/ROOT/pages/plans/archive/outbound-trigger-parity.adoc, …recut.sql = services/craig-placement/migrations/20260925130000_removal_episodes_recut.sql.
| Anchor | What binds here |
|---|---|
#1804 (P2, W8), #1806 (P2, W3), #1821 (P2, W3) |
one program; #1804 is the spine of four binds (ADR-075 |
Removal episodes (ADR-079 D2, |
the identity row: stable id, owning case for life, deferred instants, |
The D1 ledgers (ADR-078 |
event ledger, |
The trigger substrate (ADR-075 |
matrix rows, admission + recipient ledgers, knob, projection, catch-up, rollout |
The DOE wire (doe/ |
INC / OUC / RMV, status NEW, 24 CLEGSTAT codes;
per-type mandatory fields (RMV: In-Care date and GTID only); |
Context (census 2026-10-12 on main)
-
No legal status anywhere. Only the partner wire crates carry one. The catalogue’s trigger is "a GTID number has been validated and the child’s most recent, active Legal Status is In-DFCS custody" (cat/
:393). DOE’s code table has no class column (cat/:247-325); the WIC catalogue lists the in-custody statuses: Permanent Court, Permanent Voluntary, Short Term Emergency Care, Temporary Court, Temporary Voluntary and the two Joint Commitments with DJJ (interfaces/wic-referral-ies.adoc:53,:953). -
The nearest facts do not fit.
court_ordersis case-scoped, has no child and emits no custody fact (crates/craig-reference/src/enums.rs:1043). Removal episodes hold placement-and-care; custody is "a separate craig-cases fact" and an in-agency move is a reassignment on the same case (data-model-placement.adoc:1040-1042, #2028). -
The substrate is stage-shaped. Recipients are
UNIQUE (interface, partner_id, stage_kind, stage_id, person_id), insert-once, with no record of the identifier a person was listed under (services/craig-exchange/migrations/20260913150000_outbound_triggers.sql:47-69); record jobs order per stage (ex/triggers/dispatch.rs:815-818, ex/store/send_jobs.rs:267-272), andclosed_sent_atis stamped at staging, not at send (ex/store/trigger_ledgers.rs:294-298).OutboundStageKindhasCaseandInvestigationonly (cc/outbound_principals.rs:31-36). A re-entry must send INC again under a newstage_id: the custody episode needs a stable id of its own. Only CPRS is bound (crates/craig-state-ga/src/outbound.rs:28-48);doe_sldsis registered (crates/craig-state-ga/src/lib.rs:115); the knob struct has onlycprs(crates/craig-common/src/settings.rs:493-511).
Scope
In: D1–D8. Out: the DOE GTIDLookup adapter (cat/:516; F7, #2345); the weekly DOE inbound; other identifier kinds (EMPI later); the
WIC, IES and STARS binds; a status change inside custody reaching DOE (no such request type); a second GTID inside one episode (#2346); a
custody-expiration date (DOE-2.1.15; optional on the wire); a person-wide custody read (#1804 asks for the case); education_records; AFCARS
use of custody; the removal-episode cross-check (F5, #2347); a pause for staged outbound jobs (#2348); a same-day exit and re-entry
(F9); the production DOE endpoint, DSA and credentials (#1813).
Restated acceptance
#1804 (stale: craig-reference; Placement.removal_date, dropped by #2018, …recut.sql:306; one event key). AC1. GA’s 24 CLEGSTAT codes
are StateBundle data with D1’s classes (F1), pinned to DoeSldsLegalStatus by a test; ⁂ #1073 confirms both. AC2. Per-child legal-status
history with effective dates, each in-custody run under a custody-episode identity row with a stable id, readable on the case. AC3. Manual acts
stating their intent and court-order-driven writes (F4) set it; corrections keep the episode id; case closure follows F11. AC4.
case.custody_opened, _closed, _retracted, _close_corrected and case.legal_status_changed (F3), ids-only, in ADR-003 and the security parser in the same MR.
#1806 (re-homed by F6: it puts the GTID on EducationRecord, services/craig-placement/src/store/models.rs:389; the catalogue reads it from
Person Identifiers, cat/:57, :385, :401). AC5. A cases person_identifiers ledger holds the GTID (kind gtid) encrypted under
BlindIndex (F8), only for a person with a DOB and names; a malformed value or date is a typed 422, a GTID live on another person a typed
409; end and retract acts; case.person_identifier_recorded / _ended, catalogued with security arms, replace #1806’s proposed (never emitted)
placement.education.gtid_validated; an audited reveal; the person’s authorization. "Validated" = format-checked and worker-attested (F7).
#1821 (blocked on the above; its "NEW" is the interface status, INC the request type, doe/:36-41). AC6. GA matrix rows citing cat/:67-73:
INC on an open episode with a live GTID, never before an earlier episode’s removal unless its closing admission was dismissed; OUC on its close and on a corrected close of the child’s
latest stage (F12); RMV on the GTID’s end or retraction, or the retraction of the child’s latest stage, each reaching only recipients listed under
that GTID or stage; per-type validation; one record per job; categorical settlement; CRAIG_EXCHANGETRIGGERSDOE_SLDS__ENABLED (default off)
+ the DSA chain; the devstack partner row and mock capture; contested legs by name; the deployment-guide row. No placement read (F6).
Design
D1 — Vocabulary as bundle data (U1)
StateBundle::legal_statuses() → Vec<LegalStatusSpec>, default empty (the uas_codes() doctrine, crates/craig-state-bundle/src/bundle.rs:61-66;
ADR-072 :55). LegalStatusSpec { token, label, custody_class: CustodyClass }, CustodyClass { InCustody, NotInCustody }, a closed neutral
enum. GA contributes the 24 codes (doe/:109-207) with these classes, the readings U0 logs on #1073:
| Class | Tokens | Source |
|---|---|---|
|
PCT, PVL, STE, TCT, TVL, JCP, JCT |
the catalogue’s "In DFCS Custody" list (Context), read as DOE’s too ⁂ |
|
NAF, NCT, NCD, NCO, NTT, NCE, NGP, NPC, NPR, NOT, NCS, NCR ("Not In DFCS Custody – …"); AFS, CTD, ILP, NDJ, DJA (aftercare, DJJ commitment) |
the twelve by name; the five because that list omits them ⁂ |
Cases resolves the list at boot: a duplicate or malformed token (not 1–16 ASCII uppercase letters or digits) refuses boot; an empty list (the TX
stub) answers every custody act with a typed 422 legal-status-vocabulary-missing, never a guess.
D2 — The episode and the history (U2; F2 A, F9)
-
custody_episodes:id(v7),child_id,case_id(one owning case for life),custody_from DATE,custody_until DATE NULL, recorded / retired columns asremoval_episodes(…recut.sql:127-148),EXCLUDE USING gist (child_id WITH =, daterange(custody_from, custody_until, '[]') WITH &&) WHERE retired_at IS NULL(inclusive: a one-day episode is a one-day range, and a re-entry opens the day after an exit at the earliest), a row guard admitting only the instants update and a retire (:102-120). -
legal_status_facts: acraig-ledgerEVENT ledger keyed by the sharedCaseChildKey(person_id= the child,case_id; cases/store/ledger_codecs.rs:24-47):status_token,custody_class(stamped at write, so a reclassification never rewrites history),effective_on,chain_root_id(the row’s own id on an original),episode_id NULLandcourt_order_id NULL, all fact columns corrections inherit (thecourt_order_idprecedent,services/craig-cases/migrations/20260923180000_permanency_ledgers.sql:115, cases/store/child_review_events.rs:38,:75-78),note,supersedes_id, retire columns; its retired-reason CHECK andLedgerRetiredReason(cc/ledger.rs:97-133) gainepisode_retracted. Rows order by(effective_on, chain_root_id), ids being v7; the status in force on a day is the last live row on or before it. -
An act states its intent. An in-custody row without
episode_idopens an episode (409custody-episode-overlapif it overlaps any live episode of the child, this case or another); with one, it is a change in that open episode. A not-in-custody row withepisode_idcloses that episode; without one it is a history row, refused while the child has an open episode in this case (409custody-episode-open, naming it) or when dated inside a live episode’s span (409custody-row-out-of-order). A named episode that is closed, retired or another case’s is 409custody-not-open. -
Episode rule, after every act. An episode’s live rows are its in-custody rows, then at most one closing row, ordered after each of them (else 409
custody-row-out-of-order);custody_from= the earliest in-custody date,custody_until= the closing date; every date is on or before today (jurisdiction clock). A correction supersedes within its class (a flip is 422) and keeps its episode; the instants follow. A one-day episode, and a change then a close on one day, are both representable. -
Retiring a row (the row retract, or D4’s sweep): (i) another live in-custody row remains: the instants follow; (ii) it was the last live in-custody row: the episode retires as in an episode retract, this row included; (iii) it is the closing row: 409
custody-close-not-retirable. A closed episode never reopens, because DOE has been sent OUC; correct the close (F12) or retract the episode. -
Episode retract retires the episode and, in the same transaction, every live row of it as
episode_retracted, the triggering row of rule (ii) too. Those rows are the snapshot D6 serves for RMV; D4’s sweep retires live rows only (child_review_events.rs:128-143), so it never touches them. -
Each act takes one lock order (ADR-079
:103-106): claim → the case row (require_case_open,FOR UPDATE, cases/store/cases.rs:202-216, on open / change / close; elseFOR KEY SHARE) → the live episodes of every child the act names, in every case, in oneFOR UPDATEstatement ordered by id; it ends withSET CONSTRAINTS ck_custody_episode_current_instants IMMEDIATE(ADR-079:121-126): the EXCLUDE answers a typed 409custody-episode-overlap; the deferred trigger (live episodes only) stays an internal invariant no request can trip.
D3 — Acts, reads, events, lifecycle (U2; F11 A)
-
Routes under
/v1/cases/cases/{case_id}/children/{child_id}/(the P-C shape, cases/api/ledgers/child_facts.rs:3-17), ADR-062 idempotent:POST legal-statuses{client_request_id, status_token, effective_on, episode_id?, note?, until?: {status_token, effective_on}}(untilwithoutepisode_idrecords a closed historical episode in one act);POST legal-statuses/{row_id}/corrections{client_request_id, status_token, effective_on, note?};POST legal-statuses/{row_id}/retractandPOST custody-episodes/{id}/retract{client_request_id, note}(crates/craig-ledger-contracts/src/lib.rs:101-110). Reads:GET /v1/cases/cases/{case_id}/custody-episodes[?child_id=]andGET …/children/{child_id}/legal-statuses. -
Authz on the case resource (
case: read/update,ledgers/child_facts.rs:95-101), no new authz file; the child holds a child-role household row of the case (400child-not-in-case). Field specscrates/craig-cases-fields/src/{custody_episodes,legal_status_facts}.rs. -
Lifecycle (F11 A). Open, change and close take
require_case_open(409case-closed); history rows, corrections and retractions pass on a closed or transferred case (data-model-cases.adoc:8-25). ABEFORE UPDATE OF statustrigger oncasesrefusesclosed/transferredwhile a case episode is open (the cross-table trigger precedent:ck_arrangement_in_episode,…recut.sql:297-302); U2 maps its error to 409custody-open, and a pre-U2 replica still serving gets it as a 500, never a closed case with open custody. The case row lock serializes a close with a racing open. -
Events, ids-only (ADR-078
:75), on theplacement.episode_exitedmodel (ADR-003:61):{episode_id?, child_id, case_id, row_id, act, act_id, act_at, user_id}.case.custody_opened/closed/_retractedon those transitions (anuntilact emits_openedthen_closed, each with its row’s id);case.custody_close_correctedon an act that changes a closed episode’s instants or closing token (a correction, or rule (i));case.legal_status_changedon every other act (a change, a correction or rule (i) on an open episode, a history row). ADR-003 rows; craig-security arms and families:case.custody→episode_id(resourcecustody_episode;openedacreate, the rest anupdate),case.legal_status→case_id(resourcecase, anupdate) (services/craig-security/src/event_parsing.rs:77-123; the count pin at:3275becomes 34).
D4 — Court-order writes (U3; F4)
-
CreateCourtOrderRequest.custody: Option<CourtOrderCustody {children, status_token, effective_on}>(cc/court_orders.rs:47) writes one D2 row per child in the order’s transaction, withcourt_order_id, under D2’s rules; child-role members only, at mostHEARING_CHILDREN_MAX(:16). An order row takes the intent the child’s state in this case implies: an open episode makes it a change or a close, none an open or a history row. -
Idempotency.
CourtOrderIntentV3(cases/api/intents/casework.rs:257-271) addscustody, an explicitnullwhen absent (crates/craig-api/src/request_claims.rs:42-44); every court-order create hash moves once with theschemakey (the V2 precedent,casework.rs:17-23), so a create retry spanning the U3 deploy answers 409idempotency-conflict(pre-1.0, no dual decode; a CHANGELOG ops note). The update is If-Match-versioned (cases/api/court_orders.rs:363,:390), not hashed. -
UpdateCourtOrderRequest.custodyfollows the hearing rule (:120-125): absent = unchanged, so a judge-name fix touches no custody row. A value restates per child: named again, the order’s live row is corrected (same class, the episode id stays; a flip is 422); no longer named, its row is retired; newly named, a new row. An order delete retires every live row it wrote. -
Retirement runs D2’s rules through the sweep (
order_corrected/order_deleted): (i) emitscase.legal_status_changedorcase.custody_close_corrected; (ii)case.custody_retracted(DOE RMV), every rowepisode_retracted; (iii) refuses the whole order act with 409custody-close-not-retirable, nothing written. No order-type → status derivation.
D5 — Person identifiers and the GTID (U4; F6 G-a, F7, F8)
-
person_identifiers:id,person_id,kind(StateBundle::identifier_kinds() → Vec<IdentifierKindSpec {token, label, format}>, default empty, boot-resolved as D1; GAgtid,IdentifierFormat::Digits(10)⁂; an undeclared kind, so every TX act, is a typed 422identifier-kind-unknown),value(CGEF) +value_hmac(BlindIndex,field_domain = "person_identifier",Canon::AsIs: the value is format-checked, never trimmed, a malformed one 422identifier-format-invalid; thecrates/craig-cases-fields/src/persons.rs:134-147shape),effective_from(on or before today),effective_until(fromeffective_fromto today; else 422identifier-dates-invalid),provenance = worker_attested, retire columns. Live = neither retired nor ended. Partial UNIQUEs over live rows: one per (person, kind); one per (kind,value_hmac), a violation 409person-identifier-duplicatenaming no one. The secondBlindIndexentity (crates/craig-cases-fields/src/lib.rs:11-12): the seeder,xtask verify-seedand the key lineage cover it. -
Demographics. Record takes the person row with
lock_person(cases/store/persons.rs:286-295) and refuses a person with no DOB or a blank first or last name (422person-demographics-incomplete). A DOB cannot be cleared (date_of_birth = COALESCE(…),store/persons.rs:215), and a person update that would blank a name of a person holding a live identifier is 409person-identifier-live, checked under the same lock. So every GTID holder carries the INC demographics (D7); supplying a DOB, then recording the GTID, is the path to the INC. -
Acts, ADR-062 idempotent: record
{client_request_id, kind, value, effective_from}, end{client_request_id, effective_until}, retract{client_request_id, note}. Events{identifier_id, person_id, kind, act, act_id, user_id}:case.person_identifier_recordedon record,case.person_identifier_endedon end and retract (actsays which; DOE scenario 3 is "end-dated / marked invalid", cat/:494-498). ADR-003 rows; craig-security arms file both under resourcepersonthrough the existingcase.person_family (the #2032 posture, ADR-003:97), since acase.person_identifier_family would failresource_id_families_are_prefix_disjoint(event_parsing.rs:3273). -
Reveal stages a fourth
case.person_pii_exportedwrapper before the body (purpose = person_identifier_reveal,{person_ids, identifier_id, kind, requested_by}; cases/events.rs:463-480),Cache-Control: no-store; anexport, so thedata_exportdetection rule sees each one. -
Routes:
POST /v1/cases/persons/{id}/identifiers,…/{identifier_id}/end,…/retract,…/reveal;GET …/identifiers(masked to the last four). Authz inherits the person’s exactly, throughPersonPath::authorize(cases/api/ledgers/mod.rs:89-99): the list = Person read; record, end, retract = Person update; reveal = Person approve (GA: Admin and Supervisor,rulesets/georgia/georgia-authz-person.json:128,:143; the SSN verification posture, cases/api/persons_ssn.rs:60-66).deny_pure_serviceprecedes every identifier route, the list included, as on every ledger route (ledgers/mod.rs:11-12); exchange reads a GTID only through D6. No new resource type or ruleset file; each jurisdiction’s person ruleset (georgia-,texas-authz-person.json) applies unchanged.
D6 — The custody stage in the projection (U5)
-
ADR-075 amendment:
OutboundStageKind::CustodyEpisode(custody_episode). The wire extends in place (one exchange resolve and dispatch path):OutboundStage.custody: Option<OutboundCustody {custody_from, custody_until, retracted, rows: [{status_token, custody_class, effective_on}]}>,OutboundPrincipal.gtid: Option<OutboundGtid {identifier_id, value, ended_on, retracted}>(live = neither; both skipped whenNone: CPRS bytes unchanged) andOutboundReadQuery.identifier: Option<Uuid>. The contract (cc/outbound_principals.rs:3-8, "No SSN …") gains "the GTID, custody arms only" (Changed). -
An episode stage:
stage_id= episode id;partner_case_id,case_number,admin_unit,county_fips,assigned_workerfrom the owning case;statusopen/closed/retracted;opened_at= the episode’srecorded_at;closed_at= the closing row’srecorded_ator the retire instant.rowsare the episode’s live rows, or for a retracted episode itsepisode_retractedrows (D2). The principal is the child (rolechild); itssource_versioncovers the person row, the served GTID row and the served rows. -
Arms behind the allowlist (cases/
api/outbound_principals.rs:41): set and single-recordGET /v1/cases/custody-episodes/{id}/outbound-principals[/{person_id}], serving closed and retracted episodes (404 only for an unknown id), with the GTIDidentifiernames (that person’s, live or not), else the live one, else the latest ended or retracted; a person → open-episode id armGET /v1/cases/persons/{id}/outbound-custody-stages(the report arm’s shape); the open-stages arm (cases/api/outbound_stages.rs:89-100): open episodes whose child has a live GTID. Each read stages the existing outbound release wrapper (stage_kind = custody_episode, cases/events.rs:772-797); nocase.outbound_principals_releasedexists (ADR-075:14-17). -
Exchange learns the kind: ex/
triggers/cases_reads.rs:144,:162route it;triggers/dispatch.rs:903parses it;cprs_stage_type(triggers/legs.rs:472-477) returnsOption,Nonerefusing assembly (a CPRS leg never meets a custody stage). No exchange migration in U5.
D7 — The DOE-SLDS legs (U6; F12)
-
Matrix (GA), one leg per event, as a leg fixes its admission key (ex/
triggers/admission.rs:159-194):case.custody_opened→doe_slds/custody_openedandcase.person_identifier_recorded→gtid_recorded(INC);case.custody_closed→custody_closedandcase.custody_close_corrected→custody_corrected(OUC);case.custody_retracted→custody_retractedandcase.person_identifier_ended→gtid_ended(RMV; ⁂ retraction as removal).case.legal_status_changedbinds nothing. -
Exchange:
Family::DoeSlds, sixDoeSlds*legs (ex/triggers/legs.rs:57-100,:171);EntityKind::CustodyEpisode(custody_*, keyedepisode_id) andPersonIdentifier(gtid_*, keyedidentifier_id;admits_eventonly forkind = gtid) (:145). The revision is0, exceptcustody_corrected, which keys on the event’sact_idso each correction is its own admission (theCprsInvPrincipalAddedprecedent,admission.rs:185-192).subject_person_idcomes from the event’schild_id/person_id; the request type isLeg::doe_request_type()(a record job takes its leg from its admission,dispatch.rs:761-781);TriggerSettings.doe_slds+ itsenabledarm;catch_up_leg(doe_slds, CustodyEpisode)=custody_opened. -
Pinning. U6’s migration adds
exchange_outbound_recipients.subject_identifier_id UUID NULL(NULL for CPRS), an index on(interface, partner_id, person_id, subject_identifier_id) WHERE removed_at IS NULL, and bumps exchange’sschema_compat_floor(Rollout). INC’sadmit_newstamps the served GTID’sidentifier_id. Thegtid_endedRMV stages only the subject’s same-partner recipients withsubject_identifier_id= the admission’sentity_id; OUC, the retraction RMV and the F12 re-send read withidentifier= the recipient’ssubject_identifier_id, on the resolve read, every record-job read and supersession (OutboundReads::stage_principalgains it,dispatch.rs:537-585). So a later GTID never replaces the one DOE listed, and ending an old GTID never touches a recipient listed under a newer one. -
Ordering across episodes. Every DOE resolve takes, after its stage lock (taken first by every resolve, ex/
store/trigger_stages.rs), a per-child transaction lock (a two-key advisory lock with its own class constant, the ex/store/trigger_stages.rs:38-45precedent) before its ledger reads, and DOE record jobs take the ordering keydoe_slds:{person_id}(the child), not the stage (dispatch.rs:815-818gains a per-family key; CPRS unchanged), so one child’s DOE records send in staging order (the claim guard,send_jobs.rs:267-272). Under the lock, with "older" and "newer" by stage id (v7; only open stages are admitted, so creation order is custody order):-
an INC resolve waits while the child holds an older same-partner recipient with neither
closed_sent_atnorremoved_atwhose closing admission is not dismissed: a new retryable classpredecessor-unsettled(ex/triggers/settlement.rs:86-91) whose last attempt holds the admission with that token rather thanretries-exhausted(ex/send_worker.rs:241-252). The transaction that stages a child’s removal (CloseExisting,RemoveAndSend) releases that child’s admissions heldpredecessor-unsettled, re-evaluated as the operator release does (ex/triggers/acts.rs:121); -
an INC, a retraction RMV or an F12 re-send for a stage older than the child’s newest same-partner recipient settles
superseded-by-reentry, nothing sent (⁂ DOE keeps the older stage’s last data). Agtid_endedRMV is never skipped: it only removes; -
at assembly, an INC re-stages behind any pending or in-flight DOE record of the child on another stage, through the supersede path (
dispatch.rs:707-746), so a superseded OUC re-inserted with a newer id still sends first; -
together: an earlier episode’s removal is sent before a later episode’s INC, and nothing for an older stage follows it except a
gtid_endedRMV, which removes only the GTID it names, whichever key DOE lists by (GTID or stage; cat/:70,:73leave it unstated).
-
-
INC (
AdmitNew): the stage is the episode, or for an identifier the person’s open episode (D6’s person arm).Leg::admitsgains the stage (today(principal, today),legs.rs:298) and admits the child with a live GTID on an open stage only, soadmit_new’s closed-stage staging (decision 9, `dispatch.rs:325-371) never fires for DOE (DOE lists children in care, cat/:393): a historical episode never reaches DOE. Whichever fact commits second admits; the recipient UNIQUE absorbs a duplicate. -
OUC (
CloseExisting): stampsclosed_sent_atand bumps the stage epoch (#1839). F12 re-send: a newResolveRule::ResendCloseforcustody_correctedstages one OUC per same-partner recipient of the stage withclosed_sent_atset andremoved_atNULL, assembled from the current projection ⁂ (the catalogue is silent on a second OUC; DOE-4.1, cat/:41, asks for updated SHINES data fields). An open episode’s start-date correction reaches DOE in its OUC, whose In-Care date is the correctedcustody_from. -
RMV: a new
ResolveRule::RemoveAndSend(+ReadingRule,legs.rs:103-128): read the subject’s record pinned as above; under the stage lock bump the epoch, stampremoved_atviaretire_recipient(now returning the row and, forgtid_ended, filtering on the pin, ex/store/trigger_ledgers.rs:325-345) and stage one record for a recipient it stamped. Stages: the episode (a retraction), or the subject’s pinnedcustody_episoderecipients (an identifier). It reaches a recipient whether or not its OUC was sent (cat/:457conditions RMV on the GTID’s end only) ⁂. -
INC guard. INC assembles only from an open episode and a live GTID, else terminal
assembly-refused, nothing sent: a superseded job re-stages behind a later OUC or RMV in the FIFO (ADR-075 decision 8; ex/store/send_jobs.rs:242-272), and an INC after its own end would re-list the child. DOE may then get an OUC or RMV for a child whose INC was refused, which only de-lists. -
Assembly of
DoeSldsCustodyEntry(doe/:221-290), validated per request type:case_id,person_id,stage_id,first_name,last_name,date_of_birthandlegal_statusbecomeOption, and a garde validator requires each, non-empty, for INC and OUC and onlygtidandlegal_status_start_datefor RMV (cat/:486,:492,:498); the mock validates and gains a 10-digit reject sentinel (todayREJECT_FOR_TEST_GTID,crates/craig-partner-doe-slds/src/mock.rs:35, which no GTID passes). An RMV is never refused for demographics.-
submitted_datethe record job’screated_atas a business date (BusinessClock::date_of; a retry is byte-identical, DOE-2.1.3);request_typeby leg;statusNEW(DOE-4.1.2 / 4.1.3);transaction_idthe job’s correlation id. -
gtidthe pinned GTID;case_idthe stage’spartner_case_id(referral_id ?? id, ADR-075:165);person_idthe child;stage_idthe episode; names and DOB from the principal;middle_nameabsent: CRAIG records none, where cat/:486,:492list it ⁂. -
legal_status: INC and RMV the latest served in-custody row’s token (a retracted episode’s snapshot always holds one, D2); OUC the closing row’s token; one outsideDoeSldsLegalStatusisassembly-refused. -
legal_status_start_date: INC that row’seffective_on(DOE-2.1.14, cat/:441); OUC and RMVcustody_from(the In-Care date) ⁂. -
legal_status_end_date: INC and RMV absent; OUCcustody_until, the catalogue’s Out-of-Care date (cat/:492) on the wire’s custody-expiration field (cat/:445) ⁂.
-
-
Acknowledgement.
classify_ackaccepts aDoeSldsCustodyAckwhosetransaction_idandgtidequal what was sent (the sent GTID ridesSentRecordin memory), elseack-mismatch, and whosestatusisSNT, elsepartner-rejected(the mock’s 200ERR,mock.rs:32-35); errors classify as CPRS’s (legs.rs:482-510). The worker stores an accepted response (ex/send_worker.rs:671-678), soAckOutcome::Acceptedcarries the body to store: DOE’s minusgtid. No GTID rests in exchange.
Forks (the maintainer rules each at approval; rec = recommended)
F2 — custody model. A (rec): D2, an episode identity row plus a legal-status ledger. Consequence: two tables and a deferred trigger; the DOE
stage_id never moves. B: one status ledger, the episode derived as the maximal in-custody run. Consequence: one table, but the stage id
drifts unless roots are tracked, non-overlap is not a database fact, and every consumer re-derives the episode. C: the placement removal
episode. Consequence: contradicts the separate-fact ruling, needs a cross-service reference, conflates placement-and-care with custody.
F6 — where the GTID lives. G-a (rec): D5, as SHINES does (cat/:401). Consequence: one cases projection serves the bind, the end date RMV
needs is a ledger fact, EMPI joins later as a kind. G-b: education_records.gtid in placement, as #1806 is written. Consequence: rows edited
in place carry no end date for RMV, and this program gains a placement S2S projection and an exchange placement client.
F7 — how it is validated. Worker-attested now, with a filed issue for the GTIDLookup adapter (rec). Consequence: no external gate; a mistyped
GTID that passes the format check reaches DOE until a worker ends it (RMV), and as recipients are insert-once
(ex/store/trigger_ledgers.rs:184-206) the corrected GTID reaches DOE only with the child’s next episode (the second-GTID follow-up). Verify-first:
a new DOE adapter plus DOE / GTA access. Consequence: the build gains an external gate, and the unit likely splits.
F11 — case closure with custody open. A (rec): D3, closure or transfer refused while an episode is open, by a DB trigger. Consequence: the
worker records the not-in-custody status first; as an in-agency move is a reassignment, transferred means the case left the agency and custody
ends first (NCO, NTT, NCS). B: custody acts pass on a closed or transferred case. Consequence: the DOE stage outlives the case; a second #1631 exception.
F12 — a corrected close. A (rec): D7’s re-send for the child’s latest stage, ⁂ that DOE takes a later OUC as a replacement. Consequence: a DOE
that refuses it answers ERR (partner-rejected); an older episode’s correction stays in CRAIG only. B: no re-send; an operator procedure.
Consequence: DOE keeps the wrong dates until a person acts outside CRAIG.
Minor forks. F1 vocabulary in the StateBundle with a per-token class (rec) OR craig-reference as #1804 says (a GA list in the neutral crate).
F3 per-transition keys (rec) OR one case.legal_status_changed with a categorical transition. F4 the status named on the order act (rec) OR
manual-only in v1. F5 independent of removal episodes plus a filed advisory-check issue (rec) OR enforced coupling. F8 BlindIndex (rec;
duplicate check, future DOE inbound match) OR Opaque (no duplicate check). F9 DATE ordered within a day by chain root (rec; court and CLEGSTAT
dates; a same-day exit and re-entry is not representable) OR TIMESTAMPTZ. F10 web (rec) OR API only.
Units — each its own MR, one epic
Order: U0 → U1 → U2 → (U3 ∥ U4) → U5 → U6; U7 after U2 and U4; U6 waits on the fix lane (#1815 typed-partner correlation, #1837 act bounds,
#1838 contested census). Each MR closes its own unit issue (epic &107: U1 #2341, U2 #2342, U5 #2343, U7 #2344) and Relates to its parent; U3 closes #1804, U4
#1806, U6 #1821. The first code unit sets Status In progress; each MR is green alone with its CHANGELOG entry; each new test carries // @axis:.
Whichever of U6 and U7 merges last closes out (Status Done, the archive row, plan-lint --done --allow-open 1073,1813,2345,2346,2347,2348).
| U | W | Content and why it is one MR | Pages |
|---|---|---|---|
U0 |
1 |
The epic (&107); re-parent #1804, #1806, #1821; unit issues; follow-ups #2345–#2348; restated ACs on the issues; D1’s classes and the ⁂ readings on #1073. Docs only |
this page (Active nav), ADR-081 (Proposed, the custody model) |
U1 |
2 |
D1: spec, GA data, the drift pin, boot resolution. Data with no consumer is inert, so it ships alone |
|
U2 |
8 |
D2 + D3: migration (both tables, the closure trigger, the retired reason), acts with stated intent, history rows, reads, field specs, events with ADR-003 rows and security arms (ADR-003’s same-MR rule) |
|
U3 |
3 |
D4: the court-order act, its V3 intent and its sweep, a separate contested surface |
|
U4 |
3 |
D5, parallel to U3; the registry, seeder and lineage move with the column; the demographics guard; its events take ADR-003 rows and security arms here |
|
U5 |
3 |
D6 and the exchange arms the new kind forces (inert until U6’s rows) |
ADR-075 amendment, |
U6 |
8 |
D7: the pin migration and floor bump, the per-child lock and ordering key, |
|
U7 |
3 |
D8 and Playwright |
|
Test matrix (each row red on main)
| Test | Axis | U | Asserts; why red on main |
|---|---|---|---|
|
happy |
U1 |
24 tokens equal `DoeSldsLegalStatus’s serde tokens; classes as D1’s table. Red: no spec |
|
evil |
U1 |
any string never panics; accepted ⇔ a bundle token; token → wire → token. Red: no parser |
|
sad |
U1 |
a duplicate or malformed token is a boot error. Red: no vocabulary |
|
sad |
U2 |
TX stub: 422 |
|
happy |
U2 |
201, episode with |
|
evil |
U2 |
overlapping open, same or another case: |
|
conc |
U2 |
two racing or serialized opens: one 201, one 409; a racing change and close serialize, no 500. Red: no table |
|
sad |
U2 |
close; a date correction keeps the id; flip 422; a named closed episode 409; rules (i)–(iii); a one-day episode; a change then a close on one day; an initial NCT and a NAF after NCO as history; a history row while open 409. Red: no acts |
|
evil |
U2 |
an episode retract, and a last-row retract (rule ii): every live row,
the triggering one too, retires |
|
evil |
U2 |
a direct instant UPDATE fails at commit. Red: no trigger |
|
replay |
U2 |
same |
|
evil |
U2 |
a worker outside the case’s unit: 403 on read and write; security records the episode. Red: 404 |
|
conc |
U2 |
close or transfer 409; racing open and close: one commits; a direct status UPDATE (an old replica’s write) refused by the trigger; closed case: open 409, correct passes. Red: closes |
|
sad |
U3 |
per-child rows; a judge-name edit keeps them; restating corrects; delete (i)–(iii); two orders naming the same two children in opposite order do not deadlock. Red: no field |
|
replay |
U3 |
same |
|
evil |
U4 |
any string never panics; accepted ⇔ ten ASCII digits ⁂; no trimming. Red: no parser |
|
evil |
U4 |
CGEF + hmac; another’s live GTID 409 naming no one; |
|
evil |
U4 |
end, retract emit |
|
sad |
U4 |
no DOB or a blank name 422; a holder’s name blanked 409, also racing the record (one fails); a future start or an end before the start 422; the DOB supplied, the record passes. Red: no act |
|
evil |
U4 |
a caseworker records, ends and retracts but cannot reveal (403); read-only sees the masked list only; a supervisor reveals; a pure service caller 403 on every route. Red: no act |
|
evil |
U5 |
other callers 403 first; a release per read; retracted and ended served; CPRS bytes same. Red: no arm |
|
happy |
U5 |
open-stages pages open episodes with a live GTID only. Red: no arm |
|
evil |
U5 |
an order delete retires an episode’s only row (rule ii): the arm still serves it as
|
|
happy |
U6 |
|
|
conc |
U6 |
GTID then custody, custody then GTID, both racing: one INC at the capture. Red: no leg |
|
sad |
U6 |
custody open, GTID refused without a DOB, DOB supplied, GTID recorded: exactly one INC. Red: no leg |
|
evil |
U6 |
one fact only, a historical episode, a resolve after the close, a non- |
|
conc |
U6 |
INC staged, then a close, a GTID end or a GTID retraction, and a name change: no INC after the OUC or RMV. Red: no leg |
|
conc |
U6 |
A closes and B opens, events delivered in either order: OUC(A) sent before INC(B), B’s held resolve released by A’s staging; OUC(A) superseded behind a staged INC(B): INC(B) re-stages behind it. Red: no leg |
|
evil |
U6 |
after B is listed, A’s retraction and A’s close correction settle
|
|
sad |
U6 |
OUC on the episode’s stage; a new episode: INC under a new |
|
evil |
U6 |
A listed under X, B under Y, X’s end delayed past B’s INC: the RMV carries X and reaches only A’s recipient; B’s later OUC is sent. Red: no leg |
|
sad |
U6 |
RMV with the pinned GTID at the capture, |
|
sad |
U6 |
the latest stage’s exit date corrected twice, then its closing token: three OUCs, each current; an open episode’s start correction rides its OUC. Red: no leg |
|
fault |
U6 |
GTID or |
|
evil |
U6 |
INC / OUC without a demographic invalid, RMV with only GTID and In-Care date valid; per D7, JSON round-trips; one job, one byte string. Red: no validator |
|
happy |
U7 |
open, close, history, GTID record, reveal and end, by test id. Red: no UI |
Rollout and risks
-
Cases first, additive. U1–U5 add tables, arms and the closure trigger, with no floor bump (ADR-063 D3). Before U6 is activated a cases image rollback stays possible: the trigger still refuses closing a case with open custody (a 500 on the old binary), and custody routes are 404s there.
-
Activation prerequisites, in order (the CPRS pattern,
deployment-guide.adoc:906-961): every cases replica on U5 or later; every exchange replica on U6 with none older remaining (U6’s floor bump stops an older replica from starting, not one already running,:917-920; a pre-U6 worker settles a DOE job naming a leg it lacks as terminalunresolvable-dispatch, ex/triggers/dispatch.rs:777-779,:107-111,:458-462); one active DOE-SLDS partner row with an admitting DSA; then the knob. Knob off: DOE receives nothing and each admission holds asknob-offuntil released; no partner or DSA:no-partner/dsa-*. An episode opened before admissions were recorded reaches DOE only through a catch-up walk. Before #1813 a production send has no partner credential path. -
Downgrade boundaries. Exchange cannot roll back below U6 once its migration runs (the floor,
:909-916). Once the bind is active, a cases rollback below U5 answers every custody read with 404, which exchange settles terminalassembly-refused(ex/triggers/cases_reads.rs:295; record jobs are not walked back, ex/send_worker.rs:589-599). The knob off holds later admissions only: it is read at admission and release (ex/triggers/admission.rs:272-276). The brake for staged DOE jobs is to deactivate the DOE partner row or its DSA, after which record dispatch’srebindsettles eachpartner-changed(dispatch.rs:672-683). No pause exists (#2348). U2–U6 migrations are additive. -
Reclassification. A #1073 ruling that moves a code’s class changes new writes only (the class is stamped per row); correcting history is a worker act.
Review log
| Round | Vendor | Resolved model | Verdict |
|---|---|---|---|
1 |
Anthropic, one fresh contextless reviewer (the page, the rules, the four questions) |
Claude Opus 5.5 |
no-ship: 6 blockers (D1 classes, RMV, wire mapping, order sweep, case lifecycle, U4 catalogue and reveal) fixed; non-blocking items folded; a GTID stored from the DOE ack fixed |
2 |
OpenAI (maintainer-run) |
GPT Astra |
no-ship: 13 findings (5 P1, 8 P2), all fixed (the pinned GTID, demographics before a GTID, the retraction snapshot, cross-episode order, mixed-binary rollout, corrected closes, history outside custody, identifier dates, stated intent, the order intent hash, identifier authz, per-type validation, same-day order); three research passes, a fold audit (7 / 6 / 0) and a gap hunt (3 P1, 3 P2, 4 P3) followed, each folded |