Skip to content

feat: add workflow orchestration pattern#458

Merged
JerrettDavis merged 1 commit into
mainfrom
feat/workflow-orchestration-451
May 30, 2026
Merged

feat: add workflow orchestration pattern#458
JerrettDavis merged 1 commit into
mainfrom
feat/workflow-orchestration-451

Conversation

@JerrettDavis

Copy link
Copy Markdown
Owner

Summary

  • adds Workflow Orchestration runtime APIs with ordered steps, conditions, retries, compensation, and execution history
  • adds source-generator attributes/generator for annotated workflow methods
  • adds fulfillment DI example, docs, catalog entries, benchmark coverage, and TinyBDD tests

Closes #451

Validation

  • targeted runtime, generator, example, catalog, and benchmark-coverage tests passed
  • dotnet format PatternKit.slnx --verify-no-changes --verbosity minimal
  • dotnet build PatternKit.slnx --configuration Release --no-restore -p:UseSharedCompilation=false
  • dotnet test PatternKit.slnx --configuration Release --no-build -p:TestTfmsInParallel=false

@github-actions

github-actions Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

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.

Pull request overview

Adds a new Workflow Orchestration application-architecture pattern: a fluent WorkflowOrchestrator<TContext> runtime with ordered/conditional steps, retries, compensation, and execution history; a Roslyn incremental generator ([WorkflowOrchestration] / [WorkflowStep]) that builds the same orchestrator from annotated partial host types; and a fulfillment DI/Generic-Host example. Catalog, example registry, docs (pattern, generator, example, ToCs, READMEs), benchmark coverage, and TinyBDD tests are updated to keep the 112-pattern coverage matrix consistent.

Changes:

  • New runtime, generator, abstractions attributes, and fulfillment example for Workflow Orchestration.
  • Catalog/DI registration updates and new FulfillmentWorkflowOrchestrationPatternExample.
  • Docs, ToCs, README, benchmark guide/results, generator analyzer release notes, and TinyBDD test coverage added.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/PatternKit.Core/Application/WorkflowOrchestration/WorkflowOrchestrator.cs New fluent orchestrator, builder, step, execution, and record types.
src/PatternKit.Generators/WorkflowOrchestration/WorkflowOrchestrationGenerator.cs New incremental generator emitting Create… factory for annotated workflows.
src/PatternKit.Generators.Abstractions/WorkflowOrchestration/WorkflowOrchestrationAttributes.cs Public [WorkflowOrchestration] / [WorkflowStep] attributes.
src/PatternKit.Generators/AnalyzerReleases.Unshipped.md Registers PKWO001–PKWO005 diagnostics.
src/PatternKit.Examples/WorkflowOrchestrationDemo/FulfillmentWorkflowOrchestrationDemo.cs Fluent + generated fulfillment workflow, service, runner, DI extensions.
src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs Registers the new fulfillment example in the aggregate examples graph.
src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs Adds the Workflow Orchestration catalog entry.
src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs Adds the fulfillment example descriptor.
benchmarks/PatternKit.Benchmarks/Application/WorkflowOrchestrationBenchmarks.cs New construction/execution benchmarks for fluent and generated routes.
test/PatternKit.Tests/Application/WorkflowOrchestration/WorkflowOrchestratorTests.cs Runtime TinyBDD scenarios for ordering, retries, compensation, validation.
test/PatternKit.Generators.Tests/WorkflowOrchestrationGeneratorTests.cs Generator scenarios for success, diagnostics, and nested partial wrappers.
test/PatternKit.Examples.Tests/WorkflowOrchestrationDemo/FulfillmentWorkflowOrchestrationDemoTests.cs Example scenarios incl. DI/aggregate registration.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs Updates application-architecture pattern count and adjacency list.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitBenchmarkCoverageTests.cs Bumps published route-result total to 448.
README.md, docs/index.md, docs/guides/pattern-coverage.md, docs/guides/benchmarks.md, docs/guides/benchmark-results.md Updates counts/rows for the new pattern and benchmark rows.
docs/patterns/application/workflow-orchestration.md, docs/patterns/toc.yml New pattern doc + ToC entry.
docs/generators/workflow-orchestration.md, docs/generators/toc.yml, docs/generators/index.md Generator doc + ToC/index entries.
docs/examples/fulfillment-workflow-orchestration.md, docs/examples/toc.yml, docs/examples/index.md Example doc + ToC/index entries.

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

Comment on lines +32 to +50
foreach (var step in _steps)
{
cancellationToken.ThrowIfCancellationRequested();

if (!step.ShouldRun(context))
{
history.Add(WorkflowExecutionRecord.Skipped(step.Name));
continue;
}

var outcome = await ExecuteStepAsync(step, context, history, cancellationToken).ConfigureAwait(false);
if (!outcome.Succeeded)
{
await CompensateAsync(completed, context, history, cancellationToken).ConfigureAwait(false);
return new WorkflowExecution<TContext>(Name, context, WorkflowExecutionStatus.Failed, history);
}

completed.Push(step);
}
Comment on lines +116 to +126
if (!string.IsNullOrWhiteSpace(step.Condition) && !HasValidCondition(type, step.Condition!, contextType!))
{
context.ReportDiagnostic(Diagnostic.Create(InvalidStep, step.Method.Locations.FirstOrDefault(), step.Method.Name));
return;
}

if (!string.IsNullOrWhiteSpace(step.Compensation) && !HasValidStepSignature(FindMethod(type, step.Compensation!), contextType))
{
context.ReportDiagnostic(Diagnostic.Create(InvalidStep, step.Method.Locations.FirstOrDefault(), step.Method.Name));
return;
}
Comment on lines +132 to +143
public WorkflowOrchestrator<TContext> Build()
{
var ordered = _steps
.OrderBy(static step => step.Order)
.ThenBy(static step => step.Name, StringComparer.Ordinal)
.ToArray();

if (ordered.Select(static step => step.Name).Distinct(StringComparer.Ordinal).Count() != ordered.Length)
throw new InvalidOperationException("Workflow step names must be unique.");

return new WorkflowOrchestrator<TContext>(_name, ordered);
}
@github-actions

github-actions Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

Test Results

    12 files      12 suites   11m 36s ⏱️
 3 908 tests  3 908 ✅ 0 💤 0 ❌
12 155 runs  12 155 ✅ 0 💤 0 ❌

Results for commit 2c24f9b.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.49431% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.83%. Comparing base (23428a4) to head (2c24f9b).

Files with missing lines Patch % Lines
...tion/WorkflowOrchestration/WorkflowOrchestrator.cs 97.22% 4 Missing ⚠️
...lowOrchestration/WorkflowOrchestrationGenerator.cs 97.81% 4 Missing ⚠️
...rationDemo/FulfillmentWorkflowOrchestrationDemo.cs 95.83% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #458      +/-   ##
==========================================
+ Coverage   96.66%   96.83%   +0.16%     
==========================================
  Files         567      571       +4     
  Lines       45979    46417     +438     
  Branches     3022     6127    +3105     
==========================================
+ Hits        44447    44946     +499     
+ Misses       1532     1471      -61     
Flag Coverage Δ
unittests 96.83% <97.49%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@github-actions

github-actions Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

🔍 PR Validation Results

Version: ``

✅ Validation Steps

  • Build solution
  • Run tests
  • Build documentation
  • Dry-run NuGet packaging

📊 Artifacts

Dry-run artifacts have been uploaded and will be available for 7 days.


This comment was automatically generated by the PR validation workflow.

@JerrettDavis JerrettDavis force-pushed the feat/workflow-orchestration-451 branch from d11eef3 to 2c24f9b Compare May 30, 2026 18:18
@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Summary
  Generated on: 05/30/2026 - 18:25:44
  Coverage date: 05/30/2026 - 18:23:11 - 05/30/2026 - 18:25:32
  Parser: MultiReport (12x Cobertura)
  Assemblies: 5
  Classes: 1683
  Files: 571
  Line coverage: 96.6%
  Covered lines: 44870
  Uncovered lines: 1547
  Coverable lines: 46417
  Total lines: 99425
  Branch coverage: 82.3% (13994 of 16998)
  Covered branches: 13994
  Total branches: 16998
  Method coverage: 96.7% (8756 of 9051)
  Full method coverage: 90.4% (8185 of 9051)
  Covered methods: 8756
  Fully covered methods: 8185
  Total methods: 9051

PatternKit.Core                                                                                                     95.6%
  PatternKit.Application.ActivityTracking.ActivityGateState                                                          100%
  PatternKit.Application.ActivityTracking.ActivityLease                                                              100%
  PatternKit.Application.ActivityTracking.ActivityRecord                                                             100%
  PatternKit.Application.ActivityTracking.ActivityTracker                                                            100%
  PatternKit.Application.Aggregates.AggregateCommandHandler<T1, T2, T3>                                              100%
  PatternKit.Application.Aggregates.AggregateCommandResult<T>                                                        100%
  PatternKit.Application.Aggregates.AggregateRoot<T1, T2>                                                            100%
  PatternKit.Application.AntiCorruption.AntiCorruptionLayer<T1, T2>                                                 90.4%
  PatternKit.Application.AntiCorruption.AntiCorruptionResult<T>                                                      100%
  PatternKit.Application.AuditLog.AuditLogAppendResult<T>                                                           85.7%
  PatternKit.Application.AuditLog.InMemoryAuditLog<T1, T2>                                                          95.4%
  PatternKit.Application.BoundedContexts.BoundedContextAdapter                                                       100%
  PatternKit.Application.BoundedContexts.BoundedContextCapability                                                   83.3%
  PatternKit.Application.BoundedContexts.BoundedContextDescriptor                                                   95.4%
  PatternKit.Application.ContextMaps.ContextMapDescriptor                                                           96.8%
  PatternKit.Application.ContextMaps.ContextMapRelationship                                                          100%
  PatternKit.Application.DataMapping.DataMapper<T1, T2>                                                             94.6%
  PatternKit.Application.DataMapping.DataMapperError                                                                  90%
  PatternKit.Application.DataMapping.DataMapperResult<T>                                                            84.6%
  PatternKit.Application.DomainEvents.DomainEventDispatcher<T>                                                      95.4%
  PatternKit.Application.DomainEvents.DomainEventDispatchResult                                                      100%
  PatternKit.Application.DomainServices.DomainServiceOperation<T1, T2>                                               100%
  PatternKit.Application.DomainServices.DomainServiceRegistry<T1, T2>                                                100%
  PatternKit.Application.EventSourcing.EventStoreAppendResult                                                        100%
  PatternKit.Application.EventSourcing.InMemoryEventStore<T1, T2>                                                   97.9%
  PatternKit.Application.EventSourcing.StoredEvent<T1, T2>                                                            80%
  PatternKit.Application.FeatureToggles.FeatureToggleDecision                                                       87.5%
  PatternKit.Application.FeatureToggles.FeatureToggleRule<T>                                                         100%
  PatternKit.Application.FeatureToggles.FeatureToggleSet<T>                                                         96.9%
  PatternKit.Application.IdentityMap.IdentityMap<T1, T2>                                                             100%
  PatternKit.Application.IdentityMap.IdentityMapResult<T>                                                           92.8%
  PatternKit.Application.ManualTaskGates.ManualTaskGate<T>                                                          98.5%
  PatternKit.Application.ManualTaskGates.ManualTaskGateState<T>                                                      100%
  PatternKit.Application.ManualTaskGates.ManualTaskRecord<T>                                                        96.9%
  PatternKit.Application.MaterializedViews.MaterializedView<T1, T2>                                                 98.4%
  PatternKit.Application.Repository.InMemoryRepository<T1, T2>                                                      92.8%
  PatternKit.Application.Repository.RepositoryResult<T>                                                             93.3%
  PatternKit.Application.ServiceLayer.ServiceLayerOperation<T1, T2>                                                 96.7%

@JerrettDavis JerrettDavis merged commit a5bfa66 into main May 30, 2026
12 checks passed
@JerrettDavis JerrettDavis deleted the feat/workflow-orchestration-451 branch May 30, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Workflow Orchestration pattern

2 participants