chess/planning/testing/quality-criteria.md
Christoph Wagner 5ad0700b41 refactor: Consolidate repository structure - flatten from workspace pattern
Restructured project from nested workspace pattern to flat single-repo layout.
This eliminates redundant nesting and consolidates all project files under version control.

## Migration Summary

**Before:**
```
alex/ (workspace, not versioned)
├── chess-game/ (git repo)
│   ├── js/, css/, tests/
│   └── index.html
└── docs/ (planning, not versioned)
```

**After:**
```
alex/ (git repo, everything versioned)
├── js/, css/, tests/
├── index.html
├── docs/ (project documentation)
├── planning/ (historical planning docs)
├── .gitea/ (CI/CD)
└── CLAUDE.md (configuration)
```

## Changes Made

### Structure Consolidation
- Moved all chess-game/ contents to root level
- Removed redundant chess-game/ subdirectory
- Flattened directory structure (eliminated one nesting level)

### Documentation Organization
- Moved chess-game/docs/ → docs/ (project documentation)
- Moved alex/docs/ → planning/ (historical planning documents)
- Added CLAUDE.md (workspace configuration)
- Added IMPLEMENTATION_PROMPT.md (original project prompt)

### Version Control Improvements
- All project files now under version control
- Planning documents preserved in planning/ folder
- Merged .gitignore files (workspace + project)
- Added .claude/ agent configurations

### File Updates
- Updated .gitignore to include both workspace and project excludes
- Moved README.md to root level
- All import paths remain functional (relative paths unchanged)

## Benefits

 **Simpler Structure** - One level of nesting removed
 **Complete Versioning** - All documentation now in git
 **Standard Layout** - Matches open-source project conventions
 **Easier Navigation** - Direct access to all project files
 **CI/CD Compatible** - All workflows still functional

## Technical Validation

-  Node.js environment verified
-  Dependencies installed successfully
-  Dev server starts and responds
-  All core files present and accessible
-  Git repository functional

## Files Preserved

**Implementation Files:**
- js/ (3,517 lines of code)
- css/ (4 stylesheets)
- tests/ (87 test cases)
- index.html
- package.json

**CI/CD Pipeline:**
- .gitea/workflows/ci.yml
- .gitea/workflows/release.yml

**Documentation:**
- docs/ (12+ documentation files)
- planning/ (historical planning materials)
- README.md

**Configuration:**
- jest.config.js, babel.config.cjs, playwright.config.js
- .gitignore (merged)
- CLAUDE.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 10:05:26 +01:00

507 lines
10 KiB
Markdown

# Quality Criteria and Acceptance Standards
## Overview
This document defines the quality gates and acceptance criteria that must be met before code can be merged and released.
---
## 1. Code Quality Metrics
### 1.1 Code Coverage
**Minimum Thresholds**:
```json
{
"statements": 85,
"branches": 80,
"functions": 85,
"lines": 85
}
```
**Coverage by Component**:
| Component | Minimum Coverage |
|-----------|------------------|
| Chess Engine (rules) | 95% |
| Game State Manager | 90% |
| UI Components | 80% |
| Utilities | 85% |
| Event Handlers | 80% |
**Exclusions**:
- Configuration files
- Type definitions
- Constants files
- Third-party integrations
---
### 1.2 Code Complexity
**Cyclomatic Complexity**:
- Maximum per function: 10
- Maximum per file: 50
- Warning threshold: 7
**Cognitive Complexity**:
- Maximum per function: 15
- Recommend refactoring above: 10
**File Size Limits**:
- Maximum lines per file: 500
- Warning threshold: 300
- Test files: 1000 (allowed for comprehensive test suites)
---
### 1.3 Code Style
**Linting**:
- ESLint: Zero errors
- Warnings: Max 5 per 1000 lines
- Disabled rules: None (all rules enforced)
**Formatting**:
- Prettier: 100% formatted
- Line length: 100 characters
- Indentation: 2 spaces
- Trailing commas: Required
- Semicolons: Required
**TypeScript** (if applicable):
- Strict mode: Enabled
- No implicit any: Enforced
- Type coverage: >90%
---
## 2. Performance Criteria
### 2.1 Load Time Performance
**Initial Page Load**:
- Time to First Byte (TTFB): <300ms
- First Contentful Paint (FCP): <1.5s
- Largest Contentful Paint (LCP): <2.5s
- Time to Interactive (TTI): <3.5s
- Cumulative Layout Shift (CLS): <0.1
**Bundle Size**:
- Main bundle (gzipped): <150KB
- JavaScript total: <250KB
- CSS total: <30KB
- Images: WebP format, <500KB total
---
### 2.2 Runtime Performance
**Move Calculation**:
- Legal move generation: <100ms
- Check detection: <50ms
- Checkmate detection: <200ms
- Complex positions (30+ pieces): <150ms
**UI Rendering**:
- Frame rate during animations: 60 FPS (16.67ms per frame)
- UI update after move: <16ms
- Board rotation animation: <500ms
- Piece drag responsiveness: <10ms
**Memory Usage**:
- Initial memory: <20MB
- Peak during gameplay: <50MB
- Memory leak tolerance: 0 (no leaks allowed)
- Garbage collection frequency: <1 per minute
---
### 2.3 Network Performance
**Offline Functionality**:
- Full game playable offline: Required
- Service Worker: Implemented
- Cache strategy: Cache-first for static assets
**Data Transfer** (if applicable):
- API response time: <200ms
- WebSocket latency: <50ms
- Compressed responses: Required
---
## 3. Functional Criteria
### 3.1 Chess Rules Compliance
**Core Rules**:
- All piece movements: 100% accurate
- Castling rules: Fully compliant
- En passant: Correctly implemented
- Pawn promotion: All pieces supported
- Check/Checkmate: Correctly detected
- Stalemate: Correctly detected
**Advanced Rules**:
- Fifty-move rule: Implemented
- Threefold repetition: Detected
- Insufficient material: Detected
- Dead position: Detected
**FIDE Compliance**:
- Laws of Chess conformance: 100%
- Standard algebraic notation (SAN): Supported
- Portable Game Notation (PGN): Import/export
---
### 3.2 User Experience
**Interaction**:
- Drag-and-drop: Smooth, no lag
- Click-to-move: Responsive
- Move validation feedback: Immediate (<100ms)
- Error messages: Clear, actionable
**Visual Feedback**:
- Valid moves highlighted: Required
- Check indication: Visual + auditory
- Last move highlight: Required
- Captured pieces display: Recommended
**Responsive Design**:
- Mobile (320px-767px): Fully functional
- Tablet (768px-1023px): Optimized layout
- Desktop (1024px+): Enhanced features
- Touch targets: Minimum 44x44px
---
## 4. Accessibility Standards
### 4.1 WCAG 2.1 Level AA Compliance
**Perceivable**:
- Color contrast: Minimum 4.5:1 (normal text), 3:1 (large text)
- Non-color indicators: Required for all states
- Alt text: All images and icons
- Captions: For any video/audio content
**Operable**:
- Keyboard navigation: 100% functionality
- No keyboard traps: Required
- Focus visible: Clear indicators
- Time limits: Adjustable or disabled
**Understandable**:
- Language attribute: Set correctly
- Consistent navigation: Required
- Error identification: Clear messages
- Labels/instructions: All inputs
**Robust**:
- Valid HTML: W3C compliant
- ARIA attributes: Correctly used
- Compatible assistive tech: Screen readers, voice control
---
### 4.2 Keyboard Accessibility
**Required Controls**:
- Tab: Navigate between elements
- Arrow keys: Navigate board
- Enter/Space: Select and move pieces
- Escape: Cancel selection
- Numbers: Quick piece selection (optional)
**Focus Management**:
- Visible focus indicator: Required
- Logical tab order: Enforced
- Skip links: Provided
- Focus trapping in modals: Implemented
---
### 4.3 Screen Reader Support
**Announcements**:
- Move notifications: "White pawn e2 to e4"
- Game state: "White in check"
- Captured pieces: "Black knight captured"
- Game end: "Checkmate. Black wins."
**Labels**:
- All interactive elements: Labeled
- Board squares: Descriptive (e.g., "e4, white square, empty")
- Pieces: "White pawn on e2"
---
## 5. Browser Compatibility
### 5.1 Desktop Browsers
**Fully Supported**:
- Chrome 100+ (latest, -1, -2 versions)
- Firefox 100+ (latest, -1)
- Safari 15+ (latest, -1)
- Edge 100+ (latest)
**Graceful Degradation**:
- Chrome 90-99: Core features
- Firefox 90-99: Core features
- Safari 14: Core features
**Not Supported**:
- Internet Explorer: Not supported
- Opera Mini: Not supported
---
### 5.2 Mobile Browsers
**Fully Supported**:
- iOS Safari 15+ (iPhone, iPad)
- Chrome Android 100+
- Samsung Internet 15+
**Touch Optimization**:
- Touch targets: Minimum 44x44px
- Gestures: Intuitive and documented
- Orientation: Both portrait and landscape
---
## 6. Security Criteria
### 6.1 Input Validation
**Client-Side**:
- All user input: Sanitized
- Move validation: Server-side (if multiplayer)
- XSS prevention: Required
- CSRF protection: Implemented (if applicable)
**Data Storage**:
- LocalStorage: Only non-sensitive data
- No credentials in localStorage: Enforced
- Encrypted storage: For sensitive data (if any)
---
### 6.2 Dependency Security
**Vulnerability Scanning**:
- npm audit: Zero high/critical vulnerabilities
- Snyk/Dependabot: Enabled
- Automated updates: Security patches
**Allowed Severity**:
- Critical: 0
- High: 0
- Medium: <3
- Low: <10
---
## 7. Testing Criteria
### 7.1 Test Coverage
**Test Types Distribution**:
- Unit tests: 70% of test suite
- Integration tests: 20% of test suite
- E2E tests: 10% of test suite
**Test Quality**:
- Flaky tests: 0 (must be fixed immediately)
- Test execution time: <2 minutes (all tests)
- Test isolation: 100% (no dependencies)
---
### 7.2 Test Execution
**Pre-Commit**:
- Unit tests: 100% pass rate
- Linting: Zero errors
- Type checking: Zero errors
**Pre-Merge**:
- All tests: 100% pass rate
- Coverage check: Pass
- E2E smoke tests: Pass
**Pre-Release**:
- Full E2E suite: 100% pass
- Cross-browser tests: Pass
- Accessibility audit: Pass
- Performance audit: Pass
---
## 8. Documentation Criteria
### 8.1 Code Documentation
**Comments**:
- Complex logic: Explained
- Public APIs: JSDoc documented
- Algorithms: Referenced (e.g., "Using minimax algorithm")
**README**:
- Setup instructions: Complete
- Running tests: Documented
- Build process: Clear
- Deployment: Detailed
---
### 8.2 User Documentation
**In-App Help**:
- Rules of chess: Accessible
- How to play: Interactive tutorial
- Keyboard shortcuts: Listed
**External Docs**:
- User guide: Provided
- FAQ: Maintained
- Changelog: Updated
---
## 9. Deployment Criteria
### 9.1 Pre-Deployment Checklist
- [ ] All tests pass (unit, integration, E2E)
- [ ] Code coverage meets thresholds
- [ ] Performance budgets met
- [ ] Accessibility audit passed
- [ ] Security scan clean
- [ ] Browser compatibility verified
- [ ] Documentation updated
- [ ] Changelog updated
- [ ] Release notes prepared
---
### 9.2 Deployment Process
**Staging Environment**:
- Deploy to staging first
- Manual QA testing
- Stakeholder approval
- Soak test: 24 hours minimum
**Production Deployment**:
- Blue-green deployment
- Canary release: 5% traffic initially
- Monitor error rates
- Rollback plan: Ready
---
## 10. Monitoring and Alerts
### 10.1 Production Metrics
**Error Tracking**:
- JavaScript errors: <0.1% of sessions
- Failed API calls: <1%
- Browser compatibility issues: <0.5%
**Performance Monitoring**:
- LCP degradation: Alert if >2.5s
- CLS increase: Alert if >0.1
- TTI slowdown: Alert if >4s
**User Experience**:
- Average game duration: Tracked
- Move frequency: Monitored
- Abandonment rate: <10%
---
## 11. Success Metrics
### 11.1 Quality Score
**Weighted Quality Score** (0-100):
- Code coverage: 20 points
- Performance: 20 points
- Accessibility: 15 points
- Browser compatibility: 15 points
- Security: 15 points
- Test quality: 15 points
**Minimum Acceptable Score**: 85/100
---
### 11.2 Release Readiness
**Definition of Done**:
1. Quality score 85
2. All critical bugs fixed
3. All acceptance tests passed
4. Documentation complete
5. Security scan passed
6. Performance benchmarks met
7. Accessibility audit passed
8. Stakeholder sign-off obtained
**Go/No-Go Decision**:
- Any criterion failed: No-go
- All criteria met: Approved for release
- Exceptions: Require VP approval
---
## 12. Continuous Improvement
### 12.1 Retrospective Metrics
**Track Over Time**:
- Test coverage trends
- Performance trends
- Bug escape rate
- Time to fix defects
**Quality Improvement**:
- Quarterly review of thresholds
- Adjust based on team capability
- Benchmark against industry standards
---
## Appendix: Calculation Examples
### Code Coverage Score
```
Coverage = (Statements + Branches + Functions + Lines) / 4
Example: (88 + 82 + 90 + 87) / 4 = 86.75%
```
### Performance Score
```
Score = 100 - (LCP_penalty + CLS_penalty + TTI_penalty)
LCP_penalty = max(0, (LCP - 2.5) * 20)
Example: LCP=2.2s, CLS=0.05, TTI=3.0s → Score = 95
```
### Quality Gate Pass/Fail
```python
def quality_gate_passed(metrics):
return (
metrics.coverage >= 85 and
metrics.performance_score >= 80 and
metrics.accessibility_score >= 90 and
metrics.security_vulnerabilities == 0 and
metrics.critical_bugs == 0
)
```