tdd · diff

git:20261118.549ccf7 to git:20261118.581e4cd

12 added, 12 removed. Audit A to A.

What this update changes in the checks

No check changed: every fixed check gives the same answer before and after this update.

A tripped check is a label, not a verdict: read the matched text and the lines below. This week's updates that newly trip a check.

---
name: tdd
- description: Drives behavioral code changes through a strict Red-Green-Refactor loop at public module seams with complete production behavior and zero test tampering. Use when building features test-first or writing unit/integration tests.
+ description: Drives multi-language behavioral changes (TS/JS, Dart/Flutter, Go, Python, Rust) through Red-Green-Refactor at public module seams with complete production behavior, performance checks, and zero test tampering. Use when building features test-first or writing unit, widget, or integration tests.
---
- # Test-Driven Development (TDD)
+ # Test-Driven Development (Multi-Language Public Seams)
- Follow **Red → Green → Refactor** at public module seams so tests verify observable contracts and survive internal refactoring.
+ Execute strict **Red → Green → Refactor** at public module seams so tests validate observable contracts and survive internal refactoring. Consult [references/stack-test-patterns.md](references/stack-test-patterns.md) and [examples/tdd-seam-example.md](examples/tdd-seam-example.md).
## Decision tree
- 1. **Does the planned test access private methods, internal state, or internal helper call counts?**
- - **Yes** → Rewrite it to call only the module's **public seam** and assert on observable outputs, state effects, or returned errors.
+ 1. **Does the planned test reach into private methods, internal state fields, or internal helper call counts?**
+ - **Yes** → Rewrite the test to invoke only the **public seam** (API route, CLI, exported function/use-case, or rendered widget/DOM role) and assert observable outputs or errors.
- **No** → Proceed to step 2.
- 2. **Does the module mix pure domain logic with external I/O (DB, HTTP, filesystem)?**
- - **Yes** → Keep pure rules in pure functions for fast zero-mock unit tests; test the I/O adapter separately at its integration seam.
+ 2. **Does the module mix pure domain logic with external I/O (DB, HTTP, storage, clock)?**
+ - **Yes** → Keep pure rules isolated for zero-mock unit tests; test adapters separately at their integration seam with outer-boundary fakes only.
- **No** → Run the Red → Green → Refactor loop below.
## Cycle
- 1. **RED**: Write one failing test named after the observable behavior. Run it via `run_command` and confirm it fails for the expected behavioral reason (not a syntax/import error).
- 2. **GREEN**: Write the smallest **complete production behavior** that makes the test pass—never a happy-path stub. Include required boundary parsing, authorization, error mapping, and idempotency. Never modify/weaken/skip the test to pass.
- 3. **REFACTOR**: Deduplicate helpers, flatten nesting with guard clauses, and verify shared UI/utility reuse while keeping tests green. Add no new behavior in this step.
+ 1. **RED**: Write one failing test named after the observable capability. Run the repo's real test runner (`npm test`, `flutter test`, `dart test`, `go test ./...`, `pytest`, `cargo test`) and confirm it fails for the expected behavioral reason.
+ 2. **GREEN**: Implement the smallest **complete production behavior**—never a happy-path stub. Include real boundary parsing, authorization, config/logging seams, error wrapping, disposal, and optimal complexity. Never `.skip`, `skip: true`, weaken assertions, or mock the System-Under-Test.
+ 3. **REFACTOR**: Remove duplication, reuse shared UI/helpers, flatten nesting with guard clauses, and re-run the test suite to stay green.
- ## Coverage floor
+ ## Mandatory coverage floor
- Before finishing a seam, verify tests cover: happy path, `N-1`/`N`/`N+1` boundaries, empty/malformed inputs, unauthorized/cross-tenant access (`401`/`403`/`404`), duplicate idempotency (if mutating), and at least one failure mode.
+ Verify tests cover: happy path, `N-1`/`N`/`N+1` boundaries, empty/null/malformed inputs, unauthorized/cross-tenant access (`401`/`403`/`404`), duplicate idempotency (if mutating), and at least one external failure/timeout case.