"""Nova Regression Verify CLI — command-line entry point.

Extracted from core/regression_verify.py (P13, REQ-177).

G-113 import direction: this module imports core.regression_verify (the
library) for run_regression + write_report. The library does not import
this CLI module. Nothing imports this CLI except direct invocation.
"""
from __future__ import annotations

import sys

from core import env as _envhelper
from core.regression_verify import run_regression, write_report


def main(argv=None):
    """CLI: run the regression gate and write the report."""
    milestone = _envhelper.get_env("REGRESSION_MILESTONE", "v1.10") or "v1.10"
    phase = int(_envhelper.get_env("REGRESSION_PHASE", "52") or "52")
    report = run_regression(milestone=milestone, phase=phase)
    md, js = write_report(report)
    print(f"regression: {report.summary} -> {md}")
    if not report.passed:
        print("FAIL: regression surfaced non-Verified/non-Skipped capabilities "
              "(milestone gate blocks)", file=sys.stderr)
        return 1
    print(f"regression: gate passes (summary={report.summary})")
    return 0


if __name__ == "__main__":
    sys.exit(main())