gooseworks 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +42 -11
  2. package/dist/commands/doctor.d.ts +29 -5
  3. package/dist/commands/doctor.d.ts.map +1 -1
  4. package/dist/commands/doctor.js +107 -63
  5. package/dist/commands/doctor.js.map +1 -1
  6. package/dist/commands/fetch.d.ts +1 -0
  7. package/dist/commands/fetch.d.ts.map +1 -1
  8. package/dist/commands/fetch.js +64 -29
  9. package/dist/commands/fetch.js.map +1 -1
  10. package/dist/commands/install.d.ts.map +1 -1
  11. package/dist/commands/install.js +37 -4
  12. package/dist/commands/install.js.map +1 -1
  13. package/dist/commands/login.d.ts.map +1 -1
  14. package/dist/commands/login.js +8 -3
  15. package/dist/commands/login.js.map +1 -1
  16. package/dist/commands/skills.d.ts +34 -0
  17. package/dist/commands/skills.d.ts.map +1 -0
  18. package/dist/commands/skills.js +109 -0
  19. package/dist/commands/skills.js.map +1 -0
  20. package/dist/commands/update.d.ts.map +1 -1
  21. package/dist/commands/update.js +17 -6
  22. package/dist/commands/update.js.map +1 -1
  23. package/dist/commands/video-local.d.ts +9 -0
  24. package/dist/commands/video-local.d.ts.map +1 -0
  25. package/dist/commands/video-local.js +83 -0
  26. package/dist/commands/video-local.js.map +1 -0
  27. package/dist/commands/video-save.d.ts +3 -0
  28. package/dist/commands/video-save.d.ts.map +1 -0
  29. package/dist/commands/video-save.js +83 -0
  30. package/dist/commands/video-save.js.map +1 -0
  31. package/dist/index.js +7 -0
  32. package/dist/index.js.map +1 -1
  33. package/dist/lib/video-local-captions.d.ts +83 -0
  34. package/dist/lib/video-local-captions.d.ts.map +1 -0
  35. package/dist/lib/video-local-captions.js +261 -0
  36. package/dist/lib/video-local-captions.js.map +1 -0
  37. package/dist/lib/video-local-runtime.d.ts +8 -0
  38. package/dist/lib/video-local-runtime.d.ts.map +1 -0
  39. package/dist/lib/video-local-runtime.js +201 -0
  40. package/dist/lib/video-local-runtime.js.map +1 -0
  41. package/dist/lib/video-save-mcp.d.ts +9 -0
  42. package/dist/lib/video-save-mcp.d.ts.map +1 -0
  43. package/dist/lib/video-save-mcp.js +162 -0
  44. package/dist/lib/video-save-mcp.js.map +1 -0
  45. package/dist/lib/video-save.d.ts +77 -0
  46. package/dist/lib/video-save.d.ts.map +1 -0
  47. package/dist/lib/video-save.js +440 -0
  48. package/dist/lib/video-save.js.map +1 -0
  49. package/dist/skills/custom-video-skill.d.ts +3 -0
  50. package/dist/skills/custom-video-skill.d.ts.map +1 -0
  51. package/dist/skills/custom-video-skill.js +6 -0
  52. package/dist/skills/custom-video-skill.js.map +1 -0
  53. package/dist/skills/installer.d.ts +12 -6
  54. package/dist/skills/installer.d.ts.map +1 -1
  55. package/dist/skills/installer.js +41 -15
  56. package/dist/skills/installer.js.map +1 -1
  57. package/dist/skills/master-skill.d.ts +22 -19
  58. package/dist/skills/master-skill.d.ts.map +1 -1
  59. package/dist/skills/master-skill.js +1472 -551
  60. package/dist/skills/master-skill.js.map +1 -1
  61. package/dist/skills/package-freshness.d.ts +16 -0
  62. package/dist/skills/package-freshness.d.ts.map +1 -0
  63. package/dist/skills/package-freshness.js +36 -0
  64. package/dist/skills/package-freshness.js.map +1 -0
  65. package/dist/skills/releases.d.ts +12 -0
  66. package/dist/skills/releases.d.ts.map +1 -0
  67. package/dist/skills/releases.js +152 -0
  68. package/dist/skills/releases.js.map +1 -0
  69. package/dist/skills/routes.d.ts.map +1 -1
  70. package/dist/skills/routes.js +7 -1
  71. package/dist/skills/routes.js.map +1 -1
  72. package/dist/utils/browser-preflight.d.ts +29 -0
  73. package/dist/utils/browser-preflight.d.ts.map +1 -0
  74. package/dist/utils/browser-preflight.js +338 -0
  75. package/dist/utils/browser-preflight.js.map +1 -0
  76. package/package.json +2 -2
  77. package/skills/goose-ads/SKILL.md +124 -16
  78. package/skills/goose-product-photos/SKILL.md +55 -3
  79. package/skills/goose-video/SKILL.md +322 -253
  80. package/skills/goose-video-local/SKILL.md +1199 -234
  81. package/skills/gooseworks/SKILL.md +199 -13
  82. package/skills/make-custom-video/SKILL.md +490 -0
  83. package/skills/manifest.json +12 -0
  84. package/skills/routes.json +8 -1
@@ -2,26 +2,115 @@
2
2
  name: goose-video-local
3
3
  slug: goose-video-local
4
4
  description: >
5
- Render an EXISTING GooseWorks video ad project or video batch on this machine (Playwright +
6
- ffmpeg + GooseWorks media proxies) and save the finished MP4 back to the project over MCP. Use
7
- when the app's "copy for Claude" command names goose-video-local, for "make the video for
8
- project <id>" / "for video batch <id>", or to remix a video ad template locally. Needs a machine
9
- with network egress and ffmpeg (local Claude Code or the desktop app), not a hosted connector.
10
- To order a NEW video ad in chat, use goose-video instead.
5
+ Render an EXISTING GooseWorks video ad project or video batch with ffmpeg (plus Playwright for
6
+ phone-mockup formats) and the GooseWorks media proxies, then save the finished MP4 back to the
7
+ project over MCP. Runs on the user's own machine (Claude Code / desktop app, with or without the
8
+ gooseworks CLI) OR inside a GooseWorks workspace sandbox (canonical MCP tools + Bash, no CLI).
9
+ Use for a client-side format project (created by goose-video), a template-remix project or a
10
+ video batch. A copy-for-Claude command or project id must first be checked with
11
+ video_project_read. A hosted connector with no shell hands this same project to the GooseWorks coworker. To start a NEW video ad in chat,
12
+ use goose-video first.
11
13
  category: ads
12
- version: 0.3.0
14
+ version: 0.6.1
13
15
  author: GooseWorks
14
- tags: [gooseworks, ads, video, remix, imessage, local-render, byoa]
16
+ tags: [gooseworks, ads, video, remix, imessage, podcast, ugc, local-render, sandbox, byoa]
15
17
  ---
16
18
 
17
19
  # GooseWorks Video Ads — local remix runtime
18
20
 
19
- You produce **video** ad creative on the user's OWN machine and sync the result back to the
20
- GooseWorks app over MCP. This document is the **runtime contract** (auth, credits, the media
21
- proxies, data I/O, the review gate). A separate **recipe skill** — fetched per format — tells you
22
- *what to make* (the pieces, prompts, models, order of assembly).
21
+ ## How to talk to the customer (applies to every message you send them)
23
22
 
24
- **Division of authority — read both, but when they disagree THIS doc wins on the environment AND the
23
+ The customer is a marketer or founder, not an engineer. Everything in this skill about tools,
24
+ fields, files, polling, models and pipeline steps is for YOU. Never pass it on to them.
25
+
26
+ - **Say what they get and what they need to decide, never how it's made.**
27
+ Bad: "Checking the media-proxy helpers for voiceover timestamps and lipsync." / "Generated with
28
+ gpt-image-2 at high quality, mouth closed, passes QC."
29
+ Good: "Recording the voices now." / "Here are your two hosts."
30
+ - **Never mention** tool, file or field names, ids, JSON, commands, scripts, installed software,
31
+ uploads, model or vendor names, timings in seconds or frames, retries, polling, internal statuses
32
+ or your own quality checks. Fix what you can quietly. If they ask how something works, explain it
33
+ simply.
34
+ - **Update them only at milestones they care about**: choices confirmed, script and voices done,
35
+ visuals done, ready to review, finished. One short line each, then stay quiet until the next
36
+ milestone. No update for setup, downloads, uploads or saving.
37
+ - **Money is in credits, with a number**: "the full video uses about N credits". Never "the cheap
38
+ pieces" or "the expensive render".
39
+ - **Problems:** say what it means for them and what they can do, in one or two sentences. No error
40
+ codes or stack traces. Only raise a problem that changes something for them.
41
+ - **Use their words**: script, voice, hook, scene, host, ending, logo, the product shot.
42
+ - **No filler**: no "Great question!", "Certainly!", "I hope this helps!", no restating what they
43
+ just said at length.
44
+
45
+ Example. Instead of a dozen lines about render tools, scripts, uploads and portraits, send:
46
+ "Got it: warm tone, home podcast studio, Brielle as the skeptic and Mark as the believer." then
47
+ "Script and voices are done (about 34 seconds)." then "Ready for you to review: the script, voices,
48
+ both hosts and the ending. You can also review your recipe ingredients in the app: <link>. Say go
49
+ here and I'll make the full video (about N credits)."
50
+
51
+ ## Use current instructions for new work
52
+
53
+ Before a new task in a terminal host, run `gooseworks skills status` once. It compares the
54
+ installed entry files, running CLI and published npm release. An older CLI needs a package
55
+ upgrade before `gooseworks update`; update alone only uses that CLI's bundled instructions.
56
+ Preserve local edits or unknown install provenance. Review/back up before explicitly replacing
57
+ modified files; never quietly reinstall over them. If the release check is unavailable, report
58
+ that freshness is unknown rather than claiming the local copy is latest.
59
+
60
+ For a new recipe run, fetch its package from the connected catalog. Retain the returned
61
+ `version` / `contentHash` and every dependency's hash with the saved package. When reusing a
62
+ saved fetch JSON, `gooseworks fetch <slug> --saved-package <file>` returns the current package
63
+ and a hash comparison without changing that file. With MCP, if the advertised `catalog_fetch`
64
+ schema accepts them, send `saved_content_hash` and `saved_dependency_hashes`; otherwise fetch
65
+ normally and compare the returned hashes yourself. Missing hashes mean unknown, not current.
66
+ The server cannot inspect a client's saved files; hash metadata does not certify later edits.
67
+ Fetch current packages into a new run directory and report stale saved instructions. Preserve
68
+ an existing approved run's recorded package; changing that harness requires a reviewed change
69
+ and approval before spending. Hosted installed snapshots use the existing Skills Update action.
70
+ Skill content and a host's cached MCP tool schemas are separate: refreshing one does not refresh
71
+ the other. Check the actual advertised tools before using new fields.
72
+
73
+ ## Chat hosts and cards
74
+
75
+ First perform the mandatory route check below. Then, without a shell, hand a verified template
76
+ project to `goose_run_task { brand_id, project_id, message }`, or a verified template batch to
77
+ `goose_run_task { brand_id, batch_id, message }` (never send both ids). Keep task_id and the
78
+ same project or batch. Generated custom children keep their separate make-custom-video flow.
79
+ Inside a coworker sandbox you are the renderer: never delegate recursively.
80
+ With card.display_hint:"widget", say at most one line and never duplicate its plan, total or
81
+ links. Otherwise print card.text_summary. Read again on customer input, not in a polling loop.
82
+ A free saved draft is not proof that planning started or a complete plan exists.
83
+
84
+ ## Mandatory route check before any local work or spend
85
+
86
+ For every existing `project_id` (including one supplied by the app's copy-for-Claude command),
87
+ call `video_project_read { brand_id, project_id }` **before** template lookup, toolchain setup,
88
+ media-proxy calls, or a review-set upload. For a batch, inspect each child project.
89
+
90
+ - **A server-rendered order** — the response has `creative_plan`,
91
+ `project.creative_spec_revision_id`, `order.creative_spec_revision_id`, a planning
92
+ `lifecycle`, or an `order` / `script_drafts.recipe` on a server format → **stop.**
93
+ Server video orders are paused, and there is **no vetted local node-execution API** for them:
94
+ do not rebuild one locally. Tell the customer this project was made for the server flow, which
95
+ is paused; offer to start the same ad on a client-side format (`goose-video`, fetched with
96
+ `catalog_fetch { type: "skill", slug: "goose-video" }`, older clients:
97
+ `fetch_skill("goose-video")`). An order already holding credits can be released with
98
+ `job_cancel`.
99
+ - **A client-side format or template remix** (a `source_sample_id` / `template_id` and none of
100
+ the above) → continue below.
101
+ - **Generated custom video** (`project.custom_video_state.mode === "generate"`) → fetch `catalog_fetch { type: "skill", slug: "make-custom-video" }`, follow it on this same project and stop following the template flow. Record independent authenticated script/ingredient approvals in this chat with the current custom_review.approval_quote phase, review_token and cumulative total; Studio is optional. A handed-off coworker cannot self-approve; do not report approval_not_required.
102
+ - **Unclear** → read again or ask; never guess and generate. A copy prompt that names this skill
103
+ is not proof of which kind the project is.
104
+
105
+ Continue below only for a verified client-side format or template remix.
106
+
107
+ For client-side formats and template remixes, you produce **video** ad creative wherever THIS agent runs and sync
108
+ the result back to the GooseWorks app over MCP. This document is the **runtime contract** (auth,
109
+ credits, the media proxies, data I/O, the review gate). A separate **recipe** — the template's
110
+ `recipe`, plus the capability skills it names — tells you *what to make* (the pieces, prompts,
111
+ models, order of assembly).
112
+
113
+ **Division of authority: read both, but when they disagree THIS doc wins on the environment AND the
25
114
  review/approval flow.** The recipe governs WHAT to make; this doc governs WHEN you pause, generate,
26
115
  and spend. In particular: a recipe may spell out a **multi-phase, multi-gate** flow — "generate the
27
116
  still [GATE] → approve → author the prompt [GATE] → approve → render [GATE] → approve", several
@@ -30,19 +119,175 @@ separate pauses. **Do NOT run it that way.** Collapse every one of those gates i
30
119
  and models; ignore its intermediate pauses. This is the exact contradiction that confused past runs
31
120
  (GOOSE-2542) — there is no ambiguity: review-once wins.
32
121
 
33
- You run inside the user's own Claude Code session (they pasted an instruction with a project
34
- id). The app NEVER runs you — it is the viewer + review surface; you are the renderer.
122
+ The app NEVER runs this skill by itself — it is the viewer + review surface; you are the renderer.
123
+
124
+ ## Keep the selected connection for the whole run
125
+
126
+ Call `account_whoami` on the connection that owns the brand/project before the first write.
127
+ Keep `environment.name` and the public `environment.api_origin` with this run. Respect the
128
+ user's selected production or staging connection. If multiple connections are available and
129
+ none was selected, resolve that once. Missing or unknown identity is uncertainty, not
130
+ permission to switch. Never infer the environment from credits, billing links or Node mode.
131
+
132
+ Reads, project creation, uploads, generation, polling and final updates all use that same
133
+ connection. If a production request fails, resume or report the failure on production;
134
+ never retry it on staging or recreate the project there. Before retrying a timed-out write,
135
+ read back the existing project or paid request on the selected connection.
136
+
137
+ Local/CLI proxy origin must match `environment.api_origin`. If it differs, use the MCP
138
+ relay on the selected connection (`GW_MEDIA_VIA=mcp`) before paid calls. Do not change
139
+ credentials or API origins to recover a failed write. An explicit user-requested move is
140
+ a separate operation, with the existing project and paid requests reconciled first.
141
+
142
+ ## Check assets for the selected format before spending
143
+
144
+ For a template, read its structured `asset_readiness` from
145
+ `video_catalog_list { kind: "formats", brand_id }`. `missing` names gaps;
146
+ `needs_review` means suitability is unverified, including older recipes without
147
+ structured requirements. `ready` describes assets only, not script or budget approval.
148
+ For a custom video, derive requirements from its actual approved scenes.
149
+
150
+ Inspect candidate files for the chosen product and format. A catalog photo can contain
151
+ multiple objects, other products or a person; its existence or approved status does not
152
+ make it a standalone image of the selected product. Check object count, framing, readable
153
+ print and real image bytes. A service conversation has no automatic packshot requirement.
154
+
155
+ Reuse a suitable approved image first. A free crop or cutout is a new file: keep the
156
+ original, inspect the result and include it in the normal ingredient review. When no
157
+ usable input exists, explain the gap before generation. Estimate any paid preparation
158
+ separately before spending. Record the selected asset and inspection in the project
159
+ review set; do not add a separate approval round.
160
+
161
+ ## Where am I running? (decide once, first)
162
+
163
+ Check in Bash, without printing any secret value:
164
+
165
+ ```bash
166
+ [ -n "$GW_MEDIA_PROXY_TOKEN" ] && echo sandbox || echo local
167
+ command -v gooseworks >/dev/null && echo cli || echo no-cli
168
+ ```
169
+
170
+ | Mode | How you know | Skills / atoms | Media-proxy auth |
171
+ |---|---|---|---|
172
+ | **GooseWorks sandbox** | `GW_MEDIA_PROXY_TOKEN` is set | `catalog_fetch { type: "skill" }` | env: `GW_MEDIA_PROXY_TOKEN` + `GW_*_PROXY_URL` |
173
+ | **Local, CLI installed** | `gooseworks` on PATH | `gooseworks fetch <slug>` or `catalog_fetch` | `~/.gooseworks/credentials.json` |
174
+ | **Local, no CLI** (Claude desktop app / Codex without login) | neither | `catalog_fetch { type: "skill" }` | `~/.gooseworks/credentials.json` if present, else **paid media over the MCP** (below) |
175
+
176
+ The `gooseworks` CLI and `~/.gooseworks/credentials.json` are **optional**. Everything this skill
177
+ needs from the app goes through the GooseWorks MCP tools below; the atoms' `media_proxy.py` reads
178
+ credentials.json when it exists and falls back to the `GW_MEDIA_PROXY_TOKEN` env otherwise.
179
+
180
+ ### Paid media over the MCP: no key, no CLI needed
181
+
182
+ Every paid generation goes through the GooseWorks media proxy and is billed to the project. **You
183
+ never need FAL_KEY, an ElevenLabs key or `fal_client`.** An atom, a recipe or an open-source
184
+ skill that lists `FAL_KEY` in its environment is describing a standalone setup; here the proxy
185
+ satisfies it. Never stop, and never ask anyone to set a key, because one is missing.
35
186
 
36
- ## CLI-free environments (cowork / headless)
187
+ **A one-off image or clip — call the MCP directly.** A frame placed in a laptop, a product cutout,
188
+ a creator still, a restyle, an animated shot, with any fal model (Nano Banana, GPT-image, Seedream,
189
+ Seedance, Kling). No atom script is needed:
37
190
 
38
- You may be running WITHOUT the `gooseworks` CLI binary (e.g. Anthropic cowork). The
39
- `mcp__gooseworks__*` tools work over the MCP connection regardless, so wherever this skill
40
- says to shell out, use the MCP equivalent:
191
+ 1. A local input (a frame pulled from a screen recording, a screenshot) must be a public URL first:
192
+ `media_upload { brand_id, scope: "video_project", scope_id: project_id, source: { type: "file" | "bytes", … } }`
193
+ (no `path`). For a file, PUT its bytes to `upload.url` with `upload.required_headers`,
194
+ then call `media_confirm { brand_id, media_id: media.id }`. Use the returned `media.url`.
195
+ 2. `data_post_provider { provider: "fal", path: <model id, e.g. "fal-ai/nano-banana/edit">, body: <model input>, project_id }`
196
+ returns `{ job_id: "fal:<request_id>" }`. Pass an `idempotency_key` so a retry isn't billed twice.
197
+ 3. Poll `job_get { job_id }` every few seconds until `complete`; the `*.fal.media` URLs are in
198
+ `result`. Download each and QC it (open the image) before using it.
41
199
 
42
- - `gooseworks fetch <slug>` → the **`fetch_skill`** MCP tool (returns the same content/scripts/
43
- files/dependencySkills). `gooseworks search <q>` → **`search_skills`**.
44
- - `gooseworks credits` → the **`get_ad_credits`** MCP tool.
45
- - `gooseworks doctor` → do the manual toolchain check in the preflight below.
200
+ For a set that must match (every laptop shot, every creator still), use ONE prompt and the same
201
+ model for all of them and change only the input image. Voice and music:
202
+ `data_post_provider { provider: "elevenlabs", path: "/v1/text-to-speech/{voice_id}" | "/v1/music", body, project_id }`
203
+ (synchronous; the audio lands in the project folder).
204
+
205
+ `photos_generate` is **not** a general image tool: it only photographs a physical catalog
206
+ product (apparel, beauty, CPG) and needs a `product_id`. A software screenshot or app mockup is a
207
+ fal image edit, above.
208
+
209
+ **Atom scripts — the MCP relay.** With neither `GW_MEDIA_PROXY_TOKEN` nor
210
+ `~/.gooseworks/credentials.json`, the atoms' `media_proxy.py` RELAYS each paid call through you
211
+ instead of calling the proxies over HTTP. Before running any atom,
212
+ `export GW_PROJECT_ID=<project_id> GW_BRAND_ID=<brand_id>` (every call is billed to that
213
+ project). When a script **exits with code 3** it wrote a request file under
214
+ `working/mcp-requests/`: make exactly that MCP call — fal:
215
+ `data_post_provider { provider: "fal", path, body, project_id }` then `job_get { job_id }` until
216
+ `complete`, saving `result.output`; ElevenLabs: `data_post_provider { provider: "elevenlabs", … }`,
217
+ saving the reply; a local file: `media_upload` with its bytes, saving `{"url": …}`. Write that JSON
218
+ to the request's `save_result_to` and **re-run the same command**; repeat until the script
219
+ finishes. Same server proxy and price as the CLI path. If the CLI is logged in to a DIFFERENT
220
+ environment than this MCP connector (prod vs staging), set `GW_MEDIA_VIA=mcp` so the spend lands
221
+ where the project lives.
222
+
223
+ ## MCP tools — canonical names (use these)
224
+
225
+ Use the canonical GooseWorks MCP tools. Legacy names are listed only as a fallback for an older
226
+ client that does not expose the canonical tool; never mix both for one step.
227
+
228
+ | Step | Canonical tool (use this) | Legacy fallback |
229
+ |---|---|---|
230
+ | Read a project / batch | `video_project_read { brand_id, project_id }` / `video_project_read { brand_id, batch_id }` | `get_ad_project` / `get_ad_video_batch` |
231
+ | Template recipe | `catalog_fetch { type: "template", slug: <source_sample_id> }` | `get_ad_template` |
232
+ | Capability skill (atom) + its scripts | `catalog_fetch { type: "skill", slug }` | `gooseworks fetch <slug>` / `fetch_skill` |
233
+ | Brand kit, products, rules | `brand_read { brand_id, sections: ["summary","kit","products","learnings"] }` | `brand_get_context` / `get_brand_kit` |
234
+ | Save a brand rule (a correction) | `brand_update { brand_id, knowledge_intent: "user_correction", user_statement: <the user's exact words>, patch: { facts: [{ id?, kind, text }] } }` | none |
235
+ | Mirror the review set | `video_project_upsert { brand_id, project_id, patch: { script: { script_drafts, script } } }` | `update_ad_project_script` |
236
+ | Project assets | `video_project_upsert { …, patch: { assets: [...] } }` | `update_ad_project_asset` |
237
+ | Progress note | `video_project_upsert { …, patch: { message: { role: "agent", content } } }` | `append_project_message` |
238
+ | Batch status | `video_project_upsert { brand_id, batch_id, patch: { batch: { status } } }` | `update_ad_video_batch` |
239
+ | Upload a file to the project | `media_upload { brand_id, scope: "video_project", scope_id: project_id, kind, path, source: { type: "file", filename, content_type } }` → PUT → `media_confirm { brand_id, media_id: media.id }` | `get_upload_url` / `get_ad_upload_url` |
240
+ | Save / find a finished piece (resume) | `media_upload { …, path, ingredient_key, input_digest }` / `media_list { brand_id, scope: "video_project", scope_id: project_id, ingredient_key_prefix: "" }` (see "Save as you go") | none |
241
+ | Open the render row | `video_render_run { brand_id, project_id, kind: "full" }` (no `dry_run`; returns `render_id`) | `submit_render { project_id, kind: "full" }` |
242
+ | Update the render row | `video_render_run { brand_id, project_id, render: { render_id, status, output_url?, thumbnail_url?, error_message?, quality_status?, quality_report? } }` | `update_render_status` |
243
+ | Pin the final render | `video_project_upsert { brand_id, project_id, patch: { final_render_id: render_id } }` | `set_final_render` |
244
+ | Credits / identity | `account_whoami` | `get_ad_credits` |
245
+
246
+ `list_accessible_scopes` and the `target: { type: "agent", agent_id }` dance are **not needed**:
247
+ `media_upload` with `scope: "video_project"` derives the right storage key (org-default Ads agent
248
+ + brand slug + project folder) on the server.
249
+
250
+ ## Running in a GooseWorks sandbox
251
+
252
+ You are an agent inside the user's GooseWorks workspace sandbox (Claude Code harness, Bash, the
253
+ GooseWorks MCP with canonical tools only). There is **no `gooseworks` CLI** and **no
254
+ `~/.gooseworks/credentials.json`**. The environment carries `GW_MEDIA_PROXY_TOKEN`, `GW_API_BASE`,
255
+ `GW_FAL_PROXY_URL`, `GW_FAL_STORAGE_PROXY_URL`, `GW_ELEVENLABS_PROXY_URL`, `GW_WHISPER_PROXY_URL`
256
+ and usually `GW_PROJECT_ID`.
257
+
258
+ - **Formats:** only formats that need **no Chromium** run here — podcast skits and UGC /
259
+ talking-head formats (ffmpeg + PIL assembly). If the template's recipe or an atom needs
260
+ Playwright/Chromium with no PIL fallback (iMessage / ChatGPT / Notes phone mockups,
261
+ hyperframes, HTML recorders), **stop before any spend** and say so plainly: "This format needs
262
+ a browser renderer that this workspace doesn't have. Run it in your own Claude Code with the
263
+ GooseWorks CLI (`goose-video-local`), or pick a podcast/UGC format." Do not half-render.
264
+ - **Toolchain:** check `ffmpeg -version` and `ffprobe -version`. Install Python deps only when an
265
+ atom needs them: `pip install --quiet pillow` when a render atom uses PIL (captions, end card),
266
+ `pip install --quiet requests` if `import requests` fails. Never `npx playwright install` here.
267
+ - **Atoms:** `catalog_fetch { type: "skill", slug }` returns `content`, `scripts`, `files` and
268
+ `dependencySkills`. Write `content` to `/tmp/gooseworks-scripts/<slug>/SKILL.md`, each
269
+ `scripts` entry to `/tmp/gooseworks-scripts/<slug>/scripts/<name>` and each `files` entry to
270
+ `/tmp/gooseworks-scripts/<slug>/<name>` (keep the key as the relative path; do the same for
271
+ each dependency skill). Run scripts from their `scripts/` folder so `import media_proxy` resolves.
272
+ - **Project attribution:** `export GW_PROJECT_ID=<project_id>` in the shell **before running any
273
+ atom** for that project (re-export per concept in a batch). The proxies bill the workspace
274
+ agent and attribute spend to that project.
275
+ - **Never call a provider with a raw key.** All FAL / ElevenLabs / Whisper traffic goes through
276
+ the `GW_*_PROXY_URL` bases with `GW_MEDIA_PROXY_TOKEN`. `FAL_KEY` / `ELEVENLABS_API_KEY` in
277
+ this environment are proxy tokens, not provider keys — never send them to `fal.run`,
278
+ `queue.fal.run` or `api.elevenlabs.io` directly. Never print any token.
279
+ - **Whisper for QC:** `export OPENAI_BASE_URL="$GW_WHISPER_PROXY_URL/v1"` before running
280
+ `review-ugc-render` / `watch` transcripts.
281
+ - **The operator may be absent.** Keep every quality gate and checkpoint below, but decide
282
+ defaults yourself from the project brief and the recipe, and record them in the review set.
283
+ Ask in the chat **only for a true taste call** (a creative choice the brief and recipe leave
284
+ open and that changes the ad), never for a mechanical or recoverable decision. The Step 3
285
+ approval still applies: ask for it in this chat and record the yes with
286
+ `video_project_upsert patch.approve`.
287
+ - **Outputs:** keep working files under `/tmp/gooseworks-video/<project_id>/` (local disk — never
288
+ the s3fs workspace mount, which is slow and can drop writes); anything the user must see goes to
289
+ the project via `media_upload` (never leave the result only in the sandbox). Every paid piece is
290
+ also SAVED to the project as soon as it passes QC — see "Save as you go — and resume".
46
291
 
47
292
  ## Report problems so we can fix them (telemetry — do this, don't skip it)
48
293
 
@@ -55,97 +300,285 @@ the skill. It's fire-and-forget, never counts against you, and never blocks your
55
300
  `export GW_RUN_ID="vid-<project_or_batch_id>"` (and `export GW_SKILL="<recipe-slug>"`) in the
56
301
  shell you render from. The media proxies read `GW_RUN_ID` automatically.
57
302
  - **CLI present →** `gooseworks log "<what happened>" --event-type <type> --level error --details '{"error":"...","step":"...","model":"..."}'`
58
- - **No CLI (cowork / headless) →** the **`log_cli_event`** MCP tool with the same fields (pass `run_id`).
59
- - `--event-type`: `api_failure` (a proxy/model call failed) · `missing_input` · `blocker` ·
303
+ - **No CLI (sandbox / cowork) →** from any atom's `scripts/` folder:
304
+ `python3 -c 'from media_proxy import gw_log; gw_log("<what happened>", event_type="blocker", level="error", details={"step": "..."})'`
305
+ (or the `log_cli_event` MCP tool if your client has it).
306
+ - Event types: `api_failure` (a proxy/model call failed) · `missing_input` · `blocker` ·
60
307
  `confusion` (unclear/contradictory instruction) · `error` (a bug) · `step`/`info` (progress notes).
61
- - Put the **real error text + the step you were on** in `--details`. Paid FAL/ElevenLabs calls
308
+ - Put the **real error text + the step you were on** in the details. Paid FAL/ElevenLabs calls
62
309
  ALREADY auto-log their own failures, so focus your manual logs on what the proxy can't see:
63
310
  missing inputs, confusing/contradictory recipe instructions, toolchain/setup failures, and bugs.
64
311
  - Logging is FOR US — it does not replace telling the user. When a problem blocks the run, still
65
- explain it to the user (and ask if you need a decision); just also `log` it so we can fix the skill.
312
+ explain it to the user (and ask if you need a decision); just also log it so we can fix the skill.
66
313
 
67
314
  ## Prerequisite — MCP + a render toolchain (Phase 0 preflight)
68
315
 
69
- - The `mcp__gooseworks__*` tools are REQUIRED. If they're unavailable, stop and tell the user
316
+ - The GooseWorks MCP tools are REQUIRED. If they're unavailable, stop and tell the user
70
317
  to connect the GooseWorks MCP server (or run `gooseworks install --claude --mcp` on the CLI)
71
318
  and restart. There is no REST fallback.
72
- - **The render runs wherever THIS agent runs, and it needs a real toolchain: `ffmpeg` +
73
- `ffprobe` + a Playwright **Chromium**.** Establish it in this priority order, and do NOT start
319
+ - **The render runs wherever THIS agent runs, and it needs a real toolchain:** `ffmpeg` +
320
+ `ffprobe` always, plus a Playwright **Chromium** for browser-rendered formats (phone mockups,
321
+ HTML end cards without a PIL fallback). Establish it in this priority order, and do NOT start
74
322
  rendering until one is confirmed:
75
- 1. **CLI present →** run `gooseworks doctor` (checks login, MCP, ffmpeg/ffprobe, Playwright
76
- Chromium in one shot). Fix any ✗ with the command it prints, then continue.
77
- 2. **No CLI →** check the toolchain yourself: `ffmpeg -version`, `ffprobe -version`, and a
78
- Playwright Chromium probe (`npx playwright --version` and, if needed, `npx playwright install
79
- chromium`). If all resolve, continue.
80
- 3. **Docker available →** this is the most reliable way to get the toolchain in a sandbox that
81
- lacks it: run the render steps inside the prebuilt image
323
+ 1. **Sandbox →** see "Running in a GooseWorks sandbox": ffmpeg + ffprobe (+ PIL on demand); no
324
+ Chromium, so browser formats stop there.
325
+ 2. **CLI present →** run `gooseworks doctor --no-browser` for login, MCP, Node 18+, ffmpeg
326
+ with libx264 + libass, and ffprobe. This is common setup only. After fetching the selected
327
+ capabilities in Step 2, check each browser renderer's actual launch before ANY paid
328
+ ingredient. An unscoped `gooseworks doctor` checks only the calling folder's browser;
329
+ it cannot certify a different fetched renderer.
330
+ 3. **No CLI →** check the toolchain yourself: `node --version` (18+), `ffmpeg -version`,
331
+ `ffprobe -version`, plus `ffmpeg -hide_banner -encoders` (libx264) and
332
+ `ffmpeg -hide_banner -filters` (ass). After fetching, use the exact-package free launch
333
+ check in Step 2; resolving a package or finding a cache folder does not prove its browser
334
+ can launch. The `watch` QC step later needs the same ffmpeg and,
335
+ for transcripts, a Whisper backend — without one it degrades to frames only.
336
+ 4. **Docker available →** the most reliable way to get the toolchain on a host that lacks it:
337
+ run the render steps inside the prebuilt image
82
338
  **`ghcr.io/gooseworks-ai/goose-video-render`** (ffmpeg + ffprobe + Playwright Chromium baked
83
- in), mounting the project working directory. Use Docker whenever the host is missing ffmpeg or
84
- Chromium and `docker` is on PATH. (Note: nested Docker is usually disabled inside managed
85
- sandboxes like cowork — treat this as an option, not a guarantee.)
86
- 4. **None of the above works →** STOP and tell the user plainly, e.g.: *"Video rendering needs
87
- ffmpeg + a Playwright Chromium (or Docker) on the machine running this agent. This environment
88
- doesn't have them and I can't install them here. Options: (a) enable/allow Docker so I can use
89
- the goose-video-render image, (b) install ffmpeg + `npx playwright install chromium`, or
90
- (c) run this skill locally in your own Claude Code where the toolchain is available."* Do not
339
+ in), mounting the project working directory. (Nested Docker is usually disabled inside
340
+ managed sandboxes — treat this as an option, not a guarantee.)
341
+ 5. **None of the above works →** STOP and tell the user plainly, e.g.: *"Video rendering needs
342
+ ffmpeg (and, for this format, a Playwright Chromium) on the machine running this agent. This
343
+ environment doesn't have them and I can't install them here. Options: (a) enable Docker so I
344
+ can use the goose-video-render image, (b) install ffmpeg + `npx playwright install chromium`,
345
+ or (c) run this skill in your own Claude Code where the toolchain is available."* Do not
91
346
  half-render or fake a result. Static image ads (the `goose-ads` skill) do NOT need any of this
92
347
  and work anywhere — offer that as the fallback if they just want an ad now.
93
348
 
94
349
  ## Identity, token, credits
95
350
 
96
- - Read `~/.gooseworks/credentials.json` → `api_key` (your agent token), `api_base`, `agent_id`.
97
- Never print the token.
98
- - **CRITICAL — target the org-default Ads agent on EVERY file op.** The app serves project files
99
- (the render-file route) from the org's DEFAULT agent, but MCP file writes default to your
100
- token's pinned agent — which can be a DIFFERENT agent, so a render written with the default
101
- scope is **invisible in the app**. First resolve the Ads agent: `list_accessible_scopes` → the
102
- scope with `is_org_default: true` (the ORG default — NOT the `is_default` / `default_agent_id`
103
- fields, which are the *user's* default agent and are often a DIFFERENT agent). Its `agent_id` is
104
- `ADS_AGENT` (name "Ads agent", slug `org-default`; usually also the `agent_id` in
105
- credentials.json). Then pass `target: { type: "agent", agent_id: ADS_AGENT }` on EVERY
106
- `get_upload_url` / `get_download_url` / `write_file` / `list_directory` / `read_file` — NEVER
107
- omit `target`.
108
- - **CRITICAL — publish under the PROJECT FOLDER, not the workspace root (the #1 "video renders but
109
- is invisible" bug).** `get_upload_url` stores at `<ADS_AGENT>/files/<path>` verbatim, but the
110
- render-file route reads from
111
- `<ADS_AGENT>/files/agent-config/brands/<brand_slug>/projects/<project_id>/<path>`
112
- (see backend `resolveProjectFileKey`). So EVERY publish/preview `path` MUST be prefixed with
113
- `agent-config/brands/<brand_slug>/projects/<project_id>/` — e.g. upload to
114
- `agent-config/brands/<brand_slug>/projects/<project_id>/working/final.mp4`, NEVER bare
115
- `working/final.mp4`. A bare path 404s in the app even though the render row AND a bare-path
116
- `get_download_url` both "succeed" (they resolve the wrong key). The render `output_url` still
117
- stays the project-relative `...render-file?path=working/final.mp4` — the route re-prepends the
118
- prefix itself. Always verify with `get_download_url` on the FULL `agent-config/...` path (must
119
- be non-empty; curl it for HTTP 200) BEFORE marking the render complete.
351
+ - **Sandbox:** the token is `GW_MEDIA_PROXY_TOKEN` (already scoped to this workspace's agent and
352
+ org); the API base is `GW_API_BASE`. Never print either.
353
+ - **Local:** read `~/.gooseworks/credentials.json` → `api_key` (your agent token), `api_base`,
354
+ `agent_id`. Never print the token.
355
+ - **Uploads go through `media_upload` with `scope: "video_project"`** — pass `path` = the
356
+ project-relative path (`working/final.mp4`, `working/review/end-card.png`). The server stores it
357
+ in the project folder of the org-default Ads agent (where the app's render-file route reads) and
358
+ returns `upload.url` (presigned PUT), `upload.required_headers` and
359
+ `upload.render_file_url`. PUT the bytes with exactly those headers, check the PUT returned
360
+ 2xx, then call `media_confirm { brand_id, media_id: media.id }` and require success before
361
+ using the file in ingredients or completing a render. This applies to project-path and
362
+ path-less file uploads. Confirmation verifies the stored file; Goose performs this tool step
363
+ without asking the user for another approval. On failure, report or repair the upload before
364
+ continuing. Never hand-build storage paths or agent prefixes; a bare workspace upload is
365
+ invisible in the app.
120
366
  - Media generation (FAL / ElevenLabs) through the GooseWorks proxies is the **REAL spend** — billed
121
- to the agent per call as you generate (Step 4). `submit_render { kind: "full" }` additionally
122
- debits **1 nominal ad credit when the render ROW is opened** (a bookkeeping fee, NOT the render's
123
- true cost) — so open it only once you actually have a rendered master (Step 4.1/4.2), and never
124
- re-submit on a guess (that double-bills). The final-video QC gate (Step 4.3) then sits between
125
- that master and PINNING it. Call `get_ad_credits` first; the user can check `gooseworks credits`.
367
+ per call as you generate (Step 4). The render row (`video_render_run kind: "full"`) charges the flat
368
+ **video base fee once, when a full render is reported `complete`**. Open one row immediately
369
+ after recorded approval, BEFORE paid production (Step 4.1), and reuse that render_id for progress
370
+ and completion. Never open a second row on a guess (a second completed row bills again). The final-video QC gate (Step 4.3) then sits between
371
+ that master and PINNING it. Call `account_whoami` first to see the credit balance.
372
+
373
+ ## Save as you go — and resume (never pay twice for a piece)
374
+
375
+ A sandbox can die mid-run (timeout, restart, a new session picks the project up). Anything that
376
+ lives only in `/tmp` is then gone, and regenerating it pays again. So: **save every piece to the
377
+ project the moment it passes its QC, and start every run by loading what is already saved.**
378
+ Working files stay in `/tmp/gooseworks-video/<project_id>/` (never the s3fs workspace mount);
379
+ the project is the durable copy.
380
+
381
+ **Ingredient keys.** Give every planned piece a stable key before you generate it, the same on
382
+ every run: `vo/scene-03`, `vo/sample-her`, `still/her-base`, `still/scene-05`,
383
+ `clip/scene-05` (a lipsync / video clip), `music/bed`, `endcard`, `captions`, `final`,
384
+ `final-thumb`. Upload path = `working/<role>/<file>` (`working/vo/scene-03.mp3`,
385
+ `working/clip/scene-05.mp4`); the review set keeps its `working/review/<name>` paths.
386
+
387
+ **Input digest.** Name the exact inputs of each generation with `input_digest` from
388
+ `media_proxy` (in every media capability's `scripts/` folder):
389
+
390
+ ```python
391
+ from media_proxy import input_digest
392
+ digest = input_digest(model_path, args) # the model + the EXACT payload you send
393
+ ```
394
+
395
+ Hash only what decides the output (prompt, voice_id, model_id, seed, duration, aspect…). An input
396
+ that is a presigned or proxy URL changes every run, so swap it for that input's own identity
397
+ before hashing, e.g. `{**args, "image_url": {"ingredient": "still/her-base", "digest": her_digest}}`
398
+ — then a changed still correctly invalidates every clip made from it. For a piece you build
399
+ locally (ffmpeg stitch, PIL end card, captions) use `input_digest("local/<step>", {params,
400
+ inputs: {key: digest, …}})`.
401
+
402
+ **1. At the START of every run (first run, resume, new sandbox), load what exists — one call:**
403
+ `media_list { brand_id, scope: "video_project", scope_id: project_id, ingredient_key_prefix: "",
404
+ limit: 100 }`. It returns ONE compact row per `ingredient_key` (the newest):
405
+ `{ id, ingredient_key, input_digest, kind, status, mime, bytes, url, path, created_at }`. Every
406
+ status except archived is included. Project-path uploads remain `pending` until
407
+ `media_confirm` succeeds. Confirm a pending project-path upload before reusing it; if
408
+ confirmation fails, repair the upload before treating it as a verified save.
409
+ Page with `cursor` if `next_cursor` is set (keep the first row you see per key — it is the newest). Also read `script_drafts.ingredients` from
410
+ `video_project_read`: it records which pieces were already approved in the review.
411
+
412
+ **2. For each planned piece:** compute its digest from the args you WOULD send now. If a saved row
413
+ has the same `ingredient_key` AND the same `input_digest`, **download it instead of
414
+ generating**:
415
+
416
+ ```bash
417
+ curl -fsSL "$URL" -o /tmp/gooseworks-video/<project_id>/<path> # URL = that row's `url`
418
+ ```
419
+
420
+ That `url` is a short-lived (~15 min) presigned S3 GET the server signs for you, so it needs no
421
+ auth header — download right after listing (list again if it expired). **Never fetch the
422
+ `/api/ads/projects/<id>/render-file?path=…` route from the sandbox:** it needs the app's
423
+ browser session and answers 401 to a token. Check the file is non-empty and plays (ffprobe for
424
+ audio/video, open the image); if the download fails or the file is broken, regenerate the piece.
425
+ Only generate what is missing or whose digest changed — a changed digest means the inputs changed,
426
+ so the old file is stale.
427
+
428
+ **Pass the digest to the proxy too:** `fal_generate(..., input_digest=digest)` (and
429
+ `fal_generate_video` / `fal_whisper`). A piece that was generated but never saved (the sandbox
430
+ died between the fal result and the upload) is then handed back by the proxy instead of paid for
431
+ again, even though its input URLs changed. Only pass `new_take=True` when the user wants a
432
+ different take of the same inputs.
433
+
434
+ **3. After EACH piece is generated AND passes its own QC, upload it right away** — don't batch
435
+ the uploads to the end:
436
+ `media_upload { brand_id, scope: "video_project", scope_id: project_id, kind, path:
437
+ "working/<role>/<file>", ingredient_key, input_digest, source: { type: "file", filename,
438
+ content_type } }` → PUT the bytes to `upload.url` with `upload.required_headers` →
439
+ `media_confirm { brand_id, media_id: media.id }`. Require a successful confirmation.
440
+ Kind: `audio` (VO), `music`, `image` (a still),
441
+ `video` (a clip), `endcard`, `document` (captions / a JSON sidecar), `render` (the master),
442
+ `thumbnail`. Re-uploading the same key is fine — the newest wins. A piece that FAILED QC is never
443
+ uploaded under its key. **Save a piece's sidecars with it** under `<key>.<name>` — e.g. the VO's
444
+ char-level timestamps as `vo/scene-03.timestamps` (`kind: "document"`, same digest). Captions are
445
+ built from them; without them a resumed run has to fall back to Whisper timings, which mis-case
446
+ brand names.
447
+
448
+ **4. Keep the approved review unchanged during production.** Record each confirmed piece's
449
+ `media_id`, `path`, `ingredient_key` and `input_digest` locally; the confirmed media rows
450
+ and render progress are the durable resume record. Before approval, mirror the draft ingredients
451
+ as part of Step 3. After approval, do NOT write `patch.script` or `script_drafts` during any
452
+ paid production, QC or repair step, or while provider work is pending. A review-set write clears
453
+ approval and can stop the next paid step, including a batch concept. Save the final descriptive
454
+ review once all paid work is finished and settled, as Step 4.5 requires.
455
+
456
+ Any material creative change or ANY change the user asked for in this chat must stop production:
457
+ save the changed complete plan and full credit total, then obtain fresh approval before continuing.
458
+ Never reuse the earlier yes for a changed plan. A repair that restores the approved choices can
459
+ continue within the existing allowance and Stop guards without rewriting the approved review.
460
+
461
+ The `final` master and `final-thumb` poster (Step 4.4) carry `ingredient_key` too, so a
462
+ resumed run that finds a passing `final` with the same digest only needs to publish.
463
+
464
+ ## Finished video, interrupted saving — resume the same version
465
+
466
+ If the final already passed QC and the customer says **"finish saving this video"**, start here.
467
+ Do not restart the recipe, choose another format, open another render, generate a take, or run a
468
+ paid transcript check again. Saving uses the **same render_id**. The ordinary first-completion
469
+ video fee can still apply; its existing same-render idempotency prevents a duplicate fee. Never
470
+ promise that all saving is free.
471
+
472
+ **Before the first final upload**, save the final review set and production manifest from Step
473
+ 4.5/4.6 (including any QC repairs) only after all paid work is finished and settled. Preserve the
474
+ approved creative choices; a material change requires the changed-plan approval flow first.
475
+ After that final save, start no new provider or render work: prepare the checkpoint and finish
476
+ the same opened render using its existing finishing allowance and guards. A released allowance
477
+ or stopped/capped render requires normal recovery; never reopen or bypass approval.
478
+ Write a durable local checkpoint outside the fetched-scripts cache. Keep the actual
479
+ final, JPEG poster, structured passing quality report, and review evidence files alongside it in
480
+ a retained local working folder. Record their SHA-256 **at the time those exact bytes pass QC**;
481
+ never attach an old verdict to a newly hashed replacement. A sandbox's local disk can disappear:
482
+ this checkpoint recovers connection interruptions, not lost storage. Save ingredients remotely
483
+ as above and tell the customer if the checked local output is no longer available.
484
+
485
+ With the current CLI and its normal login to the selected environment, write a manifest like:
486
+
487
+ ```json
488
+ {
489
+ "brand_id": "<owning brand>", "project_id": "<same project>", "render_id": "<already opened render>",
490
+ "input_digest": "<assembly input digest>",
491
+ "final_path": "/absolute/retained/working/final.mp4",
492
+ "poster_path": "/absolute/retained/working/final-thumb.jpg",
493
+ "qc": {
494
+ "final_sha256": "<64 lowercase hex characters recorded during final QC>",
495
+ "poster_sha256": "<64 lowercase hex characters recorded during poster review>",
496
+ "report_path": "/absolute/retained/working/quality-report.json",
497
+ "evidence_paths": ["/absolute/retained/working/review/finished-ad.json"]
498
+ }
499
+ }
500
+ ```
501
+
502
+ Run `gooseworks video-save prepare --manifest <manifest.json> --checkpoint <retained/save-<render_id>.json>`
503
+ before any upload, then `gooseworks video-save resume --checkpoint <same checkpoint>` for both
504
+ normal saving and recovery. The helper uses the saved login and canonical MCP connection; it does
505
+ not copy credentials or use a raw Ads REST fallback. Its atomic private checkpoint binds the
506
+ environment, account, project owner, project/render, final/poster bytes, assembly digest, passing
507
+ quality report, review set, evidence files and stage receipts. Preserve it until delivery. Never
508
+ edit the checkpoint to clear a failed check. Keep checkpoint and manifest files out of commits.
509
+
510
+ The helper reads remote state before writes. It keeps `final` / `final-thumb` ingredient keys
511
+ and writes per-render paths `working/final-<render_id>.mp4` / `working/final-<render_id>-thumb.jpg`
512
+ so saving this version cannot overwrite an older one. It confirms pending uploads, checks remote
513
+ bytes against the QC hashes, and reuses confirmed media. A request with missing stored bytes can
514
+ get a fresh upload URL at that same path. A lost completion reply is unknown until project read
515
+ confirms the same render's output and passing report; then only final selection remains.
516
+
517
+ **No CLI / a host-selected MCP connection:** keep the same protocol with the host's canonical
518
+ tools. Atomically write versioned JSON locally (write a private same-directory temporary file,
519
+ flush/fsync, rename, then fsync the directory) before any upload and between each upload request,
520
+ PUT, confirmation, completion and final selection. Persist only public environment identity,
521
+ account/owner/project/render IDs, file paths/sizes/hashes, input digest, exact quality report and
522
+ evidence fingerprints, saved-review digest, media IDs and stage states; **no tokens, session IDs,
523
+ signed URLs or auth headers**. On reconnect call `account_whoami`,
524
+ `video_project_read { brand_id, project_id, include: ["renders"] }` and
525
+ `media_list { brand_id, scope: "video_project", scope_id: project_id, ingredient_key, input_digest }`
526
+ on the original connection. Compare identities, local/evidence hashes and saved review; verify
527
+ confirmed remote bytes too. Treat a lost reply as unknown and read back before retrying. Use only
528
+ the missing `media_upload` → PUT → `media_confirm`, same-render `video_render_run { render: … }`
529
+ callback and `video_project_upsert` with only `patch.final_render_id` and
530
+ `patch.final_selection_guard: { expected_final_render_id, expected_review_digest }`; never a
531
+ render-open call. The expected final is the last read's pin, including explicit `null`; the
532
+ review digest is SHA-256 of recursively sorted-key JSON
533
+ `{script: project.script ?? null, script_drafts: project.script_drafts ?? null}` saved at checkpoint
534
+ creation. First confirm the selected server advertises this guard in `tools/list`. If absent,
535
+ stop and request the normal server update/reconnect; an unguarded pin is unsafe. A
536
+ `final_selection_conflict` means the choice or review changed: keep the checkpoint and explain
537
+ that saving stopped without overwriting it. Retain the
538
+ strict Step 4.3/4.4 report and Step 4.5 review-set requirements.
539
+
540
+ If authorization expired, reconnect/sign in through the normal host/CLI flow on the original
541
+ connection, then resume. Missing tools are a reconnect requirement, not permission to switch
542
+ environments. Missing/changed files, stale/missing QC, changed account/owner/review, another final
543
+ selection, or a stopped/capped/failed/blocked render require diagnosis; do not reopen it or
544
+ regenerate automatically. If saving stops, say: **"Your video is finished locally, but saving to
545
+ Goose was interrupted."** Link the actual local file and preserve its checkpoint. Claim saved
546
+ delivery only after a fresh project read verifies completion and selection of that exact render.
126
547
 
127
548
  ## Step 0 — project id, or video BATCH id? (fan out before anything else)
128
549
 
129
- The handoff you were pasted is EITHER a single `project <id>` OR a `video batch <id>`. A batch is
550
+ The handoff is EITHER a single `project <id>` OR a `video batch <id>`. A batch is
130
551
  the app's "N concepts" flow: one composer submission fans out into **N independent concept projects**
131
552
  (the user picked a concept count, default 3), and the app expects EACH to be rendered. **Handle both:**
132
553
 
133
554
  - **`project <id>`** → you have one project. Treat it as a batch of one and continue to Step 1.
134
- - **`video batch <id>`** → call `get_ad_video_batch { video_batch_id }`. It returns every child
555
+ - **`video batch <id>`** → call `video_project_read { brand_id, batch_id }`. It returns every child
135
556
  concept under `projects[]` — each is a normal project with its own `id`, `variant_index`
136
557
  (Concept 1..N), and its own `creative_brief` (the per-concept angle/hook/offer/message). **You
137
558
  MUST process every concept, not just the first** — dropping concepts 2..N is the #1 batch bug.
138
559
 
139
- **Loop shape (one agent, sequential, ONE approval for the whole batch):**
140
- 1. Run **Step 1 + Step 1.5 + Step 2 + Step 3-assemble** for EACH concept project (each has its own
141
- `project_id`, brief, and `working/` folder — never cross-write between concepts).
142
- 2. Mirror EVERY concept's review set (Step 3's `update_ad_project_script` per project), then stop
143
- for **ONE** approval that covers all concepts — show the per-concept credit estimate and the
144
- batch total. Set the batch to `review` (`update_ad_video_batch { status: "review" }`).
145
- 3. On approval, set the batch to `rendering` and run **Step 4 (the expensive render)** for each
146
- concept **sequentially** (finish Concept 1's master before starting Concept 2 — one machine can't
147
- render them in parallel). Deliver each (Step 5). When all concepts are pinned, set the batch to
148
- `complete`.
560
+ **Loop shape (ONE approval for the batch, isolated work per concept):**
561
+ 1. Run **Step 1 + Step 1.5 + Step 2 + Step 2.5 + Step 3-assemble** for EACH concept project (each
562
+ has its own `project_id`, brief, `GW_PROJECT_ID` and `working/` folder — never cross-write
563
+ between concepts). The brand read (Step 1 item 3) and `brand-rules.json` (Step 1.7) are per
564
+ BRAND: do them once for the batch and copy the file into each concept's `working/`. The read is
565
+ ~90K characters. Step 2.5's angle bank is shared per brand AND product: load or build it once, and
566
+ give every concept whose angle is `auto` a DIFFERENT angle from that list, so the batch is N
567
+ different ads, not one ad N times.
568
+ 2. Mirror EVERY concept's review set (Step 3's `video_project_upsert patch.script` per project),
569
+ then stop for **ONE** approval in this chat that covers all concepts. Save each render_estimate.total_credits
570
+ (previews + render + the 200 base fee) and the batch total. Widget: one line; text: card.text_summary. Set the batch to `review` (`video_project_upsert
571
+ { brand_id, batch_id, patch: { batch: { status: "review" } } }`).
572
+ 3. On an explicit yes, record it ONCE for the whole batch: `video_project_upsert { brand_id, batch_id,
573
+ patch: { approve: { user_quote: "<their exact words>", total_credits: <the saved total> } } }`. Check its `not_ready` list is
574
+ empty (a concept listed there has no saved review set: save it, show it, ask again). If they
575
+ approve only some concepts ("1 and 3 are good, redo 2"), record each approved one with its
576
+ `project_id` instead, and redo the rest. Then set the batch to `rendering` and run **Step 4 (the expensive render)** for each
577
+ concept with up to 8 isolated workers when the machine can sustain them. Retry
578
+ concurrency_limit after retry_after_seconds; reduce concurrency on a limited machine. Deliver each (Step 5). When every concept is pinned, set the batch to
579
+ `complete`. A concept the Step 4.3 gate leaves `blocked` cannot be pinned (a batch concept
580
+ needs `passed`): finish the others, set the batch to `blocked`, and tell the user which
581
+ concepts passed and which are blocked, with each one's failing checks.
149
582
 
150
583
  If a single concept fails, keep going with the rest, mark that concept blocked, and report which
151
584
  ones shipped — never abort the whole batch on one bad concept. Everything below (Steps 1–5) is
@@ -153,11 +586,18 @@ written per-project; a batch just runs it N times with the shared approval gate
153
586
 
154
587
  ## Step 1 — resolve the project, source, brand
155
588
 
156
- 1. `get_ad_project { project_id }` → keep `brand_id`, `source_sample_id`, `name`, `status`, the
157
- **top-level** `app_url` + `brand_url` (returned alongside `project`, NOT inside it — the links
158
- you hand the user for the in-app review in Step 3 and delivery in Step 5), AND the user's
159
- **`creative_brief`**, project **`assets`**, `character_id`, `default_voice_id` — these are the
160
- authoritative inputs the user chose in the composer (see Step 1.5). Do NOT discard them.
589
+ 1. `video_project_read { brand_id, project_id }` → keep `brand_id`, `source_sample_id`, `name`,
590
+ `status`, the **top-level** `app_url` + `brand_url` (the links you hand the user for the in-app
591
+ review in Step 3 and delivery in Step 5), AND the user's **`creative_brief`**, project
592
+ **`assets`**, `character_id`, `default_voice_id` — these are the authoritative inputs the user
593
+ chose in the composer (see Step 1.5). Do NOT discard them. Then `export GW_PROJECT_ID=<project_id>`.
594
+ Keep its saved `campaign_id` and `campaign_concept_id` too. If the customer explicitly
595
+ wants to attach this existing video to a known campaign/concept, verify the IDs with the
596
+ campaign read and use `video_project_upsert { brand_id, project_id, patch: {
597
+ campaign_association: { campaign_id, campaign_concept_id? } } }` as a separate, sole-field
598
+ patch. Read back the same project and confirm the saved IDs. Linking never needs a new
599
+ project, render, generation call or approval. A conflicting saved link stays intact; explain
600
+ it instead of silently moving the video. Leave unlinked legacy videos alone unless asked.
161
601
 
162
602
  ### Step 1.5 — the project brief is AUTHORITATIVE (honor it; don't re-ask)
163
603
 
@@ -176,49 +616,368 @@ for a field the brief leaves empty. Map the fields you WILL honor:
176
616
  assets.
177
617
  - `character_id` → the avatar/creator to use. `default_voice_id` → the voice for any VO (put its
178
618
  NAME in the review `subtitle`). Use these instead of picking your own.
179
- - `creative_brief.ratio` / `.durationSeconds` → target aspect ratio + length. Honor when the
180
- format's render pipeline supports it; if the format physically can't (e.g. a fixed phone-mockup
181
- aspect), keep the format's native value and note the constraint in the review rather than silently
182
- ignoring the request.
619
+ - `creative_brief.durationSeconds` → target length; honor it when the format allows.
620
+ `creative_brief.ratio` → video ads are ALWAYS 9:16 (1080×1920). If the brief asks for another
621
+ ratio, make 9:16 anyway and say so in the review; never export another size (a recipe's
622
+ "also 1:1" option included).
183
623
  - `polish_policy` (`standard` | `extra`) → `extra` means spend the extra pass on QC/polish.
184
- 2. `get_ad_template { template_id: source_sample_id }` → the source video: `media_url`,
185
- `recipe`, `format` (e.g. "imessage"), `extracted_script`, `how_to`, `remix_spec`.
186
- 3. Brand gate: `get_brand_kit { brand_id }`. If `researchStatus` is `complete`, REUSE it —
187
- never re-research. If not, run brand research first (`gooseworks fetch brand-research`,
188
- follow it, then `finalize_brand_research { brand_id }`) before continuing.
624
+
625
+ 2. `catalog_fetch { type: "template", slug: <source_sample_id> }` → the source video: `media_url`,
626
+ `recipe`, `format` (e.g. "podcast-skit", "imessage"), `extracted_script`, `how_to`, `remix_spec`.
627
+ 3. Brand gate: `brand_read { brand_id, sections: ["summary", "kit", "products", "learnings"] }`
628
+ (older clients: `brand_get_context` with the same sections). Ask for all four: the default
629
+ leaves out the kit and the brand's saved rules, and a video made without them is off-brand.
630
+ If the kit's `researchStatus` (or the brand's `research_status`) is `complete`, REUSE it —
631
+ never re-research. If not, run brand research first (`catalog_fetch { type: "skill", slug:
632
+ "brand-research" }`) and follow its stored-pack workflow. Only when that verified pack is
633
+ saved in the supported research workspace, finalize with
634
+ `brand_update { brand_id, patch: { finalize_research: true } }`, then read the brand back.
635
+ Never send raw research JSON through `kit_patch`: the public tool accepts only the existing
636
+ `video_lab` asset slot there. If there is no verified stored pack, submit researched facts
637
+ through typed `patch.knowledge` / `patch.kit` as pending agent proposals; do not pretend
638
+ research is finalized or its proposals are approved. Then do Step 1.7 with verified facts.
639
+
640
+ ### Step 1.6 — a remix of a FINISHED video (the project read has a `remix` block)
641
+
642
+ A project made from **Community videos** remakes another customer's finished video for THIS brand.
643
+ Its `video_project_read` returns a top-level `remix` block
644
+ (`{ remix_of_project_id, instruction, direction }`), and `reference_video_url` is that finished video.
645
+
646
+ - **Watch the reference video first** (download `reference_video_url`, pull frames + the transcript).
647
+ It is the target: match its structure, beat order, pacing, framing, look, voice and tone.
648
+ - **`remix.direction` is its approved review set** (scenes and lines, set/look notes, take prompts,
649
+ captions, music, voice). Start your review set from it instead of the template's defaults; it
650
+ already carries every change that customer made to the template.
651
+ - **`remix.direction.implementation`, when present, is HOW it was made**: the pipeline and the model
652
+ each step used, the style and negative prompts, the character and per-scene still/motion prompts
653
+ with their guards, voice and music settings, the mix, and `fixes` (what went wrong and how it was
654
+ fixed). Reuse the same models, style/negative prompts and guards, rewrite the prompts' subjects for
655
+ this brand, and apply every `fix` up front so you don't repeat the same mistake.
656
+ - **Rewrite everything for THIS brand.** "[source brand]", "[source product]", "[link]", "[email]"
657
+ and "[code]" mark the other customer's details: never write them, and never reuse their claims,
658
+ numbers, URLs, offers or CTA. Every product, claim, name, image and CTA comes from this brand's
659
+ kit, products and media. Their footage (screen recordings, product shots) and their creator face
660
+ are NOT carried over: use this brand's own assets and make a new creator from the description.
661
+ - Precedence: this project's own `creative_brief` and assets (Step 1.5) > `remix.direction` >
662
+ the template recipe's defaults.
663
+ - In the Step 3 review, say it is a remix of that video and list what you kept vs. changed.
664
+
665
+ ### Step 1.7 — the brand rules file and the brand assets (every run, before any writing)
666
+
667
+ Write `working/brand-rules.json` from the Step 1 brand read. Every later step reads THIS file,
668
+ not your memory of the chat:
669
+
670
+ ```json
671
+ {
672
+ "name": "Acme",
673
+ "pronunciations": [{ "term": "Acme", "say_as": "ak-mee", "learning_id": "…" }],
674
+ "must_say": [{ "text": "…", "learning_id": "…" }],
675
+ "never_say": [{ "text": "Never claim it cures insomnia", "learning_id": "…" }],
676
+ "products": [{ "id": "…", "name": "…", "facts": ["size, flavour, price, ingredients as stored"], "images": ["…"] }],
677
+ "logo": { "url": "…", "confidence": "<kit.logoConfidence>" },
678
+ "fonts": ["…"],
679
+ "palette": ["#…"]
680
+ }
681
+ ```
682
+
683
+ - **Video taste is direction, not dialogue.** Before mapping brand rules, extract entries
684
+ prefixed `Video preference:` from both `learnings` and `kit.instructions` into the verified
685
+ taste brief, including accepted proposals. They govern pacing, voices, captions, visuals and
686
+ format choice; do not copy them into `must_say` / `never_say` or read them aloud. Carry the
687
+ brief into the choices, scene planning and review.
688
+ - **Sources.** `learnings` are the brand's saved rules (the user's past corrections among them):
689
+ `must` / `do` → `must_say`, `dont` → `never_say`, and a `must` whose text reads
690
+ `Pronounce "<term>" as "<say_as>"` (straight or curly quotes) → `pronunciations`. Add `kit.instructions` (free-text
691
+ standing rules) only when they require actual spoken wording or prohibit a claim. Production
692
+ directions stay in the brief. A required spoken line or prohibited claim remains its own
693
+ ordinary `must` / `dont` rule.
694
+ - **Which product.** The one the brief names (`creative_brief.productName`); with none, the row
695
+ whose name matches the product the user asked for, or the brand itself for a one-product
696
+ brand. Product lists often hold other brands' items or old ads saved as products: if more than
697
+ one row could be it, ask in the choices round. Never mix facts across rows.
698
+ - **Product facts** come from that row (name, description, variant, price) and, when the row is
699
+ empty, from the kit (`valueProps`, `description`, `tagline`): nothing else. Write them to
700
+ `products[].facts`; the script may only state what is there.
701
+ - **Logo.** Download the kit's logo FILE (`kit.logoUrl`, else `kit.logos[0]`) to `working/brand/`,
702
+ keeping its real extension (an SVG stays `.svg`; rasterise it to a 1024px-wide PNG with
703
+ `rsvg-convert` or `cairosvg` when a renderer needs pixels). It is used as-is on every scene and
704
+ end card that shows a logo: **never generate, redraw, re-letter or restyle a logo with an image
705
+ model.** If the kit's `logoConfidence` says favicon-grade, or the file's long side is under
706
+ 256 px (or it is under 40,000 px²), it is a site favicon, not a logo: do not upscale it. Ask the user for a real logo (or offer the brand name
707
+ set as text in the brand font) in the SAME question round as the recipe's `choices`.
708
+ - **Font.** `kit.typography.heading` when its `source` is `user` (the user chose it), else
709
+ `kit.fonts.heading`. Download the font file (the kit's own, or the same family from Google
710
+ Fonts) to `working/brand/` and use it for every on-screen line. With no match, use the closest
711
+ free font and say so in the review.
712
+ - **No wordmark file.** When a recipe wants a wordmark SVG and the kit has only a logo image, set
713
+ the brand name as text in the brand font beside the logo file. Never generate one.
714
+ - Record in `brand-rules.json` which logo the video will actually composite (`logo.file`), or
715
+ `"logo": { "mode": "text" }` when it will show only the brand name set in the brand font.
716
+ - **Product images.** Download this product's own images to `working/brand/`. Use only images of
717
+ THIS product: never a catalogue image of another product, a mascot, a lifestyle photo of a
718
+ person, or a stand-in. If the product has no usable image, ask in the choices round.
719
+
720
+ ### Brand corrections stick — save them to the brand the moment they are made
721
+
722
+ When the user corrects something about the BRAND in chat — how a name is said, a claim that may
723
+ not be made, a product fact, a visual rule ("never use red", "the logo goes top-left") — save it
724
+ in the SAME turn, before anything else:
725
+
726
+ `brand_update { brand_id, knowledge_intent: "user_correction", user_statement: <the user's exact correction>, patch: { facts: [{ kind, text }] } }`
727
+
728
+ | Correction | `kind` | `text` |
729
+ |---|---|---|
730
+ | Pronunciation | `must` | `Pronounce "Acme" as "ak-mee"` (exactly this form) |
731
+ | A claim or word to avoid | `dont` | `Never say or imply: <the claim>` |
732
+ | Something that must be said | `must` | `<the rule>` |
733
+ | A product fact | `must` | `<product name>: <the fact>` |
734
+ | A visual rule | `do` / `dont` | `<the rule>` |
735
+
736
+ - If it changes an EXISTING rule (a new pronunciation for the same term), update that rule by id
737
+ (`facts: [{ id: <learning_id>, text }]`) instead of adding a second one.
738
+ - Use the correction intent and user's statement when supported, as described below. Read
739
+ `brand_read` learnings back and verify the rule and source before claiming it was saved.
740
+ - Then tell the user in one line: "Saved to your brand for future videos." Update
741
+ `working/brand-rules.json` and apply the rule to THIS video too.
742
+ - A one-off note about this video ("make it shorter", "use the blue background here") is NOT a
743
+ brand rule: don't save it.
744
+
745
+ ## Save durable brand answers, then verify them
746
+
747
+ Read the selected brand with `brand_read { brand_id, sections: ["summary", "kit", "products", "learnings", "onboarding"] }`
748
+ (fallback: `brand_get_context` with the same sections). Keep founder answers, user corrections,
749
+ research and your own hypotheses distinct. Reuse matching saved answers; ask only about gaps.
750
+
751
+ When the user asks to remember a rule, answers a brand interview, or explicitly corrects a
752
+ standing fact, save that answer in the same turn. The capture request authorizes those answers;
753
+ do not ask for approval again. A direction for this one video stays in its brief. If the scope
754
+ is genuinely ambiguous, ask whether it applies to future videos before saving a standing rule.
755
+
756
+ Use the **live registered schema**. Where supported, call `brand_update` with
757
+ `knowledge_intent: "user_correction"` and `user_statement` containing the user's exact,
758
+ verbatim answer, not your paraphrase or researched text.
759
+ For an inference or suggested improvement, use `knowledge_intent: "agent_proposal"`. Show the
760
+ before/after change from your prior read and proposed value; retain the returned proposal IDs
761
+ and say the user must accept it in the app. Link only a review surface actually returned by a
762
+ tool; the compact `knowledge_updates` response does not itself contain a diff or URL.
763
+ A pending proposal is not a saved fact. Never call an unavailable
764
+ tool or silently relabel research or your inference as something the user said.
765
+
766
+ The safe structured shape is `patch: { knowledge: { positioning?, audience?, voice?,
767
+ instructions?, brandType?, tagline?, valueProps? } }`, using only fields present in the live
768
+ schema. Inferred rules/taste go in an `instructions` proposal with a rationale, never in
769
+ `patch.facts`. Prefix every video-only preference in that proposed text with "Video preference:"
770
+ so it remains production direction after acceptance. Preserve unrelated instructions when
771
+ proposing a merged replacement.
772
+
773
+ | User answer | Canonical write |
774
+ | --- | --- |
775
+ | Primary audience, positioning or voice correction | `patch.knowledge: { audience/positioning/voice: <answer> }` (one actual key). During onboarding, `brand_onboarding { action: "review_research", review: { action: "correct", field, value } }` writes these existing corrections with provenance. |
776
+ | Founder story, customer pains, objections, buying trigger or useful audience detail without a structured field | `patch.facts: [{ kind: "insight", text }]`; retain attribution such as "Founder reports: …" rather than turn a belief into a verified result. |
777
+ | Required wording or pronunciation | `patch.facts: [{ kind: "must", text }]`; pronunciation is exactly `Pronounce "<term>" as "<say_as>"`. |
778
+ | Forbidden claim, word or visual | `patch.facts: [{ kind: "dont", text }]`. |
779
+ | Durable visual, voice or pacing preference | `patch.facts: [{ kind: "do", text }]` for a preference; `dont` for an avoidance; `template_hint` for a preferred format. Prefix video-only preferences with "Video preference:". |
780
+
781
+ Facts are existing `ad_brand_learning` rows with user provenance; they are not a second profile.
782
+ Update a matching rule by its returned `id` instead of adding duplicates. Preserve unrelated
783
+ rules and the user's exact meaning. Only use the legacy facts shape for explicitly user-authored
784
+ answers when the live schema lacks intent fields; agent suggestions still need a proposal path.
785
+
786
+ **Claims and plans have separate gates.** A founder assertion or proof point is not an approved,
787
+ evidence-backed claim or consent to quote a customer. Use the existing evidence/claims and
788
+ operating-plan tools only if registered, following their proposal, evidence and confirmation
789
+ requirements. Never encode a spend cap, approver or emergency stop as a learning. If that write
790
+ path is missing, report the specific unsaved item and keep it pending for the supported review
791
+ surface; do not claim it was saved or create a parallel local profile.
792
+
793
+ After every write, **read back before saying saved**: use `brand_read` with `kit`, `learnings`
794
+ or `onboarding` as appropriate, or `brand_onboarding { action: "status", brand_id }` after an
795
+ onboarding answer. Verify the intended field/rule, its source and the absence of a conflicting
796
+ duplicate. A generic success response, pending proposal, ignored key or truncated result is not
797
+ proof. Report partial saves honestly. Carry the verified rules into the current task and the
798
+ routed skill; claims still pass their own safety gate.
799
+
800
+ ## Video taste — reuse examples and preferences
801
+
802
+ When asked to capture video taste, or when the user volunteers a durable video preference,
803
+ first read the saved learnings and `media_list { brand_id, scope: "brand", scope_id: brand_id,
804
+ tags: ["video-taste"], limit: 100 }`. Follow `next_cursor` before deciding an example is absent.
805
+ Do not force a taste interview before an unrelated task or ask again for an existing preference.
806
+
807
+ Save what the user has already supplied first. Then ask only the missing useful question, for
808
+ example: "What do you like about this video—its pace, voice, captions, or look?" An inaccessible
809
+ link can still be saved as a link with the user's explanation; do not pretend you watched it.
810
+
811
+ - **Direct clip or video file:** register with `media_upload { brand_id, scope: "brand",
812
+ scope_id: brand_id, kind: "video", source: { type: "url", url }, tags: ["video-taste", "reference-only"],
813
+ metadata: { purpose: "video_taste", source_url: url, provenance: "user", captured_at: <ISO timestamp>,
814
+ preference: <the user's explanation> } }`. For a file use the live file/bytes upload flow and
815
+ `media_confirm` after a presigned upload. Registration of a URL does not copy or inspect it.
816
+ - **Instagram/post/page link:** the same registration with `kind: "document"`; it is a link
817
+ bookmark, not downloadable footage or an indexed transcript. Do not fabricate a direct clip URL.
818
+ - **Preferences:** save the user's reasons, likes and dislikes through the facts mapping above.
819
+ Read and preserve existing facts before updating one. Do not invent `video_preferences` or
820
+ new `video_lab` keys; the live kit patch accepts only its documented asset fields.
821
+ - **Deduplicate:** reuse a matching returned media row, then `media_update` its title/tags/metadata
822
+ if needed; preserve existing metadata and tags. Do not create another row for the same example.
823
+ Read back with `media_list` and `brand_read` learnings before claiming it was saved.
824
+ Check the returned row belongs to this brand: URL deduplication may return another brand's
825
+ existing row. Do not relabel that row or claim success unless the current brand's scoped read
826
+ actually returns it. Report an unsaved association if no supported attach path is available.
827
+
828
+ Never put third-party taste examples into kit reference images: `kind: "reference"` at brand
829
+ scope writes there. The tags and metadata above record purpose and provenance; **they do not
830
+ grant or enforce usage rights**. Study the structure, pacing and look only. Never use the example's
831
+ footage, face, product, testimonial or claims in a new ad without independently verified permission.
832
+
833
+ Read video-only entries prefixed `Video preference:` from both saved learnings and
834
+ `kit.instructions`, including accepted proposals. Keep them out of required or forbidden
835
+ dialogue. Build a brief from the verified readback: preferred pace, voice, caption treatment, visual style,
836
+ formats to favour/avoid, reference links and the user's reasons. Say what is still unknown.
837
+ Pass it with the brand rules into the existing video workflow. A one-video request overrides a
838
+ default for that project; it does not silently rewrite the brand's standing preference.
189
839
 
190
840
  ## Step 2 — read the template's recipe (it carries everything; NO hardcoded format map)
191
841
 
192
842
  The ad format is a **template (data) in the ad_sample DB**, not a per-format skill.
193
- `get_ad_template(source_sample_id)` returns the template's `recipe` — a self-contained brief you
843
+ `catalog_fetch { type: "template" }` returns the template's `recipe` — a self-contained brief you
194
844
  read and execute. **Do NOT map `format` to a hardcoded recipe slug** (there is no such table):
195
845
 
196
846
  - `recipe.format` — the format label (e.g. `vignette`), for display only.
197
- - `recipe.atoms` — the **capabilities** this template composes (e.g. `create-video-seedance-2-fal`,
198
- `create-image-gpt-image-fal`, `review-ugc-render`, `watch`). `gooseworks fetch <name>` each — they
199
- live in `skills/ads/capabilities/` and are reused across templates (so they cache).
847
+ - `recipe.atoms` — the **capabilities** this template composes (e.g. `create-vo-elevenlabs`,
848
+ `create-image-gpt-image-fal`, `render-podcast-skit`, `review-ugc-render`, `watch`). Fetch each
849
+ with `catalog_fetch { type: "skill", slug }` (or `gooseworks fetch <name>` when the CLI is
850
+ installed) — they are reused across templates.
200
851
  - `recipe.instructions` — the **playbook** to follow: `instructions.inline` prose, or
201
852
  `instructions.doc_url` (an S3 markdown doc — fetch it).
202
853
  - `recipe.config` — every param (prompts, layout, timings, palette, model choices).
203
854
  - `recipe.inputs` — the brand-asset contract (which product / logo / offer this template needs).
855
+ - `recipe.choices` — the creative calls the USER makes (who is on screen, narrator, tone, setting,
856
+ art style, music). Ask every unanswered one in ONE round before any paid step, with its options plus
857
+ "you pick". Its `reference` is what the demo used: an example, never the default.
204
858
  - `recipe.assets` — reference material as S3 links (reference render, style guide, example frames) —
205
859
  fetch as needed.
206
860
 
207
- Runtime: **read the recipe → `gooseworks fetch` each capability in `recipe.atoms` → follow
861
+ Runtime: **read the recipe → fetch each capability in `recipe.atoms` → follow
208
862
  `recipe.instructions` with `recipe.config` + the brand's bound `inputs`.** The template IS the recipe;
209
863
  there is no `format → recipe-slug` table and no per-format skill to fetch.
210
864
 
211
- Save each fetched capability's scripts + files under `/tmp/gooseworks-scripts/<name>/`. If a capability
212
- is a Node package (a phone-mockup renderer), `npm install` in its folder so its `generate.js` +
213
- Playwright resolve, and point the recorder's `NODE_PATH` at it.
865
+ Save each fetched capability's content, scripts + files under `/tmp/gooseworks-scripts/<name>/`
866
+ (layout in "Running in a GooseWorks sandbox"). If a capability is a Node package (a phone-mockup
867
+ renderer), install its documented dependencies in the folder containing its `package.json`,
868
+ and preserve the recorder's documented `NODE_PATH` — local machines only; in a sandbox that
869
+ format stops (no Chromium).
870
+
871
+ **Selected browser readiness — before ANY paid ingredient:** identify the actual browser script
872
+ from the fetched capability's instructions (including an HTML end-card renderer if used).
873
+ For Node scripts using `require('playwright')` with default `chromium.launch()`, run
874
+ `gooseworks doctor --renderer-script "/absolute/path/to/the/fetched/scripts/record.js"`.
875
+ Substitute the actual script, and keep the same cwd and environment as the render, including
876
+ `NODE_PATH` and `PLAYWRIGHT_BROWSERS_PATH`. It resolves Playwright relative to that script,
877
+ launches and closes Chromium with the default settings and bounded waits, and downloads nothing.
878
+ On failure, stop before spending, show its folder-specific repair and recheck after setup.
879
+ For non-browser formats use `doctor --no-browser` plus their documented runtime checks;
880
+ never combine `--no-browser` with `--renderer-script` or use it to bypass a browser renderer.
881
+
882
+ **No CLI or CLI without these flags:** run an equivalent free probe in a separate Node process: use
883
+ `require('node:module').createRequire(require('node:path').resolve(actualRendererScript))`
884
+ to load `playwright`; keep the render's cwd, environment and default launch settings. Await
885
+ `chromium.launch({ timeout: 15000 })`, then await `browser.close()` (bound close to 3 seconds).
886
+ Bound the whole process to 20 seconds and stop its own process tree on failure or timeout.
887
+ Report the resolved module path/version and error without credentials. Missing module, executable,
888
+ headless runtime or failed launch is a failed check; a cache folder, executablePath alone or
889
+ another project's browser is not a pass. Other browser packages, Python renderers or custom
890
+ launch settings need the same free launch/close check through their documented runtime and
891
+ actual settings. Do not replace their browser/channel/flags to get a pass. Setup is a separate
892
+ action under existing permissions; this check never silently installs or downloads anything.
214
893
 
215
894
  > **Migration note:** older phone-mockup formats (`imessage` / `chatgpt` / `apple-notes`) whose DB
216
895
  > recipe does not yet carry `atoms` / `instructions` still hold the legacy `recipe.thread` payload;
217
896
  > migrate them to this shape (capabilities + instructions in the DB) — do not reintroduce a CLI map.
218
897
 
219
- ## Step 3 — assemble the review set, then get ONE approval in the app (before the expensive render)
898
+ ## Step 2.5 — plan words and visuals with `write-video-ad-script`
899
+
900
+ Every video concept gets creative strategy, including silent formats. Fetch
901
+ **`write-video-ad-script`** through the skill catalogue and follow it before assembling
902
+ review ingredients. It reuses or fetches **`ad-angle-miner`**, binds the researched promise
903
+ to this template's full recipe, writes words and visuals together, and checks product
904
+ claims and production fit. Its independent critic is a quality screen, not a forecast
905
+ of ad performance. The existing Step 3 review and approval remain unchanged.
906
+
907
+ - **Carry the research into the writer.** Pass the brand and exact product, audience,
908
+ objective, offer, CTA, selected template recipe, available assets and the full miner
909
+ bank or its readable workspace pointer. A selected miner idea includes its angle id,
910
+ evidence and proof plan, not only its hook. Reuse the shared video-angle-bank.v1 from
911
+ the brand's video-scripts workspace or this run. Prepare angle-context.json with the
912
+ writer's preparation script with `--brief working/script/creative-brief.json` and use
913
+ its strict rule check before review. Save the sourced brief in the writer's documented
914
+ shape: exact product/variant, buyer situation, supported mechanism, offer/CTA, constraints,
915
+ delivery intent, source references, locked copy, applicable prior decisions and unknowns.
916
+ New custom/template shapes set `requires_creative_brief: true`; both writer and critic
917
+ receive the same angle-context. Carry that brief revision into the scene/tool plan and
918
+ production manifest; missing evidence stays explicit rather than becoming a claim.
919
+ - **Already decided stays decided.** The user's angle, hook, batch concept, recipe choice
920
+ or remix direction is binding. Preserve the selected angle id. Compare executions or
921
+ hooks inside it; do not reopen the angle choice. An incompatible promise needs a
922
+ supported execution or an explicit format change before production.
923
+ - **The recipe owns the production contract.** Its story mechanism, speakers, timing,
924
+ text limits and visual capabilities win. Inspect the actual recipe and available assets;
925
+ a catalogue card alone cannot establish fit. An impossible essential visual blocks
926
+ the proposal until repaired. Do not force a testimonial into every format.
927
+ - **Research only what is missing.** Fetching the miner does not spend or rerun research.
928
+ Reuse current facts and prior evidence. If paid collection is needed, its permission
929
+ rides in the existing choices round. A new product with no reviews can use verified
930
+ facts and a feasible demo; do not require paid research merely to fill a quote quota.
931
+ - **Choose eligible concepts only.** Take the strongest supported concept and validated
932
+ hook into review, with up to two viable alternatives when the direction is open.
933
+ Do not pad three concepts or select the highest-ranked rejected one. If all fail,
934
+ repair within the brief and recipe before Step 3.
935
+ - **Unavailable writer or research.** Complete an explicit agent check of claim support,
936
+ recipe limits, visual feasibility and hook payoff. Record missing provenance and say
937
+ in the review when research is provisional. Never report a failed check as a pass.
938
+ - **The user's exact lines** remain verbatim; use report-only checks and raise material
939
+ timing, claim or format conflicts without silently rewriting them.
940
+ - **No spoken words.** Still fit the visual promise, reveal, cards and CTA to the silent
941
+ recipe. Skip speech writing and spoken checks, not the strategy step.
942
+ - **Keep private provenance separate.** Store source quotes and links in the research
943
+ workspace; put only a concise strategy explanation in remixable review data.
944
+
945
+ ## Shared editorial craft inside this template flow
946
+
947
+ Fetch `video-production-harness` and read its `references/editorial-review.md`,
948
+ `references/specialist-handoff.md` and `references/hook-compatibility.md`, plus the
949
+ review/edit/polish/promote/wrap steps when used. Save the fetched version/content hash with
950
+ this run's capability records. These supply craft and evidence rules inside the template
951
+ flow; this entry's existing review, paid approval, storage and two-repair limit still apply.
952
+ Do not turn a template into a custom project or import the custom host's extra gates.
953
+
954
+ Before executing a fetched recipe atom, pass the exact brief/script revision, scene/beat IDs,
955
+ timing, selected product/assets/source windows, performance choice and expected output roles.
956
+ Check actual scripts/dependencies and free runtime readiness, then validate returned media
957
+ against that handoff. An interrupted run reuses valid approved media with matching digest;
958
+ a file merely existing does not prove validity. A missing package/required renderer blocks
959
+ that route before paid generation, with a concrete supported alternative for review.
220
960
 
221
- This is a **review-once** flow: put the whole review set in the app, get ONE approval, then run the
961
+ Rough review asks what the cut communicates and whether the proof/payoff serves the hook;
962
+ fine review diagnoses performance, sequence and local execution; final review checks each
963
+ actual export. Save the received message from the cut before comparing with the brief where
964
+ possible. A technically clean incoherent cut returns to script/sequence work; a local caption
965
+ defect gets a local repair. These internal questions share existing review surfaces.
966
+
967
+ Before a hook change, classify same-promise compatible opening versus new-promise/body recut.
968
+ For example, an automatic report supports “stop copying campaign results”; it does not alone
969
+ prove “know where to spend the next dollar.” Propose required script/body/coverage changes for
970
+ the latter. Every restyled opening gets fresh image/action/audio/text review even when words
971
+ are unchanged. Fetch the existing `render-hook-replacement` before selecting that route;
972
+ a not-found/empty result stops it before generation. Use its actual preflight and preservation
973
+ checks when available; never build a duplicate renderer or infer publication from source.
974
+ Compare complete labeled candidates, retain source/body/ending and record the hypothesis.
975
+ No quality score or recommendation is an observed performance winner.
976
+
977
+ ## Step 3 — assemble the review set, then get ONE approval (before the expensive render)
978
+
979
+ This is a **review-once** flow: save the whole review set to the project, get ONE approval in this
980
+ chat, then run the
222
981
  expensive render + any remaining paid work end-to-end. Never spend on the expensive render before
223
982
  approval, and don't drip pieces out one at a time and re-pause.
224
983
 
@@ -231,9 +990,10 @@ every piece three ways by cost, NOT just "free vs paid":
231
990
  mirror the real asset. The few credits buy a real review: the user SEES the actual creator face
232
991
  and end card and HEARS the VO, instead of judging a prompt. **This OVERRIDES any recipe rule that
233
992
  says to gate ALL paid calls** — only the expensive render below is gated.
234
- - **EXPENSIVE paid** — the video take / final AI render (hundreds of credits) → do NOT generate.
235
- Put its **exact prompt/spec** (+ ref image URLs) in the tile. This is the ONE thing approved as a
236
- prompt (you can't preview a hundreds-of-credits video for free); it's generated only in Step 4.
993
+ - **EXPENSIVE paid** — the video take / final AI render / per-line lipsync clips (hundreds of
994
+ credits) → do NOT generate. Put its **exact prompt/spec** (+ ref image URLs) in the tile. This is
995
+ the ONE thing approved as a prompt (you can't preview a hundreds-of-credits video for free); it's
996
+ generated only in Step 4.
237
997
 
238
998
  **The expensive render's exact prompt must be in the panel BEFORE you ask for approval** — so a
239
999
  single "go" runs it (plus any remaining paid work) without re-pausing mid-run.
@@ -250,27 +1010,38 @@ render (GOOSE-2542). The full video is assembled ONLY in Step 4, after approval.
250
1010
  ingredient here is only a genuinely separate SOURCE clip the format needs (e.g. supplied b-roll).
251
1011
 
252
1012
  1. **Assemble every piece the format needs — not just the script.** Read the recipe for the exact
253
- list. For an iMessage video that's the **script** (bubble thread), the **conversation image(s)**,
254
- and the **end card**; richer templates add a hook frame, background, product shots, music bed, a
255
- creator/avatar, a voiceover… For each piece, decide FREE / CHEAP-paid / EXPENSIVE-paid (above):
256
- - **FREE or CHEAP paid** (≤ ~100 credits — HTML mockups, a still, the creator frame, the end
257
- card, a short VO/music bed) → generate it now and `get_upload_url` the asset to the project
258
- folder `agent-config/brands/<brand_slug>/projects/<project_id>/working/review/<name>` (same
259
- path-prefix rule as final publish — a bare `working/review/<name>` won't render in the panel);
260
- set that piece's `path` in `script_drafts` to the project-relative `working/review/<name>`.
261
- - **EXPENSIVE paid** (the video take / final render, hundreds of credits) → do NOT generate. Put
262
- the **exact prompt/spec** (and any ref image URLs) in the tile's `text` / `subtitle` so the
263
- user reviews what will be spent on. No `path` yet — it's generated in Step 4.
264
- Include the **estimated cost in CREDITS** (never dollars) of the cheap pieces already generated +
265
- the pending render, so the user approves knowing the total spend. **Answer clarifying questions
1013
+ list. For a podcast skit that's the **script** (both hosts' lines), the two **host stills**,
1014
+ one **voice sample per host**, and the **end card**; an iMessage video has the bubble thread,
1015
+ the conversation image(s) and the end card. For each piece, decide FREE / CHEAP-paid /
1016
+ EXPENSIVE-paid (above):
1017
+ - **FREE or CHEAP paid** (≤ ~100 credits) → generate it now and upload it with
1018
+ `media_upload { brand_id, scope: "video_project", scope_id: project_id, kind, path:
1019
+ "working/review/<name>", ingredient_key, input_digest, source: { type: "file", filename:
1020
+ "<name>", content_type } }` → PUT → `media_confirm { brand_id, media_id: media.id }`;
1021
+ after confirmation succeeds, set that
1022
+ piece's `path` (+ `media_id`, `ingredient_key`) in `script_drafts` to the project-relative
1023
+ `working/review/<name>`. First check "Save as you go" — a piece already saved with the same
1024
+ digest is downloaded, not regenerated.
1025
+ - **EXPENSIVE paid** → do NOT generate. Put the **exact prompt/spec** (and any ref image URLs)
1026
+ in the tile's `text` / `subtitle` so the user reviews what will be spent on. No `path` yet —
1027
+ it's generated in Step 4.
1028
+ Save **render_estimate.total_credits**: previews already spent + pending render + the 200 base fee.
1029
+ Use current server pricing, never a catalog range in place of the full total.
1030
+ **Brand check of the script, before it goes in the panel:** every line, caption and on-screen
1031
+ text is checked against `working/brand-rules.json`. Nothing in `never_say` appears, in words or
1032
+ in meaning (a paraphrase of a banned claim is still banned). Every product detail (name,
1033
+ flavour, size, price, ingredient, result) comes from `products[]` or the kit: anything else is
1034
+ cut, not invented. Add a `note` ingredient labelled "Brand rules applied" that lists the
1035
+ pronunciations used and the rules the script respects, so the user sees them.
1036
+ **Answer clarifying questions
266
1037
  from the project brief FIRST (Step 1.5)** — only ask the user for a field (angle, which product,
267
1038
  offer/code) the `creative_brief` leaves empty AND the recipe can't default. Do not re-ask for
268
1039
  anything the composer already captured.
269
- 2. **Mirror the whole ingredient set for review** — `update_ad_project_script { project_id,
270
- script_drafts, script }`. `script_drafts` is a structured payload of **container-tagged
271
- ingredients** so the app renders each piece the right way:
272
- `{ format, scenes?, ingredients: [{ container, label, subtitle?, path?, text? }] }`. Each
273
- ingredient's `container` tells the app HOW to show it:
1040
+ 2. **Mirror the whole ingredient set for review** — `video_project_upsert { brand_id, project_id,
1041
+ patch: { script: { script_drafts, script } } }`. `script_drafts` is a structured payload of
1042
+ **container-tagged ingredients** so the app renders each piece the right way:
1043
+ `{ format, scenes?, ingredients: [{ container, label, subtitle?, path?, url?, text? }], render_estimate? }`.
1044
+ Each ingredient's `container` tells the app HOW to show it:
274
1045
  - `image` (a frame shown in the video), `endcard` (the end card), `avatar` (a character
275
1046
  headshot), `background` → rendered as an image tile.
276
1047
  - `voice` (a voiceover clip — put the voice NAME in `subtitle`), `music` (the bed),
@@ -278,147 +1049,325 @@ ingredient here is only a genuinely separate SOURCE clip the format needs (e.g.
278
1049
  - `video` (a clip) → a video player. `text` (a copy line like the CTA) → a text tile.
279
1050
  - `script` / `thread` / `note` / `conversation` → the written script (or set `scenes[]`
280
1051
  for the podcast shape, or pass the readable `script` string).
281
- `path` = `working/review/<name>` (upload the preview asset first via `get_upload_url`); `url`
282
- works too. **Label every ingredient** ("Hook image", "End card", "Voiceover", "Background
283
- music", "HER"). The `update_ad_project_script` call itself writes no render and costs no credits
284
- (the cheap pieces you already generated above have their own small cost) — it just populates the
285
- review panel.
286
- 3. **STOP — the review happens in the APP's review panel, NOT in this chat.** You've mirrored the
287
- ingredients (3.2); now hand the user the project's `app_url` (from `get_ad_project`) and tell
288
- them to review the pieces there and hit **"Approve & render"**. That button gives them a short
289
- message to paste back into this session — THAT is your go-ahead. Do NOT paste the
290
- script/ingredients into the chat for a thumbs-up, and do NOT render until that approval comes
291
- back from the app. If they want changes (via the app's comments or here), regenerate the
292
- affected ingredient, call `update_ad_project_script` again, tell them it's refreshed in the
293
- app, and wait for a fresh approval. Only AFTER the app approval do Step 4. A single approval
294
- authorises the WHOLE remaining chain — generate every paid piece, render, self-QC, publish —
295
- with NO further pauses (that is exactly why every paid prompt must already be in the panel).
296
-
297
- ## Step 4 — render locally, report stages, publish
298
-
299
- 1. Now generate every PAID piece you showed as a prompt in Step 3 — the AI stills/video, voice,
300
- music, the end-card render — through the media proxies (below), each from its approved prompt.
301
- Then assemble per the recipe (Playwright record where needed → ffmpeg stitch → `mix-master`
302
- audio).
303
- 2. Open the row LAST: `submit_render { project_id, kind: "full" }` → keep `render_id`, then
304
- `update_render_status { render_id, status: "running" }`. The render row tracks status only
305
- (queued / running / complete / failed) — narrate fine-grained progress with
306
- `append_project_message` instead.
307
- 3. **MANDATORY final-video QC gate — YOU review EVERY finished master before `set_final_render`,
308
- whatever the format (UGC or not).** This is your own automated quality check, separate from the
309
- user's Step-3 approval — it does not go back to the user. The render row is already open (its
310
- nominal credit spent, `submit_render` in 4.2);
311
- this gate stands between a rendered master and PINNING/publishing it, so a bad render never gets
312
- set as final. A master that looks fine on a still can still have a mis-voiced word, a caption
313
- drifting off its line, a beat out of order, or a deformation — review the actual VIDEO, not
314
- stills. Run the passes that APPLY to this format:
1052
+ **Label every ingredient** ("Hook image", "End card", "Voiceover", "Host A", "HER"). The upsert
1053
+ writes no render and costs no credits — it just populates the review panel.
1054
+ 3. **STOP for ONE approval, in this chat.** Only a complete current saved review set with
1055
+ render_estimate.total_credits can be approved. Widget: one line, no duplicate plan or app
1056
+ link; otherwise print card.text_summary. The choices are Approve, Change and Not now.
1057
+ “Not now” keeps the plan. In a coworker sandbox end the turn after saving the review set;
1058
+ the customer's approval arrives as the next message.
1059
+ Record the explicit yes with `video_project_upsert { brand_id, project_id, patch: { approve:
1060
+ { user_quote: "<their exact words>", total_credits: <the saved total> } } }` before rendering.
1061
+ A single project requires recorded approval too; never treat an absent approval as permission.
1062
+ Changes require an updated saved review, clearing prior approval, and approval of the new
1063
+ total. One yes authorizes the remaining approved chain. On insufficient_balance start
1064
+ nothing; offer a shorter video or top-up. Remove batch concepts with patch.concepts remove:true,
1065
+ then show the changed total before approval.
1066
+
1067
+ ## Step 4 — render, report stages, publish
1068
+
1069
+ 1. **Open the render row FIRST** — right after recording the Step 3 approval, before any paid
1070
+ generation (if this returns `approval_required`, the approval is missing or was cleared: go
1071
+ back to Step 3 and ask in this chat, don't retry):
1072
+ `video_render_run { brand_id, project_id, kind: "full" }` (no `dry_run`; returns
1073
+ `render_id`) → keep `render_id`, then mark it running:
1074
+ `video_render_run { brand_id, project_id, render: { render_id, status: "running",
1075
+ workflow_stage: "preparing", progress_note: "starting", progress_percent: 5 } }`. The user sees this
1076
+ live in the app and gets a WhatsApp "started" message automatically — don't message them yourself
1077
+ about start / blocked / complete.
1078
+ After EVERY progress callback inspect stop. If true, start no new paid step; record
1079
+ status:"stopped" with a plain note and report what is kept and credits used. SPEND_CAP_REACHED
1080
+ stops the same way; raising the cap requires patch.approve scope:"raise_cap" and the customer's
1081
+ words. Send render.steps with the same neutral names each time and a live count only in the
1082
+ current detail; use render.choices when blocked.
1083
+ 2. Now generate every PAID piece you showed as a prompt in Step 3 — the AI stills/video, lipsync
1084
+ clips, voice, music — through the media proxies (below), each from its approved prompt, with
1085
+ `GW_PROJECT_ID` exported. **Save as you go** (section above): skip any piece already saved
1086
+ with the same `input_digest` (download it), and upload each new piece with its
1087
+ `ingredient_key` + `input_digest` the moment it passes QC.
1088
+ Keep the approved script and review unchanged throughout production and QC; confirmed media
1089
+ and progress preserve resume state. Stop and replan/reapprove any material creative change.
1090
+ A voiceover made with `data_post_provider` (ElevenLabs `…/with-timestamps`) returns its
1091
+ `alignment` only in the reply: write it to `working/vo/<scene>.timestamps.json` at once
1092
+ (captions are timed from it) and record the returned `media_id` on the ingredient.
1093
+ **Brand pronunciations in every voiceover:** the text sent to the voice has each
1094
+ `pronunciations[].term` replaced by its `say_as` (`create-vo-elevenlabs`:
1095
+ `gen_vo.py … --rules working/brand-rules.json`; when a render atom calls the voice itself,
1096
+ swap the terms in the text you hand it). Captions, on-screen text and the review keep the
1097
+ written name. Write `working/approved-script.txt` (the Step 4.3 audio check) with the SPOKEN
1098
+ form. **Logo, font, product:** every logo is the file from Step 1.7 composited as-is; every
1099
+ product shot uses the Step 1.7 product images as its reference.
1100
+ Then assemble per the recipe (ffmpeg stitch; PIL captions / end card;
1101
+ Playwright record only where the format needs it and the host has Chromium → `mix-master` audio).
1102
+ **Report progress at each milestone** — about one update per milestone, never per poll:
1103
+ `video_render_run { brand_id, project_id, render: { render_id, status: "running", workflow_stage, progress_note, progress_percent } }`
1104
+ (`progress_note` = plain words the customer reads in the app, ≤200 chars; no model, tool or
1105
+ step names):
1106
+ - voiceovers done → `"preparing"`, `"voices recorded"`, 20
1107
+ - stills done → `"preparing"`, `"scenes designed"`, 35
1108
+ - each lipsync / video clip → `"rendering"`, e.g. `"filming scene 5 of 8"`, 35–75
1109
+ - assembly → `"rendering"`, `"putting the video together"`, 85
1110
+ - QC (4.3) → `"final check"`, 95
1111
+ **Hard stop that needs the user** → `{ render_id, status: "running", workflow_stage: "blocked",
1112
+ error_message: "<what's wrong + what you need>" }`; an unrecoverable failure → `status: "failed"`
1113
+ + `error_message`. Completing (4.4) sets the bar to 100.
1114
+ 3. **MANDATORY final-video QC gate — YOU review EVERY finished master before pinning it
1115
+ (`patch.final_render_id`), whatever the format (UGC or not).** This is your own automated quality
1116
+ check, separate from the user's Step-3 approval — it does not go back to the user. The render row
1117
+ is already open (4.1); this gate stands between a rendered master and PINNING/publishing it, so a
1118
+ bad render never gets set as final. A master that looks fine on a still can still have a
1119
+ mis-voiced word, a caption drifting off its line, a beat out of order, or a deformation — review
1120
+ the actual VIDEO, not stills. Run the passes that APPLY to this format:
315
1121
  - **Audio ↔ script** — any master with SPEECH (VO or native/Seedance voice); **skip for
316
1122
  music-only / no-speech formats.** `review-ugc-render` is format-agnostic despite the name —
317
- a deterministic Whisper transcript-vs-script diff, not UGC-specific: persist the approved
318
- spoken lines to `working/approved-script.txt`, then `gooseworks fetch review-ugc-render` and
319
- run `review_render.py --video <master>.mp4 --script-file working/approved-script.txt --json
320
- working/review-verdict.json` (exit 0 PASS / 2 FAIL / 3 ERROR). It blocks a mis-voiced word
1123
+ a deterministic Whisper transcript-vs-script diff: persist the approved spoken lines to
1124
+ `working/approved-script.txt`, fetch `review-ugc-render` (`catalog_fetch`) and run
1125
+ `review_render.py --video <master>.mp4 --script-file working/approved-script.txt --json
1126
+ working/review-verdict.json` (exit 0 PASS / 2 FAIL / 3 ERROR). For each brand pronunciation add
1127
+ `--brand-term "<term>"`, plus `--brand-term` for each word of `say_as` that is not an
1128
+ everyday word (the flag strips those tokens from the WHOLE diff, so never pass "a", "one",
1129
+ "works" alone): Whisper spells a respelled name back as the brand word ("Goose Works" heard
1130
+ as "Gooseworks"), so the diff must accept it. The proof of
1131
+ intended delivery is the text/settings you sent (keep them in the review); actual
1132
+ pronunciation/performance requires isolated and mixed-audio listening at normal speed.
1133
+ Preserve pauses/emphasis and final consonants; never mandate faster or louder delivery.
1134
+ Verify a transcript mismatch against the actual audio before calling it a defect. It flags a mis-voiced word
321
1135
  (approved "human-vetted" → "human witted"), a dropped phrase, or silence. It routes Whisper
322
- through the gooseworks proxy when `OPENAI_BASE_URL` is set; with no backend at all, run
323
- `fal-ai/whisper` via `fal-proxy` (upload the audio, pass its `get_download_url` as `audio_url`)
1136
+ through the gooseworks proxy when `OPENAI_BASE_URL` is set (sandbox:
1137
+ `$GW_WHISPER_PROXY_URL/v1`); with no backend at all, run `fal-ai/whisper` via the FAL proxy
324
1138
  and diff the transcript yourself.
325
1139
  - **Captions / subtitles** — ANY captioned format (the most common non-UGC defect); **skip for
326
- UGC/Seedance masters, which carry no subtitle track.** Concrete check: diff the caption file
327
- you burned (SRT/ASS) against the SAME Whisper transcript + word timings from the audio pass —
328
- every caption line must match the heard/scripted words and sit within ~0.3s of when they're
329
- spoken; then in the visual pass below, OCR-read the burned caption off 4–5 sampled frames to
330
- confirm it's actually on screen at that time and not colliding with a hyperframe or the end
331
- card. Mismatched text or >0.3s drift fails the gate.
1140
+ UGC/Seedance masters, which carry no subtitle track.** Diff the caption file you burned
1141
+ (SRT/ASS/PNG cue list) against the SAME Whisper transcript + word timings — every caption line
1142
+ must match the heard/scripted words and sit within ~0.3s of when they're spoken; then in the
1143
+ visual pass below, inspect each cue and its start/end boundaries in actual frames, plus
1144
+ full-speed playback at destination size, to confirm reading time, product visibility,
1145
+ hierarchy and no duplicate overlay or end-card collision. Silent/text-led formats use
1146
+ approved visible wording and reading windows, not nonexistent speech timings. Mismatched text or >0.3s drift fails the gate.
332
1147
  - **Visual + structure** — always: run the `watch` skill on the master — beat/scene order + SFX,
333
- the brand's product (not the source's) is shown, the end card has the real wordmark + code, no
1148
+ the brand's product (not the source's) is shown, the end card has the brand's logo file (or its name set in the brand font) + code, no
334
1149
  deformation/artifact, duration within ~20% of the source.
335
- If ANY applicable pass fails, FIX it (regenerate/stitch the offending window, rebuild captions)
336
- and re-review — only a clean pass proceeds to `set_final_render`. **This gate is universal: it
337
- runs from the master skill for every format, so a recipe never has to opt in.**
338
- 4. Publish: `get_upload_url { target: { type: "agent", agent_id: ADS_AGENT } }` → PUT the master
339
- and poster **under the project folder** (see Identity's path-prefix rule) — to
340
- `agent-config/brands/<brand_slug>/projects/<project_id>/working/final.mp4` and
341
- `.../working/final-thumb.jpg`. **Always target ADS_AGENT AND use the full project-folder path**
342
- — a bare `working/final.mp4`, even on the right agent, 404s in the app. Verify servable:
343
- `get_download_url { target: ADS_AGENT, path: "agent-config/brands/<brand_slug>/projects/<project_id>/working/final.mp4" }`
344
- must return a non-empty URL (curl it for HTTP 200).
345
- Then `update_render_status { render_id, status: "complete", output_url, thumbnail_url }` where
1150
+ - **Finished ad + brand fidelity** — always: fetch `review-finished-ad` (`catalog_fetch`,
1151
+ `pip install --quiet numpy pillow` if needed) and run
1152
+ `review_finished_ad.py --video <master>.mp4 --json working/review/finished-ad.json
1153
+ --sheet working/review/finished-ad-sheet.png --logo <the logo file the video composites>
1154
+ --palette "<kit palette, comma-separated>" --product-images <the Step 1.7 images>
1155
+ --font <brand font file> --brand-name "<name>" --endcard-s <end card length>`. Pass the
1156
+ file that is ACTUALLY on screen (the kit logo, or the recipe's wordmark file). When the video
1157
+ shows only the brand name as text (`"logo": {"mode": "text"}`), omit `--logo` and judge the
1158
+ text on the sheet. Add `--no-speech` for a format with no VO or dialogue, `--logo-at <s>` for
1159
+ each mid-video logo, and any gate flags the recipe's instructions name (a chat format's
1160
+ reading holds need a longer `--max-freeze-s`). Exit 0 PASS / 2 FAIL / 3 ERROR. It
1161
+ checks size, hook, pacing, dead air, black frames, the kit logo on the end card
1162
+ (a wrong, redrawn or favicon logo fails) and the palette. **Then open the sheet it writes
1163
+ and judge every line of its `judge_on_sheet`:** captions/CTA/logo outside the red safe
1164
+ zones, the brand font, every product shot matching the product images, the product the same
1165
+ in every scene, the logo unaltered. A failed eye check is a FAIL like any other.
1166
+ - **Output size** — always **1080×1920 (9:16)**. Video ads are only ever 9:16. Lipsync / video
1167
+ models often return 720p or odd sizes — scale (and pad if the aspect differs) every clip to
1168
+ 1080×1920 BEFORE the concat, never ship the model's native size.
1169
+ Save exact output checksum/version, first-to-last normal-speed playback and full-audio
1170
+ coverage. Frame sheets, transcripts and process success do not substitute for listening or
1171
+ continuous motion. Missing required capability leaves review incomplete/blocked. Each
1172
+ supported crop, duration, language or caption derivative needs its own actual-file review;
1173
+ unsupported destination requirements need a reviewed route, never a silent export change.
1174
+ Honor intended silence, loops and endings rather than forcing music or fades on every ad.
1175
+ If ANY applicable pass fails, FIX it (regenerate/stitch the offending window, re-composite the
1176
+ end card from the real logo file, rebuild captions) and re-run the passes — only a clean pass
1177
+ proceeds to pinning. **At most 2 repair rounds.** If a pass still fails after them, do NOT pin
1178
+ and do NOT present the video as finished: upload it (4.4) and close the row with exactly
1179
+ `video_render_run { brand_id, project_id, render: { render_id, status: "complete",
1180
+ workflow_stage: "blocked", quality_status: "blocked", repair_pass_count: 2, output_url,
1181
+ thumbnail_url, quality_report } }` (the failing checks as `fail` in the report), and tell the user plainly in
1182
+ chat which checks failed, what you tried, and the choices (fix a specific thing, re-roll, or
1183
+ use it anyway). Pin it only if they say to use it anyway. The app shows a blocked render as
1184
+ "Needs attention". **This gate is universal: it runs from this skill for every format, so a
1185
+ recipe never has to opt in.**
1186
+ 4. **For a passing final, create the finished-video checkpoint first**, following "Finished video, interrupted saving"
1187
+ above. With the CLI, use its prepare/resume flow instead of duplicating the writes below; it
1188
+ saves the same already-opened render and pins only the checked output. Save the final review set
1189
+ and production manifest (Step 4.5/4.6) before preparing that checkpoint. Without it, follow the
1190
+ same durable protocol. A blocked version follows Step 4.3's existing upload/report-only path;
1191
+ never route it through the passing-final helper or pin it automatically.
1192
+ Publish: `media_upload { brand_id, scope: "video_project", scope_id: project_id, kind: "render",
1193
+ path: "working/final.mp4", ingredient_key: "final", input_digest, source: { type: "file", filename: "final.mp4", content_type:
1194
+ "video/mp4" } }` → PUT the master to `upload.url` with `upload.required_headers` →
1195
+ `media_confirm { brand_id, media_id: media.id }`. Same for the poster (`kind: "thumbnail"`, `path: "working/final-thumb.jpg"`, `ingredient_key: "final-thumb"`).
1196
+ Keep each `upload.render_file_url`. Verify the PUT returned 2xx and the file you uploaded is a
1197
+ real, non-empty MP4 (ffprobe it), and require both confirmations to succeed BEFORE marking
1198
+ the render complete.
1199
+ Then `video_render_run { brand_id, project_id, render: { render_id, status: "complete", output_url, thumbnail_url } }` (attach the Step 4.3 verdict as `quality_status: "passed"` (or
1200
+ `"blocked"` when the gate still fails after 2 repair rounds) + `quality_report` — ALWAYS
1201
+ attach it; a batch concept cannot complete without a passing one; exact shape, strict (no extra keys):
1202
+ `{ version: 1, summary: string, checks: { source, brand, product, hook_and_scene_order,
1203
+ voice_and_script, captions, endcard_and_cta, duration_and_ratio, visual_artifacts }, detected_issues?:
1204
+ string[], repair_actions?: string[] }` where EVERY check is `{ status: "pass"|"fail"|"not_applicable",
1205
+ note?: string }`). Fill each check from the Step 4.3 passes: `brand` ← logo_asset + logo +
1206
+ palette + font + logo unaltered; `product` ← product likeness + product consistency;
1207
+ `hook_and_scene_order` ← hook + pacing + the `watch` beat order; `voice_and_script` ← the
1208
+ Whisper diff (pronunciations included) + no `never_say` line; `captions` ← the caption diff +
1209
+ safe zones; `duration_and_ratio` ← ratio + duration; `visual_artifacts` ← black frames +
1210
+ frozen stretches + the `watch` pass; `endcard_and_cta` ← the end card holds the real logo +
1211
+ CTA. Put each failing check's note in `detected_issues` and each fix in `repair_actions`.
346
1212
  **output_url MUST be the durable render-file URL**
347
- `/api/ads/projects/<project_id>/render-file?path=working/final.mp4` (the app re-presigns it on
348
- every view) — NEVER a raw proxy/CDN URL (those expire). Same for `thumbnail_url`.
349
- 5. `set_final_render { project_id, render_id }` to pin it, then return the `app_url` +
350
- `brand_url` (from the project/links) verbatim. Never end on just "done" or a file path.
1213
+ (`upload.render_file_url`, i.e. `/api/ads/projects/<project_id>/render-file?path=working/final.mp4`
1214
+ — the app re-presigns it on every view) — NEVER a raw proxy/CDN/presigned URL (those expire).
1215
+ Same for `thumbnail_url`.
1216
+ 5. **Save the final review set BEFORE pinning** — it must describe the video you actually rendered.
1217
+ Only after all paid production, QC, repairs and pending provider work are finished and settled,
1218
+ save one final descriptive/provenance update: confirmed pieces, exact settings and repairs that
1219
+ preserve the approved creative choices. Material creative changes, including changed lines,
1220
+ look, timing, captions or music, require a changed complete plan, total and fresh approval BEFORE
1221
+ the changed production. Never relabel a changed plan as provenance or silently reuse approval.
1222
+ In the checkpoint flow, save the final review before Step 4.4; do not rewrite it afterward merely
1223
+ to follow the numbered order. Resume checks that this reviewed set stayed unchanged.
1224
+ When final provenance needs updating, upsert the review set once:
1225
+ `video_project_upsert { brand_id, project_id, patch: { script: {
1226
+ script_drafts, script } } }` with the final lines, final pieces (mark generated takes as done, not
1227
+ "not generated yet") and the settings you used. The project keeps this, not your chat: it is
1228
+ what the app shows, and what a Community remix of this video copies. Instructions that live only
1229
+ in this conversation are lost when it ends. **Keep the approved detail**: never shorten a piece to a
1230
+ summary (e.g. per-scene prompts or their "no shake / no letterbox" guards). Only update what changed.
1231
+ After this write, do not start new paid work. Save the production manifest, prepare the final
1232
+ checkpoint and complete the same render with its existing finishing allowance and guards.
1233
+ 6. **Save the production manifest** — HOW you made it, so the next run (or a remix) starts from what
1234
+ worked instead of rediscovering it: `video_project_upsert { brand_id, project_id, patch: { production:
1235
+ { version: 1, pipeline: [{ step, model, purpose?, settings? }], style: { prompt, negative, notes? },
1236
+ characters: [{ name, prompt }], scenes: [{ id, line, still_prompt, motion_prompt, duration_s }],
1237
+ voice: { voice_id, name, model, settings }, music: { prompt, model, length_s }, assembly: { … },
1238
+ fixes: [{ problem, fix }], notes? } } }`. Use the exact models and prompts you sent (full text, guards
1239
+ included), and list every fix you had to make (e.g. "VO ran 47s → tightened four lines, voice 1.08x";
1240
+ "hair drifted → restated the hair colour"). No URLs, keys or raw logs; it must stay under 48 KB.
1241
+ In the checkpoint flow, save this before Step 4.4 too and skip the duplicate write afterward.
1242
+ 7. Pin it — only a `passed` render (or a `blocked` one the user said to use anyway):
1243
+ If checkpoint recovery already verified selection of this render, skip this duplicate write.
1244
+ An unfinished checkpoint must use the guarded selection protocol above; never replace it
1245
+ with an unguarded pin.
1246
+ `video_project_upsert { brand_id, project_id, patch: { final_render_id: render_id } }`,
1247
+ then use the returned card: widget hosts get one line and no duplicate links; text hosts get
1248
+ card.text_summary and the returned delivery links verbatim. Never end with a local file path.
351
1249
 
352
- Narrate each long step in one line via `append_project_message { project_id, role: "agent",
353
- content }` — never sit silent on a queue > 90s.
1250
+ Narrate each long step in one line via `video_project_upsert { brand_id, project_id, patch:
1251
+ { message: { role: "agent", content } } }` — never sit silent on a queue > 90s. Write it for the
1252
+ customer ("Filming the scenes, about 5 more minutes"), per "How to talk to the customer" above.
354
1253
 
355
1254
  ## Media generation — the GooseWorks proxies (queue loop)
356
1255
 
357
- Media APIs go through GooseWorks proxies with your agent token; do NOT use an SDK's default host
358
- (your token isn't a FAL/ElevenLabs token → 401). Base = `<api_base>/api/internal/<proxy>`; pass
359
- `?token=<api_key>&agent_id=<agent_id>&project_id=<project_id>` (agent_id bills the Ads agent;
360
- `project_id` = the id of the project you're rendering — it attributes this generation's credits to
361
- that ad project so the user sees per-project spend in the app. ALWAYS pass it). FAL = `fal-proxy`
362
- (+ `fal-storage-proxy` to host a local image and get a CDN URL); ElevenLabs = `elevenlabs-proxy`
363
- (VO / music bed).
1256
+ Media APIs go through GooseWorks proxies; do NOT use an SDK's default host (your token isn't a
1257
+ FAL/ElevenLabs token → 401, and in a sandbox a raw provider call is never allowed). Prefer the
1258
+ atoms' own `media_proxy.py` (`fal_generate`, `fal_generate_video`, `eleven_music`, …) — it already
1259
+ handles auth, the queue host-swap, project attribution (`GW_PROJECT_ID`) and failure logging.
1260
+
1261
+ - **Sandbox:** FAL base = `$GW_FAL_PROXY_URL`, ElevenLabs = `$GW_ELEVENLABS_PROXY_URL`, FAL
1262
+ storage = `$GW_FAL_STORAGE_PROXY_URL`; auth = `?token=$GW_MEDIA_PROXY_TOKEN` (or
1263
+ `Authorization: Bearer`), plus `&project_id=$GW_PROJECT_ID`. The token already names the agent.
1264
+ - **Local:** base = `<api_base>/api/internal/<proxy>` (`fal-proxy`, `fal-storage-proxy`,
1265
+ `elevenlabs-proxy`); pass `?token=<api_key>&agent_id=<agent_id>&project_id=<project_id>`
1266
+ (agent_id bills the Ads agent; project_id attributes the spend to this ad project so the user
1267
+ sees per-project spend in the app. ALWAYS pass it).
364
1268
 
365
1269
  **FAL queue gotcha** (#1 waste of generations): submit returns `status_url`/`response_url` on
366
1270
  `queue.fal.run` (the real host, not the proxy). Polling those 401s forever — rewrite their host
367
- to the proxy base (keep the path), re-add `?token=&agent_id=`. Only the final `*.fal.media`
368
- image is a real public URL. Helper:
1271
+ to the proxy base (keep the path), re-add the auth params. Only the final `*.fal.media`
1272
+ file is a real public URL. Helper (works in both modes):
369
1273
 
370
1274
  ```python
371
1275
  import json, os, pathlib, time, requests
372
1276
  from urllib.parse import urlparse
373
1277
 
374
1278
  def _cfg():
1279
+ """(fal_base, token, agent_id). Sandbox env first, then ~/.gooseworks/credentials.json."""
1280
+ tok = os.environ.get("GW_MEDIA_PROXY_TOKEN")
1281
+ if tok:
1282
+ base = os.environ.get("GW_FAL_PROXY_URL") or os.environ["GW_API_BASE"].rstrip("/") + "/api/internal/fal-proxy"
1283
+ return base.rstrip("/"), tok, None
375
1284
  c = json.loads(pathlib.Path(os.path.expanduser("~/.gooseworks/credentials.json")).read_text())
376
- return c["api_base"].rstrip("/"), c["api_key"], c.get("agent_id")
1285
+ return c["api_base"].rstrip("/") + "/api/internal/fal-proxy", c["api_key"], c.get("agent_id")
377
1286
 
378
- def _params(tok, agent, project_id=None):
1287
+ def _params(tok, agent):
379
1288
  p = {"token": tok}
380
1289
  if agent: p["agent_id"] = agent
381
- if project_id: p["project_id"] = project_id # attributes the spend to this ad project
1290
+ pid = os.environ.get("GW_PROJECT_ID")
1291
+ if pid: p["project_id"] = pid # attributes the spend to this ad project
382
1292
  return p
383
1293
 
384
- def fal_generate(model_path, payload, project_id=None, timeout_s=180, poll_s=3):
1294
+ def fal_generate(model_path, payload, timeout_s=180, poll_s=3):
385
1295
  """model_path e.g. 'fal-ai/nano-banana-2/edit' (the recipe names the model).
386
- Pass project_id = the ad project you're rendering so credits attribute to it.
387
- Returns the result image URL (a public *.fal.media CDN URL)."""
388
- api_base, tok, agent = _cfg()
389
- base = api_base + "/api/internal/fal-proxy"
390
- sub = requests.post(f"{base}/{model_path}", params=_params(tok, agent, project_id), json=payload).json()
1296
+ Export GW_PROJECT_ID first. Returns the result image URL (a public *.fal.media URL)."""
1297
+ base, tok, agent = _cfg()
1298
+ sub = requests.post(f"{base}/{model_path}", params=_params(tok, agent), json=payload).json()
391
1299
  to_proxy = lambda u: base + urlparse(u).path
392
1300
  status_url, response_url = to_proxy(sub["status_url"]), to_proxy(sub["response_url"])
393
1301
  deadline = time.time() + timeout_s
394
1302
  while time.time() < deadline:
395
- st = requests.get(status_url, params=_params(tok, agent, project_id)).json()
1303
+ st = requests.get(status_url, params=_params(tok, agent)).json()
396
1304
  if st.get("status") == "COMPLETED":
397
- return requests.get(response_url, params=_params(tok, agent, project_id)).json()["images"][0]["url"]
1305
+ return requests.get(response_url, params=_params(tok, agent)).json()["images"][0]["url"]
398
1306
  if st.get("status") in ("FAILED", "ERROR"):
399
1307
  raise RuntimeError(f"FAL failed: {st}")
400
1308
  time.sleep(poll_s)
401
1309
  raise TimeoutError("FAL polling exceeded timeout")
402
1310
  ```
403
1311
 
404
- ElevenLabs (VO / music) is the same shape against `<api_base>/api/internal/elevenlabs-proxy`
405
- with `?token=&agent_id=&project_id=`. Feed FAL a local image by storing it (`get_upload_url`) and passing its
406
- `get_download_url` presigned URL as an `image_urls` / `audio_url` entry — this is the reliable
407
- path. (`fal-storage-proxy` may 404 depending on the install; don't block on it — prefer the
408
- `get_download_url` presigned URL.)
1312
+ ElevenLabs (VO / music) is the same shape against the ElevenLabs proxy base. To feed FAL a local
1313
+ file (a product image, a VO track), it must be a PUBLIC URL: upload it with `media_upload`
1314
+ (`scope: "video_project"`, source `file`, no `path`) → PUT → `media_confirm` and use the returned
1315
+ `media.url` if it is a public https URL (curl it: HTTP 200 without auth), or host it through the
1316
+ FAL storage proxy. Never pass a `render-file` URL to a provider — it needs app auth.
1317
+
1318
+ ## Follow-up actions use the watched version
1319
+
1320
+ Keep original note text, exact source render/time and intended viewer effect. Record an
1321
+ acceptance condition and disposition in existing feedback/project artifacts; applying a
1322
+ command means changed, not verified. Consolidate duplicates without deleting their source
1323
+ IDs. Conflicting “calmer” and “more urgent” instructions need the authorized decision owner's
1324
+ recorded choice, even if they touch different files. Offer concrete cheap alternatives for
1325
+ “more premium” inside the approved scope before escalating taste.
1326
+
1327
+ Map changed copy/performance/shot/pause to affected picture, timings, captions, music/SFX,
1328
+ approvals and derivatives; preserve unrelated approved work. Rewatch the full candidate and
1329
+ verify the original effect before resolving a note. Accepted final, candidate and original
1330
+ note source remain distinct across selection and rollback. Keep editable script/timeline,
1331
+ source assets/takes, stems, captions, package versions and prior decisions in the existing
1332
+ production manifest/history; retrieve applicable rejections/pronunciation/delivery rules
1333
+ before a related brief. Project taste is not a standing brand rule. Record audience results
1334
+ only with actual variant/audience/placement/objective/window; otherwise unavailable.
1335
+
1336
+ - “Fix this”: use the render/project context attached to the message (or named version, else
1337
+ the final one). Save patch.fix { of_render_id, changes, total_credits }. Never replace a supplied
1338
+ watched render with the final. After explicit approval save patch.approve { user_quote,
1339
+ total_credits, scope:"fix" }, then video_render_run { kind:"partial", fix_of_render_id }.
1340
+ Re-make only changed scenes, keep earlier versions and charge no second base fee.
1341
+ - “Make 3 more like this”: video_project_upsert { brand_id, name, remix_of_project_id,
1342
+ remix_of_render_id, vary, concepts:3 }. Preserve a provided watched render; omit only when none is named.
1343
+ - “Test 1 of each”: approve only:"test"; “Make the other N”: only:"rest". “Stop the rest”:
1344
+ job_cancel { job_id:<batch_id> }. Finished videos stay saved.
1345
+ - Share for review uses patch.share_for_review { subject }; return the real link.
409
1346
 
410
1347
  ## Rules
411
1348
 
412
- - **MCP + ffmpeg + Playwright required** — run `gooseworks doctor` in Phase 0; stop with the
413
- exact fix it prints if anything is ✗.
414
- - **Assemble the whole review set first**, mirror it with `update_ad_project_script`, and get the
415
- user's approval **in the app's review panel** (the "Approve & render" button) BEFORE the expensive
416
- render — never ask for a thumbs-up in this chat (review-once, in-app).
1349
+ - **Canonical MCP tools first** (`video_project_read`, `video_project_upsert`, `catalog_fetch`,
1350
+ `media_upload` + `media_confirm`, the `video_render_run` render-row actions, `account_whoami`);
1351
+ legacy names only when the client lacks the canonical tool.
1352
+ - **A missing key is never a blocker.** Paid media goes through the proxy: a one-off image or clip
1353
+ is `data_post_provider { provider: "fal", … }` + `job_get` (see "Paid media over the MCP");
1354
+ never ask for FAL_KEY, never use `photos_generate` for anything but a physical product.
1355
+ - **The CLI and credentials.json are optional.** In a GooseWorks sandbox (`GW_MEDIA_PROXY_TOKEN`
1356
+ set) use the env proxies and `catalog_fetch`; never call a provider with a raw key.
1357
+ - **No Chromium in a sandbox** — a browser-rendered format stops there, before any spend, and says so.
1358
+ - **Toolchain before spend** — common checks use `gooseworks doctor --no-browser`; every selected
1359
+ browser renderer must also pass `--renderer-script` or its equivalent exact-runtime launch
1360
+ check in Step 2. Stop with the folder-specific fix if anything is missing.
1361
+ - **Assemble the whole review set first**, mirror it with `video_project_upsert patch.script`, and
1362
+ get ONE approval in this chat, recorded with `patch.approve`, BEFORE the expensive render
1363
+ (review-once). Never send the user to the app to approve; the app is only for reviewing.
417
1364
  - **Show the REAL cheap pieces; PROMPT only the expensive render.** Generate the FREE + CHEAP-paid
418
1365
  pieces (≤ ~100 credits — stills, creator frame, end card, short VO/music) and mirror the real
419
1366
  assets; put ONLY the expensive video take/render in the panel as its exact prompt. That prompt
420
1367
  must be in the panel before you ask to approve, so a single "go" runs the render + any remaining
421
1368
  paid work (→ QC → publish) with no re-pausing.
1369
+ - **Operator may be absent (sandbox):** decide mechanical choices yourself; ask in chat only for a
1370
+ true taste call.
422
1371
  - **Costs in CREDITS, never dollars.** credits ≈ round-up(provider-$ × 120) per generation + a flat
423
1372
  200-credit base per video; never show a "$…" figure to the user.
424
1373
  - **Never assemble the full video before approval.** The review shows the
@@ -426,15 +1375,31 @@ path. (`fal-storage-proxy` may 404 depending on the install; don't block on it
426
1375
  stitched/composited cut; do not add a "full cascade" / finished-video clip
427
1376
  as a review ingredient (GOOSE-2542). The assembled video is produced only in
428
1377
  Step 4.
429
- - **submit_render only after the master is rendered** (Step 4.2), never on a guess; `output_url` =
430
- the durable render-file URL, never a CDN URL.
431
- - **Always pass `project_id` on media-proxy calls** (fal / ElevenLabs) so the credits attribute
432
- to this ad project — that's what lets the user see per-project spend in the app.
1378
+ - **Open the render row at the start of Step 4** (4.1, after the approval) and keep its stage /
1379
+ progress current; mark it `complete` only after the master passes QC. `output_url` = the
1380
+ durable render-file URL, never a CDN URL.
1381
+ - **Always export `GW_PROJECT_ID`** (and pass `project_id` on hand-rolled proxy calls) so the
1382
+ credits attribute to this ad project.
433
1383
  - **Verify a real, non-empty MP4** (watch it) before marking the render complete.
434
1384
  - **Reuse the brand** when its research is complete; never re-research.
1385
+ - **Brand rules first:** load kit + products + learnings (Step 1), write `working/brand-rules.json`
1386
+ (Step 1.7), and follow it: pronunciations in every voiceover, nothing from `never_say`, product
1387
+ facts only from the product rows, the kit's logo FILE (never a generated or favicon logo), the
1388
+ brand font, this product's own images.
1389
+ - **Save brand corrections** from chat with `brand_update patch.facts` in the same turn, and say so.
1390
+ - **Finished-ad gate on every master** (`review-finished-ad` + the sheet); at most 2 repair
1391
+ rounds, then publish as `blocked` with the report and warn the user — never pass off a failing
1392
+ video as finished.
435
1393
  - On a hard error (auth/quota/model/timeout) set the render `failed` with a short
436
- `error_message` and stop — don't ship the source unchanged. **Also `log` it** (`gooseworks log`
437
- / `log_cli_event`, `--event-type api_failure|error`) so we can see + fix it (see "Report problems").
438
- - **Report blockers/bugs/confusing instructions via telemetry** (`gooseworks log` or the
439
- `log_cli_event` MCP tool) — not just to the user. Set `GW_RUN_ID` once so events group.
440
- - Always end a successful run with `app_url` + `brand_url`, verbatim.
1394
+ `error_message` (`video_render_run { …, render: { render_id, status: "failed", error_message } }`) and stop — don't ship the source unchanged. **Also log
1395
+ it** (see "Report problems") so we can see + fix it.
1396
+ - Finish according to card.display_hint: widget hosts get one short line without duplicate links;
1397
+ text hosts get card.text_summary and the returned delivery links verbatim.
1398
+
1399
+ ## Use uploaded footage
1400
+
1401
+ When the customer asks to use existing footage, check the actual advertised schemas. Use `media_search` with purpose `production`, kind `video`, the brand and current project when needed. Omit query spend for free retrieval. Read facts/scenes with `media_analyze`, then use `media_excerpt` action `inspect` to review actual bounded frames and timed transcript before selecting. A description or thumbnail URL alone is not visual review.
1402
+
1403
+ Freeze `source_excerpt:{asset_id,analysis_revision,scene_id,start_ms,end_ms,audio_mode}`. Revision is the original-byte SHA, scene may be null for a known user trim, bounds use integer milliseconds, and audio is original or muted. Call `media_excerpt` action `attach` with that exact selection and a stable idempotency key. The returned project remains unfinished and unapproved. Open its existing Studio review; preserve user locks and requested format, and keep footage separate from image packshot indexes. An incompatible format requires an explicit choice before changing it.
1404
+
1405
+ For custom production, fetch the current shared `video-production-harness` and follow script/ingredient gates. Download the verified original and trim its exact selected window at normal speed with the approved audio. Recheck current revision and production permission before consumption and final upload/completion. Save excerpt lineage in plan and ingredient readback. Missing optional semantics does not require another upload; known user-selected stored footage remains usable. Research and competitor references never become production footage. Selected originals require no paid generation; only newly generated/replaced ingredients consume the approved budget.