Skip to content

Commit 138db3e

Browse files
Docs: describe ID reuse policies and start request IDs as the server implements them (#1584)
Proto comments for IdReusePolicy, FlowAlreadyStartedOptions, and StartFlowRequest.request_id (with the retry rule from #1559), regenerated code; the abnormal-close policy now documents Failed, Canceled, and Terminated across the five SDKs, the Developer reference, and skills; the default reuse value is documented as Disallow with no server setting. No behavior change. Skills 1.0.13.
1 parent 046b464 commit 138db3e

27 files changed

Lines changed: 263 additions & 33 deletions

File tree

‎docs/reference/go/start-flow-options.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ rejects the start:
149149
| **IDReusePolicy** | Existing active Flow | Existing closed Flow |
150150
|-------------------|----------------------|----------------------|
151151
| **IDReuseDefault** | Rejects the start. | Rejects the start. |
152-
| **IDReuseAllowIfPreviousFailed** | Rejects the start. | Starts a new run only after a failed run; otherwise rejects it. |
152+
| **IDReuseAllowIfPreviousFailed** | Rejects the start. | Starts a new run when the latest run failed, was canceled, or was terminated. A Flow timeout closes a run as failed or canceled under the fail or cancel timeout policy; under the handler policy, the handler's outcome decides. Rejects the start after a completed run. |
153153
| **IDReuseAllowIfNotRunning** | Rejects the start. | Starts a new run. |
154154
| **IDReuseDisallow** | Rejects the start. | Rejects the start. |
155155
| **IDReuseTerminateIfRunning** | Terminates the active run and starts a replacement. It does not produce an already-started error. | Starts a new run. |

‎docs/reference/java/start-flow-options.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ rejects the start:
142142
| **IDReusePolicy** | Existing active Flow | Existing closed Flow |
143143
|-------------------|----------------------|----------------------|
144144
| **IDReuseDefault** | Rejects the start. | Rejects the start. |
145-
| **IDReuseAllowIfPreviousFailed** | Rejects the start. | Starts a new run only after a failed run; otherwise rejects it. |
145+
| **IDReuseAllowIfPreviousFailed** | Rejects the start. | Starts a new run when the latest run failed, was canceled, or was terminated. A Flow timeout closes a run as failed or canceled under the fail or cancel timeout policy; under the handler policy, the handler's outcome decides. Rejects the start after a completed run. |
146146
| **IDReuseAllowIfNotRunning** | Rejects the start. | Starts a new run. |
147147
| **IDReuseDisallow** | Rejects the start. | Rejects the start. |
148148
| **IDReuseTerminateIfRunning** | Terminates the active run and starts a replacement. It does not produce an already-started error. | Starts a new run. |

‎docs/reference/python/start-flow-options.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ rejects the start:
135135
| **IDReusePolicy** | Existing active Flow | Existing closed Flow |
136136
|-------------------|----------------------|----------------------|
137137
| **IDReuseDefault** | Rejects the start. | Rejects the start. |
138-
| **IDReuseAllowIfPreviousFailed** | Rejects the start. | Starts a new run only after a failed run; otherwise rejects it. |
138+
| **IDReuseAllowIfPreviousFailed** | Rejects the start. | Starts a new run when the latest run failed, was canceled, or was terminated. A Flow timeout closes a run as failed or canceled under the fail or cancel timeout policy; under the handler policy, the handler's outcome decides. Rejects the start after a completed run. |
139139
| **IDReuseAllowIfNotRunning** | Rejects the start. | Starts a new run. |
140140
| **IDReuseDisallow** | Rejects the start. | Rejects the start. |
141141
| **IDReuseTerminateIfRunning** | Terminates the active run and starts a replacement. It does not produce an already-started error. | Starts a new run. |

‎docs/reference/rust/start-flow-options.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ rejects the start:
145145
| **IDReusePolicy** | Existing active Flow | Existing closed Flow |
146146
|-------------------|----------------------|----------------------|
147147
| **IDReuseDefault** | Rejects the start. | Rejects the start. |
148-
| **IDReuseAllowIfPreviousFailed** | Rejects the start. | Starts a new run only after a failed run; otherwise rejects it. |
148+
| **IDReuseAllowIfPreviousFailed** | Rejects the start. | Starts a new run when the latest run failed, was canceled, or was terminated. A Flow timeout closes a run as failed or canceled under the fail or cancel timeout policy; under the handler policy, the handler's outcome decides. Rejects the start after a completed run. |
149149
| **IDReuseAllowIfNotRunning** | Rejects the start. | Starts a new run. |
150150
| **IDReuseDisallow** | Rejects the start. | Rejects the start. |
151151
| **IDReuseTerminateIfRunning** | Terminates the active run and starts a replacement. It does not produce an already-started error. | Starts a new run. |

‎docs/reference/typescript/start-flow-options.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ rejects the start:
140140
| **IDReusePolicy** | Existing active Flow | Existing closed Flow |
141141
|-------------------|----------------------|----------------------|
142142
| **IDReuseDefault** | Rejects the start. | Rejects the start. |
143-
| **IDReuseAllowIfPreviousFailed** | Rejects the start. | Starts a new run only after a failed run; otherwise rejects it. |
143+
| **IDReuseAllowIfPreviousFailed** | Rejects the start. | Starts a new run when the latest run failed, was canceled, or was terminated. A Flow timeout closes a run as failed or canceled under the fail or cancel timeout policy; under the handler policy, the handler's outcome decides. Rejects the start after a completed run. |
144144
| **IDReuseAllowIfNotRunning** | Rejects the start. | Starts a new run. |
145145
| **IDReuseDisallow** | Rejects the start. | Rejects the start. |
146146
| **IDReuseTerminateIfRunning** | Terminates the active run and starts a replacement. It does not produce an already-started error. | Starts a new run. |

‎protos/dex.proto‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,15 +487,28 @@ message FlowTimeoutHandlerOptions {
487487
repeated string load_channel_map_instances = 11;
488488
}
489489

490+
// Decides whether StartFlow may start a new run for a Flow ID that already has a run.
491+
// Dex checks the latest run only. A Flow ID without runs always starts.
492+
// A retry of the latest run's start request skips this policy; see StartFlowRequest.request_id.
490493
enum IdReusePolicy {
494+
// Same as ID_REUSE_POLICY_DISALLOW_REUSE.
491495
ID_REUSE_POLICY_UNSPECIFIED = 0;
496+
// Starts a new run when the latest run closed as FAILED, CANCELED, or TERMINATED.
497+
// Rejects the start when the latest run is RUNNING or COMPLETED.
498+
// A Flow timeout closes a run as FAILED or CANCELED under FAIL or CANCEL; under HANDLER, the handler decides.
492499
ID_REUSE_POLICY_ALLOW_IF_PREVIOUS_EXISTS_ABNORMALLY = 1;
500+
// Starts a new run when the latest run is closed, whatever its status.
493501
ID_REUSE_POLICY_ALLOW_IF_NO_RUNNING = 2;
502+
// Rejects the start whenever the Flow ID has a run.
494503
ID_REUSE_POLICY_DISALLOW_REUSE = 3;
504+
// Terminates a running latest run, then starts a new run. Never rejects a new request.
495505
ID_REUSE_POLICY_ALLOW_TERMINATE_IF_RUNNING = 4;
496506
}
497507

508+
// Chooses the StartFlow result when Dex does not start a new run.
498509
message FlowAlreadyStartedOptions {
510+
// True returns the latest run's ID when the request ID matches that run's start request ID.
511+
// Otherwise, and whenever this is false, StartFlow fails with ALREADY_EXISTS (FLOW_ALREADY_STARTED).
499512
bool ignore_already_started_error = 1;
500513
}
501514

@@ -626,6 +639,9 @@ message StartFlowRequest {
626639
Value step_input = 8;
627640
StepOptions step_options = 9;
628641
FlowStartOptions flow_start_options = 10;
642+
// Required. Identifies one logical start; Dex records it on the run it starts.
643+
// A request with the latest run's request ID is a retry: Dex never applies the ID reuse policy.
644+
// flow_already_started_options then chooses the result. Dex compares only the ID, not input or options.
629645
string request_id = 11;
630646
}
631647

‎sdk-go/dex/options.go‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,14 @@ func defaultSubFlowOptions() SubFlowOptions {
466466
type IDReusePolicy uint8
467467

468468
const (
469-
// IDReuseDefault uses the server default, which rejects every previously used Flow ID.
469+
// IDReuseDefault rejects the start whenever the Flow ID has a run, the same as IDReuseDisallow.
470+
// The server does not make this default configurable.
470471
IDReuseDefault IDReusePolicy = iota
471-
// IDReuseAllowIfPreviousFailed permits reuse only after a failed run.
472+
// IDReuseAllowIfPreviousFailed starts a new run only when the latest run closed abnormally:
473+
// failed, canceled, or terminated.
474+
// A Flow timeout closes a run as failed or canceled under the fail or cancel timeout policy.
475+
// Under the handler policy, the timeout handler's outcome decides.
476+
// A running or completed latest run rejects the start.
472477
IDReuseAllowIfPreviousFailed
473478
// IDReuseAllowIfNotRunning permits reuse when no run is active.
474479
IDReuseAllowIfNotRunning

‎sdk-go/gen/dexpb/dex.pb.go‎

Lines changed: 25 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎sdk-java/src/main/java/io/superdurable/dex/IdReusePolicy.java‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,18 @@
1717
* the server against prior and currently running executions with the same Flow ID.
1818
*/
1919
public enum IdReusePolicy {
20-
/** Uses the Dex server default, which rejects every previously used Flow ID. */
20+
/**
21+
* Rejects the start whenever the Flow ID has a run, the same as {@link #DISALLOW}. The server
22+
* does not make this default configurable.
23+
*/
2124
DEFAULT,
2225

23-
/** Allows reuse only when the previous execution ended abnormally. */
26+
/**
27+
* Starts a new run only when the latest run closed abnormally: failed, canceled, or terminated.
28+
* A Flow timeout closes a run as failed or canceled under the fail or cancel timeout policy.
29+
* Under the handler policy, the timeout handler's outcome decides. A running or completed latest
30+
* run rejects the start.
31+
*/
2432
ALLOW_IF_PREVIOUS_FAILED,
2533

2634
/** Allows reuse when no execution with the ID is currently running. */

‎sdk-java/src/main/java/io/superdurable/gen/FlowAlreadyStartedOptions.java‎

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)