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

nordisk/nornir

.nornir/self-emitters.md

Self-emitters — nornir wiring its OWN functional_status matrix (design + guide)

nornir consumes the nornir-testmatrix functional_status emitter across its own enumerated functional surface (viz tabs, server RPCs, warehouse paths, CLI verbs, arch/funnel engines). The emitter feeds one functional row per real check into the nornir test matrix. Built 2026-06-16 (branch feat/self-emitters). Sibling of aut5-surface-coverage-gate.md; plan: nordisk_plan.md.

1. EMIT-DOCTRINE (the law)

DEFAULT  →  assert on the RETURN VALUE / object state (the returned result + state()/state_json).
FALLBACK →  ONLY when the result can't be observed from outside (a render / side-effect): implant a
            functional_status(...) INSIDE the function under test, then read the row back in the test.
RELEASE  →  every emit AND its detail-building is gated `#[cfg(feature = "testmatrix")]`, so a plain
            build strips it to nothing. No emit exists in release.

2. The bridge

3. What is wired

4. Run it

cargo build --workspace --features testmatrix            # green, emits stripped in any non-test build
cargo test --features "viz,server,testmatrix" \
     --test self_emitters_core --test self_emitters_viz -- --test-threads=1

5. Per-crate emit roster (the internal-crate allow-list)

Each crates/nornir-* leaf carries its OWN selftest::emit bridge + a #[cfg(all(test, feature = "testmatrix"))] wiring test that drives its real surfaces and drains the rows back. The roster (12 internal crates):

crate emits functional_status how
nornir-testmatrix — (IS the emitter) defines functional_status / the matrix
nornir-selftest ✅ nornir's own emit + assert_emit! bridge
nornir-git ✅ src/selftest.rs — real git ops
nornir-guard ✅ src/selftest.rs
nornir-jobs ✅ src/selftest.rs — job lifecycle
nornir-bench ✅ src/selftest.rs
nornir-cli-outcome ✅ src/selftest.rs
nornir-introspect ✅ src/selftest.rs
nornir-coverage ✅ runner emits
nornir-saga ✅ src/record.rs
nornir-build-thing ✅ src/selftest.rs — variant validate / cargo argv / surface projection (wired task #8)
nornir-robotui EXEMPT test-harness lib: emitting TestResultRows IS its product surface (a bridge would be a self-referential no-op)

The nornir-robotui EXEMPT row is the allow-list entry: it is excused because it emits matrix rows by construction, not through a consumer bridge (see the crate's module docs). Every other internal crate MUST carry a bridge.

functional_status appends one JSONL row per check to $NORNIR_TESTMATRIX_OUT (default target/nornir-functional.json), which nornir test's Unit aspect reads back into the matrix (aspect = functional). Without --features testmatrix both test files compile to 0 tests and every emit is a no-op.