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
let an autopilot run resume after its production fails, is canceled or is replaced by hand
[._.]/ Adam Eivy684fd8f0606e
diff --git a/client/src/components/musicVideo/AutonomousRunPanel.jsx b/client/src/components/musicVideo/AutonomousRunPanel.jsxindex 99ba3f76a5..e7c8cb06d9 100644--- a/client/src/components/musicVideo/AutonomousRunPanel.jsx+++ b/client/src/components/musicVideo/AutonomousRunPanel.jsx@@ -78,7 +78,9 @@ export default function AutonomousRunPanel({ project, auto, readiness, selectedS: awaiting === 'style' ? { key: 'style', label: 'Suno style', value: run.output?.sunoStyle || '' } : null;const draft = edit && edit.for === awaiting ? edit.value : editable?.value;const changed = editable && draft !== editable.value;- const canRetry = ['needs-human', 'failed', 'stopped'].includes(run.status) || run.interrupted;+ // A run canceled while waiting on production can resume: it adopts or restarts production.+ const reopenable = run.status === 'canceled' && run.stage === 'produce';+ const canRetry = ['needs-human', 'failed', 'stopped'].includes(run.status) || run.interrupted || reopenable;const orchestrator = isOrchestratedRun(run) ? run.brief.orchestrator : null;const tone = STATUS_TONES[run.status] || '';// #10157: what the production run has used against its limits (Suno is counted apart).@@ -206,7 +208,7 @@ export default function AutonomousRunPanel({ project, auto, readiness, selectedS</div>)}- {!orchestrator && (awaiting || canRetry) && (live || run.status === 'failed') && (+ {!orchestrator && (awaiting || canRetry) && (live || run.status === 'failed' || reopenable) && (<AutoApproveFieldsidPrefix="mv-run"value={autoApprove}@@ -216,7 +218,7 @@ export default function AutonomousRunPanel({ project, auto, readiness, selectedS/>)}- {live || run.status === 'failed' ? (+ {live || run.status === 'failed' || reopenable ? (<div className="flex flex-wrap gap-2">{canRetry && !awaiting && (<button type="button" disabled={auto.busy} onClick={() => resume()} className={buttonClass}>@@ -226,7 +228,7 @@ export default function AutonomousRunPanel({ project, auto, readiness, selectedS{run.status === 'running' && !run.interrupted && (<button type="button" disabled={auto.busy} onClick={() => auto.stop()} className={buttonClass}><Pause size={14} aria-hidden="true" /> Pause</button>)}- <button type="button" disabled={auto.busy} onClick={() => auto.cancel()} className={`${buttonClass} text-port-error`}><X size={14} aria-hidden="true" /> Cancel</button>+ {!reopenable && <button type="button" disabled={auto.busy} onClick={() => auto.cancel()} className={`${buttonClass} text-port-error`}><X size={14} aria-hidden="true" /> Cancel</button>}</div>) : null}</section>diff --git a/client/src/components/musicVideo/AutonomousRunPanel.test.jsx b/client/src/components/musicVideo/AutonomousRunPanel.test.jsxindex 5093fdf39f..72722d58d9 100644--- a/client/src/components/musicVideo/AutonomousRunPanel.test.jsx+++ b/client/src/components/musicVideo/AutonomousRunPanel.test.jsx@@ -137,6 +137,19 @@ describe('AutonomousRunPanel', () => {await waitFor(() => expect(api.resumeAutonomousMusicVideo).toHaveBeenCalledWith('mv-1', { retakeSong: true }, { silent: true }));});+ it('offers Resume, not Cancel, for a run canceled while it waited on production', async () => {+ api.resumeAutonomousMusicVideo.mockResolvedValue({ project: { id: 'mv-1', autonomousRun: baseRun() }, run: baseRun() });+ render(<Harness initial={baseRun({ status: 'canceled', stage: 'produce', error: 'Production was canceled' })} />);+ expect(screen.queryByRole('button', { name: /cancel/i })).toBeNull();+ fireEvent.click(screen.getByRole('button', { name: /resume/i }));+ await waitFor(() => expect(api.resumeAutonomousMusicVideo).toHaveBeenCalledWith('mv-1', {}, { silent: true }));+ });++ it('offers nothing to resume for a run canceled before production', () => {+ render(<Harness initial={baseRun({ status: 'canceled', stage: 'song' })} />);+ expect(screen.queryByRole('button', { name: /resume/i })).toBeNull();+ });+it('offers a retry for a run that needs the director, and shows why', async () => {api.resumeAutonomousMusicVideo.mockResolvedValue({ project: { id: 'mv-1', autonomousRun: baseRun() }, run: baseRun() });render(<Harness initial={baseRun({ status: 'needs-human', stage: 'song', error: 'Sign in to Suno in the PortOS Browser' })} />);diff --git a/docs/features/music-video-autonomous.md b/docs/features/music-video-autonomous.mdindex a89b27a348..55fdc00594 100644--- a/docs/features/music-video-autonomous.md+++ b/docs/features/music-video-autonomous.md@@ -143,7 +143,8 @@ and does not press Create or spend credits on a second generation.- A signed-out Suno parks the run **`needs-human`** (`PUBLISH_LOGIN_REQUIRED`): sign in to Suno in the PortOS Browser, then Resume.- Any other stage failure parks **`failed`** with the error; Retry re-runs that stage only. Songs already submitted to Suno are stored the moment Suno accepts the request, so a failed download retries the same songs and never spends credits on a second generation.- Resume after Stop waits for the prior stage attempt to settle before restarting. A Cancel while Resume waits remains canceled.-- A parked or failed delegated production run parks this run `needs-human`; Resume resumes the production run.+- A parked or failed delegated production run parks this run `needs-human`; Resume resumes the production run. A production run canceled on its own (not by canceling this run) also parks it `needs-human` (`PRODUCTION_CANCELED`).+- **Resume after manual edits.** At the produce stage, Resume follows the newest production run started since the run began, so a run the director started by hand (for example with a different video model) is adopted: a live one is followed, a parked one is resumed, and a completed one goes straight to the final render. With no production run left to follow, Resume starts a new one from the brief. A run canceled while it waited on production can be resumed the same way. Resume may also carry `limits` (raised or lowered, applied to the brief and to the resumed production run) and `models` (per-tool swaps, `null` clears a pin); a changed model cancels the current production run and starts a new one with the new pool.The Suno adapter fills the form through `placeholder` / role selectors and reads the new `/song/<id>` links. It opens the first take in the same signed-in PortOS Browser, selects only M4A, and presses Download (or Unlock & Download) once. It waits for the browser download to finish saving, checks the container and decodes the complete audio to reject damaged files, and imports the original M4A without conversion. The export has a ten-minute deadline; timeout, cancellation, or invalid audio removes staging files and never imports a partial/error response. Failures identify the export stage using bounded reason metadata. A retry reopens the existing song rather than pressing Create again.@@ -153,7 +154,7 @@ The Suno adapter fills the form through `placeholder` / role selectors and reads|---|---|---|| `POST` | `/api/music-video/autonomous` | Start (202 `{ project, run }`). Body: `prompt` plus optional `songSource` (`suno` default, or `local`), `localFallback`, `suno` (Suno form options), `tools`, `models` (per-tool model pin), `budgetUsd`, `limits`, `checkpoints`, `instrumental`, `guidance`, `providerId`/`model`/`effort` (the direction LLM), `llmStages` (per-stage LLM pins), `lyricsReview`, `authoring` (code-rendered video), `autoApprove` (authenticated planning grant, see Production review), `orchestrator` (authenticated; see Orchestrated mode). || `GET` | `/api/music-video/:id/autonomous` | The run. |-| `POST` | `/api/music-video/:id/autonomous/resume` | Approve the checkpoint, retry the stage that stopped, or resume an interrupted run. Optional `lyrics`, `style`, `suno` edits; `retakeSong: true` at the song checkpoint; `autoApprove` to grant or revoke automatic planning approvals using the authenticated session. |+| `POST` | `/api/music-video/:id/autonomous/resume` | Approve the checkpoint, retry the stage that stopped, or resume an interrupted run. Optional `lyrics`, `style`, `suno` edits; `models` and `limits` patches; `retakeSong: true` at the song checkpoint; `autoApprove` to grant or revoke automatic planning approvals using the authenticated session. || `POST` | `/api/music-video/:id/autonomous/stop` / `cancel` | Pause / cancel (also stops/cancels its production run). |Progress is pushed over the `music-video:autonomous` socket event (`{ projectId, runId, run, project }`).diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.jsindex 43618d8aaa..b9bc4e5bf6 100644--- a/server/lib/musicVideoValidation.js+++ b/server/lib/musicVideoValidation.js@@ -980,6 +980,13 @@ export const musicVideoAutonomousResumeSchema = z.object({localMusic: musicVideoLocalMusicOptionsSchema.nullable().optional(),// At the song checkpoint: discard the song and generate a new one.retakeSong: z.boolean().optional(),+ // Swap a tool's model (null clears the pin) and raise or lower the run's limits. A changed+ // model at the produce stage starts a new production run with the new pool.+ models: z.partialRecord(z.enum(MUSIC_VIDEO_AUTOMATION_TOOL_IDS), z.string().trim().min(1).max(200).nullable()).optional(),+ limits: 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(),// 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 b34ed1a82d..d644dce135 100644--- a/server/services/musicVideo/autonomousService.js+++ b/server/services/musicVideo/autonomousService.js@@ -105,6 +105,9 @@ const defaults = {analyzeSong: async (projectId) => (await import('./projectAudio.js')).analyzeProjectSong(projectId),designCoverArt: async (projectId, input) => (await import('./coverArt.js')).designCoverArt(projectId, input),startProduction: async (...args) => (await import('./productionService.js')).startProduction(...args),+ resumeProduction: async (...args) => (await import('./productionService.js')).resumeProduction(...args),+ stopProduction: async (...args) => (await import('./productionService.js')).stopProduction(...args),+ cancelProduction: async (...args) => (await import('./productionService.js')).cancelProduction(...args),generateDocument: async (...args) => (await import('./documentGeneration.js')).generateMixedMediaDocument(...args),acceptDocument: async (...args) => (await import('./documentGeneration.js')).acceptMixedMediaDocument(...args),generateCode: async (...args) => (await import('./codeGeneration.js')).generateMusicVideoCode(...args),@@ -1034,7 +1037,10 @@ export async function getAutonomousRun(projectId) {* output the director edited). Returns `{ project, run }`.*/const assertResumable = (run) => {- const resumable = AUTONOMOUS_LIVE_STATUSES.includes(run.status) || run.status === 'failed';+ // A run canceled while it waited on production can pick up again: resume adopts the+ // director's own production run, or starts a new one from the brief.+ const resumable = AUTONOMOUS_LIVE_STATUSES.includes(run.status) || run.status === 'failed'+ || (run.status === 'canceled' && run.stage === 'produce');if (!resumable) throw runError(409, 'NOT_RESUMABLE', `A ${run.status} run cannot be resumed`);if (run.status === 'running' && run.processId === PROCESS_ID) throw runError(409, 'ALREADY_RUNNING', 'This run is already running');};@@ -1057,11 +1063,15 @@ const SONG_OUTPUT_KEYS = ['trackId', 'sunoSongIds', 'songSource', 'songFallbackRexport async function resumeAutonomousVideo(projectId, edits = {}, { autoApproveAuthorized = false } = {}) {const { run } = await requireRun(projectId);+ // A model swap only takes effect in a new production run (its pool is fixed at start).+ const modelsPatch = briefModelsPatch(run.brief, edits.models);assertResumable(run);// "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) assertAtSongCheckpoint(run);+ const modelsChanged = modelsPatch !== null && JSON.stringify(modelsPatch) !== JSON.stringify(run.brief.models || {});+ const limitsPatch = edits.limits ? { ...run.brief.limits, ...edits.limits } : null;// Stop changes the record immediately, but its stage may still be settling.// Let that attempt release ownership before marking a new attempt running.await inflight.get(projectId);@@ -1079,8 +1089,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 ? { brief: {+ ...(edits.suno || edits.localMusic !== undefined || grant || modelsPatch || limitsPatch ? { brief: {...r.brief,+ ...(modelsPatch ? { models: modelsPatch } : {}),+ ...(limitsPatch ? { limits: limitsPatch } : {}),...(edits.suno ? { suno: normalizeSunoOptions({ ...r.brief.suno, ...edits.suno }) } : {}),...(edits.localMusic !== undefined ? { localMusic: normalizeLocalMusicOptions(edits.localMusic ? { ...r.brief.localMusic, ...edits.localMusic } : null) } : {}),...(grant || {}),@@ -1103,17 +1115,70 @@ export async function resumeAutonomousVideo(projectId, edits = {}, { autoApprovereturn { project: presentProjectAutonomousRun(latest), run: presentAutonomousRun(projectAutonomousRun(latest)) };}if (out.run.stage === 'produce' && out.run.output.productionRunId) {- const { resumeProduction } = await import('./productionService.js');- const failure = await resumeProduction(projectId, out.run.output.productionRunId, { acceptBasis: true }).then(() => null, (err) => err);+ return resumeDelegatedProduction(projectId, out.run, { restart: modelsChanged, limits: edits.limits });+ }+ advanceInBackground(projectId);+ return { project: out.project, run: presentAutonomousRun(out.run) };+}++/**+ * The brief's models with a resume's per-tool swaps applied (null clears a pin), or null+ * when the resume names none. Only tools the brief already allows can be pinned.+ */+function briefModelsPatch(brief, models) {+ if (!models || !Object.keys(models).length) return null;+ const next = { ...(brief.models || {}) };+ for (const [tool, model] of Object.entries(models)) {+ if (!brief.tools.includes(tool)) throw runError(400, 'VALIDATION_ERROR', `The run does not use ${tool}`);+ if (model) next[tool] = model;+ else delete next[tool];+ }+ return next;+}++// 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']);++/**+ * Hand a resumed run back to production. It follows the newest production run started+ * since the run began (the director may have replaced its own by hand) and resumes it+ * with any raised limits, or finishes straight to the final render when that run is+ * already complete. A model swap, or no production run left to follow, starts a new+ * one from the brief by re-entering `produce`.+ */+async function resumeDelegatedProduction(projectId, run, { restart = false, limits } = {}) {+ const project = await getProject(projectId);+ const runs = Array.isArray(project.productionRuns) ? project.productionRuns : [];+ const current = runs.find((r) => r.id === run.output.productionRunId) || null;+ const adopt = restart ? null : runs+ .filter((r) => ADOPTABLE_PRODUCTION.has(r.status) && String(r.createdAt || '') >= String(run.createdAt || ''))+ .sort((a, b) => String(b.createdAt || '').localeCompare(String(a.createdAt || '')))[0] || null;+ if (!adopt) {+ if (current && PRODUCTION_LIVE.has(current.status)) await deps.cancelProduction(projectId, current.id).catch(() => {});+ const out = await patchRun(projectId, (r) => ({ output: { productionRunId: null }, ...stagePatch(r, 'produce', { status: 'pending', error: null, step: null }) }));+ console.log(`🎬 Autonomous music video ${short(run.id)} starting a new production run${restart ? ' with the new models' : ''}`);+ advanceInBackground(projectId);+ return { project: out.project, run: presentAutonomousRun(out.run) };+ }+ if (adopt.id !== run.output.productionRunId) {+ await patchRun(projectId, () => ({ output: { productionRunId: adopt.id } }));+ console.log(`🎬 Autonomous music video ${short(run.id)} adopted production run ${short(adopt.id)}`);+ }+ if (adopt.status === 'completed') {+ await patchRun(projectId, () => ({ output: { productionDone: true } }));+ await reconcileFinalRender(projectId, { restart: true });+ } else if (adopt.status !== 'running') {+ const productionLimits = limits ? Object.fromEntries(Object.entries(limits).filter(([, v]) => v != null)) : undefined;+ const failure = await deps.resumeProduction(projectId, adopt.id, { acceptBasis: true, ...(productionLimits ? { limits: productionLimits } : {}) })+ .then(() => null, (err) => err);if (failure) {- // A failed or canceled production run cannot be resumed; say so rather than leave the run looking live.const parked = await park(projectId, 'needs-human', { error: trimTo(`Production could not resume: ${failure.message}`, 500), errorCode: failure.code || null });return { project: parked.project, run: presentAutonomousRun(parked.run) };}- return { project: out.project, run: presentAutonomousRun(out.run) };}- advanceInBackground(projectId);- return { project: out.project, run: presentAutonomousRun(out.run) };+ const latest = await getProject(projectId);+ return { project: presentProjectAutonomousRun(latest), run: presentAutonomousRun(projectAutonomousRun(latest)) };}// Read from the freshly patched record, so a job id stored a moment before the status flipped is seen.@@ -1126,8 +1191,7 @@ export async function stopAutonomousVideo(projectId) {if (!['running', 'awaiting-approval', 'needs-human'].includes(run.status)) throw runError(409, 'NOT_RUNNING', `A ${run.status} run cannot be stopped`);const out = await patchRun(projectId, () => ({ status: 'stopped' }));if (run.output.productionRunId) {- const { stopProduction } = await import('./productionService.js');- await stopProduction(projectId, run.output.productionRunId).catch(() => {});+ await deps.stopProduction(projectId, run.output.productionRunId).catch(() => {});}sunoControllers.get(run.id)?.abort();await cancelLocalSongJob(out.run);@@ -1140,8 +1204,7 @@ export async function cancelAutonomousVideo(projectId) {const out = await patchRun(projectId, () => ({ status: 'canceled', awaiting: null }));if (run.output.renderJobId) await deps.cancelRender(run.output.renderJobId).catch(() => {});if (run.output.productionRunId) {- const { cancelProduction } = await import('./productionService.js');- await cancelProduction(projectId, run.output.productionRunId).catch(() => {});+ await deps.cancelProduction(projectId, run.output.productionRunId).catch(() => {});}sunoControllers.get(run.id)?.abort();await cancelLocalSongJob(out.run);@@ -1174,7 +1237,9 @@ async function onProductionEvent({ projectId, runId, run: production }) {} else if (production.status === 'failed') {await park(projectId, 'failed', { error: reason || 'Production failed', errorCode: 'PRODUCTION_FAILED' });} else if (production.status === 'canceled') {- await park(projectId, 'canceled', { error: reason || null });+ // 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_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 c43e5b023f..f1d8418582 100644--- a/server/services/musicVideo/autonomousService.test.js+++ b/server/services/musicVideo/autonomousService.test.js@@ -93,6 +93,9 @@ beforeEach(() => {analyzeSong: stub('analyze', async () => ({})),designCoverArt: vi.fn(async () => ({})),startProduction: stub('production', async () => ({ run: { id: 'mvpr-1' } })),+ resumeProduction: stub('resume-production', async () => ({})),+ stopProduction: stub('stop-production', async () => ({})),+ cancelProduction: stub('cancel-production', async () => ({})),generateCode: stub('code', async () => ({})),generateDocument: stub('document', async () => ({ document: { directory: 'music-video/mv-auto/composition/example' } })),acceptDocument: stub('accept-document', async (id, directory) => { store.get(id).composition.document = { directory }; return {}; }),@@ -270,6 +273,68 @@ describe('startAutonomousVideo', () => {expect(runOf().output.renderJobId).toBe('render-3');});+ describe('resuming after production fails, is canceled or is replaced by hand', () => {+ const later = () => new Date(Date.now() + 1000).toISOString();+ const delegated = async (input = {}) => {+ await service.startAutonomousVideo({ prompt: 'p', tools: ['image:local', 'video:local'], models: { 'video:local': 'text-only' }, ...input });+ await vi.waitFor(() => expect(runOf()?.output.productionRunId).toBe('mvpr-1'));+ store.get('mv-auto').productionRuns = [{ id: 'mvpr-1', status: 'running', createdAt: later() }];+ };++ it('parks when its production run is canceled on its own, then adopts the run the director started instead', async () => {+ await delegated();+ store.get('mv-auto').productionRuns[0].status = 'canceled';+ await service.__testing.onProductionEvent({ projectId: 'mv-auto', runId: 'mvpr-1', run: { status: 'canceled' } });+ expect(runOf()).toMatchObject({ status: 'needs-human', errorCode: 'PRODUCTION_CANCELED' });++ store.get('mv-auto').productionRuns.push({ id: 'mvpr-manual', status: 'running', createdAt: later() });+ await service.resumeAutonomousVideo('mv-auto');+ expect(runOf()).toMatchObject({ status: 'running', stage: 'produce', output: expect.objectContaining({ productionRunId: 'mvpr-manual' }) });+ expect(doubles.resumeProduction).not.toHaveBeenCalled();+ expect(doubles.startProduction).toHaveBeenCalledOnce();+ // The adopted run's completion is now ours: it starts the final render.+ await service.__testing.onProductionEvent({ projectId: 'mv-auto', runId: 'mvpr-manual', run: { status: 'completed' } });+ expect(runOf().output.renderJobId).toBe('render-1');+ });++ it('goes straight to the final render when the adopted run already completed', async () => {+ await delegated();+ await service.cancelAutonomousVideo('mv-auto');+ expect(runOf().status).toBe('canceled');+ store.get('mv-auto').productionRuns = [{ id: 'mvpr-1', status: 'canceled', createdAt: later() }, { id: 'mvpr-manual', status: 'completed', createdAt: later() }];+ await service.resumeAutonomousVideo('mv-auto');+ expect(doubles.renderVideo).toHaveBeenCalledOnce();+ expect(runOf()).toMatchObject({ status: 'running', output: expect.objectContaining({ productionRunId: 'mvpr-manual', productionDone: true, renderJobId: 'render-1' }) });+ });++ it('resumes a parked run with raised limits, and a model swap starts a new production run with the new pool', async () => {+ await delegated();+ store.get('mv-auto').productionRuns[0].status = 'limit-reached';+ await service.__testing.onProductionEvent({ projectId: 'mv-auto', runId: 'mvpr-1', run: { status: 'limit-reached', stopReason: 'generation limit' } });+ await service.resumeAutonomousVideo('mv-auto', { limits: { maxGenerations: 120 } });+ expect(doubles.resumeProduction).toHaveBeenCalledWith('mv-auto', 'mvpr-1', { acceptBasis: true, limits: { maxGenerations: 120 } });+ expect(runOf().brief.limits.maxGenerations).toBe(120);++ store.get('mv-auto').productionRuns[0].status = 'blocked';+ await service.__testing.onProductionEvent({ projectId: 'mv-auto', runId: 'mvpr-1', run: { status: 'blocked', stopReason: 'no image-to-video' } });+ doubles.startProduction.mockResolvedValueOnce({ run: { id: 'mvpr-2' } });+ await service.resumeAutonomousVideo('mv-auto', { models: { 'video:local': 'image-capable' } });+ expect(doubles.cancelProduction).toHaveBeenCalledWith('mv-auto', 'mvpr-1');+ await vi.waitFor(() => expect(runOf().output.productionRunId).toBe('mvpr-2'));+ expect(doubles.startProduction.mock.calls[1][1].pool).toEqual([{ kind: 'image', mode: 'local' }, { kind: 'video', mode: 'local', model: 'image-capable' }]);+ await expect(service.resumeAutonomousVideo('mv-auto', { models: { 'image:fal': 'x' } })).rejects.toMatchObject({ code: 'VALIDATION_ERROR' });+ });++ it('starts a new production run when there is none left to follow', async () => {+ await delegated();+ await service.cancelAutonomousVideo('mv-auto');+ store.get('mv-auto').productionRuns[0].status = 'canceled';+ doubles.startProduction.mockResolvedValueOnce({ run: { id: 'mvpr-2' } });+ await service.resumeAutonomousVideo('mv-auto');+ await vi.waitFor(() => expect(runOf()).toMatchObject({ status: 'running', output: expect.objectContaining({ productionRunId: 'mvpr-2' }) }));+ });+ });+it('parks needs-human when production parks, and failed when it fails', async () => {await service.startAutonomousVideo({ prompt: 'p' });await vi.waitFor(() => expect(runOf()?.output.productionRunId).toBe('mvpr-1'));