Test Coverage Scorecard

This is the single living scorecard for CRAIG’s risk coverage — the matrix of "for each critical workflow, which adversarial axes have we tested?" Distinct from line coverage (which cargo-tarpaulin and cargo-llvm-cov produce); risk coverage answers "would a regression in this workflow be caught by the existing test suite?"

Plan: test-framework-hardening.adoc §DB.2.

The 6 axes

Every workflow row tracks coverage across the canonical Test Categories taxonomy from Testing Reference (CRAIG):

Axis What it asserts

Happy

Documented success path returns 2xx + the expected envelope

Sad

Documented failure path returns the documented 4xx (e.g. 404 for unknown id, 422 for invalid body, 409 for state conflict)

Evil

Adversarial input — Unicode, RTLO, NUL injection, oversized strings, depth bombs — is rejected cleanly

Concurrency

Concurrent same-key behavior matches the documented invariant (one winner; no double-execution; no lost write)

Replay

Crash-and-restart / message redelivery semantics produce the documented post-recovery state

Fault

Dependency error handling — DB down, broker down, object-store error, upstream 5xx, malformed JSON

Legend: ✅ covered, ⏳ planned (issue filed), ❌ gap (no plan).

Top-20 workflows

Workflow Happy Sad Evil Concurrency Replay Fault

Convert-class POST claims (cross-cutting; crates/craig-api/src/request_claims.rs — ADR-062 §B replaced the deleted idempotency.rs middleware, epic &77)

✅

✅

✅

✅

✅

✅

Outbox publish (cross-cutting; craig_mq::stage_event / stage_json_event, drained by OutboxWorker)

✅

✅

✅

✅

✅

✅

Inbox handler dedup (cross-cutting; crates/craig-mq::handle_idempotently — the ADR-062 §A single-transaction attempt machine, epic &77)

✅

✅

✅

✅

✅

✅

Attachment upload (4 sites — cases contacts, cases reports, exchange ICPC, placement homes; ADR-062 §U generation-fenced attempts, epic &77)

✅

✅

✅

✅

✅

✅

Exchange send (services/craig-exchange/src/api/transactions.rs)

✅

✅

✅

✅

✅

✅

Placement transition guard (services/craig-placement/src/transitions.rs)

✅

✅

✅

✅

✅

✅

BFF page render under upstream failure (craig_bff::transport::Transport; Concurrency = the plugin render route’s same-key single flight, services/craig-web/src/plugins.rs: one upstream fetch shared by a burst whether it fails or succeeds, and by the requests joined to an aborted holder; Replay = an in-process craig-web rebuild from the same session secret reads the pre-restart flash exactly once)

✅

✅

✅

✅

✅

✅

Person match (services/craig-cases/src/api/persons.rs::search_persons)

✅

✅

✅

n/a

n/a

✅

Rules evaluation (services/craig-rules/src/api/evaluations.rs::evaluate; Replay = the rules.cache_invalidated consumer: one envelope delivered twice, and a restart whose pending invalidation the boot reload recovers)

✅

✅

✅

✅

✅

✅

Public intake submit (services/craig-intake/src/api/public.rs::submit_report; Replay: the cases profile’s answer lost after the upstream commit, router rebuilt, the retry answers the committed report; the SHINES profile’s crash after the write, the retry answers the stored receipt)

✅

✅

✅

✅

✅

✅

Partner intake submit (services/craig-intake/src/api/partner.rs; Replay: the answer lost after the upstream commit, router rebuilt, the re-signed retry answers the committed report and the old jti is refused)

✅

✅

✅

✅

✅

✅

JWT validation across 8 services (crates/craig-auth::JwksProvider::validate_token)

✅

✅

✅

✅

n/a

✅

Cross-service FK reconciliation (craig-manage reconcile)

✅

✅

✅

n/a

n/a

✅

Health endpoints — /livez vs /readyz differentiation + worker/MQ gates (crates/craig-api unit readiness + tests/fault/, &76 U2/U3; Concurrency = the U1 supervisor unit tests' deterministic order-serialization + duplicate-rejection pins, which feed the gate)

✅

✅

n/a

✅

✅

✅

Invariant sweep — outbox/inbox transport drains (craig-manage invariants; the idempotency-table invariant was deleted with its table in epic &77 B2/BF — the request_claims beyond-grace watchdog replaced it)

✅

✅

n/a

n/a

n/a

✅

State-machine matrix (crates/craig-test-lib::state_machine_matrix; only services/craig-financial/tests/transitions_matrix.rs calls it today)

✅

✅

n/a

n/a

n/a

n/a

Soft-delete activation flip (every soft-delete table — ~20 tables across services)

✅

✅

✅

✅

✅

✅

Audit log emission per state mutation (services/craig-security/src/lib.rs::handle_inbound_event, the audit subscriber’s handler; a hostile envelope field is never dropped, #2864: a NUL is escaped everywhere storage would fail (audit_log, details, the inbox bookkeeping, dead_letter_audit), format characters are escaped on the displayed identifier columns, indexed identifiers are capped at 1024 bytes, and a vocabulary lift falls back to authz_decision or a NULL UUID)

✅

✅

✅

✅

✅

✅

Filename + Content-Disposition sanitization (crates/craig-store::StoredFileName)

✅

✅

✅

n/a

n/a

n/a

Typed-DTO contract round-trip (crates/craig-cases-contracts)

✅

✅

n/a

n/a

n/a

n/a

Reading this scorecard

  • Cell at ✅ means there is at least one test that exercises this workflow on this axis. Test counts per cell are NOT tracked here — the runtime coverage matrix (test-results/http/coverage-matrix.json, written by every full battery; Coverage Matrix) lists each route’s observed axes and observing tests.

  • Cell at ⏳ means a tracking issue exists and the plan has a slot for the test. Click through to the issue tracker for the specific blocker.

  • Cell at ❌ means no test, no plan. These are the cells that should drive the next plan-authoring round.

  • n/a means the axis is structurally inapplicable (e.g. a typed-DTO crate has no concurrency axis because it’s a pure-Rust serde test).

When to update

  • Per-MR: when a test lands that ticks a previously-empty cell, flip the cell from ⏳/❌ to ✅ in the same MR. This is part of the delivery checklist (the delivery-protocol standard).

  • Plan-authoring: when a new plan adds tests that fill cells, update the scorecard before the plan ships so reviewers see the projected post-plan state.

  • Quarterly: a maintainer rebuilds the scorecard from scratch by walking the 20 workflows and re-evaluating each cell. This catches drift where ✅ cells decay into stale tests that no longer exercise the axis they claim.

Drift detection

The static coverage matrix and its auto-derived scorecard are gone (#2703). Compare the hand-curated rows above against the runtime coverage matrix’s per-route axes (test-results/http/coverage-matrix.json, written by every full battery; Coverage Matrix): a ✅ cell whose workflow’s routes show no observed credit on that axis, or a ❌ cell whose routes do, is a signal that the curated scorecard has drifted.

The runtime matrix is a signal, not a replacement: it shows what the tests sent and what came back, not coverage quality. A workflow can have 5 tests on the Happy axis that all hit the same code path while leaving important branches untested. That’s exactly the kind of gap the curated scorecard surfaces.

Line coverage (Plan K F-044)

The risk-coverage matrix above is the primary scorecard. Line coverage is a complementary signal — useful for spotting whole files / branches that no test reaches, useless for arguing that a workflow is "covered".

cargo xtask coverage wraps cargo llvm-cov nextest --workspace --summary-only for local measurement. #1208 moved the runner onto nextest: plain cargo test (same-process test threads) races the process-global-state tests that are safe only under nextest’s process-per-test model (craig-common’s Prometheus-instrument OnceLock pins were the observed casualty), and nextest is the mandated runner everywhere else.

Invocation Effect

cargo xtask coverage

Measure + print summary, then enforce the baseline floor (#1208): FAILS when workspace line coverage drops more than 0.5 points below the ledger xtask/baselines/coverage.toml — the test-authoring floor. Each run also leaves its measurement for a later bless.

cargo xtask baselines bless --only coverage

Rewrite the ledger from the last run’s measurement (it measures nothing itself). Raises the record freely; lowers it only with --allow-lower "<why>", written into the file. Commit it; the diff review is the ratchet’s consent step.

cargo xtask coverage --threshold N

Additional ABSOLUTE floor. Adds --fail-under-lines N to the underlying llvm-cov invocation; bails when workspace line coverage drops below N, independent of the baseline delta.

Local prerequisites: cargo install cargo-llvm-cov --locked (or cargo binstall cargo-llvm-cov) + cargo-nextest (already the mandated test runner).

Where the floor runs

cargo xtask coverage enforces the baseline-relative floor by default: a drop of more than 0.5 points below the ledger xtask/baselines/coverage.toml fails. The baseline is 69.40% of lines (re-recorded 2026-11-20, #2672; it had stood at 45.68% since 2026-08-09 while measured coverage rose, so the floor would have passed a 23-point drop).

  • CI: the coverage-floor job of the weekly scheduled pipeline runs it on main, with no devstack (the unit tests; devstack-gated tests are skipped, as they are locally). It is advisory, like the other scheduled jobs: a failure shows on the scheduled pipeline and blocks no merge.

  • Not per merge: a full instrumented run takes about ten minutes and a 67 GB build on the battery host.

  • Refreshing: when a change legitimately moves coverage, run cargo xtask coverage, then cargo xtask baselines bless --only coverage (with --allow-lower "<why>" for a drop), and commit the file; the diff is the review. Two runs on one tree differed by 0.03 points.

The ledger holds one number, the line percentage, and no per-crate table is kept: the run prints the per-crate summary, and nothing gates on it.

Edit this page · latest