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
+41 -6
View File
@@ -481,10 +481,11 @@ PROFILES = {
sample_resources=True,
),
# поочерёдная замена под нагрузкой (уровень 4): та же нагрузка и
# лимиты, что у failover; реплики стартуют на образе c50b721 —
# последнего commit до change rolling-update (без колонки
# messages.instance_id) — и заменяются на образ текущего checkout.
# Решение 8 design change rolling-update
# лимиты, что у failover; реплики стартуют на образе e1161f7 —
# последнего commit лабы 4 до change attachments (без таблиц вложений
# и с прежним ограничением текста) — и заменяются на образ текущего
# checkout. Решение 8 design change rolling-update, commit — решение
# 14 design change attachments; правило выбора — bench.md
"rollout": Profile(
name="rollout",
sizes=(1_000,),
@@ -504,7 +505,7 @@ PROFILES = {
replicas=2,
failover_write_rate=100,
failover_read_rate=100,
rollout_from="c50b721",
rollout_from="e1161f7",
rollout_before_s=15,
rollout_budget_s=90,
rollout_after_s=15,
@@ -529,7 +530,7 @@ PROFILES = {
replicas=2,
failover_write_rate=100,
failover_read_rate=100,
rollout_from="c50b721",
rollout_from="e1161f7",
rollout_before_s=5,
rollout_budget_s=60,
rollout_after_s=8,
@@ -5649,6 +5650,33 @@ def resume_problems(
return found
def rollout_commit_problem(commit: str) -> str | None:
"""Commit прежнего образа профиля замены есть в истории; иначе —
сообщение с commit и подменой `--from` (design change `attachments`,
решение 14)."""
found = subprocess.run(
[
"git",
"-C",
str(ROOT),
"rev-parse",
"--verify",
"--quiet",
f"{commit}^{{commit}}",
],
capture_output=True,
text=True,
check=False,
)
if found.returncode == 0:
return None
return (
f"rollout commit {commit!r} is not in this repository history: "
"update Profile.rollout_from (.claude/rules/bench.md) or pass "
"--from <commit> for debugging"
)
def apply_overrides(
profile: Profile,
args: argparse.Namespace,
@@ -5700,6 +5728,13 @@ def main(argv: list[str]) -> int:
if args.resume and not profile.is_series:
print("--resume: track 1 series profiles only", flush=True)
return 2
if profile.is_rollout:
# commit методики — до стенда, а не на шестой секунде сборки
# (спек load-benchmark, «Прежний commit профиля замены»)
problem = rollout_commit_problem(profile.rollout_from)
if problem:
print(problem, flush=True)
return 2
# профиль отказа реплик — доказательство уровня 4, рядом с прогонами
# make test-failover (решение 7 design change graceful-failover)
kind = "failover" if profile.is_failover else "bench"