#!/usr/bin/env bash
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Works both:
# - in-repo:   finish_ready/scripts/validate_artifacts.sh
# - extracted: scripts/validate_artifacts.sh
if [[ -d "$HERE/../engine" && -d "$HERE/../paper" ]]; then
  ROOT_DIR="$(cd "$HERE/.." && pwd)"
elif [[ -d "$HERE/../../engine" && -d "$HERE/../paper" ]]; then
  ROOT_DIR="$(cd "$HERE/../.." && pwd)"
else
  echo "Could not locate repository root (engine/ not found)." 1>&2
  exit 2
fi

ART="$ROOT_DIR/engine/artifacts"
AUDIT="$ROOT_DIR/engine/audit/audit_wsc.py"

python3 "$AUDIT" "$ART/WSC-G-AWT-0001.json"
python3 "$AUDIT" "$ART/WSC-E-LDW-0001.json"
python3 "$AUDIT" "$ART/WSC-C-CMT-0001.json"
python3 "$AUDIT" "$ART/WSC-E-HW-0002.json"
python3 "$AUDIT" "$ART/WSC-C-AFFINE-0002.json"
echo "OK: core WSC artifacts validated"
