From 98a8a1434390fc8cf6d1c430440fc16c84c9fad3 Mon Sep 17 00:00:00 2001 From: TO Date: Wed, 25 Nov 2026 10:28:34 +0100 Subject: [PATCH] Add Rule #3: tests observe, they don't shape Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0192He3BEKJ9v922udzup4Qn --- CLAUDE.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index f455a30..d3a6626 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -18,6 +18,13 @@ When adding behavior or tests would grow a Rust file and leave it above 500 line - Group integration tests by behavior in the package's top-level `tests/` directory and exercise the public API. - When documenting a runnable API example, use a Rust code block in the item's `///` comments so `cargo test` checks it. +## Rule #3: tests observe, they don't shape + +Production code does not exist to satisfy a test. Tests go through the same paths production uses; when a test needs a way in, that is a design seam with a production meaning (an injected clock, a trait with a real implementation), not a test hook. + +- No `cfg(test)` / `cfg!(test)` branches inside production logic, no flags or parameters only tests set, no visibility widened only for tests. +- Exception: passive instrumentation under `#[cfg(test)]` (counters, recorded events) that guards a Rule #1 structural test, never read by production code and never changing its behaviour. + ## Agent skills ### Issue tracker -- 2.54.0