Files
mtusi2026lab6/src/messenger/messaging/application/ports.py
T
Artyom 12db77133f Forward the lab 5 foundation while preserving lab 6 telemetry
Source: immutable lab5 snapshot f88e9ba43cdfd7eb6a5a7ae5feb4247b4e820071; forward the allowed diff from 64d5c67. Carry SQLAlchemy, Alembic, reliability fixes, versioned jobs, infrastructure and student tests without changing protected coursework files.

Validation: make check, validate, lint; 515 student tests passed with one Linux-only skip; public smoke with telemetry enabled and repeat migration passed. Stop the owned stack and retain volumes. Preserve the existing OTel work in progress; grade implementation remains a separate phase.
2026-11-06 12:29:35 +03:00

52 lines
1.4 KiB
Python

from collections.abc import Sequence
from datetime import datetime
from typing import Protocol, runtime_checkable
from uuid import UUID
from messenger.messaging.domain.keys import HistoryKey
from messenger.messaging.domain.models import Chat, Message, Receipt
from messenger.shared.application.ports import UnitOfWork
@runtime_checkable
class CursorCodec(Protocol):
def encode(self, scope: str, key: HistoryKey) -> str: ...
def decode(self, scope: str, raw: str) -> HistoryKey: ...
@runtime_checkable
class ChatRepository(Protocol):
async def add(self, chat: Chat) -> None: ...
@runtime_checkable
class MessageLog(Protocol):
async def post(
self, message: Message, key: str, fingerprint: bytes, since: datetime
) -> Receipt | None: ...
@runtime_checkable
class MessagingUnitOfWork(UnitOfWork, Protocol):
@property
def chats(self) -> ChatRepository: ...
@runtime_checkable
class AttachmentStates(Protocol):
async def unusable(self, chat_id: UUID, attachment_ids: Sequence[UUID]) -> bool: ...
@runtime_checkable
class ChatDirectory(Protocol):
async def chat_for_member(self, chat_id: UUID, user_id: UUID) -> Chat | None: ...
async def chats_of(
self, user_id: UUID, *, after: HistoryKey | None, limit: int
) -> tuple[list[Chat], bool]: ...
async def history(
self, chat_id: UUID, *, after: HistoryKey | None, limit: int
) -> tuple[list[Message], bool]: ...