Plan: SSA screening on Gateway’s income inquiry

Status

Done (2026-11-28) — SSA screening asks Gateway’s income and resource inquiry, keyed by the member’s DHR client number (Georgia: the empi identifier, named by screening_identifier_kind), and no SSN leaves craig-cases for it. The SOAP answer’s SI/ST and SSR/SSD rows on the client’s own clientID become ssi and title_ii facts; an active fact the answer leaves out is terminated; a member Gateway holds no record for is no_gateway_record and raises the review alert; the SSN release, digest binding and verification CAS are gone. Production activation stays Phase P (#1433): the send-authority witness is unconstructible, so a release build still pauses every job. #3176 (renames) and #3177 (non-SSA income) stay open.

Closes: #3175. Relates to: #162 (anchor), #1433 (Phase P), #1432, #3172. Supersedes: units C0–C3 of Plan: SSA Benefit Verification (SOLQ / SDX / BENDEX) for IV-E Eligibility (the SDX/BENDEX import).
Maintainer (2026-11-27), the first four on #162 (note 4341730085): re-key in place; a member Gateway does not serve is screened with no record, plus an alert; SSA codes only; the WSDL’s SOAP wire; terminate by absence.

Context

The pipeline of ssa-data-exchange.adoc (units A1–E4, built) screens a case’s household before an IV-E determination. It releases each member’s SSN from craig-cases just in time, sends it to an ssa_solq partner as placeholder JSON, and has no response contract: every answer maps to Unmappable (services/craig-exchange/src/ssa_worker.rs, map_response_outcome).

SSA’s exchanges end at Gateway. The child welfare system reads the results through Gateway’s incomeResourceInquire, transcribed in Gateway Income and Resource Inquiry (IncomeResourceService). It is SOAP, keyed by DHR client number, and carries no SSN. Its unearnedIncome rows hold what Gateway’s BENDEX and SDX batches loaded: SSR and SSD (RSDI), SI and ST (SSI). One answer lists the whole Gateway household’s rows, each tagged with the clientID it belongs to. Gateway does not enforce the WSDL’s maxOccurs.

CRAIG stores the DHR client number as a person identifier of kind empi (Georgia: 9 digits), encrypted, one live row per person and kind, its value immutable (services/craig-cases/migrations/20261014130000_person_identifiers.sql).

Scope

In: the identifier-keyed cohort and release (D1, D2); the SOAP codec (D3); the worker’s send and mapping (D4); outcome semantics in craig-cases (D5); the vocabulary and schema (D6); the docs and ADR amendments (§ Delivery).

Out:

  • Production activation. The send-authority witness (crates/craig-partner-ssa-solq/src/authority.rs) stays unconstructible, so a release build still pauses every job contract-pending. Flipping it, outbound authentication, the DSA, the egress allowlist and cutover evidence remain Phase P (#1433, operations).

  • Renaming the partner kind ssa_solq, its crate and the ssa_* tables (#3176).

  • Non-SSA income (VA, railroad, child support, earnings) for the IV-E income test (#3177).

  • A devstack Gateway mock (Canopy’s subject) and Gateway’s other SHINES services (#3172).

  • Survivors' benefits: Gateway has no code for them, so ssa_death stays dormant.

Design

D1. The cohort binds each member’s client-number identifier

Setting. A bundle names the identifier kind screening uses, as it does for the Medicaid application:

  • StateBundle::screening_identifier_kind(&self) → Option<&'static str>, default None (crates/craig-state-bundle/src/bundle.rs, beside medicaid_application_identifier_kind).

  • screening_identifier_kind: Option<String> in Settings (crates/craig-config-bundle/src/schema.rs), carried by bundle.rs. read.rs’s `medicaid_kind_is_declared becomes one check over both keys, with the same UndeclaredIdentifierKind error.

  • craig-cases boots ScreeningIdentifierGate(Option<IdentifierKind>) in src/identifier_kind.rs, mirroring MedicaidApplicationGate: a kind the vocabulary does not declare refuses boot.

  • Georgia sets screening_identifier_kind = "empi" in craig-config-georgia/bundle/settings.toml; step 5 bumps config-sources.lock.

Cohort. StageScreeningMember (crates/craig-cases-contracts/src/screening_wire.rs) carries identifier_id: Uuid in place of ssn_digest. assemble_cohort (services/craig-cases/src/api/case_screening_cohort.rs) reads each active household person’s live identifier id of the gate kind through one new store read in store/person_identifiers.rs. It refuses with 409:

  • SCREENING_UNCONFIGURED when the gate is None;

  • SCREENING_IDENTIFIER_MISSING, naming the person ids and the kind’s label, when a member holds no live identifier of the kind. This replaces MISSING_SSN here.

Members sort by person id, then identifier id. cohort_hash (screening_cohort.rs) takes &[(Uuid, Uuid)] and its domain tag becomes craig.ssa.cohort.v2.

Revision seam (services/craig-cases/src/screening_revision.rs). CohortChangeKind loses PersonDigest, SsnCleared and LinkPromoted with their four call sites (api/persons_ssn.rs, api/persons.rs, api/report_persons.rs, ssn_promotion.rs): an SSN change no longer alters a cohort. It gains ScreeningIdentifier (wire token screening_identifier), noted by record_person_identifier, end_person_identifier and retract_person_identifier (api/ledgers/person_identifiers.rs) inside their own transaction when the row’s kind is the gate kind.

D2. The identifier release replaces the SSN release

POST /v1/cases/persons/{id}/screening-identifier-release, in a new api/persons_screening_release.rs. It keeps the SSN release’s guards: the consumer allowlist of one (craig-exchange) and stage-time attribution.

  • Request ScreeningIdentifierReleaseRequest { identifier_id, screening_run_id, screening_member_id, requested_by }; response { value: String }, the plaintext client number.

  • The row must belong to the person, be of the gate kind and be live. It is decrypted with the helper reveal_person_identifier uses. Otherwise 409 SCREENING_IDENTIFIER_STALE; an unknown person is 404.

  • Audit (events.rs). A release keeps the wrapper publish_person_pii_released_for_screening and its key case.person_pii_exported, with purpose income_inquiry_screening, include_full_ssn false and the identifier_id added. A refusal’s key case.person_ssn_release_refused is renamed case.person_screening_release_refused, reason identifier_stale, with its craig-security parser arm, census test and ADR-003 entry. SsnReleaseAudit becomes ScreeningReleaseAudit.

Deleted: api/persons_ssn_release.rs, its route and OpenAPI entry, SsnReleasePurpose, SsnReleaseRequest, SsnReleaseResponse, CasesClient::release_ssn, and their tests. current_ssn_digest and current_digest_version move to api/persons_ssn.rs, which still uses them for the human SSN attestation. SsnDigest and persons.ssn_verified stay for that path.

D3. The SOAP codec

A new module crates/craig-partner-ssa-solq/src/income_inquiry.rs:

/// A DHR client number: 1 to 9 ASCII digits. `Debug` redacts it.
pub struct ClientNumber(String);                 // ClientNumber::parse(&str) -> Option<Self>
pub struct IncomeInquiryRequest { pub client: ClientNumber, pub request_date: NaiveDate }
pub enum SsaIncomeKind { Ssi, TitleIi }
pub enum IncomeInquiry {
    /// `R000` with the request month's data: the SSA kinds on the client's own rows, possibly none.
    Answered { month: NaiveDate, kinds: BTreeSet<SsaIncomeKind> },
    /// `R005`, `R006`, or `R000` without the request month: Gateway holds nothing for the client then.
    NoRecord,
}
pub fn envelope(request: &IncomeInquiryRequest) -> Vec<u8>;
pub fn parse(body: &[u8], request: &IncomeInquiryRequest) -> Result<IncomeInquiry, SsaSolqError>;

envelope writes the document/literal request the interface page describes: a SOAP 1.1 Envelope and Body, the element incomeResourceInquire in the namespace IncomeResourceServiceNamespace, and unqualified children incomeResourceService → incomeResourceRequest → DHRClientNumber, requestIdentifier (INQ) and requestDate (MM/dd/yyyy). The three values are digits, a constant and a formatted date, so none needs escaping. The contract has no correlation field; the correlation id stays on the exchange transaction row.

parse, in order. Each refusal is a variant of SsaSolqError carrying no response bytes, and nothing of the response but the result leaves it:

  1. The body is UTF-8 and parses with a DTD refused and a node limit of 50,000: else MalformedResponse. The transport already caps the body at 1 MiB (MAX_RESPONSE_BYTES). Elements match by local name; namespaces are not compared. An element with xsi:nil="true" or no text is absent.

  2. A SOAP Fault in the body is PartnerFault (new).

  3. returnCode under incomeResourceResponse: R000 continues; R005 and R006 are NoRecord; R001–R004 are RequestRefused (new); R007, an unknown code, or no returnCode is PartnerError (new).

  4. The inquiryData whose benefitMonth is the request date’s MMyyyy: none is NoRecord. Every inquiryData and every unearnedIncome is read, however many there are.

  5. Each unearnedIncome of that month needs a clientID and an unearnedType: a row missing either is MalformedResponse, so a renamed field fails loudly instead of reading as "no benefit". A row counts when its clientID, as a number, equals the request’s client number. SI and ST give Ssi; SSR and SSD give TitleIi; any other type is ignored.

The crate. The parser uses roxmltree, a read-only tree. Compared:

  • quick-xml with serde: deny.toml already ignores RUSTSEC-2026-0194 and -0195 for two transitive copies, on the ground that they parse only S3 API responses. Using it here would add a third copy, on partner ingress. Its serde lists also match repeated elements by qualified name and need a feature for non-adjacent repeats.

  • serde-xml-rs: the least maintained of the three, and it brings xml-rs.

  • roxmltree: refuses a DTD unless asked, has a node limit, and exposes local names, so the lenient rules above are ours to state. We keep four fields, so serde derives save nothing. Step 3 starts by reading the pinned version’s ParsingOptions documentation and running cargo deny check.

D4. The worker’s send and mapping

In services/craig-exchange/src/ssa_worker.rs:

  • custody_phase calls CasesClient::release_screening_identifier. A released value that ClientNumber::parse refuses ends the member failed (identifier-unusable); a 409 stale ends it identifier_stale.

  • The request date is the jurisdiction’s business date, as claim_state_gates already reads it.

  • SsaSolqAdapter’s `ExchangeAdapter impl takes IncomeInquiryRequest and returns IncomeInquiry. It sends Content-Type: text/xml; charset=utf-8 and the quoted SOAPAction of the interface page.

  • partner_error_class: PartnerFault → partner-fault and PartnerError → partner-error, both retried like today’s classes. RequestRefused → partner-refused is the one class dispatch does not retry: it ends the member failed through terminal_pair.

  • map_response_outcome becomes map_inquiry: Answered { month, kinds } → Screened { screened_month: month, entries }, one entry per kind with role recipient, status active, as_of the month’s first day; NoRecord → NoGatewayRecord. SolqScreeningRequest, SolqScreeningResponse, SCHEMA_VERSION and the error variant RequestEncoding are deleted.

D5. Outcome semantics in craig-cases

RecordSsaOutcomeRequest (crates/craig-cases-contracts/src/screening_outcome.rs) loses echo_matched and expected_digest and gains identifier_id. SsaMemberOutcome becomes Screened { screened_month, entries } | NoGatewayRecord; NoMatch and Unmappable are deleted.

record_outcome_tx (services/craig-cases/src/api/ssa_outcomes.rs), in order:

  1. The replay guard and the person lock, as today.

  2. The member’s identifier row is still live, read FOR SHARE by id: else 409 SCREENING_IDENTIFIER_STALE. This replaces verify_digest.

  3. The authority refusal, as today.

  4. Each entry is inserted through insert_fact_chained, as today.

  5. Termination by absence. For Screened, each of the person’s chain heads that is active and has no entry of its kind and role gets a terminated successor, as_of the screened month. The heads come from store::ssa_benefits::current_facts_for_person, which now takes the transaction and loses its dead_code expectation. NoGatewayRecord writes no fact.

  6. The facts_recorded fan-out runs when any fact row was written. NoGatewayRecord fans out no_gateway_record through fan_out_review_items_for_person (store/ive_determinations.rs).

  7. The projection row, as today. apply_verification_cas and the solq_match attestation are deleted.

The alert at determination. The fan-out reaches determined cases only. So persist_determination (api/ive_determination.rs), after insert_determination, calls upsert_review_item(tx, case_id, "no_gateway_record") when the witnessed run holds a no_gateway_record outcome (a new read in store/ssa_benefits.rs). derive_evidence is unchanged.

D6. Vocabulary and schema

  • Step 4, cases ssa_screening_outcomes.member_outcome and exchange ssa_screening_members.status: no_match → no_gateway_record, rows updated and CHECKs swapped.

  • Step 4, cases screening_review_worklist.latest_reason: the CHECK gains no_gateway_record.

  • Step 5, exchange ssa_screening_members: ssn_digest dropped, identifier_id UUID NOT NULL added, ssn_stale → identifier_stale, unmappable removed.

  • Step 5, cases ssa_screening_outcomes.member_outcome: unmappable removed and its fact-less rows deleted.

Step 5’s exchange migration first deletes the rows of ssa_screening_jobs, ssa_transport_handoffs, ssa_screening_members and ssa_screening_runs, in that order: a run bound to SSN digests has no identifier to re-key to, and no run was sent under authority. The Rust enums, the retention and archive specs that name ssn_digest (ssa_retention.rs, retention_archive.rs), the worker’s job classes, craig-web’s and plugins/ssa-screening’s status labels, and `tests/e2e follow the same renames.

Steps

Each step is one MR on its own branch from main, with its tests, docs and a changelog.d/ fragment.

  1. Plan. This page under plans/, its nav entry, and in ssa-data-exchange.adoc an erratum line plus N/A for C0–C3. The issue this plan closes (#3175) and the two out-of-scope issues (#3176, #3177) are filed; the rescope is noted on #1433.

  2. Setting. D1’s setting in craig-state-bundle and craig-config-bundle, inert. Then Georgia’s settings.toml, as an MR in craig-config-georgia.

  3. Codec. D3’s module, its dependency and its tests. The adapter impl is untouched.

  4. Outcome semantics. D5 without the identifier binding: echo_matched and the CAS go; screened_month, termination by absence, NoGatewayRecord and both alert writers arrive; D6’s step-4 rows. expected_digest, verify_digest and Unmappable stay until step 5: the worker still sends the placeholder and maps Unmappable.

  5. Re-key. D1’s cohort and seam, D2, D4, D5’s identifier_id, D6’s step-5 rows, and the lock bump.

  6. Close. The plan to plans/archive/, Status Done, a note on #162 with what Phase P still owes.

Risks

  • Another person’s row is credited to the member (fail-open: a sibling’s SSI would derive a parent’s incapacity). Mitigation: a row counts only on a numeric clientID match; test a_household_members_row_is_not_credited_to_the_client.

  • A stale active fact survives when Gateway has no record (fail-open). Mitigation: the no_gateway_record alert from both writers; tests no_gateway_record_alerts_the_determined_case and a_determination_over_a_no_record_member_opens_the_item.

  • Termination by absence on a Gateway data gap (fail-closed: a benefit is dropped and a deprivation basis lost). Mitigation: the chain is append-only, so the next screening re-activates it, and the termination itself raises facts_recorded; the operations page says so.

  • Contract drift read as "no benefit" (silent, then fail-closed through termination). Mitigation: a row without clientID or unearnedType, and a missing returnCode, are errors, not empty answers; tests a_row_without_its_type_is_malformed and an_answer_without_a_return_code_is_a_partner_error.

  • Hostile or oversized XML (fail-closed). Mitigation: DTD refused, node limit, 1 MiB cap; tests a_doctype_is_refused and parse_never_panics.

  • The client number or another person’s data leaks into a log, row or event (silent). Mitigation: ClientNumber redacts, errors carry no bytes, and the canary sweep covers the new path; test the_inquiry_leaves_no_canary_in_any_sink.

  • A deployment sends before Phase P (fail-closed): the witness is unchanged, pinned by witness_unconstructible.

  • The setting is absent (fail-closed: screening refuses SCREENING_UNCONFIGURED); test screening_refuses_without_a_configured_kind.

  • Step 5’s migration deletes development runs (silent). Mitigation: the changelog’s operations note; no run was sent under authority.

Tests

Contract (wire).

  • the_envelope_matches_the_pinned_bytes: the request, byte for byte.

  • Fixtures written from the WSDL under crates/craig-partner-ssa-solq/tests/fixtures/income_inquiry/, one test each: r000_ssi_and_rsdi, r000_month_absent, r005, r006, r007, empty_service, nil_fields, fault, and the R001–R004 refusals.

  • the_worker_posts_the_envelope_and_no_ssn: the body wiremock received equals `envelope’s output.

  • Worker classes, against wiremock: a_refused_request_fails_the_member_without_a_retry, a_partner_error_is_retried and an_unparseable_client_number_fails_the_member.

  • The OpenAPI goldens of craig-cases and craig-exchange, and cohort_hash_matches_the_pinned_vector (v2).

Property. parse_never_panics, on arbitrary bytes. parse_agrees_with_the_model: generated answers with shuffled rows, unknown elements, several clients and more rows than the WSDL allows; the kinds equal the model’s.

Regression.

  • a_household_members_row_is_not_credited_to_the_client, and rows_past_the_wsdl_caps_are_all_read (five unearnedIncome, three inquiryData).

  • a_screened_answer_without_the_row_terminates_the_active_fact, no_gateway_record_terminates_nothing, and a_replayed_outcome_writes_no_second_termination.

  • a_member_without_the_identifier_refuses_the_cohort, an_ssn_change_no_longer_bumps_the_cohort and ending_the_identifier_bumps_the_cohort.

Concurrency. an_identifier_ended_before_the_send_makes_the_member_stale, and an_end_racing_the_outcome_leaves_facts_or_a_stale_member: an END and the outcome transaction joined; one of the two legal results holds.

Security. only_exchange_may_release_the_identifier, the_inquiry_leaves_no_canary_in_any_sink, and the release’s audit events through craig-security’s parser.

End to end. tests/e2e/specs/cases-ssa.spec.ts records identifiers, not SSNs, and gains the missing-identifier leg.

Delivery

  • ADRs: ADR-066 gains an amendment (Gateway as counterparty and source, the wire, the mapping, termination by absence, the unchanged witness); ADR-065 gains one (the identifier release replaces the SSN release).

  • Docs, each in the step that changes its surface: data-model-cases.adoc, data-model-exchange.adoc, the regenerated api/craig-cases.adoc and api/craig-exchange.adoc, operations/ssa-screening-ops.adoc, operations/ssa-digest-rotation.adoc (its screening part goes), configuration-reference.adoc (the setting) and the event catalogue in adrs/adr-003-rabbitmq-topology.adoc. The interface page stays the contract.

  • CHANGELOG entry: one changelog.d/<issue>.<slug>.<type>.adoc fragment per step, folded into CHANGELOG.adoc at release. Steps 4 and 5 are breaking wire and schema changes and carry operations notes.

  • Close: step 6 closes the plan’s issue and archives the page.

Erratum (2026-11-27): settings.toml’s keys are documented in `multi-jurisdiction-extensibility.adoc § settings.toml, not configuration-reference.adoc; the setting’s doc goes there.

Review log

Round Vendor Resolved model Verdict

1

Anthropic (Vertex)

vertex-anthropic/claude-fable-5-2

FLAGS on the second question. D2 named an audit key the tree lacks: the release wrapper emits case.person_pii_exported. And D4’s no-retry class had no worker test. D2 now keeps that key and wrapper and names the refusal key’s rename. Tests gained the three worker-class cases.

2

Google (Vertex)

vertex-gemini/gemini-4-carbon

CLEAN on all four questions; the maintainer then approved the plan for implementation.

Edit this page · latest