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.
This commit is contained in:
Artyom
2026-11-06 12:29:35 +03:00
parent dc9256baf9
commit 12db77133f
161 changed files with 11160 additions and 1467 deletions
+9 -2
View File
@@ -9,6 +9,7 @@ from messenger.messaging.application.ports import (
AttachmentStates,
ChatDirectory,
CursorCodec,
MessageLog,
MessagingUnitOfWork,
)
from messenger.messaging.application.queries import GetChat, ListChats, ReadHistory
@@ -16,6 +17,7 @@ from messenger.messaging.config import MessagingSettings
from messenger.messaging.infrastructure.cursor import SignedCursorCodec
from messenger.messaging.infrastructure.postgres import (
PostgresChatDirectory,
PostgresMessageLog,
PostgresMessagingUnitOfWork,
)
from messenger.shared.application.commands import Command
@@ -37,6 +39,10 @@ class MessagingProvider(Provider):
def directory(self, database: Database) -> ChatDirectory:
return PostgresChatDirectory(database)
@provide(scope=Scope.APP)
def log(self, database: Database, attachments: AttachmentStates) -> MessageLog:
return PostgresMessageLog(database, attachments)
@provide(scope=Scope.APP)
def cursors(self, settings: MessagingSettings) -> CursorCodec:
return SignedCursorCodec(settings.cursor_secret.get_secret_value().encode())
@@ -61,7 +67,8 @@ class MessagingProvider(Provider):
def command_bus(
self,
uow: MessagingUnitOfWork,
attachments: AttachmentStates,
log: MessageLog,
directory: ChatDirectory,
publisher: EventPublisher,
clock: Clock,
ids: IdGenerator,
@@ -70,6 +77,6 @@ class MessagingProvider(Provider):
ttl = timedelta(seconds=settings.idempotency_ttl_seconds)
handlers: dict[type[Command], CommandHandler] = {
CreateChat: CreateChatHandler(uow, clock, ids),
PostMessage: PostMessageHandler(uow, attachments, clock, ids, ttl),
PostMessage: PostMessageHandler(uow, log, directory, clock, ids, ttl=ttl),
}
return MessagingCommandBus(handlers, uow, publisher)
@@ -37,7 +37,7 @@ class CreateMessageRequest(BaseModel):
class PageQuery(BaseModel):
limit: int = Field(default=50, ge=1, le=100)
cursor: str | None = None
cursor: str | None = Field(default=None, min_length=1)
class ChatOut(BaseModel):