Gunnar

nordisk/znippy

.nornir/quality-matrix.md

# znippy's own quality matrix (L4b)
<!-- nornir:class: history -->

znippy consumes the published reusable test-matrix engine
[`nornir-testmatrix`](https://crates.io/crates/nornir-testmatrix) as a
**dev-dependency** of the `znippy-tests` member. This proves the matrix
framework is reusable from this repo — znippy can render its OWN quality
matrix standalone, with no nornir checkout.

## Run znippy's matrix

```sh
cargo run -p znippy-tests --example quality_matrix
```

This runs `run_full_matrix(".", Aspect::DEFAULT)` — build, unit, doctest,
clippy, fmt, audit — writes the rows to `target/quality-matrix.jsonl` via
`JsonFileSink`, and prints `render_matrix(&rows)`.

It shells one `cargo` invocation per aspect, so it is **deliberately NOT** in
the normal `cargo test` path (no cargo-inside-cargo on every test run).

## Wiring proof (fast + offline)

`tests/tests/testmatrix_wiring.rs` is an inject-and-assert test
(`testmatrix_roundtrip_and_render_inject_assert`): it feeds canned
`TestResultRow`s (varied status / aspect / metric) through the real
`JsonFileSink` round-trip and `summarize_runs` + `render_matrix`, then asserts
exact tallies, that aspect+metric survive serde, and that the rendered grid
shows the red `✗` marker. No cargo subprocess, no network.

## CLI functional-status surfaces (introspection)

Each `znippy-cli` verb self-reports one or more **functional_status** rows
(`component / check / ok / detail`) so `nornir test --features testmatrix` SEES
whether a command actually worked — GREEN on the success path, **RED** on
failure — without anyone reading stdout. The wrapper compiles to an `#[inline]`
no-op with **no** nornir dep in the default (shipped) build, so the lean CLI
carries zero cost; build `--features testmatrix` (optionally `+sign`) to record
rows.

| Surface (`component`) | `check` | GREEN when | RED when |
|---|---|---|---|
| `znippy-cli/compress` | `archive_written` | archive sealed OK | `compress_dir` errored |
| `znippy-cli/verify` | `integrity_checksum` | 0 corrupt files/bytes | any corruption **or** a hard read error |
| `znippy-cli/format-version-guard` | `on_disk_version_supported` | reader accepted the on-disk version | (errors out before emit) |
| `znippy-cli/decompress` | `reconstruct_verify` | every file's blake3 reconciled | any corrupt file/byte **or** a hard read error |
| `znippy-cli/compress-sign` | `signer_loaded` | `--sign` key+cert loaded | signer load failed (missing `--sign-cert`, bad key/alg) |
| `znippy-cli/verify-signed` | `provenance_chain` | detached CMS chained to a trusted root | no roots, unreadable CA, or chain/verify failure |
| `znippy-cli/append` | `native_append` | rows added ≥ files | — |
| `znippy-cli/run-dispatch` | `handler_command` | handler subcommand ran | dispatch errored |

### Red-when-broken tests

`znippy-cli/src/lib.rs` gates two `#[cfg(feature = "testmatrix")]` tests on the
process-global functional buffer (serialized via a shared `fs_test_lock`, drained
with `nornir_testmatrix::drain_functional_rows`):

- `green_roundtrip_then_red_on_corruption` — a clean compress → verify →
  decompress round trip records GREEN rows; flipping one blob byte flips the
  `verify` + `decompress` rows to **RED**.
- `build_signer_missing_cert_emits_red_row` (also needs `sign`) — a `--sign`
  with no `--sign-cert` both errors AND records a **RED** `signer_loaded` row.