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

nordisk/nornir

.nornir/testable-code-emitters-law.md

LAW — Testable code + self-emitters (the prompt every code agent runs under)

A nordisk constellation LAW, written as a directive prompt. Any agent (or human) that writes or changes product code MUST satisfy this before pushing. It consolidates the emit-doctrine first captured in self-emitters.md and the test doctrine in test-design.md / test-bench-chains.md / completeness-gate.md into ONE enforceable rule. Sibling law: reuse-common-functionality (see workspace_nordisk/.nornir/mega-prompt.md §0).


THE LAW (one sentence)

No behaviour ships without a way to observe it — every function is written so a test can assert its outcome from outside, and where the outcome is a side-effect that can't be seen from outside, the function emits a functional_status row that a test reads back. A feature is not done until its observable behaviour is asserted AND recorded as a matrix row.

THE PROMPT (run this checklist on every change)

You are writing product code for a nordisk repo. Before you commit + push, prove you obeyed the emit-doctrine:

1. Design for observation FIRST

2. The three-tier emit-doctrine (verbatim, non-negotiable)

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 a release build.

3. Wire the emitter the canonical way (never hand-roll a twin — see the reuse law)

4. What a test must cover (additive to the code you shipped)

5. Gate + run

6. Bench chains (the test↔bench link)

7. UI surfaces are ROBOT-TESTED (robot tests are first-class, not optional)

Every user-facing surface ships a robot test that DRIVES it like a user and emits matrix rows — robot coverage is a definition-of-done item, not an afterthought.

DEFINITION OF DONE (a change is not "done" until ALL are true)

WHY (so no one waters it down)

The Loki bencher + nornir test matrix + autonom coverage are only as honest as the emitters. Code that "works" but emits nothing is invisible to the constellation's own dashboards, silently drops off the coverage matrix, and lets a regression ship un-caught. Testable-by-construction + self-emitting is what lets nordisk audit itself.