Skip to content

feat(workflow): add ordering to schedule_new_workflow - #1391

Open
JoshVanL wants to merge 3 commits into
dapr:mainfrom
JoshVanL:workflow-ordering-key
Open

JoshVanL wants to merge 3 commits into
dapr:mainfrom
JoshVanL:workflow-ordering-key

Conversation

@JoshVanL

@JoshVanL JoshVanL commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

schedule_new_workflow and schedule_new_workflow_with_result, sync and
aio, take ordering=WorkflowOrdering(key, on_predecessor_failure) to queue
the workflow behind the other workflows of its app started with the same
key. OrderingFailurePolicy (CONTINUE, BLOCK, CANCEL) sets what the
workflow does when the workflow before it did not complete successfully.
Both are exported from dapr.ext.workflow. The request carries an ordering
only when one is given.

Regenerates the durabletask stubs from durabletask-protobuf v0.8.0, the
first release with WorkflowOrdering, and records its commit in
PROTO_SOURCE_COMMIT_HASH. The release also carries the workflow schedule
service (workflow_schedule_pb2 and the *WorkflowSchedule RPCs) and the
other proto additions since the last regeneration, which had not been
generated here yet.

schedule_new_workflow and schedule_new_workflow_with_result, sync and
aio, take ordering=WorkflowOrdering(key, on_predecessor_failure) to queue
the workflow behind the other workflows of its app started with the same
key. OrderingFailurePolicy (CONTINUE, BLOCK, CANCEL) sets what the
workflow does when the workflow before it did not complete successfully.
Both are exported from dapr.ext.workflow. The request carries an ordering
only when one is given.

Regenerates the durabletask stubs from durabletask-protobuf 9a0ac7b, the
merge of WorkflowOrdering, and records it in PROTO_SOURCE_COMMIT_HASH.
That commit also carries the workflow schedule service
(workflow_schedule_pb2 and the *WorkflowSchedule RPCs), which had not
been generated here yet.

Signed-off-by: joshvanl <me@joshvanl.dev>
@JoshVanL
JoshVanL requested review from a team as code owners December 2, 2026 16:01
Copilot AI balanced review requested due to automatic review settings December 2, 2026 16:01
@CasperGN CasperGN self-assigned this Dec 2, 2026
@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 21.75573% with 205 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.39%. Comparing base (0e26721) to head (2cc4869).

Files with missing lines Patch % Lines
.../_durabletask/internal/orchestrator_service_pb2.py 2.94% 66 Missing ⚠️
...rkflow/_durabletask/internal/history_events_pb2.py 1.78% 55 Missing ⚠️
...orkflow/_durabletask/internal/orchestration_pb2.py 2.85% 34 Missing ⚠️
...low/_durabletask/internal/workflow_schedule_pb2.py 33.33% 30 Missing ⚠️
...abletask/internal/orchestrator_service_pb2_grpc.py 51.21% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1391      +/-   ##
==========================================
- Coverage   88.72%   88.39%   -0.34%     
==========================================
  Files         166      168       +2     
  Lines       13632    13744     +112     
==========================================
+ Hits        12095    12149      +54     
- Misses       1537     1595      +58     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The ordering tests omit the sync and async schedule_new_workflow_with_result paths, leaving request key, failure policy, and returned instance ID and staged flag behavior unverified.

1 open issue
5 files not reviewed
  • dapr/ext/workflow/_durabletask/internal/backend_service_pb2.py: Generated file
  • dapr/ext/workflow/_durabletask/internal/history_events_pb2.py: Generated file
  • dapr/ext/workflow/_durabletask/internal/orchestration_pb2.py: Generated file
  • dapr/ext/workflow/_durabletask/internal/orchestrator_service_pb2.py: Generated file
  • dapr/ext/workflow/_durabletask/internal/workflow_schedule_pb2.py: Generated file
What changed in this PR

Adds optional keyed workflow ordering to the Dapr Python SDK’s synchronous and asynchronous scheduling APIs.

Changes:

  • Exports WorkflowOrdering and failure policies, forwarding ordering through both scheduling variants.
  • Regenerates durabletask bindings for ordering and workflow schedule services.
  • Adds ordering-forwarding and request-presence tests.
File Description
tests/​ext/​workflow/​test_workflow_client.py Tests synchronous ordering forwarding.
tests/​ext/​workflow/​test_workflow_client_aio.py Tests asynchronous ordering forwarding.
tests/​ext/​workflow/​durabletask/​test_client_routing.py Checks ordering in start requests.
dapr/​ext/​workflow/​workflow_ordering.py Defines ordering options and failure policies.
dapr/​ext/​workflow/​dapr_workflow_client.py Adds ordering to synchronous scheduling APIs.
dapr/​ext/​workflow/​aio/​dapr_workflow_client.py Adds ordering to asynchronous scheduling APIs.
dapr/​ext/​workflow/​_durabletask/​internal/​workflow_schedule_pb2.pyi Adds schedule message type stubs.
dapr/​ext/​workflow/​_durabletask/​internal/​workflow_schedule_pb2.py Adds generated schedule messages.
dapr/​ext/​workflow/​_durabletask/​internal/​workflow_schedule_pb2_grpc.py Adds generated gRPC compatibility checks.
dapr/​ext/​workflow/​_durabletask/​internal/​PROTO_SOURCE_COMMIT_HASH Records the updated protobuf source revision.
dapr/​ext/​workflow/​_durabletask/​internal/​orchestrator_service_pb2.pyi Types ordering and instance-prefix fields.
dapr/​ext/​workflow/​_durabletask/​internal/​orchestrator_service_pb2.py Updates request and service descriptors.
dapr/​ext/​workflow/​_durabletask/​internal/​orchestrator_service_pb2_grpc.py Adds workflow schedule RPC bindings.
dapr/​ext/​workflow/​_durabletask/​internal/​orchestration_pb2.pyi Types ordering messages and policies.
dapr/​ext/​workflow/​_durabletask/​internal/​orchestration_pb2.py Generates ordering messages and policies.
dapr/​ext/​workflow/​_durabletask/​internal/​history_events_pb2.pyi Types ordering on execution-start events.
dapr/​ext/​workflow/​_durabletask/​internal/​history_events_pb2.py Adds ordering to execution-start descriptors.
dapr/​ext/​workflow/​_durabletask/​internal/​backend_service_pb2.pyi Types backend ordering metadata.
dapr/​ext/​workflow/​_durabletask/​internal/​backend_service_pb2.py Generates backend ordering metadata.
dapr/​ext/​workflow/​_durabletask/​client.py Forwards ordering into synchronous start requests.
dapr/​ext/​workflow/​_durabletask/​aio/​client.py Forwards ordering into asynchronous start requests.
dapr/​ext/​workflow/​__init__.py Exports public ordering types.

Review effort: Balanced

v0.8.0 is the first release with WorkflowOrdering. PROTO_SOURCE_COMMIT_HASH
records its commit. The release also carries the proto additions after
the ordering merge: workflow priority, history propagation scope, the
activity completion worker capability and the name and version of a
detached instance.

Signed-off-by: joshvanl <me@joshvanl.dev>
The sync test that compares schedule_new_workflow_with_result with
schedule_new_workflow now passes an ordering and checks it on the
request. A new async test checks that schedule_new_workflow_with_result
forwards the ordering and still returns the instance ID and staged flag.

Signed-off-by: joshvanl <me@joshvanl.dev>

@sicoyle sicoyle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much @JoshVanL for your interest in the Dapr open source project and for putting this together! 🙌 The plumbing through the low-level clients is nice and clean, and I really like that leaving ordering unset keeps the request exactly as it was before, so existing callers aren't affected. I left a few comments inline, please take a look. 👀

Drafted with AI assistance and reviewed by me.

scheduledStartTimestamp=helpers.new_timestamp(start_at) if start_at else None,
version=wrappers_pb2.StringValue(value=''),
router=new_task_router(app_id),
ordering=ordering,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the ordering key validated anywhere before it reaches the sidecar? The proto requires key to use only letters, digits, - and _, with at most 64 characters. Here the pb.WorkflowOrdering goes straight into the request. The conversion in workflow_ordering.py / dapr_workflow_client.py isn't in this diff, so I can't tell from here.

If it isn't checked yet, what do you think about validating key in the WorkflowOrdering constructor, or in a small request builder like _new_rerun_request? Then users get a clear ValueError instead of an opaque gRPC error, and an empty key wouldn't be taken literally. A few tests would be great too: an empty key, a 65-character key, and a key with a disallowed character.

chain. Any propagated history this workflow received from its
parent is forwarded to the child.
"""
HISTORY_PROPAGATION_SCOPE_START_EVENT_ONLY: _HistoryPropagationScope.ValueType # 3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regeneration adds HISTORY_PROPAGATION_SCOPE_START_EVENT_ONLY = 3, so a runtime on v0.8.0 can now send that value in a propagated history. Does dapr.ext.workflow.propagation convert the wire scope with something like PropagationScope(value) or a fixed mapping? If so, I think it would raise (or quietly misbehave) on 3.

Could we either map 3 explicitly in PropagationScope or fall back safely on unknown values? A test that feeds in a propagated history with scope 3 would cover it nicely.

from google.protobuf.internal import builder as _builder
_runtime_version.ValidateProtobufRuntimeVersion(
_runtime_version.Domain.PUBLIC,
6,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module calls ValidateProtobufRuntimeVersion with 6.33.5, and orchestrator_service_pb2 now imports it unconditionally. Is the protobuf lower bound in the extension's packaging at least 6.33.5? If it's lower, importing dapr.ext.workflow will fail for anyone on an older protobuf runtime. If the floor is lower, I think we could either bump it or regenerate the stubs with the same protoc version the other stubs use.

@@ -1 +1 @@
caf5cc1dbbb896f38d50cd6f8bb1b603a57ca006
a086f5acd1024824d4ecc0a54a2d13f0f351c29a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the first commit message says the stubs come from durabletask-protobuf 9a0ac7b, the second commit and the PR body say v0.8.0, and this file records a086f5a. Is a086f5a the v0.8.0 tag commit? If so, could you reword the squash commit message so it only names v0.8.0 (a086f5a)? That way the history doesn't point at 9a0ac7b.

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.

4 participants