name: Trinity Compliance Check on: push: branches: [main, master, develop] pull_request: branches: [main, master, develop] schedule: - cron: '0 0 * * 0' # Weekly on Sunday at midnight jobs: check-compliance: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Check Trinity Structure run: | echo "๐ŸŒˆ Light Trinity Compliance Check" echo "=================================" echo "" ERRORS=0 # Check .trinity/ exists if [ ! -d ".trinity" ]; then echo "โŒ CRITICAL: .trinity/ directory missing" ERRORS=$((ERRORS + 1)) else echo "โœ… .trinity/ directory present" fi # Check RedLight echo "" echo "๐Ÿ”ด Checking RedLight..." if [ ! -d ".trinity/redlight" ]; then echo " โŒ RedLight directory missing" ERRORS=$((ERRORS + 1)) else echo " โœ… RedLight directory present" # Count templates if [ -d ".trinity/redlight/templates" ]; then template_count=$(find .trinity/redlight/templates -name "*.html" 2>/dev/null | wc -l) echo " ๐Ÿ“„ Found $template_count HTML templates" if [ "$template_count" -lt 10 ]; then echo " โš ๏ธ Warning: Expected at least 10 templates, found $template_count" fi else echo " โŒ Templates directory missing" ERRORS=$((ERRORS + 1)) fi # Check docs if [ -f ".trinity/redlight/docs/REDLIGHT_TEMPLATE_SYSTEM.md" ]; then echo " โœ… Documentation present" else echo " โŒ Documentation missing" ERRORS=$((ERRORS + 1)) fi fi # Check GreenLight echo "" echo "๐Ÿ’š Checking GreenLight..." if [ ! -d ".trinity/greenlight" ]; then echo " โŒ GreenLight directory missing" ERRORS=$((ERRORS + 1)) else echo " โœ… GreenLight directory present" # Count docs if [ -d ".trinity/greenlight/docs" ]; then doc_count=$(find .trinity/greenlight/docs -name "*.md" 2>/dev/null | wc -l) echo " ๐Ÿ“š Found $doc_count documentation files" if [ "$doc_count" -lt 10 ]; then echo " โš ๏ธ Warning: Expected at least 10 docs, found $doc_count" fi else echo " โŒ Docs directory missing" ERRORS=$((ERRORS + 1)) fi # Check template script if [ -f ".trinity/greenlight/scripts/memory-greenlight-templates.sh" ]; then echo " โœ… Template script present" # Count templates in script template_funcs=$(grep -c "^gl_" .trinity/greenlight/scripts/memory-greenlight-templates.sh 2>/dev/null || echo "0") echo " ๐Ÿ”ง Found $template_funcs template functions" else echo " โŒ Template script missing" ERRORS=$((ERRORS + 1)) fi fi # Check YellowLight echo "" echo "๐Ÿ’› Checking YellowLight..." if [ ! -d ".trinity/yellowlight" ]; then echo " โŒ YellowLight directory missing" ERRORS=$((ERRORS + 1)) else echo " โœ… YellowLight directory present" # Check docs if [ -f ".trinity/yellowlight/docs/YELLOWLIGHT_INFRASTRUCTURE_SYSTEM.md" ]; then echo " โœ… Documentation present" else echo " โŒ Documentation missing" ERRORS=$((ERRORS + 1)) fi # Check scripts script_count=$(find .trinity/yellowlight/scripts -name "*.sh" 2>/dev/null | wc -l) echo " ๐Ÿ”ง Found $script_count infrastructure scripts" fi # Check Trinity System echo "" echo "๐ŸŒˆ Checking Trinity System..." if [ ! -d ".trinity/system" ]; then echo " โŒ System directory missing" ERRORS=$((ERRORS + 1)) else echo " โœ… System directory present" # Check core docs if [ -f ".trinity/system/THE_LIGHT_TRINITY.md" ]; then echo " โœ… Trinity overview present" else echo " โŒ Trinity overview missing" ERRORS=$((ERRORS + 1)) fi if [ -f ".trinity/system/LIGHT_TRINITY_ENFORCEMENT.md" ]; then echo " โœ… Enforcement docs present" else echo " โŒ Enforcement docs missing" ERRORS=$((ERRORS + 1)) fi fi # Check README echo "" echo "๐Ÿ“– Checking README..." if [ -f ".trinity/README.md" ]; then echo " โœ… Trinity README present" else echo " โš ๏ธ Warning: Trinity README missing" fi # Summary echo "" echo "=================================" if [ $ERRORS -eq 0 ]; then echo "โœ… Trinity compliance check PASSED" echo "๐ŸŒˆ All three lights present and functional" exit 0 else echo "โŒ Trinity compliance check FAILED" echo "๐Ÿ”ฅ Found $ERRORS critical issues" echo "" echo "To fix, see: .trinity/README.md" echo "Source of truth: https://github.com/blackroad-os/blackroad-os-infra" exit 1 fi - name: Run Trinity Tests if: success() run: | if [ -f ".trinity/system/trinity-record-test.sh" ]; then echo "๐Ÿงช Running Trinity tests..." bash .trinity/system/trinity-record-test.sh else echo "โš ๏ธ No test script found, skipping tests" fi - name: Generate Compliance Report if: always() run: | echo "๐Ÿ“Š Trinity Compliance Report" > trinity-report.txt echo "============================" >> trinity-report.txt echo "" >> trinity-report.txt echo "Repository: ${{ github.repository }}" >> trinity-report.txt echo "Branch: ${{ github.ref_name }}" >> trinity-report.txt echo "Commit: ${{ github.sha }}" >> trinity-report.txt echo "Date: $(date -u)" >> trinity-report.txt echo "" >> trinity-report.txt # Structure check echo "Structure:" >> trinity-report.txt echo " RedLight: $([ -d .trinity/redlight ] && echo 'โœ…' || echo 'โŒ')" >> trinity-report.txt echo " GreenLight: $([ -d .trinity/greenlight ] && echo 'โœ…' || echo 'โŒ')" >> trinity-report.txt echo " YellowLight: $([ -d .trinity/yellowlight ] && echo 'โœ…' || echo 'โŒ')" >> trinity-report.txt echo " System: $([ -d .trinity/system ] && echo 'โœ…' || echo 'โŒ')" >> trinity-report.txt echo "" >> trinity-report.txt # File counts echo "File Counts:" >> trinity-report.txt echo " RedLight templates: $(find .trinity/redlight/templates -name '*.html' 2>/dev/null | wc -l)" >> trinity-report.txt echo " GreenLight docs: $(find .trinity/greenlight/docs -name '*.md' 2>/dev/null | wc -l)" >> trinity-report.txt echo " YellowLight scripts: $(find .trinity/yellowlight/scripts -name '*.sh' 2>/dev/null | wc -l)" >> trinity-report.txt cat trinity-report.txt - name: Upload Compliance Report if: always() uses: actions/upload-artifact@v4 with: name: trinity-compliance-report path: trinity-report.txt retention-days: 30