Skip to content

fix(messaging): register EF Core and MongoDB messaging patterns through the shared helper (#1333) - #1399

Merged
dlrivada merged 6 commits into
mainfrom
fix/messaging-registration-1333
Sep 27, 2026
Merged

dlrivada merged 6 commits into
mainfrom
fix/messaging-registration-1333

Conversation

@dlrivada

Copy link
Copy Markdown
Owner

Summary

EF Core and MongoDB hand-rolled their messaging-pattern registrations instead of using the shared helper in Encina.Messaging, and the copies had drifted. MongoDB never registered InboxPipelineBehavior<,>, so UseInbox silently skipped deduplication. Neither provider registered ISagaRunner or ISagaNotFoundDispatcher, so UseSagas threw at first resolution.

What changed

  • Encina.Messaging: new public AddOutboxInboxSagaSchedulingServices<...>. It takes the four pattern flags and their option types separately, so a provider whose configuration type is not MessagingConfiguration can use it. AddMessagingServices<...>, used by the six ADO.NET and Dapper packages, now delegates to it with no behaviour change. PublicAPI.Unshipped.txt is updated.
  • Encina.EntityFrameworkCore: Outbox, Inbox, Saga and Scheduling now register through the shared method. Its own DbContext-bound TransactionPipelineBehavior stays registered directly. It is a different class from the generic one in Encina.Messaging, and routing it through the full helper broke an existing test.
  • Encina.MongoDB: both AddEncinaMongoDB overloads call the shared method through one private helper. EncinaMongoDbOptions exposes the same four option types.
  • Tests:
    • EF Core and MongoDB DI tests build the provider with ValidateOnBuild and ValidateScopes. They assert that InboxPipelineBehavior<,> is present when UseInbox is on and absent when it is off, and that ISagaRunner and ISagaNotFoundDispatcher resolve when UseSagas is on. One test enables every pattern for completeness.
    • Guard tests cover the new public method.
  • changelog.d/1333-messaging-registration.fixed.md and the knowledge record docs/knowledge/issues/1333.md.

Verification

  • Release build of Encina.slnx: 0 warnings, 0 errors.
  • Unit tests matching MongoDB or EntityFrameworkCore: 1726 passed. Messaging guard tests: 493 passed. Messaging, MongoDB and EF Core contract tests: 304 passed.
  • The new DI tests fail on the old registrations. With only the three production files restored to their old content (stashed, not committed), 6 tests failed with the expected symptoms: InboxPipelineBehavior missing, and No service for type 'Encina.Messaging.Sagas.LowCeremony.ISagaRunner'. All pass again with the fix.
  • dotnet format --verify-no-changes clean on changed files. changelog-fragments --check and knowledge-records --check OK.
  • CRAP: the new method has a cyclomatic complexity of about 6, and the tests cover both branches of every condition. AddMessagingServices lost complexity.
  • Self-review by adversarial-reviewer found one major and two minors, all fixed:
    • the major: no guard tests for the new public method;
    • an overstated claim in the knowledge record;
    • duplicated calls in the two MongoDB overloads.

Follow-ups

Cross-cutting checklist (ADR-018)

This is a registration fix, with no new entity, store, behavior or integration. Registration completeness (AGENTS.md §3) is integrated, with a DI test per provider. The 12 functions are not applicable.

Fixes #1333

…ixes

Add PublicAPI entry for AddOutboxInboxSagaSchedulingServices method.
Add changelog fragment documenting MongoDB InboxPipelineBehavior registration
and EF Core/MongoDB ISagaRunner/ISagaNotFoundDispatcher registration fixes.
…EF Core and MongoDB

EF Core and MongoDB hand-rolled their Outbox/Inbox/Saga/Scheduling registration
blocks instead of calling the shared Encina.Messaging helper the ADO.NET and
Dapper packages use, so the registrations had drifted: MongoDB never wired
InboxPipelineBehavior against IPipelineBehavior<,>, and neither EF Core nor
MongoDB registered ISagaRunner or ISagaNotFoundDispatcher.

Add AddOutboxInboxSagaSchedulingServices<...> to
MessagingServiceCollectionExtensions, a granular overload of the existing
Outbox/Inbox/Saga/Scheduling registration logic that takes individual flags
and options instead of a MessagingConfiguration, so a provider whose own
options type is not a MessagingConfiguration (Encina.MongoDB.EncinaMongoDbOptions)
can still share the exact same registrations. AddMessagingServices now
delegates to it internally with no behavior change for ADO.NET/Dapper.

EF Core keeps its own DbContext-bound TransactionPipelineBehavior registered
separately, since it is not interchangeable with the generic
Encina.Messaging.TransactionPipelineBehavior ADO.NET and Dapper share.

Add DI tests per provider that build under ValidateOnBuild/ValidateScopes
with every messaging pattern enabled and resolve ISagaRunner,
ISagaNotFoundDispatcher and the InboxPipelineBehavior<,> registration.
Add GuardTests coverage for the new public
AddOutboxInboxSagaSchedulingServices method (null checks on services and
all four options parameters), extract MongoDB's duplicated registration
call into a private RegisterMessagingPatterns helper shared by both
AddEncinaMongoDB overloads, and correct the knowledge record's overstated
claim about ADO.NET/Dapper DI test coverage.
@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: dlrivada/Encina/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 12fee738-747d-475e-a9da-fe8a290cfa8e


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

…hreshold

Split AddEncinaEntityFrameworkCore, AddEncinaMongoDB (both overloads),
AddMessagingServices and AddOutboxInboxSagaSchedulingServices into small,
single-concern private methods (one per messaging pattern or optional
feature block), each using an early-return guard so its own cyclomatic
complexity stays low. No registration changes: every DI registration is
identical before and after, only regrouped into smaller methods.

Also extracts MongoDB's duplicated common registration block (audit
stores, anonymization, ABAC, index creation, health check, module
isolation, read/write separation) into one shared RegisterCommonServices
helper used by both AddEncinaMongoDB overloads, removing the duplication
between them.

Adds unit tests for branches that had no coverage: the Recoverability
pipeline (including the delayed-retry sub-branch) shared by ADO.NET and
Dapper via AddMessagingServices, and MongoDB's AddEncinaRepository.
@dlrivada

Copy link
Copy Markdown
Owner Author

The first CI run failed the blocking crap-gate on five registration methods (CRAP up to 61.6). 756103f splits them into single-concern private helpers, one per messaging pattern or feature block, with the same registrations, lifetimes and order. It also adds tests for the previously uncovered Recoverability and MongoDB repository branches; 7e3e354 fixes a test summary. Local run of the gate script on real coverage: "No changed method exceeds the CRAP threshold" (45 changed methods). Build 0 warnings; unit 3514/3515 and guard 1100/1101, where the single failure in each needs a Docker daemon and is unrelated; contract 304/304. An independent adversarial review confirmed every extracted block is a verbatim move. The duplicated blocks left in AddMessagingServicesCore are tracked in #1406. CodeRabbit is rate-limited; the adversarial reviews stand in for it (pr-cycle).

@dlrivada
dlrivada enabled auto-merge (squash) September 27, 2026 08:11
@dlrivada
dlrivada merged commit 28fc999 into main Sep 27, 2026
48 checks passed
@dlrivada
dlrivada deleted the fix/messaging-registration-1333 branch September 27, 2026 09:29
dlrivada added a commit that referenced this pull request Sep 27, 2026
…gh the shared helpers (#1406) (#1422)

* refactor(messaging): route AddMessagingServicesCore through the shared Register* helpers

AddMessagingServicesCore carried its own inline copy of the per-pattern registration blocks that PR #1399 already extracted into Register* helpers for AddMessagingServices, so the two paths could drift again. Replace every inline block with a call to the matching helper and drop the redundant outer flag checks each helper already performs.

Add MessagingServiceCollectionExtensionsCoreEquivalenceTests, pinning the exact ServiceDescriptor set AddMessagingServicesCore produces with all patterns enabled and all patterns disabled against the pre-refactor snapshot, proving no behavior change for the ADO.NET tenancy extensions.

Fixes #1406.

* docs(knowledge): link PR #1422 in the #1406 record

---------

Co-authored-by: dlrivada <3762783+dlrivada@users.noreply.github.com>
dlrivada added a commit that referenced this pull request Sep 27, 2026
dlrivada added a commit that referenced this pull request Sep 27, 2026
…as the review-bot fallback (#1447) (#1458)

* docs(plans): implementation plan for pr-reviewer agent (#1447)

* feat(agents): add pr-reviewer agent definition (#1447)

* feat(hooks): wire pr-reviewer into spawn/publish/path-ownership hooks (#1447)

* test(hooks): add pr-reviewer regression cases to Test-Hooks.ps1 (#1447)

* docs(pr-cycle): trigger pr-reviewer instead of adversarial-reviewer when CodeRabbit is unavailable (#1447)

* docs(engineering): sync pr-reviewer agent into routing table and history (#1447)

Adds pr-reviewer to the Claude subagent tier table in ai-task-routing.md
(kept verbatim in sync with .claude/agents/README.md) and records it as
item 15 of the 2026-09-23 agent system review in AI-DEVELOPMENT-MODEL.md.

* docs(knowledge): record pr-reviewer implementation and #1397/#1399 dry-run comparison (#1447)

* fix(agents): wire enforce-path-ownership on pr-reviewer's Bash|PowerShell matcher too

* docs(knowledge): record the self-review finding and fix (#1447)

* docs(knowledge): link PR #1458 in the #1447 record

---------

Co-authored-by: dlrivada <3762783+dlrivada@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] MongoDB never registers InboxPipelineBehavior; EF Core and MongoDB never register ISagaRunner/ISagaNotFoundDispatcher

1 participant