Files
agent/docs/superpowers/plans/2026-09-14-editor-media-pipeline.md

6.3 KiB
Raw Permalink Blame History

Editor Media Pipeline Implementation Plan

Execute inline using executing-plans and test-driven-development; the user already requested execution, no further execution-mode confirmation.

Goal: Prepare actual licensed source media and return auditable frames/subtitles through Agent Studio, then enforce original analysis, reference, recipe, render and review gates. Architecture: Fixed CMS/admin signing; bounded same-CDN HTTPS HLS retrieval to local files; FFmpeg/FFprobe without network or inherited secrets. Per-session service and explicit approval tools reuse the existing Harness. Rendering cannot run until analysis and reference gates pass. Tech Stack: Existing TypeScript/Fastify/Pi/React; pinned ffmpeg-static 5.3.0, ffprobe-static 3.1.0; bundled Python 3.12 and original Skill validators. Spec: docs/superpowers/specs/2026-09-10-short-drama-web-design.md.

Constraints

No CMS writes, uploads, source overwrites, arbitrary shell or credential/URL exposure. First acceptance title is 06aa396d-175a-48ed-ad76-02786ef4d0a9 (Beneath the Ice). Read-only preflight is already PASS. Metadata completeness is not media analysis. Content review must follow the newly added adult-content gate, never fabricate reviewer PASS.

1. Source preparation

Files: cms/cms-connection.ts, media/hls.ts, media/media-worker.ts, media/editor-service.ts, matching harness tests.

  • Write failing tests for HLS target-origin/path escapes, encrypted/byte-range playlists, master nesting, segment count/duration/byte limits; valid playlists become local filenames without signed URLs.
  • Implement parseHls(text:string): {kind:'master',variants:string[]} | {kind:'media',segments:{uri:string,duration:number}[],duration:number}. Only finite VOD MPEG-TS sources; reject unsupported formats explicitly, never silently skip encryption or audio renditions.
  • Add CmsConnection.playback(dramaId,episodeId) returning signed URL only to server-side service after exact inventory binding and admin checks.
  • EditorService.prepare({dramaId,episodeNumbers},signal) allows at most 5 episodes, 30 minutes/episode, 1 GiB/task download. Fetch fixed public CDN, no redirects, preserve CDN-issued per-path signing query only on same episode-directory assets. Localize manifests before invoking FFmpeg with file,crypto,data protocol allowlist; no network credentials in child env.
  • Probe real local MP4 for audio and video, hash sources; create representative JPEGs, save captions and source/time bindings in private runtime. Cancellation aborts fetch and kills process group.

2. Web tools and artifacts

Files: media/editor-tools.ts, server assembly and routes, tool policy and approval UI.

  • Expose prepare_drama_sources with exact IDs/quotas (approval), read_drama_frames returning small selected JPEG images plus time/source binding (approval), editor_job_status (read-only).
  • Keep normal image-tool results out of SSE base64 payloads. Expose only registered frame IDs scoped to owning Session, with no-store/nosniff and inline JPEG display. Model must read Skill before analysis; no shell access.
  • Verify actual first/middle/last source download, image tool result acceptance by existing Qwen, and genuine transcript evidence. A safe extraction result can be claimed only after probing output.

3. Analysis and downstream gates

Files: validator bridge and video job routes/review components, separate tests following the verified interfaces above.

  • Bind every analysis submission to freshly prepared drama_id/fetched_at and server-issued analysis_id. Server compares actual subtitle/frame IDs before invoking original validator; reject invented evidence, paths or PASS flags.
  • After diagnosis PASS, obtain verified public short-drama references through a separately configured source or user-supplied direct evidence; never claim current Codex search is inherited by the webpage. Missing reference access/evidence is a genuine gate requiring input, not an automatic Tier C downgrade.
  • Bind immutable recipe and content-review records to the same analysis and approved source IDs; user approves exact plan hash. Run original render_exact and machine QA with bounded child process and minimum environment. Verified with synthetic engineering fixtures; real-drama acceptance remains pending.
  • Serve REVIEW preview/ranged download only for registered artifacts; final export requires human full-playback-with-sound review bound to exact video hash, plus existing content/story gates.

Verification and persistence

  • Run baseline/regression tests, original validators, typecheck/lint/build. Keep progress in this plan, avoid claiming later unchecked gates complete.
  • Restart only the local service after build; fresh web Session must enable verified Qwen image capability by default. Credentials remain in memory, require re-login after restart.
  • Run real browser task to a genuine review/approval gate. Do not stop at a preflight or after writing a plan.

2026-09-14 execution evidence

  • Real local acceptance passed: episodes 1/3/5 downloaded, remuxed with audio/video, probed, SHA-256 recorded, 9 JPEGs and English VTT saved.
  • Real browser run loaded the original Skill and CMS contract, requested page approval, then successfully ran prepare_drama_sources for all three episodes. Job job_b1280a06-450e-4982-935a-b2bd8dfb726f; nine actual 288×512 images loaded in the result card.
  • Licensed subtitles/frames have NOT yet been sent to Qwen. Separate transmission authorization remains pending. Do not equate the model's earlier synthetic-image test with a real-drama analysis pass.
  • Original analysis/recipe/hook validators, reference scorer, renderer and machine QA are now connected. Source and plan review endpoints are human-only; tools cannot submit approval. REVIEW video routes support byte ranges, with frontend playback/download. Actual model transmission and real-title end-to-end acceptance remain pending.
  • Fresh synthetic integration produced actual 10-second H.264/AAC/1080×1920 with original source audio and mapped English subtitles. It does not establish licensed-drama analysis, real reference evidence, or semantic content PASS.
  • Local persisted files are not yet restart-resumable. Global disk-cache quota, automatic public reference search and final-stage export remain open; final PASS is never synthesized.