Skip to content

Add RunInChildContextAsync#2370

Draft
GarrettBeatty wants to merge 1 commit into
GarrettBeatty/stack/3from
gcbeatty/durable-child-context
Draft

Add RunInChildContextAsync#2370
GarrettBeatty wants to merge 1 commit into
GarrettBeatty/stack/3from
gcbeatty/durable-child-context

Conversation

@GarrettBeatty
Copy link
Copy Markdown
Contributor

Summary

  • Adds RunInChildContextAsync to IDurableContext (3 overloads: reflection, AOT-safe ICheckpointSerializer<T>, and void-returning).
  • Adds ChildContextConfig (SubType for observability, ErrorMapping for exception remapping) and ChildContextException for failure surfacing.
  • Implements Internal/ChildContextOperation<T> mirroring the Step/Wait pattern: sync-flush CONTEXT START → run user func → emit SUCCEED with serialized result, or FAIL with error and throw ChildContextException. Replay: SUCCEEDED returns cached value, FAILED throws (after ErrorMapping), STARTED/PENDING re-runs the func and lets the child's own operations replay from their own checkpoints.
  • Extends LambdaDurableServiceClient.MapFromSdkOperation to copy ContextDetails (Result + Error).

This is a building block for upcoming WaitForCallbackAsync, which (per the Java/JS reference SDKs) wraps CreateCallbackAsync + a submitter step inside a child context for observability and clean error mapping.

Test plan

  • 16 new tests in ChildContextOperationTests.cs covering: fresh execution + checkpoint emission, deterministic child operation IDs, replay SUCCEEDED, replay FAILED (with and without ErrorMapping), suspended child (Wait inside child propagates termination), replay STARTED with completed inner step, void overload, AOT-safe serializer overload.
  • 161/161 tests pass on net8.0 and net10.0 (existing Step/Wait tests untouched).
  • Production build clean: 0 warnings, 0 errors.

🤖 Generated with Claude Code

@GarrettBeatty GarrettBeatty force-pushed the GarrettBeatty/stack/3 branch from d943d16 to 7ca2099 Compare May 14, 2026 18:07
@GarrettBeatty GarrettBeatty force-pushed the gcbeatty/durable-child-context branch from cd3e24c to e146869 Compare May 14, 2026 18:10
Adds child-context support to the .NET Durable Execution SDK. A child
context is a logical sub-workflow with its own deterministic
operation-ID space, persisted as a CONTEXT operation so subsequent
invocations replay the cached value without re-executing the function.

Public surface:
- IDurableContext.RunInChildContextAsync<T> (reflection + AOT-safe
  ICheckpointSerializer<T> overloads, plus a void overload).
- ChildContextConfig with SubType (observability label) and
  ErrorMapping (transform exceptions before they surface to the caller).
- ChildContextException for failure surfacing.

Used as a building block for upcoming WaitForCallbackAsync.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@GarrettBeatty GarrettBeatty force-pushed the gcbeatty/durable-child-context branch from e146869 to 369a029 Compare May 14, 2026 21:49
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