Plan: State reference data loads from config bundles (config-git-source U5)

Status

Done (2026-11-15) — state reference data loads from each jurisdiction’s bundle/ config files; the compiled state crates are gone, craig-partners-ga keeps the Georgia adapters, and the first train car booted the stack on the new wiring green.

Closes: #2956 (epic &121). Parent: config-git-source, § State reference data (U5) and scope row U5.
Branch: feat/config-bundle. Tree: written against origin/main (2026-11-14).
Notes on: #2297, #2328, #1797, #2306, #1930 (see § Delivery).

A Design + Scope plan. It freezes when work starts; a deviation is a one-line erratum.

Context

Today a jurisdiction is a compiled crate. crates/craig-state-bundle/src/bundle.rs defines the StateBundle trait (16 methods); crates/craig-state-ga/src/lib.rs and crates/craig-state-tx-stub/src/lib.rs implement it with Rust literals (the 16 include contribute()). Ten consumers (craig-cases, -financial, -placement, -exchange, -reporting, -intake, -web, -security, craig-seed, craig-mock-server) link the crates behind state-ga / state-tx-stub features, and crates/craig-state-bundle/src/activation.rs picks one from CRAIGACTIVE_STATE_BUNDLES. Each service also reads CRAIG_<SVC>JURISDICTION. Changing a Georgia rate or holiday is a source change and a release.

U1 to U4 of the parent plan moved rulesets and policy to signed config repositories, read through crates/craig-config/src/snapshot.rs (ConfigSnapshot: layered resolve, highest layer wins, absent is Ok(None)). U5 does the same for the bundle data. Only code stays in source: the eleven Georgia partner adapter factories.

Three statements in the parent plan are stale and are corrected here, not there: no audit codecs exist any more; mock routes already live in crates/craig-state-ga-mock; and the outbound trigger matrix is data (ruling F4). Georgia tables in craig-reference and the SHINES backend in craig-intake are in no U5 text and stay.

Rulings this plan implements (maintainer, 2026-11-11 to 2026-11-14, on #2956)

Id Ruling

F1

No partner_types.toml means the product’s 14 types; a file only adds extras.

F2

theme.toml gives a product palette’s name or explicit token values, never both.

F3

Enum spellings are snake_case: calendar_days; in_custody / not_in_custody; { digits = N }.

F4

The outbound trigger matrix moves to bundle/outbound_triggers.toml; craig-exchange’s boot check that every row names a registered adapter stays.

V1

No rate-class file means the code default TODAYS_PAYMENT_TYPES; a file overrides it.

X2

A jurisdiction without an AFCARS crosswalk boots; AFCARS export refuses for it.

R1

ConfigBundle leaks the parsed bundle once at boot to satisfy the trait’s &'static types. The trait and its consumers do not change.

R2

The business clock reads a set-once process registry installed at boot from the loaded bundle.

R3

One CRAIG MR. The config repositories merge their bundle data first; the MR carries the pin bump.

R4

A retired variable still set in a deployment is ignored silently.

R5

The Texas palette moves to the Texas config repository as explicit values.

R6

The mock server serves every compiled partner mock and reads no config.

R7

The feature matrix shrinks to craig-exchange and craig-mock-server, with and without the Georgia partner crate.

R8

A new verb, cargo xtask config check-bundle <dir>, validates a bundle directory.

R9

craig-seed skips the AFCARS policy rows when the jurisdiction has no crosswalk, and says so.

Design

D1. ConfigBundle (new crate crates/craig-config-bundle)

Depends on craig-config, craig-state-bundle, craig-reference, serde, toml, thiserror; craig-state-bundle keeps no runtime toml.

  • ConfigBundle::check(&ConfigSnapshot) → Vec<BundleError> parses and validates every bundle/ file and returns every error it finds, not the first. ConfigBundle::load(&ConfigSnapshot) → Result<&'static ConfigBundle, BundleErrors> runs check, refuses on any error, and leaks the result once (R1). It implements StateBundle; name() and jurisdiction_code() both return the manifest’s jurisdiction. (Today Texas’s name() is "tx-stub"; the name was only the activation key, which goes.)

  • Schemas. Each file’s keys are the fields of the spec type it fills, in snake_case, as the Georgia and Texas drafts (Draft MR !3 in each config repository) already spell them, with the corrections of § Scope step 2. A file holding a list is an array of tables named for the file (, ); a map is one table ([federal_mapping]); settings.toml is top-level keys. The implementer writes the structs first and the testonia fixture from them; the fixture is then the worked example of every file.

  • Each file is its own #[serde(deny_unknown_fields)] struct. BundleError is a thiserror enum whose variants name the layer, file and key.

  • snapshot.list("bundle") is compared with the known file set: an unknown file name is an error, so a misspelt fmap_rate.toml is refused instead of reading as "no FMAP".

  • Validation is structural: parse, enum membership, duplicates, and cross-file references (the Medicaid identifier kind must be a declared identifier kind; a terminology manifest entry must name an existing .ftl). Semantic checks stay with their consumers (FMAP ordering in craig-cases, UAS windows in craig-financial).

  • The high-contrast palette merge now done in crates/craig-state-bundle/build.rs becomes one function both build.rs and the loader call.

D2. The bundle/ file map

An absent file means exactly today’s trait default.

File Trait item Absent means

settings.toml

business_timezone, subsidy_writes_enabled, medicaid_application_identifier_kind

None, false, None

adapters.toml

names resolved against the compiled catalog (D3)

no adapters

partner_types.toml

extras over the product taxonomy

the 14 product types (F1); a product token in the file is a duplicate error

federal_mapping.toml

federal_mapping

empty

rate_tables.toml

contribute().seed_data.rate_tables, order kept

empty

theme.toml

contribute().theme (F2)

the product default palette

terminology.toml + terminology/<lang>/*.ftl

contribute().terminology, order kept

no overlay

field_surfaces.toml

contribute().field_ownership (surface keys; rosters stay product)

none

compositions.toml

contribute().compositions

none

subsidy_policy.toml

subsidy_policy

None

rate_class_policy.toml

rate_class_policy

TODAYS_PAYMENT_TYPES (V1)

uas_codes.toml, fmap_rates.toml, legal_statuses.toml, identifier_kinds.toml, search_schemes.toml

the same-named methods

empty

holidays.toml

holiday_calendar

empty

outbound_triggers.toml

outbound_triggers (F4)

empty

D3. What stays code

  • crates/craig-state-ga is renamed crates/craig-partners-ga and exports only pub fn adapters() → Vec<(&'static str, ErasedAdapterFactory)>. crates/craig-state-ga-mock is renamed crates/craig-partners-ga-mock, content unchanged. crates/craig-state-tx-stub is deleted with crates/craig-state-bundle/theme/tx-stub.toml and tx_stub_palette() (R5).

  • craig-exchange keeps one feature, partners-ga (default on), and builds its adapter catalog from the compiled crates in services/craig-exchange/src/bundle_orchestrator.rs. A name in adapters.toml the catalog lacks refuses boot; a shines entry still refuses.

  • The other consumers lose the state-* features, the optional dependencies and their candidate_bundles() wrappers. activation.rs and the candidate_bundles! macro are deleted.

  • xtask/src/cmd/feature_matrix.rs (R7): FEATURE_MATRIX_CRATES becomes craig-exchange and craig-mock-server, and JURISDICTION_FEATURES becomes the one feature partners-ga, checked on and off. craig-mock-server gets the same partners-ga feature (default on) gating its craig-partners-ga-mock dependency, and serves every route of the mocks it compiled (R6). In PLUGIN_AXIS_CHECKS the two craig-web rows collapse to one, ("craig-web", "plugin-example,plugin-ssa-screening"); the craig-composition row is unchanged.

D4. Jurisdiction, settings and the clock

  • ConfigSnapshot::load(env) loses its jurisdiction argument and ConfigError::JurisdictionMismatch goes: the manifest is the only source. Every place that reads settings.jurisdiction reads snapshot.jurisdiction(). ServiceSettings.jurisdiction (crates/craig-common/src/settings.rs) is removed as an env key. No code reads CRAIGACTIVE_STATE_BUNDLES or CRAIG_<SVC>JURISDICTION; one still set is ignored (R4).

  • Readers outside ServiceSettings, all moved to the snapshot: IntakeSettings.jurisdiction (services/craig-intake/src/config.rs); the cases gate (services/craig-cases/src/gate_hooks.rs) and the scheme-rewrite tool (services/craig-cases/src/scheme_rewrite/mode.rs), which load the snapshot from CRAIG_CONFIG_SOURCE instead of the two variables; xtask/src/cmd/rewrite_scheme.rs, which selects Texas by passing the Texas source list; and the env lists in xtask/src/registry.rs.

  • Every bundle consumer loads a snapshot at boot, so each needs CRAIG_CONFIG_SOURCE, the config volume and the craig-config-fetch dependency in docker-compose.yml and docker-compose.cluster.yml (today only placement, composition, rules and seed have them). The three craig-intake-standalone* services get the same Georgia source list and volume as craig-intake; craig-intake-tx gets the Texas source list. The compose anchors *active_state_bundles and *jurisdiction are deleted with their uses.

  • The link-time timezone slice in crates/craig-common/src/clock.rs (declare_business_timezones!) is replaced by a set-once registry (OnceLock), installed at boot from the bundle before the router is built (R2). Installing a different zone for an installed jurisdiction is an error. BusinessClock::for_jurisdiction and try_for_jurisdiction keep their signatures, so their 196 call sites do not change. Under cfg(test) and for integration tests, craig-test-lib installs the Georgia and Texas zones.

D5. Tests' source of bundles

  • fixtures/config/testonia/bundle/: a complete fixture bundle, one file of every kind, with an explicit palette. Tests that must run with no fetched config use it.

  • craig_test_lib::config gains a helper returning the ConfigBundle of a named layer, cached one per layer per process (bounds the R1 leak). The roughly 59 call sites that pass Some("georgia") or Some("tx-stub") to a *_for boot function use it.

  • Georgia-specific tests in the old crate (FMAP citation tether, legal statuses against the DOE wire, trigger legs) move to craig-partners-ga or craig-config-bundle and read the locked Georgia layer. Fake bundles in craig-financial and craig-exchange tests are unchanged: the trait stays.

  • The contrast test (crates/craig-state-bundle/tests/data/contrast-pairs.toml) runs over the product palettes, the locked Texas layer’s explicit palette and the testonia fixture.

D6. cargo xtask config check-bundle <dir> (R8)

Builds a working-copy snapshot over the directory (ConfigEnv::working_copy), runs ConfigBundle::check, and prints every error with file and key; exit 1 on any. The config repositories' agents run it from this branch before they merge.

D7. Seed (R9)

tools/craig-seed/src/afcars_policy.rs stops hardcoding Georgia: it resolves <jurisdiction>-afcars-crosswalk.json (the existing naming rule, with the snapshot’s jurisdiction) from the snapshot; when the file is absent it writes no AFCARS policy rows and logs one line naming the jurisdiction.

Scope and order (one MR, R3)

  1. On feat/config-bundle: D1, D2, D5’s fixture and D6. Push the branch, unarmed.

  2. The Georgia and Texas config agents re-transcribe their Draft MR !3 against D2 from current CRAIG main (the drafts predate it): file names as D2, no name / jurisdiction keys, no product partner types (F1), Georgia adds outbound_triggers.toml (F4), Texas adds explicit palette values (R5). Texas adds no FMAP: its bundle equals what the stub compiles in, and #2328’s data is a later Texas-repository change with its own pin bump. Each runs check-bundle from the branch and merges.

  3. On the branch: bump config-sources.lock; add a golden test comparing ConfigBundle with GeorgiaBundle and TxStubBundle item by item; run it and record its output in the MR. The one declared difference is Texas’s name() ("texas" loaded, "tx-stub" compiled), asserted as exactly that pair.

  4. On the branch: D3, D4, D7; delete the compiled bundles and the golden; add the locked-layer tests of § Tests; compose, xtask plumbing, docs.

  5. Arm the MR. Main is untouched until it merges.

Out of scope: craig-reference Georgia tables; the SHINES backend; #2297’s third criterion; #1797 and #2306 (they follow this unit); a Texas devstack profile (U6); rewriting Georgia mentions in prose.

Risks

Risk Class Mitigation, and the test that pins it

A misnamed or missing file reads as "empty" where the compiled bundle had data.

silent

An unknown file under bundle/ refuses boot (an_unknown_bundle_file_refuses_the_load). The step-3 golden compares every item. After the deletion, the_locked_georgia_layer_carries_its_reference_data asserts each non-empty Georgia item by count and key values.

The golden passes because both sides are empty, or skips an item.

silent

The golden enumerates the trait’s items by name from one list a second test holds equal to the trait’s method set, and asserts Georgia’s non-empty counts before comparing.

The config repositories' pipelines pin an older CRAIG; a new bundle/ directory may fail a check there (unverified).

fail-closed

Their merge is blocked, not CRAIG’s main. The agent reports the failing job before changing anything; the fix is a CRAIG_VERSION bump in that repository or an exclusion there, decided then.

A retired variable is still read somewhere and silently changes behaviour.

silent

no_source_reads_a_retired_selection_variable: a test over the workspace sources and both compose files asserts neither name occurs outside docs and changelogs.

The golden exists only inside the branch (R3), so main never runs it.

silent

Its output is recorded in the MR; the locked-layer tests above stay and run in every car.

A config value drifts from a product enum or the partner wire.

fail-closed

Enum parse refuses an unknown token (an_unknown_enum_token_refuses_the_load, per file). The legal-status / DOE-wire bijection test moves to craig-partners-ga over the locked layer.

A jurisdiction boots with no holiday calendar or FMAP.

fail-closed

Consumers' existing typed refusals stay. a_bundle_without_fmap_refuses_an_eligible_determination and a_bundle_without_holidays_refuses_a_holiday_skipping_window run on a Texas-shaped fixture.

adapters.toml names an adapter the build lacks.

fail-closed

craig-exchange refuses at boot (an_adapter_no_compiled_crate_provides_refuses_boot). Other services do not validate adapter names; documented.

A trigger row names an unregistered adapter (F4).

fail-closed

The existing exchange boot check, now fed from config (a_trigger_naming_an_unregistered_adapter_refuses_boot).

The clock registry is not installed, so dates run on UTC.

silent

Boot installs before the router. the_business_zone_is_installed_before_the_router_serves asserts try_for_jurisdiction is Some after each service’s boot function; subsidy writes already refuse without a resolved zone.

Two installs race or disagree.

fail-closed

concurrent_installs_of_one_zone_agree_and_a_different_zone_is_refused (concurrency test).

A retired variable left in a deployment is ignored and the operator believes it applies (R4, accepted).

silent

Accepted by ruling. The release note names both variables as no longer read.

Tests need fetched config a fresh checkout lacks.

fail-closed

craig_test_lib::config::layer already panics naming cargo xtask config fetch; fixture-only tests use testonia.

The pin moves before a config repository carries a valid bundle.

fail-closed

The order in § Scope; check-bundle runs before each config merge, and the MR’s car loads both layers.

A service that never loaded config before now fails to boot without CRAIG_CONFIG_SOURCE.

fail-closed

The compose changes of D4; the car boots the full devstack. The release note states the new requirement.

Leaked bundles grow in a test process.

silent

The helper caches one per layer (loading_a_layer_twice_returns_the_same_bundle).

Tests

Category Tests Devstack

Contract (schema)

Per file: unknown key, unknown enum token, wrong type, duplicate; unknown file; missing .ftl; theme with both a name and values; unknown palette name; a product token in partner_types.toml; Medicaid kind not a declared identifier kind.

no

Contract (defaults)

an_empty_bundle_equals_the_trait_defaults, item by item, F1 and V1 included.

no

Golden (branch only)

Loaded Georgia and Texas equal the compiled bundles on every item.

no (needs the fetch)

Regression

Seed SQL byte-identity (tools/craig-seed/tests/sql_byte_identity.rs) unchanged; Georgia theme CSS byte-equal to today’s; the contrast pairs over the Texas palette; the locked-Georgia-layer value test.

no (needs the fetch)

Boot refusal

Schema error; unknown adapter; shines in adapters.toml; trigger naming an unregistered adapter.

no

X2

reporting_under_a_layer_without_a_crosswalk_boots_and_afcars_generate_refuses: craig-reporting under the Texas layer boots and AFCARS generate answers crosswalk-absent. the_seed_skips_afcars_policy_without_a_crosswalk (R9).

service-level; the first may need the devstack

Concurrency

The clock registry install test above.

no

Property

Round-trip and no-panic for the identifier-format and palette parsers (proptest).

no

check-bundle

Exit 0 on the testonia fixture; exit 1 naming file and key on a planted error.

no

Every new test gets a red proof. Devstack-gated tests are compiled locally and run by the car.

Delivery

  • Canonical page: docs/modules/ROOT/pages/shared-crates.adoc (the state crates' new shape, the file map).

  • Also updated for the retired settings and features: configuration-reference.adoc, deployment-guide.adoc, local-dev.adoc, devstack.adoc, quality-gates.adoc (feature matrix), testing-reference.adoc, multi-jurisdiction-extensibility.adoc, cli.adoc (config check-bundle).

  • ADR-072 amendment (a dated section): Tier 2’s home becomes config bundle data under bundle/ in the jurisdiction layer, boot-resolved, fail-closed, stamped by the layer SHA; partner adapters stay source, selected by adapters.toml; the set-once clock registry is recorded as accepted global state (R2).

  • Parent plan: one erratum line (the stale "codecs, mock routes, triggers").

  • CHANGELOG entry: the release-note fragment changelog.d/2956.changed.adoc (folded into CHANGELOG.adoc at the release), pre-1.0 BREAKING. Ops: CRAIG_CONFIG_SOURCE is required by every service; CRAIGACTIVE_STATE_BUNDLES and CRAIG_<SVC>JURISDICTION are no longer read; the state-ga and state-tx-stub features are gone.

  • Close: Closes #2956; after merge, one line with the merge SHA and the car’s evidence. Notes on #2297 (criteria 1 and 2 mooted, 3 not done), #2328 (not done here: the data is now a Texas-repository change, the cases test a source change), #1797 and #2306 (unblocked), #1930.

Notes

  • crates/craig-policy/src/bundle_ref.rs is a pure parser of bundle:<method>[<entry>] refs and needs no change; its tether is the FMAP citation test that D5 moves.

  • Departure from the triage note on #2956, which folded #2328’s Texas FMAP into this unit: it is left out so the Texas bundle equals the stub and the golden has one declared difference. For the maintainer to confirm.

Errata

  • Erratum (2026-11-14): craig-config-bundle also depends on serde_path_to_error (already a workspace dependency), so a parse error names its key.

  • Erratum (2026-11-14): the loader refuses four more structural faults than D1 lists: a theme with neither a palette name nor values; a catalog outside terminology/<lang>/ for its own language; a field surface the product has no roster for; a high-contrast override of a token its base mode lacks.

  • Erratum (2026-11-14): the § Notes line calling the #2328 omission a departure from the triage note is wrong. The note says to do #2328 after this unit, as a Texas-repository change plus a cases test, which is what this plan does.

  • Erratum (2026-11-15): D4 is wrong that craig-rules already has CRAIG_CONFIG_SOURCE; for craig-rules the variable’s presence was the config-managed switch. craig-rules now always loads a snapshot, and a new setting, CRAIG_RULES__RULE_SET_AUTHORITY (config, the default, or api), says who owns the rule sets. The devstack sets api. ADR-087 is amended with the docs of this unit.

  • Erratum (2026-11-15): the clock registry (R2) gives tests their zones through a test-only test-zones feature of craig-common that craig-test-lib enables, not through an install call in craig-test-lib.

  • Erratum (2026-11-15): the cluster rig (docker-compose.cluster.yml) gets no fetch service and no named volume, which that rig forbids: its two services bind-mount the fetched target/config read-only, and cargo xtask cluster-tests fetches the locked layers before it brings the rig up.

Review log

Round Vendor Resolved model Verdict

1

Anthropic

vertex-anthropic/claude-fable-5-2 (cold read)

FLAGS (2): a risk stated in prose; the golden contradicted name(), and an unpinned "never". Folded.

2

Google

vertex-gemini/gemini-4-carbon

FLAGS (2): #2328’s FMAP bundled in; undeferred scope questions, missing readers and matrix rows, multi-error check. Folded.

Approved by the maintainer on 2026-11-14, after both rounds were folded.

Edit this page · latest