From 0ec48f1662dc86d63fd2ab3f5b23bcc848f59bd9 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Mon, 16 Nov 2026 22:44:36 -0500 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Betty=20speaks=20ready=20answer?= =?UTF-8?q?s=20shortest=20first=20and=20moves=20a=20long=20voice=20queue?= =?UTF-8?q?=20to=20chat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quorum's say queues clips and plays them in order, so hive keeps an estimate of the queued speech. Spoken answers ready in the same loop turn are said back to back, shortest first; one that would wait behind more than 20 s goes to chat with one spoken "I've put the rest in chat"; an ack behind more than 8 s of speech is skipped. Answers to addressed requests may take meetings.chat_answer_burst (3) extra chat posts a minute past the chat rate. Part of #18590. Signed-off-by: Andy Anderson --- changelog.d/added-18590-betty-voice-queue.md | 1 + src/cmd/hive/meetingswire.go | 1 + src/docs/meetings.md | 4 +- src/pkg/config/meetings_config.go | 16 ++ src/pkg/meetings/betty/overflow.go | 29 ++++ src/pkg/meetings/live/policy.go | 15 +- src/pkg/meetings/live/session.go | 19 ++- src/pkg/meetings/live/voicequeue.go | 166 +++++++++++++++++++ src/pkg/meetings/live/voicequeue_test.go | 130 +++++++++++++++ 9 files changed, 375 insertions(+), 6 deletions(-) create mode 100644 changelog.d/added-18590-betty-voice-queue.md create mode 100644 src/pkg/meetings/betty/overflow.go create mode 100644 src/pkg/meetings/live/voicequeue.go create mode 100644 src/pkg/meetings/live/voicequeue_test.go diff --git a/changelog.d/added-18590-betty-voice-queue.md b/changelog.d/added-18590-betty-voice-queue.md new file mode 100644 index 0000000000..c208d4f9ef --- /dev/null +++ b/changelog.d/added-18590-betty-voice-queue.md @@ -0,0 +1 @@ +- **Betty speaks several ready answers back to back, shortest first, and moves the rest to chat.** Spoken answers ready together no longer wait behind a long one; an answer that would wait behind more than 20 s of queued speech goes to chat with a spoken "I've put the rest in chat.", and a stale acknowledgement is skipped. Answers to addressed requests may take `meetings.chat_answer_burst` (default 3) extra chat posts a minute beyond `meetings.chat_posts_per_minute`, so parallel answers are not held for a minute. ([#18590](https://github.com/hivecommons/hive/issues/18590)) diff --git a/src/cmd/hive/meetingswire.go b/src/cmd/hive/meetingswire.go index b14aaef683..8142d1677d 100644 --- a/src/cmd/hive/meetingswire.go +++ b/src/cmd/hive/meetingswire.go @@ -221,6 +221,7 @@ func wireMeetingsLive(cfg *config.Config, mgr *meetings.Manager, store *meetings Notes: notes, Policy: live.Policy{ ChatPostsPerMinute: m.ChatPostsPerMinuteOrDefault(), + ChatAnswerBurst: m.ChatAnswerBurstOrDefault(), ResearchPerMeeting: m.ResearchPerMeetingOrDefault(), VoiceOnAddress: m.VoiceOnAddressEnabled(), MaxTokensPerMeeting: m.Budget.MaxTokensPerMeetingOrDefault(), diff --git a/src/docs/meetings.md b/src/docs/meetings.md index a9ae7b1bbd..aa81a57db2 100644 --- a/src/docs/meetings.md +++ b/src/docs/meetings.md @@ -36,7 +36,8 @@ Hive attends meetings as a persona: **Betty** ("Betty Bee from the hive", she/he - **Questions about the hive itself.** "How many open issues are there?", "what PRs are open in the hive repo?", "which agents are working?" are answered from the hive's live dashboard state (the same open, actionable, held and blocked counts, agents and open PRs the Overview and the dashboard chat use), read in-process, so the answer comes in seconds and never goes to research. Such a question names the hive (or "the repo") or asks for open issues, open PRs, actionable items or recent merges. - **Deep dives.** When an addressed question needs research (the model sets `needs_research`, or its confidence is below `min_confidence`) and the meeting has a research path, she says "I'll dig into that and report back", starts a research item through the same pool, cap and approval as Spek's research (shown in the panel as `betty-N`, dispatched with `betty=1` in its meta), and posts exactly one follow-up in her own voice when it completes (the summary as is if restyling fails). - **Room questions.** Betty also answers questions people ask the room (a line ending in "?" or starting with "what", "how", "who" and the like, four words or more), but only if nobody answers within `answer_wait_s` (8 seconds), the knowledge sources had a hit, the model is at least `min_confidence` (0.75) sure, and the topic was not already answered. She never posts general commentary. -- **Caps.** Unprompted answers are capped at `per_10m` (2 per ten minutes), at least `min_gap_s` (90 seconds) apart and `per_meeting` (12) per meeting, with one reply per question, at most `queue_depth` (3) questions waiting and none older than `stale_s` (60 seconds). Addressed requests skip these caps but still go through the chat rate limit (`meetings.chat_posts_per_minute`) and the meeting budget. Chat answers are at most 3 sentences and 300 characters. +- **Caps.** Unprompted answers are capped at `per_10m` (2 per ten minutes), at least `min_gap_s` (90 seconds) apart and `per_meeting` (12) per meeting, with one reply per question, at most `queue_depth` (3) questions waiting and none older than `stale_s` (60 seconds). Addressed requests skip these caps but still go through the chat rate limit (`meetings.chat_posts_per_minute`) and the meeting budget; once that rate is spent, answers to addressed requests may take `meetings.chat_answer_burst` (3) more posts a minute, so answers worked on in parallel are not held for a minute. +- **Several spoken answers.** Quorum queues each spoken clip and plays them in order, so she never talks over herself; hive estimates the queued speech (about 15 characters a second). Spoken answers that are ready together are said back to back, shortest first. An answer that would wait behind more than 20 s of queued speech is posted to chat instead, and she says "I've put the rest in chat." (at most once every 30 s). An acknowledgement that would play only after more than 8 s of earlier speech is skipped. Chat answers are at most 3 sentences and 300 characters. - **Spek.** With Betty on, Spek's spoken replies are dropped, Spek's chat posts go through Betty (posted unless she already covered the topic, so the meeting never gets two answers), and Spek's clarifying questions are reworded in Betty's voice with one quick model call (800 ms; on failure or timeout the original text is posted). The rewording runs beside the meeting loop, so the transcript, notes and other replies keep flowing; Spek's later questions and chat posts wait their turn so they still appear in Spek's order. Notes and research are unchanged. Lines addressed to Betty and leave phrases never count as answers to Spek's questions. - **Manners.** Plain, brief language; at most one light touch of humor, never about a person and none when the conversation sounds tense. Set `meetings.persona.humor: off` to turn humor off. Meeting speech, knowledge and work items reach the model as data, never as instructions. She never claims to have done something she did not do. - **Model.** Betty answers with the meetings model through the same path as `hive meeting-llm` (an OpenAI-compatible endpoint, charged to the meeting's usage ledger and budget). On a hive with only an Anthropic key (`HIVE_MEETINGS_ANTHROPIC_API_KEY` or `meetings.llm.anthropic_key_file`) she calls the Anthropic Messages API directly with `meetings.llm.model` (default `claude-haiku-5-5`), with the same timeouts, in-flight limit and usage ledger, so her tokens count toward the meeting's budget. With no model she still introduces herself but says she cannot answer questions. With `meetings.llm.mode: agent-backend` (or `claude-cli`) she answers through one of the hive's agent backends instead; see [Agent backends](#agent-backends). @@ -306,6 +307,7 @@ Every key has an environment override that wins over `hive.yaml`. The full list | `meetings.research_pool_size` | `2` | Research agents (`research-1..N`). | | `meetings.research_per_meeting` | `5` | Research items per meeting before approval is needed. | | `meetings.chat_posts_per_minute` | `6` | Chat post rate limit per meeting. | +| `meetings.chat_answer_burst` | `3` | Extra chat posts a minute for Betty's answers to requests addressed to her, once the rate limit is spent (`HIVE_MEETINGS_CHAT_ANSWER_BURST`). | | `meetings.lobby_timeout_s` | `600` | Seconds to wait in a lobby. | | `meetings.budget.max_tokens_per_meeting` | `200000` | LLM tokens per meeting (when Spek reports usage). | | `meetings.budget.max_tokens_per_hour` | `500000` | Hive-wide hourly ceiling. | diff --git a/src/pkg/config/meetings_config.go b/src/pkg/config/meetings_config.go index 3fa746bb35..22acf49c1d 100644 --- a/src/pkg/config/meetings_config.go +++ b/src/pkg/config/meetings_config.go @@ -54,6 +54,9 @@ const ( // DefaultMeetingsChatPostsPerMinute caps hive's chat posts into one // meeting. DefaultMeetingsChatPostsPerMinute = 6 + // DefaultMeetingsChatAnswerBurst is the extra posts a minute addressed + // answers may take. + DefaultMeetingsChatAnswerBurst = 3 // DefaultMeetingsLobbyTimeoutS is how long hive waits in a meeting // lobby before it gives up and leaves. DefaultMeetingsLobbyTimeoutS = 600 @@ -128,6 +131,7 @@ const ( MeetingsResearchPoolSizeEnv = "HIVE_MEETINGS_RESEARCH_POOL_SIZE" MeetingsResearchPerMeetingEnv = "HIVE_MEETINGS_RESEARCH_PER_MEETING" MeetingsChatPostsPerMinuteEnv = "HIVE_MEETINGS_CHAT_POSTS_PER_MINUTE" + MeetingsChatAnswerBurstEnv = "HIVE_MEETINGS_CHAT_ANSWER_BURST" MeetingsLobbyTimeoutEnv = "HIVE_MEETINGS_LOBBY_TIMEOUT_S" MeetingsRetentionDaysEnv = "HIVE_MEETINGS_RETENTION_DAYS" MeetingsConsentTextEnv = "HIVE_MEETINGS_CONSENT_TEXT" @@ -182,6 +186,11 @@ type MeetingsConfig struct { // ChatPostsPerMinute caps hive's chat posts into one meeting. Zero or // negative means the default. ChatPostsPerMinute int `yaml:"chat_posts_per_minute,omitempty" json:"chat_posts_per_minute,omitempty"` + // ChatAnswerBurst is how many extra chat posts a minute the persona's + // answers to requests addressed to her may take beyond + // ChatPostsPerMinute, so parallel answers are not held for a minute + // (#18590). Zero or negative means the default. + ChatAnswerBurst int `yaml:"chat_answer_burst,omitempty" json:"chat_answer_burst,omitempty"` // LobbyTimeoutS is how long hive waits in a lobby. Zero or negative // means the default. LobbyTimeoutS int `yaml:"lobby_timeout_s,omitempty" json:"lobby_timeout_s,omitempty"` @@ -581,6 +590,12 @@ func (m MeetingsConfig) ChatPostsPerMinuteOrDefault() int { return meetingsEnvInt(MeetingsChatPostsPerMinuteEnv, m.ChatPostsPerMinute, DefaultMeetingsChatPostsPerMinute) } +// ChatAnswerBurstOrDefault returns the extra chat posts a minute addressed +// persona answers may take. +func (m MeetingsConfig) ChatAnswerBurstOrDefault() int { + return meetingsEnvInt(MeetingsChatAnswerBurstEnv, m.ChatAnswerBurst, DefaultMeetingsChatAnswerBurst) +} + // LobbyTimeoutSOrDefault returns the lobby timeout in seconds. func (m MeetingsConfig) LobbyTimeoutSOrDefault() int { return meetingsEnvInt(MeetingsLobbyTimeoutEnv, m.LobbyTimeoutS, DefaultMeetingsLobbyTimeoutS) @@ -742,6 +757,7 @@ func (m MeetingsConfig) Validate() error { {"meetings.research_pool_size", m.ResearchPoolSize}, {"meetings.research_per_meeting", m.ResearchPerMeeting}, {"meetings.chat_posts_per_minute", m.ChatPostsPerMinute}, + {"meetings.chat_answer_burst", m.ChatAnswerBurst}, {"meetings.lobby_timeout_s", m.LobbyTimeoutS}, {"meetings.retention_days", m.RetentionDays}, {"meetings.budget.max_tokens_per_meeting", m.Budget.MaxTokensPerMeeting}, diff --git a/src/pkg/meetings/betty/overflow.go b/src/pkg/meetings/betty/overflow.go new file mode 100644 index 0000000000..1f8b7df428 --- /dev/null +++ b/src/pkg/meetings/betty/overflow.go @@ -0,0 +1,29 @@ +package betty + +import "strings" + +// restInChat is what she says when her spoken answers would queue too long +// and the rest went to chat (hivecommons/hive#18590), by primary language +// subtag; English is the fallback. +var restInChat = map[string]string{ + "en": "I've put the rest in chat.", + "es": "El resto lo dejé en el chat.", + "fr": "J'ai mis la suite dans le chat.", + "de": "Den Rest habe ich in den Chat geschrieben.", + "pt": "Coloquei o resto no chat.", + "it": "Il resto l'ho scritto in chat.", +} + +// RestInChatText is the spoken note for answers moved to chat, in the +// persona's language. +func (e *Engine) RestInChatText() string { + if t, ok := restInChat[primaryTag(e.s.Persona.Language)]; ok { + return t + } + return restInChat["en"] +} + +// primaryTag is a BCP-47 tag's primary language subtag ("en-GB" is "en"). +func primaryTag(lang string) string { + return strings.ToLower(strings.SplitN(strings.TrimSpace(lang), "-", 2)[0]) +} diff --git a/src/pkg/meetings/live/policy.go b/src/pkg/meetings/live/policy.go index 247b58845a..890fed7d13 100644 --- a/src/pkg/meetings/live/policy.go +++ b/src/pkg/meetings/live/policy.go @@ -24,7 +24,11 @@ const ( // Policy is the per-meeting policy configuration. type Policy struct { - ChatPostsPerMinute int + ChatPostsPerMinute int + // ChatAnswerBurst is the extra chat posts a minute the persona's + // answers to addressed requests may take once ChatPostsPerMinute is + // spent; zero means none. + ChatAnswerBurst int ResearchPerMeeting int VoiceOnAddress bool MaxTokensPerMeeting int @@ -32,6 +36,15 @@ type Policy struct { AnswerWindow time.Duration } +// answerBurst is the extra chat room for addressed answers: none when the +// chat rate is unlimited or no burst is set. +func answerBurst(p Policy) rateLimiter { + if p.ChatPostsPerMinute <= 0 || p.ChatAnswerBurst <= 0 { + return rateLimiter{} + } + return rateLimiter{n: p.ChatAnswerBurst, window: rateWindow} +} + func (p Policy) withDefaults() Policy { if p.AnswerWindow <= 0 { p.AnswerWindow = DefaultAnswerWindow diff --git a/src/pkg/meetings/live/session.go b/src/pkg/meetings/live/session.go index 36ecaad3da..3407d485f0 100644 --- a/src/pkg/meetings/live/session.go +++ b/src/pkg/meetings/live/session.go @@ -69,6 +69,10 @@ type session struct { spek Spek state State rate rateLimiter + // burst is the extra chat room for answers to addressed requests; + // voice is the estimate of queued speech (voicequeue.go). + burst rateLimiter + voice voiceQueue // persona is the meeting's attendee persona, nil when it is off. With // it on, it owns the bot's voice in the meeting: Spek's say intents are // dropped, its chat posts are offered to the persona, and its @@ -95,6 +99,7 @@ func (r *Runner) newSession(m meetings.Meeting, spek Spek) *session { s := &session{ r: r, id: m.ID, spek: spek, rate: rateLimiter{n: r.opts.Policy.ChatPostsPerMinute, window: rateWindow}, + burst: answerBurst(r.opts.Policy), updates: make(chan meetings.Update, sessionInbox), signals: make(chan ResearchSignal, sessionInbox), approves: make(chan approveReq), @@ -171,6 +176,7 @@ func (s *session) run(ctx context.Context) { case rep := <-replies: if !ending { s.onPersonaReply(ctx, rep) + s.drainPersona(ctx, replies) } case <-ctx.Done(): s.spek.Close(nil) @@ -706,7 +712,7 @@ func (s *session) onPersonaReply(ctx context.Context, rep betty.Reply) { if s.state.BudgetExhausted { return } - if s.speak(ctx, text) { + if s.speakAck(ctx, text) { s.emitPersona(rep) } else { s.drop("ack_no_voice") @@ -729,9 +735,14 @@ func (s *session) onPersonaReply(ctx context.Context, rep betty.Reply) { return } posted := true - if rep.Kind == betty.KindVoice { - s.say(ctx, text) - } else { + switch { + case rep.Kind == betty.KindVoice: + // Spoken with the other answers ready now, shortest first + // (flushVoice), falling back to chat. + s.queueVoice(text) + case rep.Trigger == betty.TriggerAddressed: + posted = s.postAnswer(ctx, text) + default: posted = s.post(ctx, text) } if posted { diff --git a/src/pkg/meetings/live/voicequeue.go b/src/pkg/meetings/live/voicequeue.go new file mode 100644 index 0000000000..25ae2e318c --- /dev/null +++ b/src/pkg/meetings/live/voicequeue.go @@ -0,0 +1,166 @@ +package live + +import ( + "context" + "sort" + "time" + "unicode/utf8" + + "github.com/hivecommons/hive/pkg/meetings/betty" +) + +// Spoken answers when several are ready (hivecommons/hive#18590). Quorum's +// say returns once the clip is queued and plays clips in call order, so +// she never talks over herself, but hive cannot see when she stops +// talking. The session keeps an estimate of the queued speech instead and +// uses it to: +// +// - speak answers that are ready together back to back, shortest first, +// so the quick ones are not held behind a long one; +// - move answers to chat once the queued speech would pass +// voiceBacklogMax, with one spoken "I've put the rest in chat"; +// - skip an acknowledgement that would only play after seconds of +// earlier speech, when it no longer acknowledges anything promptly. +const ( + // voiceCharsPerSecond is the speaking rate the estimate assumes, about + // 160 words a minute. + voiceCharsPerSecond = 15 + // voiceMinClip is the least a clip is assumed to take (synthesis and + // the pauses around it). + voiceMinClip = time.Second + // voiceBacklogMax is the most queued speech an answer may wait behind; + // later answers go to chat. + voiceBacklogMax = 20 * time.Second + // ackMaxBacklog is the most queued speech an acknowledgement may wait + // behind: past it the ack would land seconds after the request, about + // when the answer itself is due. + ackMaxBacklog = 8 * time.Second + // restInChatGap is the least time between two "rest in chat" notes. + restInChatGap = 30 * time.Second + // maxReplyDrain bounds the ready replies one turn of the session loop + // takes together. + maxReplyDrain = 16 +) + +// speechTime estimates how long text takes to say. +func speechTime(text string) time.Duration { + d := time.Duration(utf8.RuneCountInString(text)) * time.Second / voiceCharsPerSecond + return max(d, voiceMinClip) +} + +// voiceQueue is the session's estimate of its queued speech. +type voiceQueue struct { + busyUntil time.Time + // restNoted is when "the rest is in chat" was last said. + restNoted time.Time + // pending are spoken answers ready this turn, flushed together. + pending []voiceAnswer +} + +// voiceAnswer is one spoken answer waiting for the flush. +type voiceAnswer struct { + text string + seq int +} + +// backlog is the speech still queued at now. +func (v *voiceQueue) backlog(now time.Time) time.Duration { + if v.busyUntil.After(now) { + return v.busyUntil.Sub(now) + } + return 0 +} + +// queued records a clip handed to the meeting at now. +func (v *voiceQueue) queued(now time.Time, text string) { + start := now + if v.busyUntil.After(now) { + start = v.busyUntil + } + v.busyUntil = start.Add(speechTime(text)) +} + +// drainPersona applies every further reply that is ready now, then speaks +// the spoken answers they produced together. +func (s *session) drainPersona(ctx context.Context, replies <-chan betty.Reply) { + defer s.flushVoice(ctx) + for range maxReplyDrain { + select { + case rep := <-replies: + s.onPersonaReply(ctx, rep) + default: + return + } + } +} + +// queueVoice holds a spoken answer for the flush. +func (s *session) queueVoice(text string) { + s.voice.pending = append(s.voice.pending, voiceAnswer{text: text, seq: len(s.voice.pending)}) +} + +// flushVoice speaks the ready answers shortest first; once the queued +// speech would pass voiceBacklogMax the rest go to chat, with one spoken +// note saying so. An answer that cannot be spoken falls back to chat as +// before. +func (s *session) flushVoice(ctx context.Context) { + batch := s.voice.pending + s.voice.pending = nil + if len(batch) == 0 { + return + } + sort.SliceStable(batch, func(i, j int) bool { + return utf8.RuneCountInString(batch[i].text) < utf8.RuneCountInString(batch[j].text) + }) + moved := false + for _, a := range batch { + now := s.now() + if b := s.voice.backlog(now); b > 0 && b+speechTime(a.text) > voiceBacklogMax { + s.postAnswer(ctx, a.text) + moved = true + continue + } + if s.speak(ctx, a.text) { + s.voice.queued(now, a.text) + continue + } + s.log().Info("[meetings] voice unavailable; answering in chat") + s.postAnswer(ctx, a.text) + } + if moved && s.persona != nil { + now := s.now() + if s.voice.restNoted.IsZero() || now.Sub(s.voice.restNoted) >= restInChatGap { + note := s.persona.RestInChatText() + if s.speak(ctx, note) { + s.voice.queued(now, note) + s.voice.restNoted = now + } + } + } +} + +// speakAck says an acknowledgement unless it would wait behind seconds of +// earlier speech; it reports whether it was spoken. +func (s *session) speakAck(ctx context.Context, text string) bool { + now := s.now() + if s.voice.backlog(now) > ackMaxBacklog { + return false + } + if !s.speak(ctx, text) { + return false + } + s.voice.queued(now, text) + return true +} + +// postAnswer posts one of the persona's answers to an addressed request: +// through the chat rate limit, and once that is spent through the small +// answer burst, so parallel answers are not held for a minute. +func (s *session) postAnswer(ctx context.Context, text string) bool { + now := s.now() + if !s.rate.allow(now) && (s.burst.n <= 0 || !s.burst.allow(now)) { + s.drop("rate_limited") + return false + } + return s.deliver(ctx, text) +} diff --git a/src/pkg/meetings/live/voicequeue_test.go b/src/pkg/meetings/live/voicequeue_test.go new file mode 100644 index 0000000000..f1d214b30a --- /dev/null +++ b/src/pkg/meetings/live/voicequeue_test.go @@ -0,0 +1,130 @@ +package live + +import ( + "context" + "strings" + "sync" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/config" + "github.com/hivecommons/hive/pkg/meetings" + "github.com/hivecommons/hive/pkg/meetings/betty" +) + +type stepClock struct { + mu sync.Mutex + now time.Time +} + +func (c *stepClock) Now() time.Time { c.mu.Lock(); defer c.mu.Unlock(); return c.now } +func (c *stepClock) add(d time.Duration) { + c.mu.Lock() + c.now = c.now.Add(d) + c.mu.Unlock() +} + +// voiceSession is a session (not running) on a meeting with voice on and a +// controllable clock, for driving the voice queue directly. +func voiceSession(t *testing.T, p Policy) (*harness, *session, *stepClock) { + t.Helper() + clk := &stepClock{now: time.Date(2026, 11, 16, 9, 0, 0, 0, time.UTC)} + h := newHarness(t, p, func(o *Options) { + o.Now = clk.Now + o.Persona = func(meetings.Meeting) *betty.Engine { + return betty.New(betty.SettingsFrom(config.MeetingsPersonaConfig{}.Resolve()), betty.Deps{}) + } + }) + h.m.VoiceEnabled = true + h.mt.m[h.m.ID] = h.m + return h, h.r.newSession(h.m, h.spek), clk +} + +// Answers ready together are spoken shortest first; one that would wait +// behind more than voiceBacklogMax of speech goes to chat, with one spoken +// note. +func TestFlushVoiceShortestFirstAndOverflow(t *testing.T) { + h, s, _ := voiceSession(t, Policy{ChatPostsPerMinute: 6, VoiceOnAddress: true}) + short := "It ships Friday." + mid := strings.Repeat("m", 150) // 10 s + long := strings.Repeat("l", 200) // about 13 s + s.queueVoice(long) + s.queueVoice(short) + s.queueVoice(mid) + s.flushVoice(context.Background()) + posts, says := h.mt.got() + want := []string{short, mid, "I've put the rest in chat."} + if strings.Join(says, "|") != strings.Join(want, "|") { + t.Fatalf("says %q, want %q", says, want) + } + if len(posts) != 1 || posts[0] != long { + t.Fatalf("posts %q, want the long answer in chat", posts) + } + if len(s.voice.pending) != 0 { + t.Fatal("the flush leaves nothing pending") + } +} + +// An acknowledgement is skipped behind more than ackMaxBacklog of queued +// speech, and spoken again once it has played. +func TestAckSkippedBehindLongSpeech(t *testing.T) { + _, s, clk := voiceSession(t, Policy{ChatPostsPerMinute: 6, VoiceOnAddress: true}) + ctx := context.Background() + s.queueVoice(strings.Repeat("x", 180)) // 12 s + s.flushVoice(ctx) + if s.speakAck(ctx, "One moment.") { + t.Fatal("an ack behind 12 s of speech is skipped") + } + clk.add(10 * time.Second) + if !s.speakAck(ctx, "One moment.") { + t.Fatal("an ack behind 2 s of speech is spoken") + } +} + +// Answers to addressed requests may take a small burst past the chat rate; +// Spek's posts may not. +func TestAnswerBurstPastChatRate(t *testing.T) { + h, s, _ := voiceSession(t, Policy{ChatPostsPerMinute: 1, ChatAnswerBurst: 3}) + ctx := context.Background() + if !s.post(ctx, "spek one") { + t.Fatal("first post") + } + if s.post(ctx, "spek two") { + t.Fatal("spek posts stay within the chat rate") + } + for i := range 3 { + if !s.postAnswer(ctx, "answer") { + t.Fatalf("answer %d within the burst refused", i+1) + } + } + if s.postAnswer(ctx, "answer") { + t.Fatal("past the burst an answer waits") + } + if posts, _ := h.mt.got(); len(posts) != 4 { + t.Fatalf("posts %q", posts) + } + _, none, _ := voiceSession(t, Policy{ChatPostsPerMinute: 1}) + none.post(ctx, "x") + if none.postAnswer(ctx, "y") { + t.Fatal("no burst configured: the chat rate holds") + } +} + +func TestSpeechTime(t *testing.T) { + if d := speechTime("hi"); d != voiceMinClip { + t.Fatalf("short clip %v", d) + } + if d := speechTime(strings.Repeat("a", 150)); d != 10*time.Second { + t.Fatalf("150 chars %v", d) + } + var v voiceQueue + now := time.Date(2026, 11, 16, 9, 0, 0, 0, time.UTC) + v.queued(now, strings.Repeat("a", 30)) + v.queued(now, strings.Repeat("a", 30)) + if b := v.backlog(now); b != 4*time.Second { + t.Fatalf("two queued clips back to back: %v", b) + } + if b := v.backlog(now.Add(time.Minute)); b != 0 { + t.Fatalf("played out: %v", b) + } +} From a4c9bac42d85bcedca8d32b35ecfd573bf7fed82 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Mon, 16 Nov 2026 22:51:33 -0500 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8C=B1=20Show=20meetings.chat=5Fanswe?= =?UTF-8?q?r=5Fburst=20in=20the=20meetings=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Part of #18590. Signed-off-by: Andy Anderson --- src/pkg/dashboard/api_meetings.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pkg/dashboard/api_meetings.go b/src/pkg/dashboard/api_meetings.go index 3e16c62fb4..2f261fb34d 100644 --- a/src/pkg/dashboard/api_meetings.go +++ b/src/pkg/dashboard/api_meetings.go @@ -481,6 +481,7 @@ func (s *Server) meetingsSettings(ctx context.Context, m config.MeetingsConfig) "meetings.research_pool_size": strconv.Itoa(m.ResearchPoolSizeOrDefault()), "meetings.research_per_meeting": strconv.Itoa(m.ResearchPerMeetingOrDefault()), "meetings.chat_posts_per_minute": strconv.Itoa(m.ChatPostsPerMinuteOrDefault()), + "meetings.chat_answer_burst": strconv.Itoa(m.ChatAnswerBurstOrDefault()), "meetings.lobby_timeout_s": strconv.Itoa(m.LobbyTimeoutSOrDefault()), "meetings.retention_days": strconv.Itoa(m.RetentionDaysOrDefault()), "meetings.consent_text": m.ConsentTextOrDefault(),