review: Astra findings for media-results-cleanup, round 1
NOT READY: P1-1 an upload begun before the grant bound can complete after cleanup; P1-2 the console's media pass tests expect cleanup in the settling pass; P2-3 a created-but-never-started execution loses its cleanup duty; P2-4 A8 overstates the lifecycle's two-day maximum. Every census unit and envelope approved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+60
−0
docs/superpowers/reviews/CODEX-FINDINGS-media-results-cleanup.md+60 −0
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-media-results-cleanup.md b/docs/superpowers/reviews/CODEX-FINDINGS-media-results-cleanup.md| new file mode 100644 |
| index 000000000..5718fc3b1 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-media-results-cleanup.md |
| @@ -0,0 +1,60 @@ |
| +Reviewed `5daee236d90388072e2bf480932d48def9f3d1eb`, round 1. Two P1 findings and two P2 findings. No files changed, tests run, or AWS API calls made. `git diff --check` passed. |
| + |
| +1. **P1 — Cleanup timing: expiry does not stop uploads already in progress.** |
| + |
| + [dispatch.go:305](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/mediajobs/dispatch.go:305) treats grant expiry as proof that nothing can subsequently create an object. However, the authoritative [spec §5.4:371](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/docs/superpowers/specs/2026-11-16-video-conversion-design.md:371) explicitly allows a transfer begun before expiry to finish afterward. |
| + |
| + **Failure scenario:** a leaked PUT starts before expiry against an absent result or failed-job output, then uploads slowly. Cleanup reaches the bound, finds no completed object, and clears `cleanup_due` at [retire.go:120](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/mediajobs/retire.go:120). The upload completes afterward. No further job cleanup runs; an output remains indefinitely. |
| + |
| + **Fix:** establish and enforce an upload-completion bound before clearing cleanup duties, or introduce a storage-side mechanism that refuses late completion. Merely adding arbitrary slack does not prove this. Add a deterministic test that starts a PUT, pauses its body, runs cleanup, then completes it. The atomic fake at [grants.go:267](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/media/mediatest/grants.go:267) cannot exercise this interleaving. |
| + |
| + **Fault family:** cleanup finality across outstanding write authority. |
| + |
| +2. **P1 — Tests: the console lifecycle tests still require immediate cleanup.** |
| + |
| + [runToStopped:154](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/console/mediapass_test.go:154) finishes its third pass about 62 seconds after dispatch. `TestMediaPassRunsTheLifecycle` then requires the result to be deleted and `cleanup_due` to be zero at [mediapass_test.go:177](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/console/mediapass_test.go:177). `TestMediaPassFailedCleansOutputs` likewise requires deleted outputs at [mediapass_test.go:209](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/console/mediapass_test.go:209). |
| + |
| + **Failure scenario:** both tests reach those assertions while cleanup is deliberately deferred until dispatch plus 65 minutes. Their assertions therefore fail under the new behavior; this follows directly from the fixture and SQL, without executing them. |
| + |
| + **Fix:** assert settlement with objects retained before the bound, then advance the worker to the bound and assert cleanup. Preserve the successful-job output checks. |
| + |
| + **Fault family:** integration tests must follow the settlement/cleanup contract. |
| + |
| +3. **P2 — Cleanup coverage: retain duties for created-but-never-started tasks.** |
| + |
| + [track.go:113](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/mediajobs/track.go:113) sends a stopped task without `StartedAt` into `neverStarted`. That function either clears its execution identity for retry or settles it with `cleanup_due = 0` at [dispatch.go:501](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/mediajobs/dispatch.go:501). |
| + |
| + **Failure scenario:** an image-pull failure leaves live transfers in ECS overrides. A bearer writes through them after the row is requeued or failed. The old execution has no cleanup duty; outputs persist indefinitely. The simulation’s action selects only current, settled executions at [actions_test.go:654](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/sim/mediajobs/actions_test.go:654), so it misses the discarded execution after retry. |
| + |
| + **Fix:** distinguish a definite non-launch from a created task that never started. Preserve a durable cleanup entry for the latter before replacing its execution identity, without charging engine time. Cover both retry and terminal cases. |
| + |
| + **Assessment:** this residual should close here; a result-only lifecycle rule does not clean its outputs. |
| + |
| + **Fault family:** cleanup obligations survive execution replacement and settlement. |
| + |
| +4. **P2 — A8: lifecycle does not guarantee deletion within two days.** |
| + |
| + [A8:1120](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/docs/superpowers/specs/2026-11-16-video-conversion-design.md:1120) promises “at most two days.” S3 rounds expiration eligibility to midnight UTC, performs deletion asynchronously, and starts noncurrent expiration after the version becomes noncurrent. Two one-day rules therefore provide no two-day physical-deletion maximum. See [https://docs.aws.amazon.com/AmazonS3/latest/userguide/troubleshoot-lifecycle.html](https://docs.aws.amazon.com/AmazonS3/latest/userguide/troubleshoot-lifecycle.html). |
| + |
| + **Failure scenario:** an operator treats two days as a retention guarantee while previous versions remain. |
| + |
| + **Fix:** describe current and noncurrent expiration eligibility separately, including asynchronous removal; remove the maximum-duration claim. |
| + |
| + **Fault family:** retention guarantees must match storage semantics. |
| + |
| +No P3 findings. For rollout, an explicit infrastructure-before-console instruction is sufficient: apply the lifecycle and IAM changes first. Retaining cleanup duties and retrying permission failures is appropriate; falling back to plain deletion would not complete cleanup. |
| + |
| +The census verdicts below concern the root-read boundary, independently of the blocking application findings: |
| + |
| +| Unit or envelope | Verdict and evidence | |
| +|---|---| |
| +| `deployment-buckets/main.tf:external` | **APPROVE.** [main.tf:101](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/deployment-buckets/main.tf:101): both added rules are confined to `media-results/`; existing rules and root-read protections remain intact. Existing `accepted-legacy` disposition remains appropriate. | |
| +| `media-engine/iam.tf:external` | **APPROVE.** [iam.tf:158](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/media-engine/iam.tf:158): version listing and deletion are scoped to results. No conversion-role expansion or root-input validation weakening. Existing disposition remains appropriate. | |
| +| `media-engine/tests/media_engine.tftest.hcl:external` | **APPROVE.** [media_engine.tftest.hcl:550](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/media-engine/tests/media_engine.tftest.hcl:550): mock-provider assertions include the exact new permissions and retain the policy-size check. | |
| +| New `deployment-buckets/tests/media_results.tftest.hcl:external` | **APPROVE** the proposed `legacy / accepted-legacy` disposition. [media_results.tftest.hcl:9](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/deployment-buckets/tests/media_results.tftest.hcl:9): mock-provider plan tests; no new runtime read authority. | |
| +| `infra/modules/deployment-buckets` envelope | **APPROVE.** Changed lifecycle blocks at [main.tf:101](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/deployment-buckets/main.tf:101) introduce no tenant-controlled root input. | |
| +| `infra/modules/deployment-buckets/tests` envelope | **APPROVE.** New assertions at [media_results.tftest.hcl:16](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/deployment-buckets/tests/media_results.tftest.hcl:16) are confined to mocked lifecycle plans. | |
| +| `infra/modules/media-engine` envelope | **APPROVE.** Changed policy statements at [iam.tf:158](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/media-engine/iam.tf:158) preserve the root-read boundary. | |
| +| `infra/modules/media-engine/tests` envelope | **APPROVE.** Changed expected statements at [media_engine.tftest.hcl:592](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/media-engine/tests/media_engine.tftest.hcl:592) match the scoped grants. | |
| + |
| +**NOT READY** |
| \ No newline at end of file |