Files
magpie/internal/provider/testdata/kimi-booster-5721.json
T
yetone aa3d11d5b7 kimi: a key's booster wallet is read, and a key spending it isn't rested to the month (#5721)
apple_test_src on X (#5721): a Kimi Code key at 98.85% of its month was
rested until the month renews, while Kimi still served it from its
booster wallet. magpie never read the wallet.

readKimiCode now reads booster_wallet (or boosterWallet). A BOOSTER wallet
with an amount over 0 adds an "Extra usage" row: amountLeft, in cents x 1e6,
in the currency of monthlyChargeLimit, else monthlyUsed, else USD. When
something is left, the plan windows are marked Credits. The gateway's full()
then doesn't count a key on its booster as full at the month's 98%. A 429
quota refusal rests it as any refusal does, not until the month renews.
A wallet that is empty, of another type or missing changes nothing.

Tests: TestReadKimiCodeBooster runs on the reporter's literal body
(testdata/kimi-booster-5721.json, where 0 is left: no Credits) and on the
same body with amountLeft injected (snake and camel case). A GIFT wallet
and amount 0 add nothing. TestKimiKeyOnItsBoosterIsNotRestedToTheMonth:
a key with booster left isn't full and its 429 rests it under 24h; a
spent key is still rested by its window.

Run on mote: gofmt -l clean; GOOS=linux and GOOS=windows go vet of
internal/provider and internal/gateway; go test ./internal/provider
./internal/gateway -count=1 -timeout 45m: both ok (154.9s, 951.7s).
Broken by hand: routing.go reverted turns the gateway test red ("a key
on its booster counts as full at the month's 98%"); dropping the Credits
marking turns the provider test red.
Not tried: a real Kimi key with booster balance left (the reporter's
body has 0 left).
2026-11-09 05:06:48 +08:00

72 lines
1.7 KiB
JSON

{
"limits": [
{
"window": {
"duration": 300,
"timeUnit": "TIME_UNIT_MINUTE"
},
"detail": {
"limit": "100",
"remaining": "100",
"resetTime": "2026-11-08T21:37:24.113549Z"
}
}
],
"booster_wallet": {
"id": "<redacted-wallet-id>",
"userId": "<redacted-user-id>",
"balance": {
"id": "<redacted-balance-id>",
"feature": "FEATURE_OMNI",
"type": "BOOSTER",
"amount": "17500000000",
"unit": "UNIT_CURRENCY",
"periodStart": "2026-10-25T08:55:29.957265Z",
"periodEnd": "2126-10-25T08:55:30.957265Z",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"userId": "<redacted-user-id>",
"createTime": "2026-10-25T08:55:30.957265Z",
"updateTime": "2026-11-07T10:33:45.909322Z",
"domain": "DOMAIN_NEXUS"
},
"status": "STATUS_ACTIVE",
"allowTopup": true,
"topupLimit": {
"currency": "CNY",
"priceInCents": "300000"
},
"autoRefillCharge": {
"currency": "CNY",
"priceInCents": "0"
},
"autoRefillThreshold": {
"currency": "CNY",
"priceInCents": "0"
},
"monthlyChargeLimit": {
"currency": "CNY",
"priceInCents": "10000"
},
"monthlyUsed": {
"currency": "CNY",
"priceInCents": "17500"
},
"createdAt": "2026-10-25T08:55:30.957265Z",
"updatedAt": "2026-10-25T08:55:35.799020Z"
},
"usages": {
"limit_5h": {
"used_ratio": 0,
"reset_time": "2026-11-08T21:37:23Z"
},
"limit_month_total": {
"used_ratio": 0.9885,
"reset_time": "2026-11-25T00:00:00Z"
},
"limit_month_code": {
"used_ratio": 0.9873,
"reset_time": "2026-11-25T00:00:00Z"
}
}
}