review: Astra brief for media-results-cleanup, round 2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+129
−0
docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-results-cleanup-R2.md+129 −0
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-results-cleanup-R2.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-results-cleanup-R2.md| new file mode 100644 |
| index 000000000..2a3169d1d |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-results-cleanup-R2.md |
| @@ -0,0 +1,129 @@ |
| +# Review brief: branch `media-results-cleanup` (media result cleanup, drills F1 and F2), round 2 of 3 |
| + |
| +Repo carlos/platform, branch `media-results-cleanup`, the commit that adds |
| +this brief (its parent is the tip under review). Under review: the whole |
| +diff `origin/main...HEAD`, with attention on what changed since round 1, |
| +`5daee236..HEAD`. Read it from the worktree you are started in. |
| + |
| +Authorities, all on main: `docs/superpowers/specs/2026-11-16-video-conversion-design.md` |
| +§5.3, §5.4, §5.5 and §11 (A5 to A7); `AGENTS.md` ("Stopping rules", "The |
| +census"). Amendment A8, which this branch adds, is under review, not an |
| +authority. The round 1 brief, |
| +`docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-results-cleanup.md`, |
| +states the defect (drills F1, F2) and what the branch does; read it first. |
| + |
| +You are an independent reviewer. Read the diff, then the code it touches |
| +and what that code reaches, and check every claim against the code. |
| + |
| +## Fixed: do not re-argue |
| + |
| +- The census verdicts of round 1 (every unit and envelope approved). No |
| + file in census scope has changed since (`git diff 5daee236..HEAD -- |
| + infra .amadan` is empty), so the census is not part of this round. |
| +- The rollout ruling of round 1: infrastructure before console, stated in |
| + A8; no fallback to a plain delete. |
| + |
| +## Round 2 |
| + |
| +Earlier rounds: round 1, `docs/superpowers/reviews/CODEX-FINDINGS-media-results-cleanup.md`. |
| +This is the second review of this change; one more round remains in the |
| +budget, and a fourth needs Paul. |
| + |
| +First give one line per P1 and P2 from round 1: resolved, partly, or not. |
| +Carry every unresolved or partly resolved finding forward at its current |
| +severity, then add new findings. The verdict covers everything |
| +outstanding, round 1 included. |
| + |
| +What the author did with each: |
| + |
| +- **P1-2 (console tests).** `internal/console/mediapass_test.go`: |
| + `runToStopped` returns the worker, `cleanAtGrantBound` checks that the |
| + settling pass deleted nothing and runs pass 4 at the grant bound. |
| + `internal/console/mediaretire_test.go` `TestAppPurgeRetiresQueuedAndRunning` |
| + checks nothing is cleaned at the stop and everything at `cleanup_due`. |
| +- **P2-3 (never-started duties).** `neverStarted` takes `sent` (RunTask |
| + was called: `track.go` for a task that never started, `launch` for a |
| + `*media.Rejected`; false for every path that never called RunTask). Sent |
| + and failing: the row keeps its execution with `cleanup_due` at the grant |
| + bound. Sent and back to queued: the execution's duty moves to two new |
| + additive columns, `prior_execution` and `prior_cleanup_due` |
| + (`schema.go`, `Migrations`), set in the same UPDATE that clears |
| + `execution_id`. `Cleanup` runs `cleanupPrior` (result and outputs) and |
| + `Prune` requires `prior_cleanup_due = 0`. A row requeues after a strike |
| + at most once; a second sent requeue with a duty still held is refused |
| + as an error rather than overwrite it. Tests: `TestGivenUpExecutionsAreCleaned`, |
| + `TestPruneKeepsAGivenUpDuty`, `TestNothingSentNoDuty`, and the two |
| + never-started tests updated. The simulation reads the new columns, and |
| + P1, P2 (prune) and I4 count the prior duty. A new invariant R2: every |
| + execution sent to RunTask that no row still runs is cleaned or holds a |
| + duty. `leaked-put` now also targets given-up executions. With `sent` |
| + forced false, R2 fails in 140 of 200 seeds. |
| +- **P2-4 (lifecycle wording).** A8 now says eligibility a day after |
| + writing or after becoming noncurrent, rounded to midnight UTC, removed |
| + asynchronously, and claims no maximum. |
| +- **P1-1 (an upload begun before the bound completes after cleanup).** Not |
| + changed in code. The author's position, now in A8 "What remains": S3 |
| + checks a presigned request's expiry when the request begins and offers |
| + no way to refuse a completion, so no bound on completion can be |
| + enforced. For a **result**, the lifecycle rules (`media-results/`, |
| + current objects expire) remove whatever such a PUT creates, which is |
| + the backstop the design asked for. For an **output** of a failed job, |
| + the object stays under that execution's prefix in the tenant's own |
| + bucket, under `derived/`, where the app's own credentials may already |
| + write (`internal/mediajobs/track.go`, `checkOutputs`' comment; the |
| + store user's policy). This case predates the branch, which narrows it |
| + from "any PUT inside the grant's hour after the stop" to "a PUT begun |
| + before the bound". Judge whether that is acceptable for this branch. |
| + If you hold it a P1, name the invariant and what fix would close it; |
| + under AGENTS.md stopping rule 2 a second round in the same fault family |
| + means the author stops and takes the choice to Paul. |
| + |
| +## What to check |
| + |
| +1. The P2-3 fix: every path that gives up or settles an execution after |
| + RunTask was called (`launch`, `release`, `neverStarted`, `Track`, |
| + `Recover`, `lostAfterRetention`, `Retire`), and that none leaves a sent |
| + execution without a duty, or records a duty for one never sent. The |
| + SQL: SQLite evaluates SET expressions against the old row, so |
| + `prior_execution = CASE WHEN ? THEN execution_id ...` takes the |
| + execution being cleared; the bool parameter binding; the guard |
| + against a second duty; the migration on an existing table. |
| +2. `cleanupPrior`: the guard on its UPDATE, a store bucket that is gone |
| + (`DeleteOutputs` treats `NoSuchBucket` as done), an app or account |
| + torn down while a duty is pending, and what `Retire`/teardown and |
| + `Prune` do with such a row. |
| +3. The simulation: R2's definition and its scan of `grantLog`; that R1, |
| + R2 and the widened `leaked-put` stay deterministic per seed and do not |
| + disturb I1 to I9; P1 and the prune rule with the prior duty. |
| +4. Anything round 1 found that the fixes did not reach, and anything the |
| + fixes broke. |
| + |
| +## Severity |
| + |
| +- **P1**: unsafe, would not compile, a test fails, or it would not work. |
| + Blocks merge. |
| +- **P2**: wrong or missing. Fixed without reopening this review. (The |
| + census, and review of any newly changed security, root, termination |
| + or production-storage behaviour, still check the fix; see AGENTS.md, |
| + "Stopping rules".) |
| +- **P3**: clarity or polish. Goes on a follow-up list; never a reason for |
| + another round. |
| + |
| +A P1 states its failure scenario and the evidence (file:line). Do not |
| +raise a P2 to P1 to keep the review open. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3. Each gives the section or task, the problem, |
| +the evidence (file:line, verified), the failure scenario, a concrete |
| +fix and the invariant or trust boundary it breaks (that is its fault |
| +family). End with exactly one verdict: |
| + |
| +- **READY**: no P1 and no P2. |
| +- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another |
| + round. |
| +- **NOT READY**: one or more P1s, listed. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run the full test suites. Leave GOCACHE unset; you need |
| +not run tests at all, and you must not call AWS. |