#!/usr/bin/env bash
# scripts/run_regression.sh - regression-class VERIFY (D-091).
#
# Re-runs capability checks against the current codebase and tags each
# capability Verified / Decayed / Broken. Fails closed: any non-Verified
# capability blocks milestone completion.
#
# Usage:
#   bash scripts/run_regression.sh                  # run all checks
#   ACDL_REGRESSION_MILESTONE=v1.10 ACDL_REGRESSION_PHASE=52 \
#     bash scripts/run_regression.sh                # override metadata
#
# Output:
#   .ciagent/REGRESSION_REPORT.md   human-readable report
#   .ciagent/REGRESSION_REPORT.json  machine-readable report
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"

echo "=== ACDL Regression VERIFY (D-091) ==="
echo "milestone: ${ACDL_REGRESSION_MILESTONE:-v1.10}  phase: ${ACDL_REGRESSION_PHASE:-52}"
echo ""

python3 core/regression_verify.py
status=$?

if [ "$status" = "0" ]; then
  echo ""
  echo "=== REGRESSION PASS ==="
  echo "all capabilities Verified; milestone gate open"
else
  echo ""
  echo "=== REGRESSION FAIL ==="
  echo "non-Verified capabilities surfaced; milestone gate blocks" >&2
fi
exit "$status"