Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
Autopilot can stop after the stills, has the orchestrator check them, and shows it the Cast & Sets renders
Claudeaa2bfcef2af9
diff --git a/client/src/components/musicVideo/AutonomousRunPanel.jsx b/client/src/components/musicVideo/AutonomousRunPanel.jsxindex a1c52ab2b4..31ce7491d3 100644--- a/client/src/components/musicVideo/AutonomousRunPanel.jsx+++ b/client/src/components/musicVideo/AutonomousRunPanel.jsx@@ -10,6 +10,7 @@ import { VideoModelField } from './ToolPicker.jsx';import { productionReviewStopGuidance } from '../../lib/musicVideoStages.js';import { formatCount, formatUsd } from '../../utils/formatters.js';import AutoApproveFields from './AutoApproveFields.jsx';+import ToggleChip from '../ui/ToggleChip.jsx';import OrchestratorReviewLog from './OrchestratorReviewLog.jsx';// The stages that report a sub-step while they run (the server's `stages[id].step`).@@ -71,6 +72,8 @@ export default function AutonomousRunPanel({ project, auto, readiness, selectedSconst [grantError, setGrantError] = useState(null);// The video model swaps the director picked for a parked production stage: { runId, value: { 'video:<mode>': id } }.const [videoSwapEdit, setVideoSwapEdit] = useState(null);+ // Video tools the director adds while approving the stills: { runId, value: ['video:<mode>'] }.+ const [addToolsEdit, setAddToolsEdit] = useState(null);if (!run) return null;const guidance = productionReviewStopGuidance(run, readiness);const rows = autonomousStageRows(run);@@ -90,6 +93,10 @@ export default function AutonomousRunPanel({ project, auto, readiness, selectedS? MUSIC_VIDEO_AUTOMATION_TOOLS.filter((tool) => tool.id.startsWith('video:') && (run.brief?.tools || []).includes(tool.id)): [];const videoSwaps = videoSwapEdit && videoSwapEdit.runId === run.id ? videoSwapEdit.value : {};+ // Stills approved on a run with no video tool: offer one, or the clips have no route.+ const missingVideoTools = awaiting === 'stills' && !(run.brief?.tools || []).some((id) => id.startsWith('video:'))+ ? MUSIC_VIDEO_AUTOMATION_TOOLS.filter((tool) => tool.id.startsWith('video:')) : [];+ const addTools = addToolsEdit && addToolsEdit.runId === run.id ? addToolsEdit.value : [];const modelsSwap = Object.fromEntries(Object.entries(videoSwaps).filter(([tool, id]) => id !== (run.brief?.models?.[tool] || '')).map(([tool, id]) => [tool, id || null]));const orchestrator = isOrchestratedRun(run) ? run.brief.orchestrator : null;const tone = STATUS_TONES[run.status] || '';@@ -206,7 +213,23 @@ export default function AutonomousRunPanel({ project, auto, readiness, selectedS</div>)}<div className="flex flex-wrap gap-2">- <button type="button" disabled={auto.busy} onClick={() => resume(changed ? { [editable.key]: draft } : {})} className={`${buttonClass} bg-port-accent text-white border-port-accent`}>+ {missingVideoTools.length > 0 && (+ <fieldset className="w-full min-w-0" aria-label="Video tool for the clips">+ <span className="block text-xs text-port-text-muted mb-1">Make the clips with</span>+ <div className="flex flex-wrap gap-1.5">+ {missingVideoTools.map((tool) => (+ <ToggleChip+ key={tool.id}+ id={`mv-run-add-${tool.id}`}+ label={tool.label}+ checked={addTools.includes(tool.id)}+ onToggle={() => setAddToolsEdit({ runId: run.id, value: addTools.includes(tool.id) ? addTools.filter((id) => id !== tool.id) : [...addTools, tool.id] })}+ />+ ))}+ </div>+ </fieldset>+ )}+ <button type="button" disabled={auto.busy} onClick={() => resume({ ...(changed ? { [editable.key]: draft } : {}), ...(addTools.length ? { addTools } : {}) })} className={`${buttonClass} bg-port-accent text-white border-port-accent`}><Play size={14} aria-hidden="true" /> {changed ? 'Save edit & approve' : 'Approve & continue'}</button>{awaiting === 'song' && (diff --git a/client/src/components/musicVideo/AutonomousRunPanel.test.jsx b/client/src/components/musicVideo/AutonomousRunPanel.test.jsxindex 88421ee9aa..81dc663916 100644--- a/client/src/components/musicVideo/AutonomousRunPanel.test.jsx+++ b/client/src/components/musicVideo/AutonomousRunPanel.test.jsx@@ -123,6 +123,16 @@ describe('AutonomousRunPanel', () => {await waitFor(() => expect(api.resumeAutonomousMusicVideo).toHaveBeenCalledWith('mv-1', { lyrics: '[verse]\nedited' }, { silent: true }));});+ // Uniquely catches approving the stills of a run with no video tool, which leaves the clips with no route.+ it('offers a video tool when approving the stills of a run that has none', async () => {+ api.resumeAutonomousMusicVideo.mockResolvedValue({ project: { id: 'mv-1', autonomousRun: baseRun() }, run: baseRun() });+ render(<Harness initial={baseRun({ status: 'awaiting-approval', awaiting: 'stills', stage: 'produce', brief: { ...baseRun().brief, tools: ['image:codex'] } })} />);+ expect(screen.getByText(/paused after/i).textContent).toMatch(/Stills/);+ fireEvent.click(screen.getByLabelText(/fal\.ai video/i));+ fireEvent.click(screen.getByRole('button', { name: /approve & continue/i }));+ await waitFor(() => expect(api.resumeAutonomousMusicVideo).toHaveBeenCalledWith('mv-1', { addTools: ['video:fal'] }, { silent: true }));+ });+it('offers the Suno style line to edit at the style checkpoint (the last stop before Suno is used)', async () => {render(<Harness initial={baseRun({ status: 'awaiting-approval', awaiting: 'style' })} />);expect(screen.getByLabelText(/suno style \(edit before continuing\)/i).value).toBe('synthwave');diff --git a/client/src/components/musicVideo/AutonomousStartDrawer.jsx b/client/src/components/musicVideo/AutonomousStartDrawer.jsxindex 37a18e6fd9..9faa0cefa1 100644--- a/client/src/components/musicVideo/AutonomousStartDrawer.jsx+++ b/client/src/components/musicVideo/AutonomousStartDrawer.jsx@@ -184,6 +184,8 @@ export default function AutonomousStartDrawer({ open, onClose, onStarted }) {</select></div>+ <ToggleChip id="mv-auto-stop-before-video" label="Stop before video: stills first" checked={draft.stopBeforeVideo} onToggle={() => patch({ stopBeforeVideo: !draft.stopBeforeVideo })} />+{orchestrated ? (<fieldset className="min-w-0 space-y-2" aria-labelledby="mv-auto-orchestrator-label"><span id="mv-auto-orchestrator-label" className="block text-xs text-port-text-muted">Orchestrator</span>diff --git a/client/src/components/musicVideo/AutopilotPanel.jsx b/client/src/components/musicVideo/AutopilotPanel.jsxindex 5aa9a43624..807eee454f 100644--- a/client/src/components/musicVideo/AutopilotPanel.jsx+++ b/client/src/components/musicVideo/AutopilotPanel.jsx@@ -21,11 +21,11 @@ const POOL_TOOL_IDS = new Set(POOL_TOOLS.map((t) => t.id));const STATUS_LABELS = {running: 'Running', stopped: 'Paused', 'limit-reached': 'Stopped at a limit', blocked: 'Blocked',- 'needs-replan': 'Setup changed', completed: 'Finished', 'needs-human': 'Needs you', failed: 'Failed', canceled: 'Cancelled',+ 'needs-replan': 'Setup changed', 'awaiting-video': 'Stills done', completed: 'Finished', 'needs-human': 'Needs you', failed: 'Failed', canceled: 'Cancelled',};const STATUS_TONES = {running: 'text-port-accent', stopped: 'text-port-warning', 'limit-reached': 'text-port-warning', blocked: 'text-port-warning',- 'needs-replan': 'text-port-warning', completed: 'text-port-success', 'needs-human': 'text-port-warning',+ 'needs-replan': 'text-port-warning', 'awaiting-video': 'text-port-warning', completed: 'text-port-success', 'needs-human': 'text-port-warning',failed: 'text-port-error', canceled: 'text-port-text-muted',};const STEP_TONES = { completed: 'text-port-success', failed: 'text-port-error', canceled: 'text-port-text-muted', refused: 'text-port-text-muted' };diff --git a/client/src/hooks/useMusicVideoProduction.js b/client/src/hooks/useMusicVideoProduction.jsindex eae04c62ac..ab064dec33 100644--- a/client/src/hooks/useMusicVideoProduction.js+++ b/client/src/hooks/useMusicVideoProduction.js@@ -16,6 +16,7 @@ const OUTCOME_TOASTS = {'limit-reached': (run) => toast.info(`Production stopped at its limit: ${run.stopReason || ''}`),blocked: (run) => toast.info(`Production is blocked: ${run.stopReason || 'no allowed route can continue'}`),'needs-replan': () => toast.info('The creative setup changed — resume to continue against the new setup'),+ 'awaiting-video': () => toast.info('Every shot has its still. Resume production to make the clips'),failed: (run) => toast.error(`Production failed: ${run.stopReason || run.error || 'unknown error'}`),};diff --git a/client/src/lib/musicVideoAttention.js b/client/src/lib/musicVideoAttention.jsindex d66be8f8d9..13d7db0b76 100644--- a/client/src/lib/musicVideoAttention.js+++ b/client/src/lib/musicVideoAttention.js@@ -176,7 +176,7 @@ function staleApprovalItem(project, readiness, stage) {// Auto-review states that wait on the director (#10156): a limit, an unverifiable// review, or a halted run. `running` is live work, not a request for the user.const AUTO_REVIEW_PARKED = new Set(['needs-human', 'limit-reached', 'stopped']);-const PRODUCTION_PARKED = new Set(['limit-reached', 'needs-human', 'blocked', 'needs-replan']);+const PRODUCTION_PARKED = new Set(['limit-reached', 'needs-human', 'blocked', 'needs-replan', 'awaiting-video']);// The header next-action ids that resume the autonomous run (see deriveNextAction).const RESUME_AUTONOMOUS_IDS = new Set(['resume-autonomous', 'retry-autonomous']);const AUTONOMOUS_PARKED = new Set(['awaiting-approval', 'needs-human', 'stopped', 'failed']);diff --git a/client/src/lib/musicVideoAutonomous.js b/client/src/lib/musicVideoAutonomous.jsindex cc01f4b427..4761230242 100644--- a/client/src/lib/musicVideoAutonomous.js+++ b/client/src/lib/musicVideoAutonomous.js@@ -39,6 +39,7 @@ export {export const AUTONOMOUS_CHECKPOINT_LABELS = Object.freeze({...Object.fromEntries(AUTONOMOUS_STAGES.map((stage) => [stage.id, stage.label])),cast: 'Cast & Sets',+ stills: 'Stills',});// Production review stages the run may approve itself (`brief.autoApprove`).@@ -83,6 +84,8 @@ export const emptyAutonomousDraft = () => ({llmStages: {},// Review & revise the lyric draft with a second pass.lyricsReview: false,+ // Make (and, when orchestrated, check) every still, then wait for me before any video.+ stopBeforeVideo: false,runMode: 'checkpoints',orchestrator: { providerId: '', model: '', effort: '' },maxReviewAttempts: String(AUTONOMOUS_DEFAULT_LIMITS.maxReviewAttempts),@@ -155,6 +158,7 @@ export function autonomousRequestFromDraft(draft, { providerId, model, effort }...(draft.characterStyleId ? { characterStyleId: draft.characterStyleId } : {}),...(llmStages ? { llmStages } : {}),...(draft.lyricsReview === true ? { lyricsReview: true } : {}),+ ...(draft.stopBeforeVideo === true ? { stopBeforeVideo: true } : {}),...(providerId ? { providerId, ...(model ? { model } : {}), ...(effort ? { effort } : {}) } : {}),};}diff --git a/client/src/lib/musicVideoStages.js b/client/src/lib/musicVideoStages.jsindex 472c42558b..26c9bf1c59 100644--- a/client/src/lib/musicVideoStages.js+++ b/client/src/lib/musicVideoStages.js@@ -39,7 +39,7 @@ const LEGACY_STAGE_IDS = { compose: 'produce' };export const isStageId = (value) => MUSIC_VIDEO_STAGES.some((stage) => stage.id === value);/** A production run in one of these states can still be resumed (or is live). */-export const RESUMABLE_RUN_STATUSES = new Set(['running', 'stopped', 'limit-reached', 'blocked', 'needs-replan']);+export const RESUMABLE_RUN_STATUSES = new Set(['running', 'stopped', 'limit-reached', 'blocked', 'needs-replan', 'awaiting-video']);// A stopped run that needs the director's attention rather than a click on Resume.const RUN_BLOCKED_STATUSES = new Set(['limit-reached', 'blocked', 'needs-replan', 'needs-human', 'failed']);const CAST_WORKING = new Set(['directing', 'imaging', 'assembling']);@@ -184,7 +184,7 @@ export function listPreviewSources(project, { finalVideoSrc = null, liveFirst =// A stopped run can be resumed as is; the others need the director first.const PRODUCTION_RUN_LABELS = {running: 'Production running', stopped: 'Production paused', blocked: 'Production blocked',- 'limit-reached': 'Production at its limit', 'needs-replan': 'Production needs a replan',+ 'limit-reached': 'Production at its limit', 'needs-replan': 'Production needs a replan', 'awaiting-video': 'Production stills done',};/**@@ -421,7 +421,7 @@ export function deriveNextAction(project, {if (run.status === 'running' && !run.interrupted) return { id: 'stop-production', kind: 'run', label: 'Stop production', shortLabel: 'Stop', runId: run.id };return {id: 'resume-production', kind: 'run', runId: run.id, acceptBasis: run.status === 'needs-replan',- label: run.status === 'needs-replan' ? 'Resume with new setup' : 'Resume production',+ label: run.status === 'needs-replan' ? 'Resume with new setup' : run.status === 'awaiting-video' ? 'Make the clips' : 'Resume production',shortLabel: 'Resume',};}diff --git a/server/lib/musicVideoAutonomous.js b/server/lib/musicVideoAutonomous.jsindex a1227db83d..b3d4a811b9 100644--- a/server/lib/musicVideoAutonomous.js+++ b/server/lib/musicVideoAutonomous.js@@ -260,6 +260,8 @@ export function normalizeAutonomousBrief(raw = {}) {// The orchestrator clears every review point itself, so it parks at none....(orchestrator ? { checkpoints: [] } : {}),orchestrator,+ // Production makes every still, then the run waits on `stills` before any clip.+ stopBeforeVideo: raw.stopBeforeVideo === true,origin: {kind: AUTONOMOUS_ORIGINS.includes(origin.kind) ? origin.kind : 'manual',ideaId: clean(origin.ideaId, 80) || null,diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.jsindex f95aa759e1..725cc45856 100644--- a/server/lib/musicVideoValidation.js+++ b/server/lib/musicVideoValidation.js@@ -949,6 +949,8 @@ export const musicVideoProductionStartSchema = z.object({authoring: musicVideoAuthoringSchema.optional(),providerId: z.string().min(1).max(200).nullable().optional(),model: z.string().min(1).max(200).nullable().optional(),+ // 'clips': make every still, then stop as `awaiting-video` before any clip.+ stopBefore: z.enum(['clips']).nullable().optional(),}).strict();// Resume may RAISE a limit; `acceptBasis` continues against a changed creative setup;@@ -957,6 +959,8 @@ export const musicVideoProductionResumeSchema = z.object({limits: musicVideoProductionLimitsSchema.partial().optional(),acceptBasis: z.boolean().optional(),pool: z.array(musicVideoProductionRouteSchema).max(12).optional(),+ // null goes on to the clips; omitted keeps a running stills-only stop (a finished one goes on).+ stopBefore: z.enum(['clips']).nullable().optional(),}).strict();// ---- Fully-autonomous run: one prompt → lyrics → Suno song → video --------------@@ -1044,6 +1048,8 @@ export const musicVideoAutonomousStartSchema = z.object({// director would (no checkpoints). Approval authority — the route requires a// signed-in session for it.orchestrator: musicVideoLlmSchema.optional(),+ // Make and review every still, then wait for the director before any clip.+ stopBeforeVideo: z.boolean().optional(),origin: z.object({kind: z.enum(AUTONOMOUS_ORIGINS).optional(),ideaId: z.string().max(80).nullable().optional(),@@ -1071,6 +1077,8 @@ export const musicVideoAutonomousResumeSchema = z.object({maxGenerations: z.number().int().min(AUTONOMOUS_LIMIT_BOUNDS.maxGenerations.min).max(AUTONOMOUS_LIMIT_BOUNDS.maxGenerations.max).optional(),maxReviewAttempts: z.number().int().min(AUTONOMOUS_LIMIT_BOUNDS.maxReviewAttempts.min).max(AUTONOMOUS_LIMIT_BOUNDS.maxReviewAttempts.max).optional(),}).strict().optional(),+ // Add tools to the brief (e.g. a video tool once the stills are approved); the production pool follows.+ addTools: z.array(z.enum(MUSIC_VIDEO_AUTOMATION_TOOL_IDS)).max(MUSIC_VIDEO_AUTOMATION_TOOL_IDS.length).optional(),// Replace the brief's auto-approve grant ("auto-approve the rest")....musicVideoAutoApproveFields,}).strict();diff --git a/server/services/musicVideo/autonomousService.js b/server/services/musicVideo/autonomousService.jsindex 62a74f58fd..ca172bf558 100644--- a/server/services/musicVideo/autonomousService.js+++ b/server/services/musicVideo/autonomousService.js@@ -4,6 +4,7 @@ import { ALIGNMENT_UNVERIFIED_PROBLEM, assertProductionApproval, productionAlignimport { CAST_SETS_WORKING } from './castAndSets.js';import { applyTreatmentPatch, applyTreatmentToProject } from './treatment.js';import { codeFirstProductionAssets, normalizeMusicVideoProductionPolicy } from '../../lib/musicVideoMediumPlan.js';+import { MUSIC_VIDEO_AUTOMATION_TOOL_IDS } from '../../lib/musicVideoAutomation.js';/*** Fully-autonomous Music Video — the run orchestrator.@@ -144,6 +145,8 @@ const defaults = {closeFeedback: async (...args) => (await import('./productionReviewService.js')).closeProductionFeedback(...args),reviseFromFeedback: async (...args) => (await import('./productionReviewService.js')).reviseProductionFromFeedback(...args),guideImagePath: async (artifact) => (await import('./devArtifactStore.js')).resolveDevArtifactFile(artifact.file),+ // A gallery image (a Cast & Sets plate, a production still) the orchestrator looks at.+ galleryImagePath: async (filename) => (await import('../../lib/pathSafety.js')).resolveGalleryImage(filename),finalReviewFrames: async (jobId) => (await import('./orchestratorReview.js')).captureFinalReviewFrames(jobId),// The overlay text pass before a final render: resolves the finished check.checkOverlayText: async (projectId) => (await import('./overlayTextService.js')).startOverlayTextCheck(projectId).then((started) => started.done),@@ -568,14 +571,31 @@ async function fillStoryboard(projectId, fill = []) {});}+const ART_REVIEW_PLATES = 6;++/** The Cast & Sets renders the art review looks at: the character sheet first, then the plates in plan order. */+async function castAndSetsImagePaths(project) {+ const stage = project.castAndSets || {};+ const keys = Object.keys(stage.images || {}).filter((key) => stage.images[key]?.status === 'done' && stage.images[key].imageId)+ .sort((a, b) => Number(stage.plan?.[b]?.kind === 'character') - Number(stage.plan?.[a]?.kind === 'character'));+ const paths = [];+ for (const key of keys) {+ if (paths.length >= ART_REVIEW_PLATES) break;+ const path = await deps.galleryImagePath(stage.images[key].imageId).catch(() => null);+ if (path) paths.push(path);+ }+ return paths;+}+async function reviewArt(run, project) {const { buildArtReviewPrompt } = await reviewModule();const draft = project.productionReview?.draft || {};const guide = project.devArtifacts?.find((a) => a.id === draft.guideArtifactId && !a.deleted);const image = guide?.mimeType?.startsWith('image/') ? await deps.guideImagePath(guide).catch(() => null) : null;- // The guide sheet is not redrawn after a text revision, so a re-review is told it shows the earlier text.- const sheetPredatesEdits = !!image && revisionsSpent(await latestRun(project.id), 'art') > 0;- return askReview(run, 'art', buildArtReviewPrompt({ ...ideaOf(run), concept: project.concept, draft, hasImage: !!image, sheetPredatesEdits }), image ? [image] : []);+ const images = [...(image ? [image] : []), ...await castAndSetsImagePaths(project)];+ // The sheet and plates are not redrawn after a text revision, so a re-review is told they show the earlier text.+ const sheetPredatesEdits = images.length > 0 && revisionsSpent(await latestRun(project.id), 'art') > 0;+ return askReview(run, 'art', buildArtReviewPrompt({ ...ideaOf(run), concept: project.concept, draft, hasImage: images.length > 0, sheetPredatesEdits }), images);}async function reviewStoryboard(run, project) {@@ -1168,9 +1188,11 @@ const STAGES = {// The run is not finished until the MP4 exists: stay on produce and let the render's own event settle it.return { output: { renderJobId: render?.jobId || null }, wait: true, step: RENDER_STEP };}+ const pool = briefProductionPool(run.brief, project);const started = await deps.startProduction(project.id, {directive: trimTo([run.brief.prompt, run.brief.guidance].filter(Boolean).join('\n\n'), 4000),- pool: briefProductionPool(run.brief, project),+ pool,+ ...(stopsBeforeClips(project, run, pool) ? { stopBefore: 'clips' } : {}),limits: { ...run.brief.limits, ...(run.brief.budgetUsd != null ? { spendCapUsd: run.brief.budgetUsd } : {}) },// The orchestrator also judges production's plates and drafts when the run has one.reviewer: isOrchestratedRun(run)@@ -1182,6 +1204,99 @@ const STAGES = {},};+// ---- stills before video -----------------------------------------------------------+// A run that asked to stop before video, or whose tools make no video, has+// production make every still and stop before the first clip. The orchestrator+// then checks the stills and has the ones it flags regenerated, up to+// `limits.maxReviewAttempts` rounds; the run then waits on `stills` for the+// director, whose approval goes on to the clips.++const STILLS_BATCH = 6;+const STILL_FIXES_MAX = 1000;++/** Production stops before its clips: the plan needs clips, and the run asked to stop or has no video route. */+function stopsBeforeClips(project, run, pool) {+ const needsClips = codeFirstProductionAssets(project)?.requiredRoutes.video ?? true;+ return needsClips && (run.brief.stopBeforeVideo === true || !pool.some((route) => route.kind === 'video'));+}++/**+ * One review round over every still. Returns the flagged shots that will be+ * regenerated (none once the rounds are spent, or when the reviewer could+ * not see the images).+ */+async function reviewStills(projectId, run) {+ const { buildStillsReviewPrompt } = await reviewModule();+ const project = await getProject(projectId);+ const shots = (project.scenes || []).filter((scene) => scene.referenceImageId);+ const issues = [];+ const reviews = [];+ for (let i = 0; i < shots.length; i += STILLS_BATCH) {+ const listed = [];+ const images = [];+ for (const scene of shots.slice(i, i + STILLS_BATCH)) {+ const path = await deps.galleryImagePath(scene.referenceImageId).catch(() => null);+ if (path) { listed.push(scene); images.push(path); }+ }+ if (!listed.length) continue;+ const review = await askReview(run, 'stills', buildStillsReviewPrompt({ ...ideaOf(run), concept: project.concept,+ cast: project.productionReview?.draft?.cast || '',+ shots: listed.map((scene, n) => ({ image: n + 1, sceneId: scene.sceneId, label: scene.label || '', still: trimTo(scene.framePrompt || scene.prompt, 400) })) }), images);+ reviews.push(review);+ // A review that could not see the stills cannot judge them.+ const known = new Set(listed.map((scene) => scene.sceneId));+ if (review.visual && review.verdict === 'revise') issues.push(...review.issues.filter((issue) => known.has(issue.sceneId)));+ }+ const spent = revisionsSpent(await latestRun(projectId), 'stills');+ const regenerate = spent < reviewLimit(run) ? issues : [];+ const scored = reviews.map((r) => r.score).filter((n) => n != null);+ const why = !reviews.length ? 'No still could be shown to the reviewer. '+ : reviews.some((r) => !r.visual) ? 'The reviewer could not see every still. '+ : issues.length && !regenerate.length ? 'Revision limit reached; accepted the latest stills. ' : '';+ await recordReview(projectId, { checkpoint: 'stills', verdict: regenerate.length ? 'revise' : 'approve',+ score: scored.length ? Math.min(...scored) : null, route: reviews.at(-1)?.route || null, visual: reviews.length > 0 && reviews.every((r) => r.visual),+ notes: trimTo(`${why}${regenerate.length ? `Regenerating ${regenerate.length} still${regenerate.length === 1 ? '' : 's'}. ` : ''}${reviews.map((r) => r.notes).filter(Boolean).join(' ')}`, 1500),+ ...(regenerate.length ? { changes: regenerate.map((issue) => trimTo(`${issue.sceneId}: ${issue.text}`, 300)) } : {}) });+ return regenerate;+}++/**+ * Production made every still. An orchestrated run reviews them and sends the+ * flagged ones back to production; otherwise (or once they pass) the run waits+ * on `stills` for the director.+ */+const settlingStills = new Set();++async function settleStills(projectId, run, productionRunId) {+ // Production announces the stop more than once; one review round answers it.+ if (settlingStills.has(productionRunId)) return;+ settlingStills.add(productionRunId);+ try {+ await reviewOrPark(projectId, run, productionRunId);+ } catch (err) {+ await park(projectId, 'needs-human', { error: trimTo(`The stills review failed: ${err.message}`, 500), errorCode: err.code || 'STILLS_REVIEW_FAILED' });+ } finally {+ settlingStills.delete(productionRunId);+ }+}++async function reviewOrPark(projectId, run, productionRunId) {+ if (isOrchestratedRun(run)) {+ const regenerate = await reviewStills(projectId, run);+ if (regenerate.length) {+ const fixes = new Map();+ for (const issue of regenerate) fixes.set(issue.sceneId, [fixes.get(issue.sceneId), issue.text].filter(Boolean).join(' '));+ const at = new Date().toISOString();+ // Clearing the still is what makes production generate it again; the fixes ride its next prompt.+ await mutateProjectRecord(projectId, (current) => ({ project: { ...current, scenes: (current.scenes || []).map((scene) => (fixes.has(scene.sceneId)+ ? { ...scene, referenceImageId: null, stillFixes: { text: trimTo(fixes.get(scene.sceneId), STILL_FIXES_MAX), at } } : scene)) } }));+ await deps.resumeProduction(projectId, productionRunId, { acceptBasis: true, stopBefore: 'clips' });+ return;+ }+ }+ await park(projectId, 'awaiting-approval', { awaiting: 'stills' });+}+// ---- the advance loop ------------------------------------------------------------const isLoginRequired = (err) => err?.code === 'PUBLISH_LOGIN_REQUIRED';@@ -1459,16 +1574,22 @@ function produceContinuation(run) {export async function resumeAutonomousVideo(projectId, edits = {}, { autoApproveAuthorized = false } = {}) {const { run } = await requireRun(projectId);+ // Tools are only ever added (a video tool once the stills are approved, say); the pool follows.+ const added = (edits.addTools || []).filter((id) => !run.brief.tools.includes(id));+ const toolsPatch = added.length ? MUSIC_VIDEO_AUTOMATION_TOOL_IDS.filter((id) => run.brief.tools.includes(id) || added.includes(id)) : null;+ const tools = toolsPatch || run.brief.tools;// A model swap is validated like Start, then replaces the parked production run's pool (#10473).- const modelsPatch = briefModelsPatch(run.brief, edits.models);+ const modelsPatch = briefModelsPatch({ ...run.brief, tools }, edits.models);assertResumable(run);- if (modelsPatch) await assertBriefVideoModelsCapable(run.brief.tools, modelsPatch);+ if (modelsPatch || toolsPatch) await assertBriefVideoModelsCapable(tools, modelsPatch || run.brief.models || {});// "Auto-approve the rest": replaces the brief's grant (an empty list clears it).const grant = edits.autoApprove !== undefined ? autoApproveGrant(edits.autoApprove, autoApproveAuthorized) : null;const retake = edits.retakeSong === true;if (retake && run.brief.songFrom) throw runError(409, 'SONG_REUSED', 'This run reuses an existing song, so it has no song to retake');if (retake) assertAtSongCheckpoint(run);- const modelsChanged = modelsPatch !== null && JSON.stringify(modelsPatch) !== JSON.stringify(run.brief.models || {});+ const modelsChanged = toolsPatch !== null || (modelsPatch !== null && JSON.stringify(modelsPatch) !== JSON.stringify(run.brief.models || {}));+ // Approving the stills goes on to the clips, including in any new production run.+ const stillsApproved = run.status === 'awaiting-approval' && run.awaiting === 'stills';const limitsPatch = edits.limits ? { ...run.brief.limits, ...edits.limits } : null;// A production run only takes raised limits; refuse a lower one before anything changes.if (edits.limits && run.stage === 'produce' && Object.entries(edits.limits).some(([key, value]) => value != null && value < (run.brief.limits?.[key] ?? 0))) {@@ -1491,8 +1612,10 @@ export async function resumeAutonomousVideo(projectId, edits = {}, { autoApproveconst stage = retake ? 'song' : r.stage;return {status: 'running', awaiting: null, error: null, errorCode: null, processId: PROCESS_ID,- ...(edits.suno || edits.localMusic !== undefined || grant || modelsPatch || limitsPatch ? { brief: {+ ...(edits.suno || edits.localMusic !== undefined || grant || modelsPatch || toolsPatch || limitsPatch || stillsApproved ? { brief: {...r.brief,+ ...(toolsPatch ? { tools: toolsPatch } : {}),+ ...(stillsApproved ? { stopBeforeVideo: false } : {}),...(modelsPatch ? { models: modelsPatch } : {}),...(limitsPatch ? { limits: limitsPatch } : {}),...(edits.suno ? { suno: normalizeSunoOptions({ ...r.brief.suno, ...edits.suno }) } : {}),@@ -1510,6 +1633,11 @@ export async function resumeAutonomousVideo(projectId, edits = {}, { autoApprove};});if (retakenTrackId) await unlinkRunTrack(projectId, out.run.id, retakenTrackId);+ // The project's brief tools gate what production may submit (a video tool for clips), so they follow too.+ if (toolsPatch) {+ await mutateProjectRecord(projectId, (current) => ({ project: { ...current,+ automation: { ...current.automation, tools: [...new Set([...(current.automation?.tools || []), ...added])] } } }));+ }const { resume } = produceContinuation(out.run);if (resume.kind === 'final-revision') {// The orchestrator's footage revision picks up where it stopped. One that@@ -1542,7 +1670,7 @@ export async function resumeAutonomousVideo(projectId, edits = {}, { autoApprovereturn { project: presentProjectAutonomousRun(latest), run: presentAutonomousRun(projectAutonomousRun(latest)) };}if (resume.kind === 'production') {- return resumeDelegatedProduction(projectId, out.run, { swapModels: modelsChanged, limits: edits.limits });+ return resumeDelegatedProduction(projectId, out.run, { swapModels: modelsChanged, limits: edits.limits, stillsApproved });}advanceInBackground(projectId);return { project: out.project, run: presentAutonomousRun(out.run) };@@ -1564,8 +1692,8 @@ function briefModelsPatch(brief, models) {}// Production runs that can still deliver the footage: live, parked or finished.-const ADOPTABLE_PRODUCTION = new Set(['running', 'completed', 'limit-reached', 'blocked', 'needs-replan', 'needs-human', 'stopped']);-const PRODUCTION_LIVE = new Set(['running', 'limit-reached', 'blocked', 'needs-replan', 'needs-human', 'stopped']);+const ADOPTABLE_PRODUCTION = new Set(['running', 'completed', 'limit-reached', 'blocked', 'needs-replan', 'needs-human', 'stopped', 'awaiting-video']);+const PRODUCTION_LIVE = new Set(['running', 'limit-reached', 'blocked', 'needs-replan', 'needs-human', 'stopped', 'awaiting-video']);/*** Hand a resumed run back to production. It follows the newest production run started@@ -1574,7 +1702,7 @@ const PRODUCTION_LIVE = new Set(['running', 'limit-reached', 'blocked', 'needs-r* when that run is already complete. No production run left to follow — or a model* swap on one that cannot resume — starts a new one from the brief by re-entering `produce`.*/-async function resumeDelegatedProduction(projectId, run, { swapModels = false, limits } = {}) {+async function resumeDelegatedProduction(projectId, run, { swapModels = false, limits, stillsApproved = false } = {}) {const project = await getProject(projectId);const runs = Array.isArray(project.productionRuns) ? project.productionRuns : [];const current = runs.find((r) => r.id === run.output.productionRunId) || null;@@ -1596,6 +1724,9 @@ async function resumeDelegatedProduction(projectId, run, { swapModels = false, l}if (adopt.status === 'completed') {await finishFromProduction(projectId, adopt.id);+ } else if (adopt.status === 'awaiting-video' && !stillsApproved) {+ // Only approving the stills goes on to the clips; any other resume reviews them (again).+ settleStills(projectId, run, adopt.id).catch((err) => console.error(`❌ Autonomous music video ${short(run.id)} stills review: ${err.message}`));} else {// Resuming a "running" run is safe and re-pins one left by a previous server process.const productionLimits = limits ? Object.fromEntries(Object.entries(limits).filter(([, v]) => v != null)) : undefined;@@ -1658,7 +1789,7 @@ const PRODUCTION_PARKED = new Set(['limit-reached', 'blocked', 'needs-replan', 'async function onProductionEvent({ projectId, runId, run: production }) {// Production emits on every step; only a terminal or parked state concerns us, and// the project is read only once one arrives.- if (!projectId || !(['completed', 'failed', 'canceled'].includes(production?.status) || PRODUCTION_PARKED.has(production?.status))) return;+ if (!projectId || !(['completed', 'failed', 'canceled', 'awaiting-video'].includes(production?.status) || PRODUCTION_PARKED.has(production?.status))) return;const project = await getProject(projectId).catch(() => null);const run = projectAutonomousRun(project);if (!run || run.stage !== 'produce' || run.output.productionRunId !== runId) return;@@ -1674,6 +1805,8 @@ async function onProductionEvent({ projectId, runId, run: production }) {// Production canceled on its own (not by canceling this run): park, so Resume can adopt// the director's replacement run or start a new one.await park(projectId, 'needs-human', { error: reason || 'Production was canceled', errorCode: 'PRODUCTION_CANCELED' });+ } else if (production.status === 'awaiting-video') {+ if (run.status === 'running') await settleStills(projectId, run, runId);} else if (PRODUCTION_PARKED.has(production.status) && run.status === 'running') {await park(projectId, 'needs-human', { error: reason || `Production is ${production.status}`, errorCode: 'PRODUCTION_PARKED' });}diff --git a/server/services/musicVideo/autonomousService.test.js b/server/services/musicVideo/autonomousService.test.jsindex 9467e69b84..157125c16e 100644--- a/server/services/musicVideo/autonomousService.test.js+++ b/server/services/musicVideo/autonomousService.test.js@@ -1390,17 +1390,19 @@ describe('orchestrated mode (brief.orchestrator)', () => {const ORCHESTRATOR = { providerId: 'orch', model: 'judge', effort: 'high' };let answers;const checkpointOf = (prompt) => (prompt.includes('the LYRICS') ? 'lyrics' : prompt.includes('SOUND AND LOOK') ? 'style'- : prompt.includes('finished SONG') ? 'song' : prompt.includes('ART DIRECTION') ? 'art' : prompt.includes('STORYBOARD') ? 'storyboard' : 'final');+ : prompt.includes('finished SONG') ? 'song' : prompt.includes('ART DIRECTION') ? 'art' : prompt.includes('STORYBOARD') ? 'storyboard'+ : prompt.includes('the STILLS') ? 'stills' : 'final');const reviews = () => (runOf().orchestration?.reviews || []).map((r) => `${r.checkpoint}:${r.verdict}`);beforeEach(() => {answers = {};- doubles.orchestrate = vi.fn(async ({ prompt }) => {+ doubles.orchestrate = vi.fn(async ({ prompt, images = [] }) => {const checkpoint = checkpointOf(prompt);const answer = (answers[checkpoint] || []).shift() || { verdict: 'approve', score: 8, notes: 'Ready.' };if (answer instanceof Error) throw answer;- return { text: `Here is my call:\n${JSON.stringify(answer)}`, route: { providerId: 'orch', model: 'judge' }, visual: false };+ return { text: `Here is my call:\n${JSON.stringify(answer)}`, route: { providerId: 'orch', model: 'judge' }, visual: images.length > 0 };});+ doubles.galleryImagePath = vi.fn(async (filename) => `/gallery/${filename}`);doubles.alignLyrics = stub('align', async () => {});doubles.finalReviewFrames = vi.fn(async () => ({ images: [], frameTimes: [], facts: { error: 'no file in tests' }, cleanup: async () => {} }));service.__setAutonomousDepsForTests(doubles);@@ -1431,6 +1433,39 @@ describe('orchestrated mode (brief.orchestrator)', () => {expect(doubles.orchestrate).toHaveBeenCalledWith(expect.objectContaining({ orchestrator: ORCHESTRATOR }));});+ // Uniquely catches a run with no video tool spending on clips, the orchestrator approving stills it never saw,+ // or a flagged still not going back to production with the fix.+ it('stops production after the stills, regenerates the ones the orchestrator flags, then waits for the director', async () => {+ await service.startAutonomousVideo({ prompt: 'p', tools: ['image:local'], orchestrator: ORCHESTRATOR }, { autoApproveAuthorized: true });+ await vi.waitFor(() => expect(doubles.startProduction).toHaveBeenCalledOnce());+ expect(doubles.startProduction).toHaveBeenCalledWith('mv-auto', expect.objectContaining({ stopBefore: 'clips' }));+ store.get('mv-auto').scenes = [+ { sceneId: 'mvs-a', label: 'Intro', framePrompt: 'a skater at dusk', referenceImageId: 'a1.png' },+ { sceneId: 'mvs-b', label: 'Verse', framePrompt: 'a boardroom', referenceImageId: 'b1.png' },+ ];+ answers.stills = [{ verdict: 'revise', score: 5, notes: 'One extra hand.', issues: [{ sceneId: 'mvs-b', text: 'The chair has three hands on it.' }, { sceneId: 'mvs-x', text: 'not a shot' }] }];+ await service.__testing.onProductionEvent({ projectId: 'mv-auto', runId: 'mvpr-1', run: { status: 'awaiting-video' } });+ expect(doubles.orchestrate).toHaveBeenLastCalledWith(expect.objectContaining({ images: ['/gallery/a1.png', '/gallery/b1.png'] }));+ expect(store.get('mv-auto').scenes[1]).toMatchObject({ referenceImageId: null, stillFixes: { text: 'The chair has three hands on it.' } });+ expect(store.get('mv-auto').scenes[0].referenceImageId).toBe('a1.png');+ expect(doubles.resumeProduction).toHaveBeenCalledWith('mv-auto', 'mvpr-1', { acceptBasis: true, stopBefore: 'clips' });+ expect(runOf().status).toBe('running');++ // The regenerated still passes: the run waits for the director, and approving goes on to the clips with the added video tool.+ store.get('mv-auto').scenes[1].referenceImageId = 'b2.png';+ await service.__testing.onProductionEvent({ projectId: 'mv-auto', runId: 'mvpr-1', run: { status: 'awaiting-video' } });+ expect(reviews().filter((r) => r.startsWith('stills'))).toEqual(['stills:revise', 'stills:approve']);+ expect(runOf()).toMatchObject({ status: 'awaiting-approval', awaiting: 'stills' });+ store.get('mv-auto').productionRuns = [{ id: 'mvpr-1', status: 'awaiting-video', createdAt: new Date().toISOString() }];+ doubles.resumeProduction.mockClear();+ await service.resumeAutonomousVideo('mv-auto', { addTools: ['video:local'] });+ expect(runOf().brief).toMatchObject({ tools: ['image:local', 'video:local'], stopBeforeVideo: false });+ expect(store.get('mv-auto').automation.tools).toEqual(['image:local', 'video:local']);+ expect(doubles.resumeProduction).toHaveBeenCalledWith('mv-auto', 'mvpr-1', expect.objectContaining({+ pool: expect.arrayContaining([expect.objectContaining({ kind: 'video', mode: 'local' })]) }));+ expect(doubles.resumeProduction.mock.calls[0][2].stopBefore).toBeUndefined();+ });+it('stops revising at the review limit and keeps a Suno song rather than spend credits on a retake', async () => {answers.lyrics = Array.from({ length: 5 }, (_, i) => ({ verdict: 'revise', notes: 'Again.', lyrics: `take ${i + 1}` }));answers.song = [{ verdict: 'retake', notes: 'Muddy mix.' }];@@ -1498,6 +1533,9 @@ describe('orchestrated mode (brief.orchestrator)', () => {],scenes: [{ sceneId: 'shot', startSec: 0, endSec: 20, label: 'Chorus' }],devArtifacts: [{ id: 'guide', version: 1, file: 'guide.html', mimeType: 'text/html' }],+ // The art review looks at the renders, character sheet first.+ castAndSets: { status: 'approved', plan: { stage: { kind: 'set' }, lead: { kind: 'character' } },+ images: { stage: { status: 'done', imageId: 'stage.png' }, lead: { status: 'done', imageId: 'lead.png' }, broken: { status: 'failed', imageId: null } } },productionReview: { draft: {cast: 'A dancer', environments: 'Theatre', visualLanguage: 'Ink silhouettes', motionLanguage: 'Slow orbit',guideArtifactId: 'guide', lyricsMode: 'vocal', timingStatus: 'provisional', timingNotes: '',@@ -1544,6 +1582,9 @@ describe('orchestrated mode (brief.orchestrator)', () => {expect(reviews()).toEqual(['lyrics:approve', 'style:approve', 'song:approve', 'art:revise', 'art:approve', 'alignment:approve', 'storyboard:revise', 'storyboard:approve', 'text:approve', 'final:revise', 'text:approve', 'final:approve']);expect(runOf().orchestration.reviews.at(-3)).toMatchObject({ issues: [{ atSec: 18, text: 'Static hold' }], notes: expect.stringContaining('Judged without frames') });expect(doubles.finalReviewFrames.mock.calls.map(([jobId]) => jobId)).toEqual(['render-1', 'render-2']);+ const artCalls = doubles.orchestrate.mock.calls.filter(([{ prompt }]) => prompt.includes('ART DIRECTION'));+ expect(artCalls[0][0].images).toEqual(['/gallery/lead.png', '/gallery/stage.png']);+ expect(runOf().orchestration.reviews.find((r) => r.checkpoint === 'art')).toMatchObject({ visual: true });});describe('final-video revision of footage', () => {diff --git a/server/services/musicVideo/castAndSetsDirection.js b/server/services/musicVideo/castAndSetsDirection.jsindex 14f50d81a0..da30e8f436 100644--- a/server/services/musicVideo/castAndSetsDirection.js+++ b/server/services/musicVideo/castAndSetsDirection.js@@ -68,14 +68,16 @@ const MOOD_ITEM_TEXT = 280;// ---- medium ------------------------------------------------------------------/**- * The medium the check-in is directed in. A code-first production policy, or a- * brief that selected code tools and no video tool, is procedural; everything- * else (an image-only brief included) stays photographic. Tools and policy are- * read together because either can be saved without the other.+ * The medium the check-in is directed in. A code-first production policy with+ * no generated footage, or a brief that selected code tools and no video tool,+ * is procedural; everything else (an image-only brief included) stays+ * photographic, so footage always has a character sheet to hold identity.+ * Tools and policy are read together because either can be saved without the other.*/export function castAndSetsMedium(project) {if (!musicVideoAllowsMedia(project, 'image')) return 'procedural';- if (project?.productionPolicy?.strategy === 'code-first') return 'procedural';+ const policy = project?.productionPolicy;+ if (policy?.strategy === 'code-first' && !(policy.maxGeneratedVideoPercent > 0 && musicVideoAllowsMedia(project, 'video'))) return 'procedural';const tools = briefTools(project);return tools.some((t) => t.startsWith('code:')) && !tools.some((t) => t.startsWith('video:')) ? 'procedural' : 'photographic';}diff --git a/server/services/musicVideo/castAndSetsDirection.test.js b/server/services/musicVideo/castAndSetsDirection.test.jsindex ec53d456d4..cf211171d9 100644--- a/server/services/musicVideo/castAndSetsDirection.test.js+++ b/server/services/musicVideo/castAndSetsDirection.test.js@@ -172,6 +172,9 @@ describe('Cast & Sets procedural medium', () => {const procedural = { ...project, productionPolicy: { strategy: 'code-first', maxGeneratedVideoPercent: 0 } };it('resolves the medium from the production policy and the brief tools together', () => {expect(castAndSetsMedium(procedural)).toBe('procedural');+ // Code-first with a generated-footage allowance needs a character sheet for that footage.+ expect(castAndSetsMedium({ ...project, productionPolicy: { strategy: 'code-first', maxGeneratedVideoPercent: 20 } })).toBe('photographic');+ expect(castAndSetsMedium({ ...project, mediaMode: 'code-images', productionPolicy: { strategy: 'code-first', maxGeneratedVideoPercent: 20 } })).toBe('procedural');expect(castAndSetsMedium({ automation: { tools: ['image:codex', 'code:render'] } })).toBe('procedural');// A video tool, an image-only brief and an untouched project stay photographic.expect(castAndSetsMedium({ automation: { tools: ['image:codex', 'code:render', 'video:local'] } })).toBe('photographic');diff --git a/server/services/musicVideo/orchestratorReview.js b/server/services/musicVideo/orchestratorReview.jsindex dc3b9e49b8..0ab598bd21 100644--- a/server/services/musicVideo/orchestratorReview.js+++ b/server/services/musicVideo/orchestratorReview.js@@ -78,13 +78,13 @@ Return JSON only:}export function buildArtReviewPrompt({ prompt, guidance, concept, draft, hasImage, sheetPredatesEdits = false }) {- return `You are the director reviewing the ART DIRECTION for a music video before any shot is planned or rendered. ${UNTRUSTED}${hasImage ? ` The attached image is the cast and environment sheet.${sheetPredatesEdits ? ' It was drawn before your earlier text revisions, so judge the text on its own and do not ask it to match the sheet.' : ''}` : ''}+ return `You are the director reviewing the ART DIRECTION for a music video before any shot is planned or rendered. ${UNTRUSTED}${hasImage ? ` The attached images are the cast and environment renders: the character sheet and set plates.${sheetPredatesEdits ? ' They were drawn before your earlier text revisions, so judge the text on its own and do not ask it to match them.' : ''}` : ''}${ideaBlock({ prompt, guidance })}${block('VISUAL CONCEPT', [concept?.prompt, concept?.style].filter(Boolean).join('\n'))}${ORCHESTRATOR_ART_FIELDS.map((key) => block(key.toUpperCase(), draft?.[key])).join('\n')}-Judge: is the cast specific and consistent enough to draw the same subject in every shot, do environments, visual language and motion language fit the concept and each other${hasImage && !sheetPredatesEdits ? ', and does the sheet match the text' : ''}? ${RULES}+Judge: is the cast specific and consistent enough to draw the same subject in every shot, do environments, visual language and motion language fit the concept and each other${hasImage && !sheetPredatesEdits ? ', do the renders match the text, and are they free of anatomy errors and stray text' : ''}? ${RULES}Return JSON only:{"verdict":"approve|revise","score":1-10,"notes":"why","changes":[{"field":"cast|environments|visualLanguage|motionLanguage","text":"the COMPLETE replacement text for that field"}]}List changes only when verdict is revise.`;@@ -103,6 +103,24 @@ ${incomplete.length ? `These shots have blank fields that must be filled: ${incoList changes only when verdict is revise; "fill" only for blank fields.`;}+/**+ * Production's stills, a batch at a time, before any clip is made. Image N is+ * shot N in SHOTS; the reviewer flags only stills a regeneration should fix.+ */+export function buildStillsReviewPrompt({ prompt, guidance, concept, cast, shots }) {+ return `You are the director checking the STILLS for a music video before any of them is animated. The attached images are shown in order: image 1 is the first shot in SHOTS, image 2 the second, and so on. ${UNTRUSTED}++${ideaBlock({ prompt, guidance })}+${block('VISUAL CONCEPT', [concept?.prompt, concept?.style].filter(Boolean).join('\n'))}+${block('CAST', cast)}+${block('SHOTS', JSON.stringify(shots, null, 2))}++Judge each still: correct anatomy (hands, limbs, faces), the same recognizable person wherever a cast member appears (face, hair, wardrobe as the cast describes them, and consistent across these stills), no stray or garbled text in frame, the shot it was asked for, and one consistent look that fits the concept. ${RULES}+Return JSON only:+{"verdict":"approve|revise","score":1-10,"notes":"why","issues":[{"sceneId":"a shot id","text":"the visible problem and what the regenerated still must show instead"}]}+List issues only when verdict is revise, one per still that must be regenerated.`;+}+export function buildFinalReviewPrompt({ prompt, guidance, concept, facts, frameTimes }) {return `You are the director watching the FINAL music video. The attached contact sheets hold frames sampled in order at these times (seconds): ${frameTimes.map((t) => Math.round(t * 10) / 10).join(', ')}. ${UNTRUSTED}@@ -154,6 +172,10 @@ export function parseOrchestratorVerdict(raw, checkpoint) {fill: (Array.isArray(parsed.fill) ? parsed.fill : []).filter((f) => text(f?.sceneId, 200)).slice(0, 200).map((f) => ({ sceneId: text(f.sceneId, 200),...Object.fromEntries(STORYBOARD_FILL_FIELDS.map((k) => [k, text(f[k], CHANGE_MAX)]).filter(([, v]) => v)) })) };+ case 'stills':+ return { ...out, issues: (Array.isArray(parsed.issues) ? parsed.issues : []).slice(0, CHANGES_MAX)+ .filter((i) => text(i?.sceneId, 200) && text(i?.text, CHANGE_MAX))+ .map((i) => ({ sceneId: text(i.sceneId, 200), text: text(i.text, 500) })) };case 'final':return { ...out, issues: (Array.isArray(parsed.issues) ? parsed.issues : []).slice(0, CHANGES_MAX).filter((i) => text(i?.text, 500))diff --git a/server/services/musicVideo/orchestratorReview.test.js b/server/services/musicVideo/orchestratorReview.test.jsindex 70a32bba88..8b94797130 100644--- a/server/services/musicVideo/orchestratorReview.test.js+++ b/server/services/musicVideo/orchestratorReview.test.js@@ -29,11 +29,11 @@ describe('parseOrchestratorVerdict', () => {// After a text revision the guide sheet is not redrawn, so a re-review must not// keep asking the text to match a sheet drawn from the earlier text.describe('buildArtReviewPrompt', () => {- it('tells a re-review that the sheet predates its text revisions', () => {+ it('tells a re-review that the renders predate its text revisions', () => {const base = { prompt: 'p', concept: {}, draft: { cast: 'A dancer' }, hasImage: true };- expect(buildArtReviewPrompt(base)).toContain('does the sheet match the text');+ expect(buildArtReviewPrompt(base)).toContain('do the renders match the text');const again = buildArtReviewPrompt({ ...base, sheetPredatesEdits: true });expect(again).toContain('drawn before your earlier text revisions');- expect(again).not.toContain('does the sheet match the text');+ expect(again).not.toContain('do the renders match the text');});});diff --git a/server/services/musicVideo/production.js b/server/services/musicVideo/production.jsindex 9c7a5b1e9a..3d04e32d67 100644--- a/server/services/musicVideo/production.js+++ b/server/services/musicVideo/production.js@@ -59,9 +59,11 @@ const PRODUCTION_LIMIT_BOUNDS = Object.freeze({const PRODUCTION_DIRECTIVE_MAX = 4000;const PRODUCTION_POOL_MAX = 12;const PRODUCTION_STATUSES = Object.freeze([- 'running', 'stopped', 'limit-reached', 'blocked', 'needs-replan', 'completed', 'needs-human', 'failed', 'canceled',+ 'running', 'stopped', 'limit-reached', 'blocked', 'needs-replan', 'awaiting-video', 'completed', 'needs-human', 'failed', 'canceled',]);-const RESUMABLE = new Set(['running', 'stopped', 'limit-reached', 'blocked', 'needs-replan']);+// `awaiting-video`: a stills-only run (`stopBefore: 'clips'`) made every frame; Resume goes on to the clips.+const RESUMABLE = new Set(['running', 'stopped', 'limit-reached', 'blocked', 'needs-replan', 'awaiting-video']);+const STOP_BEFORE = new Set(['clips']);/** Statuses Resume accepts. */export const PRODUCTION_RESUMABLE_STATUSES = RESUMABLE;const LIVE_STEP = new Set(['reserved', 'queued']);@@ -204,7 +206,7 @@ export const poolHasRoute = (run, route) => !!route && run.pool.some((r) => rout* when unknown); a dollar cap requires every route to have a known price.*/export function startProductionOnProject(project, {- directive = '', pool, limits, reviewer = {}, authoring = null, processId, pricing = {},+ directive = '', pool, limits, reviewer = {}, authoring = null, processId, pricing = {}, stopBefore = null,}, now = new Date().toISOString()) {const live = activeProductionRun(project);if (live) throw productionError(409, 'PRODUCTION_IN_PROGRESS', 'Finish, cancel or resume the existing production run first', { runId: live.id });@@ -246,7 +248,9 @@ export function startProductionOnProject(project, {usage: { generations: 0, spentUsd: 0 },planned: false,reviewRunId: null,- pilot: { scenes: null },+ // A stills-only run makes no clip, so it has no clip pilot to prove first.+ stopBefore: STOP_BEFORE.has(stopBefore) ? stopBefore : null,+ pilot: STOP_BEFORE.has(stopBefore) ? null : { scenes: null },steps: [],processId: processId || null,stopReason: null,@@ -468,7 +472,7 @@ export function nextProductionStep(project, run, { jobs = [], processId = null }if (gate) return { type: 'halt', status: 'blocked', reason: 'This selected performance shot needs the reviewed Cast & Sets references. Build and approve that check-in, then resume; production will not start an unbudgeted image batch.' };}let waiting = false;- for (const stepKind of ['frame', 'clip']) {+ for (const stepKind of run.stopBefore === 'clips' ? ['frame'] : ['frame', 'clip']) {for (const scene of targets[stepKind]) {if (pendingPilots.length && !pendingPilots.some((pilot) => pilot.sceneId === scene.sceneId)) continue;if (scene[SLOT[stepKind]]) continue;@@ -486,6 +490,7 @@ export function nextProductionStep(project, run, { jobs = [], processId = null }}}if (waiting) return { type: 'wait', on: 'generation' };+ if (run.stopBefore === 'clips') return { type: 'halt', status: 'awaiting-video', reason: 'Every shot has its still. Resume to make the clips.' };if (pendingPilots.length) {const pilot = pendingPilots[0];const scene = scenes.find((s) => s.sceneId === pilot.sceneId);@@ -761,7 +766,7 @@ export function stopProductionOnProject(project, runId, now = new Date().toISOSt* budget. A run halted on a changed creative setup continues only when the* director accepts the new basis (`acceptBasis`), which re-snapshots it.*/-export function resumeProductionOnProject(project, runId, { limits, acceptBasis = false, processId, pool = null, pricing = {} } = {}, now = new Date().toISOString()) {+export function resumeProductionOnProject(project, runId, { limits, acceptBasis = false, processId, pool = null, pricing = {}, stopBefore } = {}, now = new Date().toISOString()) {return mutateRun(project, runId, (run) => {if (!RESUMABLE.has(run.status)) throw productionError(409, 'PRODUCTION_CLOSED', `This production run is ${run.status} — start a new run instead`);if (normalizeMusicVideoProductionPolicy(project?.productionPolicy).strategy === 'code-first' && !run.authoring) throw productionError(409, 'PRODUCTION_AUTHORING_REQUIRED', 'Cancel this legacy run and start a code-first run with an authoring model');@@ -782,6 +787,9 @@ export function resumeProductionOnProject(project, runId, { limits, acceptBasis// A replacement pool (a swapped model, #10473) is checked like Start; the// caller has already proven every route eligible on this install.const nextPool = pool ? normalizeProductionPool(pool, { allowEmpty: !!run.authoring }) : null;+ // Resuming a finished stills-only run goes on to the clips unless the caller keeps the stop.+ const nextStop = stopBefore !== undefined ? (STOP_BEFORE.has(stopBefore) ? stopBefore : null)+ : run.status === 'awaiting-video' ? null : run.stopBefore || null;return {status: 'running',limits: nextLimits,@@ -789,7 +797,8 @@ export function resumeProductionOnProject(project, runId, { limits, acceptBasisprocessId,resumedAt: now,retryAcknowledged: run.steps.filter((step) => step.status === 'failed').map((step) => step.key),- ...(!run.pilot && !run.reviewRunId ? { pilot: { scenes: null } } : {}),+ stopBefore: nextStop,+ ...(!run.pilot && !run.reviewRunId && !nextStop ? { pilot: { scenes: null } } : {}),stopReason: null,error: null,...(run.finalRender?.status === 'failed' || (run.finalRender && run.processId !== processId) ? { finalRender: null } : {}),diff --git a/server/services/musicVideo/productionDispatch.js b/server/services/musicVideo/productionDispatch.jsindex 413c9c1ae1..349c7cbd21 100644--- a/server/services/musicVideo/productionDispatch.js+++ b/server/services/musicVideo/productionDispatch.js@@ -50,7 +50,10 @@ async function dispatchFrame({ project, scene, route, tag, settings }) {const basePrompt = sceneFramePrompt(project, scene);const repairing = project.productionRuns?.find((run) => run.id === tag.productionRunId)?.steps?.find((step) => step.key === tag.productionStepKey)?.plateRepairBasis;const unmet = repairing ? (scene.takes || []).flatMap((take) => currentPlateEvidence(scene, take)?.checks.filter((check) => check.status === 'fail').map((check) => `${check.requirement}: ${check.note}`) || []) : [];- const prompt = basePrompt && [basePrompt, unmet.length ? `Repair these visible plate mismatches while preserving the shot intent:\n${[...new Set(unmet)].join('\n')}` : ''].filter(Boolean).join('\n');+ // The autonomous run's stills review names what the last still got wrong (autonomousService.js).+ const fixes = typeof scene.stillFixes?.text === 'string' ? scene.stillFixes.text : '';+ const prompt = basePrompt && [basePrompt, unmet.length ? `Repair these visible plate mismatches while preserving the shot intent:\n${[...new Set(unmet)].join('\n')}` : '',+ fixes ? `Fix these visible problems from the previous still while preserving the shot intent:\n${fixes}` : ''].filter(Boolean).join('\n');if (!prompt) throw unprompted(scene, 'frame');const referenceImagePaths = conditioningReferences(project, scene).map((ref) => resolveGalleryImage(ref.imageId, { mustExist: false })).filter(Boolean);diff --git a/server/services/musicVideo/productionService.js b/server/services/musicVideo/productionService.jsindex d97915625d..dd508fa55a 100644--- a/server/services/musicVideo/productionService.js+++ b/server/services/musicVideo/productionService.js@@ -637,7 +637,7 @@ async function cancelOwnedJobs(runId, { includeRunning = false, jobIds = null }* Start a run (explicit director request). Every pool route must be eligible* now. Returns `{ project, run }`; the run advances in the background.*/-export async function startProduction(projectId, { directive, pool: requested, limits, reviewer, authoring: requestedAuthoring }) {+export async function startProduction(projectId, { directive, pool: requested, limits, reviewer, authoring: requestedAuthoring, stopBefore }) {const project = await requireProject(projectId);if (project.videoSettings?.renderPool && project.videoSettings.renderPool.mode !== 'local') {throw new ServerError('Production runs require This Mac until immutable run pools support peer placement', { status: 409, code: 'MUSIC_VIDEO_RENDER_POOL_UNAVAILABLE' });@@ -652,7 +652,7 @@ export async function startProduction(projectId, { directive, pool: requested, l// The autopilot cuts on the song (#9290) unless the director chose how it// cuts — set before the run captures its creative-setup basis.const out = await mutateProjectRecord(projectId, (current) => startProductionOnProject(withAutopilotCutting(current), {- directive, pool, limits, reviewer, authoring, processId: PROCESS_ID, pricing: poolPricing(pool, current),+ directive, pool, limits, reviewer, authoring, processId: PROCESS_ID, pricing: poolPricing(pool, current), stopBefore,}));console.log(`🎬 Music Video production ${short(out.run.id)} started: ${out.run.pool.length} allowed route(s), ≤${out.run.limits.maxGenerations} generations, ≤${out.run.limits.maxReviewAttempts} reviews`);advanceInBackground(projectId, out.run.id);@@ -666,7 +666,7 @@ export async function startProduction(projectId, { directive, pool: requested, l* continue. A replacement pool is validated exactly like Start's.* Returns `{ project, run }`.*/-export async function resumeProduction(projectId, runId, { limits, acceptBasis = false, pool: requested } = {}) {+export async function resumeProduction(projectId, runId, { limits, acceptBasis = false, pool: requested, stopBefore } = {}) {const before = await requireProject(projectId);const prior = findProductionRun(before, runId);const priorReviewId = prior.reviewRunId;@@ -675,7 +675,7 @@ export async function resumeProduction(projectId, runId, { limits, acceptBasis =const jobs = await liveJobs();await mutateProjectRecord(projectId, (current) => reconcileProductionSteps(current, runId, jobs));const out = await mutateProjectRecord(projectId, (current) => resumeProductionOnProject(current, runId, {- limits, acceptBasis, processId: PROCESS_ID, ...(pool ? { pool, pricing: poolPricing(pool, current) } : {}),+ limits, acceptBasis, processId: PROCESS_ID, stopBefore, ...(pool ? { pool, pricing: poolPricing(pool, current) } : {}),}));if (pool) console.log(`🎬 Music Video production ${short(runId)} resumed with a replaced pool: ${pool.length} allowed route(s)`);if (priorReviewId && !out.run.reviewRunId) {diff --git a/server/services/musicVideo/productionService.test.js b/server/services/musicVideo/productionService.test.jsindex 0dd0ab8f16..0817cdba21 100644--- a/server/services/musicVideo/productionService.test.js+++ b/server/services/musicVideo/productionService.test.js@@ -255,6 +255,31 @@ describe('music video production run (#9066)', () => {expect(theRun().status).toBe('completed');});+ // Uniquely catches a stills-only run spending on a clip (pilot or bulk) or stopping before every still exists.+ it('makes every still and stops before any clip when told to, then goes on to the clips on Resume', async () => {+ seedProject();+ await start({ pool: POOL.filter((route) => route.kind === 'image'), stopBefore: 'clips' });+ expect(dispatch.mock.calls.map(([a]) => [a.stepKind, a.scene.sceneId])).toEqual([['frame', 'mvs-a'], ['frame', 'mvs-b']]);+ completeJob('job-1');+ completeJob('job-2');+ await settle();+ expect(theRun()).toMatchObject({ status: 'awaiting-video', stopBefore: 'clips', pilot: null, stopReason: expect.stringContaining('still') });+ expect(dispatch).toHaveBeenCalledTimes(2);+ expect(startAutoReview).not.toHaveBeenCalled();++ // A resume that keeps the stop makes only missing stills.+ await service.resumeProduction('mv-example', theRun().id, { stopBefore: 'clips' });+ await settle();+ expect(theRun().status).toBe('awaiting-video');+ expect(dispatch).toHaveBeenCalledTimes(2);++ await service.resumeProduction('mv-example', theRun().id, { pool: POOL });+ await settle();+ expect(theRun()).toMatchObject({ status: 'running', stopBefore: null });+ expect(dispatch.mock.calls.slice(2).every(([a]) => a.stepKind === 'clip')).toBe(true);+ expect(dispatch.mock.calls.length).toBeGreaterThan(2);+ });+it('in a composition document, skips frames for card scenes and clips for still/card scenes', async () => {seedProject({composition: { mode: 'document' },