Repository navigation
Consume activity workflow continuation v2 (server#1181) - #501
Merged
Merged
Conversation
Native Server implements activity workflow continuation v2 (server#1181). With enableActivityContinuation on, the Worker now prefers v2 when the Server advertises a well-formed v2 member and keeps v1 as the fallback. - Negotiation reads the v2 member on its own, so a malformed member disables v2 only. v2 also needs sticky history suffixes and no worker interceptors. A 422 unsupported_continuation_version turns v2 off until the Worker registers again. - A workflow task completion with a cached boundary asks for continuation_tail. A tail is appended only when it continues the cache exactly; otherwise the entry is evicted. An omitted or missing tail keeps the old boundary. 422 invalid_continuation_tail resends without the tail. - The activity completion sends v2 only when the cache starts with WorkflowStarted, is contiguous and ends in this attempt's ActivityStarted, and the replay with the result passes the v1 checks. It carries an activity poll; an accepted answer's tail keeps the cache exact and its leased activity runs in the same tick, up to 16 per tick. - Declines process the carried workflow poll and evict only for cache_identity_mismatch and run_not_open. Refusals send the ordinary completion with the same poll. Unknown outcomes resend the identical request and are never replaced by an ordinary completion. The option stays off by default. Docs say continuations are unqualified and may cost throughput until the server#1181 benchmark passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The regression corpus requires a new fixture when sticky-cache and workflow-completion code changes. One opted-in worker runs two sequential activities against a v2 Server: the first workflow task's tail seeds the cache, and both activities complete with v2 continuations speculated from the cache, with no history read. The second continuation's commands come from the first accepted answer's tail and complete the run with 14. On the base revision the worker has no v2 consumer, completes the workflow task without asking for a tail and the scenario fails. The trusted runner has no implementation for the new workflow type at either source revision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ReplayRegressionCorpusTest replays every fixture through tests/Support/ReplayRegressionFixture.php, which mirrors the official runner's scenario dispatch. Add the golden.activity-continuation-v2 case there too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Member
Author
|
Independent review: PASS at head 636999f I checked this against the v2 contract on server main, including "Resolved during implementation", and against the server source ( What I verified:
Two non-blocking follow-ups. Both affect performance only, within the opt-in path, and neither affects correctness:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Part of #500. This is the sdk-php consumer of activity workflow continuation v2 (durable-workflow/server#1181, contract). The issue stays open after merge: it is done only when this ships in the same window as the Server release that advertises v2 and the #1181 benchmark passes.
What
With
enableActivityContinuationon, the Worker prefers v2 when the Server advertises a well-formedv2member and keeps v1 as the fallback. The option stays off by default.supported_versionscontains2,v2.version === 2, the exactcomplete_endpoint,requires_worker_capabilitieswithin what the Worker registers (sticky_execution,sticky_history_suffix), negotiated sticky history suffixes, and the option. Thev2member is parsed on its own, so a malformed member disables v2 only. Worker interceptors keep the ordinary path, as in v1. A422 unsupported_continuation_versionturns v2 off until the Worker registers again.continuation_tail: {"version": 2}. The tail is appended only when it continues the cache exactly (StickyWorkflowCache::appendTail, the same rule as suffixes). Otherwise the entry is evicted. An omitted tail, or a missing one from an older Server, keeps the old boundary. A closed run evicts. A422 invalid_continuation_tailis resent once without the tail and evicts the entry. The run's workflow type and input are kept with the cache entry for the speculative replay.WorkflowStarted, is contiguous from sequence 1, and ends in this attempt'sActivityStarted. That last check covers a lease a replayed carried poll handed back. The Worker must also have reserved a workflow poll slot, and the replay of the cache plus one syntheticActivityCompleted(no ID, norecorded_at, as v1 builds it) must pass the v1 checks. The request carrieshistory_through_sequence,history_last_event_id, thesticky_cacheclaim (boundary equal tothrough), the commands,workflow_polland anactivity_poll. If any precondition fails, the Worker sends the ordinary completion. It does not fall back to v1.cache_identity_mismatchandrun_not_openand keeps the cache for every other reason.500 invalid_continuation_receiptand500 history_invariant_violatedsend the ordinary completion with the same carried workflow poll. The two 500s also evict and log an error.409 stale_attemptandconflicting_completiongo to the existing stale and duplicate handling and are never retried.retryStorageAdmissiongains anuncertainOutcomehook). It is never replaced by an ordinary completion. If the retries run out, the Worker logsworker.outcome_unpublishedand leaves the attempt to the Server.tail_unavailableon a retry. The Worker does not speculate on the leased activity, because the cache does not end in itsActivityStarted. That activity completes the ordinary way.v1 is unchanged. With the option off, or without the v2 member, the request and answer paths are byte-for-byte the old ones.
Docs (
docs/portal/build/workers.md),CHANGELOG.md[Unreleased]andtests/Integration/README.mdare updated. The guide says continuations are unqualified and may cost throughput until the #1181 benchmark passes.Tests
tests/WorkerActivityContinuationV2Test.php(67 tests) uses mocked HTTP to cover:v2and worker-condition case, and that v1 still works;tail_unavailable, a missing tail, another boundary, a gap, alast_sequencemismatch, another version, malformed events;ActivityStarted, and theinvalid_continuation_tailresend;stale_attemptandconflicting_completion;tail_unavailableon a retry, the accepted-tail edge cases, the chain bound, andStickyWorkflowCachetail and context behaviour.tests/Integration/ActivityContinuationV2Test.phpruns against a real native Server. It covers an accepted 3-step chain with no history reads and each activity recorded once. It also covers a lost answer resent identically and answered from the receipt (already_completed, same decision), a 422 refusal falling back to the ordinary completion with the same workflow poll, a decline caused by a signal, and a 300 KB result whose tail is omitted. Locally it passed 4 of 4 runs against an image built from servermain8b71fd1 (Dockerfile.native).tests/fixtures/replay-regressions/activity-continuation-v2-tail-chain.jsonruns a newgolden.activity-continuation-v2scenario (tests/Support/ActivityContinuationV2Scenario.php) through the official runner. On this branch the two activities complete with v2 continuations and no history read. The base revision fails the scenario, and the trusted runner rejects the new workflow type at both source revisions, as the corpus rule requires for a new runner consumer.validate-regression-corpus.py --base-ref origin/mainpasses locally.DURABLE_WORKFLOW_CONTINUATION_V2_QUALIFICATION=1plusDURABLE_WORKFLOW_RUNTIME_URL), following the repo's pattern for candidate-Server qualification. They also skip unless cluster info advertises thev2member. They skipped cleanly against publisheddurableworkflow/server:3.29.0, so no published Server can make them fail. Ordinary CI runs them as skipped.WorkerActivityContinuationTest, everyWorker*Test,StickyHistorySuffixTest,ApiReferenceMetadataTest,ClientContractTestand the completion-limit tests, 3,928 tests in all. One timing test,WorkerActivityLeaseMaintenanceTest::testASlowInitialRenewalKeepsTheClaimUnderTheConservativePollGrant, failed once under load and passed 3 of 3 times on its own with this change. PHPStan is clean, and so is the public-boundary check. CI runs the full matrix.Notes for review
standalone_activity(the cache is kept, a no-op in practice),422 invalid_continuation_tail(resent without the tail, entry evicted), or a missingcontinuation_tailon an accepted v2 answer (evicted). Each choice is the conservative one.🤖 Generated with Claude Code