Data Model: Data Exchange & ICPC

Overview

The exchange service manages inter-agency data sharing (partners, agreements, transactions) and Interstate Compact on the Placement of Children (ICPC) requests with home studies and attachments.

Partners define external systems to exchange data with. Agreements establish the legal basis. Transactions record individual data exchange operations. ICPC requests follow a handler-enforced status workflow from draft to completion; home studies and attachments are child records that never advance the request.

The fleet-standard platform tables also live in this schema and are documented centrally: event_outbox / event_inbox / event_inbox_collisions (ADR-022 and the ADR-062 §A attempt machine), request_claims (ADR-062 §B), schema_compat_floor (ADR-063), and since #3190 the background-job ledger background_jobs + background_job_attempts (ADR-068 § Amendment — #1571), on which a collection run executes as the collection_run kind. A claim’s actor is the ADR-085 D3 column pair (#2740): request_claims.created_by_sub holds a worker’s UUID and created_by_sub_service a service’s service:<name> encoding, with a CHECK that exactly one is set.

Recorders name the acting worker (#2321). No craig-exchange recorder (a who-acted column or an event’s actor key) names the request token’s own sub / preferred_username: under a BFF-lifted token that token is craig-web’s service principal, so a staff write names claims.acting_worker() or the claim’s effective actor (ADR-028, ADR-062), the lifted worker, or the token’s own subject when nothing is lifted. That covers icpc_requests.created_by / created_by_name, exchange_transactions.initiated_by / initiated_by_name on a manual send (and initiated_by on an operator’s collection run, whose initiated_by_name is collection:<interface>/<leg>; a run the collection schedule started records initiated_by = system, as a triggered send does, #3190), icpc_home_studies.assessed_by / assessed_by_name (the worker who submits the home study in CRAIG) and exchange_trigger_catchup_runs.requested_by, plus the icpc.created, icpc.status_changed and exchange.send_requested user_id. Each name column is the acting worker’s username. The screening writes record craig-cases' body.requested_by (a body-named actor from the allowlisted producer), which since #2498 must name the worker in the verified X-Craig-Actor craig-cases relays, and the run start’s request_claims row records that worker, never service:craig-cases. Since #2522 the Claims fields are private and crates/craig-test-lib/tests/acting_identity_census.rs pins it: the token’s own identity is read only through a bearer() accessor, each such read under services/craig-exchange/src is pinned with its reason, and a recorded worker is claims.worker_subject(), which reads the claims.acting_worker() view, never the bare claims (#2740 removed parse_sub / parse_actor_sub).

Tables

Table Purpose

ssa_cohort_watermarks

#1466 B5 (ADR-065/066 §Amendment #1479) SSA screening run-lifecycle substrate: per-case cohort watermarks backing stale-run invalidation delivery

exchange_partners

External agencies/systems configured for data exchange. Soft-deleted rows stay REGISTRY-VISIBLE (#1580, ruled 2026-08-29): the admin/supervisor default list + GET return active=false tombstones — a ratified exception to the fleet uniform-absence posture (#1579), so operators can audit and reactivate deactivated partners. #2427 (TP-2 D1): auth_type is a closed vocabulary — none, bearer, basic, api_key — and auth_config holds secret REFERENCE names only, shaped by the type ({}, {"token_ref"}, {"username", "password_ref"}, {"header", "key_ref"}); create and update answer 422 for anything else and name the JSON path, never the value. An update names both fields or neither. endpoint_url never carries userinfo (refused at create and every update, whatever active says), and a non-none partner’s endpoint is https unless its host is listed in CRAIG_EXCHANGE__PARTNER_AUTH_PLAIN_HTTP_HOSTS (default empty). The stored-row gate re-checks the row as stored before every send and probe, reading no secret. Each reference resolves per send as the deployment guide’s Outbound partner authentication describes (#1813). caller_partner_id (#3193, ADR-091) names the craig-security partner whose approved client certificates may call CRAIG as this row; NULL for a row nobody calls as. It is set by an update, never cleared by one, and carries no foreign key, since the partner lives in craig-security’s database: an id that names no partner there matches no caller. uq_exchange_partners_kind_caller keeps one active row per (adapter_kind, caller_partner_id), so a call resolves to one row or none; an update that would make a second (naming the caller, changing the kind or reactivating) is a 409 duplicate-resource, and a deactivated row releases its caller

data_sharing_agreements

Legal agreements governing data exchange with a partner. approved_by is first-write-wins and approved_by_name rides it. An API write stores the name as the acting worker’s username when approved_by is the acting worker’s own sub, else NULL (#2320, the #1366 rule)

exchange_transactions

Individual send/receive operations with payload and status tracking. A DOE-SLDS trigger send stores the acknowledgement’s transaction_id, status and received_at in response_payload, never its gtid (#1821). origin says where a row came from: manual (the send route), trigger (an outbound trigger) or, since #3188, collection (a run that read what a partner published). A collection row is written terminal, inbound, with exchange_type <interface>.<leg>, record_count the records the document held and error_message the failure class when the run failed. It holds no payload: chk_exchange_transactions_collection_shape refuses one, so no partner-reported value rests in craig-exchange. Since #3193 a fourth origin, return, is a partner’s call to the return listener (A return): also terminal, inbound and without payload (chk_exchange_transactions_return_shape), with record_count the records the call’s body held, initiated_by partner-certificate:<registration id>, initiated_by_name return:<interface>/<leg> and error_message apply-failed:<n> when the owning service did not take n of its reports. Its id is minted when the run starts, and each report the run hands on names it. Only a manual row can be retried

exchange_send_jobs

Async partner-send queue behind the 202-Accepted handler (platform-stab-2 §D5; #1185 lease + fencing). #1835 adds record_closure: whether a trigger record job carries its stage’s closure indicator, decided by the resolve that staged it. Keeping it on the row (rather than re-reading the stage at dispatch) is what makes an opening record and the closure that follows it two distinct sends, and what keeps a job’s bytes a pure function of the row and its pinned source_version

exchange_trigger_admissions

#1828 (ADR-075): ONE row per outbound-trigger OCCURRENCE, under an identity that deliberately excludes the partner — (interface, leg, entity_kind, entity_id, entity_revision). Written inside the inbox attempt transaction, so a redelivery (absorbed by the inbox triple) and a producer re-emission (absorbed by this index) both collapse to one row. status is staged → resolved, or held (with a closed held_reason: the chain’s reasons, or a settlement class, including #2427’s auth-unsupported and auth-misconfigured from the fifth link — the partner row as stored, its auth pair parsed and its endpoint checked, no secret read) → released or dismissed; a held row is recoverable work, never a dropped event. #1835 adds origin: an event admission names the envelope that carried it, a catch-up one has no event to name (a CHECK ties the two), so the operator’s walk and the inbox never disguise themselves as each other. #1829 adds subject_person_id — the person an occurrence is ABOUT when the leg acts on one principal rather than the whole stage. The investigation removal leg is the first: the report-person link it names is already deleted by the time its resolve runs, so the projection cannot say whom to retire and a released held admission has no event left to ask. entity_kind is now case, investigation OR report; a report is not a stage, so a report-keyed admission resolves to the investigations of its referral and may reach several of them (#2264: a link also reaches the closed ones, a removal the open ones only). #1821 adds the entity kinds custody_episode (keyed by episode) and person_identifier (keyed by identifier row; admitted only for the GTID kind), the held reason predecessor-unsettled (a DOE INC waiting for the child’s previous episode to be removed; released when that removal is staged) and the system dismissal superseded-by-reentry (an occurrence for an episode older than the one the partner lists). #2401 adds last_attempted_at (nullable): the instant a release pass last re-evaluated the row’s chain and re-held it. A pass takes at most 500 rows, never-attempted first (oldest first among them), then the least recently attempted, so repeated passes reach every held row instead of re-addressing the same oldest 500. A row whose leg the deployment’s partner set no longer provides is skipped untouched and is never stamped. #2496 adds dismissed_by (nullable UUID): the subject of the admin whose dismiss act retired the row, beside its dismiss_reason. A CHECK (chk_exchange_trigger_admissions_dismissed_by) allows it on a dismissed row only; it is NULL on a system dismissal (superseded-by-reentry) and on every dismissal written before #2496. Each dismiss pass also stages exchange.trigger_admissions_dismissed naming the admin (ADR-003)

exchange_outbound_recipients

#1828 (ADR-075): the catalogued OUTBOUND table — one row per (interface, partner, stage_kind, stage_id, person_id) recording who has been admitted to which partner, when, and under which correlation (no digest of what was sent since #2508). Ids and dates only: the birth MONTH (dob_year_month) for the continuation cut-off, never a name, a date of birth or an address. Its UNIQUE identity is what makes a re-run resolve converge instead of re-admitting a child. Two one-way stamps end a recipient’s traffic: closed_sent_at (a closure record has been STAGED for them — the guard that makes re-resolving a closed stage add nothing) and removed_at (no further record is sent at all). #1821 adds subject_identifier_id (NULL for CPRS): the cases person-identifier row a DOE recipient was listed under, the id only, never the GTID. Every later DOE read for the recipient names it, so a later GTID never replaces the one the partner listed, and ending a GTID removes only the recipients listed under it (partial index on (interface, partner_id, person_id, subject_identifier_id) where removed_at IS NULL). #3188: a row with neither stamp is the person’s open listing with the partner. A collection admits a partner’s report only under one and posts the report with the row’s id (the newest, where a person has more than one open), and each stamp stages exchange.listing_ended in its own transaction, from the two store functions that are the stamps' only writers, so the service that keeps the report drops it (Partner-reported education records). A stamp that finds the row already stamped stages nothing

exchange_outbound_stage_epochs

#1839 (ADR-075): one counter per (interface, stage_id) that a closure or an investigation removal has touched — the serialization point of the outbound-trigger resolves. A resolve reads the stage’s membership from cases before its write transaction; every resolve transaction takes the stage’s advisory lock first, a closure or a removal bumps this counter under it, and a reading pass that finds the counter moved since its read re-reads under the lock instead of writing from the stale one. A stage with no row is at 0. Ids, a counter and a timestamp only (no personal data); never age-pruned

exchange_trigger_catchup_runs

#1835 (ADR-075 decision 15): one row per operator catch-up walk — the interface and stage kind it covered, who asked for it, what it scanned and created, and whether it completed. The walk itself is idempotent, so this exists to answer the operator afterwards rather than to gate a re-run; a row left running is a walk whose process died, and its admissions are real

icpc_requests

Interstate placement requests with multi-step status workflow. Carries the (assigned_worker_sub, supervisor_sub, assignment_revision) denorm triple (#1312 revision guard; the supervisor half landed with #1367) — applied by the case.assignment_changed inbox, consulted by record-level authz refs and the worker/supervisor list-scope filters

icpc_home_studies

Structured home study evaluations for ICPC requests (one-to-one); carries the same denorm triple via the icpc_requests JOIN legs

icpc_attachments

Documents attached to ICPC requests — stored in object storage; carries the same denorm triple via the icpc_requests JOIN legs

upload_attempts

ADR-062 §U upload-attempt tombstones (SU2 #1248): one immutable row per client upload operation, id = the client-held request id; generation-fenced CAS state machine + replay decision table live in craig-store::attempts (shared crates); kinds here: icpc_attachment. 31 d terminal retention (reconciler-pruned); no FK — target_id is polymorphic by design. The claimant is the ADR-085 D3 column pair (#2740): created_by holds a worker’s UUID and created_by_service a service’s service:<name> encoding, with a CHECK that exactly one is set.

ssa_screening_runs

SSA SOLQ screening runs (#1462, plan Plan::SSA B1; ADR-066 §D5): one row per household screening request, carrying the H1 cohort binding (cohort_hash
as_of + the one-way invalidation marker). Provenance class (ADR-065 §D4) — never transport-pruned; archive-eligible only once completed AND past the 12-month quiescence horizon. Carries the UD10 legal_hold flag (#1566): an eligibility-predicate column every destructive retention statement selects on AND re-asserts, transitively shielding the run’s whole family (members/jobs/transactions/handoffs); set/cleared by the human-admin hold endpoints, each transition audited. One ACTIVE (pending, not-invalidated) run per case by partial unique index.

ssa_screening_members

One row per screened household member: identifier_id (NOT NULL, a logical fk — the craig-cases person identifier of the screening kind the cohort bound; its value is released only while that row is live), per-run ordinal, and the txn↔member one-to-one link (transaction_id is a logical fk — SSA transaction rows are prunable transport, provenance must outlive them). Terminal statuses include identifier_stale (the staged identifier was no longer live at the release or the outcome record) and no_gateway_record (Gateway held no record for the person). #3175 renamed no_match, then replaced ssn_digest with identifier_id, renamed ssn_stale and retired unmappable; that migration deleted every run graph staged under SSN digests, and each bumped the schema_compat_floor. Provenance class.

ssa_screening_jobs

The typed job queue the SsaWorker (#1465) drains — deliberately NO payload column (H18/SD14: the wire payload is built at send time from the member row + the value-bound custody release, never persisted). exchange_send_jobs-shaped lease (claimed_at + claim_generation); paused = the H16 class (categorical last_error: contract-pending / gate-disabled / partner-unavailable / auth-not-applied / dsa-not-active / egress-refused), re-admitted ONLY by the #1469 fork-6 resume endpoint (POST /v1/exchange/ssa-screening-jobs/resume — human-admin, live precondition re-check, attempts reset with the pre-reset count on the ssa.jobs_resumed audit event; never automatic on config change). Terminal failed classes incl. identifier-stale (the release refused the staged identifier → the member goes identifier_stale), identifier-unusable (the released value is no client number) and partner-refused (Gateway R001–R004, never retried). Transport class — pruned at the UD4 window (default/max 90 d, CRAIG_EXCHANGESSA_SCREENINGTRANSPORT_RETENTION_DAYS) by the E3 handoff-then-prune sweep (#1566): each batch snapshots the transport facts into ssa_transport_handoffs and deletes the job + its SSA exchange_transactions row in ONE transaction — the jobs delete re-asserts the full eligibility predicate plus a snapshot-exists guard, the transactions delete the hold + type legs — so a UD10 hold landing mid-batch (or flapping across the statements) rolls the whole batch back.

ssa_transport_handoffs

E3 (#1566): the UD4 provenance handoff relation — one insert-only row per member, written INSIDE the transport prune transaction, snapshotting the facts only the pruned job/transaction rows held (correlation token, partner, attempts, final status, categorical last_error, timing). FK direction is the recorded rule: the handoff FKs the MEMBER (ON DELETE RESTRICT) — provenance never FK-depends on transport — which also forces the archive deletion order handoffs → members → runs. Provenance class; archives with the family via the exchange engine.

archive_ledger

E3 (#1566): craig-exchange’s durable archive ledger (the craig-rules shape verbatim; ADR-058 D8) — one row per archived-and-pruned provenance batch, written inside the prune transaction; craig-manage archive-fetch craig-exchange <table> resolves through its [min,max] id ranges (D17). No legal_hold column — exchange ships no purge tooling until DFCS names a schedule (#1480); the purge tooling that lands then must add it.

Names kept from the SOLQ interface (#3176)

The SSA screening was built against SSA’s SOLQ interface and now asks Gateway’s income inquiry (the interface page). The partner that answers it has the kind gateway_income, provided by the configuration layer’s crate craig-partner-gateway-income. Until #3176 the kind was ssa_solq; a migration gives a stored partner row the new kind.

Three tokens that are stored in rows keep the old name. Renaming them would rewrite history in two databases and change nothing a deployment does:

Token Where it is stored What it means now

ssa_solq_screening

exchange_transactions.exchange_type (craig-exchange)

The transaction of one screening member’s question to the income inquiry. The retention sweep finds screening transactions by it.

solq

ssa_benefit_facts.source (craig-cases)

A benefit fact that an SSA screening’s answer asserted, whichever interface answered it. It is the only source the column admits.

solq_match

persons.ssn_verification_method (craig-cases)

The value reserved for an SSN verification that a screening recorded. No current path writes it: a worker’s attestation stores the worker’s own text.

ER Diagram

exchange_partnersuuididPKtextpartner_nameUKtextpartner_typetextdirectiontextendpoint_urltextauth_typenone, bearer, basic or api_key (#2427)jsonbauth_configsecret reference names only, shaped by auth_type (#2427); write-only (#757)textexchange_formatbooleanactivesoft-delete flaguuiddata_sharing_agreement_idFKnullableuuidcaller_partner_idnullable; the craig-security partner that may call as this row (#3193)bigintversionIf-Match CAS counter, bumped by DELETE too (ADR-062 §G2)timestamptzcreated_attimestamptzupdated_atdata_sharing_agreementsuuididPKuuidpartner_idFKtextagreement_titledateeffective_datedateexpiration_datejsonbdata_elementstextlegal_authoritytextstatusdraft|active|expired|terminatedtextobject_keytextapproved_bytextapproved_by_namenamed only when approved_by is the acting worker (#2320)timestamptzapproved_attimestamptzcreated_atexchange_transactionsuuididPKuuidpartner_idFKtextdirectiontextexchange_typelowercase token of 1-64 bytes: letters, digits, _ . - (manual send, #2824)textstatuspending|success|failed (CHECK - #1638)jsonbrequest_payloadjsonbresponse_payloadtexterror_messageintegerrecord_counttimestamptzinitiated_attimestamptzcompleted_attextinitiated_byicpc_requestsuuididPKuuidcase_idcross-service FKuuidchild_idcross-service FKtextdirectiontextsending_statetextreceiving_statetextrequest_typetextstatusdraft|submitted|received|home_study_in_progress|approved|conditional|denied|completed|withdrawn (CHECK - ٦ transitions handler-enforced)timestamptzsubmitted_atauto-set on submittimestamptzdeadline_atauto-set on received: now + CRAIG_EXCHANGE__ICPC_DEADLINE_DAYS (default 60 calendar days, #1734)timestamptzcompleted_atauto-set on completed or withdrawntextcreated_bytimestamptzcreated_attimestamptzupdated_aticpc_home_studiesuuididPKuuidicpc_request_idFKtexthome_safetypending|pass|fail (CHECK - #1637)textbackground_checkspending|pass|fail (CHECK - #1637)textreferences_checkpending|pass|fail (CHECK - #1637)textspace_capacitypending|pass|fail (CHECK - #1637)textsupport_systemspending|pass|fail (CHECK - #1637)texteducation_accesspending|pass|fail (CHECK - #1637)textmedical_accesspending|pass|fail (CHECK - #1637)textrules_recommendationtextcoordinator_decisiontextoverride_justificationtimestamptzcompleted_attextassessed_byicpc_attachmentsuuididPKuuidicpc_request_idFKtextattachment_typetextobject_keytextobject_statuspending|present|failed (CHECK; rows are born present)timestamptzuploaded_attextuploaded_byssa_screening_runsuuididPKuuidcase_idcross-service logical fktextstatuspending|completedchar_64cohort_hashsha256 hex, H1 cohort bindingdateas_ofbusiness date the cohort was bounduuidcreated_byrequesting caseworker subtimestamptzcreated_attimestamptzcompleted_atbiconditional with status=completedtimestamptzinvalidated_atone-way H1 marker, orthogonal to statustextinvalidation_reasoncohort_changed|operator_cancelled|freshness_expired; paired with invalidated_atbigintcohort_revisionproducer-carried cohort revision (D14); the watermark protocol keybooleanlegal_holdUD10 operator hold; shields the whole family (#1566)ssa_screening_membersuuididPKuuidrun_idFKON DELETE RESTRICTuuidperson_idcross-service logical fkintordinalunique per run; H5 per-ordinal determinismuuididentifier_idcross-service logical fk - the bound person identifiertextstatuspending|screened|identifier_stale|failed|cancelled|no_gateway_recorduuidtransaction_idUKlogical fk - txn rows are prunable transporttimestamptzcreated_attimestamptzcompleted_atbiconditional with terminal statusssa_screening_jobsuuididPKuuidmember_idFKON DELETE RESTRICT; unique - one job per memberuuidcorrelation_idUKpartner-side idempotency tokentextstatuspending|in_flight|paused|sent|failedintattemptstextlast_errorcategorical only (ADR-065 D1)timestamptznext_attempt_attimestamptzclaimed_atclaim clock (1185 lease shape)timestamptzpaused_atH16 pause stamp; cleared by resumebigintclaim_generationfencing tokentimestamptzcreated_attimestamptzcompleted_atbiconditional with sent|failedssa_transport_handoffsuuidmember_idPKFK ON DELETE RESTRICT — provenance never FKs transportuuidrun_idFKON DELETE RESTRICTuuidjob_idvalue snapshot of the pruned jobuuidtransaction_idvalue snapshotuuidcorrelation_idthe partner-side token, preserved past the pruneuuidpartner_idvalue snapshotintattemptstextfinal_statussent|failedtextlast_errorcategorical class (ADR-065 D1)timestamptzjob_created_attimestamptzcompleted_atthe family's shared archive age clocktimestamptzhanded_off_atgoverned byactive agreementtransacts withevaluated indocumented byscreensdelivered bytransport facts preserved by (#1566)

exchange_send_jobs

The send worker’s queue: one row per staged partner send or outbound-trigger job, drained by ExchangeSendWorker (claim → dispatch → fenced finalize). Statuses: pending / in_flight / sent / failed. Every column is NOT NULL unless its Notes say when it is NULL.

Column Type Notes

id

UUID

PK (uuidv7)

transaction_id

UUID

FK → exchange_transactions (ON DELETE CASCADE). NULL exactly on a resolve job, which creates transactions rather than belonging to one: CHECK chk_exchange_send_jobs_resolve_has_no_transaction, (kind = 'resolve') = (transaction_id IS NULL) (#1828)

partner_id

UUID

Target partner

correlation_id

UUID

UNIQUE: the partner-side idempotency token. A payload job injects it as craig_correlation_id; a typed partner carries it on its own transaction_id (caps, cprs, doe_slds, stars, wic) or not at all (empi, ies, ions, smile, tcm, which have no field that holds a UUID), #1815; the SHINES envelope carries it at its top level under the same key (StandardAdapter::transform_outbound, #2398); a trigger record carries it on the leg’s id field

payload

JSONB

A payload job: the outbound payload staged verbatim. A trigger job: a reference, ids only — a resolve job holds its admission_id; a record job its recipient_id, person_id and stage_id; the record itself is assembled at dispatch and never stored (#1828)

kind

TEXT

CHECK payload (a partner transaction send, staged by the API) / resolve / record (the outbound-trigger kinds, #1828). Set at insert and never updated, so a row’s claim lane (#2071) never changes

admission_id

UUID

FK → exchange_trigger_admissions (ON DELETE CASCADE: a job whose admission is gone goes with it). The admission a trigger job serves (#1828): set on every resolve and record job, NULL on a payload job. Written at insert, never updated. No CHECK ties it to kind; a trigger job without a readable admission settles failed as unresolvable-dispatch

recipient_id

UUID

FK → exchange_outbound_recipients (ON DELETE CASCADE). The recipient a record job sends for (#1828); NULL on payload and resolve jobs. Written at insert, never updated. No CHECK ties it to kind; a record job without it settles failed as unresolvable-dispatch

source_version

TEXT

The source version a record job’s bytes are pinned to at staging, re-read at every dispatch (ADR-075 decision 8). When the source has moved, or a DOE-SLDS record is queued ahead of an older stage’s live record of the same child (#1821), the job settles failed as superseded and one replacement record job carries the current version under a fresh correlation and transaction. NULL on payload and resolve jobs. Written at insert, never updated; a record job without it settles failed as unresolvable-dispatch

ordering_key

TEXT

FIFO key (#1828, ADR-075 decision 9) on resolve and record jobs: a resolve job keys on its admission’s entity (the stage, or a report or DOE-SLDS identifier row); a record job on its stage, except DOE-SLDS record jobs, which key on the child (doe_slds:<person_id>, #1821) so one child’s records send in staging order across episodes; NULL on payload jobs, which never wait

record_closure

BOOLEAN

Default false. Whether a record job carries its stage’s closure indicator (#1835), decided by the resolve that staged it and never re-derived at dispatch; a supersession’s replacement copies it. CHECK chk_exchange_send_jobs_closure_is_a_record, NOT record_closure OR kind = 'record'

status

TEXT

CHECK pending / in_flight / sent / failed

attempts

INT

Incremented on every claim (incl. lease reclaims). A local-read retry (#2244) refunds its claim’s increment, so on a trigger job attempts counts ladder attempts and claim_generation − attempts counts local-read retries (a negative difference reads as spent; a hand-edited counter shifts the count, which stays bounded). Retryable failures past MAX_ATTEMPTS (6) ladder attempts go terminal

last_error

TEXT

Latest adapter/dispatch error. NULL until a retry or a terminal failure writes it; a sent finalize clears it; auth-unsupported / auth-misconfigured (#2427) are terminal and nothing was sent; auth-unavailable (no usable secret, nothing sent) and auth-refused:<status> (a trigger record the partner answered 401/403, no body digest) ride the ladder, and partner-inactive ends a queued manual job whose partner was deactivated (#1813). A failure a secret reference causes ends ` ref=<name>`, and the presented credential’s forms read [credential] (a record job failed under any auth-* class is recoverable by release’s record arm)

restaged_as

UUID

#2427: the job the release record arm re-staged this failed record job as (self-FK, ON DELETE NO ACTION; CHECK chk_exchange_send_jobs_restaged_as: set only on a failed record job). NULL = not re-staged, the arm’s selector. The old row keeps its auth class in last_error. The send-job retention sweep keeps a failed record job of an auth class while restaged_as is NULL, so an unreleased one outlives the retention window

next_attempt_at

TIMESTAMPTZ

Scheduled ELIGIBILITY (backoff target) — deliberately untouched at claim; never a claim clock — the partner ladder’s target, or for assembly-unavailable the local-read schedule’s (#2244)

claimed_at

TIMESTAMPTZ

#1185: the REAL claim clock. NULL (never claimed / legacy / crash residue) counts as an expired lease

claim_generation

BIGINT

#1185: fencing token — every claim increments it; every terminal/retry transition carries a status='in_flight' AND claim_generation = $n CAS, so a superseded worker’s stamp is a no-op (never a sent↔failed overwrite, never conflicting events)

created_at / completed_at

TIMESTAMPTZ

Stage / terminal stamps. completed_at is NULL until the job goes sent or failed

Lease semantics (#1185): the claim query itself re-admits in_flight rows whose claimed_at is NULL or older than the worker’s CLAIM_LEASE_SECS (90s = 3× the 30s transport cap) — recovery is continuous on the 1s poll; there is no recovery sweep. A crash after the partner accepted but before finalize re-sends after lease expiry: at-least-once by design (ADR-022 #1185 amendment), re-sending the same token, on the carrier above, for the partner to dedup on.

Retry schedules (#2244). A retryable failure goes back to pending with next_attempt_at set; the claim is released either way. Partner-facing failures (transport, timeout, partner-unavailable, and every manual send’s adapter error but an invalid payload, which settles terminal payload-invalid on its first attempt: a wire-contract refusal, or since #2397 a payload that does not decode into the partner’s typed outbound) take the ladder, BACKOFF_SCHEDULE_SECS indexed by attempts: 5 s, 30 s, 120 s, 300 s, 900 s, then retries-exhausted. A referral whose receipt could not be handed to craig-cases (receipt-unapplied, #3193) takes the same ladder: each retry sends the same record under the same correlation id and hands the receipt over again; spent, it ends under its own class, not retries-exhausted. One whose receipt craig-cases refused as a second reference for the application ends at once under receipt-conflict. A trigger job whose cases read failed (assembly-unavailable) first takes the local-read schedule: four retries at 0.5–1 s, 1–2 s, 2–4 s, 4–8 s, the point in each range fixed by the low ten bits of the job id, each refunding its claim; then the ladder at the rung its ladder attempts have reached (the first, 5 s, for a job whose failures were all local).

Claim lanes (#2071): the worker claims in two lanes, one statement each, so a trigger backlog never queues ahead of a partner send. The send lane takes kind = 'payload'; the trigger lane takes every other kind (resolve, record). Each lane has its own dispatch budget per worker, SEND_CONCURRENCY (8) and TRIGGER_CONCURRENCY (8), so trigger jobs, however many or however slow, never hold a partner send’s capacity. Every pass claims the send lane first, then the trigger lane, each up to its free budget. A pass runs on the 1s poll, or sooner (#2076): when a lane’s last claim took every free permit of its budget, so more due rows may be waiting, the next pass starts as soon as one of that lane’s permits frees. A burst therefore drains at the rate its dispatches finish instead of one budget per second. A pass in which every lane’s claim came back short, or that failed, waits the full second, so an idle worker polls no faster than before. Both statements come from one template: the due-pending and expired-lease arms, ORDER BY next_attempt_at, FOR UPDATE SKIP LOCKED and the FIFO guard are identical. The guard still matches an earlier non-terminal job with the same ordering_key of any kind. payload jobs carry no key, so the guard never makes one lane wait on the other. The two lanes share the worker’s DB pool (3 connections). Re-claiming does not raise the pool’s peak demand, which is still at most SEND_CONCURRENCY + TRIGGER_CONCURRENCY dispatches plus the loop’s one claim at a time. It only lengthens how long a burst keeps the pool busy, so 3 stands (#2076).

Auth-class recovery (#2427, TP-2 D3). A record job that failed under an auth class (auth-unsupported, auth-misconfigured, auth-unavailable, auth-refused) is not lost. POST /v1/exchange/triggers/admissions/release with record_class locks the interface’s failed record jobs whose last_error leading token is that class and whose restaged_as is NULL (FOR UPDATE, blocking; at most 500 per pass, oldest first), re-runs the consent chain for each, and re-stages a job the chain admits for its own partner as a supersession does: the same ordering_key, admission, recipient, source_version and record_closure under a new transaction and correlation, with a fresh attempt budget. The old row stays failed with its class and names the replacement in restaged_as. A re-staged row is never selected again, so a repeated or concurrent release re-stages nothing. A job the chain refuses is left as it is and counted refused. Any other class is a 422 release-record-class-unsupported (#2436 owns general record recovery). A refused job stays selectable and every pass re-reads it, so past 500 refused jobs newer ones are named with ids. The replacement takes a new id, so it queues behind any job of its key staged since the original failed (the FIFO is by id). Until it is released, such a job is exempt from the send-job retention sweep.

Key Indexes

  • idx_exchange_partners_type — filter by partner type

  • idx_exchange_partners_active — active partner lookup

  • uq_exchange_partners_kind_caller — UNIQUE (adapter_kind, caller_partner_id) WHERE the caller is set and the row is active (#3193): the row a partner’s call resolves to

  • idx_agreements_partner — agreements by partner

  • idx_agreements_status — agreement status filtering

  • idx_exchange_partners_created_at / idx_agreements_created_at — #3170 (created_at): the partner list’s and the agreement list’s default sort (ORDER BY created_at DESC LIMIT n), read in index order so a page’s cost does not grow with the table

  • idx_transactions_partner — transactions by partner

  • idx_transactions_status — transaction status filtering

  • idx_transactions_initiated_at — time-range queries

  • idx_icpc_case — ICPC requests by case

  • idx_icpc_child — ICPC requests by child

  • idx_icpc_status — ICPC status filtering

  • idx_icpc_direction — inbound vs outbound ICPC

  • ssa_screening_runs_one_active_idx — UNIQUE (case_id) WHERE pending AND not invalidated: the one-ACTIVE-run-per-case safety net (#1462)

  • ssa_screening_runs_case_idx — run history by case (D3 freshness checks)

  • ssa_screening_members_person_idx / _ordinal_idx — UNIQUE per run

  • ssa_screening_members_transaction_idx — UNIQUE fleet-wide (txn↔member 1:1)

  • ssa_screening_jobs_member_idx / _correlation_idx — UNIQUE

  • ssa_screening_jobs_drainable_idx / _lease_idx — the B4 worker’s claim
    lease-recovery partials (the exchange_send_jobs shape)

  • ssa_screening_runs_held_idx — partial on (id) WHERE legal_hold (#1566): the held-runs gauge + hold-shield predicates; held rows are rare by design

  • ssa_transport_handoffs_completed_idx — the archive spec’s (ts, id) paging key (#1566; the family’s shared age clock)

  • idx_archive_ledger_id_range — (first_record_id, last_record_id): the D17 archive-fetch batch resolution (#1566)

  • idx_icpc_home_study_request — home study by ICPC request

  • idx_icpc_attachments_request — attachments by ICPC request

  • idx_exchange_send_jobs_drainable — partial on (next_attempt_at) WHERE status = 'pending'; the trigger lane’s due-pending arm

  • idx_exchange_send_jobs_drainable_payload — partial on (next_attempt_at) WHERE status = 'pending' AND kind = 'payload' (#2071); the send lane’s due-pending arm, so the send-lane claim need not read the trigger backlog

  • idx_exchange_send_jobs_lease — partial on (claimed_at) WHERE status = 'in_flight' (#1185); the claim query’s expired-lease arm (replaced the wrong-clock stuck_in_flight index)

  • idx_exchange_send_jobs_correlation — UNIQUE on correlation_id

  • idx_exchange_send_jobs_ordering_key — partial on (ordering_key, id) WHERE ordering_key IS NOT NULL AND status IN ('pending', 'in_flight') (#1828, ADR-075 decision 9); the claim’s FIFO guard (no earlier non-terminal job with the same key, by id) and the DOE-SLDS older-stage check (older_stage_record_pending, #1821)

  • idx_exchange_send_jobs_restaged_as — partial on (restaged_as) WHERE restaged_as IS NOT NULL (#2427); the self-FK lookup each retention delete runs

  • idx_exchange_trigger_admissions_subject_held — partial on (interface, subject_person_id) WHERE status = 'held': the child-scoped release a DOE removal runs (#1821)

  • idx_exchange_trigger_admissions_held_attempted — partial on (interface, last_attempted_at NULLS FIRST, created_at) WHERE status = 'held' (#2401): the release pass’s order

Edit this page · latest