Skip to content

Add standalone activity dispatch hook - #11798

Merged
fretz12 merged 3 commits into
mainfrom
fredtzeng/dispatch-task-hook
Sep 3, 2026
Merged

Add standalone activity dispatch hook#11798
fretz12 merged 3 commits into
mainfrom
fredtzeng/dispatch-task-hook

Conversation

@fretz12

@fretz12 fretz12 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

What changed?

  • Corrected standalone activity dispatch-reason classification for resets and retries.
  • Added a dispatch hook that runs after CHASM validation and before sending the activity to Matching.
  • Added coverage for retry, reset, and pause/unpause transitions.

Why?

Consumers need a reliable way to classify and intercept standalone activity dispatches. Reset attempt 1 was previously classified as a retry, and processing before CHASM validation could include stale tasks replaced by reset, update, pause, or unpause operations.
These changes ensure dispatch reasons reflect the actual attempt and allow integrations to act only on valid dispatches.

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)

Potential risks

  • An incorrectly implemented dispatch hook could block, drop, or duplicate an activity dispatch.

  • Hook errors now propagate through task processing and may cause the dispatch task to retry.

  • Consumers relying on the previous reset dispatch classification may observe reset attempt 1 changing from RETRY to IMMEDIATE.

    When no hook is configured, dispatch behavior remains unchanged.

@fretz12
fretz12 requested a review from a team August 26, 2026 15:42
@fretz12
fretz12 requested a review from a team as a code owner August 26, 2026 15:42
@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Claude finished @fretz12's task in 3m 53s —— View job


Reviewed 5 files, 6 findings.
· fredtzeng/dispatch-task-hook

Comment thread chasm/lib/activity/tasks.go Outdated
Comment thread chasm/lib/activity/tasks.go Outdated
Comment thread chasm/lib/activity/tasks.go Outdated
Comment thread chasm/lib/activity/tasks_test.go
Comment thread chasm/lib/activity/statemachine_test.go
Comment thread chasm/lib/activity/statemachine_test.go Outdated
Comment thread chasm/lib/activity/statemachine_test.go Outdated
@fretz12
fretz12 requested a review from dandavison August 26, 2026 18:11
@fretz12 fretz12 added the reliability-2026 Reliability related changes label Aug 26, 2026
@dandavison
dandavison requested a review from prathyushpv August 28, 2026 18:31
Comment thread chasm/lib/activity/tasks.go Outdated
ctx context.Context,
request *matchingservice.AddActivityTaskRequest,
) error {
_, err := h.opts.MatchingClient.AddActivityTask(ctx, request)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this 1-line helper function improves anything, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

agreed, refactored


return &activitypb.ActivityDispatchTask{
Stamp: a.LastAttempt.Get(ctx).GetStamp(),
Stamp: attempt.GetStamp(),

@dandavison dandavison Sep 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My understanding is that these changes are fixing a bug wherein we were classifying Resets as Retries. This bit LGTM.

if err != nil {
return err
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add a comment here explaining why this task execute function needs this hook machinery instead of just doing its job directly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added

@fretz12
fretz12 marked this pull request as draft September 3, 2026 16:39
@fretz12
fretz12 marked this pull request as ready for review September 3, 2026 16:39
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Claude finished @fretz12's task in 4m 53s —— View job


Reviewed 5 files, 4 findings.
· fredtzeng/dispatch-task-hook

Comment thread chasm/lib/activity/tasks.go
Comment thread chasm/lib/activity/tasks.go
Comment thread chasm/lib/activity/tasks_test.go
Comment thread chasm/lib/activity/statemachine_test.go
@fretz12
fretz12 merged commit 91b7d77 into main Sep 3, 2026
57 checks passed
@fretz12
fretz12 deleted the fredtzeng/dispatch-task-hook branch September 3, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reliability-2026 Reliability related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants