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

Condition Cast & sets character sheets on the director's own references

atomantice2d8393fbddf
diff --git a/client/src/components/musicVideo/CastAndSetsReferenceProgress.jsx b/client/src/components/musicVideo/CastAndSetsReferenceProgress.jsx
index 0e9cbec995..2b96e0e44f 100644
--- a/client/src/components/musicVideo/CastAndSetsReferenceProgress.jsx
+++ b/client/src/components/musicVideo/CastAndSetsReferenceProgress.jsx
@@ -16,8 +16,11 @@ function previewItem(ref, prompt) {
function cardReferences(item, stage) {
const image = stage.images?.[item.key] || {};
if (typeof image.submittedPrompt === 'string') return image.submittedReferences || [];
- return (item.refKeys || []).flatMap((key) => stage.images?.[key]?.imageId
- ? [{ kind: 'image', filename: stage.images[key].imageId }] : []);
+ return [
+ ...(item.refKeys || []).flatMap((key) => stage.images?.[key]?.imageId
+ ? [{ kind: 'image', filename: stage.images[key].imageId }] : []),
+ ...(item.refImages || []).map((filename) => ({ kind: 'image', filename })),
+ ];
}
/**
diff --git a/server/services/musicVideo/castAndSets.js b/server/services/musicVideo/castAndSets.js
index abaac02f61..d7475b6fa2 100644
--- a/server/services/musicVideo/castAndSets.js
+++ b/server/services/musicVideo/castAndSets.js
@@ -14,7 +14,7 @@
* productionRunId, // the production run that started it, if any
* route: { mode, model },
* direction, // castAndSetsDirection.js shape (`medium`: absent = photographic)
- * plan: { [key]: { key, kind, label, prompt, deps, refKeys, setId?, testIndex? } },
+ * plan: { [key]: { key, kind, label, prompt, deps, refKeys, refImages?, setId?, testIndex? } },
* images: { [key]: { status, jobId, imageId, history, failures, error, updatedAt,
* submittedPrompt?, submittedPromptTruncated?, submittedReferences?, submittedRevision? } },
* artifactId, artifactVersion, notesApplied,
diff --git a/server/services/musicVideo/castAndSetsPlan.js b/server/services/musicVideo/castAndSetsPlan.js
index 26284126dd..d9edce64be 100644
--- a/server/services/musicVideo/castAndSetsPlan.js
+++ b/server/services/musicVideo/castAndSetsPlan.js
@@ -7,7 +7,8 @@
* The prompts generalize the hand-made check-in's templates:
* - `character` — the canonical five-view character sheet. First, and every
* image of the protagonist after it uses it as reference #1.
- * It has no image references: mood board images are
+ * Its references are the director's own character
+ * identity images (`refImages`); mood board images are
* outside inspiration and only reach it as text.
* - `expressions` — a 2×3 expression sheet including the signature gesture.
* - `looks` — the wardrobe lookbook, one panel per look.
@@ -25,6 +26,7 @@
*/
import { trimTo } from '../../lib/textUtils.js';
+import { isOutsideMusicVideoReference } from '../../lib/musicVideoConditioning.js';
import { songSections } from './castAndSetsDirection.js';
export const CAST_SETS_IMAGE_SIZE = Object.freeze({ width: 1536, height: 1024 });
@@ -59,6 +61,19 @@ function identity(p) {
return [p.face && `face: ${p.face}`, p.hair && `hair: ${p.hair}`].filter(Boolean).join('; ');
}
+/**
+ * The director's own identity references for the protagonist: the project's
+ * character references flagged to condition frames (their uploads or images
+ * PortOS rendered), never a mood board import or Pinterest pin, and never an
+ * earlier Cast & Sets output (the sheet would condition on itself).
+ */
+function identityImages(project) {
+ return [...new Set((project?.visualSpec?.references || [])
+ .filter((r) => r?.role === 'character' && r.condition && r.imageId
+ && !String(r.id || '').startsWith(CAST_SETS_REF_PREFIX) && !isOutsideMusicVideoReference(r))
+ .map((r) => r.imageId))].slice(0, MAX_CONDITIONING);
+}
+
function rulesLine(p) {
return (p.rules || []).length ? `Rules: ${p.rules.join('; ')}` : '';
}
@@ -130,9 +145,10 @@ function buildProceduralImagePlan(direction, { revisionNotes = {} } = {}) {
/**
* Build the full image plan for a direction: `{ [key]: { key, kind, label,
- * prompt, deps, refKeys, setId?, testIndex? } }`. `refKeys` name other plan
- * keys whose image is passed as a reference (in order): only this project's
- * own generated images, never mood board images. A revision note for a key is
+ * prompt, deps, refKeys, refImages?, setId?, testIndex? } }`. `refKeys` name
+ * other plan keys whose image is passed as a reference (in order), then
+ * `refImages` (the director's character identity images) follow: only the
+ * project's own images, never mood board images. A revision note for a key is
* appended to its prompt.
*/
export function buildCastAndSetsImagePlan(project, direction, { revisionNotes = {} } = {}) {
@@ -143,6 +159,7 @@ export function buildCastAndSetsImagePlan(project, direction, { revisionNotes =
const style = trimTo(direction.look, 500) || trimTo(project?.concept?.style, 500);
const firstLight = direction.sets?.[0]?.lighting || '';
const note = (key) => (revisionNotes[key] ? `Revision: ${revisionNotes[key]}` : '');
+ const identities = identityImages(project);
const plan = {};
plan.character = {
@@ -151,8 +168,10 @@ export function buildCastAndSetsImagePlan(project, direction, { revisionNotes =
label: 'Character sheet',
deps: [],
refKeys: [],
+ refImages: identities,
prompt: join(
`Photographic character reference sheet of ONE consistent person, ${p.name || 'the protagonist'}: ${p.description || ''}`,
+ identities.length && 'The SAME person as the identity reference images: keep their face, hair and build exactly',
identity(p),
p.signature && `Signature detail, always visible: ${p.signature}`,
firstLook && `Wearing ${firstLook.description}`,
@@ -170,6 +189,7 @@ export function buildCastAndSetsImagePlan(project, direction, { revisionNotes =
label: 'Expression sheet',
deps: ['character'],
refKeys: ['character'],
+ refImages: identities,
prompt: join(
'Photographic expression sheet, 2 rows x 3 columns grid of tight close-ups of the SAME person as the character reference',
identity(p),
@@ -188,6 +208,7 @@ export function buildCastAndSetsImagePlan(project, direction, { revisionNotes =
label: 'Looks',
deps: ['character'],
refKeys: ['character'],
+ refImages: identities,
prompt: join(
`Fashion lookbook sheet of the SAME person as the character reference, ${looks.length} full-body panels side by side`,
identity(p),
@@ -258,7 +279,8 @@ export function affectedImageKeys(previousPlan, nextPlan, force = []) {
const out = new Set(force.filter((k) => nextPlan[k]));
for (const [key, item] of Object.entries(nextPlan)) {
const before = previousPlan?.[key];
- if (!before || before.prompt !== item.prompt || before.refKeys.join('|') !== item.refKeys.join('|')) out.add(key);
+ if (!before || before.prompt !== item.prompt || before.refKeys.join('|') !== item.refKeys.join('|')
+ || (before.refImages || []).join('|') !== (item.refImages || []).join('|')) out.add(key);
}
let grew = true;
while (grew) {
diff --git a/server/services/musicVideo/castAndSetsService.js b/server/services/musicVideo/castAndSetsService.js
index a7d7a734bf..66c381fb31 100644
--- a/server/services/musicVideo/castAndSetsService.js
+++ b/server/services/musicVideo/castAndSetsService.js
@@ -272,6 +272,10 @@ function referencePaths(stage, item) {
const path = id ? resolveGalleryImage(id, { mustExist: false }) : null;
if (path) paths.push(path);
}
+ for (const id of item.refImages || []) {
+ const path = resolveGalleryImage(id, { mustExist: false });
+ if (path && !paths.includes(path)) paths.push(path);
+ }
return paths.slice(0, 4);
}
diff --git a/server/services/musicVideo/castAndSetsService.test.js b/server/services/musicVideo/castAndSetsService.test.js
index b3211c582a..31cae5233c 100644
--- a/server/services/musicVideo/castAndSetsService.test.js
+++ b/server/services/musicVideo/castAndSetsService.test.js
@@ -808,6 +808,26 @@ describe('Cast & Sets procedural check-in', () => {
});
+it('conditions the character, expressions and looks sheets on the director\'s own character references only', async () => {
+ const project = await seed({ visualSpec: { moodBoardId: 'mb-1', references: [
+ { id: 'own-upload', imageId: 'upload-face.png', role: 'character', condition: true },
+ { id: 'own-render', imageId: 'rendered-face.png', role: 'character', condition: true },
+ { id: 'mvr-board-1', imageId: 'board-face.png', role: 'character', condition: true },
+ { id: 'pinned', imageId: 'pinterest-0123456789abcdef.jpg', role: 'character', condition: true },
+ { id: 'mvr-cs-character', imageId: 'old-sheet.png', role: 'character', condition: true },
+ { id: 'unflagged', imageId: 'spare-face.png', role: 'character', condition: false },
+ ] } });
+ await service.startCastAndSets(project.id);
+ await runTo(project.id, 'review');
+ const refs = (key) => jobs.findLast((j) => keyOf(j) === key).params.referenceImagePaths?.map((p) => p.split(/[\\/]/).pop());
+ const character = jobs.find((j) => keyOf(j) === 'character');
+ expect(refs('character')).toEqual(['upload-face.png', 'rendered-face.png']);
+ expect(character.params.prompt).toContain('SAME person as the identity reference images');
+ expect(refs('expressions')).toEqual([`${character.id}.png`, 'upload-face.png', 'rendered-face.png']);
+ expect(refs('looks')).toEqual([`${character.id}.png`, 'upload-face.png', 'rendered-face.png']);
+ expect(refs('set:lab')).toBeUndefined();
+});
+
it('keeps people out of set plates: no mood board person in the look, no character action in a set', async () => {
const personBoard = { ...board, style: { prompt: 'An adult woman with tousled curls sits alone beside a rain-speckled window. Amber haze.' } };
service.__setCastAndSetsDepsForTests(testDeps({ loadBoard: async () => personBoard }));