7b2b96b957
A task is not a fact and not a note. A fact is a claim about the world that a correction supersedes; a note is something to recall by meaning. A task is work with a lifecycle, and the read that matters is "everything outstanding right now" — which over an append-only log would mean replaying history on every question. So: a tasks table, migration #14, statuses candidate/open/done/dropped that each move forward exactly once. Dedupe is on normalised text among LIVE rows only, via a partial unique index. That is the property the mail side needs: an extractor may call CaptureTask for every message it reads, as often as it likes, without growing the list — while a weekly errand is still capturable again once the last one is done. Three ways in, one seam. ipc.CaptureTaskReq is it: the voice path (router.ParseTaskCapture on an explicit marker — "добавь в задачи …", never "надо бы поспать"), the /tasks form, and the email reader from #246 when it exists. Mail-derived items set Source "email:<account>", Status "candidate" and Evidence to whatever makes the row reviewable; a candidate is inert until he confirms it on /tasks, and Maven names it as unconfirmed when she recites the list rather than putting words in his mouth. No new intent — the router enum is a contract with the relabelling prompt, so capture rides the note intent and the list rides a query source, both matched deterministically like the calendar and plan matchers already are. Nothing here speaks. No tick rule reads tasks; the list is answered when asked about, which is why /tasks POST is not step-up gated the way /tools and /routines are — a task write moves no boundary. Vikunja #130
48 lines
1.7 KiB
Go
48 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"strconv"
|
|
|
|
"github.com/kami/maven/internal/router"
|
|
)
|
|
|
|
// actionNote handles router.IntentNote: embed the note, persist it, and
|
|
// index it for recall.
|
|
func (h *reactiveHandler) actionNote(ctx context.Context, dec router.Decision) string {
|
|
// An utterance that explicitly files a task is work, not recall, and
|
|
// belongs in the task store (Vikunja #130). Checked before the embedding
|
|
// is paid for. Everything else is a note, exactly as before.
|
|
if reply, ok := h.captureTaskFromNote(ctx, dec); ok {
|
|
return reply
|
|
}
|
|
// embed the note text with the same model the classifier uses, persist
|
|
// via CoreAPI (source=tap:voice). Semantic recall lives in `notes`, not
|
|
// facts — no predicate reads it (spec's two-memory split).
|
|
vec, err := router.EmbedPassage(ctx, h.embedder, dec.Utterance)
|
|
if err != nil {
|
|
log.Printf("voice: embed note: %v", err)
|
|
return "не получилось сохранить заметку."
|
|
}
|
|
noteTs := h.now()
|
|
noteID, err := h.api.WriteNote(ctx, noteTs, dec.Utterance, vec, "tap:voice")
|
|
if err != nil {
|
|
log.Printf("voice: write note: %v", err)
|
|
return "не получилось сохранить заметку."
|
|
}
|
|
// Insert into long-term memory (best-effort, must not fail the note write).
|
|
// text/ts in the meta make a Search hit self-describing (see bestRecall).
|
|
if h.memStore != nil {
|
|
if err := h.memStore.Insert(ctx, "note:"+strconv.FormatInt(noteID, 10), vec, map[string]string{
|
|
"source": "voice",
|
|
"type": "note",
|
|
"text": dec.Utterance,
|
|
"ts": strconv.FormatInt(noteTs.Unix(), 10),
|
|
}); err != nil {
|
|
log.Printf("voice: memory insert: %v", err)
|
|
}
|
|
}
|
|
return "" // replier phrases the "saved" reply
|
|
}
|