"""AWOOOI warning-step template copy execution plan 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_execution_plan_v1"


def load_latest_awoooi_gitea_onboarding_warning_step_template_copy_execution_plan() -> dict[str, Any]:
    """Return the controlled template copy plan source."""
    return source_ready_payload(
        schema_version=_SCHEMA_VERSION,
        source_id="warning_step_template_copy_execution_plan_service",
        status="controlled_template_copy_execution_plan_ready",
        readback={
            "execution_status": "ready_for_controlled_template_copy",
            "dry_run_only": False,
            "controlled_apply_scope": "warning_step_template_copy_only",
            "source_template_path": (
                "docs/operations/templates/"
                "awoooi-gitea-onboarding-warning-step.workflow.yaml"
            ),
            "destination_workflow_path": (
                ".gitea/workflows/awoooi-onboarding-warning-step.yaml"
            ),
            "command_preview_count": 1,
            "command_preview": [
                (
                    "cp docs/operations/templates/"
                    "awoooi-gitea-onboarding-warning-step.workflow.yaml "
                    ".gitea/workflows/awoooi-onboarding-warning-step.yaml"
                )
            ],
            "template_runtime_default": "fail_closed_job_disabled",
            "forbidden_events": [
                "push",
                "pull_request",
                "pull_request_target",
            ],
            "forbidden_runner_labels": [
                "awoooi-host",
                "awoooi-ubuntu",
                "ubuntu-latest",
                "ubuntu-*",
                "self-hosted",
            ],
            "allowed_runner_labels": [
                "awoooi-non110-host",
            ],
            "post_copy_validators": [
                "python3 ops/runner/guard-gitea-runner-pressure.py --root .",
                "git diff --check",
            ],
            "rollback_plan": (
                "remove .gitea/workflows/awoooi-onboarding-warning-step.yaml "
                "before commit"
            ),
        },
        next_actions=[
            "copy_warning_step_template_with_fail_closed_runtime_default",
            "run_runner_pressure_guard_and_git_diff_check",
            "do_not_trigger_workflow_until_next_controlled_gate",
        ],
    )
