# -*- coding: utf-8 -*-
"""anu_v3.operational_collector_wiring — operational collector wiring 보강.

task-2553+45 (회장 §5 — ``anu_v3/operational_collector_wiring.py`` 보강).

회장 §3 verbatim: "실제 normal collector 경로가
``operational_collector_wiring::run_operational_completion_callback_collector``
를 경유하게 한다." 기존 +25 산출(``utils/operational_collector_wiring.py``)·
+37 산출(``utils/normal_completion_callback_collector_entrypoint.py``)은 §8/
§5 에 의해 **무수정**이다. 본 모듈은 anu_v3 namespace 의 **strict-additive
read-only 보강 레이어**로서:

  1. +25 ``run_operational_completion_callback_collector`` 와 +37
     ``run_wired_normal_completion_callback_collector`` 공개 심볼을
     read-only re-export 한다 (기존 호출지점 무변, 신규 import 경로 제공).
  2. live normal collector cron prompt 가 결선해야 할 단일 live
     entrypoint(``anu_v3.cancel_on_success_live_wiring.
     run_cancel_on_success_live_wiring``)를 ``resolve_live_collector_
     entrypoint()`` 로 노출한다 — durable 4-tuple registry(+44) lookup +
     canonical-first root(+46) + +37→+25→+23 seam 경유가 보장되는 경로.

Layer A / NO-CRON (9-R.1): re-export·resolver 만. ZERO cron register/
remove, ZERO dispatch, ZERO merge, ZERO ``cokacdir``/``subprocess`` exec.
원본 +25/+37 모듈 byte-0 (import 만, 1 byte 수정 0).
"""
from __future__ import annotations

from typing import Callable

# +45 live wiring (durable lookup + canonical root + +37 경유).
from anu_v3.cancel_on_success_live_wiring import (  # pyright: ignore[reportMissingImports]  # noqa: E501
    CancelOnSuccessLiveResult,
    DurableFallbackLookup,
    lookup_fallback_from_durable_registry,
    run_cancel_on_success_live_wiring,
)

# +25 operational collector wiring — read-only re-export (byte-0 무수정).
from utils.operational_collector_wiring import (  # pyright: ignore[reportMissingImports]  # noqa: E501
    OperationalSeamParams,
    OperationalWiringResult,
    compute_event_id,
    run_operational_completion_callback_collector,
)

# +37 standard wired entrypoint — read-only re-export (byte-0 무수정).
from utils.normal_completion_callback_collector_entrypoint import (  # pyright: ignore[reportMissingImports]  # noqa: E501
    NormalCallbackBinding,
    WiredCollectorResult,
    run_wired_normal_completion_callback_collector,
)

WIRING_SCHEMA = "anu_v3.operational_collector_wiring.v1"

#: live normal collector cron prompt 가 결선해야 하는 단일 entrypoint
#: dotted-path (회장 §3 — operational_collector_wiring 경유 결선 증명).
LIVE_COLLECTOR_ENTRYPOINT = (
    "anu_v3.cancel_on_success_live_wiring."
    "run_cancel_on_success_live_wiring"
)

#: 그 entrypoint 가 내부적으로 경유하는 결선 체인 (계약 증명).
LIVE_WIRING_CHAIN = (
    "run_cancel_on_success_live_wiring → durable 4-tuple registry "
    "lookup (anu_v3.callback_4tuple_registry, +44) + canonical-first "
    "root (anu_v3.artifact_root_resolver, +46) → "
    "utils.normal_completion_callback_collector_entrypoint."
    "run_wired_normal_completion_callback_collector (+37, PRIMARY) → "
    "utils.operational_collector_wiring."
    "run_operational_completion_callback_collector (+25) → "
    "utils.completion_callback_operational_cancel_seam."
    "run_operational_cancel_seam(operational=True) (+23) → "
    "utils.live_cron_state_verifier 5조건 AND → +9a bound cron-remove"
)


def resolve_live_collector_entrypoint() -> Callable:
    """live normal collector cron 이 결선해야 하는 단일 callable 을 반환.

    회장 §3 결선 — 이 callable 을 경유하면 durable-success 후
    operational cancel seam 이 durable-bound·verified 1건에 한해 작동한다.
    """
    return run_cancel_on_success_live_wiring


def live_wiring_contract() -> dict:
    """결선 계약 (collector cron prompt 가 박아야 하는 routing 계약)."""
    return {
        "schema": WIRING_SCHEMA,
        "live_collector_entrypoint": LIVE_COLLECTOR_ENTRYPOINT,
        "wiring_chain": LIVE_WIRING_CHAIN,
        "fallback_cron_id_lookup_source": "durable_4tuple_registry (+44)",
        "artifact_root_resolution": "canonical-first (+46)",
        "primary_path": (
            "run_cancel_on_success_live_wiring (registry/checkpoint = "
            "recovery layer only, never replaces this)"
        ),
        "layer_a_no_cron": (
            "deliverable 모듈 임의 cron 조작 0 — re-export/resolve/lookup "
            "+ +37 경유만, ZERO cokacdir/subprocess"
        ),
        "layer_b_single_bound_cancel": (
            "durable lookup + live verifier 5조건 AND PASS = single "
            "bound·verified cancel 1건 (회장 §1 목표)"
        ),
    }


__all__ = [
    "WIRING_SCHEMA",
    "LIVE_COLLECTOR_ENTRYPOINT",
    "LIVE_WIRING_CHAIN",
    "resolve_live_collector_entrypoint",
    "live_wiring_contract",
    # +45 live wiring re-export
    "CancelOnSuccessLiveResult",
    "DurableFallbackLookup",
    "lookup_fallback_from_durable_registry",
    "run_cancel_on_success_live_wiring",
    # +25 read-only re-export
    "OperationalSeamParams",
    "OperationalWiringResult",
    "compute_event_id",
    "run_operational_completion_callback_collector",
    # +37 read-only re-export
    "NormalCallbackBinding",
    "WiredCollectorResult",
    "run_wired_normal_completion_callback_collector",
]
