chore: user office experiment workflow#1391
Conversation
…elated methods and types
…g and introducing WorkflowStatus model
…lowStatusId instead of id
…ntroducing CreateWorkflowConnection mutation
…rget status lookups
…vents table and updating related references
…usActionsOnConnection
…lowStructure method
…onsistency in workflow management
…efactoring IsProposalSubmittedGuard
…andling and refactoring related methods
…error for missing proposal workflow
… GuardFn and refactoring related guards
…ent metadata handling
…tatusConnectionId and refactor related properties
…authorization checks for proposal assignments
…orkflow migration scripts
… for proposal status filtering
efafe12 to
0141550
Compare
|
I am still getting this error running the branch against our staging database |
TCMeldrum
left a comment
There was a problem hiding this comment.
Quite a large pr so have put my comments in for the backend will look through the rest later this week
Good point. I would like to look @ellen-wright. @ellen-wright We would like to bring the exp workflow along with proposal workflow. As I understand, stfc decided to move the proposal workflow up in the menu. So I wanted to check if you could help us with this. |
…andling in mutations
8aad9f1 to
046add4
Compare
…proved error logging
…of github.com:UserOfficeProject/user-office-core into SWAP-5222-user-office-experiment-workflow-improvement
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 74 out of 74 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (2)
apps/backend/src/eventHandlers/workflowEntities/proposal/statusActionEngine.ts:25
Proposaldoesn't haveworkflowIdorstatusIdfields (seeapps/backend/src/models/Proposal.ts), so grouping by['workflowId', 'statusId']collapses everything into one group (both keys areundefined). That can result in executing status actions using the first proposal’sworkflowStatusIdfor all proposals, even when they differ.
apps/backend/src/eventHandlers/workflowEntities/proposal/statusActionEngine.ts:33- Looking up a workflow connection only by
nextworkflow status id is ambiguous when multiple transitions lead into the same status (allowed by the schema; only(workflow_id, prev, next)is unique). In those cases this can fetch the wrong connection and run the wrong status actions. The status action engine should use the actualworkflow_status_connection_idfrom the workflow transition (or at minimum includeprevWorkflowStatusIdin the lookup).
| const [{ workflowStatusId }] = groupedExperimentSafeties; | ||
| const currentConnection = | ||
| await workflowDataSource.getWorkflowConnectionByNextStatusId( | ||
| workflowStatusId | ||
| ); |
| async getWorkflowConnectionByNextStatusId( | ||
| nextWorkflowStatusId: number | ||
| ): Promise<WorkflowConnection | null> { | ||
| const workflowConnections: WorkflowConnectionRecord[] = await database | ||
| .select('*') | ||
| .from('workflow_status_connections') | ||
| .where('next_workflow_status_id', nextWorkflowStatusId); | ||
|
|
||
| return workflowConnections.length > 0 | ||
| ? this.createWorkflowConnectionObject(workflowConnections[0]) | ||
| : null; |
TCMeldrum
left a comment
There was a problem hiding this comment.
Looked through the frontend/e2e, seemed fine to me.
…usCodes enum and improve variable naming for clarity


Description
This PR implements comprehensive workflow improvements for experiment safety management and integrates the new workflow data structures across the application. It includes support for manual status changes, enhanced workflow engine with guards, and updates to frontend components for better workflow status handling.
Motivation and Context
The experiment safety workflow needs to support more sophisticated status transitions and manual interventions similar to the proposal workflow. This requires integrating the new workflow data structures (from SWAP-4949) into the experiment safety module and implementing proper authorization checks, event handling, and UI components for managing experiment safety workflow statuses.
Related Issue: SWAP-5222
How Has This Been Tested
Changes
Backend Changes
Database Migrations:
0208_MigrateOldWorkflowsToNewDataStructures.sql- Migrates existing workflows to new data structures0211_ExperimentSafetyWorkflowStatusNotNull.sql- Makes experiment_safety.workflow_status_id non-nullable with AWAITING_ESF backfillWorkflow Engine & Guards:
src/workflowEngine/experiment.ts)Data Sources:
ExperimentDataSourceto support workflow status managementWorkflowDataSourcefor experiment safety workflowsEvent Handlers:
Authorization:
ExperimentSafetyAuthorizationfor workflow-based access controlMutations:
ChangeExperimentsSafetyStatusMutationfor manual status changesFrontend Changes
Experiment Safety Components:
ChangeExperimentSafetyStatus.tsx- New component for manual status changesExperimentSafety.tsx,ExperimentSafetyPage.tsx,ExperimentSafetyReview.tsx- Updated for new workflow status handlingExperimentSafetyNotification.tsx- Enhanced notifications for workflow changesWorkflow Management:
WorkflowEditor.tsx,WorkflowView.tsx- Enhanced workflow visualizationStatusEventsAndActionsDialog.tsx- Updated for workflow actionsworkflowUtils.ts- Utility functions for workflow status handlingUI Updates:
E2E Tests
Depends on
This PR builds upon the workflow overhaul from SWAP-4949. The new workflow data structures and state machine implementation are integrated into the experiment safety module.
Tests included/Docs Updated?