Files
weval-l99/l99-beton.sh
2026-04-13 12:43:21 +02:00

105 lines
4.1 KiB
Bash
Executable File

#!/bin/bash
# L99 BETON ORCHESTRATOR — chains existing L99 scripts into unified result
# Paradigm: ENRICH existing scripts, never fragment. Opus = wiring. Master = executor.
set +e
cd /opt/weval-l99
mkdir -p results logs beton
TS=$(date +%Y%m%d-%H%M%S)
OUT=/opt/weval-l99/beton/l99-beton-$TS.json
LOG=/opt/weval-l99/logs/l99-beton-$TS.log
LATEST=/opt/weval-l99/beton/l99-beton-latest.json
echo "[BETON] start $TS" | tee $LOG
run_layer() {
local id="$1" name="$2" cmd="$3" timeout="${4:-300}"
echo "[L$id] $name START $(date +%H:%M:%S)" | tee -a $LOG
local t0=$(date +%s)
timeout $timeout bash -c "$cmd" >> $LOG 2>&1
local rc=$?
local dur=$(($(date +%s)-t0))
echo "[L$id] $name END rc=$rc dur=${dur}s" | tee -a $LOG
echo "{\"layer\":\"L$id\",\"name\":\"$name\",\"rc\":$rc,\"duration_s\":$dur}" >> /tmp/l99-beton-layers.jsonl
}
> /tmp/l99-beton-layers.jsonl
# L1 INFRA — disk, docker, services
run_layer "01" "INFRA" "df -h / && docker ps --format '{{.Names}} {{.Status}}' && systemctl is-active nginx php8.3-fpm postgresql" 60
# L2 AUTH SOUVERAIN
run_layer "02" "AUTH_SSO" "bash /opt/wevia-brain/l99-sso-test.sh 2>&1 || bash /opt/weval-l99/weval-sso-health.sh" 120
# L3 PAGES VISUAL — 126 HTML + screenshots
run_layer "03" "PAGES_VISUAL" "python3 /opt/weval-l99/l99-wevia-master-visual.py" 900
# L4 APIs
run_layer "04" "APIS" "python3 /opt/weval-l99/l99-deep-scan.py 2>/dev/null || python3 /opt/weval-l99/l99-exhaustive.py" 600
# L5 BRAINS — 167 modules + dormants
run_layer "05" "BRAINS" "python3 /opt/weval-l99/l99-ai-scanner.py 2>/dev/null || python3 /opt/weval-l99/gap-detector.py" 300
# L6 AGENTS — 13 IAs souveraines
run_layer "06" "AGENTS" "python3 /opt/weval-l99/agent-scanner.py" 180
# L7 PROVIDERS LLM cascade 7
run_layer "07" "PROVIDERS" "curl -s https://weval-consulting.com/api/key-check.php?all=1 | head -100" 60
# L8 DATA RAG — Qdrant 15953 vecteurs
run_layer "08" "DATA_RAG" "curl -s http://127.0.0.1:6333/collections | python3 -c 'import sys,json;d=json.load(sys.stdin);print(json.dumps(d))'" 60
# L9 DOCKER — 17 containers
run_layer "09" "DOCKER" "docker ps -a --format '{{.Names}}|{{.Status}}|{{.State}}'" 60
# L10 CRONS
run_layer "10" "CRONS" "crontab -l | grep -vc '^#' && ls -la /var/log/wevia-director/ 2>/dev/null | tail -20" 30
# L11 BUSINESS E2E — full pipeline
run_layer "11" "BUSINESS_E2E" "python3 /opt/weval-l99/l99-master.py" 1800
# L12 SECURITY
run_layer "12" "SECURITY" "python3 /opt/weval-l99/l99-security-scan.py 2>/dev/null || echo security-scan-placeholder" 300
# Aggregate
python3 <<PYEOF
import json, os, glob, time
layers = []
with open('/tmp/l99-beton-layers.jsonl') as f:
for line in f:
try: layers.append(json.loads(line))
except: pass
# Pull latest results from each script
def load_json(p):
try:
with open(p) as f: return json.load(f)
except: return None
results = {
"master_pipeline": load_json('/opt/weval-l99/results/pipeline-result.json'),
"master_visual": load_json('/var/www/html/api/l99-results/l99-full-results.json'),
"godmode": load_json('/opt/weval-l99/godmode-results.json'),
"functional": load_json('/opt/weval-l99/functional-test-results.json'),
}
total_pass = 0
total_fail = 0
total_warn = 0
for k, v in results.items():
if not v: continue
total_pass += v.get('pass', v.get('passed', 0))
total_fail += v.get('fail', v.get('failed', 0))
total_warn += v.get('warn', v.get('warnings', 0))
beton = {
"timestamp": "$TS",
"layers": layers,
"layer_count": len(layers),
"aggregated_results": results,
"totals": {"pass": total_pass, "fail": total_fail, "warn": total_warn},
"score_pct": round(total_pass*100/max(1,total_pass+total_fail+total_warn), 2)
}
with open('$OUT', 'w') as f: json.dump(beton, f, indent=2)
with open('$LATEST', 'w') as f: json.dump(beton, f, indent=2)
print(f"BETON DONE: L{len(layers)} | {total_pass}P/{total_fail}F/{total_warn}W")
PYEOF
cp $OUT /var/www/html/api/l99-results/l99-beton-latest.json 2>/dev/null
echo "[BETON] done → $OUT" | tee -a $LOG
cat $LATEST | python3 -c "import sys,json;d=json.load(sys.stdin);print('LAYERS:',d['layer_count'],'| TOTALS:',d['totals'],'| SCORE:',d.get('score_pct','?'),'%')"