carlos / platform Public

spec: video conversion revision 5, Astra round 4 fixes

Endpoint policies on the registry and logs interface endpoints (only
the task execution role, scoped actions); a reaper on a one-minute
schedule that stops any engine task past the hard deadline, with
charging at the full 17-minute bound; recovery lists running and
stopped tasks; a launch-rejected transition with the one retry. Two
activation gates added to the spike. Approved by Paul.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 0e7e991d016d7bc73e8fc2331754141fb9f39331 parent dcd38f8
1 file changed, +114 −39
  • docs/superpowers/specs/2026-11-16-video-conversion-design.md +114 −39

Intent

Human

Yes, but I don't mind a fifth round if that's recommended.

Human

<task-notification> <task-id>ad8a1b25ebf69fbf7</task-id> <tool-use-id>toolu_01EuYtdGhnEURPhnou8WKR8T</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/8509ad95-d983-414c-9679-b3ef222618ef/tasks/ad8a1b25ebf69fbf7.output</output-file> <status>completed</status> <summary>Agent "Fable drafts video conversion design" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Revision 5 is written in place and uncommitted: 791 lines, up from 716. The diff against rev 4 is 114 insertions and 39 deletions, confined to the passages the four fixes need plus the header and review log. ## Where each fix landed - **R4-1 (endpoint policies):** a new "Endpoint policies" paragraph in §5.5 names the principals on all four endpoints. The registry API, registry Docker and logs endpoints admit only the task execution role, for pull and log-write actions scoped to the engine's repository and log group. `ecr:GetAuthorizationToken` is called out as the one action that cannot be repository-scoped. The S3 gateway's conversion-role restriction is restated beside them. The confinement claim in §6 now says credentials smuggled in with the source open nothing. - **R4-2 (console-independent deadline):** the reaper is added to the module in §5.5: a function on a one-minute schedule whose role is `ListTasks`, `DescribeTasks` and `StopTask` on the engine cluster only. The hard-deadline bullet in §5.3 defines the full bound as 17 minutes (15-minute deadline, one schedule interval, 30-second stop grace). The "unknown" transition, invariant I3 and the engine-time budget in §7.2 now charge and reserve at that bound. §8 gets the one line for a non-AWS deployment: the runner's own timeout, such as systemd's `RuntimeMaxSec`. - **R4-3 (recovery without an ARN):** a new bullet in §5.3. The pass lists the cluster's tasks with desired status `RUNNING` and then `STOPPED`, matches the described `startedBy`, saves the ARN before settling, and never replays `RunTask`. If neither list has the task once retention has passed, the row settles as `engine_lost` at the full bound. The crash-after-launch, finish-before-recovery interleaving is in the simulation list. - **R4-4 (launch rejection):** a new "launch rejected" row in the §5.3 transition table, sharing the `start_failures` counter and the one-retry rule with "never started". Ambiguous transport errors stay on the recovery path. Both outcomes are separate simulation steps and separate drills. Both activation gates are stated once in §5.5, repeated as spike item 4 in §7.4, and covered by new drills in §9. The cost line notes the reaper's runs cost cents. ## Two details of mine - **The deadline runs from ECS's task creation time, always.** You suggested start time, falling back to creation time. Using creation time for every task gives one bound from dispatch and is the stricter of the two. - **A row with no task found holds its dispatch place until retention passes,** about 77 minutes after dispatch, before settling as `engine_lost`. That follows your wording. It only arises when the console crashes around the `RunTask` call itself, and it costs one of the four places for that time. ## Decisions for Paul Only decision 1 (the spike) changes: its scoped approval now also covers the reaper and its schedule, and the spike must pass the two activation gates. Decisions 2 to 10 are unchanged.</result> <usage><subagent_tokens>316161</subagent_tokens><tool_uses>5</tool_uses><duration_ms>124363</duration_ms></usage> </task-notification>

diff --git a/docs/superpowers/specs/2026-11-16-video-conversion-design.md b/docs/superpowers/specs/2026-11-16-video-conversion-design.md
index a49c564d6..4d37fb71c 100644
--- a/docs/superpowers/specs/2026-11-16-video-conversion-design.md
+++ b/docs/superpowers/specs/2026-11-16-video-conversion-design.md
@@ -1,8 +1,8 @@
# Video conversion: a phone clip in, a playable video out
-**Date:** 2026-11-16, revision 4 (Paul's ruling R-F after Astra round 3, §13)
-**Status:** draft for a final, narrow review of the Fargate change. Not
-approved.
+**Date:** 2026-11-16, revision 5 (Astra round 4's four fixes, approved by
+Paul, §13)
+**Status:** draft for a diff-only review of those fixes. Not approved.
**Asked for by:** Paul, 2026-11-16. Rulings: amadan discussion 1120.
**Builds on:** the PDF service's door, credential, plan cap and fair-use
shape (`2026-11-02-pdf-service-design.md`).
@@ -11,10 +11,10 @@ stage 3's first product and part of stage 5. See §11.
**Review budget:** AGENTS.md "Stopping rules". The three rounds are spent;
round 4 covers only the Fargate change and the round-3 fixes.
-Marks: **(paul R-F)**, **(paul R-C)** Paul's rulings; **(astra R3-N)** a
-round-3 finding; **(my call)** the author's, cheap to overturn;
-**(estimate)** not measured; **(unverified)** not checked against a source
-in this tree.
+Marks: **(paul R-F)**, **(paul R-C)** Paul's rulings; **(astra R3-N)**,
+**(astra R4-N)** round-3 and round-4 findings; **(my call)** the author's,
+cheap to overturn; **(estimate)** not measured; **(unverified)** not checked
+against a source in this tree.
## 1. Intent
@@ -207,10 +207,11 @@ bytes, preset, bucket, `state`, `execution_id`, `task_arn`, `dispatched_at`,
| submit | no row | `queued` |
| dispatch | `queued` | `running`; a new random `execution_id`; `dispatched_at`; `task_stopped` false |
| task recorded | `running` | `task_arn` set |
-| never started | `running`, ECS says stopped with no start time | `task_stopped`; back to `queued` uncharged, or after a second time `failed` (`engine_unavailable`), settled, uncharged |
+| launch rejected (astra R4-4) | `running`, `RunTask` answers with failures, or with a 4xx, and no task was created | `task_stopped`; `start_failures` + 1; then as "never started" |
+| never started | `running`, ECS says stopped with no start time | `task_stopped`; `start_failures` + 1; back to `queued` uncharged if the cause is retryable and this is the first, otherwise `failed` (`engine_unavailable`), settled, uncharged |
| stopped, success | `running`, exit 0, result read, outputs checked, not retired | `done`; `charged_ms` from ECS; `settled`; `task_stopped`; `cleanup_due` now |
| stopped, failure | `running`, any other stop | `failed`; `charged_ms` from ECS; `settled`; `task_stopped`; `cleanup_due` now |
-| unknown | `running`, ECS has no such task after the hard deadline | `failed` (`engine_lost`); `charged_ms` 15 min; `settled`; `task_stopped`; `cleanup_due = dispatched_at + 1 h` |
+| unknown | `running`, ECS shows no such task and its record retention has passed | `failed` (`engine_lost`); `charged_ms` the full bound; `settled`; `task_stopped`; `cleanup_due = dispatched_at + 1 h` |
| cleanup | `cleanup_due` reached | the result object deleted, and the three outputs unless the row is `done`; `cleanup_due` cleared |
| retire | any row of an app, account or store being removed | `retired_at` set; a `queued` row becomes `failed` uncharged; a `running` row's task is stopped and the row settles by the rows above |
@@ -220,17 +221,35 @@ bytes, preset, bucket, `state`, `execution_id`, `task_arn`, `dispatched_at`,
Then it mints the grant (§5.4) and calls `RunTask` with the execution id as
the idempotency token and the `startedBy` value, and records the task ARN.
- **Tracking (paul R-F).** The pass reads every row with `task_stopped` false
- from ECS by task ARN, or by `startedBy` when a crash left no ARN. ECS is the
- source of the task's state and of its start and stop times. A console
- restart therefore loses nothing: it re-reads the same rows.
-- **The hard deadline** is 15 minutes after dispatch. Past it the console
- calls `StopTask` and keeps tracking until ECS confirms the stop.
+ from ECS by task ARN. ECS is the source of the task's state and of its
+ start and stop times. A console restart therefore loses nothing: it
+ re-reads the same rows.
+- **Recovery without an ARN (astra R4-3).** A crash, or an ambiguous
+ transport error from `RunTask`, can leave a `running` row with no ARN. The
+ pass then lists the cluster's tasks twice, once with desired status
+ `RUNNING` and once with `STOPPED`, describes them, and takes the one whose
+ `startedBy` is the row's execution id. It saves that ARN before anything
+ else, then settles by the ordinary rows. It never calls `RunTask` again
+ for that execution: re-minted transfers would be a different request. If
+ neither list has the task once ECS's retention has passed (the full bound
+ plus an hour after dispatch), the row is "unknown".
+- **The hard deadline (astra R4-2)** is 15 minutes after ECS created the
+ task, and it does not depend on the console. A **reaper**, a scheduled
+ function in the module (§5.5), runs every minute and stops every task in
+ the cluster older than that. The console calls `StopTask` at the same age
+ when it is up. **The full bound** on any execution is therefore 17
+ minutes: the deadline, one schedule interval, and the task's 30-second
+ stop grace. A running execution is reserved at the full bound, and one
+ whose ECS record has expired is charged it.
- **Charge.** ECS's stop time minus its start time. ECS keeps a stopped
task's record for about an hour **(unverified)**, so "unknown" arises only
- when the console was down longer than that, after the hard deadline.
-- **Never started.** No capacity or a failed image pull: no engine time, and
- nothing written. One return to `queued` adds a counter and no obligation
- **(my call)**. A task that ran and failed is never retried.
+ when the console was down longer than that.
+- **Never started, or rejected at launch (astra R4-4).** No capacity, a
+ failed image pull, or `RunTask` refusing the request: no engine time, and
+ nothing written. A definitive rejection releases the row's place at once,
+ in its own transaction. One return to `queued` for a retryable cause adds a
+ counter and no obligation **(my call)**. A task that ran and failed is
+ never retried.
- **Commit.** For exit 0 the console reads the result object (§5.4) and HEADs
the three outputs against the sizes it reports. A retired row never
commits `done`.
@@ -255,7 +274,7 @@ bytes, preset, bucket, `state`, `execution_id`, `task_arn`, `dispatched_at`,
transaction that writes `charged_ms` and the terminal state, and nothing
writes `charged_ms` afterwards.
- **I3. Never undercharged.** `charged_ms` is at least the time ECS reports
- the task ran, or the full 15 minutes when ECS cannot say.
+ the task ran, or the full bound of 17 minutes when ECS cannot say.
- **I4. Obligations retained.** A row that is unsettled, has `cleanup_due`
set, or has `task_stopped` false is never deleted.
- **I5. One execution.** A `done` row's outputs are the keys of its own
@@ -268,10 +287,12 @@ bytes, preset, bucket, `state`, `execution_id`, `task_arn`, `dispatched_at`,
not destroyed while one of its rows has `task_stopped` false.
**The simulation.** The plan's first build task is `internal/sim/mediajobs`: a
-randomized interleaving of submit, dispatch, task start failure, task stop,
-task record expiry, console restart, cleanup, app purge, and store destroy and
-recreate, against the real transition code and a fake engine whose tasks keep
-running until stopped, checking I1 to I7 after every step.
+randomized interleaving of submit, dispatch, launch rejection, an ambiguous
+launch error, task start failure, task stop, a crash after launch with the
+task finishing before recovery, task record expiry, console restart, cleanup,
+app purge, and store destroy and recreate, against the real transition code
+and a fake engine whose tasks keep running until stopped, checking I1 to I7
+after every step **(astra R4-3, R4-4)**.
### 5.4 Authority
@@ -309,7 +330,11 @@ GET and HEAD presigned by the assumed role, and a presigned PUT with a signed
image repository, the network below, the conversion role, and the console's
new permissions: assume that role; `RunTask`, `DescribeTasks`, `ListTasks`
and `StopTask` on this cluster and task definition; and `iam:PassRole` for
-the task execution role only. Its one output is the console variable
+the task execution role only. It also creates the **reaper (astra R4-2)**: a
+minimal function on a one-minute schedule whose role allows `ListTasks`,
+`DescribeTasks` and `StopTask` on this cluster and nothing else. It handles no
+tenant input and stops any task older than the hard deadline, by ECS's
+creation time. The module's one output is the console variable
`CARLOS_MEDIA_ENGINE`. Unset, the door answers 503. The module fails its
precondition if its region is not the store region; on dev and flagship both
are `eu-west-1` **(as reported; those roots are outside this tree)**.
@@ -353,6 +378,25 @@ endpoints. The S3 endpoint's policy admits requests signed by the conversion
role for buckets under the store prefix and for `media-results/`, and reads
of the registry's layer bucket for the image pull.
+**Endpoint policies (astra R4-1).** An interface endpoint with no policy
+admits any caller's credentials, so a hostile file could bring its own. All
+four endpoints therefore name their principals:
+
+- S3 gateway: the conversion role, for the buckets above. The layer bucket is
+ read-only (`GetObject`) for any principal, because the registry signs those
+ requests; nothing can be written through that statement.
+- Registry API and registry Docker endpoints: the task execution role only,
+ and only the image-pull actions, scoped to the engine's repository. The
+ token action (`ecr:GetAuthorizationToken`) cannot be scoped to a
+ repository.
+- Logs: the task execution role only, and only `CreateLogStream` and
+ `PutLogEvents` on the engine's log group.
+
+**Activation gate:** conversion stays off in a deployment until requests
+signed with an unrelated account's credentials have been shown to be refused
+at all four endpoints, and until the reaper has stopped a container that
+ignores its budget while the console is stopped.
+
**DNS (astra R3-2).** A security group cannot stop queries to the VPC
resolver. A Route 53 Resolver DNS Firewall rule on this VPC allows the S3,
registry and logs names for the region and blocks every other name. With no
@@ -468,11 +512,14 @@ is defence in depth: the child shares the container with the handler.
handler's memory. It then holds this execution's five transfers: one tenant's
one source, three output keys nobody else will ever use, and this execution's
result object. It can reach S3 only through the endpoint, as the conversion
-role's presigned requests. It has no credentials, no route or name resolution
-beyond the three AWS services, no console, no other box, and no later
-execution to wait for. Its worst outcome is bad output and a false result for
-the one job whose input attacked it; the engine time is still charged from
-ECS.
+role's presigned requests. The registry and logs endpoints admit only the task
+execution role, which it does not hold, so credentials smuggled in with the
+source open nothing **(astra R4-1)**. It has no credentials of the platform's,
+no route or name resolution beyond the three AWS services, no console, no
+other box, no later execution to wait for, and at most the full bound of 17
+minutes to run **(astra R4-2)**. Its worst outcome is bad output and a false
+result for the one job whose input attacked it; the engine time is still
+charged from ECS.
## 7. Limits, metering and sizing
@@ -486,7 +533,8 @@ ECS.
| Frame rate | 60 | Slow-motion capture is out of scope |
All are settings (`CARLOS_MEDIA_LIMITS`). **The handler's budget is 10 minutes
-and the hard deadline 15 minutes after dispatch (my call)**: every admitted
+and the hard deadline 15 minutes after the task is created (my call)**: every
+admitted
clip must download, convert and upload within the budget, and the spike
confirms that the slowest admitted input does. If one does not, the caps come
down.
@@ -501,7 +549,8 @@ down.
- Per account: at most 2 such rows, and 20 queued or running (429); 30
submissions a minute, burst 10 (429).
- **Engine-time budget:** 60 minutes a UTC day of `charged_ms` on executions
- that did not end `done`, counting a running execution at 15 minutes. Over
+ that did not end `done`, counting a running execution at the full bound of
+17 minutes. Over
it, the door refuses with 429 `execution_budget` and the pass leaves that
account's queued rows until the next UTC day.
- Deployment-wide, at most 200 queued: 503.
@@ -533,8 +582,8 @@ All figures here are **estimates** until the spike reports.
- **Cost.** About 0.003 US dollars a task-minute **(unverified)**: under a
cent for a typical clip, about two cents for the slowest admitted one, 5 to
10 dollars for a thousand clips a month. Fixed: the three interface
- endpoints, about 24 dollars a month, or about 16 without logs; nothing else
- while idle.
+ endpoints, about 24 dollars a month, or about 16 without logs. The reaper's
+ 43,200 runs a month cost cents. Nothing else while idle.
**The spike precedes the build** (decision 1). On a dev cluster it shows:
@@ -545,8 +594,11 @@ All figures here are **estimates** until the spike reports.
environment, the credentials endpoint, the metadata endpoints or the
instance metadata address; no name resolved and no host reached outside
the allowed three; nothing shared between two tasks;
-4. that the override payload fits, and the two store behaviours of §5.4;
-5. whether the single fragmented MP4 plays and seeks progressively in Safari
+4. the two activation gates of §5.5: all four endpoints refuse an unrelated
+ account's credentials, and the reaper stops a container that ignores its
+ budget while the console is stopped, within the full bound;
+5. that the override payload fits, and the two store behaviours of §5.4;
+6. whether the single fragmented MP4 plays and seeks progressively in Safari
on iOS and macOS, Chrome and Firefox, and the playlist in Safari and a
JavaScript HLS player. If progressive playback fails anywhere, the
fallback is a second, ordinary faststart MP4, and G2 is amended.
@@ -569,6 +621,8 @@ MinIO-compatible backend arrives, its engine runs the same image as a
one-shot container on a box the console can reach, with the equivalent
sandbox: a fresh container per execution, no credentials, size-limited
scratch, memory and time limits, and a network that reaches only the store.
+Its hard deadline is the runner's own timeout on that container, such as
+systemd's `RuntimeMaxSec`, in place of the reaper.
## 9. Rollout and acceptance gates
@@ -606,8 +660,16 @@ live wherever `CARLOS_MEDIA_ENGINE` is set.
until one is confirmed stopped, and each job completes and is charged ECS's
times.
- A task with a bad image digest fails to start twice and the job ends
- `engine_unavailable`, uncharged. A task that ignores its budget is stopped
- at the hard deadline.
+ `engine_unavailable`, uncharged; so does a `RunTask` the service rejects,
+ tested separately from an ambiguous transport error, which takes the
+ recovery path. With the console stopped, a task that ignores its budget is
+ stopped by the reaper within 17 minutes.
+- From inside a task, requests signed with an unrelated account's
+ credentials are refused at the S3, registry API, registry Docker and logs
+ endpoints.
+- The console killed after `RunTask` and before the ARN is saved, with the
+ task finishing before the restart: the job completes and is charged ECS's
+ times.
- Store destroy with a task running is refused until the task has stopped;
after destroy and recreate, the same key and bytes make a new job.
- An app purged with one job queued and one running: both are retired, the
@@ -670,8 +732,9 @@ Already ruled: a platform engine, Fargate (R-F), the lifecycle cut (R-C).
HLG, portrait with rotation, variable frame rate, an ordinary 1080p
clip); his scoped approval to create in the dev account, for its
duration, an ECS cluster and task definition, an image repository, the
- engine VPC with its endpoints and DNS rule, and the conversion role; the
- isolation and credential checks of §7.4; and Safari checks on a real
+ engine VPC with its endpoints and DNS rule, the reaper and its schedule,
+ and the conversion role; the isolation and credential checks and the two
+ activation gates of §7.4; and Safari checks on a real
iPhone by Paul or on the tito-studio Mac. Recommend approving it as the
first task.
2. **The engine's network:** a small VPC of its own, which lets a DNS
@@ -713,4 +776,16 @@ Rounds 1 and 2: sixteen findings, all accepted. **Round 3**
- **R3-4** store destroy: it retires the rows, stops their tasks and waits
for them; jobs are keyed to a store incarnation (§5.2, §5.3, I7).
+**Round 4** (`CODEX-FINDINGS-VIDEO-R4.md`, 2 P1, 2 P2), all four applied
+with Paul's approval:
+
+- **R4-1** open interface endpoints: principal-restricted policies on all
+ four endpoints, and an activation gate (§5.5, §6).
+- **R4-2** deadline dependent on the console: a reaper outside the console
+ and the container, a full bound of 17 minutes, charged and reserved at
+ that bound, and an activation gate (§5.3, §5.5, §7.2).
+- **R4-3** recovery missing a finished task: both task lists, the ARN saved
+ before settlement, no `RunTask` replay (§5.3).
+- **R4-4** launch rejection: its own uncharged transition (§5.3).
+
**Findings not accepted:** none.