Files
Maven/internal/router/question_test.go
claude 2e0e2fd0bb router: a deterministic test for question-shaped text (V-470)
The predicate a fact write needs before it trusts a routing decision. Tokenized,
not substring: 'что' inside 'чтобы' is not a question. Capture verbs win over
every question signal, because 'запиши что я пил воду' contains an interrogative
and is still a capture.
2026-08-03 13:40:33 +04:00

49 lines
1.7 KiB
Go

package router
import "testing"
func TestIsQuestionShaped(t *testing.T) {
// The seven utterances #470 recorded, plus the captures that must keep
// working. A capture misread as a question loses a fact; a question
// misread as a capture poisons recall, so the captures are the ones worth
// pinning here.
cases := []struct {
text string
want bool
}{
{"какая последняя версия языка Go?", true},
{"что дальше?", true},
{"расскажи про битву при Ватерлоо", true},
{"почему небо синее?", true},
{"какая столица Австралии?", true},
{"кто такой Никола Тесла?", true},
{"сколько стоит доллар", true},
{"who is the premier of Japan", true},
{"объясни линии Фраунгофера", true},
{"запиши что я пил воду", false},
{"запомни какая у меня машина", false},
{"отметь что я поужинал", false},
{"поужинал", false},
{"я выпил кофе", false},
{"вода", false},
{"привет", false},
{"", false},
}
for _, c := range cases {
if got := IsQuestionShaped(c.text); got != c.want {
t.Errorf("IsQuestionShaped(%q) = %v, want %v", c.text, got, c.want)
}
}
}
// Substring matching is what made the day-plan predicates wrong before, and
// this predicate gates a write, so it gets the same guard.
func TestIsQuestionShapedIsTokenized(t *testing.T) {
for _, text := range []string{"чтобы не забыть, я полил кактус", "какао выпил"} {
if IsQuestionShaped(text) {
t.Errorf("IsQuestionShaped(%q) = true; a question word inside a longer word is not a question", text)
}
}
}