Repository navigation
fix: keep Prometheus and rule-carrying structs out of the layers - #1
Merged
Merged
Conversation
No change in behaviour; the release brings the deployed code in line with main. - Metrics: httpapi defines the Recorder it needs; the Prometheus counters and the /metrics handler move to the adapter internal/metrics. - httpapi.New takes the Speaker and the WAV Encoder as parameters, the logger, Recorder and metrics handler as functional options, instead of an exported Options struct. - speech.Request becomes the value speech.Text (ParseText: not blank, at most 4096 characters), which prints redacted; Speak(ctx, text, speed). - speech.Settings becomes parameters of NewService (voices, fallback, rate) and options WithMinConfidence, WithMinWords, WithPause. - wav.Encoder is an exported interface with an unexported implementation. - app holds its parts; serve builds the HTTP handler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
subpathdev
commented
Nov 29, 2026
subpathdev
commented
Nov 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Review of v0.1.0 against the Go conventions: the transport used Prometheus directly, and three exported structs carried rules (
httpapi.Options,speech.Settings,speech.Request). The behaviour doesn't change. Merging releases 0.1.1 (fix:), so the deployed code matchesmain; smart-home#114 then bumps the chart tag to 0.1.1.What
httpapi.Recorder(Spoken,Rejected,TimedOut,Failed) is defined by the handlers. The new adapterinternal/metricsimplements it with Prometheus (exported interfaceMetrics, unexported implementation,New(), its own registry) and serves/metrics. Metric names and labels are unchanged.httpapi.Options.New(svc Speaker, wav Encoder, opts ...Option);WithLogger,WithRecorder,WithMetrics(http.Handler). Without options: no logs, nothing counted, no/metrics.speech.Textinstead ofspeech.Request. An opaque value made byParseText(not blank, at most 4096 characters). It prints redacted (String,GoString), and only packagespeechreads the content.Speak(ctx, text, speed).speech.Settings.NewService(detector, synthesizer, voices, fallback, rate, opts...);WithMinConfidence(0.7),WithMinWords(3),WithPause(150 ms), with their ranges checked inNewService. The confidence threshold stays afloat64: 0 is a valid threshold, so a value type would have no zero value to reject.wav.Encoderis an exported interface with an unexported implementation (wav.New()).appholds its parts (config, service, encoder, metrics, logger);servebuilds the HTTP handler.speech.Guess,Utterance,Segment,Speech, andconfig.Config(checked byLoad).How to validate
Already done:
go vet ./...andgo test -race ./...pass. New tests: themetricsadapter against a real scrape, the handlers against a fakeRecorder(one call per outcome), handler defaults without options,ParseTextincluding redaction under%v/%+v/%#v, andNewServicechecks and defaults. The end-to-end test also reads/metrics.After merge: CI releases v0.1.1. Then the voice-router pod in smart-home (chart 0.1.1) logs
"segments":"de,en"for a mixed request, andvoice_router_*shows up in Prometheus.Risk
The refactor could have changed behaviour by mistake. The unchanged end-to-end and handler tests cover the API (formats, errors, logs without text), the speaches calls and the metric names. Blast radius: Open WebUI's read aloud.
Rollback
Pin smart-home back to chart 0.1.0 (same behaviour), or undo the change in a
fix:commit so svu releases a patch. A plaingit revertcommit has no conventional type, so svu would not release it.🤖 Generated with Claude Code