Files
Maven/cmd/mavend/calendarq_test.go
T
claude aa7ef33bbf the calendar answers his day, not any day (V-552)
queryCalendar matched on a day word and stepped aside only on weather
wording. Every world question naming a day was claimed by it and answered
with an empty schedule: "какой сегодня курс доллара" replied "на
05.08.2026 ничего нет", which reads as an answer about a subject she
never looked at. All four probe utterances have an answer in search, and
search sits below the calendar.

V-474 fixed one instance of the class. Sunset, holidays, exchange rates
and world news are the same class and weather wording does not cover them.

router.IsAgendaQuestion is the narrowing. Its first arm reuses
AgendaQueryGrammars, so the rule that routes a question to the query
chain and the rule that lets the calendar answer it cannot drift. The
second reads a scheduled-thing noun, wider than the grammars because
"какие встречи завтра" carries no possessive. The third claims a
question that names no subject of its own.

A continuation is exempt: "а завтра?" cannot name an agenda, and this
is the only date-aware source there is.
2026-08-05 21:40:15 +04:00

62 lines
2.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import (
"context"
"testing"
"github.com/kami/maven/internal/router"
)
// TestCalendarStepsAsideForTheWorld — the defect (Vikunja #552). Weather was
// one instance of a wider class, and V-474 fixed only that instance. Every one
// of these answered "на 05.08.2026 ничего нет" on the deployed daemon, and
// every one of them has an answer in search, which sits below the calendar.
func TestCalendarStepsAsideForTheWorld(t *testing.T) {
h, api := contQueryHandler()
for _, u := range []string{
"во сколько закат сегодня",
"какой сегодня курс доллара",
"какой сегодня праздник",
"что интересного произошло сегодня в мире",
} {
if reply, ok := h.queryCalendar(context.Background(), &queryTurn{
dec: router.Decision{Intent: router.IntentQuery, Utterance: u},
}); ok {
t.Errorf("the calendar claimed %q with %q", u, reply)
}
}
if api.events != 0 {
t.Errorf("CalendarEvents called %d times for world questions, want 0", api.events)
}
}
// The other half of the same narrowing: a question about his own day still
// reaches the calendar, including the one that names no subject at all.
func TestCalendarStillAnswersHisDay(t *testing.T) {
for _, u := range []string{
"что у меня сегодня",
"во сколько у меня встреча сегодня",
"какие встречи завтра",
"что в календаре на завтра",
"что сегодня?",
} {
h, _ := contQueryHandler()
if _, ok := h.queryCalendar(context.Background(), &queryTurn{
dec: router.Decision{Intent: router.IntentQuery, Utterance: u},
}); !ok {
t.Errorf("the calendar passed on %q", u)
}
}
}
// A continuation carries its subject in the turn before it, and the calendar
// is the only date-aware source, so the narrowing must not reach it.
func TestCalendarStillAnswersAContinuation(t *testing.T) {
h, _ := contQueryHandler()
if _, ok := h.queryCalendar(context.Background(), &queryTurn{
dec: router.Decision{Intent: router.IntentQuery, Utterance: "а завтра?", Continued: true},
}); !ok {
t.Error("the calendar passed on a continuation")
}
}