ADR-071: Two-Corpus Scenario Inventory with First-Class Relational Oracles
Status
Accepted (2026-08-31). Implements #665 (epic &56 Stream B) per the #664 spike taxonomy and the policy-journey plan. B2–B5 (#666–#669) consume this schema; #670 (generative seeding) is deferred with only the precondition rows' forward-compat shape shipped.
Context
CRAIG had the substrate (deterministic seed, entity builders, cross-service event assertions, ~35 smoke specs, typed-API workflow tests) but no narrative layer: no answer to "are the important journeys tested?", no coverage gate, and silently regressing journey coverage. The #664 spike catalogued 22 scenarios from the ACTUAL transition tables, each with relational oracles and their current enforcement class, and decided the id convention and schema shape. Prior art is Canopy ADR-032/033 — ported, not consumed.
Decision
Two corpora, one schema
compliance/scenario-inventory/{stage}.toml is the core corpus: bundle-independent
state-machine + relational truths (transition tables, DB/store invariants, event lockstep —
true for ANY StateBundle). rulesets/<jurisdiction>/scenarios/{stage}.toml are the
jurisdiction packs (StateBundle-policy-dependent behavior: program knobs, office matrices,
screening vocabulary, money policy). Canopy’s hardest-won lesson — never use a real
jurisdiction as the engine corpus — is honored in STRUCTURE now and in EXECUTION later:
CRAIG has exactly one deployable bundle, so core rows run against the GA devstack,
jurisdiction-parameterized, until a second StateBundle exists (no synthetic test-bundle
pair: a full StateBundle is a product surface, not a test fixture). The GA-ism-leak risk is
mitigated by the corpus-split discipline at authoring/review time and revisited at
bundle #2. Both corpus families are MANDATORY: the audit hard-errors when
compliance/scenario-inventory/ is absent, when no jurisdiction pack exists, or when any
corpus parses to zero rows — a deleted corpus must never green the gate. Since #1618 the
pack set is REGISTRY-PINNED (rulesets/scenario-packs.toml): registered↔discovered
drift in either direction hard-errors (with multiple packs, one could otherwise vanish
silently), and duplicate invariant-catalog stems across service buckets are findings
(the oracle join and the runtime gate key on the bare stem).
Id convention
{corpus}.{stage}.{kebab-slug}, globally unique across ALL corpora. corpus ∈ {core,
<jurisdiction-slug>}; stage is a closed 13-token vocabulary (intake, screening,
investigation, case, plan, placement, financial, subsidy, claiming, permanency, reporting,
identity, exchange). Stage replaces Canopy’s program segment because CRAIG is a
single-program lifecycle system — the discriminating axis is the lifecycle stage. Rows are
filed per-stage; a row whose stage segment disagrees with its file stem, or whose corpus
segment disagrees with its directory, is a finding.
First-class oracles + the bidirectional enforcement join
Every row carries rows (key, relation, enforcement) — the CRAIG
addition over Canopy, and the reason the whole layer exists: making enforcement a first-
class fact lets the audit derive the #668 priority signal mechanically (journey-critical
= every oracle ∈ {store-only, none, report-only-invariant} — journey coverage is the ONLY
enforcement). For the invariant classes the SQL invariant catalog IS the registry, and the
join is BIDIRECTIONAL: an oracle declaring blocking-invariant/report-only-invariant
must name a real catalog stem with matching blocking-ness (a promotion surfaces as a
mismatch on the next run), AND an oracle whose key matches a catalog stem must declare an
invariant class — so enforcement can be neither fabricated nor understated (the
one-directional version died in plan review as a false-success hole). The audit also
asserts filename-stem == header-name catalog-wide, because the real invariant gate keys
blocking-ness off the header while this join uses stems. db/store-only/reconcile/
none are honest declarations the machine cannot verify — said so in the report.
Derived coverage, path-derived served levels
Rows declare level (unit < flow < journey — required test altitude; tier is
implementation priority, a separate axis). Status is DERIVED: no bindings → Uncovered; all
bindings dangling → Uncovered + findings; best-resolving binding’s served level ≥ level →
Covered; else Partial. Served levels are PATH-derived, never declared (self-grading is the
gameable alternative): e2e-spec serves Journey iff the file is journey-.spec.ts, else
Flow; integration-test serves Flow iff the file lives under
crates/craig-test-lib/tests/ (the cross-service harness home), else Unit;
ruleset-fixture serves Unit. Recorded residues (the gate defends against drift and honest
mistakes, not adversarial authors — corpus edits are reviewed code): renaming a spec
journey- mints Journey service, and a trivial test under the harness dir serves Flow.
Declaration-anchored resolution
Substring contains resolution (the Canopy shape) is satisfiable by a comment — so
resolution anchors on declarations: e2e-spec needs a test.describe( (incl.
.serial/.parallel) whose first string argument equals the bound title, with
.skip/.fixme chains REJECTED; integration-test (path::fn_name) needs fn <name>(
carrying [test]/[tokio::test] in its attribute block. [ignore] deliberately does
NOT dangle: in this repo [ignore = "requires devstack"] is the devstack GATE and the
battery — the sole functional-correctness gate — runs --run-ignored=all, so ignored
tests execute on every pre-push (treating them as parked would falsely dangle every
cross-service workflow binding). ruleset-fixture must exist, parse as JSON, and — when a
JDM document — carry non-empty nodes (the Canopy SHELL-fixture rule: a parseable-but-
empty fixture would launder a gap into covered). Anchors are matched against a
comment/string-MASKED view of the source (#1615): line/block comments (nesting-aware for
Rust), string/raw-string/char literals (Rust) and string/template literals (TS) are
blanked before anchor search — a declaration-shaped comment or string literal neither
resolves a binding nor steals position() from the real declaration. Recorded residue:
TS regex literals and template-interpolation code stay out of scope (a '/" inside a
regex over-masks at most to end-of-line, a backtick inside one over-masks to the next
backtick, and a nested template inside ${…} leaks its text unmasked — byte/line
geometry always holds; only the mask/unmask classification wobbles on those shapes).
Journey honesty
A Journey-serving binding must carry asserts naming ≥1 of the row’s oracle keys (and any
named assert must be real) — the #664 "a journey binding must name which oracles it
asserts" rule, statically checkable because serving is path-derived.
Exit semantics and the blocking surface
Canopy doctrine verbatim: uncovered scenarios never fail; lies in the inventory always
do. cargo xtask scenarios audit exits 1 on any finding; uncovered rows are the counted
burn-down. The validate wiring is an ADVISORY report step (per the 665 contract) — but
the committed corpus is ALSO audited by a battery [test] in xtask::cmd::scenarios, so
an inventory lie fails every pre-push from day one. Since #669 (B5) the validate step is
BLOCKING and the ratchet is the per-ID coverage ledger — see § Amendment — #669 below
(the row-count ratchet first sketched here was dropped: it could not tell an honest
demotion from a deleted row).
Amendment — #669 (B5): the per-ID coverage ledger
The promotion mechanism is a committed per-ID ledger, compliance/scenario-coverage.lock,
not a row-count ratchet. One entry per row records { id, level, status
(derived, pre-bucket), bucket, oracles = sorted key:enforcement, oracle_fingerprint };
[corpus.<name>] covered_floor is a per-corpus monotone floor over the DENOMINATOR; a
{ id, reason, replaced_by? } is the only way an id leaves (human-authored;
tooling never writes one). Every backward move is a finding: an id vanished without a
tombstone, a tombstone whose id came back, a replaced_by naming no row, a lowered level, a
shrunken oracle set (a key gone, or one demoted into a weak class), a regressed status, a
broken floor, and an ABSENT ledger (deleting the lock must never switch the ratchet off).
cargo xtask scenarios audit --bless records forward moves only (refused on any standing
finding or regression), writes atomically, and the lock is CODEOWNERS-owned — a bless is a
reviewed diff. Statuses tightened with it: oracle keys unique per row and ≥1 on t1/t2 rows;
asserts required on EVERY binding (⊆ the row’s oracles); Covered = altitude AND the union
of the RESOLVING bindings' asserts covering all oracle keys; journey_critical is ANY-weak
with the weak count reported (the all-weak subset stays a second tag). Buckets: knob-capped
rows (no registry evidence) and blocked rows (blocked_by non-empty) keep their derived
status but sit outside the denominator, reported separately. One rule the B4 sweep made
necessary: a journey binding may list a catalog stem the post-journey sweep runs ONLY if
the spec records the selector’s entity kind (ledger.track('<kind>') — the sweep is that
oracle’s enforcement, so the footprint is the evidence. The validate step is BLOCKING from
this amendment on: an unreadable corpus, an inventory lie, or a ledger regression fails
pre-push and CI.
Entity registry
slice arrow-paths (entity(detail) → …, paren-aware split so detail may narrate
transitions) draw entities from a closed registry: person, report, screening_decision,
referral, investigation, case, case_household, case_assignment, case_plan, contact,
court_order, placement, foster_home, foster_home_license, kinship_option, payment,
payment_adjustment, claim, ive_determination, subsidy_agreement, subsidy_review,
subsidy_import_record, afcars_submission — and, since the taxonomy-v2 reader pass
(#1609, 2026-09-02):
icpc_request, icpc_home_study, icpc_attachment, exchange_transaction, send_job,
inbox_envelope, screening_run, screening_member, screening_job, foster_home_training.
Extending it is a deliberate schema change.
Corpus v1 excluded three machines the spike had not catalogued (exchange inbound, the
ICPC lifecycle, foster-home training-expiry). #1609 read them from code and found: there
is no partner-inbound machine — "inbound" is the fleet event_inbox envelope plus the
two exchange consumers (assignment denorm, SSA cohort invalidation) and the SSA
run/member/job graph; the ICPC request machine is a handler matrix over an unconstrained
column whose child entities (home study, attachments) never advance it; and there is no
training-expiry machine at all (expires_at has no reader — decision pending on
#1639). The
exchange stage rows and the two placement rows record exactly that.
Consequences
-
"Are the important journeys tested?" is now a mechanical report with an honest opening answer (1 covered / 4 partial / 17 uncovered at landing) and a derived priority list (7 journey-critical rows) for #668.
-
Coverage can only improve visibly: bindings that rot become findings, not silent passes; enforcement promotions surface on the next audit run.
-
The precondition rows ship shape-checked-only (relation/subject/param/count; the §8 no-literal rule enforced syntactically) so #670 inherits a populated schema, not a migration.
-
Cost accepted: the inventory duplicates knowledge that lives in tests and ADRs; the duplication is the index that makes gaps enumerable.
Amendment — #1621 (2026-08-31): the synthetic fixture jurisdiction
rulesets/testonia/ is a SYNTHETIC POLICY FIXTURE (not a StateBundle — that stays
deferred to bundle #2, #1608): 1–2 minimal JDMs with round-number values that can never
coincide with a real jurisdiction’s, its own citations manifest (all manual authority)
with the rules[0].i_age cell tether as the GA-leak tripwire, a citation-exceptions
ledger in the planned A3 shape, and a two-row scenario pack (one bound, one honestly
Uncovered). The FIXTURE-JURISDICTION marker file is the generic seed-exclusion
contract: devstack seed.sh skips marked dirs in both its load and receipt loops, and
fixture jurisdictions stay ADVISORY for the #661 audit forever. This satisfies the B5
(#669) precondition: GA-isms leaking into core corpus rows or citation universes are
now detectable mechanically (crates/craig-policy/tests/testonia_fixture.rs pins both
leak directions), not only by review.
Amendment — #2999 (2026-11-08): the configuration layers left CRAIG’s source
ADR-087 U4 (#2955) moved the configuration layers out of CRAIG’s source. A rulesets/<j>/<file> path above now names
<file> in layer <j>: the federal, Georgia and Texas layers are the craig-config-{federal,georgia,texas}
repositories, pinned in config-sources.lock and fetched to target/config/layers/<j>/ by cargo xtask config
fetch, and the synthetic testonia layer is fixtures/config/testonia/. The rulesets/scenario-packs.toml registry
is retired: a pack is active because its layer carries it. The decision above is unchanged.