router: stage 0 claims the task marker before the model renames it (V-467)
Spoken capture was dead. "добавь в задачи купить молоко" routed act, so the gate found no allowlisted fn and asked "Что сделать?", and the list stayed empty. Capture rides the note intent by design (#130, no eighth intent), and nothing under actionNote was reached any more. The model also rewrote the payload on the way — "купить молоко" came back as "сделать покупку молока", and a task must read as the words he said. TaskCaptureGrammar answers it at stage 0, the same place the agenda rules went. It matches any utterance and lets ParseTaskCapture refuse, so the marker list stays data. Three phrasings he used are added to that list: "запиши в список дел" and the two next to it were missing. The other deterministic matchers were checked for the same exposure. They are all question-shaped — money, habit, feed, day plan, task list, calendar — and a question lands on query, which is where they already sit. Capture was the only imperative among them, which is why only it was taken. ru-note-006 is the fixture case. The classifier alone cannot pass it, and the hash baseline drops by that one case; the daemon answers it at stage 0.
This commit is contained in:
@@ -85,3 +85,37 @@ func TestIsTaskListQuery(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestTaskCaptureGrammarClaimsTheMarker — the capture marker is answered at
|
||||
// stage 0, so the model never gets to call it an act (Vikunja #467).
|
||||
func TestTaskCaptureGrammarClaimsTheMarker(t *testing.T) {
|
||||
g := TaskCaptureGrammar()
|
||||
captures := map[string]string{
|
||||
"добавь в задачи купить молоко": "купить молоко",
|
||||
"запиши в список дел купить хлеб": "купить хлеб",
|
||||
"поставь задачу вынести мусор": "вынести мусор",
|
||||
"добавь в задачи срочно оплатить дом": "оплатить дом",
|
||||
}
|
||||
for in, want := range captures {
|
||||
m := g.Pattern.FindStringSubmatch(in)
|
||||
if m == nil {
|
||||
t.Fatalf("%q did not match the grammar pattern", in)
|
||||
}
|
||||
d, ok := g.Build(m)
|
||||
if !ok {
|
||||
t.Fatalf("%q must be claimed as a capture", in)
|
||||
}
|
||||
if d.Intent != IntentNote || d.Slots.Text != want {
|
||||
t.Errorf("%q → intent=%s text=%q, want note/%q", in, d.Intent, d.Slots.Text, want)
|
||||
}
|
||||
}
|
||||
// Everything without a marker falls through, including a marker with no
|
||||
// task after it and a question about the list.
|
||||
for _, in := range []string{"надо бы поспать", "добавь в задачи", "какие у меня задачи?", "перезапусти nginx"} {
|
||||
if m := g.Pattern.FindStringSubmatch(in); m != nil {
|
||||
if _, ok := g.Build(m); ok {
|
||||
t.Errorf("%q must fall through to the cascade", in)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user