Skip to content

[DRAFT] feat(dotnet): workflow context propagation quickstart#1310

Draft
nelson-parente wants to merge 1 commit into
dapr:masterfrom
nelson-parente:feat/wf-ctx-propagation-dotnet
Draft

[DRAFT] feat(dotnet): workflow context propagation quickstart#1310
nelson-parente wants to merge 1 commit into
dapr:masterfrom
nelson-parente:feat/wf-ctx-propagation-dotnet

Conversation

@nelson-parente
Copy link
Copy Markdown
Contributor

Summary

Scenario

Credit-card payment with fraud detection across a 3-level workflow hierarchy:

MerchantCheckout (root)
  └─ ValidateMerchant         (activity, no propagation)
  └─ ProcessPayment           (child wf, HistoryPropagationScope.Lineage)
        └─ ValidateCard               (activity, no propagation)
        └─ CheckSpendingLimits        (activity, no propagation)
        └─ FraudDetection             (grandchild wf, HistoryPropagationScope.Lineage)
        |      reads MerchantCheckout + ProcessPayment events
        └─ SettlementWorkflow         (grandchild wf, HistoryPropagationScope.OwnHistory)
               reads ProcessPayment events only
               └─ SettlePayment       (activity)

.NET API confirmed (dapr/dotnet-sdk#1802)

  • HistoryPropagationScope enum: None, OwnHistory, Lineage
  • ChildWorkflowTaskOptions(PropagationScope: HistoryPropagationScope.Lineage) — passed to CallChildWorkflowAsync
  • WorkflowContext.GetPropagatedHistory()PropagatedHistory?
  • PropagatedHistory.FilterByWorkflowName(name) → filtered PropagatedHistory
  • PropagatedHistoryEntry — has WorkflowName, AppId, InstanceId, Events
  • PropagatedHistoryEvent — has EventId, Kind (HistoryEventKind), Timestamp

Key difference from Python sibling

The Python SDK supports propagation= on bare activity calls (call_activity()), so settle_payment is a plain activity receiving PropagationScope.OWN_HISTORY.

The .NET SDK v1.18 scopes HistoryPropagationScope to ChildWorkflowTaskOptions only — activity calls do not carry a propagation scope. To demonstrate identical OwnHistory trust-boundary semantics, SettlePayment is wrapped in a SettlementWorkflow child workflow. This is the correct .NET idiom; it is not a gap in the sample.

Status — DRAFT

Test plan

  • dotnet build clean
  • dapr run -f . against Dapr 1.18 RC sidecar with Redis
  • FraudDetection receives 2 propagated segments (MerchantCheckout + ProcessPayment) under Lineage
  • SettlementWorkflow receives 1 propagated segment (ProcessPayment only) under OwnHistory
  • MerchantCheckout segment correctly absent from SettlementWorkflow's history
  • Older sidecar (pre-1.18): GetPropagatedHistory() returns null, sample exits gracefully
  • CI passes on the .NET quickstart matrix

References

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant