Dispatch cancel command for standalone activities#10218
Draft
rkannan82 wants to merge 8 commits into
Draft
Conversation
When a standalone activity's cancellation is requested or it is terminated while running on a worker, proactively dispatch a cancel command via the Nexus worker commands control queue. This avoids relying on the worker to discover cancellation only through heartbeat responses. Changes: - Add worker_control_task_queue field to ActivityAttemptState proto - Store control queue from poll request in TransitionStarted - Add CancelCommandDispatchTask side-effect task - Schedule dispatch task on cancel request and terminate - Dispatch cancel command via Nexus to matching service Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests both cancel-request and terminate paths: start activity with worker control queue, trigger cancellation/termination, verify cancel command arrives on the Nexus control queue with correct task token. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the duplicated cancelCommandDispatchResponseToError with the shared commonnexus.DispatchResponseToError now available from the merged kannan/move-dispatch-response-to-error branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
77e0a54 to
d68c034
Compare
Port error handling pattern from workerCommandsTaskDispatcher: distinguish UpstreamTimeout (no_poller metric), non-retryable handler errors, transport errors, and permanent worker-returned failures. Fix misleading comment on buildCancelCommandTaskToken. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The test was using s.OverrideDynamicConfig, s.FrontendClient(), s.tv etc. which don't exist on the suite — must use env from newTestEnv(). Also fix gofmt formatting in activity_test.go and library.go. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
What
When a standalone (CHASM) activity is cancel-requested or terminated while running on a worker, dispatch a cancel command via the Nexus worker commands control queue — same mechanism added for workflow-based activities in #9233 and #10047.
Why
Without this, standalone activities only discover cancellation passively via heartbeat or completion. If heartbeat isn't enabled, the activity runs to completion uselessly.
How did you test it?
Unit tests (chasm/lib/activity):
Functional tests (tests/standalone_activity_test.go):
TestDispatchCancelCommandToWorker/CancelRequest: start activity with control queue, cancel, verify cancel command arrives on Nexus control queue with correct task tokenTestDispatchCancelCommandToWorker/Terminate: same flow but with terminate🤖 Generated with Claude Code