Files
yetone 6256d9956a gateway keys: a limit can follow a subscription account's own window (ljayic on X)
A key's limit gains the period "account": it names one subscription
account ("<provider>/<user>") and one of its windows (5h, Weekly, Monthly,
...), and starts and resets when that account's window does, at the reset
time in the account's last good reading (quotas.json), never asked of the
vendor on the request's path (provider.AccountWindow).

When the window can't be read (no reading yet, no such window, or its reset
has passed with no reading since), the limit is "reset unknown": it is
neither reset nor lifted. It counts from the latest time the window can't
have begun before (the reset that passed, else when the limit was set), so
it counts at least the window's calls; a refused call gets Retry-After 300
and a 429 saying the window can't be read now, and the accounts are read
again in the background at most once a minute.

GUI: Gateway keys -> a key's limit -> Window -> "An account's window", then
an app-menu picker of the accounts' windows as read (GET
/api/caller-keys/account-windows); the row reads "$x / $y · 5h of
codex/...", and an unknown reset reads "resets with the account's window".
CLI: magpie gateway-key limit <id> account --account codex/me@example.com
--window 5h --tokens 2m. i18n zh, zh-TW, ja, de. reference.md and
gateway-routing.md say it, with the fallback.

Run (at this tree, base ec8125e68, rebased onto 1ac137e10 which touches
none of these files):
- gofmt -l clean; go vet darwin, linux (-tags nogui), windows clean (mica).
- go test -count=1: internal/access, internal/budget, internal/provider,
  internal/cli, internal/gui ok (mica). TestEveryRouteHasACommandOrIsNamed
  was red until the new route was named (magpie quota).
- New: TestAccountWindowLimit (budget), TestAccountWindowFromLastReading and
  TestReadAccountWindowsOnceAMinute (provider), TestParseAccountWindowLimit
  (cli), TestCallerKeyAccountWindowsRoute (gui). Broken by hand: the unknown
  branch made to guess a 5h window from now -> TestAccountWindowLimit red
  ("let through on a window not read").
- GUI: gateway-key-account-window.test.cjs, chromium + webkit, en zh zh-TW
  ja de, 500px, no native select: 10 of 10 (red without the keys.js and
  i18n change). Every GUI file that loads the caller-keys fixture or the
  Gateway keys page, plus i18n*: 1064 tests, 1046 pass, 18 red, the same
  18 red on origin/main ec8125e68 alone: api-key-theme (6, #6444),
  gateway-key-arrange 420px (10, #6268), text-size webkit (a subtest and its test, #6561).
Not tried: a real Codex/Claude account's window through a live gateway;
the full GUI suite (mote and mica each had a full suite running).
2026-11-15 03:50:46 +08:00
..