string FlowId { get; }
Source
Gets the flow id.
Registers the AppSurface Flow Durable Task adapter boundary.
The module is passive. It declares the core Flow dependency, registers durable adapter services, and leaves Durable Task worker/client hosting to the application. This package intentionally does not register storage providers, background workers, endpoints, authentication handlers, or Semantic Kernel services.
Evaluates AppSurface Flow nodes as Durable Task orchestration decisions.
TContext
This service is the AppSurface mapping layer between durable orchestration code and the core host-neutral IFlowTransitionEvaluator{TContext}
. Hosts still own Durable Task worker/client setup, instance and activity scheduling, registered work/result codecs, persisted state, timers, replay, and external event delivery.
ValueTask<DurableTaskFlowDecision<TContext>> StartAsync(string flowId, string version, string instanceId, TContext context, CancellationToken cancellationToken = default)
Starts a durable flow by evaluating the definition's start node.
flowId
version
instanceId
context
cancellationToken
A durable decision. Missing definitions, missing nodes, non-durable contexts, invalid next targets, and unsupported outcomes are returned as DurableTaskFlowDecisionKind.Fault
decisions. Typed Activity outcomes return DurableTaskFlowDecisionKind.ScheduleActivity
.
ArgumentException
flowId
, version
, or instanceId
is empty. ArgumentNullException
context
is null.
Caller code should inspect the returned DurableTaskFlowDecision{TContext}.Kind
instead of relying on exceptions for process-level failures. Exceptions are reserved for invalid caller arguments and cancellation.
ValueTask<DurableTaskFlowDecision<TContext>> RunNodeAsync(DurableTaskFlowStep<TContext> step, CancellationToken cancellationToken = default)
Evaluates one node and maps its outcome to a durable orchestration decision.
step
cancellationToken
A durable decision. Missing definitions or nodes, serialization failures, invalid next targets, node faults, and unsupported outcomes are returned as DurableTaskFlowDecisionKind.Fault
decisions.
ArgumentNullException
step
is null.ArgumentException
step
carries both a resume event and an activity result. A node evaluation can resume from only one external input at a time.
When AppSurfaceFlowDurableTaskOptions.ValidateContextSerialization
is enabled, this method validates the input context before executing the node and validates returned contexts before scheduling a node or activity, waiting, timing out, or completing. Disabling that option skips the context round-trip check. Activity work/result codec registration remains a host responsibility. Callers must branch on the returned decision kind.
ValueTask<DurableTaskFlowDecision<TContext>> ResumeAsync(DurableTaskFlowStep<TContext> step, string expectedEventName, CancellationToken cancellationToken = default)
Resumes a waiting node if the delivered event matches the event the orchestration was waiting for.
step
expectedEventName
cancellationToken
A durable decision. Missing resume events return a fault decision. Mismatched events return DurableTaskFlowDecisionKind.IgnoreLateEvent
when AppSurfaceFlowDurableTaskOptions.IgnoreLateResumeEvents
is enabled, otherwise they return a fault decision.
ArgumentException
expectedEventName
is empty.ArgumentNullException
step
is null.
The expectedEventName
comparison uses StringComparison.Ordinal
, so matching is case-sensitive. Deliver only the exact event the orchestration is currently waiting for, or normalize event names before calling this method. Mismatches are represented as late-event or fault decisions, so callers should inspect the returned kind before scheduling more work.
Default implementation of IDurableTaskFlowRunner{TContext}
.
TContext
System.Text.Json implementation of IFlowContextSerializer
.
Default resume authorizer that denies every external resume event.
Hosts must replace this service with an application-specific implementation before exposing resume endpoints or queue consumers. Durable instance ids and event names are not sufficient authorization by themselves.
Input used by the Durable Task adapter to evaluate one flow node.
TContext
string FlowId { get; }
Source
Gets the flow id.
string Version { get; }
Source
Gets the flow version.
string InstanceId { get; }
Source
Gets the durable instance id.
string NodeId { get; }
Source
Gets the current node id.
TContext Context { get; }
Source
Gets the current flow context.
FlowResumeEvent? ResumeEvent { get; }
Source
Gets the optional external event or timeout used to resume the node.
FlowActivityWorkResult? ActivityResult { get; init; }
Source
Gets an optional typed activity result used to resume this node.
Set this property when replaying a prior DurableTaskFlowDecisionKind.ScheduleActivity
decision. Do not also supply ResumeEvent
; the shared evaluator rejects ambiguous resume inputs.
Authorizes external resume events before they are delivered to Durable Task.
ValueTask<FlowResumeAuthorizationResult> AuthorizeAsync(FlowResumeAuthorizationRequest request, CancellationToken cancellationToken = default)
Authorizes a resume request.
request
cancellationToken
An authorization result.
Resume-event authorization request.
string FlowId { get; }
Source
Gets the flow id.
string Version { get; }
Source
Gets the flow version.
string InstanceId { get; }
Source
Gets the durable instance id.
string NodeId { get; }
Source
Gets the waiting node id.
string EventName { get; }
Source
Gets the external event name.
string Caller { get; }
Source
Gets the application-defined caller identifier.
IReadOnlyDictionary<string, string> Metadata { get; }
Source
Gets application-defined authorization metadata.
Authorization result for a resume event.
FlowResumeAuthorizationResult Allow(string code = "flow.resume-allowed", string message = "Resume event allowed.")
Creates an allow result.
FlowResumeAuthorizationResult Deny(string code, string message)
Creates a deny result.
bool Allowed { get; }
Source
Gets a value indicating whether the resume event is allowed.
string Code { get; }
Source
Gets the stable machine-readable result code.
string Message { get; }
Source
Gets the human-readable diagnostic message.
Authorizes external resume requests before a host raises a Durable Task external event.
TContext
ValueTask<FlowResumeAuthorizationResult> AuthorizeResumeAsync(FlowResumeAuthorizationRequest request, CancellationToken cancellationToken = default)
Authorizes a resume event.
request
cancellationToken
The authorization result.
Default implementation of IDurableTaskFlowClient{TContext}
.
TContext
Validates that a flow context can survive a serializer round trip before durable execution starts.
FlowContextSerializationResult Validate<TContext>(TContext context)
Validates a context by serializing and deserializing it.
TContext
context
A success or failure result.
Result produced by FlowContextSerializationValidator
.
Succeeded
Message
Exception
FlowContextSerializationResult Success()
Creates a successful validation result.
FlowContextSerializationResult Failure(string message, Exception exception)
Creates a failed validation result.
Serializes flow contexts for Durable Task persistence validation.
string Serialize<TContext>(TContext context)
Serializes a context to a string payload.
TContext
context
Serialized payload.
TContext Deserialize<TContext>(string payload)
Deserializes a context from a string payload.
TContext
payload
Deserialized context.
Describes retry settings that a Durable Task host can apply when scheduling flow node work.
The adapter only carries retry intent. Durable Task worker/client code remains responsible for translating this value into the provider-specific retry options used by the host.
int MaxAttempts { get; }
Source
Gets the maximum number of attempts, including the first attempt.
TimeSpan FirstRetryInterval { get; }
Source
Gets the delay before the first retry.
double BackoffCoefficient { get; }
Source
Gets the backoff coefficient applied by the durable host.
Configures the Durable Task adapter boundary for AppSurface Flow.
The default configuration is intentionally conservative: resume events are denied until a host registers an IFlowResumeAuthorizer
implementation, and context serialization is validated before durable execution.
bool ValidateContextSerialization { get; set; }
Source
Gets or sets whether the adapter validates flow context serialization before evaluating durable decisions.
bool IgnoreLateResumeEvents { get; set; }
Source
Gets or sets whether a host should ignore late or mismatched resume events instead of faulting the durable flow.
The default value is true
because durable orchestrations can receive delayed external events after a timer has won the race. Ignoring the stale signal is usually safer than failing a completed timeout path.
FlowRetryPolicy? NodeRetryPolicy { get; set; }
Source
Gets or sets the retry policy a Durable Task host should apply when scheduling flow node work.
The default value is null
, which means the adapter does not request retries and the host's normal scheduling behavior applies. Set this when every node in a flow should share one durable retry policy.
Durable Task adapter decision created from one flow node evaluation.
TContext
DurableTaskFlowDecision<TContext> ScheduleNode(string nodeId, TContext context, FlowRetryPolicy? retryPolicy = null)
Creates a schedule-node decision.
nodeId
context
retryPolicy
ArgumentException
nodeId
is null, empty, or white space. ArgumentNullException
context
is null.
Schedule decisions carry the next node id, the context to persist, and optional retry metadata. They do not carry event, timeout, fault, or diagnostic details. Inspect Kind
before reading kind-specific properties.
DurableTaskFlowDecision<TContext> WaitForExternalEvent(string nodeId, string eventName, TContext context, FlowTimeout? timeout)
Creates a wait-for-external-event decision.
nodeId
eventName
context
timeout
ArgumentException
nodeId
or eventName
is null, empty, or white space. ArgumentNullException
context
is null.
Wait decisions pause durable execution until the named event arrives or the optional timeout expires. The timeout may be null for waits without a durable timer. Inspect Kind
before reading wait-specific properties.
DurableTaskFlowDecision<TContext> WaitForExternalEvent(string nodeId, IFlowEventCallsite eventCallsite, TContext context, FlowTimeout? timeout)
Creates a wait-for-external-event decision with an exact typed payload contract.
nodeId
eventCallsite
context
timeout
A typed external-event wait decision.
ArgumentException
nodeId
is empty.ArgumentException
eventCallsite
is empty. ArgumentNullException
eventCallsite
, its payload type, or context
is null. This overload preserves the callsite metadata emitted by the shared Flow transition evaluator. The host remains responsible for authorization, persisted wait ownership, payload decoding, and duplicate delivery handling.
DurableTaskFlowDecision<TContext> Complete(string nodeId, TContext context)
Creates a complete decision.
nodeId
context
ArgumentException
nodeId
is null, empty, or white space. ArgumentNullException
context
is null.
Complete decisions are terminal and do not carry wait, timeout, retry, fault, or diagnostic details. Inspect Kind
before reading kind-specific properties.
DurableTaskFlowDecision<TContext> TimedOut(string nodeId, string eventName, TContext context)
Creates a timeout decision.
nodeId
eventName
context
ArgumentException
nodeId
or eventName
is null, empty, or white space. ArgumentNullException
context
is null.
Timed-out decisions mean timeout handling has already run; they are distinct from wait decisions that carry a future timeout. Inspect Kind
before reading timeout-specific properties.
DurableTaskFlowDecision<TContext> Faulted(string nodeId, FlowFault fault, string? diagnostic = null)
Creates a fault decision.
nodeId
fault
diagnostic
ArgumentException
nodeId
is null, empty, or white space. ArgumentNullException
fault
is null.
Fault decisions do not carry a context. Use fault
for stable machine-readable failure details and diagnostic
only for explanatory text. Inspect Kind
before reading fault-specific properties.
DurableTaskFlowDecision<TContext> IgnoreLateEvent(string nodeId, string eventName, string diagnostic)
Creates an ignored-late-event decision.
nodeId
eventName
diagnostic
ArgumentException
nodeId
, eventName
, or diagnostic
is null, empty, or white space.
Ignored-late-event decisions are non-scheduling decisions used when stale external events should not fault the durable instance. They do not carry context, timeout, retry, or fault details. Inspect Kind
before reading late-event-specific properties.
DurableTaskFlowDecision<TContext> ScheduleActivity(string nodeId, IFlowActivityRequest<TContext> activity)
Creates a decision that asks the Durable Task host to schedule one typed activity.
nodeId
activity
An activity scheduling decision.
ArgumentException
nodeId
or activity metadata is empty, a contract version is invalid, or the work value does not implement its declared type. ArgumentNullException
activity
or one of its required values is null.
The adapter does not execute the activity. The host maps the declared CLR types and contract versions to its registered codecs/executor, persists the decision before dispatch, and supplies a FlowActivityWorkResult
on the next DurableTaskFlowStep{TContext}
evaluation.
DurableTaskFlowDecisionKind Kind { get; }
Source
Gets the decision kind.
TContext? Context { get; }
Source
Gets the context carried by the decision, when present.
string? NodeId { get; }
Source
Gets the node id associated with the decision.
string? EventName { get; }
Source
Gets the external event associated with the decision.
IFlowEventCallsite? EventCallsite { get; }
Source
Gets the exact typed external-event contract for a wait decision, or null
for a no-payload string wait.
The Durable Task host uses this metadata to select an allowlisted payload codec and validate the delivered event against its persisted wait registration before resuming the Flow node. The decision does not authorize or decode the event itself.
FlowTimeout? Timeout { get; }
Source
Gets the optional timeout for a wait decision.
FlowRetryPolicy? RetryPolicy { get; }
Source
Gets the retry policy requested for scheduled node work, when present.
FlowFault? Fault { get; }
Source
Gets fault details for a fault decision.
string? Diagnostic { get; }
Source
Gets a human-readable diagnostic message.
IFlowActivityRequest<TContext>? Activity { get; }
Source
Gets the typed activity request for a DurableTaskFlowDecisionKind.ScheduleActivity
decision.
Identifies the durable orchestration decision produced from a flow node outcome.
The numeric values are part of the Durable Task adapter compatibility contract and may appear in durable persistence, telemetry, or wire payloads. Do not reorder, renumber, remove, or reuse values. Add new decisions only at the end with explicit numeric values and migration/versioning considerations.