Coverage Matrix

The coverage matrix is a route × axis table computed from what the tests actually sent: the HTTP records the battery’s harness writes (Testing Reference (CRAIG) § HTTP recording). Each record of a passed test’s final attempt is matched to an operation of its service’s OpenAPI spec, and its response earns that operation a happy, sad, evil, fault, replay or conc credit. It replaces the static matrix, which credited routes by test name and literal path and filled 18 of 2,820 cells (#2703).

A broken recorder fails the battery. So does the coverage-signature gate, which every full battery runs right after the matrix: a required signature missing from the run and not in the committed baseline xtask/baselines/coverage-signatures.toml, or a stale baseline entry, fails it. The gate, its baseline and its rules are Quality Gates § Coverage-signature gate; each full battery writes a fresh report. Design and rationale: plan Runtime Coverage Matrix § D3–D6.

Running it

In the battery. Every full devstack battery, that is cargo xtask validate’s devstack phase and `cargo xtask test --integration (CI’s ci-integration job), ends with two steps after nextest, the C24 program-verification gate, the invariants gate and the caregiver report:

  1. HTTP run manifest writes test-results/http/run.json (§ Reports and provenance).

  2. Coverage matrix and coverage-signature gate computes the matrix over this run’s records and the battery profile’s own JUnit, test-results/<profile>/integration/results.xml, then runs the gate’s check (--check) against the manifest and the baseline.

A red nextest or a red gate returns before either step, so a failed battery leaves no manifest and no matrix. An error in either step fails the battery. The matrix’s refusals (§ Attribution, § Route matching, § Health floor) are recorder failures, never coverage gaps; the gate runs only once the matrix is computed, and fails on a refused provenance, a new missing signature or a stale baseline line. The scoped run (cargo xtask test --package <crate> --integration) writes only a scoped manifest and never runs the matrix or the gate: a partial battery cannot judge what was not observed.

Standalone, from the workspace root, over the records and JUnit a battery left behind:

cargo xtask coverage-matrix [--records <dir>] [--junit <xml>] [--output <md>] [--check]
Flag Default Meaning

--records

test-results/http/records

The record directory the battery preamble empties and nextest fills.

--junit

test-results/integration/integration/results.xml

The nextest JUnit of the run that wrote the records: the integration profile’s, which cargo xtask validate runs. After test --integration --profile ci-integration, pass test-results/ci-integration/integration/results.xml.

--output

target/coverage-matrix.md

The Markdown table.

--check

off

After the matrix, the coverage-signature gate’s check: fails on a new missing signature or a stale baseline line (Quality Gates § Coverage-signature gate).

Either way, the command reads each of the nine api_docs::SERVICES binaries' OpenAPI document from --print-openapi (api_docs::from_source_specs, the source cargo xtask api-docs renders), and reads HEAD’s tree hash and the working tree’s status from git. The binaries are the devstack’s one compile when it is current for the tree, so the battery’s matrix compiles nothing; otherwise the command builds them first (cargo build --locked, debug) (testing-reference, #3049). It writes:

  • test-results/http/coverage-matrix.json, the report (inside CI’s test-results/ artifact);

  • the Markdown table at --output (under target/, so outside CI’s artifact).

The console shows a banner, the health line and its miss groups (§ Health floor), then the record counts, the outcome counts, the routes credited per axis, and the two paths written. With --check, and in the battery, the gate’s own banner follows, then its verdict: one line of counts when clean, else each new pair and each stale line.

Attribution

A record earns credit only if it belongs to a test that passed, and only from that test’s final attempt.

  • Test identity. A test is (binary_id, test), the record file header’s NEXTEST_BINARY_ID and NEXTEST_TEST_NAME. One process is one attempt (NEXTEST_ATTEMPT); files sharing (binary_id, test, attempt) are one test.

  • The JUnit scan. The nextest JUnit is read without an XML crate, the way test_binaries::whole_binary_aborts reads it. <testsuites uuid="…"> is the run, <testsuite name="…"> the binary_id, <testcase name="…"> the test; attribute values are unescaped (<, >, ", ', &). quick-junit escapes < in text content, so every raw < starts a tag and captured output cannot pose as one. If nextest ever stopped writing name as the first attribute, the scan would find no testcase, and every record would refuse as absent from the JUnit.

  • Passed means the testcase has no <failure, <error or <skipped child.

  • Final attempt is 1 plus the testcase’s <flakyFailure, <flakyError, <rerunFailure and <rerunError children.

  • Standing. Each file is credited (passed, final attempt), failed test (the test did not pass, all its attempts) or non-final attempt (passed, an earlier attempt). Only credited records can reach the axes.

The run refuses at the first problem found, in record-file path order, so a refusal is deterministic:

Refusal Cause

No HTTP records under the record dir (a missing dir counts as empty)

The recorder did not run. The message names both causes: cargo-nextest older than 0.9.116 (its tests lack NEXTEST_BINARY_ID, NEXTEST_TEST_NAME and NEXTEST_ATTEMPT), or no CRAIG_TEST__HTTP_RECORD_DIR (the battery preamble sets it; a direct cargo nextest run does not).

The record dir does not list

A filesystem error other than a missing dir.

A broken record file

A file that cannot be read, has no header line, holds an unparsable line (named file:line), or names a format version v this reader does not know.

Mixed run ids

Two record files carry different `NEXTEST_RUN_ID`s; both files are named. One battery is one run.

No readable JUnit report

The --junit path does not read; pass the run’s own report.

A malformed JUnit report

An unterminated <testsuite name= or <testcase name= value, or an attempt count that overflows.

A testcase listed twice

One (binary_id, test) appears twice in the JUnit.

A JUnit that names no run

No <testsuites uuid=, so the report cannot be matched to the records' run.

A JUnit of another run

Its uuid differs from the records' run_id: a stale report would credit a test that failed in this run.

A record of a test the JUnit lacks

A record file names a (binary_id, test) with no testcase.

An attempt above the final attempt

A record file’s attempt exceeds what the JUnit’s retry children allow.

Route matching

Each matrix service gets one matchit router (axum’s own router crate, =0.8.4) holding every path key of its from-source spec; at(path) yields the template, and the record’s method then selects the operation. Paths in the records carry no query string, and methods compare exactly (upper case). A static segment wins over a parameter sibling: /v1/x/things/export matches that template, not /v1/x/things/{id}.

Every record gets one outcome, decided in this order:

  1. probe: the path is exactly /healthz, /livez, /readyz or /metrics, whatever its svc. These are craig-api’s probe routes, which no spec serves.

  2. unattributed: svc is null (the origin was never registered with the recorder) or names no SERVICES member.

  3. unmatched-path: no template of the service’s spec matches the path.

  4. unmatched-method: a template matches, but the spec has no operation for that method on it.

  5. matched: the record names one operation, (service, method, template).

Every record is counted, credited or not; only a credited, matched record reaches the axes.

Shape conflicts refuse. matchit normalises parameter names, so two path keys of one service that differ only in a parameter’s name (/v1/x/{id} and /v1/x/{thing_id}) are one shape, and a record’s path could not name its route. The run refuses, naming both keys. Differently named parameters in otherwise distinct shapes (/v1/x/{id}/a and /v1/x/{xid}/b) coexist. A real-tree test pins that the committed API pages build a conflict-free table. The table also refuses a key that is not a valid route template and a document that does not read as paths and component schemas.

Health floor

The floor tells a broken recorder from a coverage gap. It runs after classification and before any report is written, and it measures every record, credited or not, because recorder health does not depend on test outcomes.

  • The figure is the share of non-probe records that are unattributed, unmatched-path or unmatched-method: (unattributed + unmatched_path + unmatched_method) / (records − probe), printed in per mille to one decimal, rounded up.

  • The ceiling is records::MAX_UNMATCHED_PER_MILLE, now 5‰. It was pinned on 2026-10-25 at the next 5‰ step above U4’s first measured figure, 3.4‰ (56 of 16,827 non-probe records); the figure and its run id are in the constant’s doc comment and on #2703. It is shrink-only: a raise is justified in its MR.

  • The checks, in order: every SERVICES member has at least one matched record, then the figure is at most the ceiling. Either failure refuses as recorder failure, not a coverage gap.

The health line always prints, followed by up to ten miss groups (outcome, svc, binary), largest first:

    health: {unmatched} of {considered} non-probe records unattributed or unmatched ({X.Y}‰; ceiling {max}‰; next 5‰ step above: {pin}‰)
    miss: {count}× {outcome} svc={svc or null} {binary_id}

The "next 5‰ step above" figure is the value a re-pin would take: the smallest multiple of 5 strictly above the figure, capped at 1000.

A large single-binary group of unattributed misses is usually an in-process server that never called recording::register_origin: a recorder gap, to be fixed under its own issue, not a coverage gap.

Axes

Each credited, matched record earns its route at most one status axis, plus replay when its response was a replay:

Status Credit Note

200–299

happy

Also replay when the record has replayed: true.

400, 404, 409, 422

sad

401, 403

evil

500–599 while armed

fault

armed: a fault arm window was open when the request started.

500–599, not armed

none

Counted as unarmed_5xx.

no response

none

Counted under unclassified as none.

anything else: 1xx, 3xx, other 4xx (405, 406, 410, 412, 413, 415, 428, 429, …), below 100, 600 and up

none

Counted under unclassified by decimal code.

Every record credits its own status axis; replay is additive, and no record is suppressed. A 409 on a re-sent key still credits sad, and a replayed 2xx credits both happy and replay. A replayed non-2xx credits no replay. replayed is the server’s Idempotent-Replayed: true response header. Since #2707 (plan U8) a service sets it on a 2xx that replays through the shared claim code (request_claims, upload_attempts), and craig-intake relays it on its two proxied attachment uploads. Since #2764 a replay resolved outside that code sets it too, through craig_api::mark_replayed(): cases' report resubmission and its SSA-screening forward, and craig-intake’s cases-backed sink relays cases' header on report submissions. Since #2783 its SHINES sink sets it too, on a report submission it answers from a receipt the request did not claim, so those replays credit replay.

Concurrency (conc). The credited records of one test on one route form a group. A group earns conc when two of its records overlap in flight, [t0_us, t1_us): t0_a < t1_b && t0_b < t1_a. Status, or no response, is ignored. A sweep finds them: sort the group by (t0_us, t1_us), and flag each record whose t0_us is below the largest t1_us before it. The t1_us tie-break matters: a zero-length [5,5) and a [5,9) do not overlap, but a t0-only order could put [5,9) first and flag the other. Back-to-back records (t1_a == t0_b) do not overlap, and an overlap across routes or across tests earns nothing. A proptest pins the sweep to the pairwise rule. On a route, `conc’s record count is the number of flagged records, and its tests are the tests with at least one overlap.

Replay attempts. A route’s replay_attempts counts the records, within one test, that carry a client_request_id (the record’s crid) an earlier record of that test on that route already carried. It ignores status and replayed, and a key reused in another test or on another route does not count. A re-sent key without the Idempotent-Replayed response header counts here only, which separates "no replay was sent" from "a replay was sent but not confirmed" for the gate’s replay requirement; the gate prints it on each missing replay line.

Authorization evidence (authz, #2898). A witness build stamps each response with the number of authorization decisions the request made, and the recorder keeps it as the record’s authz_decisions. Each credited 2xx record on a route is counted once: decided when the stamp is above zero, zero when it is zero, unwitnessed when the response carried no stamp (the service was not a witness build). A route with at least one 2xx and no decided one is listed in the report’s authz_unproven, unless the exemption ledger xtask/baselines/authz-exempt-routes.toml names it or it is a route the witness exempts on every service (craig_api::SHARED_EXEMPT_ROUTES, the admin event replay). In-process suites are witnessed too (Testing Reference (CRAIG) § The authz witness in-process). The list is a report, not a gate: the witness itself refuses an undecided 2xx on a non-exempt route while the battery runs, so the list names what a battery without the witness could not show. A route no test answered 2xx on is not listed.

Each axis on each route is a tally: the number of credited records, and the distinct tests that sent them.

Idempotent routes

Each route carries idempotent, plan D6’s predicate; the coverage-signature gate requires a replay credit on each such route. A route is idempotent when:

  • its method is POST, PUT, PATCH or DELETE (a GET never is); and

  • its request body has an application/json or multipart/form-data media type (parameters such as ; charset=utf-8 ignored, case-insensitive) whose schema has a top-level client_request_id property, directly or through ANY $ref, allOf, oneOf or anyOf branch.

A property nested under another object (data.client_request_id) does not count, and neither does another media type. A reference cycle ends that branch without the key. A $ref that is not a #/components/schemas/ entry of the document, or names a missing one, refuses the run (fail closed), as does a request body that is itself a $ref: utoipa emits neither, and silently reading one as "not idempotent" would drop a requirement. Since #2706 (plan U7) the upload handlers declare their multipart/form-data bodies, so an upload whose form carries client_request_id is idempotent too.

Reports and provenance

test-results/http/coverage-matrix.json (pretty JSON, v: 2) holds:

  • run_id (the records' NEXTEST_RUN_ID), tree_hash (git rev-parse HEAD^{tree}), clean_tree (an empty git status --porcelain) and spec_sha256 (sha256 over each spec’s service name and compact JSON, in SERVICES order);

  • health: unmatched, considered and max_per_mille;

  • totals: records, credited, failed_test, non_final_attempt, matched, probe, unmatched_path, unmatched_method and unattributed, where records = credited + failed_test + non_final_attempt = matched + probe + unmatched_path + unmatched_method + unattributed;

  • routes: every operation of every spec, observed or not, in (service, method, template) order, each with service, method, template, idempotent, axes (happy, sad, evil, conc, replay and fault, each records plus tests, a list of binary_id and test), authz (decided, zero and unwitnessed), unarmed_5xx, unclassified (each decimal code, or none, to its record count) and replay_attempts;

  • authz_unproven: the service, method and template of each route listed under § Authorization evidence, in row order.

The Markdown table opens with the run id, tree hash and clean flag, the specs' sha256, the route, record and outcome counts, and the health figure, then one row per route:

Column Cell

Service, Method, Template

The operation.

Idempotent

yes, or empty.

happy, sad, evil, conc, replay, fault

Distinct tests, then the record count in parentheses (2 (3)); empty at 0.

authz

The 2xx records that showed a decision over all 2xx records (2/3); empty when the route has no 2xx.

unarmed 5xx

The count; empty at 0.

unclassified

405×1, none×2, in code order; empty when none.

replay attempts

The count; empty at 0.

The run manifest, test-results/http/run.json, records which battery wrote the records, so the coverage-signature gate can check that it judges a whole run of the current, committed tree (its provenance refusals are in Quality Gates § Coverage-signature gate):

  • the full battery writes {"kind":"full","run_id":…,"tree_hash":…,"clean_tree":…,"spec_sha256":…} once nextest and its gates pass. It loads the records to take their run_id, so a record-loading refusal fails this step too, and it builds the specs (the first build is the slow part; the matrix step’s rebuild is a no-op);

  • the scoped run writes exactly {"kind":"scoped"} after its nextest step.

Reset. Every battery’s preamble empties test-results/http/records/ and deletes run.json, coverage-matrix.json and target/coverage-matrix.md, so no report or manifest outlives the run that wrote it.

Limits

From the plan’s § Risks:

  • Observed is not asserted. A setup call’s 2xx credits happy as much as the call under test. The matrix shows what the tests sent and what came back, not what they checked; mutation testing stays the oracle for assertion strength.

  • Bypasses are invisible. A request that does not go through the recorder (an in-process oneshot call, or a raw send left raw) leaves no record. #2700 counted them, #2702 moved every matrix-service send onto the recorder, and the sends left raw are listed on those issues.

  • Precision. Clock skew can miss or add a conc credit. A fault armer outside the arm window shows its 5xx as unarmed. A fired single-shot armer (arm_stage_fault, PgFaultArmer) stays armed until it is dropped, so a later 5xx in that window credits fault. None of this is gated.

  • Scope. Only the nine SERVICES have rows; craig-intake-keyring, craig-web and craig-portal do not. A flaky test’s earlier attempts earn nothing, and a failed test earns nothing at all.

Edit this page · latest