Skip to content

Add patch activation callback#782

Open
Sushisource wants to merge 2 commits into
mainfrom
patch-activation-callback
Open

Add patch activation callback#782
Sushisource wants to merge 2 commits into
mainfrom
patch-activation-callback

Conversation

@Sushisource

@Sushisource Sushisource commented Jul 10, 2026

Copy link
Copy Markdown
Member

What was changed

Added an experimental TemporalWorkerOptions.PatchActivationCallback that lets a worker decide whether the first newly encountered, non-replay Workflow.Patched call activates a patch.

The callback receives workflow information and the patch ID. Its boolean decision is memoized for the workflow run. Declined patches return false without recording a marker, while replay, existing history markers, and deprecated patches retain their existing behavior.

This ports the behavior introduced by temporalio/sdk-ruby#481.

The work is intentionally split into two commits:

  1. Add patch activation callback contains only the callback API, plumbing, activation semantics, and rollout tests.
  2. Harden read-only workflow contexts makes the callback read-only and completes the workflow context's read-only enforcement. This includes guarding nested patches, workflow metadata and handler mutation, continue-as-new, and patch calls from queries and update validators.

Note

We can drop the second commit if it feels like too much to put in the PR, but, it's done and I think adds some nice safety.

Why?

This allows workflow changes using Workflow.Patched to roll out gradually without every new-code worker immediately recording a marker that older workers cannot replay.

Keeping the read-only hardening in a subsequent commit separates the callback's intended behavior from the broader workflow-context consistency fixes discovered during review.

Testing

  • .NET SDK build across all target frameworks with zero warnings
  • First callback-only commit independently formatted and tested
  • 21 focused callback, read-only, mutation, handler, query, and update-validator cases
  • Changed-file formatting verification
  • Diff and sdk-core submodule cleanliness checks

@jmaeagle99 jmaeagle99 self-assigned this Jul 11, 2026
@Sushisource Sushisource force-pushed the patch-activation-callback branch from 03d9b5d to 3ef7ca1 Compare July 14, 2026 22:06
@Sushisource Sushisource force-pushed the patch-activation-callback branch from 3ef7ca1 to 81323b6 Compare July 14, 2026 23:45
@Sushisource Sushisource force-pushed the patch-activation-callback branch from 81323b6 to 8399fc4 Compare July 15, 2026 17:21
@Sushisource Sushisource marked this pull request as ready for review July 15, 2026 17:44
@Sushisource Sushisource requested a review from a team as a code owner July 15, 2026 17:44
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