"""Abstract sync provider interface (U6).

All external calendar sync providers (CalDAV, Outlook, Google) implement
this interface so :class:`SyncManager` can orchestrate them uniformly.
"""

from __future__ import annotations

from abc import ABC, abstractmethod

from agentkit.calendar.models import CalendarEvent, ExternalCalendarConfig


class AbstractSyncProvider(ABC):
    """Interface for bidirectional external calendar sync."""

    @abstractmethod
    async def pull_changes(
        self, config: ExternalCalendarConfig, since: str | None = None
    ) -> list[CalendarEvent]:
        """Pull remote changes into local DB. Returns pulled/updated events."""
        ...

    @abstractmethod
    async def push_changes(
        self, config: ExternalCalendarConfig, events: list[CalendarEvent]
    ) -> list[CalendarEvent]:
        """Push local events to remote. Returns updated events (with external_id set)."""
        ...

    @abstractmethod
    async def test_connection(self, config: ExternalCalendarConfig) -> tuple[bool, str]:
        """Test connectivity. Returns (ok, error_msg). error_msg is "" on success."""
        ...
