a97764c5f7
MavenHelpGrammar keeps "как отменить напоминание" on SourceSelf, where the answer names the command Maven accepts, instead of leaking to search. PublicCurrentVersionGrammar anchors an explicitly current release on SourceWorld and declines first-person ownership. AmbiguousFragmentGrammar refuses filler plus an unresolved demonstrative rather than letting a statistical head invent context. ImplicitElapsedQueryGrammar reads Russian question word order in "давно я не тренировался" as recall; the declarative order stays a statement. ReminderCancellationReportGrammar keeps "я отменил напоминание" in the non-mutating chat lane. CommandProhibitionGrammar routes a direct negative command to a sentinel fn that can never collide with an enabled tool. ActHasEntityTarget stops a bare verb or a demonstrative-only tail from crossing into Nexus. Praxis attention now accepts "что там с X" for the four service names only. taskstatus separates command mood from result words so a first-person report cannot mutate the board. question.go exports the open-question and locative shapes the recall gate reads. --no-verify: master is the working branch this session by the owner's call. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
99 lines
3.4 KiB
Go
99 lines
3.4 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)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestIsOpenQuestionShapedDistinguishesWordsFromPunctuation(t *testing.T) {
|
|
for _, text := range []string{
|
|
"где лежит запасной ключ?",
|
|
"как я восстановил конфиги",
|
|
"which colour scheme do i like",
|
|
"расскажи про домашний сервер",
|
|
} {
|
|
if !IsOpenQuestionShaped(text) {
|
|
t.Errorf("IsOpenQuestionShaped(%q) = false, want an explicit information request", text)
|
|
}
|
|
}
|
|
for _, text := range []string{
|
|
"я отменил напоминание про молоко?",
|
|
"сервер работает?",
|
|
"запиши что я пил воду?",
|
|
} {
|
|
if IsOpenQuestionShaped(text) {
|
|
t.Errorf("IsOpenQuestionShaped(%q) = true; punctuation alone is not an open question", text)
|
|
}
|
|
}
|
|
// Existing callers still need polar punctuation to count as a question.
|
|
if !IsQuestionShaped("сервер работает?") {
|
|
t.Error("IsQuestionShaped stopped recognising a polar question")
|
|
}
|
|
}
|
|
|
|
func TestIsLocativeQuestionShaped(t *testing.T) {
|
|
for _, text := range []string{
|
|
"где мой паспорт?",
|
|
"куда я спрятал второй ключ",
|
|
"откуда берётся токен",
|
|
"докуда идёт автобус",
|
|
"where is the big disk mounted",
|
|
} {
|
|
if !IsLocativeQuestionShaped(text) {
|
|
t.Errorf("IsLocativeQuestionShaped(%q) = false, want true", text)
|
|
}
|
|
}
|
|
for _, text := range []string{
|
|
"во сколько я обычно засыпаю",
|
|
"which colour scheme do i like",
|
|
"сервер работает?",
|
|
"запиши где лежит ключ",
|
|
} {
|
|
if IsLocativeQuestionShaped(text) {
|
|
t.Errorf("IsLocativeQuestionShaped(%q) = true, want false", text)
|
|
}
|
|
}
|
|
}
|