---
name: Establish the TDD Workflow and Gates
---

# Story 26: Establish the TDD Workflow and Gates

## User Story
As a user, I want a clear, enforceable TDD workflow with quality gates, so development is test-first and regressions are blocked.

## Acceptance Criteria
- [ ] A test-first workflow is defined and enforced before implementation begins.
- [ ] Each story requires both unit tests and integration tests (standard Rust `tests/` layout).
- [ ] A test plan is produced and approved before any code changes.
- [ ] Stories cannot be accepted unless all required tests pass.
- [ ] The system warns when multiple tests fail and blocks acceptance until all required tests pass.

## Test Plan (Approved)


### Backend (Rust) — Unit + Integration
- AC1/AC3: Block write/exec when no approved test plan exists.
- AC2: Enforce presence of both unit + integration test categories before a story can proceed.
- AC4: Block story acceptance unless all required test results are passing.
- AC5: Allow only one failing test at a time (reject registering a second failure).

**Integration coverage:**
- Attempt to write before test plan approval → expect rejection.
- Add/approve test plan → write succeeds.
- Attempt acceptance with failing/missing tests → expect rejection.
- Acceptance with all passing tests → expect success.
- Register second failing test while one is red → expect rejection.

### Frontend (React) — Vitest + Playwright
- AC1/AC3: Gate status shown in story view; tools blocked until test plan approved.
- AC4: Acceptance action disabled when required tests are failing or missing.
- AC5: UI surfaces “red test count” and blocks when more than one failing test is present.
- E2E: Attempt blocked actions show a visible banner/toast and do not execute.

## Out of Scope
- Backfilling tests for legacy code (covered by a separate story).
- Adding new test frameworks beyond those defined in `specs/tech/STACK.md`.