Add env-based feature flags (intent_v2_shadow/decision, multi_intent, workflow_intents), V1/V2 shadow diff reporting, expectation_plus_new plan building, ranked-frame L2 conflict gate, and coordinator sequential query plan execution with confirm-step deferral. Co-authored-by: Cursor <cursoragent@cursor.com>
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package intent
|
|
|
|
import "testing"
|
|
|
|
func TestTierAllowsRisk(t *testing.T) {
|
|
tests := []struct {
|
|
tier V2DecisionTier
|
|
risk RiskLevel
|
|
want bool
|
|
}{
|
|
{V2TierNone, RiskLow, false},
|
|
{V2TierQuery, RiskLow, true},
|
|
{V2TierQuery, RiskMedium, false},
|
|
{V2TierGenerate, RiskMedium, true},
|
|
{V2TierGenerate, RiskHigh, false},
|
|
{V2TierWriteLow, RiskHigh, false},
|
|
{V2TierWriteHigh, RiskHigh, true},
|
|
}
|
|
for _, tc := range tests {
|
|
if got := tierAllowsRisk(tc.tier, tc.risk); got != tc.want {
|
|
t.Errorf("tierAllowsRisk(%s, %s) = %v, want %v", tc.tier, tc.risk, got, tc.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestBuildV2ShadowReport_MismatchDetection(t *testing.T) {
|
|
SetFeatureFlagsForTest(FeatureFlags{IntentV2Shadow: true})
|
|
defer ResetFeatureFlagsForTest()
|
|
|
|
res := &IntentRecognitionResult{
|
|
TopIntent: &CandidateIntent{Intent: IntentQueryProgress, Confidence: 0.9},
|
|
IntentFrameV2: &IntentFrameV2{
|
|
LegacyIntent: IntentQueryRegulations,
|
|
ActionKey: "regulation.query",
|
|
Goal: GoalQuery,
|
|
},
|
|
}
|
|
ApplyV2ShadowObservability(res)
|
|
if res.V2Shadow == nil {
|
|
t.Fatal("expected v2_shadow report")
|
|
}
|
|
if !res.V2Shadow.Mismatch {
|
|
t.Error("expected mismatch=true")
|
|
}
|
|
}
|