Plan: AFCARS Pipeline II — Records and Generate (#2125, P-D2 of #1965)

Archive record

Merge requests: !1776 (U0 plan page + the A4 / A7 and ADR-048 errata + the unit and follow-up issues, Relates #2125) + !1777 (U1, Closes #2138) + !1778 (U2, Closes #2139) + !1779 (U3, Closes #2140) + !1780 (U4, Closes #2141) + !1781 (U5, Closes #2142) + !1782 (U6, Closes #2143) + !1784 (U7, Closes #2144) + !1785 (U8, Closes #2145) + !1786 (U9, Closes #2146 and #2125)

2026-10-02 — approved in plan mode 2026-10-02 (rulings R-D8–R-D11 as recommended) after a contextless round 1 (no-ship, 2 blockers fixed, 9 findings folded) and the maintainer’s round 2 (no-ship, 9 findings folded). What landed: the reporting field key (U1: CRAIG_REPORTING_FIELD_ENCRYPTION_KEY from ADR-064 store v2, delivered to craig-reporting only; encryption_mode lifted onto ServiceSettings; the shared boot verifier in craig_search::lineage with the value-free KeyLoadReason; a crypto_key_lineage migration; crates/craig-reporting-fields); the record model (U2: the submission chain, file and supersedes_id; five record tables by CFR cardinality, a cell one slot per value-set atom as JSONB, the R11 columns TEXT envelopes; coverage, gaps and the policy stored once by hash; AFCARS_RECORD_CONTRACT with files; long tokens cut to 63 bytes); the window and clients (U3: label to window, local midnights, as_of = enqueue minus the extended ceiling; financial_base_url; three paged clients and the cases batcher of 500 keys and 10 000 anchors); assembly (U4: Crosswalk::lookup, seven rule tables, raw values only; a 2028-series view refused until #2148); the derivations (U5: the §1355.42(a) population, strictly more than the threshold over the whole episode; the reported episode; plan links per R-B8; (b)(9); the cohort index and (b)(20) / (b)(21)); the generate job (U6: afcars_generate in child-boundary batches of 250, the population rule before any cases ask, ONE commit of head lock, establish_lineage, submission, records, coverage, gaps, policy and complete_in_tx; recovery first; 17 closed engine_failed tokens; every AFCARS dead-code expect retired; the volume measure on #2125, follow-up #2154); the 202 flip (U7: the strict PeriodLabel request and the extractor’s 422 before authz; claim first, a replay answered before the surface checks, the typed 503 AFCARS_SURFACE_NOT_READY, the generability 422, background_job claims; the web poll shell, CLI --client-request-id / --no-wait, suites planting by SQL, seed half labels; the program close-out grep empty); replay vs regenerate (U8: the export renders under the submission’s retained policy, read_policy re-verifying both document hashes, never the live surface; the TSV names the retained identities; no policy row is the typed 409 afcars-policy-missing, a tampered document a logged 500; seed policy rows; #1965 AC2 proven by a same-name crosswalk promotion). Pre-existing races met on the way were fixed on their own branches (!1783, #2156) or filed (#2155). Follow-ups: #2147 (the (a)(1)(ii) capture), #2148 (the 2028 series), #2149 (column-key rotation), #2150, #2151, #2152, #2153, #2154, #2155; P-D3 #2126 carries the inputs.

Status

Done (2026-10-02) — !1786

Anchor What binds here

#2125; AFCARS 2020 Program (#949)

A4 (the surface, the two verbs), A6 with its errata, A7 (the record model) — erratum requested (R-D10), A10 (hermetic legs), R3, R11, R13, R14

P-D1 (#1965) D1–D7 as built and the P-D2 inputs on #2125

binding: rows not elements, the cohort before the population rule, the cases keys and caps, the three as-of classes, "a failed call fails the generate, never a default", (a)(3)'s case, financial_base_url with its reader

The P-D inputs on #1965 (P-B1, P-B2 D6 / D11, P-B3 D2–D4, P-C D5)

binding: the same-day plan rule, the caregiver slots, the adoptive-parent ids, (b)(20) / (b)(21), the (c) cells, (g)(3) not_applicable

ADR-048 D3 and § Amendment — #949

the dedicated reporting key, its named channel, the KCV lineage — wording erratum (R-D9)

ADR-064

the store schema is exact; a second entry is an amendment

ADR-062 and the NCANDS job (#1936, services/craig-reporting/src/jobs.rs)

the claim, the 202 shape, one commit per job

ADR-040

per-row materialization; leave-unpopulated (no faithful value is a blank, never a guess)

⁂ = a reading DFCS may rule otherwise, logged on #1073. "Local" is craig_common::clock::BusinessClock on the jurisdiction clock.

Context (census 2026-10-01, on main)

  • Generate is a stub: a synchronous 200 with a zero-record draft under the claim entity afcars_submission (services/craig-reporting/src/api/afcars.rs:63-145, src/api/intents/creates.rs:19). afcars_submissions has no status CHECK, no chain and a free-text period; the seed plants YYYY-Qn labels and no records (tools/craig-seed/src/datagen.rs:3064).

  • The surface is built, unconsumed: snapshot, view_for and policy_snapshot wait for P-D under expect(dead_code) (src/afcars_surface/mod.rs:186-216, :359-364); there is no 503 mapping; parse_pair drops the documents' content (afcars_surface/verify.rs:129-160); the production contract is empty (contract.rs:104-109) while covers walks every element, assist and the 2028 series included. Until #1987 a deployed surface stops at layout-unpinned.

  • No reporting key, one client: no fields crate, crypto dependency or key mount; the ADR-064 store holds one entry (xtask/src/secrets_store.rs:12-21); the verifier is craig-cases' (boot_verify.rs:169); reporting reads cases_base_url only.

  • The dictionary is data: 142 elements and the population table (#2027), no evaluator, no crosswalk value-to-code lookup; PeriodLabel, period_end_of (afcars_crosswalk/verify.rs:236) and the metadata route’s place already resolve a half.

  • NCANDS is the 202 precedent (#1936): one job per period, one commit, submission id = job id; web, CLI and test-lib already poll reporting jobs. A claim stored under another entity answers idempotency-conflict (crates/craig-api/src/request_claims.rs:465), not the replay-entity-gone the #1936 CHANGELOG entry says.

Scope

In: D1–D9. Out: applicability, the classes, findings and finalize (P-D3); the encrypted artifact and readiness (P-D4); the XML, (a)(4) and its pseudonym key, the period reservation, the lifecycle e2e (P-D5); the assistance file (P-E); the class-3 history (#2131); the column key’s rotation (#2149); any NCANDS change.

Design

D1 — The reporting field key (R11, R-D9)

  • A column key. CRAIG_REPORTING_FIELD_ENCRYPTION_KEY, loaded by FieldEncryptor::from_env, encrypts D3’s R11 columns (and P-D4’s artifact) and never derives the record number: P-D5’s pseudonym key is separate. Rotation is not built here: it needs an old-key-to-new-key re-encryption of immutable Opaque cells and a lineage transition, which the #1399 tool does not do (it moves one column between schemes under one key, crates/craig-search/src/rewrite.rs:97-99); #2149 owns it.

  • Delivery. The ADR-064 store becomes v2 — shared.field_encryption_key plus shared.reporting_field_encryption_key (an ADR-064 amendment) — and cargo xtask secrets mints the new entry fresh, non-interactively, never typed. The devstack writes devstack/reporting-field-key.env beside field-key.env (xtask/src/field_key.rs, field_key_reconcile.rs), with its own KCV marker in the wipe guard (devstack_guard.rs:762), gitignored like field-key.env (.gitignore:27), mounted into craig-reporting only. devstack/ci/write-field-key.sh and the integration job’s own key step (.gitlab-ci.yml:497) write both files, each key 32 independent random bytes. .env.example, configuration-reference.adoc and deployment-guide.adoc (production: the orchestrator store) name it.

  • Mode. encryption_mode moves from CasesSettings to ServiceSettings (the flatten rule, settings.rs:296-306): cases reads CRAIG_CASESENCRYPTION_MODE unchanged, reporting CRAIG_REPORTINGENCRYPTION_MODE; default required.

  • Lineage. A crypto_key_lineage migration in craig_reporting (the cases DDL). The boot matrix moves into craig-search behind its sqlx feature, parameterised by (registry, key env name); craig-cases calls it with unchanged behaviour and reporting calls it at boot, verify-only. The writer is the generate commit (D7): INSERT … ON CONFLICT DO NOTHING of the KCV row (or the keyless sentinel), then a verify of KCV and canary against the row that won — ADR-048 D3’s deferred production first-write, atomic with the first ciphertext. No seeder writes reporting lineage.

Erratum (2026-10-04): P-D4 U2 (#2177) — a keyed AFCARS export also establishes or verifies the row before its claim (establish_lineage, plan afcars-readiness D2); the generate is no longer the sole writer.

  • crates/craig-reporting-fields, the craig-cases-fields shape: U1 lands it with an empty DEFAULT_REGISTRY and proves the shared verifier over a fixture registry; U2 registers D3’s R11 columns (Opaque) and owns reporting’s ciphertext leg.

D2 — The submission and the supersede chain (A7)

  • afcars_submissions gains file (NOT NULL DEFAULT 'oohc', CHECK oohc or assist) and supersedes_id (nullable, UNIQUE, FK to itself ON DELETE RESTRICT). A new submission’s reporting_period is its canonical PeriodLabel.

  • The head of (reporting_period, file) is the row with a policy row (D3) that no row supersedes. The generate commit reads it FOR UPDATE and links to it; the job’s dedup key serialises generates per half and the UNIQUE backstops a fork.

  • Prior rows keep their records, snapshots and export pointers; validated_with_errors stays terminal per row (transitions.rs:16); the transition graph is P-D3’s.

D3 — The record tables (A7, R3, R11; R-D8, R-D10)

Table Cells (by dictionary cardinality) One row per

afcars_child_records

most_recent: (a), (b), (c)(1)–(c)(4) and the 2028 most_recent rows

child

afcars_record_parents

per_parent: (c)(5)–(c)(5)(ii)

parent_set entry, in its order, uncapped

afcars_record_removals

per_removal and per_exit: (d), (g), (h) and the 2028 (i) removal and exit rows; (d)(6)(ii) as a date list

episode

afcars_record_living_arrangements

per_living_arrangement: (e) and the 2028 (i)(5)–(i)(8) rows

arrangement

afcars_record_events

per_plan, per_visit and the (f) repeating dates, kind = plan, periodic_review, permanency_hearing or visit

event

  • Keys. Each row (and each gap row) carries an id UUID v7 primary key (the AAD’s row id), submission_id (FK ON DELETE RESTRICT), child_id and its source id (episode, arrangement, parent, plan, review or contact). An arrangement row and a plan event also carry removal_record_id, a FK to its episode’s afcars_record_removals row — a plan’s from D6, null when undated — so a same-day exit and re-entry keeps ownership after instants become dates.

  • Cells. One column per element token in dictionary document order (a token in both series is one column). A cell holds one optional slot per atom of its element’s value set, in value-set order, each a typed CellValue (one variant per Atom kind, afcars_dictionary/mod.rs:973, plus a date list for a repeating_dates cell held on one row, (d)(6)(ii)): (b)(1) keeps its date AND its estimated_abandoned indicator. Stored as JSONB; all slots empty is NULL, the blank. A trigger refuses UPDATE and DELETE.

  • R11 columns (R-D8). (b)(1), (h)(3), (h)(8); (d)(5)–(d)(6)(ii); (e)(11), (e)(16), (h)(5), (h)(10): TEXT holding the envelope of the same JSON, Opaque in craig-reporting-fields, written by encrypt_row and read by decrypt_row (crates/craig-search/src/row.rs:237, :408). The AAD binds table, column and row id, so a regenerate re-derives every cell.

  • Coverage. afcars_submission_coverage(submission_id, key, sourcing), one row per oohc element of the period’s view (key = its ElementKey) and one per population situation (key = population.<situation>); sourcing is captured, derived or unsourced ((a)(4), P-E’s (h)(14) and population.ive_payments_under_agreement are unsourced).

  • Gaps. afcars_record_gaps(submission_id, child_id, element_key, reason) says why a sourced cell is blank: person_not_found, admin_unit_unresolved, sibling_without_arrangement, plan_undated, crosswalk_unmapped. P-D3’s findings read it.

  • Policy (R-D10). afcars_policy_documents(content_sha256 PRIMARY KEY, content JSONB), inserted if absent, the hash recomputed on every write and read; afcars_submission_policy(submission_id PRIMARY KEY, the dictionary’s and crosswalk’s rule_set_id, revision and content_sha256), each hash a FK to the documents. Plaintext, outside the registry. VerifiedSnapshot keeps the read content.

  • Compatibility (R13). src/afcars/records/schema.rs is the one element → (table, column) map, in column order: it drives the INSERTs and is AFCARS_RECORD_CONTRACT — every oohc element of both series with its own cardinality and the kinds of its committed atoms; layouts stays empty until P-D5’s renderer. The contract gains files, the data files this build generates (oohc), and covers checks only their elements (contract.rs:166 walks every element today), so the assist rows wait for P-E without holding the oohc file not ready after P-D5 (R-D10).

Erratum (2026-10-02): 23 oohc tokens exceed Postgres’s 63-byte identifier limit; each column is the token cut to 63 − 1 − len(paragraph) bytes, trailing _ trimmed, then _<paragraph> (U2, #2139); the R11 registry uses the same names.

D4 — The window and the three clients (A6, P-D1 D2)

  • Window. A label resolves to from = local midnight of the half’s first day (place), to = local midnight of the day after period_end_of, and as_of = the enqueue instant minus EXTENDED_REQUEST_CEILING, minted once, then checked by check_export_window. A half is generable iff it has ended (to ⇐ as_of), is on or after the crosswalk’s supported_from, and has a dictionary period row; otherwise 422 validation-failed naming reporting_period.

  • Settings. financial_base_url joins ServiceSettings beside placement_base_url; reporting reads all three leaves; compose sets CRAIG_REPORTINGPLACEMENT_BASE_URL and CRAIG_REPORTINGFINANCIAL_BASE_URL; .env.example and configuration-reference.adoc list them.

  • Clients (src/afcars/clients/, the cases_client.rs shape: service token, per-page 8 s budget, 503 fail-closed without a token, no retry), typed by the producers' contracts crates (new dependencies on craig-placement-contracts and craig-financial-contracts). Each walks its cursor to next = null with from, to and as_of fixed.

  • The cases batcher. At most 500 keys and 10 000 anchors per call; one child key per distinct (child, case); each caregiver and adoptive parent once per role with the union of its anchors; the same body bar after and limit on every page.

  • Any non-200 page fails the walk: never a default.

D5 — Element assembly (pure, src/afcars/assembly/)

  • Instants project to local dates; (d)(2) and (g)(2) take first_recorded_at (R14).

  • A cell is read at its element’s temporal_anchor: the window row in force at that date; (b)(11) at the earlier of period end and an in-period exit; slot caregivers at the arrangement’s (e)(1) date; adoptive parents at the exit date.

  • (c) is copied from parent_cells as cases resolves it (crates/craig-cases-contracts/src/afcars_export_ledgers.rs:40-75): the (c)(1)–(c)(4) cells, and per parent its (c)(5)–(c)(5)(ii) with death dates and the deceased indicator already applied.

  • Crosswalked elements map the fleet token to the ACF code through a lookup added to afcars_crosswalk; the cited unmapped arm is a blank with gap crosswalk_unmapped (A3 erratum).

  • (f)(3) / (f)(4) split held_on by review kind; (g)(3) is not_applicable without an answered exit; (b)(18) is yes iff the child is in financial’s id set; a gated cell carries its list only when the parent response is enabling.

  • A not_found child key leaves its cases-sourced cells blank with gap person_not_found; placement’s cohort decides membership.

  • Header. (a)(1) is the jurisdiction’s state FIPS; (a)(3) the county FIPS of the selected case’s admin_unit (services/craig-reporting/src/ncands_mapping.rs:170-200), an unresolved unit a blank with gap admin_unit_unresolved, never the raw name ⁂ — P-D5 checks both against the bulletin’s format; (a)(2) is the month and year of period end; (a)(4) is blank.

  • Raw only. No applicability row is evaluated: (e)(4) under (e)(2) = yes, the (d)(6)(i) gate and every blank-by-rule are P-D3’s.

  • The 2022 series. U4 assembles every element a half ending before 2028-10-01 serves. The 2028 series — incl. folding the per-parent (i)(2) / (i)(3) answers into their most_recent cells — is #2148, due before 2029A; until it lands its cells are blank and unsourced.

Erratum (2026-10-02): U4 (#2141) rulings — period-end cells and the (c)(5) rows read the reported episode’s child key, events the union of the child’s keys; (e)(4) is blank on a foster_family_home arrangement; an adult’s abandoned race is blank; a not-found adult, and (a)(3) under a not-found key, are person_not_found; a dated plan outside every episode has a NULL link and no gap.

Erratum (2026-10-02): U4 refuses a view ending on or after 2028-10-01 (AssemblyError::ElementNotInForce, the first 2022-only token absent) instead of assembling it with blank 2028 cells: a loud refusal, never a silent blank. #2148 replaces the refusal; no such half is generable before 2029-04-01.

D6 — Derivations (pure, src/afcars/derive/; #2027 merged)

  • Population (§1355.42(a), read through DictionaryView::population). A cohort child is in it iff an episode in the period (exit absent or at or after from) lasted MORE than its row’s more_than_hours in total (exactly 24 h is out; an open episode runs to to) — situation runaway_or_whereabouts_unknown when the arrangement in force at removal is runaway or whereabouts_unknown, else foster_care; the whole episode counts, not its overlap with the period (retained_through). ive_payments_under_agreement (§1355.42(a)(1)(ii)) has no capture: coverage records it unsourced; the capture is #2147 (R-D11). A child outside the population gets no record.

  • The reported episode — for (a)(3), (b)(9) and every period_end cell — is the child’s latest episode with removal before to, ties broken by episode id.

  • Plans to episodes. A plan goes to the episode whose closed date interval holds its established_on, a date in two going to the later (R-B8 ⁂); no established_on is gap plan_undated.

  • (b)(9) is yes iff a health_assessment_visit falls inside the reported episode, on or before period end.

  • (b)(20) / (b)(21) (P-B2 D11, P-B3 D4), over the sibling_link rows in force at period end and a cohort-wide index (child → in care at period end, setting identity, placement type): (b)(20) counts siblings with a live episode and an effective arrangement at period end, placed_at_home excluded ⁂; (b)(21) counts those at the child’s setting identity. A sibling in care without an arrangement blanks both, gap sibling_without_arrangement.

D7 — The generate job and the 202 (A4, R13)

  • Handler, in order. Authz; reporting_period parsed as a PeriodLabel (deny_unknown_fields), else 422. Then one execute_claimed_tx composing claim_first and enqueue_in_claim (the claim_enqueue shape, crates/craig-api/src/jobs/claim_enqueue.rs:91-121; claim entity background_job, scope reporting.generate_afcars, intent reporting_period): a replayed claim answers its existing job, 202, whatever the surface now says; a fresh claim first needs snapshot() verified — else a typed 503 problem_types::AFCARS_SURFACE_NOT_READY (a new URL beside SCREENING_SURFACE_NOT_READY, crates/craig-common/src/error.rs:618) naming the reason token — and D4’s generability checks against the verified documents, else 422; either refusal rolls the claim back. Then the enqueue, 202 with Location. Another generate for an active half is 409 job-already-active.

  • Kind afcars_generate, registered beside NCANDS: dedup afcars_generate:<label>, lease_key = None, CONSENT = false, three attempts; input = label and as_of.

  • Attempt. snapshot() again (not verified is terminal Engine("surface_not_ready")); view_for the period end; financial’s id set first; then placement’s walk in child-id order, closed into batches at a child boundary (at most 250 children). Per batch: the population rule on placement’s rows, so cases is asked only for in-population children and their adults; the cases calls; assembly and the per-child derivations. Raw rows are dropped and only records and the cohort index accumulate; (b)(20) / (b)(21) fill after the walk.

  • One commit. The head FOR UPDATE, the lineage establish-or-verify (D1), the submission (id = job id, draft, record_count), records, coverage, gaps, policy, supersedes_id and complete_in_tx. A re-queued attempt re-walks under the same as_of; recovery short-circuits on an existing submission with the job’s id.

  • Failure. A non-200 page, a lineage mismatch or an encrypt error ends the job failed with a reason that carries no cell value.

  • The flip, in one MR with the handler. The test-lib generate_afcars returns ApiResponse<JobView>; craig-web redirects to ?job= with the poll shell, flashes "AFCARS generation started." and names the 503 reason; craig-cli gains --client-request-id, the poll and --no-wait (run_generate_ncands, services/craig-cli/src/cmd/reporting.rs:297); the devstack suites plant submissions by direct SQL with their policy rows and assert the 503 where they generate; the e2e generate leg (tests/e2e/specs/reporting-actions.spec.ts:46) becomes the 503 leg; the seed and spec labels become PeriodLabel`s, which claims the program’s close-out grep `2025-Q|2026-export-Q; the generate route’s skipped String categories in tests/api/evil_corpus.rs run; the ceilings comment, ADR-068’s row, the API page and cli.adoc.

Erratum (2026-10-02): reporting_period is a typed PeriodLabel in GenerateAfcarsRequest, so a malformed label and an unknown field are the fleet extractor’s 422, before authz (the NCANDS order); a well-formed caseworker request is 403 before any claim (U7, #2144).

D8 — Replay vs regenerate (A4)

  • Request replay (ADR-062): the same client_request_id returns the same job.

  • Regenerate: a fresh id for a half with a head creates a new submission on the current surface that supersedes it (D2).

  • Replay (A4): an export renders under the submission’s retained policy, read from afcars_submission_policy with every hash re-verified, never from snapshot(). The TSV metadata row gains the retained dictionary and crosswalk identities (pre-1.0 Changed), so a promotion under the same name changes no re-export. A submission without a policy row is refused 409 afcars-policy-missing; the seed plants policy rows for its submissions. P-D5 re-points the test at the XML.

  • A regenerate may differ from its predecessor (new captures, class-3 edits read current, #2131); a replay never does.

D9 — Code layout

  • services/craig-reporting/src/afcars/: window.rs, clients/, assembly/, derive/, records/ (schema.rs, the store), job.rs. api/afcars.rs (804 lines) changes only its generate handler and the export’s policy read.

  • Code landed before its production caller carries cfg_attr(not(test), expect(dead_code, reason = …)) naming U6 (the P-A precedent, afcars_surface/mod.rs:186-192); U6 removes every one, the surface’s included, and deletes a surface method still without a caller; U7 deletes NOT_READY_TYPE.

Erratum (2026-10-02): U6 (2143) keeps one expect — window::as_of_for, whose only production caller is U7’s generate handler minting the job’s as_of, names U7 (#2144), and U7 removes it. job.rs landed as job/ (mod.rs, batch.rs, walk.rs, commit.rs); records::Cell::{blank, from_stored} and the two errors only they build are [cfg(test)] until P-D3 / P-D5 call them.

Units

Each MR Relates to #2125, #1965 and #949 and closes its own unit issue; U9 closes #2125.

MR Scope W

U0

this page (Active nav); the unit issues under &99 (U1 #2138 … U9 #2146); the A7 / A4 and ADR-048 errata (R-D9, R-D10); issues: the §1355.42(a)(1)(ii) capture #2147 (R-D11), the 2028-series assembly #2148 (D5), the column key’s rotation #2149 (D1), the #1936 CHANGELOG wording #2150, idx_afcars_status in data-model-reporting.adoc #2151; ⁂ entries on #1073

1

U1

FIELD KEY: the store v2 and its ADR-064 amendment, delivery incl. the CI key step, the mode lift, the shared verifier, the lineage table, the fields crate (D1)

5

U2

RECORD MODEL: the chain columns, the record, coverage, gap and policy tables, the R11 registry, the store, the contract and its files, the surface keeping content (D2, D3)

5

U3

WINDOW AND CLIENTS: label to window, financial_base_url, the three clients, the batcher (D4)

3

U4

ASSEMBLY (D5)

5

U5

DERIVATIONS (D6)

3

U6

GENERATE JOB: the kind, the batched walk, the one commit, the lineage writer, recovery; enqueued by tests only (D7)

5

U7

THE 202 FLIP: the handler, the typed 503, the claim, every consumer, the labels (D7)

3

U8

REPLAY VS REGENERATE (D8)

2

U9

CLOSE-OUT: data-model-reporting.adoc as built, the archive row, the P-D3 inputs on #2126 (coverage, gaps, the raw cells it blanks)

1

Weight 33. U0 first; U1 → U2; U3 after U0; U4 after U2 and U3; U5 after U4; U6 after U1–U5; U7 after U6; U8 after U7; U9 last. Every MR is green alone with its CHANGELOG entry; every new test carries // @axis:. Hermetic legs run the in-src job runtime over the reporting scratch base with wiremock producers and VerifiedGeorgiaSurface (tests/support/afcars_surface.rs:104); devstack legs see the 503 until #1987.

Test matrix (by risk)

Test Axis Unit Asserts

a_wrong_key_or_a_keyless_boot_on_keyed_lineage_refuses

fault

U1

the shared matrix over a fixture registry; the remedy names CRAIG_REPORTING_FIELD_ENCRYPTION_KEY; craig-cases' boot legs and the store’s schema tests pass with the second entry

pii_cells_are_envelopes_at_rest

evil

U2

a raw read of every R11 column is an envelope; a cell copied to another row fails to decrypt; reporting ciphertext without lineage refuses boot

record_schemas_match_the_dictionary_elements_in_order

evil

U2

every oohc element of both series maps to one column of its cardinality’s table, in document order, no orphan column (scratch DB); covers reports no delta, an assist row change none

a_date_and_its_indicator_survive_together

evil

U2

(b)(1) with a date and estimated_abandoned round-trips both slots

record_rows_are_immutable

evil

U2

UPDATE and DELETE refused on every record table

a_projection_never_receives_a_period_string_only_resolved_instants (#1965 AC2)

evil

U3

every wiremocked placement and financial query and every cases body carries local-midnight from / to and one as_of, no period field

a_window_for_a_half_resolves_to_local_midnights

happy

U3

2026A → 2025-10-01 to 2026-04-01 on the Georgia clock

the_cases_batcher_splits_at_500_keys_and_10000_anchors

sad

U3

501 keys → two calls; a shared caregiver once with its anchor union; one body bar after per page

a_failed_page_fails_the_walk

fault

U3

a 500, 503 or timeout on any page of any route is an error, never a default

each_cell_is_read_at_its_anchor

happy

U4

period end, exit, removal, arrangement and (b)(11)'s earlier-of

instants_project_to_jurisdiction_dates_across_dst

evil

U4

(d)(1), (e)(1), (g)(1) at 23:30 local on both DST days

transaction_dates_ride_the_first_recording

happy

U4

a corrected removal keeps (d)(2) = its first first_recorded_at

a_crosswalk_unmapped_arm_is_a_gap_never_a_value

evil

U4

blank cell plus crosswalk_unmapped

a_not_found_key_or_unresolved_unit_is_a_gap

sad

U4

the record exists; the cells are blank; person_not_found / admin_unit_unresolved

exactly_24_hours_is_outside_the_population

evil

U5

24 h out; 24 h + 1 s in; an open episode counts to to

a3_takes_the_unit_of_the_latest_removal_case

happy

U5

two cases, a re-entry, a tie broken by episode id

a_plan_on_a_same_day_exit_and_re_entry_goes_to_the_later_episode

evil

U5

R-B8

a_visit_after_exit_or_in_another_episode_leaves_b9_no

evil

U5

P-B3 D4

a_sibling_in_care_without_an_arrangement_blanks_b20_and_b21

evil

U5

never defaulted; the gap is recorded

siblings_count_across_batches

happy

U6

siblings in different batches count in (b)(20) / (b)(21)

every_parent_and_episode_link_is_retained

evil

U6

three parent_set entries make three parent rows in order; a same-day exit and re-entry keeps each arrangement and plan with its episode

cases_is_asked_only_for_in_population_children

evil

U6

a 20-hour episode’s child and its caregivers reach no cases body

an_interrupted_walk_recovers_without_duplicate_records

fault

U6

same as_of; records once; recovery short-circuits

a_generate_writes_its_coverage_and_policy

happy

U6

one coverage row per view element and situation; the policy hashes equal the snapshot’s

a_lost_surface_or_a_lineage_mismatch_fails_the_job_and_writes_nothing

fault

U6

terminal failed, no submission

no_cell_value_reaches_the_job_error_or_logs

evil

U6

sentinel DOB and trafficking values absent from error and the tracing capture

the_surface_not_ready_503_leaves_no_claim

sad

U7

typed URL and reason; no claim, no job; the same id later is a fresh claim (devstack and hermetic); craig-web and craig-cli show the reason

a_caseworker_is_403_and_a_malformed_label_is_422_before_the_503

evil

U7

the order; an unended half is 422 only once verified (hermetic)

generate_answers_202_and_the_same_id_replays_the_job

replay

U7

hermetic; submission id = job id; one job, one attempt

an_accepted_request_replays_after_the_surface_is_lost

replay

U7

the retry answers its job, not the 503 or a 422

a_pre_flip_claim_answers_idempotency_conflict

replay

U7

a stored afcars_submission claim

a_second_generate_for_an_active_half_is_409

conc

U7

job-already-active; the claim rolled back

concurrent_regenerates_keep_one_linear_chain

conc

U8

one head per (period, file); the UNIQUE holds

a_regenerate_supersedes_and_the_prior_row_is_retained

replay

U8

the prior keeps records, snapshots and its pointer

re_export_renders_under_the_retained_policy_content_not_the_current_name (#1965 AC2)

replay

U8

a promotion under the same name: the re-export (same generated_on) names the retained hashes, byte-identical; a regenerate names the new revision

a_tampered_or_missing_policy_refuses_the_export

evil

U8

a content edit fails the hash; a missing row is 409 afcars-policy-missing; no artifact

Erratum (2026-10-04): #2174 makes the retained policy immutable, so the tamper leg’s content edit is now refused by the trigger; the leg plants damage by inserting a document whose content does not hash to its key.

Verification

  • Per MR: the gate list (fmt, clippy, the budgets at their locks, validate-authz-coverage, api-docs --check, check-docs, plan-lint), then the battery (bare git push); U6 records a full-state walk’s time and peak records on #2125.

  • Close-out: cargo xtask plan-lint --done docs/modules/ROOT/pages/plans/archive/afcars-records-and-generate.adoc --allow-open 949,1073,1965,1987,2000,2125,2126,2131,2146,2147,2148,2149 --allow-missing devstack/reporting-field-key.env (plus #2150 / #2151 while open).

Rollout and risks

  • U1: set CRAIG_REPORTING_FIELD_ENCRYPTION_KEY and CRAIG_REPORTING__ENCRYPTION_MODE before the roll (required refuses boot without a key). U3: set both base URLs before the roll. U2: additive (a defaulted file, a nullable supersedes_id, new tables), no floor bump.

  • U7: one roll of craig-reporting, craig-web and the CLI release; Ops line: a stored pre-flip AFCARS claim answers 409 idempotency-conflict until it expires. The other units need no order.

  • Risks: a full-state walk’s time and memory (batched; measured at U6); PII in a long-retained copy (R-D8 bounds it); class-3 edits read current (#2131); the column key cannot rotate until #2149 lands (D1).

# Recommendation Alternative

R-D8

The R11 columns are the cells approved text calls PII: the dates of birth (b)(1), (h)(3), (h)(8) (R-D5); the trafficking cells (d)(5)–(d)(6)(ii) and the caregiver and adoptive-parent race (e)(11), (e)(16), (h)(5), (h)(10) (A6)

the dates of birth only; every sensitive fact, ahead of #2000

R-D9

Two reporting keys: P-D2’s column key (records and P-D4’s artifact; no derived value pins it, its rotation is #2149) and P-D5’s never-rotated pseudonym key; ADR-048 § #949 reworded at U0

one root key with HKDF domains, which makes the column key unrotatable

R-D10

A7 / A4 erratum: tables by cardinality (afcars_record_parents; the (i) cells with their cardinality, no afcars_record_icwa), afcars_record_gaps, the policy content stored once by hash, and the record contract covering the files a build generates

A7 literally: one (i) table of mixed cardinality, about 350 KB of policy text per submission; covers over every file, so oohc waits for P-E

R-D11

§1355.42(a)(1)(ii) (IV-E payments under another agency’s agreement) has no capture: the population evaluates the other two situations, coverage records it unsourced, the capture is #2147 ⁂

hold U5 until a capture exists

Review log

Round Vendor Resolved model Verdict

1

Anthropic — one fresh contextless reviewer (the page, the rules incl. coding-conventions / test-authoring, the four questions; 38 tree citations, 37 exact)

Claude Opus 5.5

no-ship — 2 blockers fixed (the generability 422 needs the verified documents; the ciphertext leg moves to U2 with the registry); 9 non-blocking findings folded (coverage keys, the element’s cardinality and a date-list cell, .gitignore, row ids, the lineage insert, tests, the 2028 series, a path)

2

maintainer-run (2026-10-01)

as reported

no-ship — 9 findings folded: every parent_set entry kept; a cell keeps a slot per atom ((b)(1)'s date and indicator); arrangements and plans keep their episode; a replayed claim answers before the mutable checks; the contract covers the files a build generates; the CI key step; the resolved (c) cells consumed; rotation an owned issue; U8 after U7

Edit this page · latest