Files
Maven/cmd/mavend/actions_reminder.go
T
claude 1d10c9535c The hour after "к" is read, and an hour nobody read is asked about (V-610)
"напомни завтра к трём часам дня позвонить врачу" now sets 15:00. It set 03:53,
which was the clock at the moment of the turn. She confirmed that as the hour he
had just said.

#252 taught hourPrepositions and the dateparser rewrite the preposition "к". So
HasTime and NamesAnHour started answering true for the sentence. The value did
not follow. The rewrite kept his preposition and handed dateparser "завтра к
03:00 pm". dateparser joins a day word to a clock through "в" and through no
other Russian preposition. It read the day, dropped the clock and filled the time
from its relative base. The completeness rule then saw what, time and day all
answered, and committed at the current minute.

The preposition is normalised along with the hour now. "на" was losing the clock
the same way and was never measured. So "напомни завтра на 9" was landing on the
current minute too.

The second half is the durable one. ResolvedTheHour is the gate the reminder slot
reads, and it refuses a parse whose minute nobody spoke. A spoken hour lands on
the hour. The three shapes that name a minute of their own are a written clock, a
half hour and a quarter to. Anything else came off the clock the parser was
handed. An interval is exempt, because it lands where the arithmetic says.
Comparing the whole instant to now is the obvious test and it is wrong.
ru-rem-006 resolves to 12:00 and the fixture reference clock is 12:00. That is an
hour he did say, reading as an hour nobody did.

The five sentences measured on the box are pinned as tests. They run against the
stub and against the production parser, and the two that already passed are in
there too.

Fixture unchanged. classifier+hash is 27/91 and classifier+onnx is 64/91, before
and after. reach is 18/30 and 27/30, before and after. No case moved and no
clarify count changed. Suite green under -race.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 04:11:47 +04:00

63 lines
2.6 KiB
Go

package main
import (
"context"
"fmt"
"log"
"time"
"github.com/kami/maven/internal/lexicon"
"github.com/kami/maven/internal/phraser"
"github.com/kami/maven/internal/router"
)
// actionReminder handles router.IntentReminder: parse the time when stage-0
// skipped the extractor, then create the reminder.
func (h *reactiveHandler) actionReminder(ctx context.Context, dec router.Decision) string {
if !dec.Slots.HasTime {
// Stage-0 (reminder-wakeword grammar) skips the extractor, so the
// time wasn't parsed. Run the parser as a fallback.
if dec.Stage == 0 && h.timeParser != nil {
t, ok, err := h.timeParser.Parse(ctx, dec.Utterance, h.now())
// Same gate as the extractor (V-577, V-579, V-610): a request whose
// hour was not spoken, or was spoken and not read, gets asked about
// and is never completed from the clock.
if err == nil && ok && router.ResolvedTheHour(dec.Utterance, t) {
dec.Slots.Time = t
dec.Slots.HasTime = true
}
}
if !dec.Slots.HasTime {
return phraser.Ack(phraser.FailReminderTime, nil)
}
}
// The body is what she says at the hour, so the marker and the time come
// out of it: the fire time is already a column, and "напомни" is an
// instruction that has been carried out (Vikunja #469).
payload := `{"text":` + jsonString(reminderBody(dec.Utterance, dec.Slots.Text)) + `}`
if _, err := h.api.CreateReminder(ctx, dec.Slots.Time, payload, ""); err != nil {
log.Printf("voice: create reminder: %v", err)
return phraser.Ack(phraser.FailReminder, nil)
}
// Phrased from the row, never from the utterance (Vikunja #507). The
// replier only ever saw Slots.Text, so it named whatever hour the sentence
// contained — including one the parser had rejected or read differently.
// A confirmation naming an hour no row holds is worse than a clarify,
// because he stops thinking about it.
return reminderConfirm(dec.Slots.Time, h.now())
}
// reminderConfirm — the confirmation for a reminder that exists, naming the
// stored fire time. Deterministic on purpose: the one sentence that must match
// a database row is not one to hand to a 1.7B.
func reminderConfirm(fire, now time.Time) string {
when := dayPrefix(now, fire)
if when == "это" {
// Further out than the day words reach — say the date instead of a
// word that would be wrong.
date := fmt.Sprintf("%d %s", fire.Day(), lexicon.MonthGenitive(int(fire.Month())))
return "хорошо, напомню " + date + " в " + fire.Format("15:04") + "."
}
return "хорошо, напомню " + when + " в " + fire.Format("15:04") + "."
}