-
Notifications
You must be signed in to change notification settings - Fork 8
fix(journey): map session-store status into the workflow loop vocabulary (EVO-1690) #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/modules/temporal/workflows/initial-workflow-status.util.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { resolveInitialWorkflowStatus } from './initial-workflow-status.util'; | ||
|
|
||
| describe('resolveInitialWorkflowStatus (EVO-1690 regression)', () => { | ||
| it("maps the session-store 'active' status into the loop's 'running'", () => { | ||
| expect(resolveInitialWorkflowStatus('active')).toBe('running'); | ||
| }); | ||
|
|
||
| it("maps 'waiting' into 'running' so signal-driven resumes re-enter the loop", () => { | ||
| expect(resolveInitialWorkflowStatus('waiting')).toBe('running'); | ||
| }); | ||
|
|
||
| it("restarts a 'completed' session as 'running' (pre-existing resume semantics)", () => { | ||
| expect(resolveInitialWorkflowStatus('completed')).toBe('running'); | ||
| }); | ||
|
|
||
| it("defaults to 'running' when the session has no status", () => { | ||
| expect(resolveInitialWorkflowStatus(undefined)).toBe('running'); | ||
| }); | ||
|
|
||
| it("preserves 'paused' — a paused session must not resume by itself", () => { | ||
| expect(resolveInitialWorkflowStatus('paused')).toBe('paused'); | ||
| }); | ||
| }); |
20 changes: 20 additions & 0 deletions
20
src/modules/temporal/workflows/initial-workflow-status.util.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| export type WorkflowExecutionStatus = | ||
| | 'running' | ||
| | 'completed' | ||
| | 'failed' | ||
| | 'paused'; | ||
|
|
||
| /** | ||
| * Maps a persisted journey-session status into the workflow loop's vocabulary | ||
| * (EVO-1690). The session store speaks 'active'/'waiting'/'completed'; the | ||
| * execution loop only advances on 'running' — copying the session status | ||
| * verbatim made `while (state.status === 'running')` false on the first | ||
| * iteration and every pre-created session (the norm since EVO-1644) completed | ||
| * with zero nodes executed. Only 'paused' survives the mapping: a paused | ||
| * session must not resume by itself. | ||
| */ | ||
| export function resolveInitialWorkflowStatus( | ||
| sessionStatus: string | undefined, | ||
| ): WorkflowExecutionStatus { | ||
| return sessionStatus === 'paused' ? 'paused' : 'running'; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Tighten the
sessionStatustype to known session-store statuses instead ofstring.string | undefinedmakes it easy for unsupported statuses to slip in unnoticed. If the session store exposes a finite set of statuses, model that as a string union type (e.g.'active' | 'waiting' | 'completed' | 'paused' | undefined) so TypeScript can enforce exhaustive handling when new statuses are introduced.Suggested implementation:
If there is already a shared type for the journey-session status (for example in a session-store module), you should reuse that instead of introducing
JourneySessionStoreStatushere, and import it into this file. Replace the localJourneySessionStoreStatusdefinition with an import and keep the parameter typed as that union plusundefined.