Skip to content

Parent Orchestration Access For SubOrchestration#92

Merged
YunchuWang merged 6 commits intomainfrom
wangbill/parent
Feb 4, 2026
Merged

Parent Orchestration Access For SubOrchestration#92
YunchuWang merged 6 commits intomainfrom
wangbill/parent

Conversation

@YunchuWang
Copy link
Member

@YunchuWang YunchuWang commented Feb 4, 2026

Summary

What changed?

  • Added ParentOrchestrationInstance type to expose parent orchestration information in sub-orchestrations
  • Added abstract parent property to OrchestrationContext base class
  • Implemented parent getter in RuntimeOrchestrationContext that extracts parent info from ExecutionStartedEvent
  • Updated orchestration-executor.ts to extract ParentInstanceInfo from protobuf events
  • Extended newExecutionStartedEvent helper to support parentInstance parameter for testing
  • Exported ParentOrchestrationInstance type from package index

Why is this change needed?

  • Feature parity with durabletask-dotnet SDK which exposes context.Parent for sub-orchestrations
  • Enables orchestrations to know if they are running as a sub-orchestration and access parent's name/instanceId
  • Useful for logging, debugging, and building orchestration hierarchies

Issues / work items

  • Resolves #[TBD - add issue number]
  • Related to feature parity initiative between JS and .NET SDKs

Project checklist

  • Release notes are not required for the next release
    • Otherwise: Notes added to CHANGELOG.md
  • Backport is not required
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • All required tests have been added/updated (unit tests, E2E tests)
  • Breaking change?
    • If yes:
      • Impact: None - this is an additive change adding a new optional property
      • Migration guidance: N/A

AI-assisted code disclosure (required)

Was an AI tool used? (select one)

  • No
  • Yes, AI helped write parts of this PR (e.g., GitHub Copilot)
  • Yes, an AI agent generated most of this PR

If AI was used:

  • Tool(s): GitHub Copilot (Claude Opus 4.5)
  • AI-assisted areas/files:
    • src/types/parent-orchestration-instance.type.ts (new file)
    • src/task/context/orchestration-context.ts (added abstract property)
    • src/worker/runtime-orchestration-context.ts (implemented parent getter)
    • src/worker/orchestration-executor.ts (extract parent from events)
    • src/utils/pb-helper.util.ts (test helper update)
    • src/index.ts (export)
    • test/parent-orchestration-instance.spec.ts (new unit tests)
    • test/e2e-azuremanaged/orchestration.spec.ts (new E2E tests)
    • docs/FEATURE_PARITY.md (documentation update)
  • What you changed after AI output: Reviewed all code, verified proto API usage, validated test assertions

AI verification (required if AI was used):

  • I understand the code and can explain it
  • I verified referenced APIs/types exist and are correct
  • I reviewed edge cases/failure paths (timeouts, retries, cancellation, exceptions)
  • I reviewed concurrency/async behavior
  • I checked for unintended breaking or behavior changes

Testing

Automated tests

  • Result: Passed

Unit tests (5 new tests)

PASS test/parent-orchestration-instance.spec.ts
  ✓ should return undefined for parent when orchestration is not a sub-orchestration
  ✓ should return parent instance info when orchestration is a sub-orchestration
  ✓ should preserve parent info during replay
  ✓ should make parent info available in generator orchestrations
  ✓ should return parent info that can be used for debugging/logging

Test Suites: 10 passed, 10 total
Tests:       134 passed, 134 total

E2E tests (2 new tests)

Test Suites: 4 passed, 4 total
Tests:       4 skipped, 49 passed, 53 total

Manual validation (only if runtime/behavior changed)

  • Environment: Windows 11, Node.js 22.x, DTS Emulator (Docker)
  • Steps + observed results:
    1. Started DTS emulator via Docker
    2. Ran E2E test suite with npm run test:e2e:azuremanaged:internal
    3. Parent orchestration tests passed - child orchestration correctly received parent name, instanceId, and taskScheduledId
  • Evidence: Test logs show parent info correctly extracted from ExecutionStartedEvent

Notes for reviewers

  • The taskScheduledId field is included in the ParentOrchestrationInstance interface (optional). This differs slightly from .NET which doesn't expose it publicly, but the proto supports it and it can be useful for debugging.
  • The parent info is set by the backend (DTS/sidecar), not by the SDK when scheduling sub-orchestrations - this matches .NET behavior.
  • Reference implementation: durabletask-dotnet/src/Worker/Core/Shims/TaskOrchestrationContextWrapper.cs

…ions

- Introduced ParentOrchestrationInstance type to represent details of the parent orchestration.
- Updated OrchestrationContext to include a parent property for accessing parent orchestration details.
- Enhanced newExecutionStartedEvent function to accept parent instance information.
- Modified OrchestrationExecutor to extract and set parent instance info during execution.
- Added tests to verify parent orchestration info is correctly handled in sub-orchestrations.
- Created FEATURE_PARITY.md to document feature comparison between durabletask-js and durabletask-dotnet.
Copilot AI review requested due to automatic review settings February 4, 2026 00:23
…tion or class'

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements parent orchestration access for sub-orchestrations, allowing orchestrations to access information about their parent when they are invoked as sub-orchestrations. The implementation adds a new ParentOrchestrationInstance type that exposes the parent's name, instance ID, and task scheduled ID through the OrchestrationContext.parent property.

Changes:

  • Added ParentOrchestrationInstance interface with parent orchestration metadata (name, instanceId, taskScheduledId)
  • Extended OrchestrationContext with abstract parent getter property
  • Implemented parent info extraction in OrchestrationExecutor from protobuf events
  • Added comprehensive unit tests and E2E tests for the feature
  • Created extensive feature parity documentation comparing durabletask-js with durabletask-dotnet

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/durabletask-js/src/types/parent-orchestration-instance.type.ts Defines the ParentOrchestrationInstance interface with documentation
packages/durabletask-js/src/task/context/orchestration-context.ts Adds abstract parent property to OrchestrationContext
packages/durabletask-js/src/worker/runtime-orchestration-context.ts Implements parent property storage in runtime context
packages/durabletask-js/src/worker/orchestration-executor.ts Extracts parent info from ExecutionStartedEvent and populates context
packages/durabletask-js/src/utils/pb-helper.util.ts Updates test helper to support parent instance info in event creation
packages/durabletask-js/src/index.ts Exports ParentOrchestrationInstance type for public API
packages/durabletask-js/test/parent-orchestration-instance.spec.ts Comprehensive unit tests for parent orchestration feature
test/e2e-azuremanaged/orchestration.spec.ts E2E tests validating parent info in real orchestration scenarios
docs/FEATURE_PARITY.md New documentation comparing feature parity with .NET SDK

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@YunchuWang YunchuWang merged commit 2cde0ad into main Feb 4, 2026
7 checks passed
@YunchuWang YunchuWang deleted the wangbill/parent branch February 4, 2026 17:08
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.

3 participants