-
Notifications
You must be signed in to change notification settings - Fork 782
Adding .NET SDK documentation for history propagation #5174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
WhitWaldo
wants to merge
6
commits into
dapr:v1.18
Choose a base branch
from
WhitWaldo:history-propagation
base: v1.18
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+217
−0
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f50eddc
Adding .NET SDK documentation for history propagation
WhitWaldo 496e2c5
Merge branch 'v1.18' into history-propagation
WhitWaldo ce3c0ca
Merge branch 'v1.18' into history-propagation
WhitWaldo bcb1754
Merge branch 'v1.18' into history-propagation
msfussell 1613b8c
Merge branch 'v1.18' into history-propagation
WhitWaldo f997c59
Updated .NET SDK documentation to reflect latest changes
WhitWaldo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
160 changes: 160 additions & 0 deletions
160
...ntent/en/dotnet-sdk-docs/dotnet-workflow/dotnet-workflow-history-propagation.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| --- | ||
| type: docs | ||
| title: "Workflow history propagation in the .NET SDK" | ||
| linkTitle: "History propagation" | ||
| weight: 1700 | ||
| description: Share ancestor workflow execution history with child workflows and activities using the .NET SDK | ||
| --- | ||
|
|
||
| ## Overview | ||
|
|
||
| Workflow history propagation allows a parent workflow to share its execution history — and optionally its full ancestor chain — with the child workflows and activities it calls. The child can then inspect those upstream events at runtime. | ||
|
|
||
| Common use cases include: | ||
|
|
||
| - Audit trails: Verifying a chain of custody across a multi-step workflow | ||
| - Fraud detection: Inspecting upstream decisions before committing a transaction | ||
| - AI agent orchestration: Passing context through hierarchical agent workflows | ||
|
|
||
| Conceptual guidance is covered in [Workflow history propagation]({{% ref "workflow-history-propagation.md" %}}). | ||
|
|
||
| {{% alert title="Note" color="primary" %}} | ||
| This feature requires Dapr .NET SDK v1.18.0 or later and Dapr runtime v1.18.0 or later. | ||
| {{% /alert %}} | ||
|
|
||
| ## Propagation scopes | ||
|
|
||
| Propagation is **opt-in and per-call**. Each call to `CallActivityAsync` or `CallChildWorkflowAsync` can independently specify a `HistoryPropagationScope`: | ||
|
|
||
| | Scope | Description | | ||
| |---|---| | ||
| | `None` | Default. No history is propagated to the callee. | | ||
| | `OwnHistory` | Propagates the calling workflow's own events only. Ancestor history is dropped, acting as a trust boundary. | | ||
| | `Lineage` | Propagates the calling workflow's events plus the full ancestor chain it inherited from its own parent. | | ||
|
|
||
| ## Propagate history to a child workflow | ||
|
|
||
| Use `WithHistoryPropagation` on `ChildWorkflowTaskOptions` to opt a child workflow into receiving the parent's history: | ||
|
|
||
| ```csharp | ||
| public sealed class MerchantCheckoutWorkflow : Workflow<Order, CheckoutResult> | ||
| { | ||
| public override async Task<CheckoutResult> RunAsync(WorkflowContext context, Order order) | ||
| { | ||
| // Activity without propagation — default behavior, no opt-in | ||
| await context.CallActivityAsync(nameof(ValidateMerchantActivity), order.MerchantId); | ||
|
|
||
| // Child workflow with full lineage propagation | ||
| var options = new ChildWorkflowTaskOptions() | ||
| .WithHistoryPropagation(HistoryPropagationScope.Lineage); | ||
|
|
||
| var result = await context.CallChildWorkflowAsync<PaymentResult>( | ||
| nameof(ProcessPaymentWorkflow), order, options); | ||
|
|
||
| return new CheckoutResult(result); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Calls that do not specify a propagation scope receive no history — other calls in the same workflow are unaffected by opt-ins. | ||
|
|
||
| ## Propagate history to an activity | ||
|
|
||
| The same `WithHistoryPropagation` extension is available on `WorkflowTaskOptions` for activity calls: | ||
|
|
||
| ```csharp | ||
| var options = new WorkflowTaskOptions() | ||
| .WithHistoryPropagation(HistoryPropagationScope.OwnHistory); | ||
|
|
||
| var auditResult = await context.CallActivityAsync<AuditResult>( | ||
| nameof(WriteAuditTrailActivity), payload, options); | ||
| ``` | ||
|
|
||
| ## Read propagated history | ||
|
|
||
| Inside a child workflow, call `GetPropagatedHistory()` on `WorkflowContext` to retrieve the history passed by the parent. The method returns `null` if propagation was not requested for this invocation. | ||
|
|
||
| ```csharp | ||
| public sealed class ProcessPaymentWorkflow : Workflow<Order, PaymentResult> | ||
| { | ||
| public override async Task<PaymentResult> RunAsync(WorkflowContext context, Order order) | ||
| { | ||
| var history = context.GetPropagatedHistory(); | ||
|
|
||
| if (history != null) | ||
| { | ||
| foreach (var entry in history.Entries) | ||
| { | ||
| // entry.WorkflowName, entry.InstanceId, entry.AppId, entry.Events | ||
| } | ||
| } | ||
|
|
||
| return await context.CallActivityAsync<PaymentResult>( | ||
| nameof(ChargeCardActivity), order); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### PropagatedHistory type | ||
|
|
||
| `GetPropagatedHistory()` returns a `PropagatedHistory` object (or `null`). Its `Entries` property is a collection of `PropagatedHistoryEntry` records, each representing one workflow in the ancestor chain: | ||
|
|
||
| | Member | Type | Description | | ||
| |---|---|---| | ||
| | `AppId` | `string` | Dapr app ID that hosted the workflow | | ||
| | `InstanceId` | `string` | Workflow instance ID | | ||
| | `WorkflowName` | `string` | Registered name of the workflow | | ||
| | `Events` | `IReadOnlyList<PropagatedHistoryEvent>` | History events for this workflow | | ||
|
|
||
| Each `PropagatedHistoryEvent` has: | ||
|
|
||
| | Member | Type | Description | | ||
| |---|---|---| | ||
| | `EventId` | `int` | Sequence number within the workflow history | | ||
| | `Kind` | `HistoryEventKind` | The type of event (see below) | | ||
| | `Timestamp` | `DateTimeOffset` | When the event occurred | | ||
|
|
||
| `HistoryEventKind` values include `ExecutionStarted`, `ExecutionCompleted`, `TaskScheduled`, `TaskCompleted`, `TaskFailed`, `SubOrchestrationInstanceCreated`, `SubOrchestrationInstanceCompleted`, `SubOrchestrationInstanceFailed`, `TimerCreated`, `TimerFired`, `OrchestratorStarted`, `OrchestratorCompleted`, `EventSent`, `EventRaised`, `ContinueAsNew`, `ExecutionSuspended`, and `ExecutionResumed`. | ||
|
|
||
| ## Filter propagated history | ||
|
|
||
| `PropagatedHistory` provides filter methods to narrow the entries to a specific workflow in the chain: | ||
|
|
||
| ```csharp | ||
| var history = context.GetPropagatedHistory(); | ||
|
|
||
| if (history != null) | ||
| { | ||
| // By app ID — useful in multi-app workflows | ||
| var fromOrderApp = history.FilterByAppId("order-app"); | ||
|
|
||
| // By workflow instance ID | ||
| var fromSpecificRun = history.FilterByInstanceId("checkout-abc123"); | ||
|
|
||
| // By workflow name | ||
| var checkoutEntries = history.FilterByWorkflowName(nameof(MerchantCheckoutWorkflow)); | ||
|
|
||
| foreach (var entry in checkoutEntries) | ||
| { | ||
| var failedTasks = entry.Events | ||
| .Where(e => e.Kind == HistoryEventKind.TaskFailed) | ||
| .ToList(); | ||
|
|
||
| // Use failedTasks for audit or routing decisions | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Security considerations | ||
|
|
||
| By default, Dapr uses mutual TLS (mTLS) between sidecars for all cross-app communication, providing transport-layer protection for propagated history in [multi-app workflow]({{% ref "dotnet-workflow-multi-app.md" %}}) scenarios. | ||
|
|
||
| For stronger guarantees in production, enable `WorkflowHistorySigning`. This feature uses SPIFFE identity to cryptographically sign each history chunk, so the receiving workflow can verify the integrity and origin of the propagated history. Without signing enabled, Dapr emits a warning that propagated chunks lack cryptographic verification. | ||
|
|
||
| See [Workflow history propagation]({{% ref "workflow-history-propagation.md" %}}) for details on configuring `WorkflowHistorySigning`. | ||
|
|
||
| ## Next steps | ||
|
|
||
| - [Workflow history propagation]({{% ref "workflow-history-propagation.md" %}}) | ||
| - [Multi-app workflows]({{% ref "dotnet-workflow-multi-app.md" %}}) | ||
| - [Workflow management operations]({{% ref "dotnet-workflow-management-methods.md" %}}) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.