Skip to content

Add patch activation callback#1394

Merged
Sushisource merged 4 commits into
mainfrom
patch-activation-callback
Jul 18, 2026
Merged

Add patch activation callback#1394
Sushisource merged 4 commits into
mainfrom
patch-activation-callback

Conversation

@Sushisource

Copy link
Copy Markdown
Member

What was changed

Added an experimental WorkerOptions::patch_activation_callback for native Rust workflows that lets a worker decide whether the first newly encountered, non-replay patched call activates a patch.

The callback receives owned, immutable PatchActivationInput containing 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.

WASM component workflows are intentionally excluded because supporting the host callback there requires a WIT/generated-interface expansion.

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

Why?

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

Testing

  • cargo test -p temporalio-sdk --lib
  • cargo test -p temporalio-workflow patch_activation
  • cargo lint
  • cargo test-lint
  • cargo integ-test workflow_tests::patches: 33 cases
  • Nightly formatting and diff cleanliness checks

@Sushisource
Sushisource force-pushed the patch-activation-callback branch from d56263c to 7cbd856 Compare July 14, 2026 22:34
@Sushisource
Sushisource marked this pull request as ready for review July 14, 2026 22:34
@Sushisource
Sushisource requested a review from a team as a code owner July 14, 2026 22:34

@chris-olszewski chris-olszewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Implementation looks good. My one concern is around exposing WorkflowContextView::new as is. Understand it is doc hidden, but it is easy enough to find in an IDE. A free function would be less discoverable or we could at least make it clear not to depend on it.

Comment thread crates/workflow/src/workflow_context.rs Outdated
Comment on lines +376 to +377
#[doc(hidden)]
pub fn new(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I understand we need someway to drive the patch activation from workflow_wasm, but I don't love exposing this interface as is. The triple Strings are begging for arg mixups.

Maybe a new small struct that carries namespace/task queue/run id and introduce a new call_patch_activation_callback(callback, workflow_info, init) here that is public hidden and handles the PatchActivationInput/WorkflowContextView construction. Still public, but harder to misuse.

@Sushisource
Sushisource force-pushed the patch-activation-callback branch from 7cbd856 to d131bf6 Compare July 17, 2026 23:44
@Sushisource
Sushisource enabled auto-merge (squash) July 17, 2026 23:45
@Sushisource
Sushisource merged commit a9bdead into main Jul 18, 2026
21 checks passed
@Sushisource
Sushisource deleted the patch-activation-callback branch July 18, 2026 00:03
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