Separate editing from running with a draft/publish split

Edits autosave to flow.draft.json and nodes.draft/ instead of the files the
engine reads, so the pipeline keeps running the published version until
someone publishes. Every save carries the version it was based on: a second
client editing the same flow is refused with 409 and offered the choice
between their version and its own, rather than silently overwriting.

Draft saves no longer rebuild the pipeline; validation and node status for a
draft come from a throwaway build that never touches live state.

Also fixes a latent bug where an empty state backend is falsy, so Pipeline
quietly built itself a second, private state and left message history empty.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Melvin Strobl
2026-08-15 23:13:15 +02:00
co-authored by Claude Fable 5
parent 36be6f1081
commit 606ab3c423
18 changed files with 1159 additions and 132 deletions
+27 -1
View File
@@ -161,12 +161,21 @@ export const FlowDetailSchema = {
type: 'array',
title: 'Issues',
default: []
},
has_draft: {
type: 'boolean',
title: 'Has Draft',
default: false
}
},
type: 'object',
required: ['definition'],
title: 'FlowDetail',
description: 'A flow plus how it is currently doing.'
description: `A flow plus how it is currently doing.
\`\`definition\`\` is the working copy — the unpublished draft when there is
one — because that is what the editor shows. \`\`nodes\`\` reports the
published flow, which is what is actually running.`
} as const;
export const FlowInput_InputSchema = {
@@ -252,6 +261,11 @@ export const FlowSummarySchema = {
type: 'integer',
title: 'Error Count',
default: 0
},
has_draft: {
type: 'boolean',
title: 'Has Draft',
default: false
}
},
type: 'object',
@@ -631,6 +645,18 @@ export const PrivateUserCreateSchema = {
title: 'PrivateUserCreate'
} as const;
export const PublishRequestSchema = {
properties: {
version: {
type: 'integer',
title: 'Version'
}
},
type: 'object',
required: ['version'],
title: 'PublishRequest'
} as const;
export const RenameRequestSchema = {
properties: {
new_name: {
+61 -4
View File
@@ -3,7 +3,7 @@
import type { CancelablePromise } from './core/CancelablePromise';
import { OpenAPI } from './core/OpenAPI';
import { request as __request } from './core/request';
import type { FlowsReadFlowsResponse, FlowsReadNodeTypesResponse, FlowsReadFlowData, FlowsReadFlowResponse, FlowsSaveFlowData, FlowsSaveFlowResponse, FlowsDeleteFlowData, FlowsDeleteFlowResponse, FlowsRenameFlowData, FlowsRenameFlowResponse, FlowsReadNodeSourceData, FlowsReadNodeSourceResponse, FlowsSaveNodeSourceData, FlowsSaveNodeSourceResponse, FlowsValidateFlowData, FlowsValidateFlowResponse, FlowsRunFlowData, FlowsRunFlowResponse, FlowsTriggerNodeData, FlowsTriggerNodeResponse, FlowsReadFlowStateData, FlowsReadFlowStateResponse, FlowsReadMessageHistoryData, FlowsReadMessageHistoryResponse, LoginLoginAccessTokenData, LoginLoginAccessTokenResponse, LoginTestTokenResponse, LoginRecoverPasswordData, LoginRecoverPasswordResponse, LoginResetPasswordData, LoginResetPasswordResponse, LoginRecoverPasswordHtmlContentData, LoginRecoverPasswordHtmlContentResponse, PrivateCreateUserData, PrivateCreateUserResponse, SecretsReadSecretsResponse, SecretsSaveSecretData, SecretsSaveSecretResponse, SecretsDeleteSecretData, SecretsDeleteSecretResponse, UsersReadUsersData, UsersReadUsersResponse, UsersCreateUserData, UsersCreateUserResponse, UsersReadUserMeResponse, UsersDeleteUserMeResponse, UsersUpdateUserMeData, UsersUpdateUserMeResponse, UsersUpdatePasswordMeData, UsersUpdatePasswordMeResponse, UsersRegisterUserData, UsersRegisterUserResponse, UsersReadUserByIdData, UsersReadUserByIdResponse, UsersUpdateUserData, UsersUpdateUserResponse, UsersDeleteUserData, UsersDeleteUserResponse, UtilsTestEmailData, UtilsTestEmailResponse, UtilsHealthCheckResponse } from './types.gen';
import type { FlowsReadFlowsResponse, FlowsReadNodeTypesResponse, FlowsReadFlowData, FlowsReadFlowResponse, FlowsSaveFlowData, FlowsSaveFlowResponse, FlowsDeleteFlowData, FlowsDeleteFlowResponse, FlowsPublishFlowData, FlowsPublishFlowResponse, FlowsDiscardDraftData, FlowsDiscardDraftResponse, FlowsRenameFlowData, FlowsRenameFlowResponse, FlowsReadNodeSourceData, FlowsReadNodeSourceResponse, FlowsSaveNodeSourceData, FlowsSaveNodeSourceResponse, FlowsValidateFlowData, FlowsValidateFlowResponse, FlowsRunFlowData, FlowsRunFlowResponse, FlowsTriggerNodeData, FlowsTriggerNodeResponse, FlowsReadFlowStateData, FlowsReadFlowStateResponse, FlowsReadMessageHistoryData, FlowsReadMessageHistoryResponse, LoginLoginAccessTokenData, LoginLoginAccessTokenResponse, LoginTestTokenResponse, LoginRecoverPasswordData, LoginRecoverPasswordResponse, LoginResetPasswordData, LoginResetPasswordResponse, LoginRecoverPasswordHtmlContentData, LoginRecoverPasswordHtmlContentResponse, PrivateCreateUserData, PrivateCreateUserResponse, SecretsReadSecretsResponse, SecretsSaveSecretData, SecretsSaveSecretResponse, SecretsDeleteSecretData, SecretsDeleteSecretResponse, UsersReadUsersData, UsersReadUsersResponse, UsersCreateUserData, UsersCreateUserResponse, UsersReadUserMeResponse, UsersDeleteUserMeResponse, UsersUpdateUserMeData, UsersUpdateUserMeResponse, UsersUpdatePasswordMeData, UsersUpdatePasswordMeResponse, UsersRegisterUserData, UsersRegisterUserResponse, UsersReadUserByIdData, UsersReadUserByIdResponse, UsersUpdateUserData, UsersUpdateUserResponse, UsersDeleteUserData, UsersDeleteUserResponse, UtilsTestEmailData, UtilsTestEmailResponse, UtilsHealthCheckResponse } from './types.gen';
export class FlowsService {
/**
@@ -55,7 +55,12 @@ export class FlowsService {
/**
* Save Flow
* Create or replace a flow. Saving the same content again changes nothing.
* Save unpublished changes to a flow.
*
* This writes a draft: the running pipeline keeps the published version until
* someone publishes. ``version`` is the one the editor last saw — a mismatch
* means another client saved in between and answers 409 rather than throwing
* their work away.
* @param data The data for the request.
* @param data.name
* @param data.requestBody
@@ -98,6 +103,51 @@ export class FlowsService {
});
}
/**
* Publish Flow
* Deploy the unpublished changes: the engine picks them up from here.
* @param data The data for the request.
* @param data.name
* @param data.requestBody
* @returns FlowDetail Successful Response
* @throws ApiError
*/
public static publishFlow(data: FlowsPublishFlowData): CancelablePromise<FlowsPublishFlowResponse> {
return __request(OpenAPI, {
method: 'POST',
url: '/api/v1/flows/{name}/publish',
path: {
name: data.name
},
body: data.requestBody,
mediaType: 'application/json',
errors: {
422: 'Validation Error'
}
});
}
/**
* Discard Draft
* Throw the unpublished changes away and go back to what is running.
* @param data The data for the request.
* @param data.name
* @returns FlowDetail Successful Response
* @throws ApiError
*/
public static discardDraft(data: FlowsDiscardDraftData): CancelablePromise<FlowsDiscardDraftResponse> {
return __request(OpenAPI, {
method: 'POST',
url: '/api/v1/flows/{name}/discard-draft',
path: {
name: data.name
},
errors: {
422: 'Validation Error'
}
});
}
/**
* Rename Flow
* Rename a flow, along with every reference to its messages.
@@ -124,7 +174,7 @@ export class FlowsService {
/**
* Read Node Source
* Read a node's Python source.
* Read a node's Python source, including unpublished edits.
* @param data The data for the request.
* @param data.name
* @param data.nodeId
@@ -147,7 +197,11 @@ export class FlowsService {
/**
* Save Node Source
* Save a node's source and report whether it loads.
* Save a node's source as an unpublished edit and report whether it loads.
*
* The answer comes from compiling the code rather than from the running
* pipeline: a draft is not deployed, and compiling is both faster and more
* precise about what the author just typed.
* @param data The data for the request.
* @param data.name
* @param data.nodeId
@@ -195,6 +249,9 @@ export class FlowsService {
/**
* Run Flow
* Run every node of a flow once.
*
* With unpublished changes this runs the draft, so the button matches what is
* on the canvas. Nothing is deployed by running it.
* @param data The data for the request.
* @param data.name
* @param data.requestBody
+23
View File
@@ -41,11 +41,16 @@ export type FlowDef_Output = {
/**
* A flow plus how it is currently doing.
*
* ``definition`` is the working copy — the unpublished draft when there is
* one — because that is what the editor shows. ``nodes`` reports the
* published flow, which is what is actually running.
*/
export type FlowDetail = {
definition: FlowDef_Output;
nodes?: Array<NodeStatusPublic>;
issues?: Array<ValidationIssue>;
has_draft?: boolean;
};
/**
@@ -81,6 +86,7 @@ export type FlowSummary = {
title?: string;
node_count?: number;
error_count?: number;
has_draft?: boolean;
};
/**
@@ -213,6 +219,10 @@ export type PrivateUserCreate = {
is_verified?: boolean;
};
export type PublishRequest = {
version: number;
};
export type RenameRequest = {
new_name: string;
};
@@ -337,6 +347,19 @@ export type FlowsDeleteFlowData = {
export type FlowsDeleteFlowResponse = (Message);
export type FlowsPublishFlowData = {
name: string;
requestBody: PublishRequest;
};
export type FlowsPublishFlowResponse = (FlowDetail);
export type FlowsDiscardDraftData = {
name: string;
};
export type FlowsDiscardDraftResponse = (FlowDetail);
export type FlowsRenameFlowData = {
name: string;
requestBody: RenameRequest;