Track 2 of lab 4 is closed. One reconciler pass merges the sorted bucket listing with keyset pages of attachments by object key, finds objects without a row, ready rows without an object or with other bytes and abandoned intents, deletes only old objects without a row after a second look at the row and old intents under SKIP LOCKED, and puts damaged ready rows into a reversible quarantine instead of deleting them. On the stand the dry-run found exactly the 22 injected discrepancies of seven classes, apply fixed the 18 fixable ones, the repeat did nothing, and 75 passes during 3418 uploads lost no ready attachment. A shallow pass costs 0.105 / 1.000 / 3.729 s for 1k / 10k / 30k objects at a flat 83 MiB, 95 % of it in the RustFS listing; --deep is 4.3-5 times dearer per object. For the defence: make reconcile-demo shows injection, dry-run, apply, the repeat, quarantine through the API, healing, the held lock, a stopped S3 and the run under uploads in about four minutes; the cost matrix is evidence/reconcile/cost/summary.txt (make reconcile-cost repeats it on a fresh stand in about seven). The lab4-storage-reconciler spec is added and the quarantine rule of lab4-attachments is updated in the main specs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V1d3RLHNBBMA6UqBLLJv27
2.8 KiB
MODIFIED Requirements
Requirement: Метаданные и скачивание только участникам
GET /api/v1/attachments/{attachment_id} SHALL возвращать 200 Attachment участнику чата вложения. GET /api/v1/attachments/{attachment_id}/content SHALL возвращать участнику 200 с исходными байтами, Content-Type вложения и Content-Length, через API, без redirect, вне зависимости от заголовка Accept. Параметр variant SHALL принимать только original (по умолчанию). Посторонний, неизвестный id и ещё не готовое вложение SHALL получать 404 с кодом not_found, не раскрывающим существование вложения; невалидный UUID и неизвестный variant — 400. Вложение, помещённое сверкой в карантин (capability lab4-storage-reconciler), SHALL отдавать метаданные как прежде, а /content SHALL отвечать 404 без обращения к S3, чтобы клиент не получил байты, расходящиеся с sha256 метаданных. Все ответы, включая бинарный 200, SHALL нести X-Request-Id и X-Instance-Id.
Scenario: Второй участник скачивает оригинал
- WHEN второй участник чата запрашивает
/contentзагруженного вложения сAccept: application/json - THEN ответ
200,Content-Type: image/png, байты совпадают с загруженными, SHA-256 равенsha256метаданных
Scenario: Посторонний
- WHEN пользователь вне чата запрашивает метаданные или
/content - THEN оба ответа
404с кодомnot_found
Scenario: Неизвестный вариант
- WHEN запрошен
/content?variant=thumbnail - THEN ответ
400с кодомinvalid_request
Scenario: Объект пропал из хранилища
- WHEN метаданные готового вложения есть, а объекта в bucket нет
- THEN
/contentотвечает404, событие пишется в журнал без ключа объекта
Scenario: Вложение в карантине
- WHEN сверка поместила вложение в карантин из-за расхождения байтов с метаданными
- THEN метаданные отвечают
200с прежними полями,/content—404с кодомnot_found