Skip to content

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

Keep the storyboard approval when the director rewords or retimes a shot (#11209)

[._.]/bd1889b59dc1
diff --git a/server/routes/musicVideoProductionReview.test.js b/server/routes/musicVideoProductionReview.test.js
index 6936355387..3c4499ad20 100644
--- a/server/routes/musicVideoProductionReview.test.js
+++ b/server/routes/musicVideoProductionReview.test.js
@@ -381,11 +381,13 @@ describe('human-reviewed Music Video workflow', () => {
expect(revised.body.project.productionReview.reviewedRevisions[entry.basis].draft.storyboard[0].staging).toBe('Figure foreground, doorway behind');
expect(revised.body.project.productionReview.feedback.at(-1).resolvedAt).toBeUndefined();
expect(revised.body.readiness.art.approved).toBe(true);
- expect(revised.body.readiness.storyboard.approved).toBe(false);
+ // Rewording an approved shot keeps the storyboard approval; the proof it fed is reviewed again.
+ expect(revised.body.readiness.storyboard.approved).toBe(true);
+ expect(revised.body.readiness.proof.approved).toBe(false);
const resolution = { feedbackId: entry.id, resolution: 'Reviewed the revised staging.' };
expect((await request(app).post(`${base}/production-review/feedback/resolve`).set('authorization', 'Bearer expired').send(resolution)).status).toBe(401);
expect((await request(app).post(`${base}/production-review/feedback/resolve`).send(resolution)).status).toBe(200);
- expect((await read()).body.readiness.readyForProduction).toBe(false);
+ expect((await read()).body.readiness.proof.approved).toBe(false);
await request(app).post(`${base}/production-review/import`).send({ source: JSON.stringify({ cast: 'Another proposal', storyboard: [] }) });
const imported = await read();
expect(imported.body.project.productionReview.feedback).toHaveLength(2);
diff --git a/server/services/musicVideo/autonomousService.test.js b/server/services/musicVideo/autonomousService.test.js
index 9d0721fc58..f87ffe511d 100644
--- a/server/services/musicVideo/autonomousService.test.js
+++ b/server/services/musicVideo/autonomousService.test.js
@@ -1365,13 +1365,13 @@ describe('autopilot clears the gates it was granted on its own', () => {
expect(doubles.verifyAlignment).toHaveBeenCalledWith('mv-auto', expect.objectContaining({ notes: expect.stringContaining('source project') }));
});
- // Uniquely catches a run granted the storyboard parking for the director when a prompt edit stales that approval mid-production.
- it('approves a storyboard a prompt edit staled again and resumes production', async () => {
+ // Uniquely catches a run granted the storyboard parking for the director when a lyric edit stales that approval mid-production.
+ it('approves a storyboard a lyric edit staled again and resumes production', async () => {
analyzed({ productionReview: { draft: { ...GUIDE, lyricsMode: 'instrumental', timingNotes: 'Synthetic instrumental master checked.', storyboard: [shot] } } });
await service.startAutonomousVideo({ prompt: 'p', tools: ['image:local'], ...GRANT[0] }, GRANT[1]);
await vi.waitFor(() => expect(doubles.startProduction).toHaveBeenCalledOnce());
const project = store.get('mv-auto');
- project.scenes[0].prompt = 'the dancer turns toward the light';
+ project.scenes[0].lyricText = 'the dancer turns toward the light';
project.productionRuns = [{ id: 'mvpr-1', status: 'blocked', createdAt: new Date().toISOString() }];
expect(actual.productionReadiness(project).storyboard.approved).toBe(false);
doubles.approveProductionReview.mockClear();
diff --git a/server/services/musicVideo/productionReview.js b/server/services/musicVideo/productionReview.js
index b44c68163c..0f3f11ba18 100644
--- a/server/services/musicVideo/productionReview.js
+++ b/server/services/musicVideo/productionReview.js
@@ -110,6 +110,15 @@ export function seedArtDraft(project, stage = project.castAndSets) {
return { ...project, productionReview: { ...project.productionReview, draft, seededDraft } };
}
+/**
+ * Is a storyboard approval current on this revision? Either it was given on
+ * exactly this revision, or only the wording, prompts or timing of the shots
+ * it covered have changed since (`shotsBasis`; approvals recorded before it
+ * existed match on the exact revision only).
+ */
+const storyboardApprovalCurrent = (approval, basis) => !!approval
+ && (approval.basis === basis.storyboard || (!!basis.storyboardShots && approval.shotsBasis === basis.storyboardShots));
+
export function productionReviewBasis(project) {
const draft = project.productionReview?.draft || {};
const art = hash({ projectId: project.id, mediaMode: project.mediaMode, authoringRenderer: project.composition?.authoringRenderer, mode: project.composition?.mode, policy: project.productionPolicy,
@@ -117,13 +126,20 @@ export function productionReviewBasis(project) {
direction: project.castAndSets?.direction,
cast: draft.cast, environments: draft.environments, visualLanguage: draft.visualLanguage,
motionLanguage: draft.motionLanguage, implementationPlan: draft.implementationPlan, guide: artifactBasis(artifact(project, draft.guideArtifactId)) });
- const storyboard = hash({ art, source: source(project), lyricsMode: draft.lyricsMode,
+ const storyboardInputs = { art, source: source(project), lyricsMode: draft.lyricsMode,
timingStatus: draft.timingStatus, timingNotes: draft.timingNotes, storyboard: draft.storyboard,
storyboardSource: draft.storyboardSource || 'board', documentStoryboard: project.productionReview?.documentStoryboard,
document: draft.storyboardSource === 'document' ? project.composition?.document : null,
// A planned camera (#10589) joins the hash only when set, so older approvals stay current.
scenes: (project.scenes || []).map(({ sceneId, startSec, endSec, lyricText, visualIntent, prompt, framePrompt, camera }) =>
- ({ sceneId, startSec, endSec, lyricText, visualIntent, prompt, framePrompt, ...(camera ? { camera } : {}) })), treatment: project.treatment });
+ ({ sceneId, startSec, endSec, lyricText, visualIntent, prompt, framePrompt, ...(camera ? { camera } : {}) })), treatment: project.treatment };
+ const storyboard = hash(storyboardInputs);
+ // The same revision without each shot's own wording and span: a director rewording or retiming
+ // a shot keeps the board they approved, while new shots, lyrics, song or direction still stale it.
+ // A document storyboard's shots live in its source, so it has no such allowance.
+ const storyboardShots = draft.storyboardSource === 'document' ? null : hash({ ...storyboardInputs,
+ storyboard: Array.isArray(draft.storyboard) ? draft.storyboard.map(shot => shot?.sceneId ?? null) : draft.storyboard,
+ scenes: (project.scenes || []).map(({ sceneId, lyricText }) => ({ sceneId, lyricText })) });
const window = project.productionReview?.proof;
const proof = hash({ storyboard, composition: project.composition,
window: window && { startSec: window.startSec, endSec: window.endSec },
@@ -131,7 +147,7 @@ export function productionReviewBasis(project) {
.map(({ sceneId, referenceImageId, videoHistoryId, performanceEdit, direction, visualLayer }) =>
({ sceneId, referenceImageId, videoHistoryId, performanceEdit, direction, visualLayer })),
soundBed: project.soundBed, videoSettings: project.videoSettings });
- return { art, storyboard, proof };
+ return { art, storyboard, storyboardShots, proof };
}
/** Labeled per-input hashes so a stale approval can name what changed since. */
@@ -348,7 +364,7 @@ export function productionReadiness(project) {
if (overlapping.some(c => !shot?.lyricCueIds?.includes(c.id))
|| shot?.lyricCueIds?.some(id => !cues.some(c => c.id === id))) boardProblems.push(`Review lyric anchors for ${scene.label || 'each shot'}.`);
}
- const storyboardApproved = !boardProblems.length && review.approvals?.storyboard?.basis === basis.storyboard;
+ const storyboardApproved = !boardProblems.length && storyboardApprovalCurrent(review.approvals?.storyboard, basis);
const camera = storyboardCameraReport(scenes, documentShots ? null : boardStoryboard(project));
const proof = review.proof;
const excerpt = (project.excerpts || []).find(e => e.id === proof?.excerptId);
@@ -468,7 +484,7 @@ export function approveProductionStage(project, { stage, basis, proofReview, app
draft: { ...project.productionReview?.draft, storyboard: boardStoryboard(project) } } };
expected = productionReviewBasis(project).storyboard;
}
- const decision = { stage, basis: expected, inputs: productionApprovalInputs(project)[stage], values: productionApprovalValues(project, stage), approvedAt: new Date().toISOString(),
+ const decision = { stage, basis: expected, ...(stage === 'storyboard' ? { shotsBasis: productionReviewBasis(project).storyboardShots } : {}), inputs: productionApprovalInputs(project)[stage], values: productionApprovalValues(project, stage), approvedAt: new Date().toISOString(),
...(approvedBy ? { approvedBy } : {}), ...(reviewer ? { reviewer: structuredClone(reviewer) } : {}),
...(stage === 'proof' ? { proofReview: structuredClone(proofReview) } : {}) };
return { ...project, productionReview: { ...project.productionReview,
@@ -492,24 +508,25 @@ export function carryProductionApprovals(before, after, reason) {
for (const stage of ['art', 'storyboard', 'proof']) {
if (!was[stage]?.approved || !approvals[stage]) continue;
const next = stage === 'proof' ? hash({ basis: basis.proof, excerptId: proofExcerpt?.id, filename: proofExcerpt?.filename }) : basis[stage];
- approvals[stage] = { ...approvals[stage], basis: next, inputs: inputs[stage], carriedOver: { reason, at: new Date().toISOString() } };
+ approvals[stage] = { ...approvals[stage], basis: next, ...(stage === 'storyboard' ? { shotsBasis: basis.storyboardShots } : {}), inputs: inputs[stage], carriedOver: { reason, at: new Date().toISOString() } };
}
return { ...after, productionReview: { ...after.productionReview, approvals } };
}
/**
- * Keep a current storyboard approval across an edit that only cuts shots or
- * moves their timing (the director's own trims): it adds no shot, prompt or
- * lyric the approval did not already cover, so the director is not asked to
- * approve the same board again. The proof stays bound to its render and stales
+ * Keep a current storyboard approval across a director's own shot edit (a cut,
+ * a merge, a retime or a reworded prompt): it adds no shot or lyric the
+ * approval did not already cover, so the director is not asked to approve the
+ * same board again. The proof stays bound to its render and stales
* as before. Returns `after` unchanged when the storyboard was not approved on
* `before`'s current revision.
*/
export function carryStoryboardApproval(before, after, reason) {
const approval = before.productionReview?.approvals?.storyboard;
- if (!approval || approval.basis !== productionReviewBasis(before).storyboard) return after;
+ if (!storyboardApprovalCurrent(approval, productionReviewBasis(before))) return after;
+ const basis = productionReviewBasis(after);
const approvals = { ...after.productionReview?.approvals, storyboard: { ...approval,
- basis: productionReviewBasis(after).storyboard, inputs: productionApprovalInputs(after).storyboard,
+ basis: basis.storyboard, shotsBasis: basis.storyboardShots, inputs: productionApprovalInputs(after).storyboard,
carriedOver: { reason, at: new Date().toISOString() } } };
return { ...after, productionReview: { ...after.productionReview, approvals } };
}
diff --git a/server/services/musicVideo/productionReview.storyboard.test.js b/server/services/musicVideo/productionReview.storyboard.test.js
index 3d7f687938..5dc9fff40a 100644
--- a/server/services/musicVideo/productionReview.storyboard.test.js
+++ b/server/services/musicVideo/productionReview.storyboard.test.js
@@ -98,8 +98,28 @@ describe('the director trimming an approved storyboard', () => {
expect(productionReadiness(cut).storyboard.problems).toContain('Storyboard shots must cover the master without unintended gaps or overlaps.');
const { project: stretched } = applySceneUpdate(cut, 's1', { endSec: 6 });
expect(productionReadiness(stretched).storyboard).toMatchObject({ approved: true, stale: null });
- const { project: reprompted } = applySceneUpdate(stretched, 's1', { visualIntent: 'A new idea' });
- expect(productionReadiness(reprompted).storyboard.approved).toBe(false);
+ const { project: relyriced } = applySceneUpdate(stretched, 's1', { lyricText: 'A new line' });
+ expect(productionReadiness(relyriced).storyboard.approved).toBe(false);
+ });
+
+ // Uniquely catches rewording one approved shot (its prompt, or its storyboard row) un-approving the whole board.
+ it('keeps the approval when a shot is reworded, and stales it when a shot is added', () => {
+ const { project: reprompted } = applySceneUpdate(approvedBoard(), 's2', { visualIntent: 'ASCII-art music video on the CRT', prompt: 'Green ASCII frames' });
+ const rows = reprompted.productionReview.draft.storyboard.map((shot) => shot.sceneId === 's2' ? { ...shot, action: 'ASCII-art video plays' } : shot);
+ const reworded = { ...reprompted, productionReview: { ...reprompted.productionReview, draft: { ...reprompted.productionReview.draft, storyboard: rows } } };
+ expect(productionReadiness(reworded).storyboard).toMatchObject({ approved: true, stale: null });
+ // A row that drops its lyric anchor keeps the allowance but fails the anchor check, so the board is not approved.
+ const unanchoredRows = rows.map((shot) => shot.sceneId === 's1' ? { ...shot, lyricCueIds: [] } : shot);
+ const unanchored = productionReadiness({ ...reworded, productionReview: { ...reworded.productionReview,
+ draft: { ...reworded.productionReview.draft, storyboard: unanchoredRows } } }).storyboard;
+ expect(unanchored.approved).toBe(false);
+ expect(unanchored.problems).toContain('Review lyric anchors for Verse.');
+ const added = { ...reworded, scenes: [...reworded.scenes.map((scene) => scene.sceneId === 's3' ? { ...scene, endSec: 7 } : scene),
+ { sceneId: 's4', label: 'Extra', startSec: 7, endSec: 8, visualIntent: 'A new shot', framePrompt: 'Wide shot' }] };
+ const addedBoard = productionReadiness(added).storyboard;
+ expect(addedBoard.problems).toEqual([]);
+ expect(addedBoard.approved).toBe(false);
+ expect(addedBoard.stale.changedFields).toContain('scene 4 timing');
});
it('keeps the approval when two shots are merged into one', () => {
diff --git a/server/services/musicVideo/projectsLogic.js b/server/services/musicVideo/projectsLogic.js
index 9ad8e025c2..ec7f429e60 100644
--- a/server/services/musicVideo/projectsLogic.js
+++ b/server/services/musicVideo/projectsLogic.js
@@ -588,8 +588,10 @@ export function replaceScenes(project, sceneInputs) {
return { project: touch(project, { scenes }), scenes, replaced: existing.length };
}
-// Scene fields a trim changes without adding new content to the shot.
-const SCENE_RETIME_FIELDS = ['startSec', 'endSec', 'beatAligned'];
+// Scene fields a director edits within an approved shot (its span, wording and
+// selected takes) without adding a shot or lyric the storyboard approval did not cover.
+const SCENE_SHOT_EDIT_FIELDS = ['startSec', 'endSec', 'beatAligned', 'label', 'prompt', 'framePrompt', 'visualIntent',
+ 'referenceImageId', 'videoHistoryId', 'endImageId'];
/**
* Apply a patch to a single scene. Returns `{ project, updated }`. Throws if the
@@ -614,9 +616,9 @@ export function applySceneUpdate(project, sceneId, patch) {
const nextScenes = scenes.slice();
nextScenes[idx] = updated;
const next = touch(project, { scenes: nextScenes });
- // A trim that only moves the shot's span keeps the storyboard approval it was judged on.
- const retimeOnly = Object.keys(data).every((key) => SCENE_RETIME_FIELDS.includes(key));
- return { project: retimeOnly ? carryStoryboardApproval(project, next, 'Retimed a shot') : next, updated };
+ // Retiming or rewording a shot, or picking another take, keeps the storyboard approval it was judged on.
+ const shotEdit = Object.keys(data).every((key) => SCENE_SHOT_EDIT_FIELDS.includes(key));
+ return { project: shotEdit ? carryStoryboardApproval(project, next, 'Edited a shot') : next, updated };
}
/** Remove a scene and re-sequence the remaining scenes' `order`. Returns the next record. */