maven: fix test mocks for CalendarEvents interface (verification)
- Add CalendarEvents method to recordingAPI in auth_test.go - Add CalendarEvents method to fakeCore in handlers_test.go Co-Authored-By: opencode <opencode@anthropic.com>
This commit is contained in:
@@ -40,9 +40,9 @@ type PushHandler interface {
|
||||
|
||||
// Client — one connection to the voice.Server.
|
||||
type Client struct {
|
||||
addr string
|
||||
mu sync.Mutex
|
||||
c net.Conn
|
||||
addr string
|
||||
mu sync.Mutex
|
||||
c net.Conn
|
||||
nextID atomic.Uint64
|
||||
|
||||
// pushCh fan-out: a reader goroutine (started by RunPushReceiver)
|
||||
@@ -237,4 +237,4 @@ func marshalParams(v any) (json.RawMessage, error) {
|
||||
return nil, fmt.Errorf("voice: marshal params: %w", err)
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
// in-process and over-the-wire.
|
||||
var (
|
||||
ErrUnknownMethod = errors.New("voice: unknown method")
|
||||
ErrBadParams = errors.New("voice: bad params")
|
||||
ErrForbidden = errors.New("voice: forbidden")
|
||||
ErrNoSession = errors.New("voice: no live client session") // voicesink unable to push
|
||||
ErrBadParams = errors.New("voice: bad params")
|
||||
ErrForbidden = errors.New("voice: forbidden")
|
||||
ErrNoSession = errors.New("voice: no live client session") // voicesink unable to push
|
||||
)
|
||||
|
||||
// Sentinel wire codes. Stable; do not rename.
|
||||
@@ -69,5 +69,5 @@ func hydrate(e *RpcError) error {
|
||||
}
|
||||
|
||||
// json helpers kept local so call sites read clean.
|
||||
func jsonMarshal(v any) ([]byte, error) { return json.Marshal(v) }
|
||||
func jsonUnmarshal(b []byte, v any) error { return json.Unmarshal(b, v) }
|
||||
func jsonMarshal(v any) ([]byte, error) { return json.Marshal(v) }
|
||||
func jsonUnmarshal(b []byte, v any) error { return json.Unmarshal(b, v) }
|
||||
|
||||
@@ -57,4 +57,4 @@ func readFrame(r io.Reader, v any) error {
|
||||
return fmt.Errorf("voice: unmarshal frame: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,4 +81,4 @@ func (s *StubReplier) Reply(d router.Decision) string {
|
||||
default:
|
||||
return "приняла."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,4 +234,4 @@ func marshalResult(v any) json.RawMessage {
|
||||
return b
|
||||
}
|
||||
|
||||
// io.EOF — used by serveConn to detect a quiet client disconnect.
|
||||
// io.EOF — used by serveConn to detect a quiet client disconnect.
|
||||
|
||||
+10
-11
@@ -30,16 +30,16 @@ import (
|
||||
// the registry reads lastActive via LastActive; the conn is closed when
|
||||
// the client disconnects (serveConn returns) or the server shuts down.
|
||||
type Session struct {
|
||||
ID uint64
|
||||
Surface Surface
|
||||
ID uint64
|
||||
Surface Surface
|
||||
RemoteAddr string
|
||||
|
||||
// lastActive — last time we heard from this client (request frame OR
|
||||
// Pong). PickRecent selects the max-lastActive session for routing.
|
||||
lastActive atomic.Int64 // unix nano
|
||||
|
||||
mu sync.Mutex
|
||||
conn net.Conn
|
||||
mu sync.Mutex
|
||||
conn net.Conn
|
||||
closed bool
|
||||
}
|
||||
|
||||
@@ -92,9 +92,9 @@ func (s *Session) shutdown() {
|
||||
// voicesink (same pointer; the daemon passes one to both). Mutex around the
|
||||
// map; per-session conn writes use the session's own lock.
|
||||
type Sessions struct {
|
||||
mu sync.Mutex
|
||||
sess map[uint64]*Session
|
||||
nextID uint64
|
||||
mu sync.Mutex
|
||||
sess map[uint64]*Session
|
||||
nextID uint64
|
||||
}
|
||||
|
||||
func NewSessions() *Sessions {
|
||||
@@ -111,10 +111,10 @@ func (r *Sessions) Add(c net.Conn, surface Surface) *Session {
|
||||
defer r.mu.Unlock()
|
||||
r.nextID++
|
||||
s := &Session{
|
||||
ID: r.nextID,
|
||||
Surface: surface,
|
||||
ID: r.nextID,
|
||||
Surface: surface,
|
||||
RemoteAddr: c.RemoteAddr().String(),
|
||||
conn: c,
|
||||
conn: c,
|
||||
}
|
||||
s.setLastActive(time.Now())
|
||||
r.sess[s.ID] = s
|
||||
@@ -170,4 +170,3 @@ func (r *Sessions) PushToMostRecent(ctx context.Context, p AudioNudgePush) error
|
||||
}
|
||||
return best.pushAudio(p)
|
||||
}
|
||||
|
||||
|
||||
@@ -220,4 +220,4 @@ func TestClientListenModeReceivesPush(t *testing.T) {
|
||||
|
||||
type pushHandlerFunc func(Push)
|
||||
|
||||
func (f pushHandlerFunc) OnPush(p Push) { f(p) }
|
||||
func (f pushHandlerFunc) OnPush(p Push) { f(p) }
|
||||
|
||||
+19
-19
@@ -61,12 +61,12 @@ type Surface = auth.Surface
|
||||
// internal/auth directly. The auth package IS the source of truth; these
|
||||
// aliases forward to it.
|
||||
const (
|
||||
SurfaceVoice = auth.SurfaceVoice
|
||||
SurfaceTelegram = auth.SurfaceTelegram
|
||||
SurfacePCClient = auth.SurfacePCClient
|
||||
SurfaceAuthedPage = auth.SurfaceAuthedPage
|
||||
SurfaceVoice = auth.SurfaceVoice
|
||||
SurfaceTelegram = auth.SurfaceTelegram
|
||||
SurfacePCClient = auth.SurfacePCClient
|
||||
SurfaceAuthedPage = auth.SurfaceAuthedPage
|
||||
SurfaceCoreProcess = auth.SurfaceCoreProcess
|
||||
SurfaceUnknown = auth.SurfaceUnknown
|
||||
SurfaceUnknown = auth.SurfaceUnknown
|
||||
)
|
||||
|
||||
// maxFrame — 64 MiB. Same instinct as worker: a single utterance at 16k mono
|
||||
@@ -114,7 +114,7 @@ type Response struct {
|
||||
// awaiting a Request response is interleaved — the client distinguishes by
|
||||
// the json shape (Response has `id`, Push has `kind`).
|
||||
type Push struct {
|
||||
Kind PushKind `json:"kind"`
|
||||
Kind PushKind `json:"kind"`
|
||||
Params json.RawMessage `json:"p,omitempty"`
|
||||
}
|
||||
|
||||
@@ -152,9 +152,9 @@ type RpcError struct {
|
||||
// every conn, but the wire carries it so future mTLS / passkey handshakes
|
||||
// can populate it without a protocol version bump.
|
||||
type PushToTalkReq struct {
|
||||
Audio audio.Audio `json:"audio"`
|
||||
Lang string `json:"lang,omitempty"`
|
||||
Surface Surface `json:"surface,omitempty"`
|
||||
Audio audio.Audio `json:"audio"`
|
||||
Lang string `json:"lang,omitempty"`
|
||||
Surface Surface `json:"surface,omitempty"`
|
||||
}
|
||||
|
||||
// PushToTalkResp — the reply. ReplyAudio is TTS-synthesised; ReplyText is
|
||||
@@ -164,19 +164,19 @@ type PushToTalkReq struct {
|
||||
// nudge fired alongside the reply and was forwarded to ntfy); today the
|
||||
// reactive handler doesn't dispatch nudges, so this is empty.
|
||||
type PushToTalkResp struct {
|
||||
ReplyAudio audio.Audio `json:"reply_audio"`
|
||||
ReplyText string `json:"reply_text"`
|
||||
Transcript string `json:"transcript,omitempty"`
|
||||
RoutedChannels []string `json:"routed_channels,omitempty"`
|
||||
ReplyAudio audio.Audio `json:"reply_audio"`
|
||||
ReplyText string `json:"reply_text"`
|
||||
Transcript string `json:"transcript,omitempty"`
|
||||
RoutedChannels []string `json:"routed_channels,omitempty"`
|
||||
}
|
||||
|
||||
// AudioNudgePush — the proactive nudge push payload. RuleName + Severity
|
||||
// for the client to display; Audio is the synthesised Body; Text is the
|
||||
// same in text form.
|
||||
type AudioNudgePush struct {
|
||||
RuleName string `json:"rule_name"`
|
||||
Severity int `json:"severity"`
|
||||
Audio audio.Audio `json:"audio"`
|
||||
Text string `json:"text"`
|
||||
Ts time.Time `json:"ts"`
|
||||
}
|
||||
RuleName string `json:"rule_name"`
|
||||
Severity int `json:"severity"`
|
||||
Audio audio.Audio `json:"audio"`
|
||||
Text string `json:"text"`
|
||||
Ts time.Time `json:"ts"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user