== worker остановлен: приём не зависит от обработки ==
  ok   - upload → 202 queued without worker (0.02s)
  ok   - still queued after 3 s: API did not resize synchronously
  ok   - content of queued attachment → 409 (got 409)
  ok   - thumbnail of queued attachment → 409 (got 409)
  ok   - message with queued attachment → 201 (got 201)
  ok   - other messages keep working
  ok   - job is in the broker stream (len=1), outbox published
== рестарт брокера и API с сохранением volumes ==
  ok   - after broker restart the message is still there (len=1)
  ok   - same session, same attachment, still queued
== worker запущен ==
  ok   - after restart: status ready, error_code null
  ok   - after restart: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
  ok   - after restart: original byte-for-byte
  ok   - after restart: thumbnail 256x160, sha256 matches
  ok   - staging removed after ready (original lives in originals/)
   attachment b442df77-ff58-4ab7-89e9-979b507b38f8, job e2871dfb-6dd2-46c7-8dd1-ce29c7f22558, events: ['01:30:28.325 accepted 1 api', '01:30:37.814 claimed 1 worker-1-0', '01:30:38.282 ready 1 worker-1']
   [worker-down: 14s]
== брокер недоступен: приём не зависит от брокера (transactional outbox) ==
  ok   - /health/ready = 200: broker is not critical for API
  ok   - upload → 202 queued while broker is down (0.0s, publish timeout ≤ 2s)
  ok   - intent kept in outbox, not published yet
  ok   - after broker is back: status ready, error_code null
  ok   - after broker is back: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
  ok   - after broker is back: original byte-for-byte
  ok   - after broker is back: thumbnail 256x160, sha256 matches
  ok   - relay published the outbox row when broker came back
   [broker-down: 4s]
== повторная доставка уже ready-задачи ==
   published duplicate: 1794436247461-0 {"schema_version": 1, "job_id": "5c7dd513-a5f2-4663-b2ad-c498ea0163e5", "type": "at
   published duplicate: 1794436247942-0 {"schema_version": 1, "job_id": "5c7dd513-a5f2-4663-b2ad-c498ea0163e5", "type": "at
  ok   - duplicates: status stays ready, variants unchanged (same sha256)
  ok   - no second set of variants: rows=3, S3 objects=3
  ok   - job finished exactly once, attempt unchanged
  ok   - duplicates acked (no pending messages)
   [redelivery: 7s]
== crash после записи в S3, до COMMIT и ack ==
   recovered in 22.7s (worker restart + lease expiry)
  ok   - after crash before ack: status ready, error_code null
  ok   - after crash before ack: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
  ok   - after crash before ack: original byte-for-byte
  ok   - after crash before ack: thumbnail 256x160, sha256 matches
  ok   - same attempt taken over after lease expiry (redelivery, not a new job)
  ok   - S3 objects from the crashed attempt reused: still exactly 3 variants
   events: ['01:30:56.132 accepted 1 api', '01:30:56.135 claimed 1 worker-fault-1', '01:31:18.241 lease_takeover 1 worker-fault-1', '01:31:18.745 ready 1 worker-fault']
   [crash-s3: 27s]
== crash после COMMIT ready, до ack ==
  ok   - commit before crash: status ready, error_code null
  ok   - commit before crash: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
  ok   - commit before crash: original byte-for-byte
  ok   - commit before crash: thumbnail 256x160, sha256 matches
  ok   - unacked message redelivered after restart and acked as no-op
  ok   - ready recorded once, 3 variants
   [crash-ack: 8s]
== crash API между COMMIT и publish (transactional outbox) ==
  ok   - client did NOT get 202: API died after COMMIT (got 502)
  ok   - attachment and job were committed before the crash (1 new)
  ok   - relay-published job: status ready, error_code null
  ok   - relay-published job: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
  ok   - relay-published job: original byte-for-byte
  ok   - relay-published job: thumbnail 256x160, sha256 matches
  ok   - outbox row published by relay (no new job created)
   [outbox: 4s]
== временные ошибки → backoff+jitter → failed → replay ==
  ok   - after 23s: failed, error_code=retry_exhausted
  ok   - bounded: 5 attempts, 4 scheduled retries, delays [0.6, 1.8, 3.8, 6.4]
  ok   - backoff grows 2^n with jitter in [d/2, d] (JOB_BACKOFF_BASE_SECONDS=1)
  ok   - content of failed → 409 (got 409)
  ok   - failed attachment cannot be attached → 409 (got 409)
  ok   - failed job is in the registry (python -m app.replay --list)
  ok   - explicit replay accepted
  ok   - after replay: status ready, error_code null
  ok   - after replay: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
  ok   - after replay: original byte-for-byte
  ok   - after replay: thumbnail 256x160, sha256 matches
  ok   - same job_id, attempt 6, replays=1 (audit)
  ok   - replay of a ready job is refused (no duplicate execution)
   [retry-replay: 31s]
== долгая, но живая задача: heartbeat продлевает аренду ==
  ok   - job ran 31s > lease 20s, no takeover, attempt 1
== замёрзший worker: аренда истекает, задачу забирают ==
  ok   - claimed by worker-fault, then it froze (processing)
   recovered in 40.8s
  ok   - after frozen worker: status ready, error_code null
  ok   - after frozen worker: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
  ok   - after frozen worker: original byte-for-byte
  ok   - after frozen worker: thumbnail 256x160, sha256 matches
  ok   - reaper: lease expired → attempt 2 → ready
  ok   - woken stale worker could not commit (lease_token fencing), result unchanged
   [lease: 104s]

66 passed, 0 failed
