carlos / platform Public

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. DeleteResult lists 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_due at the bound. One that goes back to queued keeps the given-up execution in two new additive columns, prior_execution and prior_cleanup_due, which Cleanup carries out and Prune waits for.
  • Lifecycle backstop (infra/modules/deployment-buckets). Two rules for media-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). Adds s3:ListBucketVersions on the deployment bucket, conditioned on s3:prefix media-results/*, and s3:DeleteObjectVersion on media-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.

Commits 13
Discussions 0 0 open
Tasks 0/0 done

Discussions

  • No discussions on this branch yet.

Tasks

  • No tasks yet.

Activity