Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-18590-consent-confirmed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Meetings: the consent notice now counts as posted only when Quorum confirms the line reached the meeting. In a live Teams test the bot could not open the meeting chat (`chat_send_failed reason=no_composer`, chat closed to guests) yet hive recorded `consent_posted_at` and kept listening (#18590, finding 11). Hive now posts the notice with `chat.post {confirm:true}` (quorum 0.2.2) and treats anything but `delivery: confirmed`, including an older Quorum that cannot say, as not posted. When chat cannot deliver it and the meeting has voice on, Betty speaks the notice instead (`consent_via: voice`, shown in the Meetings panel); when neither works she leaves at once with state reason `consent_undelivered`, and the panel says "Left: the consent notice could not be delivered (chat unavailable (...), voice off)". Transient failures (bot not admitted yet, rate limit, a dropped call) are retried up to three times before that. The image now ships quorum v0.2.2.
4 changes: 2 additions & 2 deletions src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@ RUN ARCH="${TARGETARCH:-$(dpkg --print-architecture)}" && \
# Bump note: see src/docs/cli-pins.md (quorum row); update QUORUM_VERSION and
# QUORUM_SHA256 together from the release's quorum.mjs.sha256, and
# QUORUM_DAVEY_VERSION from quorum's package-lock.json.
ARG QUORUM_VERSION=v0.2.1
ARG QUORUM_SHA256=4c5c374a7bab1fd71cb62ae76c29de28f395e96784ad2ea40605b071c2761fbb
ARG QUORUM_VERSION=v0.2.2
ARG QUORUM_SHA256=f36ab9b3618f9a0b9a017f67a8404001e449255f74ce8b34f2c70f287c08e1fc
ARG QUORUM_DAVEY_VERSION=0.1.12
RUN if [ -n "${QUORUM_VERSION}" ]; then \
test -n "${QUORUM_SHA256}" || { echo "QUORUM_SHA256 is required with QUORUM_VERSION" >&2; exit 1; } && \
Expand Down
4 changes: 3 additions & 1 deletion src/pkg/dashboard/static-src/js/meetings.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
const raw = String(m.state_reason || '');
if (!raw) return '';
if (m.state === 'blocked') return 'The meeting refused a guest bot.';
if (/consent_undelivered/.test(raw)) return 'Left: the consent notice could not be delivered' + (m.consent_error ? ' (' + m.consent_error + ')' : '') + '.';
if (/lobby_timeout/.test(raw)) return 'Nobody admitted hive from the lobby in time.';
if (/platform_unavailable/.test(raw)) return 'This meeting platform is not available on this hive right now.';
if (/invalid_argument/.test(raw)) return 'The meeting service did not accept this meeting link.';
Expand Down Expand Up @@ -128,7 +129,8 @@
'<span class="kc-pill" data-status="' + escapeHtml(MEETINGS_PILL_STATUS[state] || '') + '">' + escapeHtml(state) + '</span></div>' +
(meta ? '<div class="muted-xs">' + escapeHtml(meta) + '</div>' : '') +
meetingsReasonHtml(m) +
(m.consent_error && !m.consent_posted_at ? '<div class="muted-xs" title="' + escapeHtml(m.consent_error) + '">chat unavailable: consent notice not posted yet</div>' : '') +
(active && m.consent_error && !m.consent_posted_at ? '<div class="muted-xs" title="' + escapeHtml(m.consent_error) + '">chat unavailable: consent notice not posted yet</div>' : '') +
(m.consent_via === 'voice' ? '<div class="muted-xs">consent notice spoken: the meeting chat could not deliver it</div>' : '') +
(m.voice_enabled && !m.voice_capable ? '<div class="muted-xs">joined without voice; replies go to chat</div>' : '') +
'</div><div class="meetings-row-actions">' +
'<button type="button" class="hv-btn btn-secondary btn-sm" data-action="meetingsOpenPanel" data-arg0="' + escapeHtml(m.id) + '">' + (open ? 'Close' : 'Open') + '</button>' +
Expand Down
4 changes: 3 additions & 1 deletion src/pkg/dashboard/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50189,6 +50189,7 @@ <h3 class="modal-h">How Agents Use Knowledge (Priming)</h3>
const raw = String(m.state_reason || '');
if (!raw) return '';
if (m.state === 'blocked') return 'The meeting refused a guest bot.';
if (/consent_undelivered/.test(raw)) return 'Left: the consent notice could not be delivered' + (m.consent_error ? ' (' + m.consent_error + ')' : '') + '.';
if (/lobby_timeout/.test(raw)) return 'Nobody admitted hive from the lobby in time.';
if (/platform_unavailable/.test(raw)) return 'This meeting platform is not available on this hive right now.';
if (/invalid_argument/.test(raw)) return 'The meeting service did not accept this meeting link.';
Expand Down Expand Up @@ -50228,7 +50229,8 @@ <h3 class="modal-h">How Agents Use Knowledge (Priming)</h3>
'<span class="kc-pill" data-status="' + escapeHtml(MEETINGS_PILL_STATUS[state] || '') + '">' + escapeHtml(state) + '</span></div>' +
(meta ? '<div class="muted-xs">' + escapeHtml(meta) + '</div>' : '') +
meetingsReasonHtml(m) +
(m.consent_error && !m.consent_posted_at ? '<div class="muted-xs" title="' + escapeHtml(m.consent_error) + '">chat unavailable: consent notice not posted yet</div>' : '') +
(active && m.consent_error && !m.consent_posted_at ? '<div class="muted-xs" title="' + escapeHtml(m.consent_error) + '">chat unavailable: consent notice not posted yet</div>' : '') +
(m.consent_via === 'voice' ? '<div class="muted-xs">consent notice spoken: the meeting chat could not deliver it</div>' : '') +
(m.voice_enabled && !m.voice_capable ? '<div class="muted-xs">joined without voice; replies go to chat</div>' : '') +
'</div><div class="meetings-row-actions">' +
'<button type="button" class="hv-btn btn-secondary btn-sm" data-action="meetingsOpenPanel" data-arg0="' + escapeHtml(m.id) + '">' + (open ? 'Close' : 'Open') + '</button>' +
Expand Down
26 changes: 26 additions & 0 deletions src/pkg/meetings/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,32 @@ func (c *Client) ChatPost(ctx context.Context, nativeID, text string) error {
return c.Call(ctx, "chat.post", textArgs{nativeID, text}, nil)
}

// confirmArgs is chat.post with confirm:true (quorum 0.2.2+).
type confirmArgs struct {
MeetingID string `json:"meeting_id"`
Text string `json:"text"`
Confirm bool `json:"confirm"`
}

// DeliveryConfirmed is chat.post's delivery when the platform reported the
// line in the meeting.
const DeliveryConfirmed = "confirmed"

// ChatPostConfirmed calls chat.post with confirm:true and reports whether
// Quorum confirmed the line reached the meeting. A send the platform
// reports as failed is an error (platform_unavailable); an older Quorum that
// answers no delivery, or a delivery Quorum could not verify in time, is
// (false, nil): not known to be posted.
func (c *Client) ChatPostConfirmed(ctx context.Context, nativeID, text string) (bool, error) {
var r struct {
Delivery string `json:"delivery"`
}
if err := c.Call(ctx, "chat.post", confirmArgs{nativeID, text, true}, &r); err != nil {
return false, err
}
return r.Delivery == DeliveryConfirmed, nil
}

// Say calls say.
func (c *Client) Say(ctx context.Context, nativeID, text string) error {
return c.Call(ctx, "say", textArgs{nativeID, text}, nil)
Expand Down
29 changes: 29 additions & 0 deletions src/pkg/meetings/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,32 @@ func TestReadSSE(t *testing.T) {
t.Fatal("empty event has no author")
}
}

func TestClientChatPostConfirmed(t *testing.T) {
f, srv := newFakeQuorumServer(t)
c := NewClient(srv.URL, "tok", nil)
ctx := context.Background()
f.results["chat.post"] = `{"ok":true,"posted_at":"2026-11-17T01:52:00Z","delivery":"confirmed"}`
if ok, err := c.ChatPostConfirmed(ctx, "q1", "notice"); err != nil || !ok {
t.Fatalf("confirmed = %v, %v", ok, err)
}
f.mu.Lock()
sent := f.args[len(f.args)-1]
f.mu.Unlock()
if sent["confirm"] != true || sent["text"] != "notice" || sent["meeting_id"] != "q1" {
t.Fatalf("args %+v", sent)
}
f.results["chat.post"] = `{"ok":true,"posted_at":"2026-11-17T01:52:00Z","delivery":"unconfirmed"}`
if ok, err := c.ChatPostConfirmed(ctx, "q1", "notice"); err != nil || ok {
t.Fatalf("unconfirmed = %v, %v", ok, err)
}
// A Quorum older than 0.2.2 answers no delivery: not known to be posted.
f.results["chat.post"] = `{"ok":true,"posted_at":"2026-11-17T01:52:00Z"}`
if ok, err := c.ChatPostConfirmed(ctx, "q1", "notice"); err != nil || ok {
t.Fatalf("legacy = %v, %v", ok, err)
}
f.results["chat.post"] = `{"ok":false,"error":{"code":"platform_unavailable","message":"the chat line was not posted: no_composer"}}`
if _, err := c.ChatPostConfirmed(ctx, "q1", "notice"); !IsCode(err, CodePlatformUnavailable) {
t.Fatalf("failed send = %v", err)
}
}
191 changes: 191 additions & 0 deletions src/pkg/meetings/consent_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
package meetings

import (
"context"
"strings"
"sync"
"testing"
"time"
)

// confirmingQuorum is a fakeQuorum whose chat.post can confirm delivery
// (quorum 0.2.2 chat.post confirm:true).
type confirmingQuorum struct {
*fakeQuorum
cmu sync.Mutex
confirm []bool // answers in order; the last one repeats
confirmEr []error // errors in order; the last one repeats
tries int
}

func (c *confirmingQuorum) ChatPostConfirmed(_ context.Context, _ string, text string) (bool, error) {
c.cmu.Lock()
defer c.cmu.Unlock()
i := c.tries
c.tries++
pick := func(n int) int { return min(i, n-1) }
var err error
if len(c.confirmEr) > 0 {
err = c.confirmEr[pick(len(c.confirmEr))]
}
if err != nil {
return false, err
}
ok := true
if len(c.confirm) > 0 {
ok = c.confirm[pick(len(c.confirm))]
}
if ok {
c.fakeQuorum.mu.Lock()
c.fakeQuorum.posts = append(c.fakeQuorum.posts, text)
c.fakeQuorum.mu.Unlock()
}
return ok, nil
}

func (c *confirmingQuorum) says() []string {
c.fakeQuorum.mu.Lock()
defer c.fakeQuorum.mu.Unlock()
return append([]string(nil), c.fakeQuorum.says...)
}

var errNoComposer = &ToolError{Tool: "chat.post", Code: CodePlatformUnavailable, Message: "the chat line was not posted: no_composer"}

// liveTeams joins a Teams meeting (voice as given), runs before (if any)
// while it is still joining, and takes it live.
func liveTeams(t *testing.T, q *confirmingQuorum, voice bool, before ...func(*Manager, Meeting)) (*Manager, Meeting) {
t.Helper()
m := newTestManager(t, q, 0)
mt, err := m.Join(context.Background(), JoinRequest{URL: "https://teams.microsoft.com/l/x", Voice: voice})
if err != nil {
t.Fatal(err)
}
if mt.VoiceCapable != voice || mt.VoiceEnabled != voice {
t.Fatalf("joined %+v", mt)
}
for _, fn := range before {
fn(m, mt)
}
q.stream("q1") <- Event{Type: EventState, State: StateLive}
return m, mt
}

func TestConsentConfirmedInChat(t *testing.T) {
q := &confirmingQuorum{fakeQuorum: newFakeQuorum()}
m, mt := liveTeams(t, q, true)
eventually(t, "consent", func() bool { got, _ := m.Get(mt.ID); return got.ConsentPostedAt != nil })
got, _ := m.Get(mt.ID)
if got.ConsentVia != ConsentViaChat || got.State != StateLive || got.ConsentError != "" {
t.Fatalf("meeting %+v", got)
}
if s := q.says(); len(s) != 0 {
t.Fatalf("a confirmed chat notice must not be spoken too: %q", s)
}
}

func TestConsentSpokenWhenChatFails(t *testing.T) {
q := &confirmingQuorum{fakeQuorum: newFakeQuorum(), confirmEr: []error{errNoComposer}}
m, mt := liveTeams(t, q, true)
eventually(t, "consent", func() bool { got, _ := m.Get(mt.ID); return got.ConsentPostedAt != nil })
got, _ := m.Get(mt.ID)
if got.ConsentVia != ConsentViaVoice || got.State != StateLive {
t.Fatalf("meeting %+v", got)
}
if s := q.says(); len(s) != 1 || s[0] != testConsent {
t.Fatalf("says %q, want the consent notice", s)
}
if posts, leaves := q.snapshot(); len(posts) != 0 || len(leaves) != 0 {
t.Fatalf("posts %q leaves %q", posts, leaves)
}
// Once the notice is delivered, replies go through.
if err := m.Say(context.Background(), mt.ID, "hello"); err != nil {
t.Fatal(err)
}
}

func TestConsentUnconfirmedChatAndVoiceOffLeaves(t *testing.T) {
// Unconfirmed (an older Quorum, or no verdict in time) is not posted.
q := &confirmingQuorum{fakeQuorum: newFakeQuorum(), confirm: []bool{false}}
m, mt := liveTeams(t, q, false)
eventually(t, "left", stateIs(m, mt.ID, StateEnded))
got, _ := m.Get(mt.ID)
if got.ConsentPostedAt != nil || got.StateReason != ReasonConsentUndelivered {
t.Fatalf("meeting %+v", got)
}
if !strings.Contains(got.ConsentError, "chat delivery not confirmed") || !strings.Contains(got.ConsentError, "voice off") {
t.Fatalf("consent error %q", got.ConsentError)
}
if _, leaves := q.snapshot(); len(leaves) != 1 || leaves[0] != "q1" {
t.Fatalf("leaves %q", leaves)
}
if s := q.says(); len(s) != 0 {
t.Fatalf("voice is off, nothing may be spoken: %q", s)
}
}

func TestConsentChatAndVoiceFailLeaves(t *testing.T) {
fq := newFakeQuorum()
fq.sayErr = &ToolError{Tool: "say", Code: CodePlatformUnavailable, Message: "speak is not available"}
q := &confirmingQuorum{fakeQuorum: fq, confirmEr: []error{errNoComposer}}
m, mt := liveTeams(t, q, true)
eventually(t, "left", stateIs(m, mt.ID, StateEnded))
got, _ := m.Get(mt.ID)
if got.ConsentPostedAt != nil || got.StateReason != ReasonConsentUndelivered ||
!strings.Contains(got.ConsentError, "no_composer") || !strings.Contains(got.ConsentError, "voice failed") {
t.Fatalf("meeting %+v", got)
}
}

func TestConsentVoiceCapableButMutedLeaves(t *testing.T) {
q := &confirmingQuorum{fakeQuorum: newFakeQuorum(), confirmEr: []error{errNoComposer}}
// The owner turned voice off before the bot went live: hive may not speak.
m, mt := liveTeams(t, q, true, func(m *Manager, mt Meeting) {
if _, err := m.SetVoice(mt.ID, false); err != nil {
t.Fatal(err)
}
})
eventually(t, "left", stateIs(m, mt.ID, StateEnded))
if s := q.says(); len(s) != 0 {
t.Fatalf("says %q", s)
}
}

func TestConsentTransientFailuresBounded(t *testing.T) {
rl := &ToolError{Tool: "chat.post", Code: CodeRateLimited, Message: "slow down"}
q := &confirmingQuorum{fakeQuorum: newFakeQuorum(), confirmEr: []error{rl}}
m, mt := liveTeams(t, q, false)
ch := q.stream("q1")
// Each line is a chance to retry; after ConsentAttempts hive gives up.
go func() {
for i := 0; i < 20; i++ {
select {
case ch <- Event{Type: EventSegment, Speaker: &Person{Name: "Ana"}, Text: "hello", Final: true}:
case <-time.After(time.Second):
return
}
time.Sleep(5 * time.Millisecond)
}
}()
eventually(t, "left", stateIs(m, mt.ID, StateEnded))
q.cmu.Lock()
tries := q.tries
q.cmu.Unlock()
if tries != DefaultConsentAttempts {
t.Fatalf("consent tried %d times, want %d", tries, DefaultConsentAttempts)
}
if got, _ := m.Get(mt.ID); got.StateReason != ReasonConsentUndelivered {
t.Fatalf("meeting %+v", got)
}
}

func TestConsentTransientThenConfirmed(t *testing.T) {
nl := &ToolError{Tool: "chat.post", Code: CodeNotLive, Message: "the bot is not in the meeting"}
q := &confirmingQuorum{fakeQuorum: newFakeQuorum(), confirmEr: []error{nl, nil}}
m, mt := liveTeams(t, q, false)
eventually(t, "consent error", func() bool { got, _ := m.Get(mt.ID); return got.ConsentError != "" })
q.stream("q1") <- Event{Type: EventSegment, Speaker: &Person{Name: "Ana"}, Text: "hello", Final: true}
eventually(t, "consent", func() bool { got, _ := m.Get(mt.ID); return got.ConsentPostedAt != nil })
if got, _ := m.Get(mt.ID); got.ConsentVia != ConsentViaChat || got.ConsentError != "" || got.State != StateLive {
t.Fatalf("meeting %+v", got)
}
}
Loading
Loading