Files
Agent-System/internal/intent/registry_test.go
T
WeiCHENandCursor 9cb129d3e8 feat(intent): Phase 4 run control, subtypes, and limited IntentPlan
Add RUN_STATUS_QUERY/RUN_RESUME/RUN_RESTART with matcher and coordinator
handlers; write QUERY_PROGRESS/SUPPLEMENT_INFO subtypes to V2 frame; support
safe query+query multi-intent plans via IntentPlan dual-write.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 02:50:21 +00:00

45 lines
1.8 KiB
Go

package intent
import "testing"
func TestDefaultRegistry_CoversAllLegacyIntents(t *testing.T) {
r := DefaultRegistry()
legacyIntents := []IntentType{
IntentQueryProgress, IntentSupplementInfo, IntentAdvanceStage, IntentTriggerTask,
IntentTriggerAdhocTask, IntentCasualChat, IntentDeclineExpectation,
IntentDocGovClaim, IntentDocGovSubmitReview, IntentDocGovReviewApprove,
IntentDocGovReviewReject, IntentDocGovFinalApprove, IntentDocGovFinalReject,
IntentDocGovProposalDecide,
IntentQueryRegulations, IntentQuerySimilarCases, IntentQueryUserRights, IntentQueryRejectReason,
IntentConfirmAction, IntentExecuteStageAdvance, IntentSecurityForbidden,
IntentSwitchWorkflow, IntentTriggerWorkflow, IntentQueryWorkflowStatus,
IntentQueryDocStatus, IntentHelpCapabilities, IntentUnsupportedAction,
IntentRunStatusQuery, IntentRunResume, IntentRunRestart,
}
for _, lt := range legacyIntents {
spec, ok := r.GetByLegacyIntent(lt)
if !ok {
t.Errorf("missing registry entry for legacy intent %s", lt)
continue
}
if spec.Key == "" || spec.LegacyIntent != lt {
t.Errorf("invalid spec for %s: key=%s legacy=%s", lt, spec.Key, spec.LegacyIntent)
}
}
if len(r.All()) < len(legacyIntents) {
t.Errorf("expected at least %d specs, got %d", len(legacyIntents), len(r.All()))
}
}
func TestActionRegistry_RegisterDuplicateKey(t *testing.T) {
r := NewActionRegistry()
s1 := ActionSpec{Key: "test.action", Domain: "test", Object: "test", Goal: GoalQuery, LegacyIntent: IntentCasualChat}
s2 := ActionSpec{Key: "test.action", Domain: "test", Object: "test", Goal: GoalMutate, LegacyIntent: IntentSupplementInfo}
if err := r.Register(s1); err != nil {
t.Fatalf("register s1: %v", err)
}
if err := r.Register(s2); err == nil {
t.Fatal("expected duplicate key error")
}
}