91 lines
2.9 KiB
Go
91 lines
2.9 KiB
Go
package household_scenarios
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"git.cin.su/m/Assistant/contracts/capability"
|
|
interactiondomain "git.cin.su/m/Assistant/modules/interaction/domain"
|
|
)
|
|
|
|
type checklistItem struct {
|
|
ID string `json:"id"`
|
|
Kind string `json:"kind"`
|
|
Message string `json:"message"`
|
|
Outcome string `json:"outcome"`
|
|
}
|
|
|
|
func TestHouseholdChecklist50ReachesPositiveSemanticReaction(t *testing.T) {
|
|
data, err := os.ReadFile(filepath.Join("checklist_50.json"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var items []checklistItem
|
|
if err := json.Unmarshal(data, &items); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(items) != 50 {
|
|
t.Fatalf("checklist has %d items, want exactly 50", len(items))
|
|
}
|
|
seen := map[string]bool{}
|
|
for _, item := range items {
|
|
if item.ID == "" || item.Kind == "" || strings.TrimSpace(item.Message) == "" || item.Outcome == "" {
|
|
t.Fatalf("incomplete checklist item: %+v", item)
|
|
}
|
|
if seen[item.ID] {
|
|
t.Fatalf("duplicate checklist item %q", item.ID)
|
|
}
|
|
seen[item.ID] = true
|
|
checkSemanticReaction(t, item)
|
|
}
|
|
}
|
|
|
|
func checkSemanticReaction(t *testing.T, item checklistItem) {
|
|
t.Helper()
|
|
candidate := interactiondomain.BuildDeterministicCandidate(item.Message, "", time.Unix(10, 0).UnixMilli())
|
|
has := func(kind capability.CapabilityKind) bool {
|
|
for _, hint := range candidate.CapabilityHints {
|
|
if capability.CapabilityKind(hint) == kind {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
switch item.Outcome {
|
|
case "identity", "memory", "conversation", "confirmation":
|
|
if has(capability.CapabilityKindWebResearch) || has(capability.CapabilityKindImageGeneration) {
|
|
t.Errorf("%s %q routed unrelated capability for %s: %+v", item.ID, item.Message, item.Outcome, candidate)
|
|
}
|
|
case "research":
|
|
if !has(capability.CapabilityKindWebResearch) {
|
|
t.Errorf("%s %q did not select research route: %+v", item.ID, item.Message, candidate)
|
|
}
|
|
case "media":
|
|
if !has(capability.CapabilityKindImageGeneration) {
|
|
t.Errorf("%s %q did not select image route: %+v", item.ID, item.Message, candidate)
|
|
}
|
|
case "action":
|
|
if !has(capability.CapabilityKindScheduleReminder) && !has(capability.CapabilityKindCognitiveReasoning) && !candidate.NeedsCognition {
|
|
t.Errorf("%s %q has no action route or cognitive handoff: %+v", item.ID, item.Message, candidate)
|
|
}
|
|
case "agent":
|
|
if !candidate.NeedsCognition && len(candidate.CapabilityHints) == 0 {
|
|
t.Errorf("%s %q has no agent route or cognitive handoff: %+v", item.ID, item.Message, candidate)
|
|
}
|
|
case "multi":
|
|
if len(candidate.CapabilityHints) < 2 {
|
|
t.Errorf("%s %q was not decomposed into multiple capabilities: %+v", item.ID, item.Message, candidate)
|
|
}
|
|
case "audio", "vision", "ocr", "video":
|
|
if len(candidate.CapabilityHints) == 0 && !candidate.NeedsCognition {
|
|
t.Errorf("%s %q has no modality route or cognitive handoff: %+v", item.ID, item.Message, candidate)
|
|
}
|
|
default:
|
|
t.Fatalf("%s uses unknown outcome %q", item.ID, item.Outcome)
|
|
}
|
|
}
|