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([issue-766]): drop stale episodeVideo modelId to default when absent from registry
[._.]/ Adam Eivy079c13a8e64d
diff --git a/server/services/pipeline/episodeVideo.js b/server/services/pipeline/episodeVideo.jsindex 584a099720..d0a42d558e 100644--- a/server/services/pipeline/episodeVideo.js+++ b/server/services/pipeline/episodeVideo.js@@ -19,7 +19,7 @@ import { getSeries } from './series.js';import { getSeriesCanon } from './seriesCanon.js';import { createProject as createCDProject, setTreatment as setCDTreatment } from '../creativeDirector/local.js';import { startCreativeDirectorProject } from '../creativeDirector/completionHook.js';-import { getDefaultVideoModelId } from '../../lib/mediaModels.js';+import { getDefaultVideoModelId, getVideoModels } from '../../lib/mediaModels.js';import { buildPlaceByKey } from '../../lib/scenePrompt.js';import { getSettings } from '../settings.js';@@ -165,7 +165,24 @@ export async function startEpisodeVideoForIssue(issueId, options = {}) {// user setting (videoGen.defaultModelId), so we persist the *choice* — not// the resolved id — and keep "Default" following the setting across reloads.// The CD project's renderer still needs a concrete model, so resolve one here.- const requestedModelId = options.modelId || null;+ // Validate an explicit picker choice against the live video-model registry.+ // A persisted `modelId` can go stale if the model is later renamed/pruned —+ // on restart it would flow into createCDProject and fail asynchronously on+ // the CD project's failureReason. Drop a now-unknown id to the resolved+ // default so the render degrades cleanly instead.+ //+ // Sentinel rule: only drop when the registry has a NON-EMPTY list to validate+ // against. An empty list means "can't validate on this platform" (e.g. every+ // video model flagged broken) — NOT "this id is unknown" — so we pass the id+ // through rather than silently swapping a possibly-valid choice for a default+ // that's equally unresolvable. This mirrors getDefaultVideoModelId, which+ // returns the configured id unchanged when there's nothing to fall back to.+ let requestedModelId = options.modelId || null;+ const knownModels = getVideoModels();+ if (requestedModelId && knownModels.length && !knownModels.some((m) => m.id === requestedModelId)) {+ console.log(`⚠️ Pipeline episode video — unknown modelId "${requestedModelId}" not in registry; dropping to default`);+ requestedModelId = null;+ }const modelId = requestedModelId || settings?.videoGen?.defaultModelId || getDefaultVideoModelId();const project = await createCDProject({diff --git a/server/services/pipeline/episodeVideo.test.js b/server/services/pipeline/episodeVideo.test.jsindex 76e4bbfff7..f5185203f9 100644--- a/server/services/pipeline/episodeVideo.test.js+++ b/server/services/pipeline/episodeVideo.test.js@@ -38,8 +38,13 @@ vi.mock('../creativeDirector/completionHook.js', () => ({startCreativeDirectorProject: vi.fn(async () => undefined),}));+let mockVideoModels = [+ { id: 'ltx23_distilled_q4' },+ { id: 'ltx2_unified' },+];vi.mock('../../lib/mediaModels.js', () => ({getDefaultVideoModelId: () => 'ltx23_distilled_q4',+ getVideoModels: () => mockVideoModels,}));vi.mock('../settings.js', () => ({@@ -76,6 +81,10 @@ describe('pipeline episodeVideo helper', () => {cdCreated.length = 0;cdTreatments.length = 0;uuidCounter = 0;+ mockVideoModels = [+ { id: 'ltx23_distilled_q4' },+ { id: 'ltx2_unified' },+ ];vi.clearAllMocks();});@@ -305,6 +314,35 @@ describe('pipeline episodeVideo helper', () => {expect(refreshed.stages.episodeVideo.modelId).toBeNull();});+ it('startEpisodeVideoForIssue drops a stale modelId (absent from the registry) to the default', async () => {+ const { issue } = await seedSeriesAndIssue({+ scenes: [{ description: 'foo' }],+ });+ // 'pruned_model' was a valid pick once but has since been renamed/removed+ // from the registry — it should degrade to the resolved default rather than+ // flow into the CD project and fail asynchronously.+ await svc.startEpisodeVideoForIssue(issue.id, { modelId: 'pruned_model' });+ expect(cdCreated[0].modelId).toBe('ltx23_distilled_q4');+ // The stale choice is cleared on the stage too (null = Default), so a reload+ // doesn't keep re-submitting the dead id.+ const refreshed = await issuesSvc.getIssue(issue.id);+ expect(refreshed.stages.episodeVideo.modelId).toBeNull();+ });++ it('startEpisodeVideoForIssue passes an explicit modelId through when the registry is empty (cannot validate)', async () => {+ // An empty registry means "no models to validate against on this platform",+ // NOT "this id is unknown" — so a possibly-valid id must not be silently+ // swapped for an equally-unresolvable default.+ mockVideoModels = [];+ const { issue } = await seedSeriesAndIssue({+ scenes: [{ description: 'foo' }],+ });+ await svc.startEpisodeVideoForIssue(issue.id, { modelId: 'some_byov_model' });+ expect(cdCreated[0].modelId).toBe('some_byov_model');+ const refreshed = await issuesSvc.getIssue(issue.id);+ expect(refreshed.stages.episodeVideo.modelId).toBe('some_byov_model');+ });+it('startEpisodeVideoForIssue reuses an existing cdProjectId by default', async () => {const { issue } = await seedSeriesAndIssue({scenes: [{ description: 'one' }, { description: 'two' }, { description: '' }],