chore: carry lab 3 over

- carry the lab 3 solution over from mtusi2026lab3-safronov
  (solution/bvt2301-safronov, ce89eba): src, migrations, student-tests,
  bench, openspec, .claude, infra/haproxy and infra/valkey, own scripts,
  Dockerfile, compose, pyproject and uv lock
- merge Makefile, .gitignore and .dockerignore (the lab 3 versions only
  add lines to the skeleton, which is the same in lab 4) and
  .env.example (lab 4 skeleton names listed in the header)
- rename the compose project to mtusi-lab4 and the image to :lab4 so
  the stand does not reuse the lab 3 containers and volumes
- update AGENTS.md for lab 4: current lab, origin commit, contract and
  test files of the new skeleton

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 17:32:33 +03:00
co-authored by Claude Opus 5.5
parent ec540a1a72
commit 5d5d8f9d2a
365 changed files with 64878 additions and 19 deletions
+18
View File
@@ -0,0 +1,18 @@
from .chat import ChatFullDTO, ChatPageDTO
from .idempotency import IdempotencyRecordDTO
from .message import MessageFullDTO, MessagePageDTO
from .session import CurrentSessionDTO, SessionFullDTO, SessionTokenDTO
from .user import UserCredentialsDTO, UserFullDTO
__all__ = [
"ChatFullDTO",
"ChatPageDTO",
"CurrentSessionDTO",
"IdempotencyRecordDTO",
"MessageFullDTO",
"MessagePageDTO",
"SessionFullDTO",
"SessionTokenDTO",
"UserCredentialsDTO",
"UserFullDTO",
]
+20
View File
@@ -0,0 +1,20 @@
from dataclasses import dataclass
from datetime import datetime
from uuid import UUID
@dataclass(frozen=True, slots=True)
class ChatFullDTO:
id: UUID
title: str
# в порядке, переданном при создании
member_ids: tuple[UUID, ...]
created_at: datetime
@dataclass(frozen=True, slots=True)
class ChatPageDTO:
"""Страница списка чатов пользователя."""
items: tuple[ChatFullDTO, ...]
next_cursor: str | None
+11
View File
@@ -0,0 +1,11 @@
from dataclasses import dataclass
from .message import MessageFullDTO
@dataclass(frozen=True, slots=True)
class IdempotencyRecordDTO:
"""Сохранённый результат ключа: хэш тела и сообщение первой отправки."""
request_hash: bytes
message: MessageFullDTO
+20
View File
@@ -0,0 +1,20 @@
from dataclasses import dataclass
from datetime import datetime
from uuid import UUID
@dataclass(frozen=True, slots=True)
class MessageFullDTO:
id: UUID
chat_id: UUID
sender_id: UUID
text: str
created_at: datetime
@dataclass(frozen=True, slots=True)
class MessagePageDTO:
"""Страница истории чата."""
items: tuple[MessageFullDTO, ...]
next_cursor: str | None
+33
View File
@@ -0,0 +1,33 @@
from dataclasses import dataclass
from datetime import datetime
from uuid import UUID
from .user import UserFullDTO
@dataclass(frozen=True, slots=True)
class SessionFullDTO:
"""Строка сессии: SHA-256 токена, а не сам токен."""
id: UUID
user_id: UUID
token_hash: bytes
expires_at: datetime
created_at: datetime
@dataclass(frozen=True, slots=True)
class SessionTokenDTO:
"""Результат входа: токен существует только здесь и в ответе API."""
token: str
expires_at: datetime
user: UserFullDTO
@dataclass(frozen=True, slots=True)
class CurrentSessionDTO:
"""Действующая сессия запроса и её владелец."""
id: UUID
user: UserFullDTO
+21
View File
@@ -0,0 +1,21 @@
from dataclasses import dataclass
from datetime import datetime
from uuid import UUID
@dataclass(frozen=True, slots=True)
class UserFullDTO:
"""Пользователь без хэша пароля: в таком виде он уходит в API."""
id: UUID
username: str
display_name: str
created_at: datetime
@dataclass(frozen=True, slots=True)
class UserCredentialsDTO:
"""Пользователь и хэш пароля — только для входа."""
user: UserFullDTO
password_hash: str