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

fix([issue-766]): address codex review — validate the settings default against the registry too

[._.]/ Adam Eivy32dc72fb6a9d
diff --git a/server/services/pipeline/episodeVideo.js b/server/services/pipeline/episodeVideo.js
index d0a42d558e..d2f2e1ce32 100644
--- a/server/services/pipeline/episodeVideo.js
+++ b/server/services/pipeline/episodeVideo.js
@@ -179,11 +179,24 @@ export async function startEpisodeVideoForIssue(issueId, options = {}) {
// 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)) {
+ // `null` when the registry can't be validated (empty list) — in that case
+ // isKnown() is never consulted and every candidate id passes through.
+ const isKnown = knownModels.length ? (id) => knownModels.some((m) => m.id === id) : null;
+ if (requestedModelId && isKnown && !isKnown(requestedModelId)) {
console.log(`⚠️ Pipeline episode video — unknown modelId "${requestedModelId}" not in registry; dropping to default`);
requestedModelId = null;
}
- const modelId = requestedModelId || settings?.videoGen?.defaultModelId || getDefaultVideoModelId();
+ // Resolve the concrete model the CD renderer needs. The saved videoGen
+ // default can be just as stale as the explicit pick, so validate it the same
+ // way before trusting it — otherwise a broken settings default would still
+ // reach createCDProject and defeat the drop-to-default contract.
+ // getDefaultVideoModelId() is the final fallback and self-validates against
+ // the platform's available list.
+ const settingsDefault = settings?.videoGen?.defaultModelId || null;
+ const resolvedDefault = (settingsDefault && (!isKnown || isKnown(settingsDefault)))
+ ? settingsDefault
+ : getDefaultVideoModelId();
+ const modelId = requestedModelId || resolvedDefault;
const project = await createCDProject({
name: `Pipeline: ${(series?.name || 'Series').slice(0, 60)} — ${(issue.title || issueId).slice(0, 60)}`,
diff --git a/server/services/pipeline/episodeVideo.test.js b/server/services/pipeline/episodeVideo.test.js
index f5185203f9..d720d33ce1 100644
--- a/server/services/pipeline/episodeVideo.test.js
+++ b/server/services/pipeline/episodeVideo.test.js
@@ -54,6 +54,7 @@ vi.mock('../settings.js', () => ({
const svc = await import('./episodeVideo.js');
const issuesSvc = await import('./issues.js');
const seriesSvc = await import('./series.js');
+const settingsMod = await import('../settings.js');
async function seedSeriesAndIssue({ scenes = [] } = {}) {
const series = await seriesSvc.createSeries({
@@ -329,6 +330,23 @@ describe('pipeline episodeVideo helper', () => {
expect(refreshed.stages.episodeVideo.modelId).toBeNull();
});
+ it('startEpisodeVideoForIssue resolves a stale settings default through the registry too', async () => {
+ // The Default choice (no explicit pick) resolves the concrete model from
+ // videoGen.defaultModelId — but that saved default can be just as stale as
+ // an explicit pick. A broken settings default must not reach the CD project;
+ // it falls through to getDefaultVideoModelId() (which self-validates).
+ settingsMod.getSettings.mockResolvedValueOnce({ videoGen: { defaultModelId: 'pruned_default' } });
+ const { issue } = await seedSeriesAndIssue({
+ scenes: [{ description: 'foo' }],
+ });
+ await svc.startEpisodeVideoForIssue(issue.id);
+ expect(cdCreated[0].modelId).toBe('ltx23_distilled_q4');
+ // The recorded choice is still Default (null) — the stale *setting* is the
+ // user's to fix; we only resolve a working model for this render.
+ 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