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
@@ -340,3 +340,18 @@ MUST NOT стартовать. Как эти сроки согласованы
`DATABASE__IDLE_IN_TRANSACTION_TIMEOUT_MS=5000` при
`request_timeout_seconds` 6
- **THEN** сервис не стартует, ошибка называет оба параметра
### Requirement: Лимиты вложений — константы контракта
Лимиты вложения — 10 485 760 байт на тело и 40 000 000 пикселей — SHALL
быть константами приложения, а не настройками: их задаёт контракт, и
они одинаковы на всех установках. Ни окружение, ни `.env`, ни
`config.toml` MUST NOT их менять. Соответствие имён skeleton
`MAX_UPLOAD_BYTES` и `MAX_IMAGE_PIXELS` этим константам SHALL быть
описано в `REPORT.md`.
#### Scenario: Окружение не меняет лимит
- **WHEN** сервис запущен с `MAX_UPLOAD_BYTES=1` и `MAX_IMAGE_PIXELS=1`
в окружении, и участник загружает `sample.png`
- **THEN** ответ 201: лимиты остались контрактными