Files
Agent-System/internal/app/intentflow/flags_test.go
T
weichenandCursor 1cd1cddf64 feat(intent-plan): independent PU8 U9–U12 flags default off
Dry-run/fail-closed adapters; does not raise plan tier.

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

95 lines
2.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 TestPlanTierIndependentOfExpansionFlags(t *testing.T) {
t.Setenv("MULTI_INTENT_PLAN_TIER", "")
t.Setenv("MULTI_INTENT_U9_SEGMENT", "true")
t.Setenv("MULTI_INTENT_U10_MUTATE", "true")
t.Setenv("MULTI_INTENT_U11_DOCGOV", "true")
t.Setenv("MULTI_INTENT_U12_RUN_CONTROL", "true")
ResetFeatureFlagsForTest()
if CurrentFeatureFlags().PlanTier != TierLegacy {
t.Fatal("U9–U12 flags must not raise MULTI_INTENT_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)
}
}