Expand description
The token governor: windowed, durable token/request budgets that pace
how fast an instance burns intelligence, with the tactics
wait | slow | degrade | refuse | fail when a window is exhausted.
- Windows —
intelligence.budget.windows[]:{per: second|minute|hour| day|week, tokens?, requests?, reset?}. Every window is a fixed window aligned to its unit (a rollingsecond|minute|hourwindow is the current unit-aligned bucket; a calendarday|weekwindow resets atresetHH:MMZ, default00:00Z, weeks on Monday). Counters{index, tokens, requests}are durable in the manifest: a restart never re-opens a spent daily budget. - Scopes — the instance governor plus optional sub-budgets per run /
conversation / principal (
Governor::admittakes the applicable scoped budgets). Sub-scopes are checked before the instance and the first refusal decides, so a tighter sub-budget shapes the verdict — including which scope’s tactic applies. - Reservation —
admitreserves an estimate against every window; the reported usagesettles it (replacing the estimate). - Lifetime —
lifetime_tokensis the hard ceiling (alwaysfail).
Pure and clock-injected (now_ms) — the runtime feeds it, the manifest
stores it, agent://budget reads it.
Structs§
- Governor
- The governor: the instance scope + named sub-scopes.
- Window
State - One window’s durable counters.
Enums§
- Admission
- The verdict of an admission request.
Functions§
- parse_
reset - Parse
HH:MMZ(orHH:MM) into ms after midnight.