Files
Agent-System/internal/app/intentflow/flags_test.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

83 lines
2.1 KiB
Go

package intentflow
import (
"testing"
)
func TestDefaultPlanTierIsLegacy(t *testing.T) {
t.Setenv("MULTI_INTENT_PLAN_TIER", "")
ResetFeatureFlagsForTest()
if got := CurrentFeatureFlags().PlanTier; got != TierLegacy {
t.Fatalf("default tier = %s, want legacy", got)
}
}
func TestUnknownPlanTierFailsClosedToLegacy(t *testing.T) {
if parsePlanTier("definitely-not-a-tier") != TierLegacy {
t.Fatal("unknown MULTI_INTENT_PLAN_TIER must fail closed to legacy")
}
}
func TestPlanTierIndependentOfLegacyMultiIntentFlag(t *testing.T) {
t.Setenv("MULTI_INTENT_ENABLED", "true")
t.Setenv("MULTI_INTENT_PLAN_TIER", "")
ResetFeatureFlagsForTest()
if CurrentFeatureFlags().PlanTier != TierLegacy {
t.Fatal("MULTI_INTENT_ENABLED must not promote plan tier")
}
}
func TestPlanTierEnv(t *testing.T) {
if parsePlanTier("shadow") != TierShadow {
t.Fatal("shadow")
}
if parsePlanTier("auto_read") != TierAutoRead {
t.Fatal("auto_read")
}
if parsePlanTier("confirm") != TierConfirm {
t.Fatal("confirm")
}
if parsePlanTier("full") != TierFull {
t.Fatal("full")
}
if !TierConfirm.Allows(TierAutoRead) || TierShadow.Allows(TierConfirm) {
t.Fatal("tier rank")
}
}
func TestErrorCodes(t *testing.T) {
if ErrorCode(ErrPlanNotFoundOrHidden) != "PLAN_NOT_FOUND_OR_HIDDEN" {
t.Fatal(ErrorCode(ErrPlanNotFoundOrHidden))
}
if ErrorCode(ErrPlanStaleRevision) != "PLAN_STALE_REVISION" {
t.Fatal("stale")
}
if ErrorCode(ErrPlanExpired) != "PLAN_EXPIRED" {
t.Fatal("expired")
}
if ErrorCode(ErrPlanDecisionConflict) != "PLAN_DECISION_CONFLICT" {
t.Fatal("conflict")
}
if ErrorCode(ErrPlanDependencyInvalid) != "PLAN_DEPENDENCY_INVALID" {
t.Fatal("dep")
}
if ErrorCode(ErrPlanActionForbidden) != "PLAN_ACTION_FORBIDDEN" {
t.Fatal("forbidden")
}
if ErrorCode(ErrPlanActionVersionConflict) != "PLAN_ACTION_VERSION_CONFLICT" {
t.Fatal("version")
}
}
func TestRESTPathsFrozen(t *testing.T) {
if PathActivePlan != "/api/v1/intent-plans/active" {
t.Fatal(PathActivePlan)
}
if PathPlanByID != "/api/v1/intent-plans/{plan_id}" {
t.Fatal(PathPlanByID)
}
if PathPlanDecisions != "/api/v1/intent-plans/{plan_id}/decisions" {
t.Fatal(PathPlanDecisions)
}
}