Data Model: Reporting & Data Quality

Overview

The reporting service provides automated data quality monitoring and federal report generation. It consumes events from other CRAIG services (cases, placement, financial) to detect data quality issues, and generates AFCARS (six-month report periods) and NCANDS (annual) submissions for federal reporting to the Administration for Children and Families (ACF).

Data quality issues are created automatically when inbound events fail validation checks (missing required fields, invalid values). AFCARS and NCANDS submissions follow an approval workflow: draft → validated → reviewed → approved. NCANDS ends there; AFCARS goes on to ready_for_transmission (#2179). Neither program can be marked transmitted: both marking-only transmit routes are retired (#2180, #2130), AFCARS transmitted is the delivery program’s (#1967), and NCANDS has no delivery program yet. For NCANDS, generate finalizes to validated only when the file has reportable records and zero validation errors; a file with genuine defects (e.g. >4 maltreatment types) or no reportable records finalizes to validated_with_errors, a terminal state the workflow cannot advance (#782). The Child File carries only children whose report received a disposition in the FFY — still-pending reports are excluded as not-yet-reportable (ADR-040 capture-complete amendment), reported in the year they are disposed. For AFCARS, the generate finalizes inside its one transaction (#2162): validated only when the file has records and no standard is failed, else the terminal validated_with_errors; until P-D5 evaluates the consistency and recurrence steps, every AFCARS submission is validated_with_errors.

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), and schema_compat_floor (ADR-063). 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.

Tables

Table Purpose

data_quality_issues

Tracks data quality problems detected across all CRAIG services (missing fields, invalid values, cross-service inconsistencies)

afcars_submissions

One AFCARS submission per generate (id = the afcars_generate job id, #2143) for a report half (reporting_period a label such as 2026A, #2144) and data file, linked into the supersede chain (#2139), with its review/approval audit trail; the ready_for_transmission act stamps ready_by, ready_at and ready_export_generation (#2179); once ready_for_transmission its export columns are frozen: the finalizer’s pointer flip skips the row and the export route refuses (409 afcars-artifact-frozen), so ready_export_generation stays equal to export_generation

afcars_child_records

One immutable AFCARS oohc record per (submission, child): its (a), (b), (c) and (i) element cells (#2139)

afcars_record_parents

One immutable row per parent of a child’s record, in parent_set order: the (c)(5) parental-rights cells (#2139)

afcars_record_removals

One immutable row per removal episode of a child’s record: its (d), (g), (h) and (i) element cells (#2139), then tribe_order_in_force (#2273, plan afcars-2028-series D9 FORK-2 A): whether the Tribe’s adoptive order of preference was in force at the exit, read from the child’s ICWA window at the period end — yes (the order is yes, established on or before the exit date), no (the order is no, or established after it), unknown (a yes with no established date); NULL when the order is unanswered, ICWA does not apply at the period end or the episode has no exit, never no

afcars_record_living_arrangements

One immutable row per living arrangement, tied to its removal row: its (e) and (i) element cells (#2139), then tribe_order_in_force (#2273): whether the Tribe’s foster-care / pre-adoptive order of preference was in force on the arrangement’s (e)(1) date, read and valued as on the removal row

afcars_record_events

One immutable row per plan, periodic review, permanency hearing or caseworker visit: the (f) element cells (#2139)

afcars_submission_coverage

Per submission, how each oohc element and population situation was sourced (captured / derived / unsourced) (#2139)

afcars_record_gaps

Per submission, each blank record cell with the reason it could not be filled (no cell value stored) (#2139)

afcars_element_results

Per submission, one immutable row per oohc element of its view: the clean class, the applicable records and the records missing, invalid and tardy by worst class, and whether the element meets its standard (#2162)

afcars_validation_steps

Per submission, the two immutable A8 step rows (consistency, recurrence): evaluated and met; both unevaluated and failing until P-D5 (#2162)

afcars_observation_errors

Per submission, one immutable row per missing, invalid or tardy observation: child, source record, element and class, no cell value (#2162)

afcars_findings

Per submission, one immutable review-only finding (a runaway exit against the episode’s latest arrangement, sibling counts out of order, a dated plan outside every episode): child, source record and kind, no cell value; never changes the status (#2163)

afcars_policy_documents

The AFCARS dictionary and crosswalk documents a submission used, stored once by canonical content hash (#2139); immutable once written (#2174)

afcars_submission_policy

Per submission, the dictionary and crosswalk rule-set id, revision and content hash it was generated under (#2139); immutable once written (#2174)

afcars_export_readiness

Per AFCARS submission, one append-only row per winning export flip, written in the flip’s transaction: the export generation, the winning attempt (no foreign key: the prune deletes attempt rows and an id may recur), the stored object’s and the delivered file’s SHA-256 and the retained dictionary and crosswalk identities (rule-set id, revision, content hash) (#2178); the ready_for_transmission act re-verifies the current generation’s row (#2179)

ncands_submissions

NCANDS annual submission records with review/approval audit trail

ncands_child_rows

Per-(report, child) materialized NCANDS Child File rows for a submission (the federal #1–34 codes); written when a submission is generated, read by the export emitter (FK → ncands_submissions ON DELETE CASCADE). report_disposition_code (#11 RptDisp) is a REPORT fact (#648): derived once per referral as the MIN codebook value over every recorded allegation + investigation disposition of the referral and stamped on each of its child rows (a substantiated child and an unsubstantiated sibling both carry 1; the precedence is a transparent CRAIG derivation over the federal list order, recorded ⁂ on #1073); mal*_lev (#27/29/31/33) stay per child. A NULL code means no determination has been recorded for that slot — since #648 every recorded disposition has a code. Alternative-response compatibility: a referral mixing codes 3/4 with any other outcome flags EVERY child row row_valid = false, validation_notes naming alternative_response_mixed_outcomes (beside the existing >4-maltreatment-types overflow reason)

data_quality_metrics

Point-in-time metrics for dashboards (field completeness, AFCARS/NCANDS readiness scores)

upload_attempts

ADR-062 §U upload-attempt tombstones (SU2 #1248): one immutable row per client upload/export operation, id = the client-held request id; generation-fenced CAS state machine + replay decision table live in craig-store::attempts (shared crates); kinds here: afcars_export / ncands_export (replace kinds — the submissions carry export_sha256 + current_export_attempt_id + export_generation); an afcars_export attempt stores the file sealed under the reporting column key (keyed deployments) and its intent carries file_sha256, the delivered file’s digest (P-D4 D2, #2177); a winning afcars_export flip also writes its afcars_export_readiness row (#2178). 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.

ER Diagram

data_quality_issuesuuididPKtextsource_serviceuuidsource_record_idtextissue_typetextfield_nametextdescriptiontextseveritybooleanresolvedtextresolved_bynullabletimestamptzresolved_atnullabletimestamptzdetected_atafcars_submissionsuuididPKtextreporting_periodtextfileoohc | assist, default oohc (#2139)uuidsupersedes_idnullable, UNIQUE, FK self ON DELETE RESTRICT (#2139)textstatusintegerrecord_countintegervalidation_errorsvarcharexport_object_keynullable, craig-store pathtimestamptzexport_generated_atnullablecharexport_sha256nullable, digest of the DELIVERED (decrypted) file (SU2; P-D4 D2)uuidcurrent_export_attempt_idnullable, §U replace pointer (SU2)bigintexport_generation§U source-drift fence (SU2)textreviewed_bynullabletimestamptzreviewed_atnullabletextapproved_bynullabletimestamptzapproved_atnullabletimestamptztransmitted_atnullable; no writer since the transmit route retired (#2180), delivery is #1967textready_bynullable, the ready act's worker (#2179)timestamptzready_atnullablebigintready_export_generationnullable, the export generation certified (#2179)timestamptzvalidated_atnullable, stamped by the in-transaction finalize (#2162)timestamptzcreated_atafcars_child_recordsuuididPKthe AAD row iduuidsubmission_idFKuuidchild_idlogical: craig-cases person; UNIQUE with submission_idjsonbcellsone column per element token; R11 cells TEXT envelopes (#2138)afcars_record_parentsuuididPKuuidsubmission_idFKuuidchild_iduuidparent_person_idlogical: the parent_set entryintegerordinalparent_set order, uncappedjsonbcells(c)(5) element columnsafcars_record_removalsuuididPKuuidsubmission_idFKuuidchild_iduuidepisode_idlogical: craig-placement episode; UNIQUE with submission_idjsonbcells(d), (g), (h), (i) element columnstexttribe_order_in_forceyes | no | unknown; NULL = unanswered, ICWA not applying at period end, or no exit (#2273)afcars_record_living_arrangementsuuididPKuuidsubmission_idFKuuidchild_iduuidarrangement_idlogical: craig-placement arrangementuuidremoval_record_idFKits episode's removal rowjsonbcells(e), (i) element columnstexttribe_order_in_forceyes | no | unknown; NULL = unanswered or ICWA not applying at period end (#2273)afcars_record_eventsuuididPKuuidsubmission_idFKuuidchild_idtextkindplan | periodic_review | permanency_hearing | visituuidsource_idlogical: the plan, review or contactuuidremoval_record_idFKnullable: a plan's episodejsonbcells(f) element columnsafcars_submission_coverageuuidsubmission_idPK,FKtextkeyPKan oohc ElementKey or population.<situation>textsourcingcaptured | derived | unsourcedafcars_record_gapsuuididPKuuidsubmission_idFKuuidchild_iduuidsource_idnullabletextelement_keytextreasonclosed set, no cell valueafcars_element_resultsuuidsubmission_idPK,FKtextelement_keyPKan oohc ElementKeytextclean_classhundred_percent | ten_percentintapplicableintmissingintinvalidinttardyboolmeets_standardafcars_validation_stepsuuidsubmission_idPK,FKtextstepPKconsistency | recurrenceboolevaluatedboolmeets_standardafcars_observation_errorsuuididPKuuidsubmission_idFKuuidchild_iduuidsource_idnullabletextelement_keytextclassmissing | invalid | tardy, no cell valueafcars_findingsuuididPKuuidsubmission_idFKuuidchild_iduuidsource_idnullabletextkindclosed set, no cell valueafcars_policy_documentscharcontent_sha256PKcanonical content hashjsonbcontentafcars_submission_policyuuidsubmission_idPKuuiddictionary_rule_set_idbigintdictionary_revisionchardictionary_content_sha256FKuuidcrosswalk_rule_set_idbigintcrosswalk_revisioncharcrosswalk_content_sha256FKafcars_export_readinessuuididPKuuidsubmission_idFKbigintexport_generationUNIQUE with submission_iduuidattempt_idno FK (prune, reuse)charobject_sha256stored objectcharfile_sha256delivered file = export_sha256uuiddictionary_idbigintdictionary_revisionchardictionary_sha256uuidcrosswalk_idbigintcrosswalk_revisioncharcrosswalk_sha256timestamptzrecorded_atncands_submissionsuuididPKintegerreporting_yeartextstatusintegerrecord_countintegervalidation_errorsintegerchild_fatalitiesvarcharexport_object_keynullable, craig-store pathtimestamptzexport_generated_atnullablecharexport_sha256nullable, ADR-062 §U artifact digest (SU2)uuidcurrent_export_attempt_idnullable, §U replace pointer (SU2)bigintexport_generation§U source-drift fence (SU2)textreviewed_bynullabletimestamptzreviewed_atnullabletextapproved_bynullabletimestamptzapproved_atnullabletimestamptztransmitted_atnullable; no writer since the transmit route retired (#2130)timestamptzcreated_attimestamptzupdated_atncands_child_rowsuuididPKuuidsubmission_idFKuuidsource_report_idnullable, provenance (not emitted)uuidsource_victim_person_idprovenance (not emitted)integersubmission_year#1textstate#2 FIPS state codetextreport_id_fieldnullable, #3 surrogatetextchild_id_fieldnullable, #4 surrogatetextstate_county_fipsnullable, #5datereport_datenullable, #6dateinvestigation_startnullable, #8smallintreport_source_codenullable, #10smallintreport_disposition_codenullable, #11 — REFERRAL-wide (#648)datedisposition_datenullable, #12smallintchild_age_codenullable, #14smallintchild_sex_codenullable, #15smallintrace_aiannullable, #16smallintrace_asiannullable, #17smallintrace_blacknullable, #18smallintrace_nhopinullable, #19smallintrace_whitenullable, #20smallintrace_unable_determinednullable, #21smallintchild_ethnicity_codenullable, #22smallintmal1_typenullable, #26smallintmal1_levnullable, #27smallintmal2_typenullable, #28smallintmal2_levnullable, #29smallintmal3_typenullable, #30smallintmal3_levnullable, #31smallintmal4_typenullable, #32smallintmal4_levnullable, #33smallintmaltreatment_deathnullable, #34booleanchild_fatalitybooleanrow_validtextvalidation_notesnullabletimestamptzcreated_atdata_quality_metricsuuididPKtextmetric_typenumericmetric_valuejsonbdetailsnullabletimestamptzmeasured_atupload_attemptsuuididPKtexttarget_kindafcars_export | ncands_exportuuidtarget_idthe export row, polymorphic by target_kindtextstatuspending | stored | promoted | superseded | failedbigintattempt_generationchardeclared_sha256bigintsize_bytestextfile_nametextcontent_typejsonbintenttextobject_keyjsonbabandoned_object_keystextfailure_reasonnullable; set exactly when faileduuidresult_idnullableuuidcreated_bynullable; the worker subject (#2740)textcreated_by_servicenullable; service:NAME; chk: exactly one of the pair settimestamptzcreated_attimestamptzupdated_atsupersedes (one head per reporting_period and file, #2139)records (one per in-population child)parentsremovalsarrangements of the episodeplans of the episodecoveragegapselement results (one per oohc coverage key)A8 steps (two)observation errorsfindings (review-only)retained policy (#2145 export reads it)by hashreadiness (one per winning export flip, #2178)materializes (one row per (report, child))

Indexes

Every index a craig-reporting migration creates on a table in § Tables: each CREATE INDEX and each named UNIQUE constraint. Primary keys and the platform tables named in § Overview are not listed.

Table Index Columns

data_quality_issues

idx_dq_issues_source

source_service, source_record_id

data_quality_issues

idx_dq_issues_type

issue_type

data_quality_issues

idx_dq_issues_unresolved

partial resolved WHERE resolved = false

afcars_submissions

idx_afcars_period

reporting_period

afcars_submissions

afcars_submissions_supersedes_id_key (UNIQUE)

supersedes_id: at most one successor per submission (#2139)

afcars_child_records

afcars_child_records_child_key (UNIQUE)

submission_id, child_id

afcars_record_parents

afcars_record_parents_ordinal_key (UNIQUE)

submission_id, child_id, ordinal

afcars_record_removals

afcars_record_removals_episode_key (UNIQUE)

submission_id, episode_id

afcars_record_removals

afcars_record_removals_submission_row_key (UNIQUE)

submission_id, id: the composite FK target of afcars_record_living_arrangements and afcars_record_events

afcars_record_living_arrangements

afcars_record_living_arrangements_arrangement_key (UNIQUE)

submission_id, arrangement_id

afcars_record_events

afcars_record_events_source_key (UNIQUE)

submission_id, child_id, kind, source_id

afcars_record_gaps

idx_afcars_record_gaps_submission

submission_id, child_id

afcars_observation_errors

idx_afcars_observation_errors_submission

submission_id, id (D7’s keyset pages)

afcars_findings

idx_afcars_findings_submission

submission_id, id (D7’s keyset pages)

afcars_export_readiness

afcars_export_readiness_submission_generation_key (UNIQUE)

submission_id, export_generation

ncands_submissions

idx_ncands_year

reporting_year

ncands_child_rows

idx_ncands_child_rows_submission

submission_id

data_quality_metrics

idx_dq_metrics_type

metric_type, measured_at

upload_attempts

upload_attempts_overdue_idx

partial updated_at WHERE status IN ('pending', 'stored'): the reconciler’s overdue pick

upload_attempts

upload_attempts_abandoned_idx

partial updated_at WHERE abandoned_object_keys <> '[]'::jsonb: the swept-keys pick

upload_attempts

upload_attempts_terminal_idx

partial updated_at WHERE status IN ('promoted', 'superseded', 'failed'): the terminal prune

Cross-Service References

The reporting service does not have direct foreign keys to other databases. Instead, it stores source_record_id (UUID) references that correspond to records in other services:

  • source_service = "craig-cases" → cases.id in craig_cases database

  • source_service = "craig-placement" → placements.id in craig_placement database

  • source_service = "craig-financial" → payments.id in craig_financial database

For NCANDS generation, the service makes HTTP calls to collect data from upstream services using the caller’s JWT token. AFCARS generation is the afcars_generate background job (#2143; enqueued by POST /v1/reporting/afcars/generate, 202, #2144). Under craig-reporting’s service token it reads craig-placement’s afcars-export, craig-financial’s afcars-facts and craig-cases' persons/afcars-export over the half’s resolved window. It then writes the submission (id = the job id), its records, coverage, gaps, retained policy and the reporting key’s lineage anchor, then validates the rows as inserted, writes the element results, steps and observation errors, finalizes the submission and writes its review-only findings, all in one transaction. An export renders under that retained policy, never the live surface (#2145). The submission-to-producer references (child_id, episode_id, arrangement_id, parent_person_id, source_id) are logical, never foreign keys.

Edit this page · latest