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
@@ -1,4 +1,5 @@
from collections.abc import AsyncIterator, Sequence
from contextlib import AbstractAsyncContextManager
from dataclasses import dataclass
from datetime import datetime, timedelta
from typing import Protocol, runtime_checkable
@@ -40,6 +41,13 @@ class StagedObject:
key: str
@dataclass(frozen=True, slots=True)
class StoredObject:
key: str
size: int
modified: datetime
@runtime_checkable
class ObjectStorage(Protocol):
async def put(self, key: str, data: bytes, content_type: str) -> None: ...
@@ -52,6 +60,10 @@ class ObjectStorage(Protocol):
async def delete(self, key: str) -> None: ...
def listing(self, prefix: str, page_size: int) -> AsyncIterator[Sequence[StoredObject]]: ...
async def stat(self, key: str) -> StoredObject | None: ...
@runtime_checkable
class ImageInspector(Protocol):
@@ -95,6 +107,14 @@ class AttachmentRepository(Protocol):
async def remove(self, attachment: Attachment) -> None: ...
async def page_after(self, key: str, limit: int) -> Sequence[Attachment]: ...
async def by_key(self, key: str) -> Attachment | None: ...
async def claim(self, attachment_id: UUID) -> Attachment | None: ...
async def mark(self, attachment: Attachment) -> None: ...
async def staged(self, limit: int, retention: timedelta) -> list[StagedObject]: ...
async def unstage(self, attachment_ids: Sequence[UUID]) -> None: ...
@@ -104,6 +124,8 @@ class AttachmentRepository(Protocol):
class JobRepository(Protocol):
async def add(self, job: Job) -> None: ...
async def reprocess(self, job: Job, operator: str) -> bool: ...
async def claim(self, job: Job, token: UUID, lease: timedelta) -> Claim | None: ...
async def complete(
@@ -158,3 +180,8 @@ class AttachmentDirectory(Protocol):
@runtime_checkable
class JobObserver(Protocol):
def observe(self, job: Job, outcome: str, seconds: float) -> None: ...
@runtime_checkable
class SingleRun(Protocol):
def hold(self) -> AbstractAsyncContextManager[bool]: ...