Skip to content

[Async stack 4/6] Add cold async orchestration context - #361

Draft
andystaples wants to merge 9 commits into
andystaples-async-stack-3-dispatch-cleanupfrom
andystaples-async-stack-4-async-context
Draft

andystaples wants to merge 9 commits into
andystaples-async-stack-3-dispatch-cleanupfrom
andystaples-async-stack-4-async-context

Conversation

@andystaples

@andystaples andystaples commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Warning

This PR is part of a review-only stack and must not be merged individually. The whole stack will be squash-merged after every PR is approved.

Layer 4/6. Async orchestrators receive a cold, await-only AsyncOrchestrationContext. Durable operations return native, single-use coroutines: validation, serialization, scheduling, and relative deadline evaluation occur when execution starts, not when the coroutine is constructed. Inputs are not copied. Timers and event receives own their local registrations and withdraw them when the waiter exits; cancelling remote-work waiters does not cancel the underlying work. Non-finite timer delays and event timeouts are rejected.

as_task_context() is the explicit escape hatch to eager scheduling and reusable durable task handles, including independent borrowed waiters through Task.wait(), task.when_any winner identification, and completion checks.

The synchronous OrchestrationContext and generator orchestration behavior remain unchanged. Async sub-orchestration calls without return_type are typed as Any.

Tests

  • Adds tests/durabletask/test_async_context.py, covering context selection for supported async callable shapes, replay/action parity, cancellation ownership, timeout ordering, public result-type inference, and the race-winner, completion-check, and result idioms.
  • Adds a public API parity test that compares AsyncOrchestrationContext with OrchestrationContext against an explicit allowlist of intentional differences (as_task_context, async-only timeout, and which members are coroutines), plus a metadata parity test for instance_id, parent_instance_id, version, current_utc_datetime, and is_replaying.
  • Moves the existing coroutine and asyncio tests from layers 1-3 to task.AsyncOrchestrationContext, using ctx.as_task_context() where they need eager handles.
  • Adds tests/durabletask/typing/async_context.py for static typing checks.

Docs and CI

Builds on #360. Functions integration (#363) and final documentation and release notes (#364) follow. The stack splits the closed #293.

Comment thread durabletask/async_context.py Resolved
Comment thread durabletask/async_context.py Resolved
Comment thread durabletask/async_context.py Resolved
Comment thread durabletask/async_context.py Resolved
Comment thread durabletask/async_context.py Resolved
Comment thread durabletask/async_context.py Resolved
Comment thread durabletask/async_context.py Resolved
Comment thread durabletask/async_context.py Resolved
Comment thread durabletask/async_context.py Fixed
Comment thread durabletask/async_context.py Fixed
@andystaples
andystaples force-pushed the andystaples-async-stack-4-async-context branch from ffe3599 to 60f02ab Compare November 12, 2026 18:40
andystaples and others added 4 commits November 12, 2026 13:43
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Expose Any when no reconstruction type is supplied, preserving existing decoding behavior and explicit return_type inference. Cover typed and raw results through replay and public typing fixtures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Adapt the new parent classifier tests to the async context introduced by this layer, preserving their callable-chain coverage and asserting runtime context selection.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@andystaples
andystaples force-pushed the andystaples-async-stack-4-async-context branch from 60f02ab to f8347b8 Compare November 12, 2026 20:46
andystaples and others added 5 commits November 12, 2026 15:33
…nc-stack-4-async-context

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…nc-stack-4-async-context

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…nc-stack-4-async-context

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…nc-stack-4-async-context

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Guard AsyncOrchestrationContext against public API and metadata drift from
OrchestrationContext with an explicit allowlist, reject non-finite create_timer
delays like event timeouts, and cover the race-winner, completion-check, and
result idioms. Document them along with un-awaited operations. Remove the
changelog entry for unreleased behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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