#!/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
#   NOVA_REGRESSION_MILESTONE=v1.10 NOVA_REGRESSION_PHASE=52 \
#     bash scripts/run_regression.sh                # override metadata
#   (ACDL_REGRESSION_* legacy fallback kept until P5)
#
# 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 "=== Nova Regression VERIFY (D-091) ==="
# NOVA_* env vars only (ACDL_* fallback removed in v1.15 P5, REQ-164).
echo "milestone: ${NOVA_REGRESSION_MILESTONE:-v1.10}  phase: ${NOVA_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"