Files
Agent-System/internal/app/intentflow/errors.go
T
weichenandCursor 9364da4974 feat(intentflow): freeze plan lifecycle contracts and batch policy
Add the app/intentflow skeleton so HITL state, error codes, REST shapes, and BatchActionPolicy live outside intent and default to the legacy tier.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-15 16:22:52 +00:00

40 lines
1.4 KiB
Go

package intentflow
import "errors"
// Sentinel errors use the public API error codes from the design §9.
var (
ErrPlanNotFoundOrHidden = errors.New("PLAN_NOT_FOUND_OR_HIDDEN")
ErrPlanStaleRevision = errors.New("PLAN_STALE_REVISION")
ErrPlanExpired = errors.New("PLAN_EXPIRED")
ErrPlanDecisionConflict = errors.New("PLAN_DECISION_CONFLICT")
ErrPlanDependencyInvalid = errors.New("PLAN_DEPENDENCY_INVALID")
ErrPlanActionForbidden = errors.New("PLAN_ACTION_FORBIDDEN")
ErrPlanActionVersionConflict = errors.New("PLAN_ACTION_VERSION_CONFLICT")
ErrUnauthenticated = errors.New("ERR_UNAUTHENTICATED")
)
// ErrorCode returns the stable machine code for a sentinel, or empty.
func ErrorCode(err error) string {
switch {
case errors.Is(err, ErrPlanNotFoundOrHidden):
return "PLAN_NOT_FOUND_OR_HIDDEN"
case errors.Is(err, ErrPlanStaleRevision):
return "PLAN_STALE_REVISION"
case errors.Is(err, ErrPlanExpired):
return "PLAN_EXPIRED"
case errors.Is(err, ErrPlanDecisionConflict):
return "PLAN_DECISION_CONFLICT"
case errors.Is(err, ErrPlanDependencyInvalid):
return "PLAN_DEPENDENCY_INVALID"
case errors.Is(err, ErrPlanActionForbidden):
return "PLAN_ACTION_FORBIDDEN"
case errors.Is(err, ErrPlanActionVersionConflict):
return "PLAN_ACTION_VERSION_CONFLICT"
case errors.Is(err, ErrUnauthenticated):
return "ERR_UNAUTHENTICATED"
default:
return ""
}
}