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

address review: skip first-pass gen when local pythonPath unset; parallelize per-member reads

[._.]/ Adam Eivy5c5e3df6c624
diff --git a/server/routes/creativeDirector.js b/server/routes/creativeDirector.js
index 4c19008b79..8aaa7dfdac 100644
--- a/server/routes/creativeDirector.js
+++ b/server/routes/creativeDirector.js
@@ -124,7 +124,8 @@ router.post('/:id/auto-cast', asyncHandler(async (req, res) => {
// First-pass gen (#1818): when opted in, kick off a catalog portrait render
// for each member auto-cast just added that has no portrait yet. The renders
// are enqueued onto the media-job queue and land via the durable catalog
- // attach hook (#1359) — we await only the (fast) enqueue so the response can
+ // attach hook (#1359). We await the enqueue (which resolves each member's
+ // render decision concurrently, then queues synchronously) so the response can
// report how many were queued; the renders themselves run in the background.
let firstPass = null;
if (generateFirstPass && Array.isArray(result.added) && result.added.length > 0) {
diff --git a/server/services/creativeDirector/firstPassGen.js b/server/services/creativeDirector/firstPassGen.js
index 0dcfa6d3b1..4ebc27c275 100644
--- a/server/services/creativeDirector/firstPassGen.js
+++ b/server/services/creativeDirector/firstPassGen.js
@@ -71,15 +71,20 @@ async function resolveQueueModeParams() {
};
}
if (mode === IMAGE_GEN_MODE.LOCAL) {
+ // We pass no modelId, so the worker renders with its default ('dev') model —
+ // an mflux model that REQUIRES a configured pythonPath (the imageGen route
+ // and universeBuilderRender both reject this up front with
+ // IMAGE_GEN_NOT_CONFIGURED). First-pass gen runs fire-and-forget with no
+ // client listening, so a doomed job's SSE failure would vanish while the
+ // user is told portraits are rendering. Skip cleanly instead — same
+ // graceful-skip contract as a disabled codex.
+ const pythonPath = settings.imageGen?.local?.pythonPath || null;
+ if (!pythonPath) return { mode, ready: false, reason: 'local-not-configured' };
const { cleanC2PA, denoise } = resolveImageCleaners(undefined, settings, mode);
- // modelId omitted → the worker falls through to its default ('dev') model,
- // matching the manual portrait path which also passes no modelId. pythonPath
- // may be null (FLUX.2 carries its own venv); the worker surfaces a missing
- // python over SSE rather than us hard-failing the whole auto-cast request.
return {
mode,
ready: true,
- jobParams: { pythonPath: settings.imageGen?.local?.pythonPath || null, cleanC2PA, denoise },
+ jobParams: { pythonPath, cleanC2PA, denoise },
};
}
// external (or an unknown mode) — synchronous SD-API isn't suited for a
@@ -117,22 +122,24 @@ export async function enqueueFirstPassPortraits(members = []) {
return { mode: resolved.mode, enqueued: [], skipped: [], reason: resolved.reason };
}
- const enqueued = [];
- const skipped = [];
- for (const member of list) {
- const { ingredientId } = member;
+ // Resolve each member's render decision concurrently — the per-member reads
+ // (getIngredient + portrait check) are independent, so a 50-member cast costs
+ // one round-trip batch rather than ~2N serial queries. Promise.all preserves
+ // order, so the enqueue pass below still assigns jobIds in cast order.
+ const decisions = await Promise.all(list.map(async ({ ingredientId }) => {
const ingredient = await getIngredient(ingredientId);
- if (!ingredient) {
- skipped.push({ ingredientId, reason: 'gone' });
- continue;
- }
- if (await ingredientHasPortrait(ingredientId)) {
- skipped.push({ ingredientId, reason: 'has-portrait' });
- continue;
- }
+ if (!ingredient) return { ingredientId, skip: 'gone' };
+ if (await ingredientHasPortrait(ingredientId)) return { ingredientId, skip: 'has-portrait' };
const prompt = buildPortraitPrompt(ingredient);
- if (!prompt) {
- skipped.push({ ingredientId, reason: 'no-prompt' });
+ if (!prompt) return { ingredientId, skip: 'no-prompt' };
+ return { ingredientId, prompt };
+ }));
+
+ const enqueued = [];
+ const skipped = [];
+ for (const { ingredientId, skip, prompt } of decisions) {
+ if (skip) {
+ skipped.push({ ingredientId, reason: skip });
continue;
}
const queued = enqueueJob({
diff --git a/server/services/creativeDirector/firstPassGen.test.js b/server/services/creativeDirector/firstPassGen.test.js
index 1d91721ffb..7ed396cd05 100644
--- a/server/services/creativeDirector/firstPassGen.test.js
+++ b/server/services/creativeDirector/firstPassGen.test.js
@@ -122,6 +122,14 @@ describe('enqueueFirstPassPortraits', () => {
expect(getIngredient).not.toHaveBeenCalled();
});
+ it('skips gracefully when local mode has no pythonPath (default model would fail unseen)', async () => {
+ getSettings.mockResolvedValue({ imageGen: { mode: 'local', local: {} } });
+ const out = await enqueueFirstPassPortraits([{ ingredientId: 'a' }]);
+ expect(out).toEqual({ mode: 'local', enqueued: [], skipped: [], reason: 'local-not-configured' });
+ expect(enqueueJob).not.toHaveBeenCalled();
+ expect(getIngredient).not.toHaveBeenCalled();
+ });
+
it('skips gracefully for external mode (not queue-backed)', async () => {
getSettings.mockResolvedValue({ imageGen: { mode: 'external' } });
const out = await enqueueFirstPassPortraits([{ ingredientId: 'a' }]);