#!/bin/bash # Verification script for Phase 1 implementation echo "============================================================" echo "Phase 1 Implementation Verification" echo "============================================================" echo "" # Check directory structure echo "1. Checking directory structure..." if [ -d "config" ] && [ -d "api/agnet" ]; then echo " ✅ Directories created: config/, api/agnet/" else echo " ❌ Missing directories" exit 1 fi # Check config files echo "" echo "2. Checking config files..." files=( "config/__init__.py" "config/error_codes.py" "config/settings.py" ) for file in "${files[@]}"; do if [ -f "$file" ]; then echo " ✅ $file" else echo " ❌ Missing: $file" exit 1 fi done # Check api/agnet files echo "" echo "3. Checking api/agnet files..." files=( "api/__init__.py" "api/agnet/__init__.py" "api/agnet/auth.py" "api/agnet/models.py" "api/agnet/validators.py" "api/agnet/idempotency.py" "api/agnet/router.py" ) for file in "${files[@]}"; do if [ -f "$file" ]; then echo " ✅ $file" else echo " ❌ Missing: $file" exit 1 fi done # Check requirements.txt updated echo "" echo "4. Checking requirements.txt..." if grep -q "redis" requirements.txt && grep -q "pydantic-settings" requirements.txt; then echo " ✅ Dependencies added: redis, pydantic-settings" else echo " ❌ Dependencies not added to requirements.txt" exit 1 fi # Check app.py integration echo "" echo "5. Checking app.py integration..." if grep -q "from api.agnet.router import router as agnet_router" app.py && \ grep -q "app.include_router(agnet_router)" app.py; then echo " ✅ Agnet router registered in app.py" else echo " ❌ Agnet router not registered in app.py" exit 1 fi # Check key implementations echo "" echo "6. Checking key implementations..." # Error codes if grep -q "class ErrorCode" config/error_codes.py && \ grep -q "INVALID_TOKEN" config/error_codes.py && \ grep -q "RESOURCE_GRANT_SECRET_REJECTED" config/error_codes.py; then echo " ✅ Error codes defined" else echo " ❌ Error codes incomplete" exit 1 fi # Settings if grep -q "HEICODE_SERVICE_TOKEN" config/settings.py && \ grep -q "REDIS_URL" config/settings.py && \ grep -q "IDEMPOTENCY_TTL_SECONDS" config/settings.py; then echo " ✅ Settings configured" else echo " ❌ Settings incomplete" exit 1 fi # Auth middleware if grep -q "verify_service_token" api/agnet/auth.py && \ grep -q "extract_headers" api/agnet/auth.py; then echo " ✅ Auth middleware implemented" else echo " ❌ Auth middleware incomplete" exit 1 fi # Validators if grep -q "scan_for_sensitive_fields" api/agnet/validators.py && \ grep -q "SENSITIVE_KEYWORDS" api/agnet/validators.py; then echo " ✅ Validators implemented" else echo " ❌ Validators incomplete" exit 1 fi # Idempotency cache if grep -q "class IdempotencyCache" api/agnet/idempotency.py && \ grep -q "def get" api/agnet/idempotency.py && \ grep -q "def set" api/agnet/idempotency.py; then echo " ✅ Idempotency cache implemented" else echo " ❌ Idempotency cache incomplete" exit 1 fi # Router if grep -q "@router.get(\"/health\"" api/agnet/router.py && \ grep -q "prefix=\"/api/agnet\"" api/agnet/router.py; then echo " ✅ Router with health check implemented" else echo " ❌ Router incomplete" exit 1 fi echo "" echo "============================================================" echo "✅ Phase 1 Implementation Complete!" echo "============================================================" echo "" echo "Summary:" echo " - Directory structure: config/, api/agnet/" echo " - Error codes: 8 codes defined" echo " - Settings: Service token, Redis, model gateways" echo " - Auth: Service token middleware + header extraction" echo " - Validators: Sensitive field scanner (recursive)" echo " - Idempotency: Redis-based cache with 24h TTL" echo " - Router: /api/agnet/health endpoint" echo " - Dependencies: redis, pydantic-settings added" echo "" echo "Next steps:" echo " 1. Install dependencies: pip install -r requirements.txt" echo " 2. Set HEICODE_SERVICE_TOKEN in .env" echo " 3. Start Redis (optional for Phase 1 testing)" echo " 4. Test health check: curl -H 'Authorization: Bearer ' http://localhost:8000/api/agnet/health" echo ""