Skip to content

feat: add scatter-gather pattern support#287

Merged
JerrettDavis merged 1 commit into
mainfrom
feat/scatter-gather-pattern
May 22, 2026
Merged

feat: add scatter-gather pattern support#287
JerrettDavis merged 1 commit into
mainfrom
feat/scatter-gather-pattern

Conversation

@JerrettDavis
Copy link
Copy Markdown
Owner

Summary

  • adds ScatterGather runtime support for fan-out request/reply aggregation
  • adds GenerateScatterGather source generator support and diagnostics
  • adds supplier quote production example with IServiceCollection integration, docs, catalogs, and TinyBDD coverage

Closes #282

Local validation

  • dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f netstandard2.0 /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f net8.0 /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f net10.0 /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Generators.Abstractions\PatternKit.Generators.Abstractions.csproj /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Generators\PatternKit.Generators.csproj /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net8.0 --no-restore --filter "FullyQualifiedName~ScatterGather" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net10.0 --no-restore --filter "FullyQualifiedName~ScatterGather" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net8.0 --no-restore --filter "FullyQualifiedName~ScatterGather" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net10.0 --no-restore --filter "FullyQualifiedName~ScatterGather" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net8.0 --no-restore --filter "FullyQualifiedName~AbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • git diff --check

Note: full local examples build remains blocked by local compiler/analyzer mismatch CS9057, so hosted CI is authoritative for source-generated example compilation.

@github-actions
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

Copy link
Copy Markdown
Contributor

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

Adds first-class Scatter-Gather support to PatternKit, including a fluent runtime API, a Roslyn incremental source generator + diagnostics, and a DI-friendly supplier quote example with documentation and test coverage.

Changes:

  • Introduces ScatterGather<TRequest, TResponse, TResult> runtime support (dispatch, recipient predicates, aggregation, result/reply models).
  • Adds [GenerateScatterGather] generator support with new PKSCG00x diagnostics plus generator/attribute coverage tests.
  • Adds supplier quote production example (DI + catalogs) and corresponding docs/ToC updates.

Reviewed changes

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

Show a summary per file
File Description
test/PatternKit.Tests/Messaging/Routing/ScatterGatherTests.cs TinyBDD coverage for runtime scatter-gather dispatch, predicates, and configuration validation.
test/PatternKit.Generators.Tests/ScatterGatherGeneratorTests.cs Validates generated factory output ordering and core diagnostics.
test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs Extends attribute coverage suite to include scatter-gather attributes and their defaults/guards.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs Updates catalog expectations to include Scatter-Gather.
test/PatternKit.Examples.Tests/Messaging/SupplierQuoteScatterGatherExampleTests.cs Verifies fluent vs generated parity and IServiceCollection integration for the example.
src/PatternKit.Generators/Messaging/ScatterGatherGenerator.cs Implements incremental generator for scatter-gather factories and PKSCG diagnostics.
src/PatternKit.Generators/AnalyzerReleases.Unshipped.md Registers new analyzer/generator diagnostics in the release notes ledger.
src/PatternKit.Generators.Abstractions/Messaging/ScatterGatherAttributes.cs Adds generator-facing attributes: host, recipient, and aggregator markers.
src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs Adds Scatter-Gather entry to the production readiness pattern catalog.
src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs Adds “Supplier Quote Scatter-Gather” to the example catalog descriptors.
src/PatternKit.Examples/Messaging/SupplierQuoteScatterGatherExample.cs Adds the supplier quote scatter-gather example (fluent + generated) and DI registration.
src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs Wires the new example into the aggregate examples DI entry point.
src/PatternKit.Core/Messaging/Routing/ScatterGather.cs Adds runtime implementation for scatter-gather, reply, and result types.
docs/patterns/toc.yml Adds Scatter-Gather to patterns TOC.
docs/patterns/messaging/scatter-gather.md New pattern guide page for Scatter-Gather usage and generator mention.
docs/guides/pattern-coverage.md Updates coverage table to include Scatter-Gather runtime + generator.
docs/generators/toc.yml Adds Scatter-Gather generator doc to generator TOC.
docs/generators/scatter-gather.md New generator guide page documenting usage and diagnostics.
docs/generators/index.md Adds Scatter-Gather to generator index table.
docs/examples/toc.yml Adds supplier quote scatter-gather example to examples TOC.
docs/examples/supplier-quote-scatter-gather.md New example guide for supplier quote scatter-gather.

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

services.AddSupplierQuoteScatterGatherDemo();

var service = provider.GetRequiredService<SupplierQuoteService>();
var summary = service.RequestQuotes(new SupplierQuoteRequest("SKU-100", 120, requiresColdChain: false));
Comment on lines +65 to +71
var aggregator = type.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(static method =>
method.GetAttributes().Any(static attr => attr.AttributeClass?.ToDisplayString() == "PatternKit.Generators.Messaging.ScatterGatherAggregatorAttribute"));
if (aggregator is null || !IsAggregator(aggregator, requestType, responseType, resultType))
{
context.ReportDiagnostic(Diagnostic.Create(InvalidAggregator, (aggregator is null ? type.Locations : aggregator.Locations).FirstOrDefault(), aggregator?.Name ?? type.Name));
return;
}
| Enterprise Integration | Message Store | `MessageStore<TPayload>` | Message Store generator |
| Enterprise Integration | Wire Tap | `WireTap<TPayload>` | Wire Tap generator |
| Enterprise Integration | Control Bus | `ControlBus<TCommand>` | Control Bus generator |
| Enterprise Integration | Scatter-Gather | `ScatterGather<TRequest,TResponse,TResult>` | Scatter-Gather generator |
@github-actions
Copy link
Copy Markdown
Contributor

Code Coverage

Summary
  Generated on: 05/22/2026 - 00:09:22
  Coverage date: 05/22/2026 - 00:07:45 - 05/22/2026 - 00:09:12
  Parser: MultiReport (9x Cobertura)
  Assemblies: 4
  Classes: 1132
  Files: 482
  Line coverage: 94.8%
  Covered lines: 34048
  Uncovered lines: 1830
  Coverable lines: 35878
  Total lines: 79699
  Branch coverage: 76.6% (9952 of 12992)
  Covered branches: 9952
  Total branches: 12992
  Method coverage: 96.5% (6465 of 6697)
  Full method coverage: 88.5% (5932 of 6697)
  Covered methods: 6465
  Fully covered methods: 5932
  Total methods: 6697

PatternKit.Core                                                                                                    96.4%
  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.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.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.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%
  PatternKit.Application.ServiceLayer.ServiceLayerResult<T>                                                        94.7%
  PatternKit.Application.ServiceLayer.ServiceLayerRule<T>                                                           100%
  PatternKit.Application.Specification.Specification<T>                                                             100%
  PatternKit.Application.Specification.SpecificationRegistry<T>                                                    93.3%
  PatternKit.Application.TableDataGateway.InMemoryTableDataGateway<T1, T2>                                           86%
  PatternKit.Application.TableDataGateway.TableGatewayResult<T>                                                    82.3%
  PatternKit.Application.TransactionScript.TransactionScript<T1, T2>                                                 97%
  PatternKit.Application.TransactionScript.TransactionScriptError                                                    90%
  PatternKit.Application.TransactionScript.TransactionScriptResult<T>                                               100%
  PatternKit.Application.UnitOfWork.UnitOfWork                                                                     90.9%
  PatternKit.Application.UnitOfWork.UnitOfWorkResult                                                               94.7%
  PatternKit.Application.UnitOfWork.UnitOfWorkRollbackResult                                                        100%
  PatternKit.Application.UnitOfWork.UnitOfWorkStep                                                                  100%
  PatternKit.Behavioral.Chain.ActionChain<T>                                                                        100%
  PatternKit.Behavioral.Chain.AsyncActionChain<T>                                                                   100%
  PatternKit.Behavioral.Chain.AsyncResultChain<T1, T2>                                                             97.7%
  PatternKit.Behavioral.Chain.ResultChain<T1, T2>                                                                   100%

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 97.34848% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.05%. Comparing base (317ea77) to head (f0bac2c).

Files with missing lines Patch % Lines
...Kit.Generators/Messaging/ScatterGatherGenerator.cs 97.52% 3 Missing ⚠️
...PatternKit.Core/Messaging/Routing/ScatterGather.cs 96.77% 2 Missing ⚠️
...les/Messaging/SupplierQuoteScatterGatherExample.cs 93.93% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #287      +/-   ##
==========================================
+ Coverage   90.46%   96.05%   +5.58%     
==========================================
  Files         392      396       +4     
  Lines       34215    34479     +264     
  Branches     4809     4868      +59     
==========================================
+ Hits        30954    33118    +2164     
+ Misses       1462     1361     -101     
+ Partials     1799        0    -1799     
Flag Coverage Δ
unittests 96.05% <97.34%> (+5.58%) ⬆️

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
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 2026

Test Results

725 tests   725 ✅  31s ⏱️
  1 suites    0 💤
  1 files      0 ❌

Results for commit f0bac2c.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 2026

🔍 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 merged commit 96e4306 into main May 22, 2026
13 of 14 checks passed
@JerrettDavis JerrettDavis deleted the feat/scatter-gather-pattern branch May 22, 2026 00:41
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 Scatter-Gather enterprise integration pattern

2 participants