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

keep autopilot board notes text-only without an image tool or under a spend cap, and close the render claim race

[._.]/ Adam Eivyc342a05404d9
diff --git a/server/services/moodBoard/renderItem.js b/server/services/moodBoard/renderItem.js
index 9ea5ccced7..3b3bc00450 100644
--- a/server/services/moodBoard/renderItem.js
+++ b/server/services/moodBoard/renderItem.js
@@ -82,7 +82,11 @@ export async function renderBoardItem(boardId, itemId, route = {}) {
if (!board) throw new ServerError('Mood board not found', { status: 404, code: 'NOT_FOUND' });
const priorJobId = board.items?.find((it) => it?.id === itemId)?.render?.jobId;
const priorLive = priorJobId ? isLiveStatus(await deps.getJob(priorJobId)) : false;
- const claimed = await store.claimBoardItemRender(boardId, itemId, { isLive: () => priorLive });
+ // A job id this request never saw (a concurrent render settled it after the
+ // read above) counts as live, so the lock can't let a duplicate through.
+ const claimed = await store.claimBoardItemRender(boardId, itemId, {
+ isLive: (jobId) => jobId !== priorJobId || priorLive,
+ });
const prompt = buildItemRenderPrompt(board, claimed);
const negativePrompt = isNonBlankStr(board.style?.negativePrompt) ? board.style.negativePrompt.trim() : undefined;
diff --git a/server/services/moodBoard/renderItem.test.js b/server/services/moodBoard/renderItem.test.js
index 97a8ef3d8a..e1c7e871f1 100644
--- a/server/services/moodBoard/renderItem.test.js
+++ b/server/services/moodBoard/renderItem.test.js
@@ -69,6 +69,8 @@ describe('renderBoardItem', () => {
enqueue.mockResolvedValueOnce({ jobId: 'job-2' });
await renderBoardItem('mb-1', 'n1');
expect(store.claimBoardItemRender.mock.calls[0][2].isLive('old')).toBe(false);
+ // A job id settled by a concurrent request after the read counts as busy.
+ expect(store.claimBoardItemRender.mock.calls[0][2].isLive('concurrent')).toBe(true);
});
});
diff --git a/server/services/musicVideo/autonomousService.js b/server/services/musicVideo/autonomousService.js
index f7ae7ae8a5..c7a55a930d 100644
--- a/server/services/musicVideo/autonomousService.js
+++ b/server/services/musicVideo/autonomousService.js
@@ -60,6 +60,7 @@ import { probeVideoDuration } from '../../lib/ffmpeg.js';
import { ServerError } from '../../lib/errorHandler.js';
import { trimTo } from '../../lib/textUtils.js';
import { RENDER_TARGET } from '../../lib/renderTargets.js';
+import { IMAGE_GEN_MODE } from '../../lib/generationModes.js';
import { assertFootageVideoModelsCapable, loadPoolEnv } from './productionPool.js';
import { PRODUCTION_RESUMABLE_STATUSES } from './production.js';
import {
@@ -838,15 +839,18 @@ async function writeRunLyrics({ project, run, save }) {
} };
}
-// The board's notes render on the run's first image tool with its pinned model,
-// or on the install's Music Video default when the run names no image tool.
+// The board's notes render on the run's first image tool with its pinned model.
+// Null keeps the board text-only: the brief names no image tool (its tool list
+// is what autopilot may use), or the run has a dollar cap and the tool is not
+// the free local backend — these pre-production renders are not counted
+// against production's spend cap, so a capped run never spends on them.
// Only reached in a mode that allows images (code-only builds no board).
function boardRenderRoute(run) {
const tool = (run.brief.tools || []).find((id) => id.startsWith('image:'));
- return {
- target: RENDER_TARGET.MUSIC_VIDEO,
- ...(tool ? { mode: tool.slice('image:'.length), model: run.brief.models?.[tool] || undefined } : {}),
- };
+ if (!tool) return null;
+ const mode = tool.slice('image:'.length);
+ if (run.brief.budgetUsd != null && mode !== IMAGE_GEN_MODE.LOCAL) return null;
+ return { target: RENDER_TARGET.MUSIC_VIDEO, mode, model: run.brief.models?.[tool] || undefined };
}
async function createRunStyle({ project, run }) {
diff --git a/server/services/musicVideo/autonomousService.test.js b/server/services/musicVideo/autonomousService.test.js
index 85cb184150..700b12db01 100644
--- a/server/services/musicVideo/autonomousService.test.js
+++ b/server/services/musicVideo/autonomousService.test.js
@@ -378,6 +378,17 @@ describe('startAutonomousVideo', () => {
});
});
+ it('keeps the board text-only when the run names no image tool, or caps spend on a paid one', async () => {
+ await service.startAutonomousVideo({ prompt: 'p', tools: ['video:local'] });
+ await vi.waitFor(() => expect(doubles.createMoodBoard).toHaveBeenCalledOnce());
+ expect(doubles.createMoodBoard.mock.calls[0][1]).toEqual({ renderRoute: null });
+ store.clear();
+ doubles.createMoodBoard.mockClear();
+ await service.startAutonomousVideo({ prompt: 'p', tools: ['image:fal'], budgetUsd: 5 });
+ await vi.waitFor(() => expect(doubles.createMoodBoard).toHaveBeenCalledOnce());
+ expect(doubles.createMoodBoard.mock.calls[0][1]).toEqual({ renderRoute: null });
+ });
+
it('parks needs-human when production parks, and failed when it fails', async () => {
await service.startAutonomousVideo({ prompt: 'p' });
await vi.waitFor(() => expect(runOf()?.output.productionRunId).toBe('mvpr-1'));