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
fix: validate persisted plate evidence and retain interrupted review charges (#9346)
[._.]/ Adam Eivy6b50975fcec7
diff --git a/client/src/components/musicVideo/PlateComparison.test.jsx b/client/src/components/musicVideo/PlateComparison.test.jsxindex c04b90d3f8..75d4c91390 100644--- a/client/src/components/musicVideo/PlateComparison.test.jsx+++ b/client/src/components/musicVideo/PlateComparison.test.jsx@@ -1,14 +1,14 @@import { render, screen } from '@testing-library/react';-import { describe, expect, it } from 'vitest';-import { plateRequirementBasis } from '../../../../server/lib/musicVideoPlateEvidence.js';+import { expect, it } from 'vitest';+import { plateRequirementBasis, plateRequirements } from '../../../../server/lib/musicVideoPlateEvidence.js';import PlateComparison from './PlateComparison.jsx';it('compares the exact selected and candidate plates and reveals missing subjects', () => {- const scene = { sceneId: 'shot-a', referenceImageId: 'one-person.png', direction: { actionContract: { version: 1, purpose: 'Two people greet' } }, takes: [] };+ const scene = { sceneId: 'shot-a', referenceImageId: 'one-person.png', direction: { actionContract: { version: 1, purpose: 'Two people greet', activeSpeaker: 'Person B' } }, takes: [] };const basis = plateRequirementBasis(scene);scene.takes = [- { kind: 'image', assetId: 'one-person.png', plateEvidence: { assetId: 'one-person.png', basis, verdict: 'fail', checks: [{ id: 'person-b', status: 'fail', requirement: 'Second subject visible', note: 'Only one person is visible' }] } },- { kind: 'image', assetId: 'two-people.png', plateEvidence: { assetId: 'two-people.png', basis, verdict: 'pass', checks: [] } },+ { kind: 'image', assetId: 'one-person.png', plateEvidence: { assetId: 'one-person.png', basis, verdict: 'fail', checks: plateRequirements(scene).map(({ id, requirement }) => ({ id, requirement, status: id === 'plate-1' ? 'fail' : 'pass', note: id === 'plate-1' ? 'Only one person is visible' : 'Visible' })) } },+ { kind: 'image', assetId: 'two-people.png', plateEvidence: { assetId: 'two-people.png', basis, verdict: 'pass', checks: plateRequirements(scene).map(({ id, requirement }) => ({ id, requirement, status: 'pass', note: 'Visible' })) } },];const { rerender } = render(<PlateComparison scene={scene} />);expect(screen.getByText('Selected · Requirements unmet')).toBeInTheDocument();@@ -18,3 +18,10 @@ it('compares the exact selected and candidate plates and reveals missing subjectexpect(screen.getByText('Selected · Unverified')).toBeInTheDocument();expect(screen.queryByText('Candidate · Ready')).not.toBeInTheDocument();});++it('treats malformed persisted checks as unverified instead of crashing', () => {+ const scene = { sceneId: 'shot-a', referenceImageId: 'example.png', direction: { actionContract: { version: 1, purpose: 'A greeting' } }, takes: [] };+ scene.takes.push({ kind: 'image', assetId: 'example.png', plateEvidence: { assetId: 'example.png', basis: plateRequirementBasis(scene), verdict: 'pass', checks: [null] } });+ render(<PlateComparison scene={scene} />);+ expect(screen.getByText('Selected · Unverified')).toBeInTheDocument();+});diff --git a/server/lib/musicVideoPlateEvidence.js b/server/lib/musicVideoPlateEvidence.jsindex 11df8c1333..7bb44edc92 100644--- a/server/lib/musicVideoPlateEvidence.js+++ b/server/lib/musicVideoPlateEvidence.js@@ -28,7 +28,14 @@ export function plateRequirements(scene) {/** A selection or shot edit cannot borrow evidence from a different image or intent. */export function currentPlateEvidence(scene, take) {const evidence = take?.plateEvidence;- return evidence && take && evidence.assetId === take.assetId && evidence.basis === plateRequirementBasis(scene) ? evidence : null;+ if (!evidence || !take || evidence.assetId !== take.assetId || evidence.basis !== plateRequirementBasis(scene) || !Array.isArray(evidence.checks)) return null;+ const requirements = plateRequirements(scene);+ if (evidence.checks.length !== requirements.length || new Set(evidence.checks.map((check) => check?.id)).size !== requirements.length+ || requirements.some(({ id, requirement }) => !evidence.checks.some((check) => check?.id === id && check.requirement === requirement+ && ['pass', 'fail', 'unverified'].includes(check.status) && typeof check.note === 'string' && check.note.trim()))) return null;+ const verdict = evidence.checks.some((check) => check.status === 'unverified') ? 'unverified'+ : evidence.checks.some((check) => check.status === 'fail') ? 'fail' : 'pass';+ return evidence.verdict === verdict ? evidence : null;}export function selectedPlatePasses(scene, runId) {diff --git a/server/services/musicVideo/productionService.test.js b/server/services/musicVideo/productionService.test.jsindex 40161b6f7a..22ebccba3c 100644--- a/server/services/musicVideo/productionService.test.js+++ b/server/services/musicVideo/productionService.test.js@@ -1,3 +1,4 @@+import { startProductionOnProject, markProductionPlanned, reserveProductionStep } from './production.js';import { plateReviewEvidence } from './plateReview.js';import { plateRequirements } from '../../lib/musicVideoPlateEvidence.js';import { captureMusicVideoEvidence } from '../../lib/musicVideoDependencies.js';@@ -952,6 +953,23 @@ describe('authored plate preflight', () => {expect(theRun().usage.generations).toBe(1);});+ it('leaves interrupted plate reservations charged and calls no provider until explicit resume', async () => {+ const project = seedProject({ scenes: [plateScene()] });+ const started = startProductionOnProject(project, { pool: POOL, limits: LIMITS, processId: 'previous-process' });+ const planned = markProductionPlanned(started.project, started.run.id);+ const reserved = reserveProductionStep(planned.project, started.run.id, { kind: 'plate', sceneId: 'mvs-a', route: { kind: 'plate', mode: 'reviewer-example', model: 'vision-example' }, costUsd: 0, processId: 'previous-process' });+ store.set(project.id, reserved.project);+ await service.__advanceProductionForTests(project.id, started.run.id);+ expect(reviewPlate).not.toHaveBeenCalled();+ expect(dispatch).not.toHaveBeenCalled();+ await service.resumeProduction(project.id, started.run.id);+ await settle();+ expect(theRun().steps[0]).toMatchObject({ kind: 'plate', status: 'failed' });+ expect(theRun().usage.generations).toBe(3);+ expect(reviewPlate).toHaveBeenCalledTimes(1);+ expect(dispatch.mock.calls.map(([args]) => args.stepKind)).toEqual(['clip']);+ });+it('honors cancellation while plate analysis is running, retaining its spend and no video job', async () => {seedProject({ scenes: [plateScene()] });let finish;diff --git a/server/services/musicVideo/projectsFile.test.js b/server/services/musicVideo/projectsFile.test.jsindex 9a06ac0d17..f9e76508b8 100644--- a/server/services/musicVideo/projectsFile.test.js+++ b/server/services/musicVideo/projectsFile.test.js@@ -1,3 +1,5 @@+import { plateReviewEvidence } from './plateReview.js';+import { plateRequirements, selectedPlatePasses } from '../../lib/musicVideoPlateEvidence.js';/*** Music Video file-backend round-trip (#1760). Runs against a tmpdir in the* normal (non-DB) suite — covers create/list/get/update/delete + the scene-board@@ -316,3 +318,21 @@ describe('projectsFile federation (#1770)', () => {expect((await file.listProjectIds({ includeDeleted: true })).sort()).toEqual([keep.id, 'mv-new-tomb'].sort());});});++it('roundtrips asset-bound plate evidence through the real serialized project store and retains it on selection', async () => {+ const project = await file.createProject({ name: 'Example Video' });+ const scene = await file.addProjectScene(project.id, { startSec: 0, endSec: 4 });+ await file.updateScene(project.id, scene.sceneId, { referenceImageId: 'example.png' });+ await file.mutateProjectRecord(project.id, (current) => {+ const live = { ...current.scenes[0], direction: { actionContract: { version: 1, purpose: 'Two people greet', activeSpeaker: 'Person A' } } };+ const evidence = plateReviewEvidence(live, 'example.png', 'run-example', JSON.stringify({ checks: plateRequirements(live).map(({ id }) => ({ id, status: 'pass', note: 'Visible' })) }));+ return { project: { ...current, scenes: [{ ...live, takes: live.takes.map((take) => ({ ...take, plateEvidence: evidence })) }] } };+ });+ const read = await file.getProject(project.id);+ expect(selectedPlatePasses(read.scenes[0], 'run-example')).toBe(true);+ expect(read.scenes[0].takes[0].plateEvidence.assetId).toBe('example.png');+ await file.updateScene(project.id, scene.sceneId, { referenceImageId: 'changed.png' });+ const changed = await file.getProject(project.id);+ expect(selectedPlatePasses(changed.scenes[0], 'run-example')).toBe(false);+ expect(changed.scenes[0].takes.find((take) => take.assetId === 'example.png').plateEvidence.verdict).toBe('pass');+});