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>
68 lines
2.9 KiB
Go
68 lines
2.9 KiB
Go
package router
|
||
|
||
import "testing"
|
||
|
||
func TestParseCommandProhibitionUsesCommandPositionAndScope(t *testing.T) {
|
||
for _, utterance := range []string{
|
||
"не отменяй напоминание про молоко",
|
||
"не закрой задачу купить молоко",
|
||
"не закрыть задачу купить молоко",
|
||
"никогда не перезапускай nginx",
|
||
"только не удаляй будильник",
|
||
"ни в коем случае не перезапускай nginx",
|
||
"ни за что не закрывай задачу",
|
||
"Maven, пожалуйста, не удаляй будильник",
|
||
"don't restart nginx",
|
||
"don’t close the task",
|
||
"do not cancel the milk reminder",
|
||
"never remove the task",
|
||
} {
|
||
if got, ok := ParseCommandProhibition(utterance); !ok || len(got.Body) == 0 {
|
||
t.Errorf("ParseCommandProhibition(%q) = %+v, %v; want direct prohibition", utterance, got, ok)
|
||
}
|
||
}
|
||
|
||
for _, utterance := range []string{
|
||
"я не закрыл задачу купить молоко",
|
||
"I did not close the task",
|
||
"можно ли не отменять напоминание",
|
||
"проверь диск, но ничего не удаляй",
|
||
"не забудь напомнить мне завтра про молоко",
|
||
"don't forget to remind me about milk",
|
||
"не мог бы ты отменить напоминание про молоко",
|
||
"donut restart nginx",
|
||
"noteworthy restart nginx",
|
||
} {
|
||
if got, ok := ParseCommandProhibition(utterance); ok {
|
||
t.Errorf("ParseCommandProhibition(%q) = %+v; not a direct prohibited mutation", utterance, got)
|
||
}
|
||
}
|
||
|
||
for _, utterance := range []string{
|
||
"не мог перезапустить nginx",
|
||
"не могла закрыть задачу купить молоко",
|
||
"не могли удалить напоминание",
|
||
"не забудь сначала задачу, потом напомнить про молоко",
|
||
} {
|
||
if _, ok := ParseCommandProhibition(utterance); !ok {
|
||
t.Errorf("%q must retain the fail-closed execution belt", utterance)
|
||
}
|
||
}
|
||
|
||
// This idiom does not contain a reminder verb. Treating its nested board
|
||
// transition as affirmative would be unsafe, so the execution belt wins.
|
||
if _, ok := ParseCommandProhibition("не забудь закрыть задачу купить молоко"); !ok {
|
||
t.Fatal("an ambiguous don't-forget board transition must fail closed")
|
||
}
|
||
}
|
||
|
||
func TestCommandProhibitionGrammarEmitsANonExecutableSentinel(t *testing.T) {
|
||
decision, matched, accepted := CommandProhibitionGrammar().Evaluate("don't restart nginx")
|
||
if !matched || !accepted || decision.Intent != IntentAct {
|
||
t.Fatalf("decision=%+v matched=%v accepted=%v; want deterministic act refusal", decision, matched, accepted)
|
||
}
|
||
if !decision.Slots.HasFn || decision.Slots.Fn != ProhibitedActFn {
|
||
t.Fatalf("slots=%+v, want non-executable fn %q", decision.Slots, ProhibitedActFn)
|
||
}
|
||
}
|