Skip to content

Dispatch cancel command for standalone activities#10218

Draft
rkannan82 wants to merge 8 commits into
kannan/move-dispatch-response-to-errorfrom
kannan/standalone-activity-cancel-commands
Draft

Dispatch cancel command for standalone activities#10218
rkannan82 wants to merge 8 commits into
kannan/move-dispatch-response-to-errorfrom
kannan/standalone-activity-cancel-commands

Conversation

@rkannan82
Copy link
Copy Markdown
Contributor

@rkannan82 rkannan82 commented May 11, 2026

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):

  • Worker control task queue stored from poll request on activity start
  • Cancel request dispatches cancel command task when activity is started with a control queue
  • Terminate dispatches cancel command task for started and cancel-requested activities

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 token
  • TestDispatchCancelCommandToWorker/Terminate: same flow but with terminate

🤖 Generated with Claude Code

rkannan82 and others added 6 commits May 11, 2026 12:22
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>
@rkannan82 rkannan82 force-pushed the kannan/standalone-activity-cancel-commands branch from 77e0a54 to d68c034 Compare May 11, 2026 19:26
@rkannan82 rkannan82 changed the base branch from main to kannan/move-dispatch-response-to-error May 11, 2026 19:26
rkannan82 and others added 2 commits May 12, 2026 11:54
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>
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.

1 participant