"""AWOOOI warning-step template copy apply gate source."""

from __future__ import annotations

from typing import Any

from src.services.awoooi_onboarding_source_contracts import source_ready_payload

_SCHEMA_VERSION = "awoooi_gitea_onboarding_warning_step_template_copy_apply_gate_v1"


def load_latest_awoooi_gitea_onboarding_warning_step_template_copy_apply_gate() -> dict[str, Any]:
    """Return the controlled apply gate for warning-step template copy."""
    return source_ready_payload(
        schema_version=_SCHEMA_VERSION,
        source_id="warning_step_template_copy_apply_gate_service",
        status="controlled_template_copy_apply_gate_ready",
        readback={
            "apply_allowed": True,
            "controlled_apply_allowed": True,
            "controlled_apply_scope": "warning_step_template_copy_only",
            "confirmed_command_count": 1,
            "required_command_count": 1,
            "confirmed_validation_count": 2,
            "required_validation_count": 2,
            "workflow_template_copy_authorized": True,
            "workflow_trigger_authorized": False,
            "auto_push_or_pull_request_trigger_authorized": False,
            "generic_runner_label_authorized": False,
            "runner_pressure_guard_required": True,
            "required_post_copy_validators": [
                "python3 ops/runner/guard-gitea-runner-pressure.py --root .",
                "git diff --check",
            ],
            "rollback_plan": "remove_copied_warning_step_template_before_commit",
            "hard_blockers_preserved": [
                "no_push_or_pull_request_trigger_to_awoooi_runner",
                "no_generic_runner_label",
                "no_workflow_dispatch_from_this_gate",
                "no_github_api_or_gh",
                "no_secret_or_token_read",
                "no_host_or_k8s_write",
            ],
        },
        next_actions=[
            "copy_warning_step_template_with_no_auto_branch_events",
            "run_runner_pressure_guard_and_git_diff_check",
            "keep_workflow_trigger_disabled_until_next_controlled_gate",
        ],
        boundary_profile="controlled_template_copy",
    )
