Files
magpie/docs
yetoneandskygunner 8278fd9b0c gateway: Volcengine Ark's monthly 429 rests the key until the reset it writes (+0800 CST), not 15 minutes (#3251 CNife, #3276 wyx1818)
Ark's 429 for a used-up month says "You have exceeded the monthly usage
quota. It will reset at 2026-10-25 23:59:59 +0800 CST." with no
Retry-After. resetsWhen read an offset only after UTC or GMT, so nothing
read it, the key rested quotaRest and was asked again every 15 minutes
until the month turned. Two more limits stood behind that one: a written
reset over 7 days off (longestWritten) isn't read, and a quota rest is
held to 8 days (longestQuota), so wyx1818's reset 9 days off would still
have fallen to the 15-minute loop.

- resetsWhen also reads the time as Go prints one (Ark's): four offset
  digits, a space and the zone's name in capitals, then punctuation or
  重置. The offset is read, the name isn't (CST is more than one zone).
  The UTC/GMT form is unchanged; a bare offset with no zone's name, or
  "+08:00" without UTC, isn't read, as Ark doesn't send them.
- monthlyWords (monthly, 月度, 每月, 本月): a refusal that says its
  allowance is a month's has its written reset believed up to
  longestMonthly (35 days) instead of the week (longestSaid). That covers
  Zhipu's 1310 "Weekly/Monthly Limit Exhausted" too (resetsZhipu), the
  sibling held to the same week.
- In failQuota the 8-day cap is lifted to 35 days only when the rest
  came from the vendor's own reset ("resets") and the refusal is a
  month's. A window read full, a Retry-After and the user's own quota
  rest are held to 8 days as before.

Ported from skygunner's branch skygunner:fix/volcengine-resets (e6c2b6fb,
posted on both issues). Taken: the monthly trust window, longestMonthly,
monthlyWords, the reporters' bodies as fixtures and the shape of
TestMonthlyWrittenResetRestsTheMonth. Changed:
- its regex made UTC|GMT optional and took any 2 to 5 letters,
  case-insensitively, after any offset, for every vendor, so "reset at
  <date> +8 now." would read. Scoped here to Go's layout, the zone's
  name matched case-sensitively.
- it lifted the cap to 35 days whenever the body said monthly, whatever
  the rest came from (a window read full, the user's own rest); here
  only for the vendor's written reset.
- its resetsZhipu kept the week; here it shares longestSaid.
vincenty on Discord: no link to another fix is on either issue
(skygunner's commit is authored as "vincent").

Not changed: Ark's plan windows read by its AccessKey (volcPlanQuotas)
still reach only the usage card, not routing (layer 2 of #3251: the
quota is the account's, not one inference key's, and a provider has one
plan, #2849). #3251 stays open for it.

Tests (fixtures: #3251's and #3276's bodies byte for byte, #3276's as
its pretty-printed JSON):
- TestResetsWritten: ark (3 days), ark 9 days off, ark escaped, 35 days
  read and 36 not, past, cut after the offset / in the offset / before
  the full stop, without the zone, +9900, Ark's form without "monthly"
  9 days off (0: the week holds), WorkBuddy's en 9 days off (0: another
  vendor unchanged), "retry after … +0800 CST." (0). Every existing
  WorkBuddy and UTC/GMT case passes unchanged.
- TestResetsZhipu: 1310 9 days off read, 36 days not; 1308 over a week
  off still 0.
- TestMonthlyWrittenResetRestsTheMonth (new): Ark's 429 3d7h and 9d12h
  off reads failQuota and rests by "resets" till then, raw and as the
  agent's error with keepRetry's note; the same body without "monthly"
  rests quotaRest; a month's refusal with no time on an account whose
  window reads full 20 days off rests 8 days by "window".

Broken by hand, in the worktree:
- old routing.go with the new tests: TestResetsWritten (ark: 0s, want
  79h7m59s; 9 days, escaped, 35 days), TestMonthlyWrittenResetRestsTheMonth
  (79h0m0s off: rests 14m59.99s by quota) and TestResetsZhipu (1310, 9
  days off: 0s) red.
- cap not lifted: 228h0m0s off rests 191h59m59s by resets, red.
- longestSaid always the week: ark 9 days / 35 days and Zhipu 1310 red.
- zone's name made optional: "ark without the zone" reads 79h7m59s, red.
- skygunner's cap (any monthly body): window 20 days off rests 479h59m,
  want 192h, red.
Each restored, green.

Run at 268c1d34c (this change on origin/main 95be6bb75, unchanged at
push): gofmt -l prints nothing; go vet ./..., GOOS=linux go vet -tags
nogui ./..., GOOS=windows go vet ./... clean; go build, GOOS=linux go
build -tags nogui, GOOS=windows go build pass. set -o pipefail; go test
-tags nogui -timeout 45m ./... (no other suite on the machine): 69 ok,
no FAIL in the log (internal/gateway ok 571s).

Not tried: a real Ark key (none here), so not against the live API; the
bodies are the reporters' curl output. Not run: the GUI suite (no GUI
change).

Co-authored-by: skygunner <84759+skygunner@users.noreply.github.com>
2026-10-22 23:47:12 +08:00
..