media-results-cleanup
Fixes media conversion drill findings F1 and F2 (dev R4, 2026-11-22). Spec amendment A8 in docs/superpowers/specs/2026-11-16-video-conversion-design.md.
The defect. The deployment bucket is versioned. Cleanup's plain DeleteObject of media-results/<execution>.json left the result as a noncurrent version under a delete marker, forever (F2). A create-only PUT succeeds over a delete marker, so a result transfer read from a stopped task's ECS overrides recreated the object after cleanup, at any size (F1).
What changes
- Cleanup deletes every version.
DeleteResultlists the key's versions with the exact key as prefix and deletes, by version id, every version and delete marker whose key is exactly that key. - Cleanup waits for the grant. A stopped row is cleaned at the later of the observation and its grant bound (
dispatched_at+ 60 min + 5 min), when every transfer of the execution has expired. A result or failed output now stays up to about 65 minutes after its job ends. - Every execution sent to RunTask keeps a cleanup duty (Astra round 1, P2-3). A never-started or rejected launch that failed keeps
cleanup_dueat the bound. One that goes back to queued keeps the given-up execution in two new additive columns,prior_executionandprior_cleanup_due, which Cleanup carries out and Prune waits for. - Lifecycle backstop (
infra/modules/deployment-buckets). Two rules formedia-results/: current objects and noncurrent versions expire after a day, and expired delete markers go. They join the existing rules in the one lifecycle resource, and are on for every deployment. - IAM (
infra/modules/media-engine, the console's customer-managed policy). Addss3:ListBucketVersionson the deployment bucket, conditioned ons3:prefixmedia-results/*, ands3:DeleteObjectVersiononmedia-results/*only. - Presign expiry is not changed. All five transfers share one
X-Amz-Expires(1 h) in the payload, and the codec and deadline container read one expiry. Shortening it would need a payload version, would eat a task's PENDING time, and would not close the gap for a task that ends early. Cleanup waiting for the grant closes the gap instead.
Rollout. Apply the module changes (IAM, lifecycle) before rolling a console with this change. Until then every due cleanup is refused and retried each pass.
What remains. A PUT begun just before the grant bound can complete after cleanup, because S3 checks expiry when a request begins. The lifecycle removes a result created that way. An output created that way stays under its execution's prefix in the tenant's bucket, under derived/, which predates this branch.
Tests. A versioned fake bucket proves that the old delete leaves the result recreatable and that DeleteResult leaves nothing. New tests: TestCleanupWaitsForTheGrant, TestGivenUpExecutionsAreCleaned, TestPruneKeepsAGivenUpDuty and TestNothingSentNoDuty. The simulation gains a leaked-put action and two invariants. R1 (nothing cleanup deleted comes back) fails in 5 of 200 seeds with the old timing. R2 (every sent execution holds a duty until cleaned) fails in 140 of 200 without the duties. The MinIO contract replays F1 on a versioned bucket. In the tofu tests, media_results.tftest.hcl was watched to fail on mutated rules, and console_policy_exact asserts the two new statements exactly.
Review. Astra round 1 was NOT READY: two P1s and two P2s, all addressed, with P1-1 left as a stated residual. Round 2 was READY AFTER FIXES: two P2s (the simulation tracks granted executions without relying on rows; no finality claim beyond new requests), both fixed without another round. Findings are in docs/superpowers/reviews/CODEX-FINDINGS-media-results-cleanup.md and -R2.md. Census: every unit and envelope approved, recorded on #280.
Not merged, awaiting Paul.
Discussions
- No discussions on this branch yet.
Tasks
- No tasks yet.
Activity
- paul@keymail.dev pushed 44a1f3ad4 Merge origin/main into media-results-cleanup
- paul@keymail.dev pushed ef854e8c1 sim: move R1 and R2 out of check, under the function-length record
- paul@keymail.dev pushed 60a0e8add provision: record-write census lists mediatest FakeGrants.Put
- paul@keymail.dev pushed ece1e4069 media: sim keeps granted executions; claim no late-completion bound
- paul@keymail.dev pushed 180dbf2a3 review: Astra findings for media-results-cleanup, round 2
- paul@keymail.dev pushed 8bc5035a0 review: Astra brief for media-results-cleanup, round 2
- paul@keymail.dev pushed 5d6cff45f media: keep a cleanup duty for every execution sent to RunTask
- paul@keymail.dev pushed 4f2702cd6 review: Astra findings for media-results-cleanup, round 1
- paul@keymail.dev pushed 5daee236d review: Astra brief for media-results-cleanup, round 1
- paul@keymail.dev pushed 25276ec2a census: propose media-results-cleanup
- paul@keymail.dev pushed 064bd1989 spec: video conversion A8, cleanup is final
- paul@keymail.dev pushed 522612c9b infra: expire media-results/ and let the console delete its versions
- paul@keymail.dev pushed 9922842f0 media: clean results after the grant, every version