Skip to content

Fix retry feature activation in mocha - #10363

Merged
PascalSenn merged 2 commits into
mainfrom
pse/fix-mocha-feature-collectoin
Sep 7, 2026
Merged

PascalSenn merged 2 commits into
mainfrom
pse/fix-mocha-feature-collectoin

Conversation

@PascalSenn

Copy link
Copy Markdown
Member

No description provided.

Copilot AI lite review requested due to automatic review settings September 7, 2026 00:02
@PascalSenn PascalSenn changed the title Fix retry feature activation Fix retry feature activation in mocha Sep 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

PooledFeatureCollection.GetOrSet currently evicts cached entries before activation and doesn’t evict type-mismatched cache entries, which can lose cached instances on initialization failures and cause persistent cache poisoning.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes feature activation/reuse behavior in Mocha’s pooled feature collections, which is particularly important for retry flows where pooled ReceiveContext instances (and their feature storage) get reused across attempts and across messages.

Changes:

  • Reworked PooledFeatureCollection to keep a cache of reusable pooled features and to reactivate them via GetOrSet without letting cached items shadow inherited/default features.
  • Added default-interface GetOrSet overloads to IFeatureCollection and refactored FeatureCollectionExtensions to delegate to those overloads.
  • Added/updated tests covering default interface implementations, pooled feature reuse/initialization, and saga retry behavior with warmed receive-context pools.
File summaries
File Description
src/Mocha/test/Mocha.Tests/Features/PooledFeatureCollectionTests.cs New test coverage for pooled feature caching, initialization, inheritance preference, and reset behavior.
src/Mocha/test/Mocha.Tests/Features/FeatureCollectionTests.cs New tests validating IFeatureCollection default-interface GetOrSet behavior and read-only handling.
src/Mocha/test/Mocha.Sagas.Tests/SagaRetryScopeTests.cs Strengthened saga retry test to validate fresh scoped stores across retries and behavior when the receive-context pool is warmed.
src/Mocha/src/Mocha.Utilities/Features/PooledFeatureCollection.cs Refactor: split active vs cached features and add cache-aware GetOrSet behavior to support safe pooling reuse.
src/Mocha/src/Mocha.Utilities/Features/IPooledFeature.cs Updated XML docs to reflect “activation” semantics in pooled collections.
src/Mocha/src/Mocha.Utilities/Features/FeatureCollectionExtensions.cs Simplified GetOrSet extension overloads to delegate to IFeatureCollection GetOrSet APIs; added a null check in Configure.
src/Mocha/src/Mocha.Abstractions/IFeatureCollection.cs Introduced default-interface GetOrSet overloads to standardize feature creation/activation across implementations.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@PascalSenn
PascalSenn merged commit 80abf31 into main Sep 7, 2026
149 of 151 checks passed
@PascalSenn
PascalSenn deleted the pse/fix-mocha-feature-collectoin branch September 7, 2026 00:17
This was referenced Oct 25, 2026
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.

2 participants