Skip to content

Conversation

@fretz12
Copy link
Contributor

@fretz12 fretz12 commented Nov 19, 2025

What changed?

Added standalone activity termination 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

Adds termination support for standalone activities across API, frontend/handler, state machine, and tests.

  • API/Proto:
    • Add TerminateActivityExecution RPC: request/response messages in proto/v1/request_response.proto and service in proto/v1/service.proto.
    • Regenerate clients/servers: activitypb request/response, service, layered client, and gRPC stubs.
  • Frontend:
    • Implement TerminateActivityExecution in frontend.go to resolve namespace and forward to activity service.
  • Backend/Handler:
    • Add handler TerminateActivityExecution to update component via (*Activity).handleTerminated.
    • Add Activity.handleTerminated to apply termination transition.
  • State Machine:
    • Enhance TransitionTerminated to finalize execution, set LastWorkerIdentity, and record TerminatedFailureInfo in outcome.
  • Tests:
    • Add unit test TestTransitionTerminated.
    • Add functional tests for terminating an activity and preventing termination after completion.

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

@fretz12 fretz12 force-pushed the saa-terminate-activity branch from 8710d0b to de5e4f2 Compare November 26, 2025 18:30
@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

}

return store.RecordCompleted(ctx, func(ctx chasm.MutableContext) error {
attempt, err := a.Attempt.Get(ctx)
Copy link
Member

Choose a reason for hiding this comment

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

Why update the last attempt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we're updating the last worker identity from the termination req. If the identity should not be updated on termination, lmk.

Copy link
Member

Choose a reason for hiding this comment

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

This is incorrect, it's not safe to assume that the identity in the termination request is the identity of a worker processing the current attempt. Most likely it'll be a separate client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, removed.
What's the purpose of the Identity field in TerminateActivityExecutionRequest? For our purposes should we ignore it?

return heartbeat, nil
}

func (a *Activity) handleTerminated(ctx chasm.MutableContext, req *activitypb.TerminateActivityExecutionRequest) (
Copy link
Member

Choose a reason for hiding this comment

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

We should dedupe based on the request ID. I forgot that detail in my initial review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this requires API change, I'll do this as a separate PR.

@fretz12 fretz12 requested a review from bergundy December 2, 2025 19:02
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 comments.

}

failure := &failurepb.Failure{
Message: req.GetFrontendRequest().GetReason(),
Copy link
Member

Choose a reason for hiding this comment

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

Put a TODO to revisit this. If the reason isn't provided we'll have an empty message, which isn't great.
I'm also wondering if we want to prefix the reason with:

"Activity terminated: " + req.GetFrontendRequest().GetReason().

Best bring this up in the crew channel on slack. Same for cancelation reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added TODO, will ping crew

Base automatically changed from saa-complete-activity to standalone-activity December 5, 2025 19:59
@fretz12 fretz12 merged commit 9566357 into standalone-activity Dec 5, 2025
48 checks passed
@fretz12 fretz12 deleted the saa-terminate-activity branch December 5, 2025 20:26
dandavison added a commit that referenced this pull request Dec 19, 2025
## What changed?
Added standalone activity termination handling.

## Why?
Needed to support standalone activities full operation.

## How did you test it?
- [X] built
- [X] run locally and tested manually
- [X] covered by existing tests
- [X] added new unit test(s)
- [X] added new functional test(s)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adds termination support for standalone activities across API,
frontend/handler, state machine, and tests.
> 
> - **API/Proto**:
> - Add `TerminateActivityExecution` RPC: request/response messages in
`proto/v1/request_response.proto` and service in
`proto/v1/service.proto`.
> - Regenerate clients/servers: `activitypb` request/response, service,
layered client, and gRPC stubs.
> - **Frontend**:
> - Implement `TerminateActivityExecution` in `frontend.go` to resolve
namespace and forward to activity service.
> - **Backend/Handler**:
> - Add handler `TerminateActivityExecution` to update component via
`(*Activity).handleTerminated`.
>   - Add `Activity.handleTerminated` to apply termination transition.
> - **State Machine**:
> - Enhance `TransitionTerminated` to finalize execution, set
`LastWorkerIdentity`, and record `TerminatedFailureInfo` in outcome.
> - **Tests**:
>   - Add unit test `TestTransitionTerminated`.
> - Add functional tests for terminating an activity and preventing
termination after completion.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
de5e4f2. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Dan Davison <dan.davison@temporal.io>
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