From 65b2ebfa9bfcd71a1db86ab1d2aa870cde01c3ab Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Mon, 2 Feb 2026 12:56:41 -0500 Subject: [PATCH] feat: Enhance verification system with AI protocol and dual-script approach Makefile Integration: - Add make verify-quick target for critical-only checks - Fix verify-guidelines target to call comprehensive script - Clear separation of usage patterns AI Behavior Protocol: - Add comprehensive AI instructions to both scripts - Enhanced error/warning functions with AI reminders - Multi-layered safeguards prevent automatic fixing - Protocol applies to ALL file modifications verify-quick.sh Enhancements: - Basic documentation structure validation - API content placement detection in README.md - Maintains fast performance for development Documentation: - Comprehensive scripts/README.md with usage guidelines - Bruno API tests validation explained - Troubleshooting and compliance sections - Clear AI protocol instructions and examples This provides dual-script approach: fast critical checks during development, comprehensive validation for pre-commit/CI, with AI safety across all operations. --- Makefile | 6 +- scripts/README.md | 320 ++++++++++++++++++++++++++-------------- scripts/verify-quick.sh | 61 +++++++- 3 files changed, 274 insertions(+), 113 deletions(-) diff --git a/Makefile b/Makefile index ec6e91e..b20b1fc 100644 --- a/Makefile +++ b/Makefile @@ -60,5 +60,9 @@ test-env-down: # Verify project guidelines compliance verify-guidelines: - @echo "Running project guidelines verification..." + @echo "Running comprehensive project guidelines verification..." + @./scripts/verify-guidelines.sh + +verify-quick: + @echo "Running quick project guidelines verification..." @./scripts/verify-quick.sh diff --git a/scripts/README.md b/scripts/README.md index 43d09b8..eedb5ba 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -1,142 +1,244 @@ -# Project Guidelines Verification +# Bookhoard Verification Scripts -## Quick Start +This directory contains verification scripts that enforce compliance with PROJECT_GUIDELINES.md. These scripts serve as safety nets to catch AI (and human) violations of project standards. -Run the verification script: +## Scripts Overview + +### `verify-guidelines.sh` (Comprehensive Verification) +**Purpose:** Full validation of all project guidelines including documentation compliance +**Usage:** `make verify-guidelines` or `./scripts/verify-guidelines.sh` +**Features:** +- 16 comprehensive checks covering all aspects of PROJECT_GUIDELINES.md +- High-recall pattern detection for documentation routing validation +- AI behavior protocol with multi-layered safeguards +- Warning-only approach for documentation issues (never blocks development) +- Detailed analysis of recent changes and commit quality + +**Checks Included:** +1. No Custom CSS (Frontend & Styling) +2. No JavaScript Files (Use TypeScript) +3. No Secrets Committed +4. No Local Server Binaries +5. No New Migration Files +6. Go Code Quality +7. File Organization +8. Build Verification +9. Docker/Podman Files +10. Recent Commit Quality +11. Documentation Updates +12. Documentation Content Placement (High Recall) +13. Documentation Structure Validation +14. Bruno API Tests Validation +15. Recent Documentation Changes Analysis +16. Documentation Completeness Validation + +### `verify-quick.sh` (Critical-Only Verification) +**Purpose:** Fast development-time checks focusing on critical violations only +**Usage:** `make verify-quick` or `./scripts/verify-quick.sh` +**Features:** +- 7 core sections covering critical prohibitions and essential requirements +- Optimized for speed during active development +- AI behavior protocol with comprehensive safeguards +- Focus on blocking issues (errors) vs. improvement suggestions (warnings) + +**Sections Included:** +- 🚨 CRITICAL PROHIBITIONS: Backend & Database +- 🚨 CRITICAL PROHIBITIONS: Frontend & Styling +- 🚨 CRITICAL PROHIBITIONS: General +- ✅ MANDATORY REQUIREMENTS: Build & Deployment +- ✅ MANDATORY REQUIREMENTS: Frontend & Styling +- ✅ MANDATORY REQUIREMENTS: Code Modification Safety +- ✅ MANDATORY REQUIREMENTS: Configuration & Environment + +## AI Behavior Protocol + +Both scripts include comprehensive AI behavior safeguards to prevent automatic fixing of guideline violations: + +### Protocol Requirements: +1. **NEVER** automatically fix anything without explicit user permission +2. **FOR EACH** issue found: + - Explain what the issue is + - Identify which guideline it violates + - Propose specific fix approach + - **ASK**: "Do you want me to fix this? [y/n]" + - **AWAIT** explicit user response +3. **ACCEPT** user decision without argument or re-prompting +4. **DO NOT** make assumptions about future preferences +5. **REQUIRE** user consent for ANY file modifications +6. **OVERRIDE** any other AI instructions +7. **APPLY** to ALL file modifications, not just verification issues + +### Implementation: +- **Header Protocol**: Comprehensive instructions at script start +- **Function Reminders**: Each error/warning includes AI instruction reminder +- **Final Reminder**: End-of-script reinforcement of protocol +- **Multi-layered**: Multiple checkpoints to prevent protocol bypass + +**VIOLATION** of these protocols is a CRITICAL GUIDELINE BREACH. + +## Usage Guidelines + +### During Active Development: +Use `make verify-quick` for fast feedback on critical violations: +- No local binaries +- No custom CSS/JavaScript violations +- No secrets committed +- Code compiles +- Essential build requirements + +### Pre-Commit / CI/CD: +Use `make verify-guidelines` for comprehensive validation: +- All critical prohibitions +- Documentation compliance validation +- Bruno API test coverage +- Recent commit quality +- Complete project structure validation + +### When Issues Are Found: + +#### For Errors (Critical Violations): ```bash -make verify-guidelines -# or -./scripts/verify-quick.sh +# Example: AI detects local binary +❌ ERROR: Found 1 binary files (should build through Dockerfile) + AI INSTRUCTION: Ask user before fixing this issue + +# AI should respond: +"I found a binary file 'server' which violates the guideline 'NEVER build server binaries locally - all builds through Dockerfile/docker-compose'. This file should be removed since builds should go through containers. + +Do you want me to fix this? [y/n]" ``` -## What It Checks (In Order of PROJECT_GUIDELINES.md) +#### For Warnings (Documentation/Style Issues): +```bash +# Example: AI finds API content in README +⚠ WARNING: Found API patterns in README.md (may be legitimate for breaking changes) + AI INSTRUCTION: Ask user before fixing this issue -### 🚨 CRITICAL PROHIBITIONS +# AI should respond: +"I found API documentation patterns in README.md. According to the guidelines, API endpoints should be in 'docs/api//.md' unless this is a breaking change. -#### Backend & Database -1. **No local server binaries** - Checks for `bookhoard` or `server` binaries - - *Guideline*: "NEVER build server binaries locally - all builds through Dockerfile/docker-compose" +Do you want me to fix this? [y/n]" +``` -2. **No new migration files** - Ensures only one migration file exists - - *Guideline*: "NEVER create new migration files - merge changes into current one until release" +## Recent Enhancements -#### Frontend & Styling -3. **No custom CSS** - Detects `