#!/bin/bash set -euo pipefail BRAIN="${BRAIN:-/Users/josephanady/Desktop/AI_Brain_Control}" DB="$BRAIN/db/shards_index.sqlite" source "$BRAIN/scripts/_util.sh" bad=0 while IFS='|' read -r id file hash; do [ -z "$id" ] && continue if [ ! -f "$file" ]; then echo "❌ missing file for shard #$id → $file" bad=$((bad+1)); continue fi calc=$(sha256_file "$file") if [ "$calc" != "$hash" ]; then echo "❌ hash mismatch shard #$id ($file)" echo " db: $hash" echo " calc: $calc" bad=$((bad+1)) else echo "✅ verified shard #$id" fi done < <(sqlite3 -separator '|' "$DB" "PRAGMA busy_timeout=5000; SELECT id,file,hash FROM shards ORDER BY id ASC;") if [ $bad -gt 0 ]; then echo "=== Verification failed: $bad issues ==="; exit 1 else echo "=== Verification OK ===" fi