Skip to content

[Context]: add DAG orchestration ContextGraphBuilder #22

Description

@rian-be

Summary

Add a DAG orchestration extension: ContextGraphBuilder + ExecuteGraphAsync to declare task dependencies and let the library derive which tasks can run in parallel and which must wait for predecessors.

Goal

Orchestrate many context-scoped tasks with declared dependencies, computing parallelism automatically — as an Extension, not part of Core.

Problem

For fan-out/fan-in flows (fetch → validate → save), manual Task.WhenAll ordering is brittle. There is no declarative dependency model.

Scope

var graph = new ContextGraphBuilder<ShopContext>()
    .AddNode("fetch_order", () => FetchOrder(id))
    .AddNode("fetch_customer", () => FetchCustomer(id))
    .AddNode("validate", ValidateOrder, dependsOn: new[] { "fetch_order", "fetch_customer" })
    .Build();

await manager.ExecuteGraphAsync(ctx, graph);
  • Node definition with dependsOn edges.
  • Cycle detection (fail on cycles).
  • Topological scheduling within a single context scope; independent nodes run concurrently.
  • Per-node context isolation + lifecycle events.
  • Cancellation + progress support.
  • Unit tests for parallelism and ordering.

Design Expectations

  • Kept minimal; lives at the Extension level (per Core-minimal-primitive rule).
  • No core runtime changes; orchestration runs topologically over base primitives.

Acceptance Criteria

  • Independent nodes run in parallel; dependent nodes wait.
  • Cycles are rejected.
  • Runs within one logical context with correct isolation.

Non-Goals

  • No workflow-engine features (state, persistence, retry / Polly).
  • No multi-process/queue orchestration (adapter-level).

Metadata

Metadata

Assignees

No one assigned

    Labels

    concurrencyParallel / batch / async executionenhancementNew feature or requestextensionExtension behaviors / helpers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions