feat(guard): enhance build architecture guard with Android protection and feedback system

- Add Android-specific build validation for asset management and API routing
- Implement feedback collection system for continuous guard improvement
- Enhance sensitive path detection to include capacitor-assets.config.json and resources/
- Add Android change detection with specific testing guidance
- Integrate feedback analysis command for maintainer insights
- Update guard rules to reflect enhanced Android build system complexity

The guard now protects sophisticated Android build features including asset validation,
resource generation, and platform-specific API routing while collecting usage data
for continuous improvement.
This commit is contained in:
Matthew Raymer
2025-08-22 08:43:21 +00:00
parent 8fc9118d50
commit 9f2ef24b2b
4 changed files with 291 additions and 20 deletions

View File

@@ -88,6 +88,7 @@ The Build Architecture Guard protects your build system by enforcing documentati
- **Protected Files**: Build scripts, config files, and platform-specific code
- **Documentation Requirement**: `BUILDING.md` must be updated alongside build changes
- **Automatic Enforcement**: Git hooks prevent commits without proper documentation
- **Feedback Collection**: Continuously improves through usage pattern analysis
#### Protected File Patterns
@@ -98,14 +99,29 @@ The guard monitors these sensitive paths:
- `android/**` - Android platform code
- `ios/**` - iOS platform code
- `capacitor.config.ts` - Mobile configuration
- `capacitor-assets.config.json` - Android asset configuration
- `resources/**` - Source assets for Android resource generation
- `package.json` - Dependencies and scripts
#### Enhanced Android Protection
The guard now provides enhanced protection for Android build system changes:
- **Asset Validation**: Protects `validate_android_assets()` function and resource paths
- **Resource Generation**: Monitors `capacitor-assets` integration and verification
- **API Routing**: Protects platform-specific IP handling (emulator vs physical device)
- **Build Modes**: Validates development/test/production mode handling
- **Resource Fallback**: Protects automatic regeneration of missing Android resources
#### Using the Guard
```bash
# Test the guard locally
./scripts/build-arch-guard.sh --staged
# Analyze guard effectiveness (for maintainers)
./scripts/build-arch-guard.sh --feedback
# Bypass for emergency commits (use sparingly)
git commit --no-verify
@@ -124,7 +140,16 @@ chmod +x scripts/build-arch-guard.sh
./scripts/build-arch-guard.sh --help
```
**Note**: The guard is active and will block commits that modify build files without updating `BUILDING.md`.
#### Feedback and Continuous Improvement
The guard system includes feedback mechanisms for continuous improvement:
- **Automatic Logging**: All guard executions are logged for analysis
- **Pattern Analysis**: Identifies false positives/negatives and missing patterns
- **Maintainer Insights**: Use `--feedback` command to analyze guard effectiveness
- **Continuous Updates**: Guard rules and patterns are updated based on feedback
**Note**: The guard is active and will block commits that modify build files without updating `BUILDING.md`. Recent enhancements provide better Android build system protection and feedback collection for continuous improvement.
### Environment Configuration