Skip to content

Conversation

@fretz12
Copy link
Contributor

@fretz12 fretz12 commented Nov 24, 2025

What changed?

Added standalone activity cancellation request and respond handling.

Why?

Needed to support standalone activities full operation.

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

Note

Implements end-to-end standalone activity cancellation with new RPCs, state transitions, token routing, and tests.

  • API/Proto:
    • Add CancelActivityExecution RPC and messages (CancelActivityExecutionRequest/Response) in proto/v1 and generated clients/servers.
  • Frontend:
    • New handler RequestCancelActivityExecution validating/normalizing request_id and calling ActivityService.CancelActivityExecution.
    • For ById activity APIs, when workflow_id is empty, embed componentRef in task tokens (completed/failed/canceled paths).
  • Activity State Machine:
    • Add transitions TransitionCancelRequested and TransitionCanceled; allow CANCEL_REQUESTED in Completed/Failed/Terminated/TimedOut sources.
    • Implement handleCancellationRequested and HandleCanceled; surface CanceledReason in buildActivityExecutionInfo.
    • Guard retries when reschedule is not possible.
  • History:
    • RespondActivityTaskCanceled handles standalone activities via componentRef by invoking Activity.HandleCanceled.
  • Validation:
    • Rename and use validateAndNormalizeRequestID.
  • Tests:
    • Add unit and functional tests covering cancel request idempotency/conflicts, respond-canceled flows, and post-cancel completions.

Written by Cursor Bugbot for commit a42eeaf. This will update automatically on new commits. Configure here.

@fretz12 fretz12 force-pushed the saa-cancel-activity branch from 210d3f9 to c5a62cf Compare November 26, 2025 19:08
@fretz12 fretz12 marked this pull request as ready for review November 26, 2025 19:10
@fretz12 fretz12 requested review from a team as code owners November 26, 2025 19:10
@fretz12
Copy link
Contributor Author

fretz12 commented Nov 26, 2025

cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!


Copy link
Member

@bergundy bergundy left a comment

Choose a reason for hiding this comment

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

Overall this looks really good, it's almost completely correct.

return &activitypb.CancelActivityExecutionResponse{}, nil
}

if err := TransitionCancelRequested.Apply(a, ctx, req); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

You need to check if you're in scheduled state and immediate transition to canceled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha, added the check and modified the transition-from states. Also added a test to cover such a case (disabled for now, see below).

However, I'm running into unable to change workflow state from Created to Completed, status Failed from the chasm engine. This was the same issue with the schedule-to-X timeouts. I believe once we implement the SearchAttributes interface (and @yycptt and team address anything outstanding?), this shouldn't fail then?

@fretz12 fretz12 requested a review from bergundy December 1, 2025 17:10
@fretz12 fretz12 requested a review from bergundy December 1, 2025 21:37
Comment on lines 237 to +239
func (a *Activity) HandleFailed(ctx chasm.MutableContext, req *historyservice.RespondActivityTaskFailedRequest) (
*historyservice.RespondActivityTaskFailedResponse, error) {
*historyservice.RespondActivityTaskFailedResponse, error,
) {
Copy link
Member

Choose a reason for hiding this comment

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

Don't have a strong opinion over the style here. Feel free to do whatever you want as long as its consistent with other places in the codebase.

I personally typically prefer this style (but don't think it's necessarily others opinion and I don't wish to block the PR on this):

Suggested change
func (a *Activity) HandleFailed(ctx chasm.MutableContext, req *historyservice.RespondActivityTaskFailedRequest) (
*historyservice.RespondActivityTaskFailedResponse, error) {
*historyservice.RespondActivityTaskFailedResponse, error,
) {
func (a *Activity) HandleFailed(
ctx chasm.MutableContext,
req *historyservice.RespondActivityTaskFailedRequest
) (*historyservice.RespondActivityTaskFailedResponse, error) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea i prefer that style as well... let me get through all these PRs and a one time reformat on anything remaining as I believe Dan has applied it on PRs after this.

Copy link
Member

@bergundy bergundy left a comment

Choose a reason for hiding this comment

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

Approved with a suggestion.

Base automatically changed from saa-terminate-activity to standalone-activity December 5, 2025 20:26
@fretz12 fretz12 merged commit 97d0e6c into standalone-activity Dec 5, 2025
46 of 48 checks passed
@fretz12 fretz12 deleted the saa-cancel-activity branch December 5, 2025 23:07
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.

4 participants