"""Compatibility stubs for external contract payload ownership.

These aliases mark the target owner package before the underlying schema models
are physically split out of ``anima.core.schemas.models``.
"""

from __future__ import annotations

from typing import Protocol, TypeAlias

from anima.core.schemas.enums import CompletionPolicy, ContextMode, LifecycleType
from anima.core.schemas.models import (
    CapabilityToken as _CapabilityToken,
    JobSpec as _JobSpec,
    Meta as _Meta,
)

JobSpec: TypeAlias = _JobSpec
CapabilityToken: TypeAlias = _CapabilityToken
Meta: TypeAlias = _Meta


class JobSpecView(Protocol):
    """Narrow consumer view for requested execution-contract inputs."""

    persona_ref: str
    instance_id: str
    context_bundle_ref: str | None
    completion_policy: CompletionPolicy
    lifecycle: LifecycleType
    context_mode: ContextMode
    max_turns: int | None
    max_tokens: int | None
    max_depth: int


class CapabilityTokenView(Protocol):
    """Narrow consumer view for capability-token enforcement."""

    token_id: str
    tools_profile: str
    persona_ref: str | None
    instance_id: str | None
    max_depth: int | None
    signature: str


class TraceMetaView(Protocol):
    """Narrow consumer view for tracing and idempotency metadata."""

    trace_id: str
    event_id: str | None
    idempotency_key: str | None
    instance_id: str | None
    persona_id: str | None


__all__ = [
    "CapabilityToken",
    "CapabilityTokenView",
    "JobSpec",
    "JobSpecView",
    "Meta",
    "TraceMetaView",
]
