81 lines
3.5 KiB
Go
81 lines
3.5 KiB
Go
package projectinstance
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"chat-agent-system/internal/workflowdef"
|
|
)
|
|
|
|
var (
|
|
ErrNotAvailable = errors.New("project instance store not available")
|
|
ErrProjectNotFound = errors.New("project not found")
|
|
ErrForbiddenNotCreator = errors.New("forbidden: only project creator can configure workflow")
|
|
ErrPlanFrozen = errors.New("plan frozen: workflow already active")
|
|
ErrWorkflowSwitchFrozen = errors.New("workflow switch frozen: definition cannot change after activation")
|
|
ErrWorkflowAlreadyActive = errors.New("workflow already active for project")
|
|
ErrPlanChangedReconfirm = errors.New("plan changed: reconfirm required")
|
|
ErrInvalidPlan = errors.New("invalid workflow plan")
|
|
ErrValidationFailed = errors.New("workflow plan validation failed")
|
|
ErrTokenInvalid = errors.New("activation token invalid or expired")
|
|
ErrConcurrentConflict = errors.New("conflict: project version mismatch")
|
|
ErrPlanRevisionConflict = errors.New("conflict: plan revision mismatch")
|
|
ErrWorkflowVersionNotFound = errors.New("workflow version not found or not published")
|
|
ErrLegacySwitchBlocked = errors.New("legacy workflow switch blocked: use project settings activation")
|
|
ErrInstanceNotFound = errors.New("workflow instance not found")
|
|
ErrStageGateNotReady = errors.New("stage gate not ready: required documents not approved")
|
|
ErrStageNotActive = errors.New("stage is not the active stage")
|
|
ErrStageNotCompleted = errors.New("stage is not completed")
|
|
ErrRecheckAckRequired = errors.New("recheck acknowledgement required")
|
|
ErrInvalidStage = errors.New("invalid stage key for instance")
|
|
ErrInstanceRevisionConflict = errors.New("conflict: instance config revision mismatch")
|
|
ErrEmptyWorkflow = errors.New("empty workflow: at least one enabled document required to activate")
|
|
ErrTerminationNotAllowed = errors.New("termination not allowed for instance state")
|
|
ErrAuthorOnlyPolicyDisabled = errors.New("author-only approval policy disabled")
|
|
ErrAuthorOnlyPolicyUnavailable = errors.New("author-only approval policy store unavailable")
|
|
ErrAuthorOnlyPolicyChanged = errors.New("author-only approval policy changed since preview")
|
|
ErrForbiddenDutyReassign = errors.New("forbidden: not allowed to reassign document duties")
|
|
ErrDocTaskNotFound = errors.New("document task not found or disabled")
|
|
)
|
|
|
|
// DocTaskBusyError 文档小队任务运行中,禁止改派。
|
|
type DocTaskBusyError struct {
|
|
TaskKey string
|
|
Reason string
|
|
}
|
|
|
|
func (e *DocTaskBusyError) Error() string {
|
|
if e == nil {
|
|
return "document task busy"
|
|
}
|
|
if e.Reason != "" {
|
|
return e.Reason
|
|
}
|
|
return "document task busy: squad run in progress"
|
|
}
|
|
|
|
func (e *DocTaskBusyError) ErrorCode() string { return "DOC_TASK_BUSY" }
|
|
|
|
func (e *DocTaskBusyError) Is(target error) bool {
|
|
_, ok := target.(*DocTaskBusyError)
|
|
return ok
|
|
}
|
|
|
|
var ErrDocTaskBusy = &DocTaskBusyError{}
|
|
|
|
// ValidationError 保留具体校验问题,供 HTTP 层返回可操作的错误信息。
|
|
type ValidationError struct {
|
|
Issues []workflowdef.ValidationIssue
|
|
}
|
|
|
|
func (e *ValidationError) Error() string {
|
|
return ErrValidationFailed.Error()
|
|
}
|
|
|
|
func (e *ValidationError) Unwrap() error {
|
|
return ErrValidationFailed
|
|
}
|
|
|
|
func newValidationError(result workflowdef.ValidationResult) error {
|
|
return &ValidationError{Issues: result.Issues}
|
|
}
|