[Nexus] Migrate event definition tests from HSM to CHASM#9597
[Nexus] Migrate event definition tests from HSM to CHASM#9597gow merged 14 commits intonexus/hsm-to-chasm-migrationfrom
Conversation
56ab33a to
4f251ef
Compare
28694e4 to
2d24633
Compare
f30fdd3 to
52e97cd
Compare
52e97cd to
447bbda
Compare
4f251ef to
8a4616e
Compare
8a4616e to
9c03b67
Compare
bergundy
left a comment
There was a problem hiding this comment.
This looks mostly good to me.
| key := strconv.FormatInt(scheduledEventID, 10) | ||
| field, ok := wf.Operations[key] | ||
| if !ok { | ||
| return nil, "", fmt.Errorf("nexus operation not found for scheduled event ID %d", scheduledEventID) |
There was a problem hiding this comment.
This should be a not found service error or something else that we can safely handle.
| scheduledEventID int64, | ||
| ) (*nexusoperation.Operation, string, error) { | ||
| key := strconv.FormatInt(scheduledEventID, 10) | ||
| field, ok := wf.Operations[key] |
There was a problem hiding this comment.
Operations should be a map of int64 to Operation, no need to do this formatting.
| attrs := event.GetNexusOperationScheduledEventAttributes() | ||
|
|
||
| scheduledTime := event.GetEventTime() | ||
| if scheduledTime == nil { |
There was a problem hiding this comment.
I don't think so. except maybe in some tests where we hand construct events. This check is not needed removed it.
| return chasmworkflow.ErrEventNotCherryPickable | ||
| } | ||
|
|
||
| // CancelRequestedEventDefinition |
There was a problem hiding this comment.
I like having docstrings on every exported member but this doesn't really do anything.
| } | ||
|
|
||
| cancellation, ok := op.Cancellation.TryGet(ctx) | ||
| if !ok { |
There was a problem hiding this comment.
I think this is never expected because how would a cancelation request be submitted without a cancelation state machine?
There was a problem hiding this comment.
I added this just defensively. But could this happen in the event of data corruption?
| } | ||
|
|
||
| if err := nexusoperation.TransitionStarted.Apply(op, ctx, nexusoperation.EventStarted{ | ||
| OperationToken: attrs.GetOperationToken(), |
There was a problem hiding this comment.
We're going to need to store the links here for standalone.
| return err | ||
| } | ||
|
|
||
| if err := nexusoperation.TransitionSucceeded.Apply(op, ctx, nexusoperation.EventSucceeded{}); err != nil { |
There was a problem hiding this comment.
We're going to need more information here for standalone but we can handle that later.
| } | ||
|
|
||
| // getOperation looks up a Nexus operation from the workflow by its scheduled event ID. | ||
| func getOperation( |
There was a problem hiding this comment.
You wouldn't need this function if we used a map of int64 to Operation as I've mentioned before to represent the operations in the workflow.
| } | ||
|
|
||
| func TestCancelRequestCompletedEventDefinitionApply(t *testing.T) { | ||
| t.Run("transitions cancellation to succeeded", func(t *testing.T) { |
There was a problem hiding this comment.
Do we need a separate subtest here?
There was a problem hiding this comment.
No. Removed it (here and in few other tests)
| nexusoperationpb.CANCELLATION_STATUS_BACKING_OFF, | ||
| func(c *Cancellation, ctx chasm.MutableContext, event EventCancellationAttemptFailed) error { | ||
| return serviceerror.NewUnimplemented("unimplemented") | ||
| // TODO: implement backing off logic similar to operation's transitionAttemptFailed |
There was a problem hiding this comment.
Was thinking of doing it along with cancellation executors.
Migrated it from HSM
447bbda to
3bd0557
Compare
d14344b to
18f14c3
Compare
3bd0557 to
66234d5
Compare
18f14c3 to
c0f4e55
Compare
## What changed? Migrating all the event definition's `Apply()` method from HSM to CHASM. Also migrated unit tests. ## Why? HSM to CHASM migration ## How did you test it? - [x] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes Nexus operation lifecycle handling by moving scheduling/cancellation and terminal event application into CHASM event definitions and adjusting state transition semantics; regressions could affect operation task emission, cancellation timing, and cleanup during replay/reset. > > **Overview** > Implements CHASM-based Nexus operation event `Apply()` handlers: scheduled/cancel-requested/started now create or update the in-memory operation component (including spawning/scheduling a cancellation child once an operation token exists), and terminal events (completed/failed/canceled/timed-out) transition the operation then remove it from the workflow. > > Refactors workflow Nexus operation storage to be keyed by `ScheduledEventId` (`int64`), simplifies command handlers to only emit history events (letting event definitions create/update components), and expands cancellation/operation state machines with concrete task emission and retry/backoff metadata. Updates `chasm.Transition.Apply` to run transition logic before mutating state (enabling source-state inspection) and adds new CHASM-focused unit tests for the migrated event definitions and updated transition behavior. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c0f4e55. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
## What changed? Migrating all the event definition's `Apply()` method from HSM to CHASM. Also migrated unit tests. ## Why? HSM to CHASM migration ## How did you test it? - [x] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes Nexus operation lifecycle handling by moving scheduling/cancellation and terminal event application into CHASM event definitions and adjusting state transition semantics; regressions could affect operation task emission, cancellation timing, and cleanup during replay/reset. > > **Overview** > Implements CHASM-based Nexus operation event `Apply()` handlers: scheduled/cancel-requested/started now create or update the in-memory operation component (including spawning/scheduling a cancellation child once an operation token exists), and terminal events (completed/failed/canceled/timed-out) transition the operation then remove it from the workflow. > > Refactors workflow Nexus operation storage to be keyed by `ScheduledEventId` (`int64`), simplifies command handlers to only emit history events (letting event definitions create/update components), and expands cancellation/operation state machines with concrete task emission and retry/backoff metadata. Updates `chasm.Transition.Apply` to run transition logic before mutating state (enabling source-state inspection) and adds new CHASM-focused unit tests for the migrated event definitions and updated transition behavior. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c0f4e55. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
## What changed? Migrating all the event definition's `Apply()` method from HSM to CHASM. Also migrated unit tests. ## Why? HSM to CHASM migration ## How did you test it? - [x] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes Nexus operation lifecycle handling by moving scheduling/cancellation and terminal event application into CHASM event definitions and adjusting state transition semantics; regressions could affect operation task emission, cancellation timing, and cleanup during replay/reset. > > **Overview** > Implements CHASM-based Nexus operation event `Apply()` handlers: scheduled/cancel-requested/started now create or update the in-memory operation component (including spawning/scheduling a cancellation child once an operation token exists), and terminal events (completed/failed/canceled/timed-out) transition the operation then remove it from the workflow. > > Refactors workflow Nexus operation storage to be keyed by `ScheduledEventId` (`int64`), simplifies command handlers to only emit history events (letting event definitions create/update components), and expands cancellation/operation state machines with concrete task emission and retry/backoff metadata. Updates `chasm.Transition.Apply` to run transition logic before mutating state (enabling source-state inspection) and adds new CHASM-focused unit tests for the migrated event definitions and updated transition behavior. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c0f4e55. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
## What changed? Migrating all the event definition's `Apply()` method from HSM to CHASM. Also migrated unit tests. ## Why? HSM to CHASM migration ## How did you test it? - [x] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes Nexus operation lifecycle handling by moving scheduling/cancellation and terminal event application into CHASM event definitions and adjusting state transition semantics; regressions could affect operation task emission, cancellation timing, and cleanup during replay/reset. > > **Overview** > Implements CHASM-based Nexus operation event `Apply()` handlers: scheduled/cancel-requested/started now create or update the in-memory operation component (including spawning/scheduling a cancellation child once an operation token exists), and terminal events (completed/failed/canceled/timed-out) transition the operation then remove it from the workflow. > > Refactors workflow Nexus operation storage to be keyed by `ScheduledEventId` (`int64`), simplifies command handlers to only emit history events (letting event definitions create/update components), and expands cancellation/operation state machines with concrete task emission and retry/backoff metadata. Updates `chasm.Transition.Apply` to run transition logic before mutating state (enabling source-state inspection) and adds new CHASM-focused unit tests for the migrated event definitions and updated transition behavior. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c0f4e55. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
## What changed? Migrating all the event definition's `Apply()` method from HSM to CHASM. Also migrated unit tests. ## Why? HSM to CHASM migration ## How did you test it? - [x] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes Nexus operation lifecycle handling by moving scheduling/cancellation and terminal event application into CHASM event definitions and adjusting state transition semantics; regressions could affect operation task emission, cancellation timing, and cleanup during replay/reset. > > **Overview** > Implements CHASM-based Nexus operation event `Apply()` handlers: scheduled/cancel-requested/started now create or update the in-memory operation component (including spawning/scheduling a cancellation child once an operation token exists), and terminal events (completed/failed/canceled/timed-out) transition the operation then remove it from the workflow. > > Refactors workflow Nexus operation storage to be keyed by `ScheduledEventId` (`int64`), simplifies command handlers to only emit history events (letting event definitions create/update components), and expands cancellation/operation state machines with concrete task emission and retry/backoff metadata. Updates `chasm.Transition.Apply` to run transition logic before mutating state (enabling source-state inspection) and adds new CHASM-focused unit tests for the migrated event definitions and updated transition behavior. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c0f4e55. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…9597) ## What changed? Migrating all the event definition's `Apply()` method from HSM to CHASM. Also migrated unit tests. ## Why? HSM to CHASM migration ## How did you test it? - [x] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes Nexus operation lifecycle handling by moving scheduling/cancellation and terminal event application into CHASM event definitions and adjusting state transition semantics; regressions could affect operation task emission, cancellation timing, and cleanup during replay/reset. > > **Overview** > Implements CHASM-based Nexus operation event `Apply()` handlers: scheduled/cancel-requested/started now create or update the in-memory operation component (including spawning/scheduling a cancellation child once an operation token exists), and terminal events (completed/failed/canceled/timed-out) transition the operation then remove it from the workflow. > > Refactors workflow Nexus operation storage to be keyed by `ScheduledEventId` (`int64`), simplifies command handlers to only emit history events (letting event definitions create/update components), and expands cancellation/operation state machines with concrete task emission and retry/backoff metadata. Updates `chasm.Transition.Apply` to run transition logic before mutating state (enabling source-state inspection) and adds new CHASM-focused unit tests for the migrated event definitions and updated transition behavior. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c0f4e55. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…9597) ## What changed? Migrating all the event definition's `Apply()` method from HSM to CHASM. Also migrated unit tests. ## Why? HSM to CHASM migration ## How did you test it? - [x] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes Nexus operation lifecycle handling by moving scheduling/cancellation and terminal event application into CHASM event definitions and adjusting state transition semantics; regressions could affect operation task emission, cancellation timing, and cleanup during replay/reset. > > **Overview** > Implements CHASM-based Nexus operation event `Apply()` handlers: scheduled/cancel-requested/started now create or update the in-memory operation component (including spawning/scheduling a cancellation child once an operation token exists), and terminal events (completed/failed/canceled/timed-out) transition the operation then remove it from the workflow. > > Refactors workflow Nexus operation storage to be keyed by `ScheduledEventId` (`int64`), simplifies command handlers to only emit history events (letting event definitions create/update components), and expands cancellation/operation state machines with concrete task emission and retry/backoff metadata. Updates `chasm.Transition.Apply` to run transition logic before mutating state (enabling source-state inspection) and adds new CHASM-focused unit tests for the migrated event definitions and updated transition behavior. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c0f4e55. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
## What changed? Migrating all the event definition's `Apply()` method from HSM to CHASM. Also migrated unit tests. ## Why? HSM to CHASM migration ## How did you test it? - [x] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes Nexus operation lifecycle handling by moving scheduling/cancellation and terminal event application into CHASM event definitions and adjusting state transition semantics; regressions could affect operation task emission, cancellation timing, and cleanup during replay/reset. > > **Overview** > Implements CHASM-based Nexus operation event `Apply()` handlers: scheduled/cancel-requested/started now create or update the in-memory operation component (including spawning/scheduling a cancellation child once an operation token exists), and terminal events (completed/failed/canceled/timed-out) transition the operation then remove it from the workflow. > > Refactors workflow Nexus operation storage to be keyed by `ScheduledEventId` (`int64`), simplifies command handlers to only emit history events (letting event definitions create/update components), and expands cancellation/operation state machines with concrete task emission and retry/backoff metadata. Updates `chasm.Transition.Apply` to run transition logic before mutating state (enabling source-state inspection) and adds new CHASM-focused unit tests for the migrated event definitions and updated transition behavior. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c0f4e55. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
## What changed? Migrating all the event definition's `Apply()` method from HSM to CHASM. Also migrated unit tests. ## Why? HSM to CHASM migration ## How did you test it? - [x] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes Nexus operation lifecycle handling by moving scheduling/cancellation and terminal event application into CHASM event definitions and adjusting state transition semantics; regressions could affect operation task emission, cancellation timing, and cleanup during replay/reset. > > **Overview** > Implements CHASM-based Nexus operation event `Apply()` handlers: scheduled/cancel-requested/started now create or update the in-memory operation component (including spawning/scheduling a cancellation child once an operation token exists), and terminal events (completed/failed/canceled/timed-out) transition the operation then remove it from the workflow. > > Refactors workflow Nexus operation storage to be keyed by `ScheduledEventId` (`int64`), simplifies command handlers to only emit history events (letting event definitions create/update components), and expands cancellation/operation state machines with concrete task emission and retry/backoff metadata. Updates `chasm.Transition.Apply` to run transition logic before mutating state (enabling source-state inspection) and adds new CHASM-focused unit tests for the migrated event definitions and updated transition behavior. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c0f4e55. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
## What changed? Migrating all the event definition's `Apply()` method from HSM to CHASM. Also migrated unit tests. ## Why? HSM to CHASM migration ## How did you test it? - [x] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes Nexus operation lifecycle handling by moving scheduling/cancellation and terminal event application into CHASM event definitions and adjusting state transition semantics; regressions could affect operation task emission, cancellation timing, and cleanup during replay/reset. > > **Overview** > Implements CHASM-based Nexus operation event `Apply()` handlers: scheduled/cancel-requested/started now create or update the in-memory operation component (including spawning/scheduling a cancellation child once an operation token exists), and terminal events (completed/failed/canceled/timed-out) transition the operation then remove it from the workflow. > > Refactors workflow Nexus operation storage to be keyed by `ScheduledEventId` (`int64`), simplifies command handlers to only emit history events (letting event definitions create/update components), and expands cancellation/operation state machines with concrete task emission and retry/backoff metadata. Updates `chasm.Transition.Apply` to run transition logic before mutating state (enabling source-state inspection) and adds new CHASM-focused unit tests for the migrated event definitions and updated transition behavior. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c0f4e55. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->

What changed?
Migrating all the event definition's
Apply()method from HSM to CHASM. Also migrated unit tests.Why?
HSM to CHASM migration
How did you test it?
Note
Medium Risk
Changes Nexus operation lifecycle handling by moving scheduling/cancellation and terminal event application into CHASM event definitions and adjusting state transition semantics; regressions could affect operation task emission, cancellation timing, and cleanup during replay/reset.
Overview
Implements CHASM-based Nexus operation event
Apply()handlers: scheduled/cancel-requested/started now create or update the in-memory operation component (including spawning/scheduling a cancellation child once an operation token exists), and terminal events (completed/failed/canceled/timed-out) transition the operation then remove it from the workflow.Refactors workflow Nexus operation storage to be keyed by
ScheduledEventId(int64), simplifies command handlers to only emit history events (letting event definitions create/update components), and expands cancellation/operation state machines with concrete task emission and retry/backoff metadata. Updateschasm.Transition.Applyto run transition logic before mutating state (enabling source-state inspection) and adds new CHASM-focused unit tests for the migrated event definitions and updated transition behavior.Written by Cursor Bugbot for commit c0f4e55. This will update automatically on new commits. Configure here.