spec: amendment A9, three hours of SDR video with its fit
Records the new video_max, the fit by plan 1's rule at both long-class 1080p SDR runs (5.85: 187 minutes, so 3 hours; 5.42: 173, so 2 h 45), the deadline and grant at the slower run (41.3 and 42.4 minutes), the 40 GiB size limit as the binding term, and the reservation of 360 allowance minutes. Updates the §7.1 table, §5.1's output size and plan 2's defaults.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+78
−7
docs/superpowers/plans/2026-11-16-media-conversion-plan-2-console.md+2 −2docs/superpowers/specs/2026-11-16-video-conversion-design.md+76 −5
diff --git a/docs/superpowers/plans/2026-11-16-media-conversion-plan-2-console.md b/docs/superpowers/plans/2026-11-16-media-conversion-plan-2-console.md| index 8bf0f97aa..3e739ea62 100644 |
| --- a/docs/superpowers/plans/2026-11-16-media-conversion-plan-2-console.md |
| +++ b/docs/superpowers/plans/2026-11-16-media-conversion-plan-2-console.md |
| @@ -16,7 +16,7 @@ |
| - Execution id: 32 hex characters from 16 bytes of `crypto/rand`. It is RunTask's `startedBy` and its idempotency token. |
| - Output keys: `derived/<key>/<etag>/<preset>/<execution>/` + `video.mp4`, `video.m3u8`, `poster.jpg` (video) or `audio.mp4`, `audio.m3u8`, `peaks.json` (audio). Result object: `media-results/<execution>.json` in the deployment bucket, read bounded to 64 KiB. |
| - Classes (§7.1): video short (picked up to 1 GiB): 4 vCPU, 8 GB, deadline 15 min, granted 10 min; video long: 16 vCPU, 32 GB, 50 min, the video maximum; audio short (up to 256 MiB): 1 vCPU, 2 GB, 10 min, 2 h; audio long: 2 vCPU, 4 GB, 50 min, the audio maximum. Ephemeral storage 20 GiB, or source size plus 8 GiB when more. |
| -- Maximums (settings, `CARLOS_MEDIA_LIMITS`; plan 1's values, spec §11 A7): video 2 h up to 1080p, 75 min for HDR up to 1080p (`video_max_hdr`), 30 min above 1080p, 40 GiB; audio 8 h, 10 GiB; 3840x2160, 60 fps. The short video class takes nothing above 1080p (A7). |
| +- Maximums (settings, `CARLOS_MEDIA_LIMITS`; plan 1's values, spec §11 A7, and A9's three hours): video 3 h for SDR up to 1080p (A9; 2 h before it), 75 min for HDR up to 1080p (`video_max_hdr`), 30 min above 1080p, 40 GiB; audio 8 h, 10 GiB; 3840x2160, 60 fps. The short video class takes nothing above 1080p (A7). |
| - Fair use: 6 short and 2 long tasks in the deployment, 2 short and 1 long per account, counted as rows with a dispatched execution and `task_stopped` false; per account 20 queued or running (429) and 30 submissions a minute with a burst of 10 (429); deployment-wide 200 queued (503). |
| - Stop grace 30 s. Full bound = `deadline_s` + 30 s. Grant lifetime 1 h. Deadline at most 50 min. Under 3 min of deadline: wait while the account has another execution running, else fail `allowance_exceeded` uncharged. |
| - Weights: `video-720p` 1, video above 1080p 2 (spec §11 A7, Paul's option A), `audio-aac` 0.1, held as tenths (10, 20 and 1) so every allowance figure is an integer: units = milliseconds × weight-tenths. A settled row is charged at the weight its probe measured (`weight_tenths`); a running long video row is reserved at 2. |
| @@ -116,7 +116,7 @@ The deck holds every string Tasks 3 to 11 write. Drafts below; implementers copy |
| - `const (StopGrace = 30*time.Second; GrantLifetime = time.Hour; GrantMintSlack = 5*time.Minute; EngineRecordRetention = time.Hour; MinDeadline = 3*time.Minute; MaxDeadline = 50*time.Minute; PassEvery = 5*time.Second; FailedRetention = 90*24*time.Hour; MaxResultBytes = 64 << 10; MaxOverrideBytes = 8192; MaxPutBytes = 5 << 30; ScratchFloorGiB = 20; ScratchHeadroom = 8 << 30)`. `EngineRecordRetention` and `MaxOverrideBytes` are plan 1 measurements. |
| - `func DeadlineSleep(start time.Time, deadline time.Duration, expiry time.Time) time.Duration`: the earlier of `start+deadline` and `expiry−StopGrace`, minus `start` (may be ≤ 0). Plan 3's deadline container and local runner both use it. |
| - `func EphemeralGiB(sourceBytes int64) int`: 0 when `ceil((bytes+8 GiB)/GiB) <= 20`, else that figure (at most 200). |
| - - `type Limits struct{ VideoMax, VideoMaxHDR, VideoMaxHi, AudioMax time.Duration; VideoBytes, AudioBytes int64; AccountMinutes int64; Short, Long, AccountShort, AccountLong, AccountActive, PerMinute, Burst, Queue int }` and `func ParseLimits(v string) (Limits, error)`: comma-separated `key=value`; keys `video_max`, `video_max_hdr` (A7, default 75m), `video_max_hi`, `video_bytes`, `audio_max`, `audio_bytes`, `account_minutes`, `short`, `long`, `account_short`, `account_long`, `account_active`, `per_minute`, `burst`, `queue`; durations in Go syntax, bytes as an integer or `<n>GiB`/`<n>MiB`; `""` gives `2h,30m,40GiB,8h,10GiB,0,6,2,2,1,20,30,10,200`; unknown, duplicate, negative or zero-count keys are errors; `account_minutes` may be 0. |
| + - `type Limits struct{ VideoMax, VideoMaxHDR, VideoMaxHi, AudioMax time.Duration; VideoBytes, AudioBytes int64; AccountMinutes int64; Short, Long, AccountShort, AccountLong, AccountActive, PerMinute, Burst, Queue int }` and `func ParseLimits(v string) (Limits, error)`: comma-separated `key=value`; keys `video_max`, `video_max_hdr` (A7, default 75m), `video_max_hi`, `video_bytes`, `audio_max`, `audio_bytes`, `account_minutes`, `short`, `long`, `account_short`, `account_long`, `account_active`, `per_minute`, `burst`, `queue`; durations in Go syntax, bytes as an integer or `<n>GiB`/`<n>MiB`; `""` gives `3h,30m,40GiB,8h,10GiB,0,6,2,2,1,20,30,10,200` (`video_max` 3h since spec §11 A9); unknown, duplicate, negative or zero-count keys are errors; `account_minutes` may be 0. |
| - `func (l Limits) MaxBytes(preset string) int64`, `func (l Limits) Granted(k ClassKey) time.Duration` (the class figure, or the preset maximum for long). |
| - Error codes as `const Code… = "…"` for every code in the deck's `media.job.*` rows plus `CodeRetired = "retired"`; `var HandlerCodes map[string]bool` (the codes a result object may carry: every `media.job.*` code except `grant_expired`, `deadline_exceeded`, `engine_unavailable`, `engine_lost`, `retired`, `store_changed`, `store_writes_denied`). |
| - Exit codes: `ExitDone = 0`, `ExitFailed = 1`, `ExitGrantExpired = 75`, `DeadlineExitReached = 0`, `DeadlineExitBadInput = 3`, `DeadlineExitStopped = 143`; container names `ContainerCodec = "codec"`, `ContainerDeadline = "deadline"`; env names `PayloadEnv = "CARLOS_MEDIA_JOB"`, `DeadlineEnv = "CARLOS_MEDIA_DEADLINE_S"`, `ExpiryEnv = "CARLOS_MEDIA_GRANT_EXPIRY"`. |
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 a50fc5831..41f40162d 100644 |
| --- a/docs/superpowers/specs/2026-11-16-video-conversion-design.md |
| +++ b/docs/superpowers/specs/2026-11-16-video-conversion-design.md |
| @@ -173,9 +173,9 @@ 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):** 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 |
| +R-X):** three hours of video at the bitrate ceiling is about 3.5 GB |
| +(§11 A9), 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 |
| added a writer and no authority)**. |
| @@ -671,11 +671,12 @@ 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. |
| -**Maximums (the spike's values, §11 A7; estimates before it).** |
| +**Maximums (the spike's values, §11 A7, and three hours of SDR, A9; |
| +estimates before them).** |
| | | `video-720p` | `audio-aac` | |
| |---|---|---| |
| -| Duration, sources up to 1080p | 2 hours | 8 hours | |
| +| Duration, sources up to 1080p (video: SDR, A9) | 3 hours | 8 hours | |
| | Duration, HDR sources up to 1080p (A7) | 75 minutes | | |
| | Duration, sources above 1080p | 30 minutes | | |
| | Source size | 40 GiB | 10 GiB | |
| @@ -1141,6 +1142,76 @@ the outputs. Store destroy gains the refusal of §5.3. |
| `checkOutputs`), and no rule of ours reaches. S3 offers no way to |
| refuse such a completion; closing it would need a platform rule on |
| tenant buckets or a sweep of `derived/`, both outside this amendment. |
| +- **A9, three hours of SDR video** (Paul, 2026-11-25). LiveKit Cloud |
| + records up to 3 hours per file, so `video_max` (SDR sources up to |
| + 1080p) rises from 2 hours to 3. `video_max_hdr` stays 75 minutes, |
| + `video_max_hi` 30 minutes, and the deadline (50 minutes), the grant |
| + (one hour, R-K), the classes and `video_bytes` (40 GiB) are unchanged. |
| + Where this differs from §5.1, §7.1, A7 or decision 5, it overrides |
| + them. |
| + - **The fit, by plan 1 Task 5 Step 4's rule.** `D = (40 min - t_start - |
| + S/B) x v`, rounded down to 15 minutes, with the spike's `t_start` |
| + 31.7 s (p95), `B` 95.3 MB/s (p5) and `S` 40 GiB, so the download is |
| + 450.7 s and 1,917.6 s remain for the encode. The spike has two |
| + long-class 1080p SDR runs at `medium`: the 1-hour source at 5.85 |
| + times real time and the 30 GiB, 1 h 43 min source at 5.42. At 5.85, D |
| + is 187.0 minutes, which rounds down to 180: 3 hours fit, with no |
| + 15-minute step to spare. At 5.42, D is 173.2 minutes, which rounds |
| + down to 165: 3 hours do not fit the 40-minute rule, by one step. |
| + - **The deadline and the grant, at the slower run.** At 5.42 the worst |
| + case, timed from the `deadline` container's start, is a 450.7 s |
| + download, a 1,992.6 s encode (33.2 minutes) and a 37.2 s upload of |
| + the output at its ceiling (2,500 kbit/s of video and 128 kbit/s of |
| + audio for 3 hours is 3.55 GB, sent at `B`; the spike sent 1.66 GB in |
| + 14.5 s): 2,480.5 s, or 41.3 minutes, against the 50-minute deadline. |
| + From `RunTask`, with the 31.7 s start and the 30 s stop grace, it is |
| + 42.4 minutes against the one-hour grant. At 5.85 the same sum is |
| + 38.9 minutes. So 3 hours end inside the deadline and the grant on |
| + both runs, and inside the plan's 40-minute rule only on the faster |
| + one. The 40-minute rule's 10-minute margin below the deadline is what |
| + the slower run spends: 1.3 minutes of it. |
| + - **The binding term is the 40 GiB size limit.** The download of `S` is |
| + 7.5 minutes of the 40. At 5.42 the rule reaches 3 hours for sources up |
| + to 33.3 GiB (30 GiB in 5 GiB steps), and every 3-hour source smaller |
| + than that fits the rule on either run. A 40 GiB, 3-hour source is |
| + about 32 Mbit/s, far above a 720p room composite from LiveKit, whose |
| + download takes well under a minute. `video_bytes` stays 40 GiB; an |
| + operator who wants the rule to hold on the slower run for every |
| + admitted source can set it to 30 GiB. |
| + - **What a slow host costs.** The spike saw one short-class cell vary |
| + by up to 45 % between Fargate hosts, and each long-class cell ran |
| + once. With a 40 GiB source, 3 hours of SDR miss the deadline below |
| + 4.30 times real time; with a source of a few gigabytes, below 3.70. A |
| + run that misses it fails `deadline_exceeded` and is charged its |
| + engine time, about 50.5 minutes at weight 1, as any overrun is. |
| + - **Outputs and storage.** 3 hours at the ceiling is 3.55 GB, under the |
| + 5 GB of one PUT (`output_too_large` is unchanged); the playlist has |
| + about 2,700 entries, far under its 4 MiB bound; ephemeral storage |
| + (the source plus 8 GiB, at least 20 GiB) holds the output. |
| + - **Billing and the reservation.** A long video row is still reserved |
| + at weight 2 before its probe (A7), so a 3-hour grant holds `2 x |
| + max(180, 50.5)` = 360 allowance minutes while it runs, where 2 hours |
| + held 240. A done 3-hour SDR job up to 1080p is charged 180. The |
| + dispatch fit (§7.3) already grants `min(3 h, R/2)` and fits the |
| + deadline to `R/2` less the stop grace, so an account needs 360 |
| + minutes free below twice its limit for the full 3 hours (a limit of |
| + 180 with nothing used is exactly enough). With less, the allowance |
| + grants less and a longer source exits `allowance_exceeded` at the |
| + probe, charged the minutes used so far. On the proposed plans, Free |
| + (30) is granted at most 30 minutes, as before, and Personal (600) |
| + the full 3 hours while 360 of its 1,200 remain. The door's 402 reads |
| + settled charges at twice the limit and is unchanged. An `engine_lost` |
| + row is still charged its full bound, `deadline_s` plus the stop |
| + grace. None of this needs a code change; the simulation's I8 gains |
| + grant checks (a row's grant and deadline within its class's figures, |
| + a done row's source no longer than its grant, and each Run's payload |
| + carrying the row's grant and the deployment's maximums) and a |
| + 3-hour witness. |
| + - **Mixed versions and settings.** The maximum travels in the payload's |
| + existing `d` field and the codec enforces whatever it is sent, so no |
| + payload version changes: an older image converts 3 hours from a newer |
| + console, and an older console keeps sending 2 hours. A deployment |
| + that sets `video_max` in `CARLOS_MEDIA_LIMITS` keeps its own value. |
| ## 12. Decisions for Paul |