spec: video conversion revision 7, no standing key, round 6 fixes
Paul's R-K: no long-lived key; the console assumes the conversion role from its instance role, so each execution fits a one-hour window (50 minute engine maximum, class-sized tasks, provisional per-file maximums for the spike to settle). Astra R6: codec dependsOn deadline START with a refusal gate; reservations cover the larger of success and failure charges; a short class picked by source size; loudness gain capped by the true-peak ceiling.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/specs/2026-11-16-video-conversion-design.md+256 −229
Intent
Sure. no key.
<task-notification> <task-id>ad8a1b25ebf69fbf7</task-id> <tool-use-id>toolu_01Gsbqi7upkLJouj9XFXVow2</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 7 is written in place and uncommitted: 993 lines, up from 966, so it did not get shorter as you asked. Removing the caller key saved a little, but the refusal gate, the class tables and the new drills added more. I also compressed the review log to a per-round summary, which goes beyond "touch only what these changes need"; restore it from rev 6 if you want the diff narrower. ## Where each change landed - **R-K (no key):** §5.4 drops the caller user and its access key. The console assumes the conversion role from its instance role for one hour per execution. A new bullet, "The hour is the engine window", says the download, every resume and the start of the last upload must fall inside it; an execution that misses fails `grant_expired`, charged the time it ran. §6 repeats the resume rule at the download step. This closes R6-2. - **R-K (sizes and maximums):** §7.1 is now a class table (task size, deadline, granted duration per preset and class) and a table of provisional maximums marked as estimates: video 2 hours up to 1080p and 30 minutes above it, 40 GiB; audio 8 hours, 10 GiB. The longest deadline is 50 minutes. 4K HDR is named as the slow case for the spike to settle. - **R6-1 (refusal gate):** §5.5 makes `codec` depend on `deadline` with condition `START` and sets both stop timeouts to 30 seconds. A new "refusal gate" paragraph has the console read each task definition revision and refuse it unless those hold, answering 503 `engine_misconfigured`. The trust statement lists Fargate's process isolation, its scheduling, the shared kernel and essential-container termination, and says it is not a defence against a kernel escape. Delayed and failed timer startup are in the activation gate, the spike and the drills. No timing estimate is used. - **R6-3 (reservation):** §7.3 reserves `w × max(granted duration, deadline + stop grace)` in the dispatch transaction, with both grants set to at most `R/w` so the reservation fits. `charged_ms` is ECS's runtime, never capped. Concurrent audio and video settlement and the grace-boundary cases are in the simulation list in §5.3. - **R6-4 (short class):** the source's size picks the class in §7.1 (video up to 1 GiB, audio up to 256 MiB are short). A short job with a longer source exits at the probe with `needs_long_class`, and the app resubmits with `"class": "long"`. The class is part of the job id, so that is a new job. §7.2 gives each class its own dispatch capacity and has the pass pick per class. - **R6-5 (loudness):** §5.1 defines one linear gain, the smaller of what reaches -16 LUFS and what reaches -1.5 dBTP, so the peak ceiling wins and dynamics are never compressed. Silence gets no gain and all-zero peaks. The drill in §9 accepts either outcome and checks that loudness range is not narrowed. ## Calls of mine you should know about - **Short-class figures are my guesses:** 15-minute deadline and 10 minutes of granted source for video, 10-minute deadline and 2 hours for audio. The long video task is 16 vCPUs and 32 GB; whether Fargate offers 16 arm64 vCPUs is unverified and is a spike item. - **A short video job that needs the long class is charged for its download and probe** before it is refused, then again when resubmitted. - **The console gains one more permission,** reading the task definition, for the gate. - **The reaper now stops any task over 70 minutes old.** ## Decisions for Paul 1. **The spike:** no longer includes a caller user; now includes the timer drills. Recommended as the first task. 2. **The engine's network:** its own small VPC with a DNS allow-list (recommended), or a private subnet of the console's VPC. 3. **No wait for stage 1:** ship on the app's own bucket and serving (recommended), or wait for `kind:media`. 4. **Authority (ruled in part by R-K):** the conversion role assumed per execution from the console's own role, sessions of at most an hour, no standing key, infected sources always refused (recommended), or the console's own role presigning. The long-lived key option is gone. 5. **Per-file maximums, provisional until the spike:** video 2 hours up to 1080p and 30 minutes above it, 40 GiB; audio 8 hours, 10 GiB (recommended as the starting point), or lower starting values. 6. **Plan values:** Free 30, Personal 600, Community 1,200, Business 12,000 video minutes, refused at twice the limit, plus a media pack of 1,000 minutes (recommended). 7. **How audio is counted:** one allowance with an audio minute weighing a tenth of a video minute (recommended), or a separate `audio_minutes_month`. 8. **Browser uploads in scope** as `carlos store uploads` (recommended), or native clients only. 9. **Always re-encode, HDR tone-mapped, one poster, audio normalised to -16 LUFS** (recommended), or add the remux path, or make normalisation a request option. 10. **On for every app** with a store and a Service credential (recommended), or a per-app switch. 11. **Codec licences:** accept or have checked before flagship. A question, no recommendation.</result> <usage><subagent_tokens>384546</subagent_tokens><tool_uses>5</tool_uses><duration_ms>180235</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 05777e2a2..fc16f85d1 100644 |
| --- a/docs/superpowers/specs/2026-11-16-video-conversion-design.md |
| +++ b/docs/superpowers/specs/2026-11-16-video-conversion-design.md |
| @@ -1,7 +1,6 @@ |
| # Media conversion: video and audio in, playable files out |
| -**Date:** 2026-11-16, revision 6 (Astra round 5, and Paul's rulings R-A and |
| -R-X, §13) |
| +**Date:** 2026-11-16, revision 7 (Astra round 6 and Paul's ruling R-K, §13) |
| **Status:** draft for a narrow review of those changes. 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 |
| @@ -13,7 +12,8 @@ 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)**, |
| **(astra R4-N)**, **(astra R5-1)** findings of rounds 3 to 5; **(paul R-A)**, |
| -**(paul R-X)** his rulings on audio and limits; **(my call)** the author's, |
| +**(paul R-X)**, **(paul R-K)** his rulings on audio, limits and keys; |
| +**(astra R6-N)** round 6; **(my call)** the author's, |
| cheap to overturn; **(estimate)** not measured; **(unverified)** not checked |
| against a source in this tree. |
| @@ -118,6 +118,9 @@ every tenant's TLS). His rulings of 2026-11-16: |
| videos and audio files they can process." The 3-minute, 512 MiB premise of |
| earlier revisions is gone. Per-file caps are generous and the plan |
| allowance is the limiter (§7). |
| +- **R-K: no long-lived key.** The console assumes the conversion role from |
| + its own instance role, so a grant lasts at most one hour. Every execution |
| + must finish inside that hour, on a task large enough to do so (§7.1). |
| ## 5. The design |
| @@ -142,10 +145,13 @@ Two presets. Every admitted source is re-encoded **(my call)**. |
| - Source: an audio file, or the first audio track of a video file. |
| - Audio: AAC-LC at 48 kHz; mono at 64 kbit/s when the source is mono, |
| otherwise stereo at 128 kbit/s, with more channels mixed down to stereo. |
| -- Loudness: normalised to -16 LUFS integrated with a true peak of -1.5 dBTP, |
| - in two passes (measure, then one linear gain), so dynamics are untouched. |
| - -16 is the usual target for speech heard on phones, and voice recordings |
| - are the first use; it is one setting **(my call)**. |
| +- Loudness **(astra R6-5)**: one linear gain, never dynamic processing. The |
| + gain is the smaller of what brings integrated loudness to -16 LUFS and |
| + what brings the true peak to -1.5 dBTP. The peak ceiling wins, so a quiet |
| + recording with a loud moment ends below -16 LUFS, and dynamics are never |
| + compressed. A source with no measurable loudness (silence) gets no gain |
| + and converts to silence with all-zero peaks. -16 is the usual target for |
| + speech on phones **(my call)**. |
| - Container: the same fragmented MP4 and byte-range playlist. |
| - Waveform: `peaks.json`, `{"version": 1, "duration_ms": N, "peaks": [...]}` |
| with exactly 1,000 integers from 0 to 255: the peak absolute amplitude of |
| @@ -165,8 +171,8 @@ belong to one execution: |
| `<etag>` is the source's ETag without quotes |
| (`internal/objstore/clamav.go:517`). Each PUT is create-only (`If-None-Match: |
| *`, signed). **Every output stays under the 5 GB a single PUT carries (paul |
| -R-X):** four hours of video at the bitrate ceiling is about 4.7 GB, and twelve |
| -hours of audio about 0.7 GB; the handler fails `output_too_large` rather than |
| +R-X):** two hours of video at the bitrate ceiling is about 2.4 GB, and eight |
| +hours of audio about 0.5 GB; the handler fails `output_too_large` rather than |
| exceed it. A later ladder preset is a sibling directory. The app learns the |
| keys from the job (§5.2); no platform code reads the tenant's bucket to learn |
| what was converted, and there is no `result.json` **(my call under R-C: it |
| @@ -182,8 +188,9 @@ through `apiAccountApp`, as the PDF and scan doors do. The credential is the |
| one an app holds for PDFs or scanning. |
| POST takes strict JSON, `{"key": "uploads/a1b2.mov"}`, with an optional |
| -`preset`: `video-720p` (the default) or `audio-aac`. Checks run in order and |
| -stop at the first failure: |
| +`preset` (`video-720p`, the default, or `audio-aac`) and an optional `class` |
| +(`short` or `long`, §7.1; by default the source's size picks it). Checks run |
| +in order and stop at the first failure: |
| | Check | Refusal | |
| |---|---| |
| @@ -206,10 +213,11 @@ checks and the insert run under the app's store walk lock |
| teardown **(astra R3-4)**. |
| **The job id** is the first 32 hex characters of the SHA-256 of `"v1"`, the |
| -key, the ETag and the preset, each followed by a zero byte. A job belongs to one **store incarnation** (below), |
| -so the door looks rows up by account, app, incarnation and job id. A repeat |
| -POST answers 200 with the existing job, whatever its state, and starts |
| -nothing. A `failed` job stays failed. |
| +key, the ETag, the preset and the class, each followed by a zero byte, so a |
| +resubmission in the long class is a new job **(astra R6-4)**. A job belongs to |
| +one **store incarnation** (below), so the door looks rows up by account, app, |
| +incarnation and job id. A repeat POST answers 200 with the existing job, |
| +whatever its state, and starts nothing. A `failed` job stays failed. |
| **GET** answers the job: `id`, `state` (`queued`, `running`, `done`, |
| `failed`), `error` (`code`, `message`), and on `done` the source's duration, |
| @@ -237,7 +245,8 @@ bucket, so eligibility is established, never inferred from its name. |
| A console table `media_jobs`, one row per job, changed only in database |
| transactions. It holds: account, app, store incarnation, job id, key, etag, |
| bytes, preset, bucket, `state`, `execution_id`, `task_arn`, `dispatched_at`, |
| -`deadline_s`, `task_stopped`, `start_failures`, `charged_ms`, `settled`, |
| +`class`, `granted_s`, `deadline_s`, `task_stopped`, `start_failures`, |
| +`charged_ms`, `settled`, |
| `source_ms`, |
| `result`, `error`, `cleanup_due`, `retired_at`. |
| @@ -246,7 +255,7 @@ bytes, preset, bucket, `state`, `execution_id`, `task_arn`, `dispatched_at`, |
| | Step | From | To | |
| |---|---|---| |
| | submit | no row | `queued` | |
| -| dispatch | `queued` | `running`; a new random `execution_id`; `dispatched_at`; `deadline_s` (§7.3); `task_stopped` false | |
| +| dispatch | `queued` | `running`; a new random `execution_id`; `dispatched_at`; `granted_s` and `deadline_s`, chosen so their reservation fits the allowance (§7.3); `task_stopped` false | |
| | task recorded | `running` | `task_arn` set | |
| | 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 | |
| @@ -331,35 +340,38 @@ bytes, preset, bucket, `state`, `execution_id`, `task_arn`, `dispatched_at`, |
| 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)**. |
| +app purge, store destroy and recreate, and two accounts' audio and video jobs |
| +dispatched and settled concurrently, including runs that end exactly at the |
| +deadline and inside the stop grace, against the real transition code and a |
| +fake engine whose tasks keep running until stopped, checking I1 to I7 and |
| +that no account is ever reserved or charged past its allowance **(astra R4-3, |
| +R4-4, R6-3)**. |
| ### 5.4 Authority |
| -- The deployment has one **conversion role**. It allows `GetObject` under the |
| - store bucket prefix, `PutObject` under `derived/` in those buckets, and |
| - `PutObject` under `media-results/` in the deployment bucket. It carries two |
| - unconditional Denies: reading any object tagged infected, and any PUT that |
| - sets a scan tag (the rule of `aws.go:200-226`). Infected sources are |
| - therefore refused whatever the store's `Enforce` flag says, at the door's |
| - HEAD and at the task's GET. |
| -- **Who assumes it (paul R-X).** A grant must outlive its job, and jobs now |
| - run for hours. A role assumed from another role, which is what the |
| - console's instance role would be doing, lasts one hour at most; a role |
| - assumed by an IAM user lasts up to twelve **(unverified)**. So the module |
| - creates a **caller user** whose only permission is to assume the |
| - conversion role, and the console holds its access key as a secret |
| - (`CARLOS_MEDIA_CALLER_KEY`), as it holds the scan signing keys. The role's |
| - trust policy names that user alone. This is the one long-lived credential |
| - the design adds (decision 4). |
| -- For each execution the console assumes the role for the row's deadline |
| - plus 30 minutes, with a session policy narrowing it to the one bucket and |
| - the one result key, and presigns five transfers: a GET for the source with |
| - `If-Match: <etag>` signed; three create-only PUTs for the outputs; one |
| +- The deployment has one **conversion role**, assumable only by the console's |
| + instance role. It allows `GetObject` under the store bucket prefix, |
| + `PutObject` under `derived/` in those buckets, and `PutObject` under |
| + `media-results/` in the deployment bucket. It carries two unconditional |
| + Denies: reading any object tagged infected, and any PUT that sets a scan |
| + tag (the rule of `aws.go:200-226`). Infected sources are therefore refused |
| + whatever the store's `Enforce` flag says, at the door's HEAD and at the |
| + task's GET. |
| +- **No standing key (paul R-K; closes astra R6-2).** There is no IAM user and |
| + no stored credential. A role assumed from a role lasts at most one hour |
| + **(unverified)**, so for each execution the console assumes the conversion |
| + role for one hour, with a session policy narrowing it to the one bucket |
| + and the one result key, and presigns five transfers: a GET for the source |
| + with `If-Match: <etag>` signed; three create-only PUTs for the outputs; one |
| create-only PUT for the result object, |
| `media-results/<execution id>.json`. The credentials never leave the |
| - console. The transfers are valid until the grant expires. |
| + console. |
| +- **The hour is the engine window.** A transfer begun before the grant |
| + expires completes; one begun after is refused by the store. So the |
| + download, every resume of it, and the start of the last upload must all |
| + fall inside the hour. An execution that misses it fails `grant_expired` |
| + and is charged the time it ran. The deadline is at most 50 minutes (§7.3), |
| + which leaves the margin. |
| - **The result object (paul R-F)** carries the probe facts, the output sizes |
| and ETags, the ffmpeg version, or a named error. It lives in the deployment |
| bucket, where no tenant can write, so an app cannot forge the duration its |
| @@ -372,59 +384,65 @@ after every step **(astra R4-3, R4-4)**. |
| through the five transfers. |
| To prove on dev first **(unverified)**: the tag-conditioned Deny holds for a |
| -GET and HEAD presigned by the assumed role; a presigned PUT with a signed |
| -`If-None-Match: *` is refused when the object exists; and a transfer presigned |
| -from a nine-hour session is still accepted in its ninth hour. |
| +GET and HEAD presigned by the assumed role, and a presigned PUT with a signed |
| +`If-None-Match: *` is refused when the object exists. |
| ### 5.5 The engine: one Fargate task per execution (paul R-F) |
| `infra/modules/media-engine` creates an ECS cluster, a task definition, an |
| 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. It also creates the caller user (§5.4) and the |
| -**reaper**: 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 platform's |
| -maximum deadline plus ten minutes. It is a backstop against a task that never |
| -starts or a deadline container that fails to launch; **no bound in this spec |
| -rests on its timing (astra R5-1)**. 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)**. |
| +and `StopTask` on this cluster and task definition, and reading that task |
| +definition; and `iam:PassRole` for |
| +the task execution role only. It also creates the **reaper**: 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 more than 70 minutes old. It is a |
| +backstop; **no bound in this spec rests on its timing (astra R5-1)**. 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)**. |
| **The task** has two containers from the same arm64 image, pinned by digest, |
| -both essential. |
| +both essential, each with `stopTimeout` set explicitly to 30 seconds. |
| -- **`codec`** runs the handler: it downloads, probes, converts (§6), uploads, |
| - writes the result object and exits. Non-root, a read-only root filesystem, |
| - every capability dropped, and the task's ephemeral storage as its only |
| - writable space. That storage bounds a job's bytes and files; filling it |
| - ends that task alone. |
| - **`deadline` (astra R5-1)** runs `sleep` for the job's deadline and exits. |
| ECS documents that when an essential container stops, every other |
| container in the task is stopped |
| (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html) |
| **(unverified; a spike drill)**. The console sets the sleep per job as a |
| container override on `deadline`, which nothing inside the task can change. |
| - |
| -`codec` cannot reach the timer: it is non-root with no capabilities, so it |
| -cannot signal another container's processes or set the clock; the two |
| -containers have separate process namespaces (the task does not set `pidMode: |
| -task`) and separate filesystems, and share no volume; `deadline` listens on |
| -nothing; and each container has its own CPU and memory reservation, so `codec` |
| -cannot starve it. **What still rests on Fargate's container isolation:** the |
| -two containers share one microVM and one kernel. An exploit that escapes the |
| -`codec` container inside that microVM could reach the timer. The microVM |
| -boundary to other tasks is unaffected, and such a task is still ended by the |
| -reaper and charged from ECS's times. |
| - |
| -**Size and storage per preset (paul R-A, R-X).** `video-720p`: 4 vCPUs and 8 |
| -GB. `audio-aac`: 1 vCPU and 2 GB. Ephemeral storage is the default 20 GiB, or |
| -the source size plus 8 GiB when that is more, set per job. The console passes |
| -all three as task overrides **(unverified that Fargate accepts them per |
| -run)**; otherwise the module defines one task definition per preset and |
| -storage tier. |
| +- **`codec`** runs the handler: it downloads, probes, converts (§6), uploads, |
| + writes the result object and exits. It **depends on `deadline` with |
| + condition `START` (astra R6-1)**, so it cannot start before the timer is |
| + running, and if the timer fails to start the task fails without `codec` |
| + ever running. Non-root, a read-only root filesystem, every capability |
| + dropped, and the task's ephemeral storage as its only writable space. That |
| + storage bounds a job's bytes and files; filling it ends that task alone. |
| + |
| +**The refusal gate (astra R6-1).** Before it dispatches against a task |
| +definition revision, the console reads that revision and refuses it unless: |
| +both containers are essential; `codec` depends on `deadline` with `START`; |
| +both stop timeouts are 30 seconds; there is no task role, no `pidMode` and no |
| +volume shared between the two. A refused revision takes no work and the door |
| +answers 503 `engine_misconfigured`. |
| + |
| +`codec` cannot reach the timer by ordinary means: it is non-root with no |
| +capabilities, so it cannot signal another container's processes or set the |
| +clock; the containers have separate process namespaces and filesystems and |
| +share no volume; `deadline` listens on nothing; and each has its own CPU and |
| +memory reservation. **What the bound trusts:** Fargate's process isolation |
| +between containers, its scheduling of the timer, the kernel the two |
| +containers share inside the microVM, and ECS's essential-container |
| +termination. It is not a defence against a kernel escape from `codec`. The |
| +microVM boundary to other tasks is unaffected. |
| + |
| +**Size per preset and class (paul R-K).** The console sets CPU, memory and |
| +ephemeral storage per job from the table in §7.1, as task overrides |
| +**(unverified that Fargate accepts them per run)**; otherwise the module |
| +defines one task definition per row of that table, and the gate above |
| +applies to each. |
| **Isolation (closes astra R3-1).** AWS documents that each Fargate task has |
| its own isolation boundary and does not share the underlying kernel, CPU, |
| @@ -474,9 +492,11 @@ four endpoints therefore name their principals: |
| **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 deadline container has ended a task |
| -whose `codec` container ignores every signal and tries to signal or kill the |
| -timer, with the console stopped **(astra R5-1)**. |
| +at all four endpoints; until `codec` has been shown not to start before |
| +`deadline` is running, nor at all when `deadline` fails to start **(astra |
| +R6-1)**; and until the deadline container has ended a task whose `codec` |
| +ignores every signal and tries to signal or kill the timer, with the console |
| +stopped **(astra R5-1)**. |
| **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, |
| @@ -564,7 +584,9 @@ Treat every source as an exploit attempt. |
| **Download.** The handler streams the source to disk in one GET, resuming a |
| broken connection with a `Range` request under the same signed `If-Match`. It |
| -enforces the byte cap as it goes **(paul R-X)**. |
| +enforces the byte cap as it goes **(paul R-X)**. A resume after the grant has |
| +expired is refused by the store and fails the execution `grant_expired` |
| +**(paul R-K)**. |
| **Before ffmpeg starts.** The handler reads the first bytes in Go and accepts |
| these families: ISO BMFF (`ftyp`: MP4, MOV, 3GP, M4A) and Matroska/WebM |
| @@ -584,7 +606,8 @@ checks, exiting before any encoding: |
| | a side over 4096, or more pixels than 3840x2160 | `source_dimensions` | |
| | over 60 frames a second | `source_frame_rate` | |
| | longer than the preset's maximum duration (§7.1) | `source_too_long` | |
| -| longer than the allowance granted to this job, or predicted not to finish before the deadline (§7.3) | `allowance_exceeded` | |
| +| short class: longer than the class's granted duration (§7.1). The message says to resubmit with `"class": "long"` | `needs_long_class` | |
| +| longer than the allowance granted to this job (§7.3) | `allowance_exceeded` | |
| | probe fails or exceeds 60 s | `unreadable` | |
| **The command.** ffmpeg and ffprobe are child processes with a fixed input |
| @@ -616,40 +639,57 @@ charged from ECS. |
| ## 7. Limits, metering and sizing |
| -### 7.1 Per-file maximums (paul R-X) |
| +### 7.1 Classes, task sizes and per-file maximums (paul R-X, R-K) |
| + |
| +Every execution must finish inside the one-hour grant, so the per-file |
| +maximum is what the largest task converts in that window. A **class** fixes |
| +the task size, the deadline and the granted duration before anything is known |
| +about the source but its size **(astra R6-4)**. |
| -Generous on purpose. The allowance (§7.3) is the limiter. |
| +| Preset | Class | Picked when | Task | Deadline | Granted duration | |
| +|---|---|---|---|---|---| |
| +| `video-720p` | short | source up to 1 GiB, class not given | 4 vCPU, 8 GB | 15 min | 10 min | |
| +| `video-720p` | long | larger source, or `"class": "long"` | 16 vCPU, 32 GB | 50 min | the video maximum | |
| +| `audio-aac` | short | source up to 256 MiB, class not given | 1 vCPU, 2 GB | 10 min | 2 hours | |
| +| `audio-aac` | long | larger source, or `"class": "long"` | 2 vCPU, 4 GB | 50 min | the audio maximum | |
| -| | `video-720p` | `audio-aac` | Why | |
| -|---|---|---|---| |
| -| Duration | 4 hours | 12 hours | A film or a long recording; keeps every output under 5 GB | |
| -| Source size | 100 GiB | 20 GiB | Four hours of 4K30 phone video is about 40 GB; Fargate storage goes to 200 GiB, less outputs and headroom | |
| -| Dimensions | 3840x2160 | | What cameras record | |
| -| Frame rate | 60 | | | |
| +A short job whose source turns out longer than its granted duration exits at |
| +the probe with `needs_long_class`, and the app submits it again with |
| +`"class": "long"`: a new job, since requeue was cut. Ephemeral storage is 20 |
| +GiB, or the source size plus 8 GiB when that is more. |
| -All are settings (`CARLOS_MEDIA_LIMITS`), **my call** on the numbers. The |
| -source is probed after it is downloaded, so refusing a large file by duration |
| -costs the minutes its download took. |
| +**Provisional maximums (estimates; the spike sets the final values).** |
| + |
| +| | `video-720p` | `audio-aac` | |
| +|---|---|---| |
| +| Duration, sources up to 1080p | 2 hours | 8 hours | |
| +| Duration, sources above 1080p | 30 minutes | | |
| +| Source size | 40 GiB | 10 GiB | |
| +| Dimensions, frame rate | 3840x2160, 60 | | |
| + |
| +4K HDR is the slow case: decoding and tone-mapping may hold it well under 30 |
| +minutes, and the spike decides whether it gets its own figure or a refusal. |
| +Audio encodes far faster than real time, so its maximum stays long. All are |
| +settings (`CARLOS_MEDIA_LIMITS`). The source is probed after it is |
| +downloaded, so refusing a large file by duration costs the minutes its |
| +download took. |
| ### 7.2 Fair use (every deployment) |
| **(my call on the numbers.)** |
| -- **Dispatch cap (astra R3-3):** at most 8 tasks, counted as rows with a |
| - dispatched execution and `task_stopped` false. A row frees its place only |
| - when ECS confirms its task stopped, never by reaching a terminal state. |
| -- Per account: at most 2 such rows, and 20 queued or running (429); 30 |
| - submissions a minute, burst 10 (429). |
| -- **Long jobs (paul R-X):** an execution whose deadline is over 30 minutes is |
| - long. At most 1 per account and 4 in the deployment run at once, so hours |
| - of film never hold every place and a clip is not queued behind them. |
| -- Deployment-wide, at most 200 queued: 503. |
| +- **Dispatch capacity is per class (astra R3-3, R6-4):** at most 6 short and |
| + 2 long tasks in the deployment, and 2 short and 1 long per account, each |
| + counted as rows with a dispatched execution and `task_stopped` false. A row |
| + frees its place only when ECS confirms its task stopped. The pass picks the |
| + next row for each class separately, so an account's waiting long row never |
| + hides its eligible short row, and film never queues a clip. |
| +- Per account: 20 queued or running (429); 30 submissions a minute, burst 10 |
| + (429). Deployment-wide, at most 200 queued: 503. |
| -The console's `allowWrite` limit does not apply, as for PDF. The engine-time |
| -budget of earlier revisions is gone: failed executions are charged to the |
| -allowance instead (§7.3). |
| +The console's `allowWrite` limit does not apply, as for PDF. |
| -### 7.3 The allowance, and how a deadline is chosen (paul R-X) |
| +### 7.3 The allowance, the grant and the reservation (paul R-X) |
| **The allowance.** A new `plans.Limits` field, `MediaMinutesMonth` |
| (`media_minutes_month`), handled exactly as `pdf_renders_month`: monthly, a |
| @@ -657,82 +697,78 @@ warning at the limit, a 402 from `capCopy` at twice the limit, ops accounts |
| exempt, zero meaning no limit, a new `capID`. A deployment with no catalog |
| uses one per-account figure from `CARLOS_MEDIA_LIMITS` in its place. |
| -**What is charged.** Every figure is a query over `media_jobs`. |
| - |
| -- A `done` job: its source duration, times the preset's weight. |
| -- Any other settled execution: its engine time (`charged_ms`), times the |
| - weight. A failure costs what it ran. |
| -- A running execution: reserved at its full bound, times the weight. |
| -- **Weights (paul R-A):** `video-720p` 1, `audio-aac` 0.1. One allowance in |
| - video minutes, with an hour of audio costing six of them (decision 7). |
| - |
| -**Remaining**, `R`, is twice the limit, less what is charged and reserved this |
| -UTC month. A preset's weight `w` turns it into minutes of that preset, `R/w`. |
| - |
| -**The deadline** is fixed by the console at dispatch, before anything is known |
| -about the source but its size, as the smallest of: |
| - |
| -1. the platform maximum, 9 hours; |
| -2. the preset's ceiling: time to move the file both ways at a conservative |
| - rate, plus the preset's maximum duration times its worst-case speed factor |
| - (from the spike; assumed 2 for video and 0.1 for audio). About 9 hours for |
| - video and 2 for audio; |
| -3. what the allowance can pay for: `R/w`. |
| - |
| -With it the console passes the job's **granted duration**: the smaller of the |
| -preset's maximum duration and `R/w`. |
| - |
| -- If `R/w` is under 5 minutes, the row waits while the account has another |
| - execution running, and otherwise fails `allowance_exceeded`, uncharged. |
| -- **The probe refuses early.** A source longer than the granted duration, or |
| - one whose duration times the measured factor for its kind does not fit the |
| - time left, exits `allowance_exceeded` before encoding, charged only the |
| - minutes used so far. |
| -- A job that still overruns is stopped by the deadline container and fails |
| - `deadline_exceeded`. |
| - |
| -So no execution can cost more than the allowance had left: success costs at |
| -most the granted duration, and failure at most the deadline and its stop |
| -grace. |
| +**What is charged.** Every figure is in allowance minutes and is a query over |
| +`media_jobs`. `w` is the preset's weight: `video-720p` 1, `audio-aac` 0.1 |
| +**(paul R-A, decision 7)**. |
| + |
| +- A `done` job: `w` times its source duration. |
| +- Any other settled execution: `w` times its engine time. `charged_ms` is |
| + ECS's runtime, recorded as it was and never capped. |
| +- A running execution: its **reservation**, `w × max(granted duration, |
| + deadline + stop grace)`, the most it can cost whether it succeeds or fails |
| + **(astra R6-3)**. |
| + |
| +**Dispatch (astra R6-3).** In the dispatch transaction the console computes |
| +`R`: twice the limit, less everything charged and reserved for the account |
| +this UTC month. It then sets, in minutes: |
| + |
| +- granted duration = the smaller of the class's granted duration and `R/w`; |
| +- deadline = the smaller of the class's deadline and `R/w` less the stop |
| + grace. |
| + |
| +Both are at most `R/w`, so the reservation is at most `R`, and it is written |
| +in the same transaction. Two rows dispatched together therefore cannot spend |
| +the same allowance. If the deadline would be under 3 minutes, the row waits |
| +while the account has another execution running, and otherwise fails |
| +`allowance_exceeded`, uncharged. |
| + |
| +**At the probe**, a source longer than the granted duration exits before |
| +encoding: `needs_long_class` when the class's own figure was the limit, |
| +`allowance_exceeded` when the allowance was. It is charged the minutes used |
| +so far. A job that overruns its deadline is stopped by the deadline container |
| +and fails `deadline_exceeded`. |
| Proposed plan values (decision 6): Free 30, Personal 600, Community 1,200, |
| -Business 12,000 video minutes a month, and a **media pack** of 1,000 minutes |
| -for accounts that convert long video. Outputs count as the tenant's storage |
| -(roadmap ruling 6). |
| +Business 12,000 video minutes a month, and a **media pack** of 1,000 minutes. |
| +Outputs count as the tenant's storage (roadmap ruling 6). |
| -### 7.4 Task size, cost and the spike |
| +### 7.4 Cost and the spike |
| All figures here are **estimates** until the spike reports. |
| - **Time.** A task takes 30 to 60 seconds to start. A three-minute 1080p30 |
| - phone clip then converts in 30 to 90 seconds on 4 vCPUs. Long video runs |
| - at roughly half to twice real time depending on the source. Audio runs at |
| - twenty times real time or better on 1 vCPU. |
| -- **Cost.** A video task is about 0.003 US dollars a minute and an audio |
| - task about 0.0007 **(unverified)**. That is under a cent for a clip, 30 |
| - cents to a dollar for a four-hour film, and under a cent for an hour of |
| - audio; at most about 0.6 cents per video minute of allowance. Storage |
| - above 20 GiB adds cents an hour. Fixed: the three interface endpoints, |
| - about 24 dollars a month, or about 16 without logs. The reaper's runs |
| - cost cents. Nothing else while idle. |
| + phone clip then converts in 30 to 90 seconds on 4 vCPUs. On 16 vCPUs, |
| + 1080p video is assumed to run at three to five times real time and 4K at |
| + about real time. Audio runs at twenty times real time or better. |
| +- **Cost.** About 0.003 US dollars a minute for the short video task, 0.011 |
| + for the long one, and under 0.001 for audio **(unverified)**. Under a cent |
| + for a clip, about half a dollar for a two-hour film, under a cent for an |
| + hour of audio; at most about half a cent per video minute of allowance. |
| + Fixed: the three interface endpoints, about 24 dollars a month, or about |
| + 16 without logs. The reaper's runs cost cents. Nothing else while idle. |
| **The spike precedes the build** (decision 1). On a dev cluster it shows: |
| -1. start time, wall time and peak memory at two task sizes and two or three |
| - x264 presets, for phone clips and for an hour of 1080p and of 4K, giving |
| - the speed factors §7.3 uses; and the same for an hour of audio; |
| +1. start time, wall time and peak memory for each row of §7.1's class table |
| + at two or three x264 presets, for phone clips, an hour of 1080p and |
| + twenty minutes of 4K and of 4K HDR, and for hours of audio; from these it |
| + sets the per-file maximums, including whether Fargate offers 16 arm64 |
| + vCPUs **(unverified)**; |
| 2. whether tone-mapping fits; if not, HDR is refused with a named error; |
| 3. the isolation and credential claims of §5.5: no credential from the |
| 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. the two activation gates of §5.5: all four endpoints refuse an unrelated |
| - account's credentials, and the deadline container ends a task whose |
| - `codec` container ignores every signal and tries to signal or kill the |
| - timer, with the console stopped, within the deadline plus the stop grace; |
| +4. the activation gates of §5.5: all four endpoints refuse an unrelated |
| + account's credentials; `codec` does not start before `deadline` is |
| + running, nor at all when `deadline` fails to start; and the deadline |
| + container ends a task whose `codec` ignores every signal and tries to |
| + signal or kill the timer, with the console stopped; |
| 5. that the override payload fits, that size and storage can be set per run, |
| - and the three store behaviours of §5.4; |
| -6. a 50 GiB source: download with a forced reconnect, conversion, and upload; |
| + and the two store behaviours of §5.4; |
| +6. a 30 GiB source: download with a forced reconnect, conversion and upload |
| + inside the hour, and a reconnect after the grant expires failing |
| + `grant_expired`; |
| 7. whether the single fragmented MP4 plays and seeks progressively in Safari |
| on iOS and macOS, Chrome and Firefox, for video and for audio, and the |
| playlists in Safari and a JavaScript HLS player. If progressive playback |
| @@ -812,17 +848,25 @@ live wherever `CARLOS_MEDIA_ENGINE` is set. |
| 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 |
| task stopped, charged and cleaned; a new app of that name sees neither. |
| +- A task whose `deadline` container is made to start late does not run |
| + `codec` until it has; one whose `deadline` cannot start never runs `codec`. |
| + A task definition revision without the start dependency, or with another |
| + stop timeout, is refused at dispatch **(astra R6-1)**. |
| - An account with 10 minutes of allowance left submits a one-hour video: it |
| - exits `allowance_exceeded` at the probe, charged only its minutes so far. |
| - One whose jobs all overrun is stopped at each deadline and can never be |
| - charged past twice its limit. A source over the size maximum, one over the |
| - duration maximum and an account at twice its limit are each refused. |
| -- Two accounts, one submitting 20 clips and one submitting one: the single |
| - clip runs within the first three. With four long videos running, a clip |
| - still starts at once. |
| -- A 20 GiB source uploaded in parts converts. A WebM voice recording, an |
| - MP3, a WAV and the audio track of a video each convert with `audio-aac`, |
| - measure -16 LUFS within a tolerance, and yield 1,000 peaks. |
| + exits `allowance_exceeded` at the probe. An account with 20 minutes left |
| + that submits a long audio file and a video together is never reserved or |
| + charged past 20 **(astra R6-3)**. A source over the size maximum, one over |
| + the duration maximum and an account at twice its limit are each refused. |
| +- A 20-minute video under 1 GiB submitted without a class exits |
| + `needs_long_class`; resubmitted with `"class": "long"` it converts as a new |
| + job. With both long places taken, a clip still starts at once, including |
| + for an account whose own long job is waiting **(astra R6-4)**. |
| +- A 20 GiB source uploaded in parts converts inside the hour. A WebM voice |
| + recording, an MP3, a WAV and the audio track of a video each convert with |
| + `audio-aac` and yield 1,000 peaks. Each output either measures -16 LUFS |
| + within a tolerance, or is quieter with its true peak at -1.5 dBTP; none |
| + exceeds that peak, and none has a narrower loudness range than its source. |
| + A silent file converts to silence **(astra R6-5)**. |
| **Then playback:** a two-minute 1080p phone clip, uploaded from a browser on |
| `shop.example.com`, plays from `video.mp4` reached through a redirect to a |
| @@ -876,34 +920,33 @@ the outputs. Store destroy gains the refusal of §5.3. |
| ## 12. Decisions for Paul |
| Already ruled: a platform engine, Fargate (R-F), the lifecycle cut (R-C), |
| -audio in and live deferred (R-A), generous per-file limits (R-X). |
| +audio in and live deferred (R-A), generous per-file limits (R-X), no |
| +standing key (R-K). |
| 1. **The spike.** It needs real files from Paul (4K60 HDR in Dolby Vision or |
| HLG, portrait with rotation, variable frame rate, an ordinary 1080p clip, |
| an hour or more of video, a browser voice recording); 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, the reaper, the conversion role and its caller user; the |
| - isolation and credential checks and the two activation gates of §7.4, |
| - the deadline-container drill among them; and Safari checks on a real |
| - iPhone by Paul or on the tito-studio Mac. Recommend approving it as the |
| - first task. |
| + DNS rule, the reaper and the conversion role; the isolation and |
| + credential checks and the activation gates of §7.4, the timer drills |
| + among them; 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 |
| allow-list apply and leaves the console's VPC untouched, or a private |
| subnet of the console's VPC with no DNS rule. Recommend its own VPC. |
| 3. **No wait for stage 1** (moves ruling 11, narrows ruling 6): ship on the |
| app's own bucket and serving, or wait for `kind:media`. Recommend |
| shipping. |
| -4. **Authority, and one long-lived key (new with R-X).** A conversion role |
| - assumed per execution that always refuses infected sources, even in |
| - stores with enforcement off. Hours-long jobs need grants that last hours, |
| - which needs an IAM user's access key held by the console as a secret. |
| - (a) accept that key; (b) no key, the console's own role assumes the |
| - conversion role, and every job is held to about 50 minutes of engine |
| - time, which rules out long video. Recommend (a). |
| -5. **Per-file maximums:** video 4 hours and 100 GiB, audio 12 hours and |
| - 20 GiB, 4K, 60 fps. Or lower them until the spike has measured long |
| - jobs. Recommend these, with the allowance as the limiter. |
| +4. **Authority (ruled in part, R-K).** A conversion role assumed per |
| + execution from the console's own role, sessions of at most an hour, no |
| + standing key, and infected sources always refused, even in stores with |
| + enforcement off. The alternative is the console's own role presigning. |
| + Recommend the conversion role. |
| +5. **Per-file maximums, provisional until the spike:** video 2 hours up to |
| + 1080p and 30 minutes above it, 40 GiB; audio 8 hours, 10 GiB. They are |
| + what fits one engine hour on the largest task. Or lower starting values. |
| + Recommend these as the starting point. |
| 6. **Plan values:** `media_minutes_month` at Free 30, Personal 600, |
| Community 1,200, Business 12,000 video minutes, refused at twice the |
| limit, plus a media pack of 1,000 minutes. At most about 0.6 cents of |
| @@ -927,40 +970,24 @@ audio in and live deferred (R-A), generous per-file limits (R-X). |
| ## 13. Review log |
| -Rounds 1 and 2: sixteen findings, all accepted. **Round 3** |
| -(`CODEX-FINDINGS-VIDEO-R3.md`, 2 P1, 2 P2), all accepted: |
| - |
| -- **R3-1** runtime-protocol takeover: closed by R-F. A Fargate task has no |
| - runtime API and is not reused (§5.5). |
| -- **R3-2** function credentials and DNS exfiltration: closed by R-F. No task |
| - role, no credentials, and a DNS allow-list on the engine's VPC (§5.5). |
| -- **R3-3** capacity released early: the cap counts rows whose task ECS has |
| - not confirmed stopped (§7.2, I6). |
| -- **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). |
| - |
| -**Round 5** (`CODEX-FINDINGS-VIDEO-R5.md`, 1 P1; R4-1, R4-3 and R4-4 closed): |
| - |
| -- **R5-1** the reaper's timing is not a bound: the deadline is now a second |
| - essential container in the task, so ECS ends the task at the deadline |
| - whatever the console or any schedule does. The reaper is a backstop and |
| - the 17-minute figure of R4-2 is gone (§5.3, §5.5, §6). |
| - |
| -**Rulings applied in revision 6:** R-A adds the `audio-aac` preset (§5.1, §6, |
| -§7); R-X replaces the short-clip caps with per-file maximums, a per-job |
| -deadline chosen from the allowance, long-lived grants and large-file |
| -transfers (§5.4, §5.6, §7). |
| +Six Astra rounds, findings committed unedited beside this file as |
| +`CODEX-FINDINGS-VIDEO.md` and `-R2.md` to `-R6.md`. Every finding was |
| +accepted; none is open by decision. What each round changed: |
| + |
| +- **Rounds 1 and 2:** execution ids, immutable per-execution outputs, the |
| + one-row lifecycle (R-C), store provenance. |
| +- **Round 3:** Lambda could not isolate the codec; Fargate (R-F). Capacity |
| + counted until ECS confirms a stop; store destroy retires rows. |
| +- **Round 4:** endpoint policies on all four endpoints; recovery without an |
| + ARN; launch rejection. Its reaper-based deadline did not hold. |
| +- **Round 5:** the deadline moved into the task as an essential container |
| + (R5-1); the reaper became a backstop. |
| +- **Round 6:** R6-1 a `START` dependency, explicit stop timeouts and a |
| + dispatch gate (§5.5); R6-2 the caller key, removed by R-K (§5.4); R6-3 |
| + reservations fitted to the allowance in the dispatch transaction (§7.3); |
| + R6-4 classes fixed before the probe, with separate capacity (§7.1, §7.2); |
| + R6-5 the peak ceiling takes precedence over the loudness target (§5.1). |
| + |
| +**Rulings:** R-C, R-F, R-A, R-X and R-K (§4). |
| **Findings not accepted:** none. |