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

reserve one production author step for a document authored in local batches

[._.]/ Adam Eivyc7a4ecdf97f2
diff --git a/server/services/musicVideo/productionService.js b/server/services/musicVideo/productionService.js
index 04e05a67d7..693fc25bb3 100644
--- a/server/services/musicVideo/productionService.js
+++ b/server/services/musicVideo/productionService.js
@@ -370,6 +370,12 @@ async function authorDocument(projectId, runId, action) {
beforeSubmit: async ({ provider, model }) => {
if (provider.id !== run.authoring.providerId || model !== run.authoring.model) throw new ServerError('The authoring provider/model changed; no fallback is allowed', { status: 409, code: 'PRODUCTION_AUTHORING_UNAVAILABLE' });
if (!isAuthoringOneShotProvider(provider)) throw new ServerError('This code authoring provider cannot run without tools', { status: 422, code: 'PRODUCTION_AUTHORING_UNAVAILABLE' });
+ // Local authoring submits once per section batch (#10515); one reserved step covers the
+ // whole document, so a later batch only rechecks that the step is still open.
+ if (key) {
+ verifyCurrent(await requireProject(projectId));
+ return;
+ }
const costUsd = isFreeProvider(provider) ? 0 : null;
const reserved = await mutateProjectRecord(projectId, (current) => {
verifyCurrent(current);
diff --git a/server/services/musicVideo/productionService.test.js b/server/services/musicVideo/productionService.test.js
index 18b600ea6a..712c888750 100644
--- a/server/services/musicVideo/productionService.test.js
+++ b/server/services/musicVideo/productionService.test.js
@@ -709,6 +709,20 @@ function failOwnedReview(atSec = 6) {
}
describe('code-first production execution (#9301)', () => {
+ it('reserves one author step for a document authored in several local batches', async () => {
+ seedCodeFirst(); const { author } = documentDoubles();
+ const single = author.getMockImplementation();
+ // Batched local authoring calls beforeSubmit once per batch before returning the document.
+ author.mockImplementation(async (id, input) => {
+ await input.beforeSubmit({ provider: authorProvider, model: AUTHORING.model });
+ return single(id, input);
+ });
+ await start({ pool: [], authoring: AUTHORING });
+ expect(author).toHaveBeenCalledOnce();
+ expect(theRun()).toMatchObject({ status: 'running', usage: { generations: 1 }, documentCheckpoint: { directory: current().composition.document.directory } });
+ expect(theRun().steps.filter((step) => step.kind === 'author')).toEqual([expect.objectContaining({ status: 'completed' })]);
+ });
+
it('authors a code-only plan with no media routes/jobs and completes only after its reviewed final render', async () => {
seedCodeFirst(); const { author, render } = documentDoubles();
await start({ pool: [], authoring: AUTHORING });