Quality & Governance
Multi-layered quality assurance: 5 pipeline gates, 3-tier verdicts, circuit breaker pattern, and a safety net that prevents runaway autonomous execution.
AI Code Quality is a Coin Flip
AI-generated code is either brilliant or broken, and you rarely know which until production. Without structured review, security vulnerabilities slip through, edge cases get ignored, and code that 'works' today becomes tech debt tomorrow. Manual review doesn't scale when AI writes thousands of lines per session.
5 Pipeline Gates
Quality gates are pipeline checkpoints. Each evaluates the previous stage's output and produces a verdict. Failed gates send work back for revision.
Planning Complete
All DISCOVER + PLAN agents finished
QA Planning
QA-Planning agent validates plan coherence
Implementation
Dev agent completes all assigned tasks
QA Implementation
Tests pass, SAST clean, coverage adequate
Deploy Ready
All gates passed, ready for production
3-Tier Verdict System
APPROVED
Score meets or exceeds the threshold. Work proceeds to the next pipeline stage without intervention.
NEEDS_REVISION
Score is within 5 points below the threshold. Work returns to the agent for targeted fixes before re-evaluation.
BLOCKED
Score is significantly below threshold or a critical blocker exists. Pipeline halts and requires human intervention.
Scoring Thresholds
QA gates require 95% to pass; other gates use 90%. These thresholds enforce consistently high quality across the pipeline.
SAST: Code Security
Static Application Security Testing scans source code for known vulnerability patterns across 10 OWASP categories, without executing the application. Runs before deployment.
10 Scanned Categories (OWASP)
Severity Classification
Ex: SQL injection in public endpoint without sanitization
Ex: XSS in user input rendered without escaping
Ex: Dependency with known low-impact CVE
Ex: Console.log in production, missing security headers
Threshold: 0 Critical + 0 High for approval. Medium/Low must be documented and acknowledged.
Triple Review Protocol
Before the adversarial structural checks, QA-Implementation runs a three-pass review protocol. Each pass examines the code from a different perspective, ensuring comprehensive coverage.
Shadow Review
Silent review during code generation. Tracks patterns, identifies potential issues as they emerge without interrupting the Dev agent.
Sentinel Review
Post-implementation structural analysis. Examines architecture adherence, Design System token usage, error handling patterns, and code organization.
Compliance Review
Constitutional and specification adherence. Verifies acceptance criteria satisfaction, security requirements, and governance rule compliance.
Shell Security (23-Point Defense)
The constitution-guard.js hook applies 23 regex-based security checks to every Bash tool call, blocking shell injection patterns in under 5ms. This includes command chaining, backtick injection, process substitution, environment variable manipulation, and network exfiltration attempts.
Adversarial Review
Five mandatory structural checks, each producing a classified finding (ERROR/WARNING/SUGGESTION/ATTESTATION). The QA agent acts as a red team, actively working to find hidden flaws in every implementation. Zero findings triggers mandatory re-review.
Input Boundary
Null/undefined inputs, empty strings, very large inputs, negative numbers, special characters.
Dependency Audit
Unused imports, circular dependencies, packages with known vulnerabilities.
Error Path Coverage
Try/catch blocks tested, error callbacks exercised, failure modes documented.
Concurrency Safety
Shared mutable state, race conditions in async code, missing locks for file I/O.
Security Scan
OWASP Top 10 beyond basic SAST: ReDoS, prototype pollution, timing attacks, path traversal.
Devil's Advocate Pass
After the initial review concludes APPROVED, the QA agent flips its stance: 'This code has a hidden flaw.' One focused pass looking for race conditions, memory leaks, bad security assumptions, and performance bottlenecks under 10x load. Always included in the report.
Circuit Breaker
Circuit breaker pattern prevents repeated failures from burning resources. After 3 consecutive failures, the circuit opens and requests get rejected until a recovery probe succeeds.
CLOSED
Normal operation. All requests flow through. Failure counter tracks consecutive failures, resets on success.
OPEN
Failure threshold exceeded. All requests rejected immediately. 60-second cooldown before recovery attempt.
HALF_OPEN
Recovery probe: one test request allowed through. Success resets to CLOSED; failure returns to OPEN.