feat: add message store pattern support#285
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results 1 files 1 suites 2m 26s ⏱️ Results for commit 59bc499. |
Code Coverage |
🔍 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. |
There was a problem hiding this comment.
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 aMessageStoreGeneratorwith 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); |
| 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(); | ||
|
|
| ```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 Report❌ Patch coverage is
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
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:
|
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 FullyQualifiedName
MessageStore\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.