Files
temporal/api/persistence/v1
Shivam 26d6f98f16 Fix transient target version notification leak (#10444)
## What changed
- Adds a focused repro for a failed transient WFT that observes
`targetWorkerDeploymentVersionChanged=true` but never durably commits a
started event. Thus, in the next workflow task, we don't set the
`targetWorkerDeploymentVersionChanged=true` which results in errors with
respect to trampolining
- Now, to fix this, we just have the LastNotifiedTargetVersion present
in the MS to be the source of truth when filling in this flag.

## Why
A transient/speculative WFT can expose the target-version-changed flag
to the SDK before its started event is durable. If that WFT fails or is
discarded, we still should be sending the
`targetWorkerDeploymentVersionChanged=true` to our next workflow task.

## Verification
- `go test -tags test_dep ./tests -run
'TestVersioning3FunctionalSuite/TestPinnedCaN_FailedTransientNotificationDoesNotBecomeDeclinedOnPlainCaN'
-count=1`\n- `go test -tags test_dep ./tests -run
'TestVersioning3FunctionalSuite/TestPinnedCaN_FailedTransientNotificationDoesNotBecomeDeclinedOnPlainCaN'
-count=3`\n\nNote: broader existing trampolining functional tests hit
local test-cluster worker-deployment/user-data setup failures even from
a clean worktree at `c2c4bc1928`; CI should be the source of truth for
those.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Touches pinned versioning signals, persistence schema (reserved
field), and continue-as-new metadata; behavior change is intentional but
affects worker SDK upgrade notifications.
> 
> **Overview**
> Fixes a **pinned worker-deployment** bug where a
**transient/speculative** workflow task could tell the SDK
`target_worker_deployment_version_changed=true` and set
`LastNotifiedTargetVersion`, but a failed/discarded task left the next
poll without that flag because it was no longer stored on mutable state.
> 
> **`target_worker_deployment_version_changed` on `WorkflowTaskStarted`
is now derived at emit time** from `LastNotifiedTargetVersion` (plus
config and **PINNED** behavior) via
`targetWorkerDeploymentVersionChangedForStartedEvent()`, instead of
persisting `workflow_task_target_worker_deployment_version_changed` on
`WorkflowExecutionInfo` / `WorkflowTaskInfo`. Proto field **112** is
**reserved**; apply/rebuild paths and mocks drop the old parameter.
> 
> **Continue-as-new:** `computeDeclinedTargetVersionUpgrade` only
propagates declined-upgrade metadata when the new run **inherits a
pinned version**; otherwise it returns nil.
> 
> Adds
**`TestPinnedCaN_FailedTransientNotificationRefiresDespiteStaleMatching`**
(failed transient notification, mutable state still has
`LastNotifiedTargetVersion`, next WFT re-fires the signal even if
matching rolls back).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
dfaf225b71. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2026-06-03 23:30:46 +00:00
..