{
  "uid": "cogitave.learn.testing-and-quality.the-test-harness-and-quality-bar",
  "kind": "moduleUnit",
  "href": "/modules/testing-and-quality/the-test-harness-and-quality-bar/",
  "title": "The test harness and the quality bar",
  "summary": "",
  "type": null,
  "products": [],
  "roles": [],
  "levels": [],
  "subjects": [],
  "headings": [
    "The harness: same commands locally and in CI",
    "The gate-to-DoD map",
    "The quality bar review enforces"
  ],
  "source": "Knowing the policy is half the job. To test a change you also need the *runnable*\nside and the *review* bar it has to survive.\n\n## The harness: same commands locally and in CI\n\nThe [Test Harness Reference](../../../../standards/docs/standards/test-harness.md)\npins the tooling so nothing floats. The runners are `cargo nextest` (Rust),\n`gotestsum` over `go test` (Go), and `vitest` (TypeScript); coverage is\n`cargo-llvm-cov`, `go test -coverprofile`, and `vitest --coverage`; mutation is\n`cargo-mutants`, `gremlins`, and `stryker` - run on critical modules only, because\nit is expensive.\n\nThe loop is split so feedback stays fast:\n\n- **Inner loop** (seconds, on save): watch-driven unit and property tests for the\n  module you are editing - no coverage, no gate.\n- **Outer loop** (CI, minutes): the full tiered suite plus every gate.\n- **Pre-commit** (lefthook): **format and lint only - no test execution.** Tests\n  belong in CI; the hook stays under a few seconds.\n\n> [!NOTE]\n> The lefthook hook runs the same lint and format commands as CI for convenience,\n> but **CI is the real gate** - there is no \"works on my machine\" escape.\n\n## The gate-to-DoD map\n\nEach required CI check is the operational form of a\n[Definition of Done](../../../../standards/docs/standards/testing-quality.md#10-the-gates-and-how-they-map-to-the-dod)\nitem: `test` and `coverage` and `mutation` satisfy `C2`; `perf` satisfies `P1`;\n`fuzz` satisfies `S1`/`S2`; `evals` satisfy `C3`; `docs-required` satisfies `C4`;\n`secret-scan` satisfies `C9`. Green across the applicable gates is **necessary but\nnot sufficient** - `done` still requires a CODEOWNER approval, because the machine\ngate and the human gate are separate by design (separation of duties).\n\n## The quality bar review enforces\n\nPassing the test gates is not the same as passing review. The\n[Code Craftsmanship Standard](../../../../standards/docs/standards/code-craftsmanship.md)\nturns design principles into **review and eval-gate criteria**: a change that\nviolates them is a change request, not a style nit. The highest-leverage form is\n**correctness by construction** - make illegal states unrepresentable and\n*parse, don't validate*, so the compiler carries the invariant instead of a\nruntime re-check. That is the same autonomy rail the root\n[`AGENTS.md`](../../../../../AGENTS.md) names: a narrow agent can act unattended\nbecause typed inputs and outputs hold.\n\nThe simplicity principles are the counterweight to over-engineering: **KISS**\n(the simplest design that expresses the invariant wins), **YAGNI** (do not build\nfor a future that has not arrived), and **DRY as knowledge, not text** - unifying\ncode that merely *looks* alike but encodes *different* knowledge is coincidental\nduplication, and collapsing it produces the wrong abstraction.\n\n> [!IMPORTANT]\n> **Dogmatic application of these principles is itself an anti-pattern.** They are\n> heuristics with costs, not laws. Demanding an interface for a single\n> implementation, or extracting two-line lookalikes, *causes* the damage the\n> principles exist to prevent. The default: choose the simplest thing that makes\n> the invariant hold and is not yet duplicated a third time - add abstraction on\n> evidence of a real second case, never on anticipation.\n",
  "partOf": "cogitave.learn.testing-and-quality",
  "durationInMinutes": 7,
  "quiz": null
}