"""Typed contracts shared by weekly draft orchestration and the coordinator."""

from __future__ import annotations

from dataclasses import dataclass
from typing import Protocol

from checkin_cli.weekly_operations_grounding import GroundedWeeklyReviewSource
from gateway.platforms.nutrition_weekly_owner_storage import WeeklyOwnerStorageAuthority


@dataclass(frozen=True, slots=True)
class WeeklyLifecycleResult:
    accepted: bool
    draft_id: str | None = None
    text: str | None = None
    error: str | None = None
    generation: int | None = None
    generation_record_digest: str | None = None
    generation_checkin_revision: str | None = None
    generation_draft_revision: str | None = None


class WeeklyDraftLifecycle(Protocol):
    def weekly_owner_key(self) -> tuple[str, str, str]: ...

    def weekly_owner_storage_authority(self) -> WeeklyOwnerStorageAuthority: ...

    def persist_grounded_weekly_review(
        self,
        customer_key: str,
        owner_key: tuple[str, str, str],
        source: GroundedWeeklyReviewSource,
    ) -> WeeklyLifecycleResult: ...

    def grounded_weekly_review_result(
        self,
        draft_id: str,
        owner_key: tuple[str, str, str],
    ) -> WeeklyLifecycleResult: ...
