Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/nornir

.nornir/viz-test-pane-shine.md

🧪 The shining Test pane — per-repo × per-aspect health matrix (EPIC L5)

Design + guide for the flagship nornir viz Test tab (src/viz/test_tab.rs, Tab::Test). EPIC L5 turned the old flat run/case list into a gorgeous repo × aspect matrix painted on the facett palette, with metric badges, per-aspect trend sparklines, per-repo health scores, a summary strip, and click-to-drill-down. THE_BIG_PLAN LAWs apply: everything rendered is exposed as data (state_json()["test"]["grid"] + $NORNIR_VIZ_TRACE), the test inject-and-asserts the real grid, and a wgpu PNG snapshot is the acceptance artifact.

What it shows

A grid over the warehouse test_results table (which since EPIC L carries aspect: String + metric: f64 per row):

element meaning
rows one per repo, taken from that repo's latest run (newest ts_micros)
columns the aspects present in the data, in canonical order: build · unit · doctest · clippy · fmt · audit · bench-smoke · coverage · feature-powerset · msrv · examples
cell colour status on the active palette: green = pass, red = fail/stalled, amber/grey = skip/ignored, faint = not-run
cell mark a painted primitive (filled dot = pass, ✗ strokes = fail, ring = stall, hollow = skip) — drawn as shapes so it renders in every font (the bundled emoji font lacks ✓/✗)
metric badge type-aware, right-aligned: coverage 87%, clippy ⚠3, audit 🛡0, unit Np Mf (pass/fail counts)
sparkline per (repo, aspect), across the last SPARK_RUNS (12) runs — coverage rising, warnings falling (warning/advisory counts are inverted so "fewer = up")
health badge a 0–100 score per repo on a red→amber→green ramp
summary strip total green / red / skip / not-run cells across the whole matrix
palette picker switches the facett palette (default · sci-fi · nordic-aurora · cyberpunk-neon · amber-crt · deep-space · hugin-noir); re-skins everything
drill-down click a cell → a bottom panel lists that repo×aspect's failing cases (suite::name + message)

Health score

health_score(aspects, cells) (in src/viz/test_matrix_grid.rs) blends, over the aspects that actually ran in the latest run:

Result is clamped to 0–100. All-green + high coverage + no warnings → ~95–100; a build fail + low coverage + several warnings → well under 50.

Architecture — pure model + thin renderer

The LAW "components expose readable data" is met by splitting the pane:

state_json shape (["test"]["grid"])

{
  "aspects": ["build","unit","doctest","clippy","fmt","audit","coverage"],
  "repos":   ["nornir","skade","znippy"],
  "rows": [
    {
      "repo": "znippy",
      "run_id": "znippy-new",
      "health": 49.0,
      "cells": [
        {
          "aspect": "clippy", "status": "fail",
          "ran": true, "red": true, "green": false,
          "metric": 3.0, "badge": "⚠3",
          "count": 1, "passed": 0, "failed": 1,
          "red_cases": [{ "test_name": "clippy", "suite": "znippy",
                          "status": "fail", "message": "3 clippy warning(s)" }],
          "spark": [0.0, 40.0]           // inverted: 5→3 warnings reads as rising
        }
        // … one cell per aspect column (blank cells: ran=false, badge="")
      ]
    }
  ],
  "totals": { "green": 15, "red": 2, "skip": 1, "blank": 3 }
}

The legacy keys (runs, cases, selected_run, selected_repo, selected_green, plus the new palette + selected_cell) remain on ["test"] for back-compat with the run-summary consumers.

Tests (LAW #1 + LAW #4)

How to drive it live

nornir test all                 # populate test_results across repos
nornir viz                      # open nornir-ui → 🧪 Test tab
# pick a palette from the top strip; click any cell to drill into its failures.
NORNIR_VIZ_TRACE=/tmp/t.jsonl nornir viz   # machine-readable IN/OUT/END twin