"""ORCH-089 — TC-26: invariant registries are NOT touched by the auto-label work.

The auto-mode reuses existing transitions/gates and only removes the wait for a
human signal; it must not add a stage, a transition, or a QG check (TRZ §10 / AC-10).
"""
import os
import tempfile

os.environ.setdefault("ORCH_DB_PATH", os.path.join(tempfile.gettempdir(), "test_auto_inv.db"))
os.environ.setdefault("ORCH_GITEA_TOKEN", "test-token")
os.environ.setdefault("ORCH_PLANE_API_TOKEN", "test-token")


def test_tc26_stage_transitions_unchanged():
    from src.stages import STAGE_TRANSITIONS
    # ORCH-090 (adr-0026): `cancelled` terminal sink added (parallel to `done`).
    assert set(STAGE_TRANSITIONS) == {
        "created", "analysis", "architecture", "development", "review",
        "testing", "deploy-staging", "deploy", "done", "cancelled",
    }
    # The two human gates still use their existing QG names (unchanged).
    assert STAGE_TRANSITIONS["analysis"]["qg"] == "check_analysis_approved"


def test_tc26_no_new_qg_check():
    from src.qg.checks import QG_CHECKS
    # No auto-label / auto-approve / auto-deploy QG check was introduced — the
    # auto-mode is a decision врезка, not a registered quality gate.
    assert not any(
        tok in k for k in QG_CHECKS for tok in ("auto_label", "autoapprove", "autodeploy")
    ), "ORCH-089 must not register a new QG check"
    # The gates it reuses are present and untouched.
    for k in ("check_analysis_approved", "check_deploy_status", "check_staging_status"):
        assert k in QG_CHECKS
