1+ #! /usr/bin/env bash
2+ # SPDX-License-Identifier: PMPL-1.0-or-later
3+ # Check API/ABI/FFI language compliance across repositories
4+
5+ set -euo pipefail
6+
7+ REPOS_BASE=" ${REPOS_BASE:-/ var/ mnt/ eclipse/ repos} "
8+ LOG_FILE=" /tmp/language-compliance-$( date +%Y%m%d) .log"
9+
10+ echo " === Language Compliance Check ===" | tee " $LOG_FILE "
11+ echo " Started: $( date) " | tee -a " $LOG_FILE "
12+ echo " " | tee -a " $LOG_FILE "
13+
14+ # Initialize counters
15+ API_VIOLATIONS=0
16+ ABI_VIOLATIONS=0
17+ FFI_VIOLATIONS=0
18+ COMPLIANT_REPOS=0
19+ TOTAL_REPOS=0
20+
21+ # Check a single repository
22+ check_repo () {
23+ local repo_path=" $1 "
24+ local repo_name=" $( basename " $repo_path " ) "
25+ local violations=0
26+
27+ echo " Checking: $repo_name " | tee -a " $LOG_FILE "
28+
29+ # Check for non-V APIs (exclude internal scripts)
30+ if find " $repo_path " -name " *.ex" -o -name " *.exs" | grep -q . ; then
31+ echo " ✓ Elixir found - checking API compliance" | tee -a " $LOG_FILE "
32+ # Elixir repos should use V for external APIs
33+ if [ ! -f " $repo_path /api/vlang" ] && find " $repo_path " -name " *.ex" | head -1 | grep -q . ; then
34+ echo " ⚠️ Potential API violation: Elixir repo without V API layer" | tee -a " $LOG_FILE "
35+ (( API_VIOLATIONS++ ))
36+ (( violations++ ))
37+ fi
38+ fi
39+
40+ # Check for non-Idris2 ABIs
41+ if find " $repo_path " -name " *.zig" | grep -q . ; then
42+ echo " ✓ Zig found - checking ABI compliance" | tee -a " $LOG_FILE "
43+ # Zig repos should use Idris2 for ABIs
44+ if [ ! -f " $repo_path /abi/idris2" ] && find " $repo_path " -name " *.zig" | head -1 | grep -q . ; then
45+ echo " ⚠️ Potential ABI violation: Zig repo without Idris2 ABI layer" | tee -a " $LOG_FILE "
46+ (( ABI_VIOLATIONS++ ))
47+ (( violations++ ))
48+ fi
49+ fi
50+
51+ # Check for non-Zig FFIs
52+ if find " $repo_path " -name " *.c" -o -name " *.h" | grep -q . ; then
53+ echo " ⚠️ Potential FFI violation: C headers found" | tee -a " $LOG_FILE "
54+ echo " Should use Zig with C compatibility layer only" | tee -a " $LOG_FILE "
55+ (( FFI_VIOLATIONS++ ))
56+ (( violations++ ))
57+ fi
58+
59+ # Check for proper C compatibility warnings
60+ if grep -r " c_compat" " $repo_path " 2> /dev/null | grep -q . ; then
61+ if ! grep -r " compileError.*C.*compatibility" " $repo_path " 2> /dev/null | grep -q . ; then
62+ echo " ⚠️ C compatibility without proper warnings" | tee -a " $LOG_FILE "
63+ (( FFI_VIOLATIONS++ ))
64+ (( violations++ ))
65+ fi
66+ fi
67+
68+ if [ $violations -eq 0 ]; then
69+ echo " ✅ Compliant" | tee -a " $LOG_FILE "
70+ (( COMPLIANT_REPOS++ ))
71+ else
72+ echo " ❌ $violations violations found" | tee -a " $LOG_FILE "
73+ fi
74+
75+ (( TOTAL_REPOS++ ))
76+ echo " " | tee -a " $LOG_FILE "
77+ }
78+
79+ # Export function for parallel execution
80+ export -f check_repo
81+ export REPOS_BASE
82+
83+ # Find all repositories
84+ echo " Scanning repositories in $REPOS_BASE ..." | tee -a " $LOG_FILE "
85+
86+ # Check core repositories first
87+ for repo in hypatia gitbot-fleet " .git-private-farm" ; do
88+ if [ -d " $REPOS_BASE /$repo " ]; then
89+ check_repo " $REPOS_BASE /$repo "
90+ fi
91+ done
92+
93+ # Check other repositories in parallel
94+ find " $REPOS_BASE " -maxdepth 1 -type d ! -name " ." ! -name " .." ! -name " .git*" ! -name " nextgen-databases" ! -name " developer-ecosystem" | while read -r repo_dir; do
95+ check_repo " $repo_dir "
96+ done
97+
98+ # Summary
99+ echo " " | tee -a " $LOG_FILE "
100+ echo " === Summary ===" | tee -a " $LOG_FILE "
101+ echo " Total repositories: $TOTAL_REPOS " | tee -a " $LOG_FILE "
102+ echo " Compliant: $COMPLIANT_REPOS " | tee -a " $LOG_FILE "
103+ echo " " | tee -a " $LOG_FILE "
104+ echo " Violations:" | tee -a " $LOG_FILE "
105+ echo " API (non-V): $API_VIOLATIONS " | tee -a " $LOG_FILE "
106+ echo " ABI (non-Idris2): $ABI_VIOLATIONS " | tee -a " $LOG_FILE "
107+ echo " FFI (non-Zig): $FFI_VIOLATIONS " | tee -a " $LOG_FILE "
108+ echo " " | tee -a " $LOG_FILE "
109+
110+ COMPLIANCE_PERCENT=$(( (COMPLIANT_REPOS * 100 ) / TOTAL_REPOS ))
111+ echo " Compliance: $COMPLIANCE_PERCENT %" | tee -a " $LOG_FILE "
112+
113+ if [ $COMPLIANCE_PERCENT -ge 90 ]; then
114+ echo " Status: ✅ PASSING" | tee -a " $LOG_FILE "
115+ exit 0
116+ elif [ $COMPLIANCE_PERCENT -ge 70 ]; then
117+ echo " Status: ⚠️ WARNING" | tee -a " $LOG_FILE "
118+ exit 1
119+ else
120+ echo " Status: ❌ FAILING" | tee -a " $LOG_FILE "
121+ exit 2
122+ fi
0 commit comments