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
Merge pull request #9570 from atomantic/claim/issue-9549
[._.]/360d9a52cc75
diff --cc server/services/musicVideo/castAndSets.jsindex 3c8324bd33,87a95a49e5..172ae1ad37--- a/server/services/musicVideo/castAndSets.js+++ b/server/services/musicVideo/castAndSets.js@@@ -13,11 -13,10 +13,11 @@@* processId, // the server process that may dispatch for it* productionRunId, // the production run that started it, if any* route: { mode, model },- * direction, // castAndSetsDirection.js shape+ * direction, // castAndSetsDirection.js shape (`medium`: absent = photographic)* moodImages: [{ kind, filename }],* plan: { [key]: { key, kind, label, prompt, deps, refKeys, moodRefs?, setId?, testIndex? } },- * images: { [key]: { status, jobId, imageId, history, failures, error, updatedAt } },+ * images: { [key]: { status, jobId, imageId, history, failures, error, updatedAt,+ * submittedPrompt?, submittedPromptTruncated?, submittedReferences?, submittedRevision? } },* artifactId, artifactVersion, notesApplied,* createdAt, updatedAt, approvedAt,* }diff --cc server/services/musicVideo/castAndSetsService.test.jsindex 5712cd9141,b1be797b0c..d3885f558d--- a/server/services/musicVideo/castAndSetsService.test.js+++ b/server/services/musicVideo/castAndSetsService.test.js@@@ -362,55 -355,104 +362,155 @@@ it('uses project moodboard style imageexpect(jobs[0].params.prompt).toContain('silver grain');const dependent = jobs.find((j) => j.params.referenceImagePaths?.length > 1);expect(dependent.params.referenceImagePaths.at(-1)).toMatch(/style.png$/);+ const firstDispatch = snapshots.find((stage) => Object.values(stage.images).filter((image) => image.jobId).length === 1);+ expect(firstDispatch.images.character).toMatchObject({+ status: 'queued', submittedPrompt: jobs[0].params.prompt, submittedPromptTruncated: false,+ submittedReferences: [{ kind: 'image', filename: 'style.png' }], submittedRevision: 1,+ });+ const saved = (await current(project.id)).castAndSets.images.character;+ expect(saved.submittedPrompt).toBe(jobs[0].params.prompt);+ expect(saved.submittedPrompt).toContain('silver grain');+});++it('bounds submitted diagnostics and records only references served from approved image roots', async () => {+ const { PATHS } = await import('../../lib/paths.js');+ imageParamsOverrides = {+ prompt: 'x'.repeat(20_010),+ referenceImagePaths: [join(ROOT(), 'private', 'unserved.png'), join(PATHS.imageRefs, 'uploaded.png'),+ ...Array.from({ length: 17 }, (_, i) => join(IMAGES(), `example-${i}.png`))],+ };+ const project = await seed({ visualSpec: null });+ await service.startCastAndSets(project.id);+ await runTo(project.id, 'review');+ const saved = (await current(project.id)).castAndSets.images.character;+ expect(saved.submittedPrompt).toHaveLength(20_000);+ expect(saved.submittedPromptTruncated).toBe(true);+ expect(saved.submittedReferences).toHaveLength(16);+ expect(saved.submittedReferences[0]).toEqual({ kind: 'image-ref', filename: 'uploaded.png' });+ expect(saved.submittedReferencesTruncated).toBe(true);+ expect(JSON.stringify(saved)).not.toContain(ROOT());+ expect(JSON.stringify(saved)).not.toContain('unserved.png');+});++it('ignores a previous revision completion while regeneration has reserved a key but has no job id yet', async () => {+ const project = await seed();+ await service.startCastAndSets(project.id);+ await runTo(project.id, 'review');+ const previous = jobs.find((job) => keyOf(job) === 'character');+ let release;+ const held = new Promise((resolve) => { release = resolve; });+ enqueue.mockImplementationOnce(async (job) => { await held; return queueJob(job); });+ onTestFinished(release);+ await service.regenerateCastAndSets(project.id, { notes: [{ target: 'character', text: 'Shorter braid' }] });+ await until(async () => (await current(project.id)).castAndSets.images.character.status === 'queued', 'the reserved regeneration');+ const before = (await current(project.id)).castAndSets;+ expect(before.images.character).toMatchObject({ status: 'queued', jobId: null, imageId: `${previous.id}.png` });+ expect(await service.onCastAndSetsImageSettled({+ projectId: project.id, key: 'character', revision: previous.params.musicVideo.castAndSets.revision,+ jobId: previous.id, filename: 'obsolete.png',+ })).toBe(false);+ expect((await current(project.id)).castAndSets).toEqual(before);+ release();+ await runTo(project.id, 'review');+ expect((await current(project.id)).castAndSets.images.character.imageId).not.toBe(`${previous.id}.png`);});++ describe('Cast & Sets procedural check-in', () => {+ const PROCEDURAL = {+ logline: 'A paper boat crosses a neon city.',+ interpretation: 'The song reads as a small thing carried by a big current.',+ protagonist: {+ name: 'Boat', description: 'a folded paper boat', construction: 'three triangles hinged at the keel', shapeLanguage: 'sharp, folded',+ materials: 'flat fills with a soft glow', palette: '#f5f0e6, #ff5a1f', expressions: ['proud: bow lifts'], movement: 'bobs on every beat',+ },+ world: { layout: 'a river through stacked streets', depth: 'three parallax planes', camera: 'slow dolly with a beat-synced push', transitions: 'wipe through reflections' },+ looks: [],+ sets: [+ { id: 'river', name: 'River', description: 'a neon river', lighting: 'magenta', imageRole: 'background', sections: [0] },+ { id: 'bridge', name: 'Bridge', description: 'an iron span', lighting: 'cyan', imageRole: 'decoration', sections: [1] },+ { id: 'quay', name: 'Quay', description: 'wet stone', lighting: 'amber', imageRole: 'texture', sections: [2] },+ ],+ songMap: [{ section: 0, setId: 'river' }, { section: 1, setId: 'bridge' }, { section: 2, setId: 'quay' }],+ overlayConcept: { summary: 'A tide clock.', elements: [] },+ moodRefs: [],+ questions: [],+ };+ const seedProcedural = (tools) => seed({+ productionPolicy: { strategy: 'code-first', maxGeneratedVideoPercent: 0 },+ automation: { tools, checkins: { castAndSets: 'review' } },+ });++ beforeEach(() => {+ runPrompt.mockResolvedValue({ text: JSON.stringify(PROCEDURAL) });+ });++ it('directs an image+code project with role-planned plates and no photographic batch, then carries the rules into the planner context', async () => {+ const project = await seedProcedural(['image:codex', 'code:render']);+ await service.startCastAndSets(project.id);+ await runTo(project.id, 'review');++ const prompt = runPrompt.mock.calls[0][0].prompt;+ expect(prompt).toContain('PROCEDURAL music video');+ // Only role-prompted set plates: no character, looks, expression or test photography.+ expect(jobs.map(keyOf).sort()).toEqual(['set:bridge', 'set:quay', 'set:river']);+ const byKey = Object.fromEntries(jobs.map((j) => [keyOf(j), j.params.prompt]));+ expect(byKey['set:river']).toMatch(/background plate/);+ expect(byKey['set:bridge']).toMatch(/isolated decorative element/);+ expect(byKey['set:quay']).toMatch(/Seamless tileable/);+ expect(Object.values(byKey).join(' ')).not.toMatch(/photoreal|person|FRONT/i);++ const reviewing = await current(project.id);+ expect(reviewing.castAndSets.direction).toMatchObject({ medium: 'procedural', world: { camera: 'slow dolly with a beat-synced push' } });+ const artifact = reviewing.devArtifacts.find((a) => a.id === reviewing.castAndSets.artifactId);+ const html = readFileSync(join(ROOT(), artifact.file), 'utf8');+ expect(html).toContain('three triangles hinged at the keel');+ expect(html).toContain('Role: decoration');+ expect(html).not.toContain('Character reference sheet');++ await service.approveCastAndSets(project.id);+ const done = await current(project.id);+ // Only the background plate conditions frame generation; texture and decoration stay loose references.+ expect(done.visualSpec.references.filter((r) => r.id.startsWith('mvr-cs-')).map((r) => [r.id, r.condition]).sort()).toEqual([+ ['mvr-cs-set-bridge', false], ['mvr-cs-set-quay', false], ['mvr-cs-set-river', true],+ ]);+ expect(done.concept.subjects.find((s) => s.id === 'cs-protagonist').description).toContain('three triangles hinged at the keel');++ // The approved motion, camera and construction reach the planner request.+ const { buildScenePlanPrompt } = await import('./planner.js');+ const planPrompt = buildScenePlanPrompt(done, [{ startSec: 0, endSec: 8, sectionIndex: 0, shotIndex: 0, shotCount: 1, sectionLabel: 'Intro', lyricText: '', delivery: [] }]);+ expect(planPrompt).toContain('slow dolly with a beat-synced push');+ expect(planPrompt).toContain('bobs on every beat');+ expect(planPrompt).toContain('image role: decoration');+ });++ it('directs a code-only project without any image backend and still waits for the director', async () => {+ const resolveRoute = vi.fn(async () => null);+ service.__setCastAndSetsDepsForTests({+ resolveProvider: async () => ({ provider: { id: 'example-provider', enabled: true }, selectedModel: 'example-model' }),+ runPrompt, getSettings: async () => ({}), enqueue, resolveRoute,+ loadBoard: async () => null, loadTrack: async () => null,+ });+ const project = await seedProcedural(['code:render']);+ await service.startCastAndSets(project.id);+ await until(async () => (await current(project.id)).castAndSets?.status === 'review', 'the code-only check-in');+ const stage = (await current(project.id)).castAndSets;+ expect(jobs).toEqual([]);+ expect(resolveRoute).not.toHaveBeenCalled();+ expect(stage.plan).toEqual({});+ expect(stage.direction.protagonist.construction).toBe('three triangles hinged at the keel');+ const html = readFileSync(join(ROOT(), (await current(project.id)).devArtifacts[0].file), 'utf8');+ expect(html).toContain('No raster image: drawn in code');+ });++ it('keeps the medium of a saved direction when the project settings change before a revision', async () => {+ const project = await seedProcedural(['image:codex', 'code:render']);+ await service.startCastAndSets(project.id);+ await runTo(project.id, 'review');+ await projects.mutateProjectRecord(project.id, (p) => ({ project: { ...p, productionPolicy: { strategy: 'legacy', maxGeneratedVideoPercent: 100 }, automation: { ...p.automation, tools: ['image:codex'] } } }));+ await service.regenerateCastAndSets(project.id, { notes: [{ text: 'make the camera slower' }] });+ await until(async () => runPrompt.mock.calls.length === 2, 'the revision call');+ expect(runPrompt.mock.calls[1][0].prompt).toContain('PROCEDURAL music video');+ await runTo(project.id, 'review');+ expect((await current(project.id)).castAndSets.direction.medium).toBe('procedural');+ });+ });