"""CLI command: asa verify — architecture verification against .asa/spec.yaml."""

from pathlib import Path

import typer

from ..core import logging as log
from ..core.paths import find_project_root
from ..engine.spec.parser import load_spec
from ..engine.verifier.verifier import verify_project


def verify(
    ci: bool = typer.Option(False, "--ci", help="CI mode: JSON output, strict exit codes"),
) -> None:
    """Verify project architecture against .asa/spec.yaml.

    Checks foundation domains, guard APIs, entitlement integrity,
    bridge completion (upgrade mode), and verification rules.
    CI-ready with --ci flag for JSON output.
    """
    project_root = find_project_root()

    spec = load_spec(project_root)
    if spec is None:
        log.error(
            "No .asa/spec.yaml found. Run 'asa spec infer' or 'asa init' first."
        )
        raise typer.Exit(code=2)

    log.header("ASA Architecture Verification")
    exit_code = verify_project(project_root, spec, ci=ci)
    raise typer.Exit(code=exit_code)
