77 lines
2.8 KiB
Go
77 lines
2.8 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"git.cin.su/m/Assistant/contracts/interaction"
|
|
interactiondomain "git.cin.su/m/Assistant/modules/interaction/domain"
|
|
)
|
|
|
|
func TestSimpleQuestionUsesStrictInterpretationForSemanticRouting(t *testing.T) {
|
|
result := interactiondomain.SemanticResult{
|
|
Interpretation: interaction.UtteranceInterpretation{
|
|
SpeechAct: interaction.SpeechActQuestion,
|
|
Applicability: interaction.SemanticNeedsBroaderInterpret,
|
|
Clarification: interaction.ClarificationNotRequired,
|
|
},
|
|
CapabilityHints: []string{"COGNITIVE_REASONING", "VERIFY_FACT"},
|
|
}
|
|
if !shouldRequestBroaderInterpretation(result) {
|
|
t.Fatal("simple question must reach semantic interpretation before any answer")
|
|
}
|
|
}
|
|
|
|
func TestOperationalQuestionStillUsesStrictInterpretation(t *testing.T) {
|
|
result := interactiondomain.SemanticResult{
|
|
Interpretation: interaction.UtteranceInterpretation{
|
|
SpeechAct: interaction.SpeechActQuestion,
|
|
Applicability: interaction.SemanticNeedsBroaderInterpret,
|
|
Clarification: interaction.ClarificationNotRequired,
|
|
},
|
|
CapabilityHints: []string{"MODIFY_CODE", "RUN_TESTS"},
|
|
}
|
|
if !shouldRequestBroaderInterpretation(result) {
|
|
t.Fatal("operational question must retain strict interpretation routing")
|
|
}
|
|
}
|
|
|
|
func TestStructuredInventoryUsesDirectReadOnlySemanticRoute(t *testing.T) {
|
|
result := interactiondomain.SemanticResult{
|
|
Interpretation: interaction.UtteranceInterpretation{
|
|
SpeechAct: interaction.SpeechActDirective,
|
|
Applicability: interaction.SemanticApplicable,
|
|
ConfidenceMillis: 980,
|
|
},
|
|
InformationRequestKind: interaction.InformationRequestCognitiveModelInventory,
|
|
}
|
|
if shouldRequestSemanticInterpretation(result) {
|
|
t.Fatal("structured model inventory must use the direct read-only semantic route")
|
|
}
|
|
}
|
|
|
|
func TestStableReflexIsPeriodicallySampledForDrift(t *testing.T) {
|
|
result := interactiondomain.SemanticResult{Interpretation: interaction.UtteranceInterpretation{
|
|
SpeechAct: interaction.SpeechActConversational, Applicability: interaction.SemanticApplicable,
|
|
}}
|
|
found := false
|
|
for minute := 0; minute < 160; minute++ {
|
|
if shouldAuditDeterministicReflex(result, "utterance-drift-probe", time.Unix(int64(minute)*60, 0)) {
|
|
found = true
|
|
break
|
|
}
|
|
}
|
|
if !found {
|
|
t.Fatal("stable reflex was never sampled during the audit window")
|
|
}
|
|
}
|
|
|
|
func TestMeaningfulSignalsAreNotReflexOnly(t *testing.T) {
|
|
for _, act := range []interaction.SpeechAct{interaction.SpeechActQuestion, interaction.SpeechActRequestToInvestigate, interaction.SpeechActDirective} {
|
|
result := interactiondomain.SemanticResult{Interpretation: interaction.UtteranceInterpretation{SpeechAct: act, Applicability: interaction.SemanticApplicable}}
|
|
if !shouldRequestSemanticInterpretation(result) {
|
|
t.Fatalf("%s must prefer cognitive interpretation", act)
|
|
}
|
|
}
|
|
}
|