Move the quiet-toggle and pattern-extraction slices out of voice.go (#321) #53

Closed
claude wants to merge 1 commits from overnight/split-voice-quiet into overnight/nginx-maven-block
Contributor

What

Continues the decomposition PR #50 started. cmd/mavend/voice.go 542 → 365 lines.

file lines moved
quiet_toggle.go 144 (new) resolveQuietToggle, quietInflections, quietStem, quietTokens, quietPhrase, quietOn/OffPhrases, classifyQuietToggle
patterns.go +44 detectPattern

quiet_toggle_test.go already existed for the first group, so the tests now sit next to their code. detectPattern goes to patterns.go because it exists to call detectAndPropose, and that file's header comment already pointed at it.

What remains in voice.go is the handler and nothing else: reactiveHandler, HandlePushToTalk, handleText, runTurn, applyAction, replySystem, chatHistory, reply.

Move-only check

All 133 distinct non-blank lines removed from voice.go were matched in the two destination files; zero lines added to voice.go. The only non-move edits are import lists (log added to patterns.go; unicode and internal/pattern dropped from voice.go) and two comments that pointed at voice.go for code that is no longer there.

No behaviour change, no new tests — the existing quiet_toggle_test.go, patterns_test.go and tick_test.go cover the moved code.

Verified

make build and make test (go test -race) exit 0. gofmt -l cmd/mavend/ clean.

Vikunja #321

## What Continues the decomposition PR #50 started. `cmd/mavend/voice.go` 542 → 365 lines. | file | lines | moved | |---|---|---| | `quiet_toggle.go` | 144 (new) | `resolveQuietToggle`, `quietInflections`, `quietStem`, `quietTokens`, `quietPhrase`, `quietOn/OffPhrases`, `classifyQuietToggle` | | `patterns.go` | +44 | `detectPattern` | `quiet_toggle_test.go` already existed for the first group, so the tests now sit next to their code. `detectPattern` goes to `patterns.go` because it exists to call `detectAndPropose`, and that file's header comment already pointed at it. What remains in `voice.go` is the handler and nothing else: `reactiveHandler`, `HandlePushToTalk`, `handleText`, `runTurn`, `applyAction`, `replySystem`, `chatHistory`, `reply`. ## Move-only check All 133 distinct non-blank lines removed from `voice.go` were matched in the two destination files; zero lines added to `voice.go`. The only non-move edits are import lists (`log` added to `patterns.go`; `unicode` and `internal/pattern` dropped from `voice.go`) and two comments that pointed at `voice.go` for code that is no longer there. No behaviour change, no new tests — the existing `quiet_toggle_test.go`, `patterns_test.go` and `tick_test.go` cover the moved code. ## Verified `make build` and `make test` (go test -race) exit 0. `gofmt -l cmd/mavend/` clean. Vikunja #321
claude added 1 commit 2026-07-31 23:30:21 +02:00
Continues the decomposition PR #50 started. voice.go 542 -> 365:

  quiet_toggle.go  144  resolveQuietToggle, quietInflections, quietStem,
                        quietTokens, quietPhrase, quietOn/OffPhrases,
                        classifyQuietToggle  (quiet_toggle_test.go already
                        existed for these)
  patterns.go     +44  detectPattern, next to detectAndPropose which it calls
                        and which patterns.go's own header already pointed at

What is left in voice.go is the handler: reactiveHandler, HandlePushToTalk,
handleText, runTurn, applyAction, replySystem, chatHistory, reply.

Move-only: all 133 distinct non-blank lines removed from voice.go were
matched in the two destination files, zero lines added to voice.go. The only
non-move edits are import lists (log added to patterns.go, unicode and
internal/pattern dropped from voice.go) and two comments that pointed at
voice.go for code that is no longer there.
kami reviewed 2026-08-01 10:01:47 +02:00
@@ -0,0 +49,4 @@
// what separates "тихий"/"тихом"/"тихо" (stem "тих" + a real ending) from
// "тихонько"/"потихоньку", which are different words: "онько" is not an
// ending, and "потихоньку" doesn't start with the stem at all.
var quietInflections = []string{
Owner

looks like a work-around.
a lot of those don't even work together.

looks like a work-around. a lot of those don't even work together.
kami reviewed 2026-08-01 10:03:02 +02:00
@@ -0,0 +110,4 @@
}
// quietOffPhrases / quietOnPhrases — the toggle vocabulary, as stem sequences.
var (
Owner

also feels like workaround which won't work as intended.

also feels like workaround which won't work as intended.
claude reviewed 2026-08-01 11:22:36 +02:00
claude left a comment
Author
Contributor

The extraction is clean, and quiet_toggle.go is better than the code it moved. Tokenising instead of reaching for \b is the right call. The comment explaining why Go's \b cannot see Cyrillic word boundaries is the kind of note that stops a rewrite into a regexp next year.

Your {"не","тих"} catch is fixed on the tip branch at 7f42cc7. Negators are now scanned across the whole utterance rather than as an adjacent pair, so "не надо тихий режим" reaches OFF. This diff still shows the adjacency version.

One thing left, on the same function.

Every quiet toggle is written with Source: "tap:voice", even the ones that never touched a microphone. resolveQuietToggle runs inside runTurn. The doc comment above it says so: mavweb /api/chat and telegram reach it too. So a toggle typed into the web UI lands in the facts table claiming the microphone wrote it. That matters here. This function is the one the comment itself calls "a network-reachable way to flip a daemon-wide setting". When you go looking at why quiet mode is on, provenance is the first column you read. Thread the channel through, or write "tap:text" from the text entry point.

Two notes, neither needing a change:

  • The whole-utterance rule for {"тих"} is the same intuition that misfires on "поужинал" in the clarify gate. Here it is correct. Bare "тихо" is a command, "в комнате тихо" is a remark. One-word patterns are the case where the rule holds.
  • quietInflections applies to every stem, so "не" also matches "ней" and "нем". Harmless with the current phrase list, since both words only count paired with a quiet stem. Worth remembering if a single-word negator ever joins the list.
The extraction is clean, and `quiet_toggle.go` is better than the code it moved. Tokenising instead of reaching for `\b` is the right call. The comment explaining why Go's `\b` cannot see Cyrillic word boundaries is the kind of note that stops a rewrite into a regexp next year. Your `{"не","тих"}` catch is fixed on the tip branch at `7f42cc7`. Negators are now scanned across the whole utterance rather than as an adjacent pair, so "не надо тихий режим" reaches OFF. This diff still shows the adjacency version. One thing left, on the same function. **Every quiet toggle is written with `Source: "tap:voice"`, even the ones that never touched a microphone.** `resolveQuietToggle` runs inside `runTurn`. The doc comment above it says so: mavweb `/api/chat` and telegram reach it too. So a toggle typed into the web UI lands in the facts table claiming the microphone wrote it. That matters here. This function is the one the comment itself calls "a network-reachable way to flip a daemon-wide setting". When you go looking at why quiet mode is on, provenance is the first column you read. Thread the channel through, or write "tap:text" from the text entry point. Two notes, neither needing a change: - The whole-utterance rule for `{"тих"}` is the same intuition that misfires on `"поужинал"` in the clarify gate. Here it is correct. Bare "тихо" is a command, "в комнате тихо" is a remark. One-word patterns are the case where the rule holds. - `quietInflections` applies to every stem, so `"не"` also matches "ней" and "нем". Harmless with the current phrase list, since both words only count paired with a quiet stem. Worth remembering if a single-word negator ever joins the list.
kami closed this pull request 2026-08-01 14:51:38 +02:00
Owner

Landed on master. The stack was one linear chain, so #84 carried every commit from #50 up, and master now contains this branch in full. Merging this PR on its own is an empty diff, so it is closed rather than merged. The review findings for it were fixed in the 2026-08-01 pass and are on master as commits on the stack tip, not on this branch.

Landed on master. The stack was one linear chain, so #84 carried every commit from #50 up, and master now contains this branch in full. Merging this PR on its own is an empty diff, so it is closed rather than merged. The review findings for it were fixed in the 2026-08-01 pass and are on master as commits on the stack tip, not on this branch.

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kami/Maven#53