spec: video conversion revision 3, Lambda engine and one-row lifecycle
Paul's rulings R-L (the engine is an arm64 Lambda image, synchronous invoke, VPC with an S3 gateway endpoint only) and R-C (cancel, DELETE and requeue cut; the job lifecycle is one console-database row changed in transactions, checked by an interleaving simulation). Closes Astra round 2: R2-1 by R-L, R2-2 to R2-5 by R-C, R2-6 by recorded or verified store provenance. result.json dropped.
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+535 −601
Intent
<task-notification> <task-id>ad8a1b25ebf69fbf7</task-id> <tool-use-id>toolu_01FD4GDFo75gAdECWG6KVDsX</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 3 is written in place and uncommitted: 698 lines, down from 764. I missed the under-600 aim; what remains is the refusal tables, the row transitions and invariants, the drills and the decisions, and I judged those worth keeping for the last round. ## How each round-2 finding is closed - **R2-1 (slot reuse after an agent restart):** closed by R-L. There is no agent, slot or helper unit. The equivalent risk on Lambda, a reused warm environment, is handled by making each environment single-use and is a spike proof. - **R2-2 (stranded jobs):** closed by R-C. One `media_jobs` row is both the job and its place in the queue; no bucket records or markers. - **R2-3 (deletion erasing the accounting):** closed by R-C. There is no DELETE; app purge and account deletion retire rows and never remove an unsettled one. - **R2-4 (cancel before the engine stops):** closed by R-C and R-L. There is no cancel, and a run the console did not see return is charged the whole function timeout. - **R2-5 (second cleanup lost):** closed by R-C. `cleanup_due` stays in the row until the deletion succeeds. It is now one deletion, an hour after the execution started, when the function is dead and its transfers have expired. - **R2-6 (bucket name is not provenance):** provenance is recorded when the walk itself creates the bucket. Any other store is verified on first use and the result recorded: minted name, deployment's account, store region, SSE-S3, versioning off, and no foreign bucket policy, lifecycle or CORS. Failures are refused as `store_unverified`. I verified R2-6's citations (`objstore.go:66`, `walk.go:245-250`). None declined. ## Calls of mine you should know about - **One execution per job, no automatic retry.** Cutting requeue means a job lost to a console restart mid-invoke ends `engine_lost` permanently, and the app must upload again under a new key. Console releases will hit running jobs, so I made this decision 9. - **Warm-environment reuse is the new main risk.** Lambda reuses environments across invocations, so "isolation is the microVM" only holds if the function exits after each response, refuses to start with other processes present, and empties `/tmp`. The spec says the design returns to Paul if the spike cannot prove a second invocation never sees the first. - **Every invoke error counts as lost.** The console never dispatches more than the reserved concurrency, so throttling should not occur; anything that does go wrong is charged the full timeout. - **`result.json` is dropped,** as you invited. `done` rows of a live app are kept as the registry. - **Provenance verification runs automatically at the door** on first use, with no new verb. - **Function timeout is 10 minutes,** inside Lambda's 15. If the slowest admitted clip does not fit, the admission caps come down. - **Engine-time budget reads the same table.** It and the plan cap are both queries over `media_jobs`; there is no separate usage table. ## Unverified in this revision Each is marked in the text. - Lambda price and the per-clip cost estimates. - That a 10-minute synchronous invoke holds from the console box. - The single-use environment behaviour. - Whether amadan CI can build arm64 images. - Whether Lambda permits a seccomp filter on the child (optional hardening). - The dev and flagship region facts, which are yours. ## Decisions for Paul 1. **The spike:** real clips from Paul (4K60 HDR, portrait with rotation, variable frame rate, an ordinary 1080p clip), scoped approval for a dev Lambda function with its role and image repository, the conversion role, and a subnet with an S3 gateway endpoint, plus Safari checks on a real iPhone or the tito-studio Mac. Recommended as the first task. 2. **No wait for stage 1** (moves ruling 11, narrows ruling 6): ship on the app's own bucket and serving (recommended), or wait for `kind:media`. 3. **Authority:** a conversion role assumed per execution that always refuses infected sources, even with enforcement off (recommended), or the console's own role presigning. 4. **Admission caps:** 180 s, 512 MiB, 4K, 60 fps (recommended, if the spike shows it fits the timeout); or 300 s and 1 GiB; or 60 s and 200 MB. 5. **Plan values:** `media_minutes_month` at Free 30, Personal 600, Community 1,200, Business 12,000, refused at twice the limit, no media pack (recommended); or no cap until usage is measured. 6. **Browser uploads in scope** as `carlos store uploads`, a member verb (recommended), or native clients only for now. 7. **Always re-encode, HDR tone-mapped, one JPEG poster** (recommended), or add the roadmap's remux path. 8. **On for every app** with a store and a Service credential (recommended), or a per-app switch. 9. **No retry in v1** (new): accept that a job lost to a console restart fails for good (recommended, and watch how often it happens), or allow one automatic second execution, which puts a second reservation and cleanup into the row. 10. **Codec licences:** accept encoding H.264 and AAC with Debian's ffmpeg, or have it checked before flagship. A question, no recommendation.</result> <usage><subagent_tokens>252954</subagent_tokens><tool_uses>8</tool_uses><duration_ms>392713</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 4aea198cb..4bc73f969 100644 |
| --- a/docs/superpowers/specs/2026-11-16-video-conversion-design.md |
| +++ b/docs/superpowers/specs/2026-11-16-video-conversion-design.md |
| @@ -1,419 +1,376 @@ |
| # Video conversion: a phone clip in, a playable video out |
| -**Date:** 2026-11-16, revision 2 (after Astra round 1 and a builder check, §13) |
| -**Status:** draft for review. Not approved. |
| -**Asked for by:** Paul, 2026-11-16. He picked approach A (§4). |
| -**Builds on:** the PDF service's shape (`2026-11-02-pdf-service-design.md`): |
| -one engine box per deployment, a console door, a Service credential, plan |
| -caps and fair-use limits. |
| +**Date:** 2026-11-16, revision 3 (two rulings by Paul and Astra round 2, §13) |
| +**Status:** draft for the last review round. 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`). |
| **Amends:** the media roadmap (`2026-09-07-media-platform-roadmap-design.md`), |
| stage 3's first product and part of stage 5. See §11. |
| -**Review budget:** AGENTS.md "Stopping rules". At most three cross-model |
| -rounds on this spec, and review stops at the first round with no P1. |
| +**Review budget:** AGENTS.md "Stopping rules". Three cross-model rounds at |
| +most. Round 3 is the last. |
| -Marks: **(astra N)** a change from round-1 finding N; **(B N)** from the |
| -builder check; **(my call)** the author's, cheap to overturn; **(estimate)** |
| -not measured; **(unverified)** not checked against a source in this tree. |
| +Marks: **(paul R-L)**, **(paul R-C)** Paul's rulings; **(astra R2-N)** a |
| +round-2 finding; **(my call)** the author's, cheap to overturn; |
| +**(estimate)** not measured; **(unverified)** not checked against a source |
| +in this tree. |
| ## 1. Intent |
| -A phone hands an app a file that plays nowhere reliably: HEVC in a `.mov`, |
| -4K at 60 frames a second, 400 MB, rotation held in metadata. This design |
| -makes conversion a **platform service**. The app uploads the original |
| -straight to its own store bucket, asks the console to convert it, and |
| -polls. The platform writes one H.264/AAC video, an HLS playlist over that |
| -same file, and a poster into the app's bucket. The app serves them the way |
| -it serves its other objects. |
| +A phone hands an app a file that plays nowhere reliably: HEVC in a `.mov`, 4K |
| +at 60 frames a second, 400 MB, rotation held in metadata. This design makes |
| +conversion a **platform service**. The app uploads the original straight to |
| +its own store bucket, asks the console to convert it, and polls. The platform |
| +writes one H.264/AAC video, an HLS playlist over that same file, and a poster |
| +into the app's bucket. The app serves them the way it serves its other |
| +objects. |
| First consumer (non-normative): a social app with content-addressed public |
| -media that caps uploads at 8 MiB today and is moving its blobs into a |
| -store bucket. Nothing here is specific to it. |
| +media that caps uploads at 8 MiB today and is moving its blobs into a store |
| +bucket. Nothing here is specific to it. |
| ## 2. Goals, non-goals, anti-goals |
| **Goals** |
| -- G1. Any app with a store and a Service credential converts a phone clip |
| - with one HTTP call and a poll. No operator grant, no per-app switch. |
| +- G1. Any app with a store and a Service credential converts a phone clip with |
| + one HTTP call and a poll. No operator grant, no per-app switch. |
| - G2. One rendition: H.264/AAC, at most 720p, never upscaled, in a single |
| fragmented MP4 that plays progressively with `Range` and is also an HLS |
| stream through a byte-range playlist; plus one JPEG poster. |
| -- G3. The source goes app to store directly, and browser uploads work |
| - (§5.8). |
| -- G4. Bad input is refused up front with a named error: at the door when |
| - the door can know, at the probe otherwise. |
| +- G3. The source goes app to store directly, and browser uploads work (§5.6). |
| +- G4. Bad input is refused up front with a named error: at the door when the |
| + door can know, at the probe otherwise. |
| - G5. A plan cap and fair use from the first job. |
| -- G6. The engine is a platform module, and a later ladder preset fits |
| - beside this one without moving it. |
| +- G6. Nothing runs, and nothing costs, while no clip is being converted |
| + **(paul R-L)**. |
| **Non-goals** |
| -- **Encrypted media.** The platform cannot convert ciphertext. Apps whose |
| - users encrypt client-side convert on the device (approach B). Ciphertext |
| - fails the probe as `unsupported_container`. |
| -- A ladder, AV1 output, DASH, captions, DRM, live, audio-only inputs. |
| -- Serving. The roadmap's stage 1 is neither needed nor built. |
| -- Completion callbacks. v1 polls. |
| -- Environment stores: the default store only, as the scan door |
| - (`internal/console/apiscan.go:902-905`). |
| -- **Adopted buckets (B3).** A store whose bucket the platform did not mint |
| - is refused (`adopted_store`): its encryption, lifecycle and prefix are |
| - unknown. |
| -- A client library. It belongs to the app framework's repository. |
| +- **Encrypted media.** The platform cannot convert ciphertext; apps whose |
| + users encrypt client-side convert on the device. Ciphertext fails the probe |
| + as `unsupported_container`. |
| +- **Cancel, delete, retry and re-encode (paul R-C).** The door is POST and |
| + GET. An app that no longer wants a result ignores it. One source, one |
| + preset, one execution, ever. |
| +- A ladder, AV1 output, DASH, captions, DRM, live, audio-only inputs, serving |
| + (the roadmap's stage 1), callbacks, environment stores, a client library, |
| + and stores of unknown provenance (§5.2). |
| **Anti-goals** |
| -- A standing grant that lets the engine box read or write tenant buckets. |
| -- ffmpeg with a network, or given a tenant-chosen path or URL. |
| +- An engine with authority over tenant buckets. |
| - Conversion of an object the scanner has tagged infected. |
| -- A free account turning the box into an encode farm. |
| -- Encoding on a box that serves requests. |
| +- A free account turning the platform into an encode farm. |
| +- Job state in more than one place **(paul R-C)**. |
| ## 3. Where things stand on `main` (15b1ee6b) |
| -- **The store user's policy** allows `GetObject`, `PutObject`, |
| - `DeleteObject` and `GetObjectTagging` under the whole bucket |
| - (`internal/objstore/aws.go:192-199`). It carries a Deny on reading |
| - objects tagged infected only when the record's `Enforce` is set |
| - (`aws.go:228-237`), and a Deny on `PutObject` when the store is past its |
| - storage grace (`aws.go:238-247`). So an app can write under any prefix, |
| - `derived/` included. |
| +- **The store user's policy** allows `GetObject`, `PutObject`, `DeleteObject` |
| + and `GetObjectTagging` under the whole bucket |
| + (`internal/objstore/aws.go:192-199`), so an app can write under any prefix. |
| + It denies reading infected objects only when the record's `Enforce` is set |
| + (`aws.go:228-237`) and denies `PutObject` past the storage grace |
| + (`aws.go:238-247`). |
| +- **A store record does not say whether its bucket was minted or adopted** |
| + (`internal/objstore/objstore.go:66`), and the grant walk takes an adopted |
| + name without comparing it to the minted one |
| + (`internal/objstore/walk.go:245-250`). |
| - **Nothing sets bucket CORS or a lifecycle rule on a store.** No |
| `PutBucketCors` call exists under `internal/`, `cmd/` or `infra/`. |
| -- **The console cannot read a store secret.** It seals with a public key |
| - (`internal/appconfig/sealer.go:18-23`); `appconfig.Open` is called only |
| - from `internal/hostfiles/sealed.go` and `internal/moves/archive/seal.go`. |
| -- **The console's role does not read tenant objects** unless scanning is |
| - on (`infra/modules/region-host/main.tf:847-862`, `963-972`). It can |
| - delete them (`main.tf:859-862`) and mint a key for any store user |
| - (`main.tf:911`). |
| -- **Only the AWS store backend exists** (`cmd/console/main.go:1093-1094`), |
| - in one region (`main.go:1098`), behind the `Provisioner` seam with an |
| - in-memory fake (`internal/objstore/provisioner.go:5-11`). |
| -- **One bucket-backed queue exists**, the scan queue, under the app's |
| - prefix so `PurgeApp` finds it (`internal/objstore/queue.go:1-14`). Its |
| - boot rebuild lists the queue items (`queue.go:231`). |
| +- **The console's role** lists and deletes in store buckets, can mint a key |
| + for any store user, and reads objects only when scanning is on |
| + (`infra/modules/region-host/main.tf:847-862`, `911`, `963-972`). It cannot |
| + read a store secret: it only seals (`internal/appconfig/sealer.go:18-23`). |
| +- **Only the AWS store backend exists** (`cmd/console/main.go:1093-1094`), in |
| + one region (`main.go:1098`). |
| - **The PDF service is the shape to copy:** Service-role doors |
| - (`internal/console/routedecls.go:1028-1032`, `apipdf.go:63`), limiter |
| - (`pdflimit.go:25`), plan check refusing at twice the limit |
| - (`planpdf.go:8-27`), `plans.Limits.PDFRendersMonth` |
| - (`internal/plans/catalog.go:53`), a row per request (`pdfrenders.go:11`), |
| - module `infra/modules/pdf-host`. The live catalog |
| - (`deploy/billing/catalog-2026-11-15-v1.json`) gives PDFs 100, 2,000, |
| - 4,000 and 40,000 a month across its four plans and has no PDF pack. |
| -- **Engine boxes install Debian packages at init with unattended upgrades |
| - on** (`infra/modules/scanner-host/scanner-init.sh.tftpl:32-47`, |
| - `pdf-host/pdf-init.sh.tftpl:20`). |
| -How PDF differs: a conversion takes minutes, so the door is asynchronous; |
| -the input is hundreds of megabytes, so it never passes through the |
| -console; the output belongs in the tenant's bucket. |
| - |
| -## 4. Approaches considered |
| - |
| -- **A. A platform engine box (chosen, Paul).** Works for every app and |
| - client, costs one box, keeps a large C codebase off the edge and the |
| - console. One region, a queue under load, no ciphertext. |
| -- **B. On the device, in the app.** No platform cost and the only option |
| - for encrypted media. Rejected as the main path: uneven browser support, |
| - battery, a closed tab loses the work, every app rebuilds it. |
| -- **C. On demand at the edge.** Dropped: minutes of CPU on the burstable |
| - box that terminates every tenant's TLS. |
| + (`internal/console/routedecls.go:1028-1032`), limiter (`pdflimit.go:25`), |
| + plan check refusing at twice the limit (`planpdf.go:8-27`), |
| + `plans.Limits.PDFRendersMonth` (`internal/plans/catalog.go:53`), a console |
| + table (`internal/console/store.go:378`). The live catalog |
| + (`deploy/billing/catalog-2026-11-15-v1.json`) gives PDFs 100, 2,000, 4,000 |
| + and 40,000 a month across four plans and has no PDF pack. |
| +- **The console purges apps and deletes accounts in its own code** |
| + (`internal/console/ownership.go:386`, `785`). |
| + |
| +## 4. Approach and rulings |
| + |
| +Paul chose a platform engine over conversion on the device (kept for encrypted |
| +media) and conversion at the edge (minutes of CPU on the box that terminates |
| +every tenant's TLS). Two rulings on 2026-11-16 shape this revision: |
| + |
| +- **R-L: the engine is a Lambda function, not a standing box.** Usage will be |
| + low, and a box that sleeps is what Lambda is. Revision 2's engine box, |
| + agent, slots, per-slot filesystems and helper unit are gone. |
| +- **R-C (stopping rule 2): cut and centralise the lifecycle.** Cancel, delete |
| + and requeue are cut, and the lifecycle is one row per job in the console's |
| + database. Revision 2's bucket job records, queue markers, attempts list and |
| + `result.json` are gone. |
| ## 5. The design |
| ### 5.1 The preset and its outputs |
| -One preset, `clip-720p`. Every admitted source is re-encoded; there is no |
| -remux path **(my call)**. |
| +One preset, `clip-720p`. Every admitted source is re-encoded **(my call)**. |
| -- Video: H.264 High, `yuv420p`, at most 1280 by 720 in either |
| - orientation, aspect kept, never upscaled, rotation applied, at most 30 |
| - frames a second, a keyframe every 2 seconds, constant quality under a |
| - ceiling of about 2.5 Mbit/s. HDR is tone-mapped to SDR. |
| +- Video: H.264 High, `yuv420p`, at most 1280 by 720 in either orientation, |
| + aspect kept, never upscaled, rotation applied, at most 30 frames a second, a |
| + keyframe every 2 seconds, constant quality under a ceiling of about 2.5 |
| + Mbit/s. HDR is tone-mapped to SDR. |
| - Audio: AAC-LC stereo, 48 kHz, 128 kbit/s; none if the source has none. |
| - Container: one fragmented MP4, 4-second fragments, with an HLS version 7 |
| playlist (`EXT-X-MAP`, `EXT-X-BYTERANGE`) over the same file. |
| -- Poster: one JPEG at output size, one second in, or the midpoint of a |
| - shorter clip. |
| +- Poster: one JPEG at output size, one second in, or the midpoint of a shorter |
| + clip. |
| - Source metadata, location included, is dropped. |
| -Outputs are **immutable and specific to one execution (astra 2)**: |
| +Outputs are immutable and belong to one execution: |
| derived/<source key>/<etag>/clip-720p/<execution id>/video.mp4 |
| video.m3u8 |
| poster.jpg |
| `<etag>` is the source's ETag without quotes |
| -(`internal/objstore/clamav.go:517`), an opaque content version. Each PUT |
| -is create-only (`If-None-Match: *`, signed), so nothing can change an |
| -output after the console has checked it. Deleting `derived/<source key>/` |
| -removes every output of a source. |
| - |
| -**The job record is the only authority (B1).** An app can write anything |
| -under `derived/` with its own credentials, so the platform never reads the |
| -tenant's bucket to decide what was converted. After a commit the console |
| -also writes `result.json` into the execution's directory as a convenience |
| -copy for the app. No platform code reads it back. A future stage-1 fence |
| -must check the console's job records, not that file. |
| +(`internal/objstore/clamav.go:517`). Each PUT is create-only (`If-None-Match: |
| +*`, signed). A later ladder preset is a sibling of `clip-720p`. 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)**. |
| ### 5.2 The door |
| - POST /api/cli/apps/{account}/{app}/media/conversions |
| - GET /api/cli/apps/{account}/{app}/media/conversions/{id} |
| - DELETE /api/cli/apps/{account}/{app}/media/conversions/{id} |
| + POST /api/cli/apps/{account}/{app}/media/conversions |
| + GET /api/cli/apps/{account}/{app}/media/conversions/{id} |
| -All register with `svcrole.Allow(svcrole.Service)` and resolve the app |
| -through `apiAccountApp`, as the PDF and scan doors do. The credential is |
| -the one an app holds for PDFs or scanning. |
| +Both register with `svcrole.Allow(svcrole.Service)` and resolve the app |
| +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`. Checks run in this order and stop at the first failure: |
| +`preset`. Checks run in order and stop at the first failure: |
| | Check | Refusal | |
| |---|---| |
| -| `CARLOS_MEDIA_ADDR` unset | 503 `not_configured` | |
| +| no engine configured (`CARLOS_MEDIA_FUNCTION`) | 503 `not_configured` | |
| | key empty, over 512 bytes, control characters, or under `derived/` | 400 `bad_key` | |
| | unknown preset | 400 `unknown_preset` | |
| | no provisioned default store | 409 `no_store` | |
| -| the bucket is not the one the platform mints for this app (B3) | 409 `adopted_store` | |
| -| store region is not the engine's region | 409 `no_engine_in_region` | |
| +| store provenance not established (below) | 409 `store_unverified` | |
| +| store region is not the function's region | 409 `no_engine_in_region` | |
| | store record has `writes_denied` | 402 `store_writes_denied` | |
| | HEAD of the key: absent | 404 `source_not_found` | |
| | HEAD of the key: denied (an infected verdict lands here, §5.4) | 409 `source_unreadable` | |
| | size zero or over the cap (§7.1) | 413 `source_too_large` | |
| | plan cap (§7.3) | 402 from `capCopy` | |
| -| fair use or execution budget (§7.2) | 429 or 503 with `Retry-After` | |
| - |
| -A passing request answers 202 with the job. |
| - |
| -**Two identities (astra 1).** |
| - |
| -- The **job id** is the idempotency key: the first 32 hex characters of |
| - `sha256("v1\0" + key + "\0" + etag + "\0" + preset)`. It is unique only |
| - inside one app, and it never leaves the console. |
| -- The **execution id** is 128 random bits, minted by the console each |
| - time it starts an attempt. The engine knows work only by execution id: |
| - every dispatch, poll, cancel and response names one. The record stores |
| - the current execution with the store's bucket and `provisioned.at`; a |
| - commit is refused if either has changed (`store_changed`). |
| - |
| -**Repeat submissions.** The job is created create-only, so the same bytes |
| -are one job. A repeat POST answers 200 with the record, and: |
| - |
| -- `queued` or `running`: nothing new starts; the queue marker is |
| - rewritten if missing (astra 7). |
| -- `done`: the recorded outputs are returned. Nothing is checked in the |
| - bucket and nothing is encoded. To encode again, DELETE the record and |
| - POST: that is a new, charged execution (astra 8). |
| -- `cancelled`, or `failed` with a retryable error: requeued, subject to |
| - the same checks. |
| -- `failed` with a non-retryable error: stays failed. The same bytes give |
| - the same answer. |
| - |
| -**DELETE** on a `queued` or `running` job swaps the record to `cancelled` |
| -and answers at once: cancellation is complete when that swap succeeds |
| -(§5.5). On a terminal job it removes the record and leaves the outputs, |
| -which are the app's objects. |
| - |
| -### 5.3 Records and the queue |
| - |
| - apps/<acct>/<app>/media-queue/<job id>.json marker: this job has work |
| - apps/<acct>/<app>/media-jobs/<job id>.json the record the app polls |
| - |
| -Both sit under the app's prefix, so `PurgeApp` removes them. |
| - |
| -**The marker is written first and deleted last (astra 7).** The door |
| -writes the marker, then the record; a requeue does the same. The pass |
| -deletes the marker only after the record is terminal and its usage is |
| -recorded (§7.4). So every job with work has a marker, and the boot |
| -rebuild that lists markers (the scan queue's, `queue.go:231`) finds all |
| -of it. A marker with no record is a door that crashed before answering: |
| -the pass deletes it. |
| - |
| -The record: `schema`, `id`, `key`, `etag`, `bytes`, `preset`, `state` |
| -(`queued`, `running`, `done`, `failed`, `cancelled`), `store` (`bucket`, |
| -`provisioned_at`), `submitted`, `execution` (`id`, `started`, |
| -`lease_until`), `attempts` (each ended execution: id, outcome, error code, |
| -wall time, whether its usage row and its cleanup are done), `error`, and |
| -on `done` the `result`: source duration, dimensions and codecs, the |
| -ffmpeg version (B5), and each output's key, size, ETag, content type and |
| -dimensions. |
| - |
| -`done` records are kept until the app deletes them or the app is purged: |
| -they are the registry of what was converted. `failed` and `cancelled` |
| -records are pruned 7 days after they ended. |
| +| fair use or engine-time budget (§7.2) | 429 or 503 with `Retry-After` | |
| + |
| +A passing request inserts the job row and answers 202 with the job. |
| + |
| +**The job id** is the first 32 hex characters of `sha256("v1\0" + key + "\0" + |
| +etag + "\0" + preset)`, unique within one app. A repeat POST answers 200 with |
| +the existing job, whatever its state, and starts nothing. A `failed` job stays |
| +failed; the remedy for the one failure that is not about the bytes |
| +(`engine_lost`, §5.3) is to upload again under a new key (decision 9). |
| + |
| +**GET** answers the job: `id`, `state` (`queued`, `running`, `done`, |
| +`failed`), `error` (`code`, `message`), and on `done` the source's duration, |
| +dimensions and codecs, the ffmpeg version, and each output's key, size, ETag, |
| +content type and dimensions. |
| + |
| +**Store provenance (astra R2-6).** Conversion relies on properties of the |
| +bucket, so eligibility is established, never inferred from its name. |
| + |
| +- A store whose bucket this deployment's walk itself created records that in |
| + its store record at creation. An adopted name never does. |
| +- Any other store qualifies through a one-time verification the door runs on |
| + first use and records in the store record. It checks that the bucket has the |
| + name the platform would mint, is owned by the deployment's account, is in |
| + the store region, uses SSE-S3 and not SSE-KMS, has versioning off, and has |
| + no bucket policy, lifecycle or CORS configuration the platform did not |
| + write. |
| +- A store that fails is refused with `store_unverified` and the failing check. |
| + The verification is repeated on the next submission, so fixing the bucket is |
| + enough. |
| + |
| +### 5.3 The job row: the one place the lifecycle lives (paul R-C) |
| + |
| +A console table `media_jobs`, one row per job, changed only in database |
| +transactions. It holds: account, app, job id, key, etag, bytes, preset, |
| +bucket, `state`, `execution_id`, `started_at`, `reserved_ms`, `charged_ms`, |
| +`settled`, `source_ms`, `result`, `error`, `cleanup_due`, `retired_at`. There |
| +are no bucket records and no queue markers **(closes astra R2-2)**. |
| + |
| +**Transitions.** Each is one transaction. |
| + |
| +| Step | From | To | |
| +|---|---|---| |
| +| submit | no row | `queued` | |
| +| dispatch | `queued` | `running`; `execution_id` is 128 new random bits; `reserved_ms` is the function timeout | |
| +| return, success | `running`, same `execution_id` | `done`; `charged_ms` is the measured invoke time; `settled` | |
| +| return, failure | `running`, same `execution_id` | `failed`; `charged_ms` measured; `settled`; `cleanup_due = started_at + 1 h` | |
| +| lost | `running` | `failed` (`engine_lost`); `charged_ms = reserved_ms`; `settled`; `cleanup_due = started_at + 1 h` | |
| +| cleanup | `cleanup_due` reached | the execution's three keys deleted, then `cleanup_due` cleared | |
| +| retire | any, on app purge or account deletion | `retired_at` set; a `queued` row fails uncharged; a `running` row is settled as lost | |
| + |
| +- **Dispatch** is done by a console pass: the oldest `queued` row of the |
| + account served least recently, within the concurrency limits (§7.2). After |
| + the transaction it re-checks the store record, mints the grant (§5.4) and |
| + invokes the function synchronously (§5.5). The return value is the result; |
| + there is no callback and no poll of the engine. |
| +- **Return, success.** The console HEADs the three outputs against the sizes |
| + the function reported, then commits. If the row is no longer `running` with |
| + this execution id, the result is dropped. |
| +- **Lost.** An invoke that returns a transport or service error, and every row |
| + found `running` when the console starts, is lost. The console cannot know |
| + how long the function ran, so it charges the whole timeout. Lambda ends the |
| + function at that timeout, so the charge is never too small **(closes astra |
| + R2-4)**. |
| +- **Cleanup.** A failed or lost execution may have written some outputs. One |
| + hour after it started, the function is long dead and its transfers have |
| + expired, so one deletion with the console role's existing `DeleteObject` is |
| + complete. The obligation is the non-null `cleanup_due`; it stays until the |
| + deletion succeeds or the bucket is gone **(closes astra R2-5)**. |
| +- **Retire.** The console's app purge and account deletion call it in their |
| + own transaction, and the pass applies it to any open row whose app it finds |
| + gone. Retired rows are invisible to the door, so a recreated app of the same |
| + name starts clean, but they are kept until settled and cleaned **(closes |
| + astra R2-3)**. |
| +- **Pruning.** A row is deleted only when it is settled, its cleanup is done, |
| + and it is either retired or `failed`, 90 days after it ended. `done` rows of |
| + a live app are kept: they are the registry of what was converted, and a |
| + future stage-1 fence must read them. |
| + |
| +**Invariants.** |
| + |
| +- **I1. Discoverable.** Every job that is not terminal and settled is a |
| + `queued` or `running` row, and the pass finds work only by querying rows. |
| +- **I2. Charged exactly once.** `settled` goes from false to true in the |
| + transaction that writes `charged_ms` and the terminal state, and nothing |
| + writes `charged_ms` afterwards. |
| +- **I3. Never undercharged.** `charged_ms` is at least the engine time the |
| + execution used: the console's own measurement of a synchronous invoke it saw |
| + return, or the whole timeout otherwise. |
| +- **I4. Cleanup retained.** A row with `cleanup_due` set, or not settled, is |
| + never deleted by purge, account deletion or pruning. |
| +- **I5. One execution.** A `done` row's outputs are the keys of its own |
| + `execution_id`, and no other execution ever held a request for them. |
| + |
| +**The simulation.** The plan's first build task is `internal/sim/mediajobs`: a |
| +randomized interleaving of submit, dispatch, invoke-return, invoke-lost, |
| +console restart, cleanup and app purge against the real transition code and a |
| +fake engine, checking I1 to I5 after every step. |
| ### 5.4 Authority |
| -| Option | Verdict | |
| -|---|---| |
| -| 1. Grant the engine's role read and write on the store prefix | rejected: the ffmpeg box would hold every tenant's bucket | |
| -| 2. The console's own role presigns | rejected: the console role gains `PutObject` on every store, and no infected Deny applies | |
| -| 3. A second key on the store user per job | rejected: rotation uses both key slots (`KeyID`, `PrevKeyID`) and `ReapKeys` deletes unknown keys | |
| -| 4. A conversion role the console assumes per execution | **chosen** | |
| - |
| -- The deployment has one conversion role, assumable only by the console's |
| - role. Its policy allows `GetObject` under the store bucket prefix and |
| - `PutObject` under `derived/` in those buckets. It carries two |
| - unconditional Denies: reading any object tagged infected, and any PUT |
| - that sets a scan tag (the anti-forgery rule of `aws.go:200-226`). |
| -- **Infected sources are always refused, whatever the store's `Enforce` |
| - flag says (astra 5).** The Deny lives on the role, not in anything |
| - copied from the store record, so there is no transition to race: the |
| - HEAD at the door and the GET at the engine are both evaluated by the |
| - store at request time. This is stricter than the store user's own |
| - access when enforcement is off, on purpose. |
| -- For each execution the console assumes the role for 20 minutes with a |
| - session policy that narrows it to the one bucket, and presigns four |
| - requests. The credentials never leave the console. |
| -- **`writes_denied` (astra 5).** Refused at the door and checked again at |
| - dispatch. A store that becomes write-denied after dispatch lets that one |
| - execution finish its outputs, at most a few hundred megabytes. |
| - |
| -This does not widen what the console box can already reach (`main.tf:911`). |
| -It does add a second, switched case of the console touching tenant |
| -objects: a HEAD of the source, HEADs of the outputs, and `result.json`. |
| - |
| -To prove on dev before anything else is built **(unverified)**: the |
| -tag-conditioned Deny holds for a presigned GET and HEAD signed by the |
| -assumed role, and a presigned PUT with a signed `If-None-Match: *` is |
| -refused when the object exists. |
| - |
| -### 5.5 Executions, commit, cancel and cleanup |
| - |
| -The pass, shaped like the scan drain, takes the oldest job of the account |
| -served least recently. Every state change below is a compare-and-swap on |
| -the job record, so at most one of commit, cancel and lease replacement |
| -wins **(astra 2)**. |
| - |
| -1. **Start.** Re-check the store record (`no_store`, `adopted_store`, |
| - `store_writes_denied`, the execution budget). Swap the record to |
| - `running` with a new execution id and `lease_until = now + 20 min`. |
| - Mint the grant, presign, dispatch. |
| -2. **Poll** the engine by execution id. |
| -3. **Commit.** On success, HEAD the three outputs and compare their sizes |
| - with the engine's report. Then swap the record from `running` with |
| - this execution id to `done` with the result. That swap is the commit |
| - and the durable completion event (astra 8). If it loses, to a cancel or |
| - a newer execution, the outputs are abandoned. |
| -4. **Fail.** On an engine error, a missing engine job, or `lease_until` |
| - passing, swap the execution into `attempts` and either requeue (one |
| - retry per queueing, for retryable errors) or end as `failed`. |
| - |
| -**Cancel.** DELETE swaps the record to `cancelled`, moving the current |
| -execution into `attempts`. From that moment no commit for it can succeed. |
| -The console then tells the engine to stop that execution, best effort; if |
| -the message is lost the engine stops at its deadline. |
| - |
| -**Abandoned outputs.** An execution in `attempts` that did not commit has |
| -three known keys. The pass deletes them with the console role's existing |
| -`DeleteObject` when the execution is abandoned, and once more 24 hours |
| -later, since a store checks a presigned URL's expiry when a request |
| -starts, not when it ends. A write landing after that is an orphan under |
| -the source's `derived/` prefix. It can never alter a committed result, |
| -because no two executions share a key. |
| - |
| -The engine keeps no durable state. If it restarts, the poll gets a 404 |
| -and the execution fails as retryable. If the console restarts, the pass |
| -resumes from markers and records. |
| - |
| -### 5.6 Deletion and verdicts |
| - |
| -- **App deleted.** `PurgeApp` removes records and markers. A response for |
| - an execution whose record is gone has nothing to commit to and is |
| - dropped. |
| -- **Store torn down or re-provisioned.** The commit is refused |
| - (`store_changed`). |
| -- **Source deleted or rewritten.** Before the download: the GET's signed |
| - `If-Match` fails and the job ends `source_changed`. After it: the |
| - outputs commit and sit under `derived/<source key>/`. The rule for apps: |
| - when you delete a source, cancel its job and delete that prefix. |
| - Roadmap ruling 6's "removed with their source" is the app's duty in v1. |
| -- **Infected verdict after the download.** The job completes. The output |
| - is re-encoded pixels, not the source's bytes, and is swept like any |
| - other object. |
| -- **Store key rotation.** Unaffected: requests are signed by the |
| - conversion role. |
| - |
| -### 5.7 The engine box |
| - |
| -`infra/modules/media-host`, a sibling of `pdf-host` with the same rules: |
| -AMI passed in, explicit replacement, a security group admitting the |
| -agent's port only from the console's group (and a standby's), Session |
| -Manager only, the Deny on SSM parameter reads, IMDSv2 with a hop limit of |
| -1, and **no bucket grant**. Output `media_addr`; console variable |
| -`CARLOS_MEDIA_ADDR`; unset, the door answers 503. |
| - |
| -**Region (B6).** The box goes in the console's VPC. On dev and flagship |
| -the console box provisions the stores and both are in `eu-west-1` |
| -**(as reported; those roots are outside this tree)**, so the engine is in |
| -the store region. The module takes the store region as an input and fails |
| -its precondition if the box's region differs. The agent reports its |
| -region, and the door's `no_engine_in_region` covers any deployment where |
| -they still disagree. |
| - |
| -On the box: |
| - |
| -- **The agent**, a small pure-Go program on the private address: |
| - `POST /v1/executions`, `GET` and `DELETE /v1/executions/{id}`, |
| - `GET /health` (versions, region, slots). A dispatch carries the |
| - execution id, preset, limits, deadline and four transfers, each as |
| - **method, URL and the exact signed headers**, `If-Match` and |
| - `If-None-Match` among them **(astra 9)**. The agent sends those headers |
| - unchanged, dials only the configured store hosts, follows no redirects, |
| - and never writes a URL or a signed header to a log or an error. A full |
| - box answers 429 and the job stays queued. |
| -- **ffmpeg and ffprobe from Debian 13 arm64 packages**, with unattended |
| - security upgrades on, as on the sibling engine boxes **(B5)**. No apt |
| - hold. The agent reports the ffmpeg version with every result. A custom |
| - minimal build is a later option if the spike shows a need. |
| -- Console to agent is plain HTTP inside the VPC, closed by the security |
| - group, the trust model accepted for clamd and Gotenberg. |
| - |
| -`carlos system media status` sits beside `carlos system pdf status`: |
| -configured, healthy, versions, region match, queue depth, 24 hours of |
| -conversions and refusals. |
| - |
| -### 5.8 Uploads from a browser |
| - |
| -In scope: a phone video that cannot be uploaded from a web page is not |
| -"just working". With no `kind:media`, this belongs to the store. |
| +- The deployment has one **conversion role**, assumable only by the console's |
| + role. It allows `GetObject` under the store bucket prefix and `PutObject` |
| + under `derived/` in those buckets, and 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 function's |
| + GET, with nothing copied from the store record to go stale. |
| +- For each execution the console assumes the role for 15 minutes with a |
| + session policy narrowing it to the one bucket, and presigns four transfers: |
| + one GET for the source with `If-Match: <etag>` signed, and three create-only |
| + PUTs with their content types signed. The credentials never leave the |
| + console. |
| +- `writes_denied` is refused at the door and again at dispatch. A store that |
| + becomes write-denied later lets that one execution finish. |
| +- **The function's own role has no S3 authority (paul R-L).** It works only |
| + through the four transfers. |
| + |
| +Rejected: a bucket grant to the engine; the console's own role presigning (no |
| +infected Deny); a second key on the store user (rotation uses both slots). |
| + |
| +To prove on dev first **(unverified)**: the tag-conditioned Deny holds for a |
| +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: a Lambda function (paul R-L) |
| + |
| +`infra/modules/media-function` creates: |
| + |
| +- **The function**: an arm64 container image, pinned by digest, invoked once |
| + per execution. Its event carries the execution id, preset, limits and the |
| + four transfers, each as method, URL and exact signed headers. It downloads, |
| + probes, converts (§6), uploads, and returns the result or a named error. It |
| + never logs a URL or a signed header. |
| +- **Its network**: a subnet in the console's VPC whose route table has the S3 |
| + gateway endpoint and no route to the internet, with a security group that |
| + allows egress only to S3. The endpoint's policy admits only requests signed |
| + by the conversion role for buckets under the store prefix. |
| +- **Its role**: network-interface management and logs. Nothing else. |
| +- **Reserved concurrency**, the deployment-wide ceiling (§7.2). |
| +- **The conversion role** and the console's two new permissions: assume it, |
| + and invoke this function. |
| + |
| +Console variable `CARLOS_MEDIA_FUNCTION` (the function's ARN). Unset, the door |
| +answers 503. The module fails its precondition if the function's region is not |
| +the store region; the door's `no_engine_in_region` covers deployments wired by |
| +hand. On dev and flagship the console and its stores are both in `eu-west-1` |
| +**(as reported; those roots are outside this tree)**. |
| + |
| +**Isolation.** Each execution runs in a Lambda microVM with its own ephemeral |
| +`/tmp`, sized at 2 GiB: the 512 MiB source plus outputs. That bounds a job's |
| +bytes and files and replaces every shared-box mechanism of revision 2 |
| +**(closes astra R2-1: there is no agent, no slot and no helper unit to |
| +recover)**. Lambda reuses a warm environment for later invocations, so the |
| +function makes each environment single-use: |
| + |
| +- it serves one execution per process and exits after its response is |
| + delivered, so the next invocation starts a new runtime; |
| +- at start it refuses to run unless it is the only process in the environment, |
| + and it empties `/tmp` and checks it is empty before anything else. |
| + |
| +The spike must show that a second invocation never observes a process or a |
| +file from the first **(unverified)**. If it cannot, the design returns to Paul |
| +before anything is built. |
| + |
| +**Image build, release and rollback.** CI builds the image for arm64 from a |
| +Debian 13 base with Debian's ffmpeg packages and the function's pure-Go |
| +handler, on every platform release and on a weekly schedule, so security |
| +updates arrive by rebuild. Each build publishes a digest. A deployment copies |
| +the image into its own registry and pins the digest in its root. A new digest |
| +reaches a deployment only when its root is changed and applied; rollback is |
| +the previous digest. `carlos system media status` shows the configured digest, |
| +its build date and ffmpeg version, the queue, and 24 hours of conversions and |
| +refusals, and warns when the image is more than 30 days old. Whether amadan's |
| +CI can build arm64 images is for the builder to establish **(unverified)**. |
| + |
| +### 5.6 Uploads from a browser |
| + |
| +In scope: a phone video that cannot be uploaded from a web page is not "just |
| +working". |
| carlos store uploads enable --app shop --origin https://shop.example.com |
| carlos store uploads status|disable --app shop |
| -- A member verb on the member's own bucket **(my call)**. |
| -- Origins are explicit: `https://` and a host, no wildcard, at most 8, |
| - plus `http://localhost:<port>`. With none given, the app's ready |
| - platform hostnames at that moment are used and printed. Nothing |
| - reconciles them later. |
| -- The store record gains an additive `uploads` block. The walk writes one |
| - CORS rule (`GET`, `HEAD`, `PUT`; any request header; `ETag` exposed; |
| - one hour) and one lifecycle rule aborting incomplete multipart uploads |
| - after a day. |
| -- **Nothing foreign is ever replaced (B3).** If the bucket has a CORS or |
| - lifecycle configuration the platform did not write, `enable` refuses and |
| - changes nothing. Adopted buckets are refused outright. |
| +- A member verb on the member's own bucket **(my call)**. Origins are |
| + explicit: `https://` and a host, no wildcard, at most 8, plus |
| + `http://localhost:<port>`. With none given, the app's ready platform |
| + hostnames at that moment are used and printed; nothing reconciles them. |
| +- The store must pass §5.2's provenance check. The walk writes one CORS rule |
| + (`GET`, `HEAD`, `PUT`; any request header; `ETag` exposed; one hour) and |
| + one lifecycle rule aborting incomplete multipart uploads after a day. It |
| + never replaces a configuration the platform did not write. |
| - The store user's policy gains `s3:AbortMultipartUpload` and |
| - `s3:ListMultipartUploadParts`, written when a store enables uploads, |
| - not by a fleet-wide rewrite. The builder checks the permissions |
| - boundary allows both. |
| + `s3:ListMultipartUploadParts` for that store. The builder checks the |
| + permissions boundary allows both. |
| -**Multipart.** A single presigned PUT carries up to 5 GB **(unverified)**, |
| -far above the source cap, so multipart is never required. v1 makes it |
| -possible and safe and documents the recipe; the helper that drives it |
| -belongs to the app framework. Native apps need no CORS. |
| +A single presigned PUT carries up to 5 GB **(unverified)**, far above the |
| +source cap, so multipart is optional; v1 makes it safe and documents the |
| +recipe. Native apps need no CORS. |
| -### 5.9 CLI, docs, and an app end to end |
| +### 5.7 CLI, docs, and an app end to end |
| carlos media convert <key> --app shop [--wait] |
| carlos media status <id> --app shop |
| - carlos media cancel <id> --app shop |
| carlos system media status |
| -A docs page `docs/site/video.md`, `docs/site/cli.md` headings for every |
| -verb, a plans-page row, and one residency sentence: conversion happens in |
| -the store's region. Its walkthrough, for app `shop` on `shop.example.com`: |
| +A docs page `docs/site/video.md`, `docs/site/cli.md` headings for every verb, |
| +a plans-page row, and one residency sentence: conversion happens in the |
| +store's region. Its walkthrough, for app `shop` on `shop.example.com`: |
| ``` |
| # once |
| @@ -430,41 +387,32 @@ carlos secrets set --app shop CARLOS_SERVICE_TOKEN=<secret> |
| 4. store the three output keys from the answer |
| ``` |
| -**Serving (astra 10).** The playlist names the video by the relative URL |
| -`video.mp4`, and a player resolves that against wherever the playlist |
| -finally came from. So the app **proxies the playlist from its own |
| -origin**, at a path beside its MP4 route: `/media/<id>/video.m3u8` and |
| -`/media/<id>/video.mp4`. It must not redirect the playlist. The MP4 and |
| -the poster may be proxied with `Range` or redirected to a presigned GET. |
| -`<video src=".../video.mp4" poster=".../poster.jpg">` then plays |
| -everywhere, and the playlist serves players that prefer HLS. |
| +**Serving.** The playlist names the video by the relative URL `video.mp4`, and |
| +a player resolves that against wherever the playlist finally came from. So the |
| +app **proxies the playlist from its own origin**, beside its MP4 route |
| +(`/media/<id>/video.m3u8`, `/media/<id>/video.mp4`), and never redirects it. |
| +The MP4 and the poster may be proxied with `Range` or redirected to a |
| +presigned GET. |
| + |
| +**Deleting.** When an app deletes a source it deletes `derived/<source key>/` |
| +too. Roadmap ruling 6's "removed with their source" is the app's duty in v1. |
| Every user-facing string goes through copy review before it is written. |
| ## 6. Security: ffmpeg and hostile input |
| -Treat every source as an exploit attempt, and judge the design by what a |
| -compromised helper can reach. |
| - |
| -**Scratch (astra 4).** Each slot owns a fixed-size filesystem of its own |
| -(2 GiB, a fixed inode count; a dedicated volume or a loop file, never the |
| -root disk). The agent recreates it before every execution, which also |
| -clears whatever a crash left. It holds two directories: `in/`, where the |
| -agent writes the download, and `out/`, where the helper writes. Bytes and |
| -inodes are bounded by the filesystem itself, downloads included, and the |
| -box's own disk is never shared with a job. A slot whose filesystem cannot |
| -be recreated takes no work. |
| - |
| -**Before ffmpeg starts.** The agent enforces the byte cap while |
| -downloading. It reads the first bytes in Go and accepts two families: ISO |
| -BMFF (`ftyp`: MP4, MOV, 3GP) and Matroska/WebM (EBML). Anything else is |
| +Treat every source as an exploit attempt. |
| + |
| +**Before ffmpeg starts.** The handler enforces the byte cap while downloading. |
| +It reads the first bytes in Go and accepts two families: ISO BMFF (`ftyp`: |
| +MP4, MOV, 3GP) and Matroska/WebM (EBML). Anything else is |
| `unsupported_container` and ffmpeg never runs. |
| -**Probe before transcode.** `ffprobe` runs in the sandbox with the |
| -demuxer forced to the sniffed family. The agent takes the first video and |
| -first audio stream, ignores every other stream, and checks: |
| +**Probe before transcode.** `ffprobe` runs with the demuxer forced to the |
| +sniffed family. The handler takes the first video and first audio stream, |
| +ignores every other stream, and checks: |
| -| Condition | Error (non-retryable) | |
| +| Condition | Error | |
| |---|---| |
| | no video stream | `no_video` | |
| | video codec not H.264, HEVC, VP8, VP9 or AV1 | `unsupported_video_codec` | |
| @@ -474,33 +422,33 @@ first audio stream, ignores every other stream, and checks: |
| | longer than the duration cap | `source_too_long` | |
| | probe fails or exceeds 30 s | `unreadable` | |
| -**The sandbox (astra 3).** ffprobe and ffmpeg each run as a transient |
| -systemd unit. Its filesystem view is built from nothing: the runtime |
| -files ffmpeg needs, bound read-only; this execution's `in/`, read-only; |
| -this execution's `out/`, writable. Nothing else of the host is visible, |
| -so the helper cannot read another file to exfiltrate. Also: `DynamicUser`, |
| -`PrivateNetwork`, `PrivateDevices`, `NoNewPrivileges`, an empty |
| -capability set, no address families, a `@system-service` syscall filter, |
| -`MemoryDenyWriteExecute`, `RestrictNamespaces`, `MemoryMax=2G` with no |
| -swap, `TasksMax=64`, and `RuntimeMaxSec` at the wall-time budget. |
| - |
| -**The command.** A fixed input path, never the tenant's key. `-nostdin`, |
| -`-protocol_whitelist file`, the demuxer forced, a decoder allow-list |
| -matching the table, only the two chosen streams mapped, `-t` at the |
| -duration cap so a lying header cannot extend the encode. |
| - |
| -**Collecting outputs (astra 3).** The agent touches `out/` only after the |
| -unit has exited and no helper process remains. It opens the three |
| -expected names relative to a directory descriptor it holds, refusing any |
| -symlink, any path that leaves the directory and anything that is not a |
| -regular file with one link, checks each size against a bound, and uploads |
| -from the open descriptors. Anything else in `out/` is ignored and wiped |
| -with the filesystem. |
| - |
| -**Wall time.** 15 minutes per execution **(my call, reset by the spike)**. |
| -Over it the job fails `too_slow`, non-retryable. |
| - |
| -## 7. Limits and sizing |
| +**The command.** ffmpeg and ffprobe are child processes with a fixed input |
| +path, never the tenant's key: `-nostdin`, `-protocol_whitelist file`, the |
| +demuxer forced, a decoder allow-list matching the table, only the two chosen |
| +streams mapped, `-t` at the duration cap, and a wall-time budget inside the |
| +function timeout. Over it the job fails `too_slow`. |
| + |
| +**Collecting outputs.** The handler touches the output directory only after |
| +the child and every descendant are dead. It opens the three expected names |
| +relative to a directory descriptor it holds, refuses any symlink, any path |
| +leaving the directory and anything that is not a regular file with one link, |
| +checks each size against a bound, and uploads from the open descriptors. This |
| +is defence in depth: the child runs in the same microVM as the handler. |
| + |
| +**What a compromised ffmpeg can reach (paul R-L).** It shares the microVM and |
| +the user with the handler, so assume it can read the handler's memory. It then |
| +holds this execution's four transfers: one tenant's one source, and three |
| +output keys nobody else will ever use. It can reach S3 through the endpoint, |
| +where the endpoint policy admits nothing but requests signed by the conversion |
| +role. It has no credentials, no route to the internet, the console, the |
| +instance metadata service or another box, and no later execution to wait for. |
| +Its worst outcome is bad output for the one job whose input attacked it. |
| + |
| +If Lambda permits a seccomp filter on the child, the builder adds one that |
| +denies sockets and reading another process's memory **(unverified, |
| +optional)**. |
| + |
| +## 7. Limits, metering and sizing |
| ### 7.1 Admission caps |
| @@ -511,254 +459,240 @@ Over it the job fails `too_slow`, non-retryable. |
| | Dimensions | 3840x2160 | What phones record | |
| | Frame rate | 60 | Slow-motion capture is out of scope | |
| -All are settings (`CARLOS_MEDIA_LIMITS`), changed without a release. |
| +All are settings (`CARLOS_MEDIA_LIMITS`). **The function timeout is 10 minutes |
| +(my call)**, inside Lambda's 15-minute ceiling: every admitted clip must |
| +download, convert and upload within it, and the spike confirms that the |
| +slowest admitted input does. If one does not, the caps come down; the timeout |
| +does not go past the ceiling. |
| ### 7.2 Fair use (every deployment) |
| -Per account **(my call on the numbers)**: |
| +**(my call on the numbers.)** |
| -- at most 20 jobs queued or running: 429; |
| -- 30 submissions a minute, burst 10: 429 with `Retry-After`; |
| -- **an execution budget (astra 6):** 60 minutes of engine wall time a UTC |
| - day spent on executions that did not commit (failed, timed out, |
| - cancelled). A running execution reserves its full 15 minutes and |
| - releases what it did not use. Over budget, the door and the pass's |
| - start step refuse with 429 `execution_budget` until the next UTC day. |
| - Deleting records does not reset it: it is counted from usage rows |
| - (§7.4), not from records. |
| -- deployment-wide, at most 200 queued: 503 with `Retry-After`. |
| +- Deployment-wide: reserved concurrency 4 on the function. The pass never runs |
| + more than that at once, so an invoke is never throttled. |
| +- Per account: at most 2 running 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 its full |
| + reservation. 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. |
| The console's `allowWrite` limit does not apply, as for PDF. |
| ### 7.3 Plan cap (deployments with a catalog) |
| A new `plans.Limits` field, `MediaMinutesMonth` (`media_minutes_month`), |
| -handled exactly as `pdf_renders_month`: monthly, a warning at the limit, a |
| -402 from `capCopy` at twice the limit, ops accounts exempt, zero meaning |
| -no limit, a new `capID`. Proposed catalog values, in the PDF row's |
| -proportions **(B4, for Paul)**: Free 30, Personal 600, Community 1,200, |
| -Business 12,000. No media pack in v1, as PDFs have none. |
| - |
| -What counts: the source duration of each committed execution, in seconds. |
| -The check runs at submission against what has committed, so an account |
| -can overshoot by its queue: 20 jobs of 3 minutes. |
| - |
| -### 7.4 Recording (astra 8) |
| - |
| -A console table `media_executions`, **one row per ended execution, unique |
| -on execution id**: account, app, credential, job id, preset, outcome, |
| -error code, source bytes and milliseconds, output bytes, wall time, time. |
| -Rows are inserted idempotently from the job record: the pass inserts a |
| -row for every ended execution not yet marked recorded, then marks it, and |
| -only then starts another execution or deletes the marker. A crash at any |
| -point repeats an insert that the unique key ignores. A repeat POST of a |
| -`done` job creates no execution and no row. Pruned at 90 days. The plan |
| -measure, the execution budget, `carlos system media status` and the usage |
| -page read this table. |
| - |
| -Outputs are ordinary objects in the tenant's bucket and count as its |
| -storage (roadmap ruling 6). |
| - |
| -### 7.5 The box and the spike |
| - |
| -**`c7g.large`**: two Graviton3 vCPUs that are not burstable, 4 GiB. The |
| -roadmap says a `t4g` is not a transcoding box and names this size for |
| -ladders. About 55 to 60 US dollars a month on demand per deployment |
| -**(unverified)**. |
| - |
| -A three-minute 1080p30 phone clip to 720p H.264 with a fast x264 preset |
| -**(estimate, not a measurement)**: 45 to 90 seconds from H.264, 60 to 120 |
| -from HEVC, 2 to 4 minutes from 4K30 HEVC, unknown with HDR tone-mapping. |
| -x264 uses both cores, so the box runs **one execution at a time**: about |
| -20 three-minute clips an hour, and ten submitted together finish in about |
| -15 minutes. Slots and instance type are module variables. |
| - |
| -**The spike is the plan's first task**; nothing above is promised until |
| -it reports. It needs real phone clips and a scoped dev change, which is |
| -decision 2 **(B2)**. On a `c7g.large` and a `c7g.xlarge` it measures: |
| - |
| -1. wall time, peak memory and scratch per clip at two or three x264 |
| - presets, and picks one; |
| -2. whether tone-mapping fits the budget; if not, HDR is refused with a |
| - named error instead of shipping washed-out video; |
| -3. whether the single fragmented MP4 plays and seeks progressively in |
| - Safari on iOS and macOS, Chrome and Firefox, and whether the playlist |
| - plays in Safari and through a JavaScript HLS player. If progressive |
| - playback fails anywhere, the fallback is a second, ordinary faststart |
| - MP4, double the storage, and G2 is amended; |
| -4. the two store behaviours in §5.4. |
| +handled exactly as `pdf_renders_month`: monthly, a warning at the limit, a 402 |
| +from `capCopy` at twice the limit, ops accounts exempt, zero meaning no limit, |
| +a new `capID`. Proposed values, in the PDF row's proportions (decision 5): |
| +Free 30, Personal 600, Community 1,200, Business 12,000. No media pack in v1. |
| + |
| +What counts: `source_ms` of `done` rows in the UTC month. The check runs at |
| +submission, so an account can overshoot by its queue. |
| + |
| +### 7.4 Metering |
| + |
| +Both measures are queries over `media_jobs`: the plan cap sums `source_ms` of |
| +`done` rows, and the engine-time budget sums `charged_ms` of the others. There |
| +is no second table and no event to carry between them. `carlos system media |
| +status` and the account usage page read the same rows. Outputs are ordinary |
| +objects in the tenant's bucket and count as its storage (roadmap ruling 6). |
| + |
| +### 7.5 Function size, cost and the spike |
| + |
| +All figures here are **estimates** until the spike reports. |
| + |
| +- **Size.** Lambda gives up to 10 GB and 6 vCPUs, and vCPUs follow memory. |
| + Start at the maximum: x264 uses every core, and a shorter run costs about |
| + the same as a smaller, longer one. |
| +- **Time.** A three-minute 1080p30 phone clip to 720p with a fast x264 |
| + preset: 20 to 60 seconds. From 4K30 HEVC: 1 to 3 minutes. With HDR |
| + tone-mapping: unknown. |
| +- **Cost.** At about 0.008 US dollars per minute of a 10 GB arm64 function |
| + **(unverified)**: up to a cent for a typical clip, two to three cents for |
| + the slowest admitted one, 5 to 15 dollars for a thousand clips a month, |
| + and cents for an idle month. Reserved concurrency caps the worst case. |
| + |
| +**The spike precedes the build** (decision 1). On a dev function it shows: |
| + |
| +1. wall time and peak memory per clip at two function sizes and two or three |
| + x264 presets, against the 10-minute timeout; |
| +2. whether tone-mapping fits; if not, HDR is refused with a named error; |
| +3. that a 10-minute synchronous invoke from the console box holds; |
| +4. the single-use environment claim of §5.5 and the two store behaviours of |
| + §5.4; |
| +5. 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. |
| ## 8. Provider boundary |
| -**Core, no cloud API:** the door, records, queue, pass, limits, metering, |
| -the engine protocol, the agent, the preset, the sandbox, and two seams in |
| -`internal/objstore` with in-memory fakes: a per-execution grant ("a |
| -presigner for this store") and bucket upload configuration. |
| - |
| -**AWS adapter:** the grant through STS `AssumeRole`; the conversion role |
| -and the console's permission to assume it, a `region-host` switch |
| -(`store_conversion`, off by default like `store_scanning`); `media-host` |
| -as an EC2 module; the CORS and lifecycle calls and their console grants. |
| - |
| -**A non-AWS deployment today** has no object stores (§3), so nothing to |
| -convert. A MinIO-compatible backend implements the two seams when it |
| -arrives. The grant needs a principal that carries the infected-tag Deny |
| -and can sign requests; MinIO documents `AssumeRole` **(unverified)**. |
| -Per-bucket CORS is not on every MinIO build **(unverified)**; there the |
| -operator sets it on the server and `uploads enable` says so. The engine |
| -box is any Linux box running the agent unit, reachable only from the |
| -console; the module README states that contract. Presigned requests and |
| -conditional headers are plain S3. |
| +**Core, no cloud API:** the door, the job row and its transitions, the pass, |
| +limits, metering, the preset, the handler, the image, and three seams with |
| +in-memory fakes: an engine ("run this execution, return its result"), a |
| +per-execution grant ("presign for this store") and bucket upload |
| +configuration. |
| + |
| +**AWS adapter:** Lambda `Invoke`, STS `AssumeRole`, the `media-function` |
| +module, and the provenance, CORS and lifecycle calls with their console |
| +grants, behind a `region-host` switch (`store_conversion`, off by default |
| +like `store_scanning`). |
| + |
| +**A deployment without AWS** has no object stores today (§3). When a |
| +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, size-limited scratch, memory and |
| +time limits, and a network that reaches only the store. |
| ## 9. Rollout and acceptance gates |
| -Rule 5 (no dormant feature): the code merges with the module, and the |
| -door is live wherever `CARLOS_MEDIA_ADDR` is set. |
| +Rule 5 (no dormant feature): the code merges with the module, and the door is |
| +live wherever `CARLOS_MEDIA_FUNCTION` is set. |
| -0. **Spike** (§7.5), in dev, under decision 2. Its report amends this |
| - spec where the numbers disagree. |
| -1. **Merge** door, pass, limits, metering, agent, module, uploads verbs, |
| - docs. Release. |
| -2. **Dev:** apply `media-host` and `store_conversion`, set |
| - `CARLOS_MEDIA_ADDR`, run every drill. |
| +0. **Spike** (§7.5), in dev, under decision 1. Its report amends this spec |
| + where the numbers disagree. |
| +1. **Simulation** (§5.3), then the door, pass, function, module, uploads verbs |
| + and docs. Release. |
| +2. **Dev:** apply `media-function` and `store_conversion`, set |
| + `CARLOS_MEDIA_FUNCTION`, run every drill. |
| 3. **Flagship:** the same, with Paul's scoped approval (AGENTS.md). |
| **Drills, attacks first:** |
| -- A source tagged infected is refused at the door in a store with |
| - enforcement **off**. One tagged between submission and dispatch fails at |
| - the download. |
| -- A token for another app or account is refused. A key under `derived/` |
| - and an adopted bucket are refused. |
| -- Two apps submit identical bytes under the same key: two executions, and |
| - cancelling one leaves the other running. |
| -- A playlist-style file that names `http://169.254.169.254/` and a local |
| - path produces no request and reads no file. A truncated file, a lying |
| - duration, a decompression bomb and a fuzzed corpus each end in a named |
| - error with the box healthy. |
| -- A test helper that writes a hundred thousand small files, and one that |
| - fills `out/`, each fail their own job; the root disk is untouched and |
| - the next job runs. |
| -- A test helper that leaves a symlink, a hard link, a FIFO and an |
| - oversized file under the expected output names: none is uploaded. |
| -- From inside the helper's unit: no route anywhere, and no host file |
| - outside its three bindings is visible. From the box: no bucket call |
| - succeeds with the instance role. |
| -- A source rewritten between submission and dispatch ends |
| - `source_changed`. A second PUT to a committed output key is refused. |
| -- A job cancelled mid-encode never commits, even when the engine's result |
| - arrives afterwards; its keys are gone after cleanup; no minutes are |
| - charged; the wall time is in the execution budget. |
| -- An account that cancels repeatedly near the deadline is refused with |
| - `execution_budget` after 60 minutes of it. |
| -- The console killed between marker and record, between commit and usage |
| - row, and between usage row and marker deletion: each recovers with one |
| - job, one row and no stranded work. |
| -- The engine killed mid-job: retried once, completes. A 600 MB file, a |
| - 4-minute clip and an account at twice its plan cap are each refused. |
| -- Two accounts, one submitting 20 clips and one submitting one: the |
| - single clip is second in line. |
| - |
| -**Then playback (astra 10):** a two-minute 1080p phone clip, uploaded |
| -from a browser on `shop.example.com`, plays from `video.mp4` reached |
| -through a redirect to a presigned GET in Safari on iOS, Chrome and |
| -Firefox, and from `video.m3u8` proxied on the app's origin in Safari and |
| -in a JavaScript HLS player, within a time the spike sets (expected under |
| -two minutes on an idle engine). Repeating the submission returns the same |
| -job and encodes nothing. |
| +- A source tagged infected is refused at the door in a store with enforcement |
| + **off**; one tagged between submission and dispatch fails at the download. |
| +- A token for another app or account, and a key under `derived/`, are |
| + refused. A store adopted under the minted name, one with SSE-KMS and one |
| + with a foreign lifecycle rule are each refused `store_unverified`. |
| +- From inside the function: no connection to the internet, the console, the |
| + metadata service or another box; an unsigned S3 request and one signed by |
| + another principal are refused at the endpoint; the function's own role |
| + lists no bucket. |
| +- A playlist-style file naming `http://169.254.169.254/` and a local path |
| + makes no request and reads no file. A truncated file, a lying duration, a |
| + decompression bomb and a fuzzed corpus each end in a named error. |
| +- A test child that fills `/tmp`, or writes a hundred thousand small files, |
| + fails its own job. One that leaves a file in `/tmp` and a background |
| + process is invisible to the next invocation. One that leaves a symlink, a |
| + hard link, a FIFO and an oversized file under the output names uploads |
| + nothing. |
| +- A source rewritten between submission and dispatch ends `source_changed`. A |
| + second PUT to a committed output key is refused. |
| +- The console killed mid-invoke: the job ends `engine_lost`, charged the |
| + whole timeout, and its keys are gone an hour after it started. |
| +- An app purged with one job queued and one running: both rows are retired, |
| + the running one charged and cleaned, and a new app of the same name sees |
| + neither. |
| +- An account whose clips all time out is refused `execution_budget` after 60 |
| + minutes of them. A 600 MB file, a 4-minute clip and an account at twice |
| + its plan cap are each refused. Of two accounts, one submitting 20 clips |
| + and one submitting one, the single clip runs within the first three. |
| + |
| +**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 |
| +presigned GET in Safari on iOS, Chrome and Firefox, and from `video.m3u8` |
| +proxied on the app's origin in Safari and a JavaScript HLS player, within a |
| +time the spike sets (expected under a minute, cold start included). |
| +Repeating the submission returns the same job and converts nothing. |
| ## 10. Left to the builder |
| -- How the agent binary reaches the box and is pinned (a release artifact |
| - fetched and hash-checked at init is the obvious fit). |
| -- Schemas, the pass's cadence, the scratch filesystem's mechanism. |
| -- The exact unit properties and ffmpeg arguments, as long as §6 and its |
| - drills hold. |
| -- Test shape. The guards that matter: every §5.2 refusal happens before |
| - anything is written; the engine never sees a job id; a commit loses to |
| - a cancel or a newer execution; no platform code reads `result.json`; a |
| - usage row exists exactly once per ended execution. |
| +The table's schema; how a deployment copies the image into its registry; the |
| +ffmpeg arguments and process handling, as long as §6 and its drills hold; |
| +module variable names, following `pdf-host`. Guards that matter beyond the |
| +simulation: every §5.2 refusal happens before a row is written; the function |
| +never sees a job id, an account or an app name; a result for a row no longer |
| +`running` with that execution id is dropped. |
| ## 11. Amendments |
| **Media roadmap:** |
| -- **Stage 3, single rendition:** replaced by this design. Kept: jobs |
| - under the app's prefix, a polled record, eligibility by region. Changed: |
| - the door's path and the verb; every source re-encoded to a 720p cap; |
| - one poster; no audio products. |
| -- **Ruling 7 moves:** a dedicated `c7g.large` engine box per deployment, |
| - not `carlos-media.service` on the Ireland `t4g.medium`. |
| -- **Ruling 11 moves:** the single rendition does not wait for stage 1. |
| - Image resizing broke that ordering the same way. |
| -- **Ruling 6 is kept in part:** outputs land under `derived/` in the |
| - tenant's bucket and count as its storage. "In the source's namespace" |
| - has no meaning before stage 1, and "removed with their source" is the |
| - app's duty until then. |
| -- **Authority and the fence:** per-execution grants, immutable execution |
| - keys and a commit on the console's job record replace the media bucket |
| - policy and stage 1's publication fence for this product. Stage 1 still |
| - owns the fence for what it serves, and must read the job records. |
| -- **Stage 5:** bucket CORS moves to `carlos store uploads enable`. |
| - "Quotas come after measurement" gives way to a cap from the first job. |
| -- **§9's stage 3 gate** is replaced by §9 here. Rulings 2 and 10 stand. |
| - |
| -**Object storage:** the primitive spec and the comment at |
| -`infra/modules/region-host/main.tf:847-851` say the console reads tenant |
| -data only for scanning. Conversion is a second, switched exception, |
| -through the conversion role. |
| - |
| -The `svcrole.go` `Service` comment and the unit economics spec each gain |
| -a line. |
| +- **Stage 3, single rendition:** replaced by this design. Kept: a polled |
| + result and eligibility by region. Changed: the door's path and verb; every |
| + source re-encoded to a 720p cap; one poster; no audio products; job state |
| + in the console's database, not under the app's bucket prefix. |
| +- **Ruling 7 moves (paul R-L):** the worker is a Lambda function, not |
| + `carlos-media.service` on the Ireland `t4g.medium`. |
| +- **§3's codec-helper rule** (a hardened systemd scope, no network) is met |
| + differently: the microVM is the scope and the network reaches only the |
| + store. Ruling 10 stands: ffmpeg is a separate process outside the Go tree. |
| +- **Ruling 11 moves:** the single rendition does not wait for stage 1, as |
| + image resizing did not. |
| +- **Ruling 6 is kept in part:** outputs land under `derived/` in the tenant's |
| + bucket and count as its storage; "removed with their source" is the app's |
| + duty until stage 1. |
| +- **The fence:** per-execution grants and keys and a commit in the console's |
| + database replace the media bucket policy and stage 1's publication fence |
| + for this product. Stage 1 still owns the fence for what it serves, and |
| + must read `media_jobs`. |
| +- **Stage 5:** bucket CORS moves to `carlos store uploads enable`, and a cap |
| + applies from the first job. §9's stage 3 gate is replaced by §9 here. |
| + |
| +**Object storage:** the console reads tenant data only for scanning |
| +(`infra/modules/region-host/main.tf:847-851`). Conversion is a second, |
| +switched exception through the conversion role: a HEAD of the source and of |
| +the outputs. |
| ## 12. Decisions for Paul |
| -1. **The box (moves ruling 7).** (a) a dedicated `c7g.large` per |
| - deployment, about 55 to 60 dollars a month each; (b) `c7g.xlarge`, two |
| - at once; (c) the roadmap's `t4g.medium` behind limits. Recommend (a), |
| - confirmed by the spike. |
| -2. **The spike (B2).** It needs a handful of real clips from Paul (4K60 |
| - HDR in Dolby Vision or HLG, portrait with rotation, variable frame |
| - rate, an ordinary 1080p clip), his scoped approval to create one IAM |
| - role and one `c7g` instance in the dev account for its duration, and |
| - Safari checks on a real iPhone by Paul or on the tito-studio Mac. |
| - Recommend approving it as the plan's first task. |
| -3. **No wait for stage 1 (moves ruling 11, narrows ruling 6).** (a) ship |
| - on the app's own bucket and serving; (b) wait for `kind:media`. |
| - Recommend (a). |
| -4. **Authority.** (a) a conversion role assumed per execution, which |
| - always refuses infected sources; (b) the console's role presigns; |
| - (c) a bucket grant to the engine. Recommend (a). |
| -5. **Admission caps.** (a) 180 s, 512 MiB, 4K, 60 fps; (b) 300 s and |
| - 1 GiB; (c) 60 s and 200 MB. Recommend (a). |
| -6. **Plan values (B4).** `media_minutes_month`: Free 30, Personal 600, |
| - Community 1,200, Business 12,000, refused at twice the limit; no media |
| - pack. Or no cap until usage is measured. Recommend the cap. |
| -7. **Browser uploads in scope** as `carlos store uploads`, a member verb. |
| - Or native clients only for now. Recommend in scope. |
| -8. **Always re-encode, HDR tone-mapped, one JPEG poster.** Or add the |
| +Already ruled: a platform engine, Lambda (R-L), the lifecycle cut (R-C). |
| + |
| +1. **The spike.** It needs real clips from Paul (4K60 HDR in Dolby Vision or |
| + HLG, portrait with rotation, variable frame rate, an ordinary 1080p |
| + clip); his scoped approval to create in the dev account, for its |
| + duration, one Lambda function with its role and image repository, the |
| + conversion role, and a subnet with an S3 gateway endpoint; and Safari |
| + checks on a real iPhone by Paul or on the tito-studio Mac. Recommend |
| + approving it as the first task. |
| +2. **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. |
| +3. **Authority:** a conversion role assumed per execution that always |
| + refuses infected sources, even in stores with enforcement off, or the |
| + console's own role presigning. Recommend the conversion role. |
| +4. **Admission caps:** (a) 180 s, 512 MiB, 4K, 60 fps; (b) 300 s and 1 GiB; |
| + (c) 60 s and 200 MB. Recommend (a), if the spike shows it fits the |
| + timeout. |
| +5. **Plan values:** `media_minutes_month` at Free 30, Personal 600, |
| + Community 1,200, Business 12,000, refused at twice the limit, no media |
| + pack; or no cap until usage is measured. Recommend the cap. |
| +6. **Browser uploads in scope** as `carlos store uploads`, a member verb, or |
| + native clients only for now. Recommend in scope. |
| +7. **Always re-encode, HDR tone-mapped, one JPEG poster**, or add the |
| roadmap's remux path. Recommend always re-encode. |
| -9. **On for every app** with a store and a Service credential, as PDFs |
| - are. Or a per-app switch. Recommend on for every app. |
| -10. **Codec licences.** The engine encodes H.264 and AAC with Debian's |
| - ffmpeg on the platform's own box. Accept that position or have it |
| - checked before flagship. A question, not a recommendation. |
| +8. **On for every app** with a store and a Service credential, as PDFs are, |
| + or a per-app switch. Recommend on for every app. |
| +9. **No retry in v1.** With requeue cut, a job lost to a console restart |
| + mid-run ends `engine_lost` for good and the app must upload again under a |
| + new key. (a) accept that; (b) allow one automatic second execution, which |
| + puts a second reservation and cleanup into the row. Recommend (a), and |
| + watch how often releases hit running jobs. |
| +10. **Codec licences.** The function encodes H.264 and AAC with Debian's |
| + ffmpeg. Accept that position or have it checked before flagship. A |
| + question, not a recommendation. |
| ## 13. Review log |
| -**Astra round 1** (`CODEX-FINDINGS-VIDEO.md`, 5 P1, 5 P2). Every citation |
| -was checked and all ten findings accepted; each change is marked |
| -**(astra N)** where it lands. Three took a simpler form than the finding |
| -proposed: 6 is one daily fair-use number counted from usage rows, not a |
| -reserve-and-release ledger against the plan; 7 orders the two writes so |
| -there is no state to reconcile; 8 makes a re-encode an explicit DELETE |
| -then POST. |
| - |
| -**Builder check:** B1 to B6 settled as marked in the text. |
| +**Round 1** (`CODEX-FINDINGS-VIDEO.md`): ten findings, all accepted. **Round |
| +2** (`CODEX-FINDINGS-VIDEO-R2.md`, 1 P1, 5 P2), all accepted: |
| + |
| +- **R2-1** slot reuse after an agent restart: closed by R-L. No agent, slot or |
| + helper unit exists; the like risk, a reused Lambda environment, is handled |
| + in §5.5 and proved in the spike. |
| +- **R2-2** stranded jobs: closed by R-C. One row is the job and its place in |
| + the queue (I1). |
| +- **R2-3** deletion erasing the accounting: closed by R-C. No DELETE; purge |
| + retires rows and never removes an unsettled one (I2, I4). |
| +- **R2-4** cancel before the engine stops: closed by R-C and R-L. No cancel, |
| + and an unobserved run is charged the whole timeout (I3). |
| +- **R2-5** second cleanup lost: closed by R-C. `cleanup_due` stays in the row |
| + until the deletion succeeds (I4). |
| +- **R2-6** bucket name is not provenance: recorded at creation or established |
| + by a recorded verification, otherwise refused (§5.2). |
| **Findings not accepted:** none. |
| -**Cut in this revision:** deterministic output keys, the platform reading |
| -`result.json`, the automatic re-encode when outputs are missing, the |
| -session policy copied from the store record, the redispatch margin, the |
| -minimal ffmpeg build, and the app appendix. |