from __future__ import annotations

from typing import Any
from typing import Protocol

from unmake.models import OperationRecord, SessionRecord, SessionStatus


class StorageBackend(Protocol):
    def start_session(self, *, context: dict[str, Any]) -> SessionRecord: ...

    def append_operation(
        self,
        *,
        session_id: str,
        op_type: str,
        payload: dict[str, Any],
    ) -> OperationRecord: ...

    def close_session(
        self,
        *,
        session_id: str,
        status: SessionStatus,
        error: str | None = None,
    ) -> SessionRecord: ...

    def list_sessions(self, *, limit: int | None = None) -> list[SessionRecord]: ...

    def get_session(self, session_id: str) -> SessionRecord | None: ...

    def get_operations(self, session_id: str) -> list[OperationRecord]: ...
