python student-tests/staging_cleanup.py
1. ready a285845a-2a6d-438d-a37c-f5ce252e5ce6: staging removed by the worker right after COMMIT; original and variants kept
2. prepared: staging leftover of a ready attachment, orphan staging, orphan variant, staging of a failed attachment, staging of a queued job (worker stopped)
3. dry-run: {"staging_after_ready": 2, "staging_failed_expired": 0, "orphan": 2} found, deleted 0
   grace 900 s: deleted 0 — everything is younger than the grace period
   grace 2 s: {"staging_after_ready": 2, "staging_failed_expired": 0, "orphan": 2}, deleted 4; kept: ready original and variants, staging of the queued job, staging of the failed attachment (retention)
   retention 0 s: failed staging deleted ({"staging_after_ready": 0, "staging_failed_expired": 3, "orphan": 0}); replay now: {'result': 'refused', 'reason': 'source_missing', 'detail': 'оригинал в staging уже удалён (истёк STAGING_RETENTION_SECONDS)'}
   repeated run: deleted 0
4. worker started: 002336e3-fb36-4738-b420-29d5362140cb ready, its staging removed
PASS: staging is removed after the result is committed; objects without a reference in the database are removed only after the grace period; the staging of failed uploads is kept for replay until retention ends; dry-run and repeated runs are safe
