Per-account top-up overrides, so one workload's appetite doesn't set everyone's limits #276
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Self-service top-up limits live in
app_configand are global:topup.auto.grant_tokens,.cooldown_secs,.max_per_account,.threshold_pct. Tuning them for one account tunes them for everyaccount.
That was acceptable on 2026-08-19 — lairball needed ~3M tokens/day
(measured: 1.46M 14-day mean, 2.80M peak) and the shipped values allowed
three top-ups ever at 1M each with a 24-hour gap, so it would have
stopped inside a week. The global values were raised to
grant_tokens = 3000000,cooldown_secs = 3600,max_per_account = 1000, which fitslairball comfortably.
The cost is that every account now gets 3M-token grants on a 1-hour
cooldown. Nothing is contending for allocation today, so this is a
deliberate, cheap trade rather than a problem. It stops being cheap the
moment there is a second account with a different profile — an
interactive user who should not be able to mint 3M tokens hourly, or a
batch workload that needs more than lairball.
Scope
Per-account overrides for the four top-up settings, falling back to the
global
app_configvalue when unset. Shape roughly:topup.rsalready reads all four throughconfig_store::get_i64in twoplaces (
can_auto_top_upand the grant path), so the resolution point issmall and singular: read the account's override, fall back to global.
Worth mirroring
config_store's clamping so an override cannot exceedthe schema bounds either.
Two things to get right
Clamping is silent.
config_store::get_i64clamps to the row'sdeclared
min_value/max_valueand says nothing. Settingmax_per_account = 1000000today yields1000with no error and no log— it looks applied and is not. Per-account overrides should either log
when they clamp, or reject out-of-bounds values at write time. Silent
clamping on a budget control is the same class of defect as #271's
silently-dropped sampling parameters.
max_per_accountcannot express "unlimited". Its bound is 1000 and0already means "no top-ups", so there is no sentinel. At lairball's3M/day with 3M grants that is one grant/day and therefore ~2.7 years
before it needs an operator-minted code — fine, but finite, and it will
expire silently on a workload nobody is watching. Either widen the bound
with an explicit
-1 = unlimitedsentinel (wideningmin_valueto -1),or accept the ceiling and add an alert when an account approaches it.
Priority
Not urgent — deferred until there is contention. Filed so the global
values raised today are a recorded trade rather than an accident, and so
whoever adds the second heavy account finds this instead of rediscovering
it.
Related: #47 (governance epic), #257 (KV budget — the other place a
per-account dimension will eventually be wanted).