Testing and Validation Loops
Relevant source files
The following files were used as context for generating this wiki page:
Testing and Validation Loops represent the core quality assurance mechanism within the project, ensuring that every code change is verified immediately and rigorously. The system relies on a "Golden Rule" where developers must never accumulate broken state; if a validation fails, it must be fixed before proceeding to the next task. This is achieved through a multi-layered approach ranging from immediate static analysis to complex GAN-style adversarial evaluation.
Sources: commands/prp-implement.md:12-14, agents/tdd-guide.md:47-49
Test-Driven Development (TDD) Loop
The TDD loop is the fundamental building block for feature implementation and bug fixing. It enforces a strict "tests-before-code" methodology to ensure comprehensive coverage and clear behavioral definitions.
The Red-Green-Refactor Cycle
- RED (Write Test First): Create a failing test that describes the expected behavior.
- Verify Failure: Run the test to ensure it fails as expected (not due to syntax errors).
- GREEN (Implementation): Write the minimal amount of code required to make the test pass.
- REFACTOR (Improve): Optimize the code while ensuring tests remain green.
- Verify Coverage: Ensure the implementation meets the 80% coverage threshold for branches, functions, and lines.
Sources: agents/tdd-guide.md:53-73, skills/tdd-workflow/references/tdd-reference.md:10-15
The following diagram illustrates the TDD execution flow:
Implementation Validation Levels
During the execution of an implementation plan via /prp-implement, the system triggers five distinct levels of validation loops. These loops catch mistakes early and prevent the progression of technical debt.
| Level | Type | Description |
|---|---|---|
| Level 1 | Static Analysis | Runs type-checkers (e.g., tsc) and linters to ensure zero syntax or type errors. |
| Level 2 | Unit Tests | Executes tests for every new function, covering happy paths and edge cases. |
| Level 3 | Build Check | Verifies that the project compiles successfully without any build-time errors. |
| Level 4 | Integration | Launches a local server and runs tests against API endpoints/routes. |
| Level 5 | Edge Case | Manual or automated verification of boundary values and failure paths. |
Sources: commands/prp-implement.md:88-140
Multi-Level Validation Workflow
The implementation process follows a sequential verification path:
Sources: commands/prp-implement.md:144-160
Adversarial GAN Evaluation Loops
For high-level feature validation and UI/UX quality, the system employs a Generative Adversarial Network (GAN) style loop between a Generator and an Evaluator.
The Iteration Cycle
The Generator implements features based on a specification and hands them off to the Evaluator. The Evaluator then tests the live running application using tools like Playwright and provides a scored report (1-10 scale).
- Implement: Generator builds/updates the app and starts a dev server.
- Evaluate: Evaluator navigates the live app, tests edge cases, and audits design.
- Feedback: Evaluator writes a feedback report highlighting critical, major, and minor issues.
- Improve: Generator reads the feedback and iterates on the code to address every issue raised.
Sources: agents/gan-evaluator.md:38-112, agents/gan-generator.md:43-70
Specialized Web Validation
Web-specific validation loops prioritize the user interface and accessibility. These rules extend the common testing practices with visual and browser-centric requirements.
Web Priority Order
- Visual Regression: Screenshotting key breakpoints (320px to 1440px) to detect UI drift.
- Accessibility: Automated checks and manual keyboard navigation verification.
- Performance: Lighthouse auditing against Core Web Vitals (CWV) targets.
- Responsive: Verifying touch interactions and ensuring no layout overflows.
Sources: rules/web/testing.md:5-24
Edge Case Testing Requirements
The project mandates that validation loops must account for specific edge cases beyond the "happy path." Failure to validate these leads to loop rejection.
- Input Boundaries: Null/undefined, empty strings/arrays, and maximum size inputs.
- Data Integrity: Invalid types, special characters (Unicode/Emoji), and SQL injection characters.
- Runtime: Network failures, database errors, race conditions, and concurrent operations.
- Performance: Handling large data sets (e.g., 10k+ items).
Sources: agents/tdd-guide.md:83-92, commands/prp-implement.md:139-140
Validation loops are the primary defense against regressions and quality degradation. By integrating static analysis, TDD, and adversarial GAN evaluation, the project maintains a high standard of code integrity and user experience. Successful completion of these loops is required before any feature is marked "complete" or ready for PR review.