feat: add workflow orchestration pattern#458
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
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.
| 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); | ||
| } |
| 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; | ||
| } |
| 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); | ||
| } |
Test Results 12 files 12 suites 11m 36s ⏱️ Results for commit 2c24f9b. ♻️ This comment has been updated with latest results. |
Codecov Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🔍 PR Validation ResultsVersion: `` ✅ Validation Steps
📊 ArtifactsDry-run artifacts have been uploaded and will be available for 7 days. This comment was automatically generated by the PR validation workflow. |
d11eef3 to
2c24f9b
Compare
Code Coverage |
Summary
Closes #451
Validation