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/added-18914-betty-meeting-budget-meter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Betty: a visible meeting-budget meter (tokens used, percent, intents answered, hive hourly and daily ceilings) on the meeting row and live view and at `GET /api/meetings/budget`, one 80 percent warning per meeting, shorter answers and no new research at 90 percent, a notice that says what to do at 100 percent, and questions dropped for budget are counted, shown and listed as "not answered: budget" in the inbox record (#18914)
52 changes: 51 additions & 1 deletion dashboard/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,51 @@
}
}
},
"/api/meetings/budget": {
"get": {
"tags": [
"Meetings"
],
"summary": "Meetings budget meter",
"description": "Any authenticated role, read-only included. The per-meeting token and intent budgets, the hive-wide hourly and daily token ceilings with what is used in the rolling hour and day, and one meter per meeting: tokens used, budget, percent, intents answered, level (ok, warning at 80 percent, degraded at 90 percent, exhausted), and the number of questions skipped because the budget ran out. Numbers only: no question or transcript text (the skipped questions' text is on the owner-only GET /api/meetings/{id}).",
"responses": {
"200": {
"description": "Budget overview",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"token_budget": {
"type": "integer",
"description": "meetings.budget.max_tokens_per_meeting in effect"
},
"intent_budget": {
"type": "integer",
"description": "meetings.budget.max_intents_per_meeting in effect"
},
"ledger": {
"type": "object",
"description": "Hive-wide spend: hourly_used, hourly_ceiling, daily_used, daily_ceiling (a zero ceiling means none)"
},
"meetings": {
"type": "array",
"items": {
"type": "object",
"description": "meeting_id, tokens_used, token_budget, percent, intents_answered, intent_budget, level, warned, degraded, exhausted, exhausted_by, skipped, dropped"
}
}
}
}
}
}
},
"503": {
"description": "Meetings are not enabled on this hive"
}
}
}
},
"/api/meetings/{id}": {
"delete": {
"tags": [
Expand Down Expand Up @@ -1243,7 +1288,12 @@
}
},
"live": {
"type": "object"
"type": "object",
"description": "Live-loop state. Includes skipped (the questions dropped because the budget ran out, with their text, first 200) and skipped_count."
},
"budget": {
"type": "object",
"description": "The meeting's budget meter, as in GET /api/meetings/budget."
}
}
}
Expand Down
20 changes: 17 additions & 3 deletions dashboard/test/meetings-calendar-role-race.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function extractConst(name) {
const GH_AUTH = ['hiveRoleSettled'];
const MEETINGS = ['meetingsIsOwner', 'meetingsRoleKnown', 'meetingsOnRoleReady', 'fetchMeetings', 'renderMeetings', 'meetingsJoinFormHtml',
'meetingsRowHtml', 'meetingsFormatTime', 'meetingsFriendlyReason', 'meetingsReasonHtml', 'meetingsLabel',
'meetingsFinished', 'meetingsCanDelete', 'meetingsDeleteButtonHtml'];
'meetingsFinished', 'meetingsCanDelete', 'meetingsDeleteButtonHtml', 'fetchMeetingsBudget', 'meetingsBudgetHtml', 'meetingsBudgetText'];
const CALENDAR = ['calendarRoleKnown', 'calendarOnRoleReady', 'calendarCanView', 'calendarIsOwner', 'fetchCalendar', 'calendarRefreshMeetings',
'fetchMeetingDrafts', 'renderCalendar', 'renderMeetingDrafts', 'meetingDraftsSplit', 'calendarFormHtml', 'calendarViewerTimeZone',
'calendarRowHtml', 'calendarFormatTime', 'calendarPlatformLabel', 'calendarMeetingLink', 'calendarActionButtons', 'renderCalendarIndicator',
Expand Down Expand Up @@ -67,13 +67,13 @@ function makeSandbox(opts) {
if (url === '/api/meetings/actions') return { ok: true, status: 200, json: async () => ({ drafts: [] }) };
return { ok: true, status: 200, json: async () => ({}) };
},
_meetingsList: null, _meetingsError: '', _meetingsOpen: null,
_meetingsList: null, _meetingsError: '', _meetingsOpen: null, _meetingsBudget: {}, _meetingsLedger: null,
_calendarData: null, _calendarError: '', _calendarMeetings: {},
_meetingDrafts: null, _meetingDraftsError: '', _meetingDraftRepos: ['o/r'],
console, Math, Number, Array, Error, Promise, String, Object, Date, Intl, isNaN,
};
vm.createContext(sb);
const consts = ['MEETINGS_ERROR_INLINE_CHARS', 'MEETINGS_PLATFORM_LABELS', 'MEETINGS_PILL_STATUS', 'MEETINGS_LIVE_STATES',
const consts = ['MEETINGS_ERROR_INLINE_CHARS', 'MEETINGS_PLATFORM_LABELS', 'MEETINGS_PILL_STATUS', 'MEETINGS_LIVE_STATES', 'MEETINGS_BUDGET_BADGES',
'CALENDAR_ACTIVE_STATES', 'CALENDAR_DEFAULT_NAME', 'CALENDAR_PLATFORM_LABELS', 'CALENDAR_PLATFORM_ICONS', 'CALENDAR_SOURCE_LABELS',
'CALENDAR_STATUS_LABELS', 'CALENDAR_PILL_STATUS', 'CALENDAR_FWD_PREFIX', 'MEETINGS_FINAL_STATES', 'CALENDAR_FINISHED_STATUSES'].map(extractConst);
// const declarations stay script-scoped in a vm context; re-declare the
Expand Down Expand Up @@ -173,3 +173,17 @@ test('calendar row: forwarded prefix stripped for display, series leads with nex
assert.match(html, /calendar-row-actions/);
assert.equal(sb.calendarApprovalWhy({ status: 'scheduled', source: 'email' }), '');
});

test('the meeting row shows the budget meter with a text alternative and a badge, never question text', async () => {
const sb = makeSandbox({});
const b = { meeting_id: 'm1', tokens_used: 124000, token_budget: 200000, percent: 62, intents_answered: 15, level: 'ok', skipped: 0 };
const ok = sb.meetingsBudgetHtml(b);
assert.match(ok, /aria-label="62% of the meeting budget used"/);
assert.match(ok, /<meter /);
assert.doesNotMatch(ok, /kc-pill/);
const warn = sb.meetingsBudgetHtml({ ...b, percent: 85, level: 'warning', skipped: 2 });
assert.match(warn, /budget 80%/);
assert.match(warn, /2 questions not answered/);
assert.match(sb.meetingsBudgetHtml({ ...b, percent: 100, level: 'exhausted' }), /budget exhausted/);
assert.equal(sb.meetingsBudgetHtml(null), '');
});
25 changes: 25 additions & 0 deletions src/cmd/hive/meetings_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ type meetingLive struct {
Meeting meetings.Meeting `json:"meeting"`
Transcript []meetings.Event `json:"transcript"`
Live *live.State `json:"live,omitempty"`
// Budget is the meeting's budget meter (numbers only).
Budget *live.BudgetView `json:"budget,omitempty"`
}

func (d *meetingsDashboard) Live(id string) (any, error) {
Expand All @@ -156,11 +158,34 @@ func (d *meetingsDashboard) Live(id string) (any, error) {
if d.live != nil {
if st, err := d.live.State(id); err == nil {
out.Live = &st
bv := live.NewBudgetView(d.live.Policy(), st, id)
out.Budget = &bv
}
}
return out, nil
}

// Budget is the hive's meetings budget: the per-meeting limits, the
// hourly and daily ceilings used, and every meeting's meter. It carries
// numbers only, so the dashboard serves it to any role.
func (d *meetingsDashboard) Budget() (any, error) {
if d.live == nil {
return live.BudgetOverview{Meetings: []live.BudgetView{}}, nil
}
list, err := d.mgr.List()
if err != nil {
return nil, meetingsDashboardError(err)
}
ids := make([]string, 0, len(list))
for _, m := range list {
ids = append(ids, m.ID)
}
return d.live.NewBudgetOverview(ids, func(id string) (live.State, bool) {
st, err := d.live.State(id)
return st, err == nil
}), nil
}

// Subscribe forwards meeting changes, transcript lines and live-loop
// events as panel frames.
func (d *meetingsDashboard) Subscribe(fn func(dashboard.MeetingFrame)) func() {
Expand Down
6 changes: 6 additions & 0 deletions src/cmd/hive/meetings_inbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ func (mi *meetingsInbox) build(m meetings.Meeting) (inbox.LiveMeeting, error) {
out.Notes = live.RenderNotesWithReplies(mi.attendee(), m, st.Notes, tr)
out.Summary = strings.Join(st.Notes[live.SectionSummary], "\n")
}
// Questions nobody answered because the budget ran out stay in the
// record, so nothing asked is lost.
if skipped := live.RenderSkippedNote(st); skipped != "" {
out.Notes = strings.TrimRight(out.Notes, "\n") + "\n\n" + skipped
out.Notes = strings.TrimLeft(out.Notes, "\n")
}
return out, nil
}

Expand Down
28 changes: 28 additions & 0 deletions src/cmd/hive/meetings_inbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,31 @@ func TestWireMeetingsInbox(t *testing.T) {
t.Fatalf("sources %+v", srcs)
}
}

// A question dropped for the meeting budget is listed in the meeting's
// inbox record, with or without other notes, so nothing asked is lost.
func TestMeetingsInboxListsQuestionsNotAnsweredForBudget(t *testing.T) {
store, err := meetings.NewStore(t.TempDir())
if err != nil {
t.Fatal(err)
}
now := time.Date(2026, 11, 15, 10, 0, 0, 0, time.UTC)
m := meetings.Meeting{ID: "mtg-budget", State: meetings.StateEnded, CreatedAt: now, EndedAt: &now}
if err := store.Save(m); err != nil {
t.Fatal(err)
}
skipped := []live.SkippedQuestion{{Who: "Ana", Text: "when does the release ship?"}}
if err := store.SaveDoc(m.ID, live.StateDoc, live.State{SkippedCount: 2, Skipped: skipped}); err != nil {
t.Fatal(err)
}
mi := &meetingsInbox{store: store}
got, err := mi.build(m)
if err != nil {
t.Fatal(err)
}
for _, want := range []string{"## Not answered: budget", "Ana: when does the release ship?", "and 1 more not listed"} {
if !strings.Contains(got.Notes, want) {
t.Errorf("inbox notes lack %q:\n%s", want, got.Notes)
}
}
}
3 changes: 2 additions & 1 deletion src/docs/api-reference/knowledge.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f
| `POST` | `/api/meetings/settings` | Owner only | Update `meetings.enabled` and `meetings.vexa.url`, and write the Vexa tenant key, Discord bot token, transcription service token and TTS service token to keystore-sealed secret files (`""` clears one): `{enabled?, vexa_url?, vexa_api_key?, discord_token?, transcribe_token?, tts_token?}`. Returns the settings with `restart_required`; 400 on an invalid value. Audited as `meetings_settings` | `pkg/dashboard/api_meetings.go:130` |
| `POST` | `/api/meetings` | Owner only | Send hive to a meeting: `{url}` for Google Meet, Teams or Zoom, or `{platform: "discord", guild_id, channel_id}`, plus `title?` and `voice?`. Returns the meeting record; 400 invalid request, 502 Quorum refused, 503 meetings off. Audited as `meeting_join` | `pkg/dashboard/api_meetings.go:131` |
| `GET` | `/api/meetings` | Owner only | `{meetings: [...], email_in}`, newest first; `email_in` is the hive's email-in address as in `GET /api/inbox` | `pkg/dashboard/api_meetings.go:132` |
| `GET` | `/api/meetings/{id}` | Owner only | `{meeting, transcript, live}`: the record, stored final segments and chat, and the live-loop state (notes, research, asks, budget); 404 unknown | `pkg/dashboard/api_meetings.go:133` |
| `GET` | `/api/meetings/{id}` | Owner only | `{meeting, transcript, live}`: the record, stored final segments and chat, and the live-loop state (notes, research, asks, budget, and `skipped`: the questions dropped because the budget ran out, with their text) plus `budget`, the meter; 404 unknown | `pkg/dashboard/api_meetings.go:133` |
| `POST` | `/api/meetings/{id}/leave` | Owner only | Make hive leave; returns the record. Audited as `meeting_leave` | `pkg/dashboard/api_meetings.go:134` |
| `POST` | `/api/meetings/{id}/voice` | Owner only | `{enabled}`: allow hive to answer aloud when addressed (with `meetings.voice_on_address`). Audited as `meeting_voice` | `pkg/dashboard/api_meetings.go:135` |
| `POST` | `/api/meetings/{id}/research/{rid}/approve` | Owner only | Dispatch a research item waiting past the per-meeting cap; 409 when it is not waiting or the live session ended. Audited as `meeting_research_approve` | `pkg/dashboard/api_meetings.go:136` |
Expand All @@ -105,6 +105,7 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f
| `DELETE` | `/api/meetings/{id}` | Owner only | Delete a meeting in a final state (ended, failed, blocked, declined, left, handed off, purged) or a pending join request (declined with `meeting.leave`, then removed): the record, transcript and live state on this hive, the meeting in Vexa (Quorum `meeting.delete`, best effort: `not_found` is fine, any other error comes back as `upstream_error` while the record is still removed), and the Calendar entry that existed only for it. Knowledge facts and drafts made from it are not touched. 200 `{id, state, upstream_error?, calendar_removed?}`; 404 unknown; 409 while hive is joining, in the lobby or live (leave the meeting first). Audited as `meeting_delete` | `pkg/dashboard/api_meetings_delete.go:44` |
| `POST` | `/api/meetings/clear-finished` | Owner only | Delete every meeting in a final state that finished before `{before?}` (RFC 3339; empty or later than now means now), each as `DELETE /api/meetings/{id}`; live meetings and pending join requests stay. 200 `{deleted, count}`; 400 bad `before`. Each meeting audited as `meeting_delete` | `pkg/dashboard/api_meetings_delete.go:45` |
| `GET` | `/api/meetings/{id}/ws` | Owner only | WebSocket live panel: a `snapshot` frame, then `meeting`, `line`, `intent`, `research`, `notes` and `dropped` frames for the meeting | `pkg/dashboard/api_meetings.go:139` |
| `GET` | `/api/meetings/budget` | Any role | The meetings budget meter: `token_budget`, `intent_budget`, `ledger` (`hourly_used`, `hourly_ceiling`, `daily_used`, `daily_ceiling`) and `meetings`: per meeting `tokens_used`, `token_budget`, `percent`, `intents_answered`, `level` (`ok`, `warning` from 80 percent, `degraded` from 90, `exhausted`), `skipped`. Numbers only, no question text, so read-only roles may read it | `pkg/dashboard/api_meetings.go:140` |
| `GET` | `/api/meetings/schedule` | Owner or read-write | The Calendar: `{upcoming, recent, attendee_name, email_in}` (`email_in` is the hive's email-in address as in `GET /api/inbox`); upcoming events (scheduled, awaiting approval, live) by start and events finished in the last 14 days, newest first. Each event carries its platform, source, status, next occurrences and the meeting it created; a passcode is shown only as `set`. See [Calendar](../meetings.md#calendar) | `pkg/dashboard/api_meetings_schedule.go:86` |
| `POST` | `/api/meetings/schedule` | Owner or read-write | Schedule a meeting: `{url, start, end?, title?, rrule?, timezone?}` (RFC 3339 times, RFC 5545 `RRULE` expanded in an IANA `timezone`). The platform comes from the link (Google Meet, Teams, Zoom). The owner's add is scheduled; a read-write user's add awaits approval. 400 invalid or already ended. Audited as `meeting_schedule_add` | `pkg/dashboard/api_meetings_schedule.go:87` |
| `POST` | `/api/meetings/schedule/{eid}/approve` | Owner only | Schedule an event awaiting approval. 409 when it is not awaiting approval. Audited as `meeting_schedule_approve` | `pkg/dashboard/api_meetings_schedule.go:88` |
Expand Down
20 changes: 19 additions & 1 deletion src/docs/meetings.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,24 @@ The warm process is replaced after `HIVE_MEETINGS_CLI_RECYCLE_TURNS` turns (defa

Spektacular must be a version that includes the `meeting` command ([hivecommons/spektacular#126](https://github.com/hivecommons/spektacular/pull/126)). With an older binary the live mode exits at once; hive keeps the meeting going (transcript, consent, `hive leave`, research approvals, the panel) without Spek's questions and notes, and the panel says plainly that notes and clarifying questions are off for the meeting. While hive cannot reach a Spektacular child that is restarting, the panel says they are paused, and clears it when Spek writes again.

## The meeting budget

Every meeting has its own token budget (`meetings.budget.max_tokens_per_meeting`, 200000 by default), and the hive has hourly and daily ceilings across all meetings (`meetings.budget.max_tokens_per_hour`, `max_tokens_per_day`). When Spek reports no usage, `meetings.budget.max_intents_per_meeting` (500) caps intents instead.

**How it is counted.** The meeting's usage ledger charges fresh input tokens, output tokens and cache writes in full, and cache reads at a tenth (the weight set in #18911: a warm session re-reads its whole history every turn, and counting those reads in full spent a meeting budget in about fifteen answers). Each answer Betty gives also counts as one intent. Hive-wide ceilings use the same token count.

**Where the owner changes it.** In `hive.yaml` under `meetings.budget`, or with `HIVE_MEETINGS_MAX_TOKENS_PER_MEETING`, `HIVE_MEETINGS_MAX_TOKENS_PER_HOUR`, `HIVE_MEETINGS_MAX_TOKENS_PER_DAY` and `HIVE_MEETINGS_MAX_INTENTS_PER_MEETING`; Settings, Meetings shows the values in effect. The 80 and 90 percent steps below are fixed behaviour, not settings.

**The meter.** The meeting row and the live meeting view show a slim meter with the percent used, with the text alternative "62% of the meeting budget used". `GET /api/meetings/budget` returns it for every meeting plus the hourly and daily ceilings used, to any role, as numbers only; the owner-only `GET /api/meetings/{id}` also carries the questions that were skipped.

| Used | What happens |
|---|---|
| 80% | One warn log line per meeting (`[meetings] meeting budget at 80%`, ids and numbers only) and a "budget 80%" badge on the meeting. Nothing changes in the meeting. |
| 90% | Betty says once that answers will be shorter and no new long research runs will start. From then on she answers in one short sentence (at most 160 characters) and does not start deep dives; research Spek asks for is not started. Research already running finishes, and the owner can still approve a waiting item by hand. |
| 100% | Betty posts the existing notice, now saying what to do: ask the owner to raise the budget or start a new meeting. She keeps taking notes but stops asking, answering and researching. |

A question dropped because the budget ran out is never lost. It is counted, shown in the live meeting view, and listed under "Not answered: budget" in the meeting's inbox record. While the budget is out, Betty repeats the notice with the running count of skipped questions each time that count doubles (1, 2, 4, 8, and so on), so the room learns questions are being skipped without a post for each one. Logs and audit carry counts and ids only, never the question text.

## Using it

Only the hive owner can send hive to a meeting.
Expand Down Expand Up @@ -456,4 +474,4 @@ Every key has an environment override that wins over `hive.yaml`. The full list
| `meetings.persona.unprompted.stale_s` | `60` | Seconds before a waiting question is dropped. |
| `meetings.persona.searxng_url` | none | SearXNG instance for web answers (for example `http://searxng.meetings.svc.cluster.local:8080`). |

When the budget runs out, hive posts one notice in the meeting and keeps taking notes, but stops asking questions, starting research and speaking.
When the budget runs out, hive posts one notice in the meeting and keeps taking notes, but stops asking questions, starting research and speaking. See [The meeting budget](#the-meeting-budget) for how it is counted and what happens at 80, 90 and 100 percent.
1 change: 1 addition & 0 deletions src/pkg/dashboard/api_meetings.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func (s *Server) registerMeetingsRoutes() {
s.mux.HandleFunc("POST /api/meetings/{id}/approve", s.handleMeetingsRequestApprove)
s.mux.HandleFunc("POST /api/meetings/{id}/decline", s.handleMeetingsRequestDecline)
s.mux.HandleFunc("GET /api/meetings/{id}/ws", s.handleMeetingsWS)
s.mux.HandleFunc("GET /api/meetings/budget", s.handleMeetingsBudget)
s.registerMeetingsDeleteRoutes()
}

Expand Down
Loading
Loading