workflows

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxNameLength          = 255
	MaxDescriptionLength   = 1000
	MaxRoleNameLength      = 255
	MaxControlIDLength     = 255
	MaxControlSourceLength = 255
	MaxAssignedToIDLength  = 255
)

Field length constraints

View Source
const CronPrefix = "cron:"

CronPrefix is the prefix for custom cron expressions

Variables

View Source
var ErrInvalidStepExecutionStatusTransition = errors.New("invalid step execution status transition")
View Source
var ErrInvalidWorkflowExecutionStatusTransition = errors.New("invalid workflow execution status transition")
View Source
var ErrRoleAssignmentNotFound = errors.New("role assignment not found")
View Source
var ErrStepExecutionStatusTransitionConflict = errors.New("step execution status transition conflict")
View Source
var ErrWorkflowExecutionStatusTransitionConflict = errors.New("workflow execution status transition conflict")

Functions

func CombineErrors

func CombineErrors(errs ...error) error

CombineErrors combines multiple validation errors into a single error

func GetWorkflowEntities

func GetWorkflowEntities() []interface{}

GetWorkflowEntities returns all workflow entities for migration purposes

func GetWorkflowTables

func GetWorkflowTables() []string

GetWorkflowTables returns all workflow table names for migration purposes

func ValidateAssignmentType

func ValidateAssignmentType(assignmentType string) error

ValidateAssignmentType validates an assignment type

func ValidateCadence

func ValidateCadence(cadence string) error

ValidateCadence validates a cadence value

func ValidateEnum

func ValidateEnum(value string, validOptions []string, fieldName string, required bool) error

ValidateEnum checks if a value is in a list of valid options If required is true, empty values will return an error

func ValidateNotNil

func ValidateNotNil(entity interface{}, entityName string) error

ValidateNotNil checks if an entity is nil and returns an appropriate error

func ValidateRelationshipStrength

func ValidateRelationshipStrength(strength string) error

ValidateRelationshipStrength validates a control relationship strength

func ValidateRelationshipType

func ValidateRelationshipType(relationshipType string) error

ValidateRelationshipType validates a control relationship type

func ValidateStepExecution

func ValidateStepExecution(stepExecution *StepExecution) error

ValidateStepExecution validates a step execution

func ValidateStepExecutionStatus

func ValidateStepExecutionStatus(status string) error

ValidateStepExecutionStatus validates a step execution status

func ValidateStringLength

func ValidateStringLength(value, fieldName string, maxLength int) error

ValidateStringLength checks if a string exceeds the maximum length

func ValidateStringRequired

func ValidateStringRequired(value, fieldName string) error

ValidateStringRequired checks if a required string field is empty

func ValidateTriggerType

func ValidateTriggerType(triggerType string) error

ValidateTriggerType validates a trigger type

func ValidateUUIDRequired

func ValidateUUIDRequired(id *uuid.UUID, fieldName string) error

ValidateUUIDRequired checks if a UUID pointer is nil

func ValidateWorkflowExecutionStatus

func ValidateWorkflowExecutionStatus(status string) error

ValidateWorkflowExecutionStatus validates a workflow execution status

Types

type AssignmentType

type AssignmentType string

AssignmentType represents the type of assignment for role assignments and step executions

const (
	AssignmentTypeUser  AssignmentType = "user"
	AssignmentTypeGroup AssignmentType = "group"
	AssignmentTypeEmail AssignmentType = "email"
)

Valid assignment types

func (AssignmentType) IsValid

func (a AssignmentType) IsValid() bool

IsValid checks if the assignment type is valid

func (AssignmentType) String

func (a AssignmentType) String() string

String returns the string representation

type BaseService

type BaseService struct {
	// contains filtered or unexported fields
}

BaseService provides common CRUD operations for workflow entities

func NewBaseService

func NewBaseService(db *gorm.DB) *BaseService

NewBaseService creates a new BaseService

func (*BaseService) ActivateEntity

func (s *BaseService) ActivateEntity(entity interface{}, id *uuid.UUID) error

ActivateEntity sets is_active to true

func (*BaseService) BulkCreate

func (s *BaseService) BulkCreate(entities interface{}, validateFn func(int) error) error

BulkCreate creates multiple entities with validation

func (*BaseService) CheckEntityExists

func (s *BaseService) CheckEntityExists(entity interface{}, id *uuid.UUID, entityName string) error

CheckEntityExists checks if an entity exists by ID and returns appropriate error

func (*BaseService) CountWhere

func (s *BaseService) CountWhere(model interface{}, condition string, args ...interface{}) (int64, error)

CountWhere counts records matching a condition

func (*BaseService) DeactivateEntity

func (s *BaseService) DeactivateEntity(entity interface{}, id *uuid.UUID) error

DeactivateEntity sets is_active to false

func (*BaseService) DeleteEntity

func (s *BaseService) DeleteEntity(entity interface{}, id *uuid.UUID, entityName string) error

DeleteEntity performs a soft delete and validates the operation

func (*BaseService) ExistsWhere

func (s *BaseService) ExistsWhere(model interface{}, condition string, args ...interface{}) (bool, error)

ExistsWhere checks if any record exists matching a condition

func (*BaseService) GetByIDWithPreload

func (s *BaseService) GetByIDWithPreload(entity interface{}, id *uuid.UUID, entityName string, preloads ...string) error

GetByIDWithPreload retrieves an entity by ID with preloading

func (*BaseService) GetByIDWithPreloadAndContext

func (s *BaseService) GetByIDWithPreloadAndContext(ctx context.Context, entity interface{}, id *uuid.UUID, entityName string, preloads ...string) error

GetByIDWithPreloadAndContext retrieves an entity by ID with preloading and context

func (*BaseService) HandleRecordNotFoundError

func (s *BaseService) HandleRecordNotFoundError(err error, id *uuid.UUID, entityName string) error

HandleRecordNotFoundError wraps GORM record not found errors with entity-specific messages

func (*BaseService) UpdateEntity

func (s *BaseService) UpdateEntity(existing interface{}, updates interface{}, id *uuid.UUID, entityName string) error

UpdateEntity performs an update with existence check

func (*BaseService) UpdateStatus

func (s *BaseService) UpdateStatus(entity interface{}, id *uuid.UUID, status string, statusField string, timestampUpdates map[string]interface{}) error

UpdateStatus updates a status field with timestamp management

func (*BaseService) ValidateAndCreate

func (s *BaseService) ValidateAndCreate(entity interface{}, entityName string, customValidate func() error) error

ValidateAndCreate validates an entity is not nil, runs custom validation if provided, then creates it

func (*BaseService) ValidateAndUpdate

func (s *BaseService) ValidateAndUpdate(existing interface{}, updates interface{}, id *uuid.UUID, entityName string, customValidate func() error) error

ValidateAndUpdate validates updates are not nil, runs custom validation if provided, then updates the entity

func (*BaseService) ValidateEntityNotNil

func (s *BaseService) ValidateEntityNotNil(entity interface{}, entityName string) error

ValidateEntityNotNil checks if an entity is nil and returns an appropriate error

func (*BaseService) ValidateUpdatesNotNil

func (s *BaseService) ValidateUpdatesNotNil(updates interface{}) error

ValidateUpdatesNotNil checks if updates parameter is nil

type CadenceType

type CadenceType string

CadenceType represents a workflow scheduling cadence

const (
	CadenceDaily     CadenceType = "daily"
	CadenceWeekly    CadenceType = "weekly"
	CadenceMonthly   CadenceType = "monthly"
	CadenceQuarterly CadenceType = "quarterly"
	CadenceAnnually  CadenceType = "annually"
)

Valid cadence values for workflow scheduling

func (CadenceType) CronExpression

func (c CadenceType) CronExpression() string

CronExpression extracts the cron expression from a cron cadence Returns empty string if not a cron cadence

func (CadenceType) IsCron

func (c CadenceType) IsCron() bool

IsCron checks if the cadence is a custom cron expression

func (CadenceType) IsValid

func (c CadenceType) IsValid() bool

IsValid checks if the cadence type is valid

func (CadenceType) String

func (c CadenceType) String() string

String returns the string representation

func (CadenceType) ValidateCronExpression

func (c CadenceType) ValidateCronExpression() error

ValidateCronExpression parses and validates the cron expression. Returns nil if valid, or an error describing the parsing failure. NOTE: This parser expects a 6-field cron expression including seconds:

second minute hour day-of-month month day-of-week

For example, "0 0 9 * * *" means "daily at 9 AM". This differs from the standard 5-field Unix cron format (minute hour day-of-month month day-of-week).

type ControlRelationship

type ControlRelationship struct {
	relational.UUIDModel
	CreatedAt time.Time      `json:"created-at"`
	UpdatedAt time.Time      `json:"updated-at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`

	// Control Information
	ControlID     string `gorm:"not null;size:255;index;index:idx_control_rel_workflow_control,priority:2" json:"control_id"` // e.g., "AC-2", "A.9.2.5"
	ControlSource string `gorm:"not null;size:255" json:"control_source"`                                                     // e.g., "NIST 800-53 Rev 5", "ISO 27001"
	CatalogID     string `gorm:"size:255;index" json:"catalog_id"`                                                            // Link to catalog if available

	// Relationship Information
	RelationshipType string `gorm:"size:50" json:"relationship_type"` // satisfies, partially_satisfies, supports
	Strength         string `gorm:"size:20" json:"strength"`          // primary, secondary, supporting
	IsActive         bool   `gorm:"default:true" json:"is_active"`

	// Foreign Keys
	WorkflowDefinitionID *uuid.UUID `gorm:"not null;index;index:idx_control_rel_workflow_control,priority:1" json:"workflow_definition_id"`

	// Relationships
	WorkflowDefinition *WorkflowDefinition `gorm:"foreignKey:WorkflowDefinitionID" json:"workflow_definition,omitempty"`
}

ControlRelationship represents the mapping between workflow definitions and compliance controls Replaces the original ControlMapping to better reflect the relationship nature

func (ControlRelationship) TableName

func (ControlRelationship) TableName() string

TableName specifies the table name for ControlRelationship

type ControlRelationshipService

type ControlRelationshipService struct {
	// contains filtered or unexported fields
}

ControlRelationshipService provides CRUD operations for ControlRelationship

func NewControlRelationshipService

func NewControlRelationshipService(db *gorm.DB) *ControlRelationshipService

NewControlRelationshipService creates a new ControlRelationshipService

func (*ControlRelationshipService) Activate

func (s *ControlRelationshipService) Activate(id *uuid.UUID) error

Activate activates a control relationship

func (*ControlRelationshipService) BulkCreate

func (s *ControlRelationshipService) BulkCreate(relationships []ControlRelationship) error

BulkCreate creates multiple control relationships at once

func (*ControlRelationshipService) CountControlsBySource

func (s *ControlRelationshipService) CountControlsBySource(workflowDefID *uuid.UUID) (map[string]int64, error)

CountControlsBySource counts control relationships grouped by control source

func (*ControlRelationshipService) Create

func (s *ControlRelationshipService) Create(relationship *ControlRelationship) error

Create creates a new control relationship

func (*ControlRelationshipService) Deactivate

func (s *ControlRelationshipService) Deactivate(id *uuid.UUID) error

Deactivate deactivates a control relationship

func (*ControlRelationshipService) Delete

func (s *ControlRelationshipService) Delete(id *uuid.UUID) error

Delete soft deletes a control relationship

func (*ControlRelationshipService) FindByControlAndSource

func (s *ControlRelationshipService) FindByControlAndSource(workflowDefID *uuid.UUID, controlID, controlSource string) (*ControlRelationship, error)

FindByControlAndSource finds a control relationship by control ID and source

func (*ControlRelationshipService) GetActiveRelationships

func (s *ControlRelationshipService) GetActiveRelationships(workflowDefID *uuid.UUID) ([]ControlRelationship, error)

GetActiveRelationships retrieves all active control relationships for a workflow definition

func (*ControlRelationshipService) GetByControlID

func (s *ControlRelationshipService) GetByControlID(controlID string) ([]ControlRelationship, error)

GetByControlID retrieves all control relationships for a specific control

func (*ControlRelationshipService) GetByControlSource

func (s *ControlRelationshipService) GetByControlSource(controlSource string) ([]ControlRelationship, error)

GetByControlSource retrieves all control relationships for a specific control source

func (*ControlRelationshipService) GetByID

GetByID retrieves a control relationship by ID

func (*ControlRelationshipService) GetByWorkflowDefinitionID

func (s *ControlRelationshipService) GetByWorkflowDefinitionID(workflowDefID *uuid.UUID) ([]ControlRelationship, error)

GetByWorkflowDefinitionID retrieves all control relationships for a workflow definition

func (*ControlRelationshipService) GetPrimaryControls

func (s *ControlRelationshipService) GetPrimaryControls(workflowDefID *uuid.UUID) ([]ControlRelationship, error)

GetPrimaryControls retrieves all primary control relationships for a workflow definition

func (*ControlRelationshipService) Update

Update updates an existing control relationship

func (*ControlRelationshipService) ValidateRelationship

func (s *ControlRelationshipService) ValidateRelationship(relationship *ControlRelationship) error

ValidateRelationship validates a control relationship

type EvidenceRequirement

type EvidenceRequirement struct {
	Type        string `json:"type"`
	Description string `json:"description"`
	Required    bool   `json:"required"`
}

type MyAssignmentsFilter

type MyAssignmentsFilter struct {
	Status               string     // Filter by step execution status
	DueBefore            *time.Time // Filter by due date before
	DueAfter             *time.Time // Filter by due date after
	WorkflowDefinitionID *uuid.UUID // Filter by workflow definition ID
}

MyAssignmentsFilter contains filter options for GetMyAssignments

type RelationshipStrength

type RelationshipStrength string

RelationshipStrength represents the strength of a control relationship

const (
	StrengthPrimary    RelationshipStrength = "primary"
	StrengthSecondary  RelationshipStrength = "secondary"
	StrengthSupporting RelationshipStrength = "supporting"
)

Valid control relationship strengths

func (RelationshipStrength) IsValid

func (r RelationshipStrength) IsValid() bool

IsValid checks if the relationship strength is valid

func (RelationshipStrength) String

func (r RelationshipStrength) String() string

String returns the string representation

type RelationshipType

type RelationshipType string

RelationshipType represents the type of control relationship

const (
	RelationshipSatisfies          RelationshipType = "satisfies"
	RelationshipPartiallySatisfies RelationshipType = "partially_satisfies"
	RelationshipSupports           RelationshipType = "supports"
)

Valid control relationship types

func (RelationshipType) IsValid

func (r RelationshipType) IsValid() bool

IsValid checks if the relationship type is valid

func (RelationshipType) String

func (r RelationshipType) String() string

String returns the string representation

type RoleAssignment

type RoleAssignment struct {
	relational.UUIDModel
	WorkflowInstanceID *uuid.UUID `gorm:"not null;index" json:"workflow_instance_id"`
	RoleName           string     `gorm:"not null;size:255" json:"role_name"`
	AssignedToType     string     `gorm:"size:20" json:"assigned_to_type"` // user, group, email
	AssignedToID       string     `gorm:"size:255" json:"assigned_to_id"`  // User ID, group ID, or email
	IsActive           bool       `gorm:"default:true" json:"is_active"`

	// Relationships
	WorkflowInstance *WorkflowInstance `gorm:"foreignKey:WorkflowInstanceID" json:"workflow_instance,omitempty"`
}

RoleAssignment represents the assignment of roles to specific users or groups for a workflow instance

func (RoleAssignment) TableName

func (RoleAssignment) TableName() string

TableName specifies the table name for RoleAssignment

type RoleAssignmentService

type RoleAssignmentService struct {
	// contains filtered or unexported fields
}

RoleAssignmentService provides CRUD operations for RoleAssignment

func NewRoleAssignmentService

func NewRoleAssignmentService(db *gorm.DB) *RoleAssignmentService

NewRoleAssignmentService creates a new RoleAssignmentService

func (*RoleAssignmentService) Activate

func (s *RoleAssignmentService) Activate(id *uuid.UUID) error

Activate activates a role assignment

func (*RoleAssignmentService) BulkCreate

func (s *RoleAssignmentService) BulkCreate(assignments []RoleAssignment) error

BulkCreate creates multiple role assignments at once

func (*RoleAssignmentService) Create

func (s *RoleAssignmentService) Create(assignment *RoleAssignment) error

Create creates a new role assignment

func (*RoleAssignmentService) Deactivate

func (s *RoleAssignmentService) Deactivate(id *uuid.UUID) error

Deactivate deactivates a role assignment

func (*RoleAssignmentService) Delete

func (s *RoleAssignmentService) Delete(id *uuid.UUID) error

Delete deletes a role assignment

func (*RoleAssignmentService) FindAssigneeForRole

func (s *RoleAssignmentService) FindAssigneeForRole(instanceID *uuid.UUID, roleName string) (*RoleAssignment, error)

FindAssigneeForRole finds the assignee for a specific role in a workflow instance

func (*RoleAssignmentService) GetActiveAssignments

func (s *RoleAssignmentService) GetActiveAssignments(instanceID *uuid.UUID) ([]RoleAssignment, error)

GetActiveAssignments retrieves all active role assignments for a workflow instance

func (*RoleAssignmentService) GetByAssignee

func (s *RoleAssignmentService) GetByAssignee(assignedToType, assignedToID string) ([]RoleAssignment, error)

GetByAssignee retrieves all role assignments for a specific assignee

func (*RoleAssignmentService) GetByID

func (s *RoleAssignmentService) GetByID(id *uuid.UUID) (*RoleAssignment, error)

GetByID retrieves a role assignment by ID

func (*RoleAssignmentService) GetByRole

func (s *RoleAssignmentService) GetByRole(instanceID *uuid.UUID, roleName string) ([]RoleAssignment, error)

GetByRole retrieves all role assignments for a specific role

func (*RoleAssignmentService) GetByWorkflowInstanceID

func (s *RoleAssignmentService) GetByWorkflowInstanceID(instanceID *uuid.UUID) ([]RoleAssignment, error)

GetByWorkflowInstanceID retrieves all role assignments for a workflow instance

func (*RoleAssignmentService) ReassignRole

func (s *RoleAssignmentService) ReassignRole(id *uuid.UUID, newAssignedToType, newAssignedToID string) error

ReassignRole reassigns a role to a different assignee

func (*RoleAssignmentService) Update

func (s *RoleAssignmentService) Update(id *uuid.UUID, updates *RoleAssignment) error

Update updates an existing role assignment

func (*RoleAssignmentService) ValidateAssignment

func (s *RoleAssignmentService) ValidateAssignment(assignment *RoleAssignment) error

ValidateAssignment validates a role assignment

type StepDependency

type StepDependency struct {
	relational.UUIDModel
	WorkflowStepDefinitionID *uuid.UUID `gorm:"not null;index" json:"workflow_step_definition_id"`
	DependsOnStepID          *uuid.UUID `gorm:"not null;index" json:"depends_on_step_id"`

	// Relationships
	WorkflowStepDefinition *WorkflowStepDefinition `gorm:"foreignKey:WorkflowStepDefinitionID" json:"workflow_step_definition,omitempty"`
	DependsOnStep          *WorkflowStepDefinition `gorm:"foreignKey:DependsOnStepID" json:"depends_on_step,omitempty"`
}

StepDependency represents the dependency relationship between workflow steps

func (StepDependency) TableName

func (StepDependency) TableName() string

TableName specifies the table name for StepDependency

type StepEvidence

type StepEvidence struct {
	relational.UUIDModel
	CreatedAt time.Time      `json:"created-at"`
	UpdatedAt time.Time      `json:"updated-at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`

	// Evidence Information
	Name         string `gorm:"not null;size:255" json:"name"`
	Description  string `gorm:"type:text" json:"description"`
	EvidenceType string `gorm:"size:50" json:"evidence_type"` // document, attestation, screenshot, log
	FilePath     string `gorm:"size:500" json:"file_path"`    // Path to stored file
	FileSize     int64  `json:"file-size"`                    // File size in bytes
	FileHash     string `gorm:"size:64" json:"file_hash"`     // SHA-256 hash of file
	Metadata     string `gorm:"type:text" json:"metadata"`    // JSON metadata

	// Foreign Keys
	StepExecutionID *uuid.UUID `gorm:"not null;index" json:"step_execution_id"`
	EvidenceID      *uuid.UUID `gorm:"index" json:"evidence_id,omitempty"` // Link to main evidence table

	// Relationships
	StepExecution *StepExecution       `gorm:"foreignKey:StepExecutionID" json:"step_execution,omitempty"`
	Evidence      *relational.Evidence `gorm:"foreignKey:EvidenceID" json:"evidence,omitempty"`
}

StepEvidence represents evidence submitted for a specific step execution

func (StepEvidence) TableName

func (StepEvidence) TableName() string

TableName specifies the table name for StepEvidence

type StepEvidenceCreator

type StepEvidenceCreator interface {
	AddStepStartedEvidence(ctx context.Context, stepExecutionID *uuid.UUID) error
}

StepEvidenceCreator interface to avoid import cycle

type StepExecution

type StepExecution struct {
	relational.UUIDModel
	CreatedAt time.Time      `json:"created-at"`
	UpdatedAt time.Time      `json:"updated-at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`

	// Execution Information
	Status        string     `gorm:"size:50;index:idx_step_exec_workflow_status,priority:2;index:idx_step_exec_step_status,priority:2" json:"status"` // pending, blocked, in_progress, completed, failed, skipped
	StartedAt     *time.Time `json:"started-at,omitempty"`
	OverdueAt     *time.Time `json:"overdue-at,omitempty"`
	DueDate       *time.Time `gorm:"index" json:"due_date,omitempty"`
	CompletedAt   *time.Time `json:"completed-at,omitempty"`
	FailedAt      *time.Time `json:"failed-at,omitempty"`
	FailureReason string     `gorm:"type:text" json:"failure_reason,omitempty"`

	// Assignment Information
	AssignedToType string     `gorm:"size:20" json:"assigned_to_type"` // user, group, email
	AssignedToID   string     `gorm:"size:255" json:"assigned_to_id"`  // User ID, group ID, or email
	AssignedAt     *time.Time `json:"assigned-at,omitempty"`

	// Foreign Keys
	WorkflowExecutionID      *uuid.UUID `` /* 149-byte string literal not displayed */
	WorkflowStepDefinitionID *uuid.UUID `` /* 151-byte string literal not displayed */

	// Relationships
	WorkflowExecution      *WorkflowExecution        `gorm:"foreignKey:WorkflowExecutionID" json:"workflow_execution,omitempty"`
	WorkflowStepDefinition *WorkflowStepDefinition   `gorm:"foreignKey:WorkflowStepDefinitionID" json:"workflow_step_definition,omitempty"`
	StepEvidence           []StepEvidence            `gorm:"foreignKey:StepExecutionID;constraint:OnDelete:CASCADE" json:"step_evidence,omitempty"`
	ReassignmentHistory    []StepReassignmentHistory `gorm:"foreignKey:StepExecutionID;constraint:OnDelete:CASCADE" json:"reassignment_history,omitempty"`
}

StepExecution represents the execution of a specific step within a workflow execution

func (StepExecution) TableName

func (StepExecution) TableName() string

TableName specifies the table name for StepExecution

type StepExecutionService

type StepExecutionService struct {
	// contains filtered or unexported fields
}

StepExecutionService provides CRUD operations for StepExecution

func NewStepExecutionService

func NewStepExecutionService(db *gorm.DB, evidenceCreator StepEvidenceCreator) *StepExecutionService

NewStepExecutionService creates a new StepExecutionService

func (*StepExecutionService) AssignTo

func (s *StepExecutionService) AssignTo(id *uuid.UUID, assignedToType, assignedToID string) error

AssignTo assigns a step execution to a user or group

func (*StepExecutionService) Block

func (s *StepExecutionService) Block(id *uuid.UUID) error

Block marks a step execution as blocked

func (*StepExecutionService) BulkFailWithTx

func (s *StepExecutionService) BulkFailWithTx(tx *gorm.DB, executionID *uuid.UUID, reason string, failedAt time.Time) error

BulkFailWithTx marks all non-terminal steps in an execution as failed using the provided transaction. If tx is nil, it falls back to the service DB handle.

func (*StepExecutionService) CanUnblock

func (s *StepExecutionService) CanUnblock(id *uuid.UUID) (bool, error)

CanUnblock checks if a step execution can be unblocked based on its dependencies

func (*StepExecutionService) Complete

func (s *StepExecutionService) Complete(id *uuid.UUID) error

Complete marks a step execution as completed

func (*StepExecutionService) Create

func (s *StepExecutionService) Create(stepExecution *StepExecution) error

Create creates a new step execution

func (*StepExecutionService) Fail

func (s *StepExecutionService) Fail(id *uuid.UUID, reason string) error

Fail marks a step execution as failed

func (*StepExecutionService) GetAssignedSteps

func (s *StepExecutionService) GetAssignedSteps(assignedToType, assignedToID string) ([]StepExecution, error)

GetAssignedSteps retrieves all step executions assigned to a specific user/group

func (*StepExecutionService) GetBlockedSteps

func (s *StepExecutionService) GetBlockedSteps(executionID *uuid.UUID) ([]StepExecution, error)

GetBlockedSteps retrieves all blocked step executions for a workflow execution

func (*StepExecutionService) GetByID

func (s *StepExecutionService) GetByID(id *uuid.UUID) (*StepExecution, error)

GetByID retrieves a step execution by ID

func (*StepExecutionService) GetByWorkflowExecutionID

func (s *StepExecutionService) GetByWorkflowExecutionID(executionID *uuid.UUID) ([]StepExecution, error)

GetByWorkflowExecutionID retrieves all step executions for a workflow execution ordered by step definition order

func (*StepExecutionService) GetCompletedSteps

func (s *StepExecutionService) GetCompletedSteps(executionID *uuid.UUID) ([]StepExecution, error)

GetCompletedSteps retrieves all completed step executions for a workflow execution

func (*StepExecutionService) GetMyAssignments

func (s *StepExecutionService) GetMyAssignments(userID, userEmail string, filter MyAssignmentsFilter, limit, offset int) ([]StepExecution, int64, error)

GetMyAssignments retrieves step executions assigned to a user with filters and pagination It queries by both user ID (for type "user") and email (for type "email")

func (*StepExecutionService) GetPendingSteps

func (s *StepExecutionService) GetPendingSteps(executionID *uuid.UUID) ([]StepExecution, error)

GetPendingSteps retrieves all pending step executions for a workflow execution

func (*StepExecutionService) GetUnblockableSteps

func (s *StepExecutionService) GetUnblockableSteps(executionID *uuid.UUID) ([]StepExecution, error)

GetUnblockableSteps retrieves all step executions that can be unblocked

func (*StepExecutionService) ReassignWithTx

func (s *StepExecutionService) ReassignWithTx(tx *gorm.DB, id *uuid.UUID, assignedToType, assignedToID string, assignedAt time.Time) error

ReassignWithTx updates step assignment fields using the provided transaction. If tx is nil, it falls back to the service DB handle.

func (*StepExecutionService) SetEvidenceCreator

func (s *StepExecutionService) SetEvidenceCreator(creator StepEvidenceCreator)

SetEvidenceCreator sets the evidence creator (to avoid circular dependency)

func (*StepExecutionService) SetLogger

func (s *StepExecutionService) SetLogger(logger *zap.SugaredLogger)

SetLogger sets the logger for the service

func (*StepExecutionService) Start

func (s *StepExecutionService) Start(id *uuid.UUID) error

Start marks a step execution as started

func (*StepExecutionService) Unblock

func (s *StepExecutionService) Unblock(id *uuid.UUID) error

Unblock marks a step execution as unblocked (pending)

func (*StepExecutionService) Update

func (s *StepExecutionService) Update(id *uuid.UUID, updates *StepExecution) error

Update updates an existing step execution

func (*StepExecutionService) UpdateStatus

func (s *StepExecutionService) UpdateStatus(ctx context.Context, id *uuid.UUID, status string) error

UpdateStatus updates the status of a step execution

type StepExecutionStatus

type StepExecutionStatus string

StepExecutionStatus represents the status of a step execution Note: This type is mirrored by workflow.StepStatus in the orchestration layer. Both types must be kept in sync. The string values are identical to ensure compatibility.

const (
	StepStatusPending    StepExecutionStatus = "pending"
	StepStatusBlocked    StepExecutionStatus = "blocked"
	StepStatusInProgress StepExecutionStatus = "in_progress"
	StepStatusOverdue    StepExecutionStatus = "overdue"
	StepStatusCompleted  StepExecutionStatus = "completed"
	StepStatusFailed     StepExecutionStatus = "failed"
	StepStatusSkipped    StepExecutionStatus = "skipped"
)

Valid step execution statuses These values match workflow.StepStatus constants

func (StepExecutionStatus) IsValid

func (s StepExecutionStatus) IsValid() bool

IsValid checks if the step execution status is valid

func (StepExecutionStatus) String

func (s StepExecutionStatus) String() string

String returns the string representation

type StepReassignmentHistory

type StepReassignmentHistory struct {
	relational.UUIDModel
	CreatedAt time.Time      `json:"created-at"`
	UpdatedAt time.Time      `json:"updated-at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`

	StepExecutionID     *uuid.UUID `gorm:"not null;index" json:"step_execution_id"`
	WorkflowExecutionID *uuid.UUID `gorm:"not null;index" json:"workflow_execution_id"`

	PreviousAssignedToType string `gorm:"size:20" json:"previous_assigned_to_type"`
	PreviousAssignedToID   string `gorm:"size:255" json:"previous_assigned_to_id"`
	NewAssignedToType      string `gorm:"size:20" json:"new_assigned_to_type"`
	NewAssignedToID        string `gorm:"size:255" json:"new_assigned_to_id"`

	Reason             string     `gorm:"type:text" json:"reason,omitempty"`
	ReassignedByUserID *uuid.UUID `gorm:"index" json:"reassigned_by_user_id,omitempty"`
	ReassignedByEmail  string     `gorm:"size:255" json:"reassigned_by_email,omitempty"`

	StepExecution *StepExecution `gorm:"foreignKey:StepExecutionID" json:"step_execution,omitempty"`
}

StepReassignmentHistory tracks reassignment events for step executions.

func (StepReassignmentHistory) TableName

func (StepReassignmentHistory) TableName() string

type StepTrigger

type StepTrigger struct {
	relational.UUIDModel
	WorkflowStepDefinitionID *uuid.UUID `gorm:"not null;index" json:"workflow_step_definition_id"`
	TriggerType              string     `gorm:"size:50" json:"trigger_type"`        // evidence_stream, time_based, external_event
	TriggerCondition         string     `gorm:"type:text" json:"trigger_condition"` // JSON condition expression
	IsActive                 bool       `gorm:"default:false" json:"is_active"`

	// Relationships
	WorkflowStepDefinition *WorkflowStepDefinition `gorm:"foreignKey:WorkflowStepDefinitionID" json:"workflow_step_definition,omitempty"`
}

StepTrigger represents automatic step transition conditions (for future Phase 5)

func (StepTrigger) TableName

func (StepTrigger) TableName() string

TableName specifies the table name for StepTrigger

type TriggerType

type TriggerType string

TriggerType represents the type of trigger for workflow execution

const (
	TriggerManual    TriggerType = "manual"
	TriggerScheduled TriggerType = "scheduled"
	TriggerAutomatic TriggerType = "automatic"
)

Valid trigger types

func (TriggerType) IsValid

func (t TriggerType) IsValid() bool

IsValid checks if the trigger type is valid

func (TriggerType) String

func (t TriggerType) String() string

String returns the string representation

type WorkflowDefinition

type WorkflowDefinition struct {
	relational.UUIDModel
	CreatedAt time.Time      `json:"created-at"`
	UpdatedAt time.Time      `json:"updated-at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`

	// Basic Information
	Name        string `gorm:"not null;size:255" json:"name"`
	Description string `gorm:"type:text" json:"description"`
	Version     string `gorm:"size:50" json:"version"`

	// Workflow Configuration
	SuggestedCadence string `gorm:"size:50" json:"suggested_cadence"`   // daily, weekly, monthly, quarterly, annually
	EvidenceRequired string `gorm:"type:text" json:"evidence_required"` // JSON array of required evidence types
	GracePeriodDays  *int   `json:"grace-period-days,omitempty"`        // Override global default if set

	// Audit Fields
	CreatedByID *uuid.UUID `gorm:"index" json:"created_by_id,omitempty"`
	UpdatedByID *uuid.UUID `gorm:"index" json:"updated_by_id,omitempty"`

	// Relationships
	Steps                []WorkflowStepDefinition `gorm:"foreignKey:WorkflowDefinitionID;constraint:OnDelete:CASCADE" json:"steps,omitempty"`
	ControlRelationships []ControlRelationship    `gorm:"foreignKey:WorkflowDefinitionID;constraint:OnDelete:CASCADE" json:"control_relationships,omitempty"`
	Instances            []WorkflowInstance       `gorm:"foreignKey:WorkflowDefinitionID;constraint:OnDelete:CASCADE" json:"instances,omitempty"`
}

WorkflowDefinition represents a template for recurring compliance activities Created centrally by Compliance teams and maps to multiple controls across catalogs

func (*WorkflowDefinition) BeforeCreate

func (w *WorkflowDefinition) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook to set default values

func (WorkflowDefinition) TableName

func (WorkflowDefinition) TableName() string

TableName specifies the table name for WorkflowDefinition

type WorkflowDefinitionService

type WorkflowDefinitionService struct {
	// contains filtered or unexported fields
}

WorkflowDefinitionService provides CRUD operations for WorkflowDefinition

func NewWorkflowDefinitionService

func NewWorkflowDefinitionService(db *gorm.DB) *WorkflowDefinitionService

NewWorkflowDefinitionService creates a new WorkflowDefinitionService

func (*WorkflowDefinitionService) CountInstances

func (s *WorkflowDefinitionService) CountInstances(id *uuid.UUID) (int64, error)

CountInstances counts the number of instances for a workflow definition

func (*WorkflowDefinitionService) Create

func (s *WorkflowDefinitionService) Create(definition *WorkflowDefinition) error

Create creates a new workflow definition

func (*WorkflowDefinitionService) Delete

func (s *WorkflowDefinitionService) Delete(id *uuid.UUID) error

Delete soft deletes a workflow definition

func (*WorkflowDefinitionService) FindByName

func (s *WorkflowDefinitionService) FindByName(name string) ([]WorkflowDefinition, error)

FindByName finds workflow definitions by name (partial match)

func (*WorkflowDefinitionService) GetAll

func (s *WorkflowDefinitionService) GetAll(limit, offset int) ([]WorkflowDefinition, int64, error)

GetAll retrieves all workflow definitions with optional filters

func (*WorkflowDefinitionService) GetByID

GetByID retrieves a workflow definition by ID

func (*WorkflowDefinitionService) GetWithInstances

func (s *WorkflowDefinitionService) GetWithInstances(id *uuid.UUID) (*WorkflowDefinition, error)

GetWithInstances retrieves a workflow definition with all its instances

func (*WorkflowDefinitionService) Update

func (s *WorkflowDefinitionService) Update(id *uuid.UUID, updates *WorkflowDefinition) error

Update updates an existing workflow definition

func (*WorkflowDefinitionService) ValidateDefinition

func (s *WorkflowDefinitionService) ValidateDefinition(definition *WorkflowDefinition) error

ValidateDefinition validates a workflow definition before creation/update

type WorkflowExecution

type WorkflowExecution struct {
	relational.UUIDModel
	CreatedAt time.Time      `json:"created-at"`
	UpdatedAt time.Time      `json:"updated-at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`

	// Execution Information
	Status        string     `gorm:"size:50;index:idx_workflow_exec_instance_status,priority:2;index:idx_workflow_exec_status_created" json:"status"` // pending, in_progress, completed, failed, cancelled
	StartedAt     *time.Time `json:"started-at,omitempty"`
	OverdueAt     *time.Time `json:"overdue-at,omitempty"`
	CompletedAt   *time.Time `json:"completed-at,omitempty"`
	FailedAt      *time.Time `json:"failed-at,omitempty"`
	FailureReason string     `gorm:"type:text" json:"failure_reason,omitempty"`

	// Execution Context
	TriggeredBy string `` // manual, scheduled, automatic
	/* 135-byte string literal not displayed */
	TriggeredByID string `gorm:"size:255" json:"triggered_by_id"` // User ID or system identifier

	// Scheduling Context
	PeriodLabel string `` // e.g., "2023-10", "2023-W42"
	/* 151-byte string literal not displayed */
	DueDate *time.Time `gorm:"index" json:"due_date,omitempty"`

	// Audit Fields
	CreatedByID *uuid.UUID `gorm:"index" json:"created_by_id,omitempty"`
	UpdatedByID *uuid.UUID `gorm:"index" json:"updated_by_id,omitempty"`

	// Foreign Keys
	WorkflowInstanceID *uuid.UUID `` /* 201-byte string literal not displayed */

	// Relationships
	WorkflowInstance *WorkflowInstance `gorm:"foreignKey:WorkflowInstanceID" json:"workflow_instance,omitempty"`
	StepExecutions   []StepExecution   `gorm:"foreignKey:WorkflowExecutionID;constraint:OnDelete:CASCADE" json:"step_executions,omitempty"`
}

WorkflowExecution represents a specific run of a workflow instance

func (WorkflowExecution) TableName

func (WorkflowExecution) TableName() string

TableName specifies the table name for WorkflowExecution

type WorkflowExecutionEvidenceCreator

type WorkflowExecutionEvidenceCreator interface {
	AddWorkflowExecutionEvidence(ctx context.Context, workflowExecutionID *uuid.UUID, status string) error
}

WorkflowExecutionEvidenceCreator interface for creating workflow execution evidence

type WorkflowExecutionService

type WorkflowExecutionService struct {
	// contains filtered or unexported fields
}

WorkflowExecutionService provides CRUD operations for WorkflowExecution

func NewWorkflowExecutionService

func NewWorkflowExecutionService(db *gorm.DB) *WorkflowExecutionService

NewWorkflowExecutionService creates a new WorkflowExecutionService

func (*WorkflowExecutionService) Cancel

func (s *WorkflowExecutionService) Cancel(id *uuid.UUID) error

Cancel cancels a workflow execution

func (*WorkflowExecutionService) Complete

func (s *WorkflowExecutionService) Complete(id *uuid.UUID) error

Complete marks a workflow execution as completed

func (*WorkflowExecutionService) Create

func (s *WorkflowExecutionService) Create(execution *WorkflowExecution) error

Create creates a new workflow execution

func (*WorkflowExecutionService) Fail

func (s *WorkflowExecutionService) Fail(id *uuid.UUID, reason string) error

Fail marks a workflow execution as failed

func (*WorkflowExecutionService) FailIfNotTerminal

func (s *WorkflowExecutionService) FailIfNotTerminal(ctx context.Context, id *uuid.UUID, reason string) (bool, error)

FailIfNotTerminal marks the execution as failed only if it is not already in a terminal state (failed, completed, or cancelled). Returns true if the row was updated, false if it was already terminal. This is the idempotent version of Fail, safe to call from concurrent code paths.

func (*WorkflowExecutionService) GetActiveExecutions

func (s *WorkflowExecutionService) GetActiveExecutions() ([]WorkflowExecution, error)

GetActiveExecutions retrieves all active (in_progress) executions

func (*WorkflowExecutionService) GetAll

func (s *WorkflowExecutionService) GetAll(limit, offset int, filters map[string]interface{}) ([]WorkflowExecution, int64, error)

GetAll retrieves all workflow executions with optional filters

func (*WorkflowExecutionService) GetByID

GetByID retrieves a workflow execution by ID

func (*WorkflowExecutionService) GetByWorkflowInstanceID

func (s *WorkflowExecutionService) GetByWorkflowInstanceID(instanceID *uuid.UUID) ([]WorkflowExecution, error)

GetByWorkflowInstanceID retrieves all executions for a workflow instance

func (*WorkflowExecutionService) GetExecutionProgress

func (s *WorkflowExecutionService) GetExecutionProgress(id *uuid.UUID) (completed, total int, err error)

GetExecutionProgress calculates the progress of a workflow execution

func (*WorkflowExecutionService) GetRecentExecutions

func (s *WorkflowExecutionService) GetRecentExecutions(since time.Time, limit int) ([]WorkflowExecution, error)

GetRecentExecutions retrieves recent executions within a time range

func (*WorkflowExecutionService) SetEvidenceCreator

func (s *WorkflowExecutionService) SetEvidenceCreator(evidenceCreator WorkflowExecutionEvidenceCreator)

SetEvidenceCreator sets the evidence creator for the workflow execution service

func (*WorkflowExecutionService) SetLogger

func (s *WorkflowExecutionService) SetLogger(logger *zap.SugaredLogger)

SetLogger sets the logger for the service

func (*WorkflowExecutionService) Start

func (s *WorkflowExecutionService) Start(id *uuid.UUID) error

Start marks a workflow execution as started

func (*WorkflowExecutionService) Update

func (s *WorkflowExecutionService) Update(id *uuid.UUID, updates *WorkflowExecution) error

Update updates an existing workflow execution

func (*WorkflowExecutionService) UpdateStatus

func (s *WorkflowExecutionService) UpdateStatus(ctx context.Context, id *uuid.UUID, status string) error

UpdateStatus updates the status of a workflow execution

func (*WorkflowExecutionService) ValidateExecution

func (s *WorkflowExecutionService) ValidateExecution(execution *WorkflowExecution) error

ValidateExecution validates a workflow execution

type WorkflowExecutionStatus

type WorkflowExecutionStatus string

WorkflowExecutionStatus represents the status of a workflow execution

const (
	WorkflowStatusPending    WorkflowExecutionStatus = "pending"
	WorkflowStatusInProgress WorkflowExecutionStatus = "in_progress"
	WorkflowStatusOverdue    WorkflowExecutionStatus = "overdue"
	WorkflowStatusCompleted  WorkflowExecutionStatus = "completed"
	WorkflowStatusFailed     WorkflowExecutionStatus = "failed"
	WorkflowStatusCancelled  WorkflowExecutionStatus = "cancelled"
)

Valid workflow execution statuses

func (WorkflowExecutionStatus) IsValid

func (w WorkflowExecutionStatus) IsValid() bool

IsValid checks if the workflow execution status is valid

func (WorkflowExecutionStatus) String

func (w WorkflowExecutionStatus) String() string

String returns the string representation

type WorkflowInstance

type WorkflowInstance struct {
	relational.UUIDModel
	CreatedAt time.Time      `json:"created-at"`
	UpdatedAt time.Time      `json:"updated-at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`

	// Basic Information
	Name        string `gorm:"not null;size:255" json:"name"`
	Description string `gorm:"type:text" json:"description"`

	// Instance Configuration
	Cadence         string `gorm:"size:50" json:"cadence"` // daily, weekly, monthly, quarterly, annually
	IsActive        bool   `gorm:"default:true" json:"is_active"`
	GracePeriodDays *int   `json:"grace-period-days,omitempty"` // Override definition/global default if set

	// Scheduling
	NextScheduledAt *time.Time `json:"next-scheduled-at,omitempty"`
	LastExecutedAt  *time.Time `json:"last-executed-at,omitempty"`

	// Audit Fields
	CreatedByID *uuid.UUID `gorm:"index" json:"created_by_id,omitempty"`
	UpdatedByID *uuid.UUID `gorm:"index" json:"updated_by_id,omitempty"`

	// Foreign Keys
	WorkflowDefinitionID *uuid.UUID `gorm:"not null;index" json:"workflow_definition_id"`
	SystemSecurityPlanID *uuid.UUID `gorm:"not null;index" json:"system_id"`
	// Relationships
	SystemSecurityPlan *relational.SystemSecurityPlan `gorm:"foreignKey:SystemSecurityPlanID" json:"system_security_plan,omitempty"`
	WorkflowDefinition *WorkflowDefinition            `gorm:"foreignKey:WorkflowDefinitionID" json:"workflow_definition,omitempty"`
	RoleAssignments    []RoleAssignment               `gorm:"foreignKey:WorkflowInstanceID;constraint:OnDelete:CASCADE" json:"role_assignments,omitempty"`
	Executions         []WorkflowExecution            `gorm:"foreignKey:WorkflowInstanceID;constraint:OnDelete:CASCADE" json:"executions,omitempty"`
}

WorkflowInstance represents a specific implementation of a workflow definition Created by Business Units when implementing controls for specific systems

func (WorkflowInstance) TableName

func (WorkflowInstance) TableName() string

TableName specifies the table name for WorkflowInstance

type WorkflowInstanceService

type WorkflowInstanceService struct {
	// contains filtered or unexported fields
}

WorkflowInstanceService provides CRUD operations for WorkflowInstance

func NewWorkflowInstanceService

func NewWorkflowInstanceService(db *gorm.DB) *WorkflowInstanceService

NewWorkflowInstanceService creates a new WorkflowInstanceService

func (*WorkflowInstanceService) Activate

func (s *WorkflowInstanceService) Activate(id *uuid.UUID) error

Activate activates a workflow instance

func (*WorkflowInstanceService) AdvanceSchedule

func (s *WorkflowInstanceService) AdvanceSchedule(ctx context.Context, id *uuid.UUID) error

AdvanceSchedule updates the last executed time to now and calculates the next scheduled time

func (*WorkflowInstanceService) CalculateNextSchedule

func (s *WorkflowInstanceService) CalculateNextSchedule(from time.Time, cadence string) time.Time

CalculateNextSchedule calculates the next scheduled time based on cadence

func (*WorkflowInstanceService) Create

func (s *WorkflowInstanceService) Create(instance *WorkflowInstance) error

Create creates a new workflow instance

func (*WorkflowInstanceService) Deactivate

func (s *WorkflowInstanceService) Deactivate(id *uuid.UUID) error

Deactivate deactivates a workflow instance

func (*WorkflowInstanceService) Delete

func (s *WorkflowInstanceService) Delete(id *uuid.UUID) error

Delete soft deletes a workflow instance

func (*WorkflowInstanceService) GetAll

func (s *WorkflowInstanceService) GetAll(limit, offset int, filters map[string]interface{}) ([]WorkflowInstance, int64, error)

GetAll retrieves all workflow instances with optional filters

func (*WorkflowInstanceService) GetByID

GetByID retrieves a workflow instance by ID

func (*WorkflowInstanceService) GetByIDWithContext

func (s *WorkflowInstanceService) GetByIDWithContext(ctx context.Context, id *uuid.UUID) (*WorkflowInstance, error)

GetByIDWithContext retrieves a workflow instance by ID with context

func (*WorkflowInstanceService) GetBySystemId

func (s *WorkflowInstanceService) GetBySystemId(systemId *uuid.UUID) ([]WorkflowInstance, error)

GetBySystemId retrieves all instances for a specific system

func (*WorkflowInstanceService) GetByWorkflowDefinitionID

func (s *WorkflowInstanceService) GetByWorkflowDefinitionID(workflowDefID *uuid.UUID) ([]WorkflowInstance, error)

GetByWorkflowDefinitionID retrieves all instances for a workflow definition

func (*WorkflowInstanceService) GetDueInstances

func (s *WorkflowInstanceService) GetDueInstances(ctx context.Context) ([]WorkflowInstance, error)

GetDueInstances retrieves all instances that are due for execution

func (*WorkflowInstanceService) Update

func (s *WorkflowInstanceService) Update(id *uuid.UUID, updates *WorkflowInstance) error

Update updates an existing workflow instance

func (*WorkflowInstanceService) UpdateLastExecuted

func (s *WorkflowInstanceService) UpdateLastExecuted(ctx context.Context, id *uuid.UUID, lastExecuted time.Time) error

UpdateLastExecuted updates the last executed time for an instance

func (*WorkflowInstanceService) UpdateSchedule

func (s *WorkflowInstanceService) UpdateSchedule(ctx context.Context, id *uuid.UUID, nextSchedule time.Time) error

UpdateSchedule updates the next scheduled time for an instance

func (*WorkflowInstanceService) ValidateInstance

func (s *WorkflowInstanceService) ValidateInstance(instance *WorkflowInstance) error

ValidateInstance validates a workflow instance

type WorkflowStepDefinition

type WorkflowStepDefinition struct {
	relational.UUIDModel
	CreatedAt time.Time      `json:"created-at"`
	UpdatedAt time.Time      `json:"updated-at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`

	// Basic Information
	Name        string `gorm:"not null;size:255" json:"name"`
	Description string `gorm:"type:text" json:"description"`

	// Step Configuration
	Order             int                                      `gorm:"not null;default:0;index:idx_workflow_order" json:"order"` // Display order within workflow
	ResponsibleRole   string                                   `gorm:"not null;size:255" json:"responsible_role"`                // Role responsible for this step
	EvidenceRequired  datatypes.JSONSlice[EvidenceRequirement] `json:"evidence_required"`                                        // JSON array of required evidence types
	EstimatedDuration int                                      `gorm:"default:0" json:"estimated_duration"`                      // Estimated duration in minutes
	GracePeriodDays   *int                                     `json:"grace-period-days,omitempty"`                              // Override default grace for this specific step

	// Foreign Keys
	WorkflowDefinitionID *uuid.UUID `gorm:"not null;index" json:"workflow_definition_id"`

	// Relationships
	WorkflowDefinition *WorkflowDefinition `gorm:"foreignKey:WorkflowDefinitionID" json:"workflow_definition,omitempty"`
	DependsOn          []StepDependency    `gorm:"foreignKey:WorkflowStepDefinitionID;constraint:OnDelete:CASCADE" json:"depends_on,omitempty"`
	DependentSteps     []StepDependency    `gorm:"foreignKey:DependsOnStepID;constraint:OnDelete:CASCADE" json:"dependent_steps,omitempty"`
	StepExecutions     []StepExecution     `gorm:"foreignKey:WorkflowStepDefinitionID;constraint:OnDelete:CASCADE" json:"step_executions,omitempty"`
	Triggers           []StepTrigger       `gorm:"foreignKey:WorkflowStepDefinitionID;constraint:OnDelete:CASCADE" json:"triggers,omitempty"`
}

WorkflowStepDefinition represents a discrete piece of work within a workflow Contains dependencies on other steps and defines evidence requirements

func (WorkflowStepDefinition) TableName

func (WorkflowStepDefinition) TableName() string

TableName specifies the table name for WorkflowStepDefinition

type WorkflowStepDefinitionService

type WorkflowStepDefinitionService struct {
	// contains filtered or unexported fields
}

WorkflowStepDefinitionService provides CRUD operations for WorkflowStepDefinition

func NewWorkflowStepDefinitionService

func NewWorkflowStepDefinitionService(db *gorm.DB) *WorkflowStepDefinitionService

NewWorkflowStepDefinitionService creates a new WorkflowStepDefinitionService

func (*WorkflowStepDefinitionService) AddDependency

func (s *WorkflowStepDefinitionService) AddDependency(stepID, dependsOnStepID *uuid.UUID) error

AddDependency adds a dependency between two steps

func (*WorkflowStepDefinitionService) Create

Create creates a new workflow step definition

func (*WorkflowStepDefinitionService) Delete

Delete soft deletes a workflow step definition

func (*WorkflowStepDefinitionService) GetByID

GetByID retrieves a workflow step definition by ID

func (*WorkflowStepDefinitionService) GetByWorkflowDefinitionID

func (s *WorkflowStepDefinitionService) GetByWorkflowDefinitionID(workflowDefID *uuid.UUID) ([]WorkflowStepDefinition, error)

GetByWorkflowDefinitionID retrieves all steps for a workflow definition ordered by the order field

func (*WorkflowStepDefinitionService) GetDependencies

func (s *WorkflowStepDefinitionService) GetDependencies(stepID *uuid.UUID) ([]WorkflowStepDefinition, error)

GetDependencies retrieves all dependencies for a step

func (*WorkflowStepDefinitionService) GetDependentSteps

func (s *WorkflowStepDefinitionService) GetDependentSteps(stepID *uuid.UUID) ([]WorkflowStepDefinition, error)

GetDependentSteps retrieves all steps that depend on this step ordered by the order field

func (*WorkflowStepDefinitionService) HasCircularDependency

func (s *WorkflowStepDefinitionService) HasCircularDependency(stepID, dependsOnStepID *uuid.UUID) (bool, error)

HasCircularDependency checks if adding a dependency would create a cycle

func (*WorkflowStepDefinitionService) RemoveDependency

func (s *WorkflowStepDefinitionService) RemoveDependency(stepID, dependsOnStepID *uuid.UUID) error

RemoveDependency removes a dependency between two steps

func (*WorkflowStepDefinitionService) Update

Update updates an existing workflow step definition

func (*WorkflowStepDefinitionService) ValidateStep

ValidateStep validates a workflow step definition

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL