Skip to content

feat: add event-carried state transfer pattern#312

Merged
JerrettDavis merged 1 commit into
mainfrom
feature/event-carried-state-transfer-308
May 22, 2026
Merged

feat: add event-carried state transfer pattern#312
JerrettDavis merged 1 commit into
mainfrom
feature/event-carried-state-transfer-308

Conversation

@JerrettDavis
Copy link
Copy Markdown
Owner

Closes #308

Summary

  • adds Event-Carried State Transfer runtime API and source generator
  • adds inventory projection demo with IServiceCollection integration
  • adds TinyBDD runtime, generator, example, catalog, and docs coverage

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 net9.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/net9.0/net10.0 --filter FullyQualifiedName~EventCarriedStateTransferTests
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net8.0/net9.0/net10.0 --filter FullyQualifiedNameEventCarriedStateTransferGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests
  • git diff --check

Note: local full examples build still hits the existing CS9057 compiler/analyzer mismatch; hosted CI validates examples/docs.

Copilot AI review requested due to automatic review settings May 22, 2026 06:11
@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

@github-actions
Copy link
Copy Markdown
Contributor

Test Results

  1 files    1 suites   1m 11s ⏱️
938 tests 938 ✅ 0 💤 0 ❌
943 runs  943 ✅ 0 💤 0 ❌

Results for commit 76edb19.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 94.80519% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.98%. Comparing base (be42863) to head (76edb19).

Files with missing lines Patch % Lines
...tateTransfer/EventCarriedStateTransferGenerator.cs 92.43% 9 Missing ⚠️
...tCarriedStateTransfer/EventCarriedStateTransfer.cs 95.55% 2 Missing ⚠️
...sferDemo/InventoryEventCarriedStateTransferDemo.cs 96.96% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #312      +/-   ##
==========================================
+ Coverage   90.24%   95.98%   +5.74%     
==========================================
  Files         436      440       +4     
  Lines       36446    36677     +231     
  Branches     5167     5201      +34     
==========================================
+ Hits        32889    35204    +2315     
+ Misses       1573     1473     -100     
+ Partials     1984        0    -1984     
Flag Coverage Δ
unittests 95.98% <94.80%> (+5.74%) ⬆️

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.

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 the Event-Carried State Transfer (ECST) pattern as a first-class PatternKit feature, including a fluent runtime API, a Roslyn incremental source generator, an inventory projection example with IServiceCollection integration, and accompanying test/docs/catalog coverage.

Changes:

  • Introduces EventCarriedStateTransfer<TEvent,TKey,TState> runtime API and EventCarriedStateTransferGenerator with diagnostics PKECST001-003.
  • Adds runtime/generator/unit tests plus an inventory projection demo and DI registration hooks.
  • Updates pattern/example catalogs and docs (TOCs, guides, generator docs, pattern docs, example docs) to include ECST.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/PatternKit.Tests/EnterpriseIntegration/EventCarriedStateTransfer/EventCarriedStateTransferTests.cs Runtime API tests for success/failure/config validation.
test/PatternKit.Generators.Tests/EventCarriedStateTransferGeneratorTests.cs Generator golden/diagnostics coverage via Roslyn test harness.
test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs Validates new generator attributes defaults/null-guarding.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs Ensures catalogs include ECST and updates family counts.
test/PatternKit.Examples.Tests/EventCarriedStateTransferDemo/InventoryEventCarriedStateTransferDemoTests.cs Validates fluent vs generated demo behavior + DI importability.
src/PatternKit.Generators/EventCarriedStateTransfer/EventCarriedStateTransferGenerator.cs New incremental generator implementation and diagnostics.
src/PatternKit.Generators/AnalyzerReleases.Unshipped.md Registers new analyzer IDs for release tracking.
src/PatternKit.Generators.Abstractions/EnterpriseIntegration/EventCarriedStateTransferAttributes.cs Adds [GenerateEventCarriedStateTransfer] + selector/mapper marker attributes.
src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs Adds ECST to the pattern catalog with doc/source/test pointers.
src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs Adds inventory ECST demo to the example catalog.
src/PatternKit.Examples/EventCarriedStateTransferDemo/InventoryEventCarriedStateTransferDemo.cs New inventory projection example (fluent + generated + DI extension).
src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs Wires ECST demo into aggregate AddPatternKitExamples() registration.
src/PatternKit.Core/EnterpriseIntegration/EventCarriedStateTransfer/EventCarriedStateTransfer.cs New ECST runtime API and result type.
docs/patterns/toc.yml Adds ECST to patterns TOC.
docs/patterns/messaging/README.md Adds ECST pattern landing entry.
docs/patterns/messaging/event-carried-state-transfer.md New ECST pattern doc page.
docs/guides/pattern-coverage.md Adds ECST row to coverage table.
docs/generators/toc.yml Adds ECST generator doc to TOC.
docs/generators/index.md Adds ECST to generator overview table and quick examples.
docs/generators/event-carried-state-transfer.md New ECST generator doc page + diagnostics list.
docs/examples/toc.yml Adds inventory ECST example to examples TOC.
docs/examples/inventory-event-carried-state-transfer.md New inventory ECST example doc page.
docs/examples/index.md Adds inventory ECST entry to examples index.

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

Comment on lines +142 to +150
sb.Append(GetAccessibility(type.DeclaredAccessibility)).Append(' ');
if (type.IsStatic)
sb.Append("static ");
else if (type.IsAbstract && type.TypeKind == TypeKind.Class)
sb.Append("abstract ");
else if (type.IsSealed && type.TypeKind == TypeKind.Class)
sb.Append("sealed ");
sb.Append("partial ").Append(type.TypeKind == TypeKind.Struct ? "struct" : "class").Append(' ').Append(type.Name).AppendLine();
sb.AppendLine("{");
Comment on lines +16 to +20
=> Given("an inventory event", () => new InventoryAdjustedEvent("SKU-100", 12, "CHI-01", 4))
.When("fluent and generated transfers project the event", evt => new
{
Fluent = InventoryEventCarriedStateTransferDemoRunner.RunFluent(),
Generated = BuildServiceProvider().GetRequiredService<InventoryEventCarriedStateTransferDemoRunner>().RunGenerated(evt)
Comment on lines +76 to +80
public static InventoryProjectionSummary RunFluent()
{
var store = new InMemoryInventoryReadModelStore();
var service = new InventoryProjectionService(InventoryStateTransfers.CreateFluent(), store);
return service.Project(new InventoryAdjustedEvent("SKU-100", 12, "CHI-01", 4));
Comment on lines +24 to +26
public void Upsert(string sku, long version, InventoryReadModel state)
=> _summaries[sku] = new("inventory-state", sku, version, state.QuantityOnHand, state.Warehouse);

@github-actions
Copy link
Copy Markdown
Contributor

Code Coverage

Summary
  Generated on: 05/22/2026 - 06:16:53
  Coverage date: 05/22/2026 - 06:15:43 - 05/22/2026 - 06:16:43
  Parser: MultiReport (9x Cobertura)
  Assemblies: 4
  Classes: 1283
  Files: 537
  Line coverage: 94.8%
  Covered lines: 36168
  Uncovered lines: 1951
  Coverable lines: 38119
  Total lines: 84185
  Branch coverage: 76.2% (10544 of 13824)
  Covered branches: 10544
  Total branches: 13824
  Method coverage: 96.3% (7015 of 7279)
  Full method coverage: 88.5% (6443 of 7279)
  Covered methods: 7015
  Fully covered methods: 6443
  Total methods: 7279

PatternKit.Core                                                                                                     96.1%
  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%

@JerrettDavis JerrettDavis merged commit 2845459 into main May 22, 2026
13 checks passed
@JerrettDavis JerrettDavis deleted the feature/event-carried-state-transfer-308 branch May 22, 2026 06:22
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 Event-Carried State Transfer pattern

2 participants