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
+17 -7
View File
@@ -250,13 +250,23 @@ change `s3-storage`, решение 9): старт стенда перечисл
сверка — как у `failover` (`k6/failover.js`, `k6/retry.js`, поля
`failover_*` профиля). Окна — `rollout_before_s` до запуска скрипта,
бюджет замены `rollout_budget_s`, ещё `rollout_after_s`.
- Реплики стартуют на образе `Profile.rollout_from` (сейчас `c50b721`,
последний commit до change в репозитории лабы 3; в лабе 4 его нет —
`KNOWN_ISSUES.md`, до правки — `--from <commit>`): `git archive
<commit> | docker build`
под тегом `mtusi-messenger:bench-from`, затем `docker tag` на
`mtusi-messenger:bench`. Рабочее дерево не трогается; тег снимается
при уборке. `--from <commit>` — отладка (`overrides`).
- Реплики стартуют на образе `Profile.rollout_from`: `git archive
<commit> | docker build` под тегом `mtusi-messenger:bench-from`, затем
`docker tag` на `mtusi-messenger:bench`. Рабочее дерево не трогается;
тег снимается при уборке. `--from <commit>` — отладка (`overrides`).
- **Какой commit** (спек `load-benchmark`, «Прежний commit профиля
замены»; design change `attachments`, решение 14): commit текущей лабы
до изменения, которое показывает замена. Сейчас — `e1161f7`, последний
commit лабы 4 до change `attachments`: замена показывает миграцию
вложений (две таблицы и ослабление `ck_messages_text_length` с `NOT
VALID`), ревизия `e656d6bbe1a4` → `ef25d50b01a8`. Commit меняется:
- при переходе в следующую лабу — commit прошлой лабы в её истории нет
(AGENTS.md, «Переход в следующую лабу»);
- когда замена должна показать новое изменение схемы.
`run.py` проверяет commit до стенда (`git rev-parse --verify
<commit>^{commit}`): нет в истории — код 2, сообщение называет commit
и `--from`. Commit — в паспорте метки (`rollout.from_commit`).
- Замену делает **тот же** `scripts/rolling-update.sh`, что у рабочего
стенда. Правило «`-p mtusi-bench`, оба `-f`, `--env-file`»
выполняется переменными `COMPOSE_PROJECT_NAME`, `COMPOSE_FILE`,