Files
Agent-System/internal/projectinstance/errors.go
T
weichenandCursor f168e44ce7 feat(projectinstance): allow live workflow config edits except switching
Activated projects can update duties, approval policy, and document enablement. Changing the workflow definition stays rejected, and project 143 remains frozen.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-21 05:20:01 +00:00

79 lines
3.4 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) 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}
}