Skip to content

feat: add message store pattern support#285

Merged
JerrettDavis merged 1 commit into
mainfrom
feat/message-store-pattern
May 21, 2026
Merged

feat: add message store pattern support#285
JerrettDavis merged 1 commit into
mainfrom
feat/message-store-pattern

Conversation

@JerrettDavis
Copy link
Copy Markdown
Owner

Closes #284.\n\nAdds the Message Store enterprise integration pattern with:\n- fluent runtime message store for append, lookup, query, replay, duplicate detection, and retention policy handling\n- source generator attributes and MessageStoreGenerator for typed generated factories\n- TinyBDD runtime and generator coverage plus attribute coverage\n- DI-importable order audit/replay example with fluent and generated paths\n- docs, ToC updates, and production-readiness catalog entries\n\nLocal validation:\n- dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f netstandard2.0 /p:UseSharedCompilation=false\n- dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f net10.0 /p:UseSharedCompilation=false\n- dotnet build src\PatternKit.Generators\PatternKit.Generators.csproj /p:UseSharedCompilation=false\n- dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net8.0 --filter FullyQualifiedNameMessageStore\n- dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net10.0 --filter FullyQualifiedNameMessageStore\n- dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net8.0 --filter FullyQualifiedNameMessageStore|FullyQualifiedNameAbstractionsAttributeCoverageTests\n- dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net10.0 --filter FullyQualifiedNameMessageStore|FullyQualifiedNameAbstractionsAttributeCoverageTests\n- docfx metadata docs/docfx.json\n- docfx build docs/docfx.json\n- git diff --check\n\nNote: local full examples build still hits the existing CS9057 Roslyn analyzer/compiler mismatch, so hosted CI remains authoritative for the complete examples pass.

Copilot AI review requested due to automatic review settings May 21, 2026 21:55
@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   2m 26s ⏱️
855 tests 855 ✅ 0 💤 0 ❌
860 runs  860 ✅ 0 💤 0 ❌

Results for commit 59bc499.

@github-actions
Copy link
Copy Markdown
Contributor

Code Coverage

Summary
  Generated on: 05/21/2026 - 22:00:18
  Coverage date: 05/21/2026 - 21:58:38 - 05/21/2026 - 22:00:08
  Parser: MultiReport (9x Cobertura)
  Assemblies: 4
  Classes: 1102
  Files: 472
  Line coverage: 94.8%
  Covered lines: 33503
  Uncovered lines: 1817
  Coverable lines: 35320
  Total lines: 78544
  Branch coverage: 76.6% (9748 of 12722)
  Covered branches: 9748
  Total branches: 12722
  Method coverage: 96.5% (6329 of 6555)
  Full method coverage: 88.5% (5802 of 6555)
  Covered methods: 6329
  Fully covered methods: 5802
  Total methods: 6555

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%

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

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 Enterprise Integration Pattern “Message Store” to PatternKit, including a fluent in-memory runtime store, a Roslyn incremental generator for typed factory generation, and full example + docs + catalog coverage so consumers can adopt either fluent or generated paths.

Changes:

  • Introduces MessageStore<TPayload> runtime API (append, lookup, query, replay) with retention + duplicate detection semantics.
  • Adds [GenerateMessageStore] + identity/retention hook attributes and a MessageStoreGenerator with diagnostics (PKMS001–PKMS004).
  • Adds TinyBDD test coverage, DI-importable order audit/replay example, and updates pattern/example catalogs and documentation ToCs.

Reviewed changes

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

Show a summary per file
File Description
test/PatternKit.Tests/Messaging/Storage/MessageStoreTests.cs Adds runtime MessageStore behavior tests (append/duplicate/retention/query/config validation).
test/PatternKit.Generators.Tests/MessageStoreGeneratorTests.cs Adds generator tests for source output and diagnostics.
test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs Extends attribute coverage suite for new message store attributes.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs Updates production-readiness catalog expectations for the new pattern entry.
test/PatternKit.Examples.Tests/Messaging/OrderMessageStoreExampleTests.cs Adds tests for fluent vs generated example behavior and DI registration.
test/PatternKit.Examples.Tests/DependencyInjection/PatternKitExampleDependencyInjectionTests.cs Ensures the new message store example is resolvable and runnable via aggregate DI registration.
src/PatternKit.Generators/Messaging/MessageStoreGenerator.cs Implements the Roslyn incremental generator for message store factories + diagnostics.
src/PatternKit.Generators/AnalyzerReleases.Unshipped.md Registers new diagnostics PKMS001–PKMS004.
src/PatternKit.Generators.Abstractions/Messaging/MessageStoreAttributes.cs Adds generator-facing attributes for host types and identity/retention hooks.
src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs Adds “Message Store” pattern entry tying together docs/runtime/generator/tests/example.
src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs Adds “Order Message Store” example descriptor for the examples catalog.
src/PatternKit.Examples/Messaging/OrderMessageStoreExample.cs Adds fluent + generated example plus DI import extension for an order audit/replay store.
src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs Wires the message store example into the aggregate AddPatternKitExamples() registration.
src/PatternKit.Core/Messaging/Storage/MessageStore.cs Adds the core in-memory MessageStore runtime implementation, query model, and append result types.
docs/patterns/toc.yml Adds Message Store to the patterns ToC.
docs/patterns/messaging/message-store.md Adds the Message Store pattern guide page.
docs/guides/pattern-coverage.md Updates coverage matrix with Message Store runtime + generator.
docs/generators/toc.yml Adds Message Store generator doc to generator ToC.
docs/generators/message-store.md Adds generator usage + diagnostics documentation.
docs/generators/index.md Links Message Store generator in generators index table.
docs/examples/toc.yml Adds Order Message Store to examples ToC.
docs/examples/order-message-store.md Adds the Order Message Store example guide page.

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

if (_byId.TryGetValue(messageId, out var existing))
return MessageStoreAppendResult<TPayload>.ForDuplicate(_name, existing);

var stored = new StoredMessage<TPayload>(_name, messageId, ++_sequence, _clock(), message, effectiveContext.Headers);
Comment on lines +46 to +49
var stored = new StoredMessage<TPayload>(_name, messageId, ++_sequence, _clock(), message, effectiveContext.Headers);
if (!_retentionPredicate(stored))
return MessageStoreAppendResult<TPayload>.ForRejected(_name, stored, "Message did not satisfy retention policy.");

.IdentifyBy((message, context) => message.Headers.MessageId!)
.RetainWhen(stored => !stored.Message.Payload.ContainsSensitiveData)
.Build();

Comment on lines +5 to +12
```csharp
services.AddOrderMessageStoreDemo();

var service = provider.GetRequiredService<OrderMessageStoreService>();
var summary = service.Record(
new OrderMessageStoreEvent("ORDER-100", "Submitted", 125m, containsSensitiveData: false),
"MSG-100",
"CHECKOUT-100");
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 97.26027% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.03%. Comparing base (7010836) to head (59bc499).

Files with missing lines Patch % Lines
.../PatternKit.Core/Messaging/Storage/MessageStore.cs 96.36% 4 Missing ⚠️
...nKit.Generators/Messaging/MessageStoreGenerator.cs 96.69% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #285      +/-   ##
==========================================
+ Coverage   90.48%   96.03%   +5.55%     
==========================================
  Files         384      388       +4     
  Lines       33640    33932     +292     
  Branches     4716     4764      +48     
==========================================
+ Hits        30439    32588    +2149     
+ Misses       1443     1344      -99     
+ Partials     1758        0    -1758     
Flag Coverage Δ
unittests 96.03% <97.26%> (+5.55%) ⬆️

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.

@JerrettDavis JerrettDavis merged commit 47dc17b into main May 21, 2026
13 checks passed
@JerrettDavis JerrettDavis deleted the feat/message-store-pattern branch May 21, 2026 22:06
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 Message Store enterprise integration pattern

2 participants