Skip to content

CHASM workflow command handler for Nexus#9109

Merged
stephanos merged 10 commits intotemporalio:nexus/hsm-to-chasm-migrationfrom
stephanos:nexus-chasm-commands
Feb 2, 2026
Merged

CHASM workflow command handler for Nexus#9109
stephanos merged 10 commits intotemporalio:nexus/hsm-to-chasm-migrationfrom
stephanos:nexus-chasm-commands

Conversation

@stephanos
Copy link
Copy Markdown
Contributor

@stephanos stephanos commented Jan 22, 2026

What changed?

  • Added workflow command handler registry to CHASM's workflow library.
  • Integrated CHASM's workflow library into workflow completion handler.

Why?

Migrating Nexus from HSM to CHASM.

How did you test it?

Tests will be ported over once actual command handler implementations are added.

@stephanos stephanos changed the title CHASM workflow command handler for Nexus CHASM workflow command handler for Nexus [WiP] Jan 22, 2026
@stephanos stephanos force-pushed the nexus-chasm-commands branch 12 times, most recently from 0225b74 to 15b2305 Compare January 22, 2026 18:19
return []*chasm.RegistrableComponent{
chasm.NewRegistrableComponent[*Operation]("operation"),
chasm.NewRegistrableComponent[*Operation]("cancellation"),
chasm.NewRegistrableComponent[*Cancellation]("cancellation"),
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.

Right?

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.

Yes

@stephanos stephanos force-pushed the nexus-chasm-commands branch 4 times, most recently from 5521052 to 125a6f1 Compare January 22, 2026 18:27
@stephanos stephanos changed the base branch from main to nexus/hsm-to-chasm-migration January 22, 2026 18:27
@stephanos stephanos force-pushed the nexus-chasm-commands branch 3 times, most recently from 3d0f476 to cfe0179 Compare January 22, 2026 18:49
Callbacks chasm.Map[string, *callback.Callback]

// Operations map is used to store the nexus operations for the workflow.
Operations chasm.Map[string, *nexusoperation.Operation]
Copy link
Copy Markdown
Contributor Author

@stephanos stephanos Jan 22, 2026

Choose a reason for hiding this comment

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

Not used yet, but demonstrates why command registry and types need to live in submodule. If they didn't there'd be an import cycle. Having this already ensures this design will work.

@stephanos stephanos force-pushed the nexus-chasm-commands branch 5 times, most recently from ceadf56 to 69632f8 Compare January 22, 2026 19:32

// FailWorkflowTaskError is an error that can be returned from a [CommandHandler] to fail the current workflow task and
// optionally terminate the entire workflow.
type FailWorkflowTaskError struct {
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.

Moving this to CHASM now to break up import cycle.

}

// CommandValidator is a helper for validating workflow commands.
type CommandValidator interface {
Copy link
Copy Markdown
Contributor Author

@stephanos stephanos Jan 22, 2026

Choose a reason for hiding this comment

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

Moved to CHASM, too. More from this package might be moved in follow-up PRs.

var commandHandler chasmcommand.Handler
var chasmCtx chasm.MutableContext

if handler.mutableState.ChasmEnabled() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You will need a way to toggle between HSM and CHASM and you will have to figure out if and how to deal with a mutable state that has both HSM and CHASM nexus operations.

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.

To simplify the migration, we could set a point where we enable CHASM-backed operations. From that time on, new workflows will only use CHASM operations. Then we just have to wait 60 days to know that there are no more valid HSM operations since that is the maximum schedule-to-close timeout.

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.

I was under the impression the migration-related work is a separate ticket out of the scope of this PR. Let me know if you think we need to take action on this PR.

Copy link
Copy Markdown
Contributor

@pdoerner pdoerner left a comment

Choose a reason for hiding this comment

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

Overall LGTM. Just need to make a decision on whether the command handler registry should be specific to the workflow component or a general CHASM concept. I lean toward letting it be coupled with workflow but I don't have a strong opinion.

@stephanos
Copy link
Copy Markdown
Contributor Author

stephanos commented Jan 28, 2026

I made some changes after a team discussion, most importantly: moved the command handler registry out of the Workflow library; it is passed through the "engine" now just like HSM's. The benefit is that the additional Library method I had added to chasm.Context isn't needed anymore.

It was also discussed to add it to chasm.Registry instead which I prefer not to do as that would make CHASM less workflow-agnostic. In any case, my immediate goal is to unblock future work here and have a separate discussion later on revisiting the best place for it.

@stephanos stephanos force-pushed the nexus-chasm-commands branch from da9c5b1 to 7f04034 Compare January 28, 2026 01:33
@stephanos stephanos requested a review from bergundy January 28, 2026 02:11
Comment thread chasm/lib/workflow/command/handler.go Outdated
type Handler func(
chasmCtx chasm.MutableContext,
validator Validator,
workflowTaskCompletedEventID int64,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe for forwards compat we can put this in an options struct?

var commandHandler chasmcommand.Handler
var chasmCtx chasm.MutableContext

// TODO: need to handle migration between HSM and CHASM
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's make sure this is tracked.

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.

👍 filed a ticket to make sure.

Copy link
Copy Markdown
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 couple of very minor comments.

@stephanos stephanos merged commit 67fa6fe into temporalio:nexus/hsm-to-chasm-migration Feb 2, 2026
65 checks passed
@stephanos stephanos deleted the nexus-chasm-commands branch February 2, 2026 18:31
gow pushed a commit that referenced this pull request Feb 3, 2026
## What changed?

- Added workflow command handler registry to CHASM's workflow library.
- Integrated CHASM's workflow library into workflow completion handler.

## Why?

Migrating Nexus from HSM to CHASM.

## How did you test it?

Tests will be ported over once actual command handler implementations
are added.
gow pushed a commit that referenced this pull request Feb 5, 2026
## What changed?

- Added workflow command handler registry to CHASM's workflow library.
- Integrated CHASM's workflow library into workflow completion handler.

## Why?

Migrating Nexus from HSM to CHASM.

## How did you test it?

Tests will be ported over once actual command handler implementations
are added.
gow pushed a commit that referenced this pull request Feb 9, 2026
## What changed?

- Added workflow command handler registry to CHASM's workflow library.
- Integrated CHASM's workflow library into workflow completion handler.

## Why?

Migrating Nexus from HSM to CHASM.

## How did you test it?

Tests will be ported over once actual command handler implementations
are added.
gow pushed a commit that referenced this pull request Feb 18, 2026
- Added workflow command handler registry to CHASM's workflow library.
- Integrated CHASM's workflow library into workflow completion handler.

Migrating Nexus from HSM to CHASM.

Tests will be ported over once actual command handler implementations
are added.
stephanos added a commit to stephanos/temporal that referenced this pull request Feb 19, 2026
- Added workflow command handler registry to CHASM's workflow library.
- Integrated CHASM's workflow library into workflow completion handler.

Migrating Nexus from HSM to CHASM.

Tests will be ported over once actual command handler implementations
are added.
stephanos added a commit to stephanos/temporal that referenced this pull request Feb 19, 2026
- Added workflow command handler registry to CHASM's workflow library.
- Integrated CHASM's workflow library into workflow completion handler.

Migrating Nexus from HSM to CHASM.

Tests will be ported over once actual command handler implementations
are added.
stephanos added a commit that referenced this pull request Feb 20, 2026
- Added workflow command handler registry to CHASM's workflow library.
- Integrated CHASM's workflow library into workflow completion handler.

Migrating Nexus from HSM to CHASM.

Tests will be ported over once actual command handler implementations
are added.
gow pushed a commit that referenced this pull request Feb 24, 2026
- Added workflow command handler registry to CHASM's workflow library.
- Integrated CHASM's workflow library into workflow completion handler.

Migrating Nexus from HSM to CHASM.

Tests will be ported over once actual command handler implementations
are added.
gow pushed a commit that referenced this pull request Feb 25, 2026
- Added workflow command handler registry to CHASM's workflow library.
- Integrated CHASM's workflow library into workflow completion handler.

Migrating Nexus from HSM to CHASM.

Tests will be ported over once actual command handler implementations
are added.
stephanos added a commit that referenced this pull request Feb 26, 2026
- Added workflow command handler registry to CHASM's workflow library.
- Integrated CHASM's workflow library into workflow completion handler.

Migrating Nexus from HSM to CHASM.

Tests will be ported over once actual command handler implementations
are added.
stephanos added a commit that referenced this pull request Feb 26, 2026
- Added workflow command handler registry to CHASM's workflow library.
- Integrated CHASM's workflow library into workflow completion handler.

Migrating Nexus from HSM to CHASM.

Tests will be ported over once actual command handler implementations
are added.
stephanos added a commit that referenced this pull request Feb 26, 2026
- Added workflow command handler registry to CHASM's workflow library.
- Integrated CHASM's workflow library into workflow completion handler.

Migrating Nexus from HSM to CHASM.

Tests will be ported over once actual command handler implementations
are added.
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.

5 participants