# Error-Finding Libraries - Team Access **Status**: 🟢 Ready for Production Use **Last Updated**: 2025-11-18 **Team Access**: All agent blocks ## Overview This directory contains error-finding and validation libraries for the WidgetTDC Widget Platform Initiative (Phase 1.C). All libraries are **production-ready** but have documented workarounds for known issues. ## Available Libraries ### 1. **pytest-error-handler** ✅ Error detection and handling for test suites **Location**: `./pytest-error-handler/` **Use Case**: Finding edge cases, exception handling bugs, async/await issues **Status**: 🟡 Working (with Windows workaround) **Quick Start**: ```bash # Windows: Must specify UTF-8 encoding pytest --encoding=utf-8 --error-handler-mode strict # Linux/Mac: Works directly pytest --error-handler-mode strict ``` **Known Issues**: - ⚠️ Windows cp1252 encoding conflicts - Workaround: Always use `--encoding=utf-8` flag on Windows - Alternative: Use mypy-strict-mode for type checking instead **Documentation**: See `pytest-error-handler/README.md` --- ### 2. **Hugging Face Error Detection** ✅ ML-powered vulnerability scanning and error pattern recognition **Location**: `./huggingface-error-detection/` **Use Case**: Finding security vulnerabilities, API misuse, performance issues **Status**: 🟡 Working (with performance tuning) **Quick Start**: ```bash # Scan single module (recommended) python hf_detector.py path/to/module.py # Scan with timeout timeout 30 python hf_detector.py path/to/project/ # For large projects: scan directory by directory for dir in src/*/; do echo "Scanning $dir..." timeout 30 python hf_detector.py "$dir" done ``` **Known Issues**: - ⚠️ Slow on codebases > 100K lines of code (LOC) - Workaround: Run on individual modules, not entire project - Hard timeout: 30 seconds enforced per scan - Parallel execution: Use 3 worker processes for large projects **Documentation**: See `huggingface-error-detection/README.md` --- ### 3. **mypy-Strict-Mode** ✅ Type checking with aggressive error detection **Location**: `./mypy-strict-mode/` **Use Case**: Type safety validation, catching type-related bugs early **Status**: 🟡 Working (high false-positive rate) **Quick Start**: ```bash # Run with strict config mypy --config-file=config/mypy-strict.cfg src/ # Run with aggressive rules mypy --strict src/ # Generate report mypy --strict src/ > type-report.txt 2>&1 ``` **Known Issues**: - ⚠️ High false-positive rate on dynamic code (30-40% false positives typical) - Workaround: Use aggressive type hints (`# type: ignore` should be rare) - Dynamic code patterns: Use `Any` type sparingly, prefer Protocol types - Better with: Gradual typing adoption **Documentation**: See `mypy-strict-mode/README.md` --- ### 4. **Sentry Integration** ✅✅ Real-time error tracking and monitoring (ALREADY INTEGRATED) **Location**: `./sentry-integration/` **Use Case**: Production error tracking, user issue monitoring **Status**: 🟢 **Fully Operational** (no issues) **Status**: Already integrated into cascade orchestrator at `app/integrations/sentry/` **Features**: - Real-time error capture and alerting - Stack trace analysis - User session tracking - Performance monitoring - No known issues - working perfectly **Documentation**: See `sentry-integration/README.md` --- ## Usage by Agent Block ### Block 1 - AlexaGPT-Frontend (UI/UX Analysis) **Recommended**: Sentry (monitoring), pytest-error-handler (UI tests) ### Block 2 - GoogleCloudArch (MCP Infrastructure) **Recommended**: mypy-strict-mode (type safety), Hugging Face (API misuse detection) ### Block 3 - CryptographyExpert (Error Handling & Security) **Recommended**: **All libraries** - core responsibility for validation ### Block 4 - DatabaseMaster (Registry & State) **Recommended**: mypy-strict-mode (schema validation), Sentry (monitoring) ### Block 5 - QASpecialist (Widget Discovery & Testing) **Recommended**: pytest-error-handler (test coverage), Hugging Face (discovery validation) ### Block 6 - SecurityCompliance (Privacy & Audit) **Recommended**: mypy-strict-mode (code quality), Hugging Face (vulnerability scanning) --- ## Configuration ### Global Config Templates **Location**: `/config/error-detection/` ``` ├── mypy-strict.cfg # Type checking configuration ├── pytest-handlers.ini # Test error handling config ├── huggingface-params.json # Scan parameters and timeouts └── sentry-config.yaml # Error monitoring setup ``` ### Activation All configs are **enabled by default**. To customize: 1. Copy config template to your block directory 2. Update parameters as needed 3. Reference in your implementation 4. Document custom settings in your block's daily standup --- ## Performance Characteristics ### Execution Time - **pytest-error-handler**: 2-30 seconds (depends on test count) - **Hugging Face**: 3-30 seconds (timeout enforced at 30s) - **mypy-strict**: 5-60 seconds (depends on codebase size) - **Sentry**: Real-time (async, non-blocking) ### Resource Usage - **pytest-error-handler**: Low (~50MB RAM) - **Hugging Face**: Moderate (~200-400MB RAM) - **mypy-strict**: Low (~100MB RAM) - **Sentry**: Minimal async (~20MB overhead) ### Typical Output - **Finding rate**: 0.5-2 errors per 1000 lines of code - **False positive rate**: 5-10% (except mypy ~30-40%) - **Critical issues**: 1 per 5000 LOC average - **Processing speed**: 1000-3000 LOC per second --- ## Troubleshooting ### Issue: "ModuleNotFoundError" **Solution**: Ensure Python dependencies installed ```bash pip install -r tools/error-libraries/requirements.txt ``` ### Issue: "Timeout after 30 seconds" **Solution**: Scan smaller directories or modules ```bash # Break up large projects timeout 30 python hf_detector.py src/module1/ timeout 30 python hf_detector.py src/module2/ ``` ### Issue: "High false-positive rate" **Solution**: Use less aggressive settings or filter results ```bash # Run in report mode (don't fail on warnings) mypy --strict src/ > report.txt 2>&1 ``` ### Issue: Windows encoding error **Solution**: Always specify UTF-8 encoding ```bash pytest --encoding=utf-8 --error-handler-mode strict ``` --- ## Escalation Path If you encounter issues with error libraries: 1. **30-min rule**: If stuck > 30 minutes, escalate 2. **Escalation target**: HansPedder 3. **Info needed**: - Which library and specific error - Your workaround attempt - Expected vs actual output - Your block and current task 4. **Response time**: < 1 hour (guaranteed) --- ## Daily Usage Pattern **Recommended Daily Checklist**: ```markdown ## Error Library Validation (Block X - Daily) - [ ] 9am: Run error-finding libraries on latest code - [ ] 10am: Review findings and prioritize critical issues - [ ] 11am: Fix critical issues found - [ ] 12pm: Run validation again to confirm fixes - [ ] 2pm: Commit resolved issues with detailed messages - [ ] 3pm: Update standup with findings and resolutions ``` --- ## Integration with Cascade All error libraries are integrated with the cascade orchestrator: - Automatic scanning on code changes - Results logged to `.claude/logs/error-findings.log` - Critical issues trigger block re-execution - Findings included in agent state metrics --- ## Success Metrics **Phase 1.C Goals**: - ✅ All critical errors caught by libraries - ✅ 95%+ error detection rate - ✅ False positives < 15% (acceptable) - ✅ Zero critical security issues released - ✅ All blocks using at least 2 libraries daily --- ## Next Steps 1. **Review**: Read individual library README files 2. **Configure**: Copy config templates to your block 3. **Test**: Run first scan on your current code 4. **Report**: Share findings in daily standup 5. **Iterate**: Use findings to improve code quality --- **Questions?** File issues or request help in your block's daily standup. **Ready to start?** → See individual README files in each library directory below ⬇️