Skip to content

feat(journaling): support composition on plain grains - #11279

Merged
ReubenBond merged 7 commits into
dotnet:mainfrom
ReubenBond:add-journaling-feature-participants
Sep 18, 2026
Merged

ReubenBond merged 7 commits into
dotnet:mainfrom
ReubenBond:add-journaling-feature-participants

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Enables journaled state composition on ordinary grains and application-defined grain base classes. The standard state manager enrolls itself in the activation lifecycle in its grain-bound constructor, so injected durable state recovers during SetupState before OnActivateAsync and requests. AddJournalStorage supplies the scoped manager through a construction-only factory. Resolving journal state or a manager creates the activation's manager; configured features can materialize their state through shared activation setup.

This supersedes this PR's original IJournaledGrainParticipant.Initialize() proposal with the runtime's IConfigureGrainTypeComponents and GrainTypeSharedContext.AddActivationSetup composition boundary. A configurator selects grain classes once per type and registers a shared action which resolves activation-scoped feature services after grain construction and assignment, before lifecycle startup. Scoped features can enroll their existing lifecycle participants for asynchronous startup and shutdown.

DurableGrain remains an optional convenience for StateManager, GetOrCreateState, and WriteStateAsync. Grain code relies on lifecycle enrollment being complete when its scoped manager resolves. The standard manager establishes that guarantee in its grain-bound constructor; custom managers establish it in their constructor or registration factory. An enrollment failure disposes the partially constructed manager and propagates the original error. Explicit-JournalId and storage-only construction retain caller-owned initialization/disposal and independent journal identity.

The change includes focused composition, isolation, recovery, failure, constructor-enrollment, and provider-coherence coverage, along with updated Journaling guidance and source-backed compiled examples. README, documentation, and runnable Azure sample operations accept cancellation tokens and flow them through grain calls, journal writes, and provider I/O. Runnable clients use the host stopping token for operations and the configured shutdown deadline for graceful cleanup. The generated Journaling API matches the runtime foundation's surface after removing the unmerged participant addition; the released compatibility baseline is preserved.

Runtime prerequisite #11305 merged into dotnet/orleans:main at 9303d4ec7cd76ba7f9f41f61fc13774e86430003. This PR is rebased onto that upstream commit, so its diff contains only the Journaling composition changes. Review the immutable Journaling-only comparison.

Downstream consumers in #11280 and #10693 adapt separately: move feature materialization from the specialized participant bootstrap into shared activation setup, resolve state through context.ActivationServices, and enroll feature lifecycle work before startup. Their branches remain separately owned.

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings September 16, 2026 20:42

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.

Copilot review overview

🔵 Needs a closer look

Prevent stale work-item coalescing after recovery-generation changes and correct the related reset wording.

Review effort: Lite
Findings: None

What changed in this PR

Adds grain-scoped Journaling participants, initializing durable state before recovery.

Changes:

  • Adds the participant contract and DurableGrain integration.
  • Updates recovery-generation fencing and state rebinding.
  • Adds lifecycle, recovery, failure, and factory tests.
  • Updates the generated API surface.
File Summary
test/​Orleans.Journaling.Tests/​StateManagerTests.cs Tests recovery fencing scenarios.
test/​Orleans.Journaling.Tests/​JournaledGrainParticipantTests.cs Tests participant lifecycle and activation behavior.
src/​Orleans.Journaling/​JournaledStateManager.cs Adds recovery-generation fencing and state rebinding.
src/​Orleans.Journaling/​IJournaledGrainParticipant.cs Defines the participant contract.
src/​Orleans.Journaling/​DurableGrain.cs Resolves and initializes participants during construction.
src/​api/​Orleans.Journaling/​Orleans.Journaling.cs Updates the generated public API.

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

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage

Metric Pull request
Lines 82.29% (112,547 / 136,771)
Branches 71.58% (32,473 / 45,367)

Report-only conclusion: current-main baseline stale.

The newest successful coverage run tested 9222be9, not current main d515d75.

Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities.

The comparison remains report-only while normal line and branch variance is calibrated.

Coverage details

@ReubenBond
ReubenBond marked this pull request as ready for review September 16, 2026 21:09
Copilot AI review requested due to automatic review settings September 16, 2026 22:01
@ReubenBond
ReubenBond force-pushed the add-journaling-feature-participants branch from a135812 to 65c73bd Compare September 16, 2026 22:01

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.

Copilot review overview

🔵 Needs a closer look

The recovery and activation changes require final human review.

Review effort: Lite
Findings: None

Copilot AI review requested due to automatic review settings September 16, 2026 23:46
@ReubenBond
ReubenBond force-pushed the add-journaling-feature-participants branch from 65c73bd to 7ecb8bb Compare September 16, 2026 23:46

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.

Copilot review overview

🔵 Needs a closer look

The explicit-JournalId test does not activate or initialize a journaling participant as intended.

Review effort: Lite
Findings: None

@ReubenBond
ReubenBond force-pushed the add-journaling-feature-participants branch from 7ecb8bb to 5c33af8 Compare September 17, 2026 02:46
Copilot AI review requested due to automatic review settings September 17, 2026 02:46

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.

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

@ReubenBond ReubenBond changed the title feat(journaling): add grain feature participants feat(journaling): support composition on plain grains Sep 17, 2026
Copilot AI review requested due to automatic review settings September 17, 2026 18:28
@ReubenBond
ReubenBond force-pushed the add-journaling-feature-participants branch from 5c33af8 to 3497499 Compare September 17, 2026 18:28

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.

Copilot review overview

🔵 Needs a closer look

A moderate concurrency issue in IGrainContextActivator must be addressed before approval.

Review effort: Lite
Findings: None

@ReubenBond
ReubenBond force-pushed the add-journaling-feature-participants branch from 3497499 to 15be673 Compare September 17, 2026 20:05
Copilot AI review requested due to automatic review settings September 17, 2026 20:17

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.

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

Copilot AI review requested due to automatic review settings September 17, 2026 21:43

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.

Copilot review overview

🟢 Approval recommended

No blocking issues were identified, and the approval assessments support approval.

Review effort: Lite
Findings: None

@ReubenBond
ReubenBond merged commit 0f9537d into dotnet:main Sep 18, 2026
73 checks passed
@ReubenBond
ReubenBond deleted the add-journaling-feature-participants branch September 18, 2026 16:09
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.

2 participants