7f42cc73be
Seven fixes, each answering a line comment on the stack.
**Weather no longer invents Moscow** (PR 50). extractWeatherLocation returned
the string "Moscow" when he named no city and voice.weather.default_location
was unset — a made-up answer presented as fact, which is the one thing maven
must never do. It returns "" now and the query path says it does not know.
**Digest statuses are a defined type** (PR 50). DigestStatus string plus the
three constants, so a rule name cannot reach the status column.
**Quiet-mode negation is not adjacency** (PR 53). The OFF list carried
{"не","тих"}, an adjacency pattern, so "не надо тихий режим" missed OFF, hit
the ON pattern {"тих","режим"}, and asking for quiet mode to stop turned it
on. Negators are scanned over the whole utterance now, with the two ON phrases
that are themselves built on "не" excluded. "тихий режим выключи" works too,
which it did not before.
**Pattern stability uses a median band** (PR 54). max/min over the extremes
asked whether every gap resembles every other gap, so 7,7,7,7,20 — four clean
weeks and one holiday — was thrown away at a ratio of 2.9. Each interval is
now tested against the median and 70% must be in band, and the reported
interval is the median of the in-band ones, so a holiday no longer drags a
weekly habit to "every 9.6 days". The reviewer's 5,8,10,3 is still rejected.
**The weekday profile stops reciting everyday habits** (PR 59). "What do I do
on Saturdays?" answered "you drink water" — true, and useless, because it is
equally true of every other day. Activities that are habits on six or more
weekdays move to Profile.Everyday and are read back as daily habits instead of
as an answer about that day.
**Russian phrase tables move out of Go** (PR 59, PR 61). The behaviour glosses
and weekday names, and the task capture/urgency/list vocabulary, are now
behavior_ru.json and task_phrases.json, embedded with go:embed. Single-binary
deploy is unchanged; wording edits are no longer source diffs.
**nginx template stops taking nginx down** (PR 52). Two host-side failure
modes, both plausible causes of today's crash. The $connection_upgrade map is
fatal when duplicated, so it moved to its own nginx-upgrade-map.conf with a
grep-first note. And `listen 10.42.0.1:80` fails with EADDRNOTAVAIL when wg0
is not up yet, so nginx exits on a reboot that beats WireGuard — the header
now documents net.ipv4.ip_nonlocal_bind.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TrVSBKe3RFDF4fGYKWYQnX
60 lines
1.9 KiB
Go
60 lines
1.9 KiB
Go
package router
|
|
|
|
import (
|
|
_ "embed"
|
|
"encoding/json"
|
|
"fmt"
|
|
"sort"
|
|
)
|
|
|
|
// The task vocabulary lives in task_phrases.json, not in Go source. See the
|
|
// comment block inside that file for what each list means and why the entries
|
|
// that are NOT in it were left out.
|
|
//
|
|
// go:embed, so the single-binary deploy is unchanged: the JSON is compiled into
|
|
// mavend and there is nothing to install beside it. Parsed once at init; a
|
|
// malformed asset panics at startup rather than silently disabling task capture,
|
|
// which would look like the feature quietly not working.
|
|
|
|
//go:embed task_phrases.json
|
|
var taskPhrasesJSON []byte
|
|
|
|
type urgencyMarker struct {
|
|
Word string `json:"word"`
|
|
Weight int `json:"weight"`
|
|
}
|
|
|
|
type taskPhrases struct {
|
|
CapturePrefixes []string `json:"capture_prefixes"`
|
|
UrgencyMarkers []urgencyMarker `json:"urgency_markers"`
|
|
ListNouns []string `json:"list_nouns"`
|
|
ListShortcutNouns []string `json:"list_shortcut_nouns"`
|
|
}
|
|
|
|
var (
|
|
taskCapturePrefixes []string
|
|
urgencyMarkers []urgencyMarker
|
|
taskListWords []string
|
|
taskListWordsShortcut []string
|
|
)
|
|
|
|
func init() {
|
|
var v taskPhrases
|
|
if err := json.Unmarshal(taskPhrasesJSON, &v); err != nil {
|
|
panic(fmt.Sprintf("router: task_phrases.json: %v", err))
|
|
}
|
|
if len(v.CapturePrefixes) == 0 || len(v.ListNouns) == 0 {
|
|
panic("router: task_phrases.json: capture_prefixes and list_nouns must be non-empty")
|
|
}
|
|
// Strongest urgency first, so stripUrgency finds "срочно" before "важно"
|
|
// in an utterance carrying both. The file is written in that order already;
|
|
// sorting here means a careless edit cannot silently downgrade a task.
|
|
sort.SliceStable(v.UrgencyMarkers, func(i, j int) bool {
|
|
return v.UrgencyMarkers[i].Weight > v.UrgencyMarkers[j].Weight
|
|
})
|
|
taskCapturePrefixes = v.CapturePrefixes
|
|
urgencyMarkers = v.UrgencyMarkers
|
|
taskListWords = v.ListNouns
|
|
taskListWordsShortcut = v.ListShortcutNouns
|
|
}
|