feat: add image attachments to messages

- upload, metadata and download endpoints for PNG/JPEG attachments:
  limits before reading and decompression, type by content,
  structural integrity check without decoding pixels, safe filename
- write order: pending row with object key -> PUT to S3 -> ready;
  per-step DB sessions so no pool connection is held during transfers
- attachment_ids in messages (validation, idempotency hash, history);
  whitespace-only text allowed with an attachment (teacher, 2026-10-20)
- migration: attachments and message_attachments tables, text length
  CHECK relaxed with NOT VALID
- student tests, fault checks and driver commands for attachments;
  rollout profile starts from e1161f7 and checks the commit first
- sync attachments deltas into main specs; rules, AGENTS.md, PLAN.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 01:08:56 +03:00
co-authored by Claude Opus 5.5
parent 73779f7acd
commit 116d8d3bf0
72 changed files with 5546 additions and 247 deletions
+21
View File
@@ -23,6 +23,7 @@ CAPABILITIES = (
"chat-cache",
"health",
"idempotency",
"attachments",
)
SCENARIO_RE = re.compile(r"^#### Scenario: (.+?)\s*$", re.MULTILINE)
@@ -105,6 +106,26 @@ EXCLUDED: dict[Scenario, Exclusion] = {
check="make test-persistence ACTION_SCRIPT=scripts/restart.sh — "
"evidence/replicas/test-persistence.md",
),
("attachments", "Принявшая реплика остановлена"): Exclusion(
reason="нужно остановить реплику API, тесты стенд не трогают",
check="driver.py --port <LB> attachment-failover [--mode stop|kill] "
"скилла run-mtusi-messenger: загрузка через LB, scripts/stop-one.sh "
"реплики ответа, скачивание через другую с тем же SHA-256, 404 "
"постороннему — evidence/attachments/failover.md",
),
("attachments", "Байты не в БД и не на диске API"): Exclusion(
reason="нужен взгляд в схему PostgreSQL, bucket S3 и файловые "
"системы контейнеров, а тесты ходят по HTTP",
check="driver.py --port <LB> attachment-storage: колонки таблиц "
"вложений, вид object_key, объект в bucket, анонимный GET — 403, "
"docker diff реплик — evidence/attachments/storage.md",
),
("attachments", "Рестарт стенда"): Exclusion(
reason="нужен рестарт стенда, тесты сервер не трогают",
check="make test-persistence ACTION_SCRIPT=scripts/restart.sh: с "
"LAB=4 проверка скачивает тот же оригинал прежним токеном — "
"evidence/replicas/test-persistence.md",
),
("users", "Хэш в БД"): Exclusion(
reason="нужен доступ к таблице users, а тесты ходят по HTTP",
check="driver.py --port <LB> auth-storage: префикс $argon2id$ и "