usage: a prepaid wallet has no way to say "how much is left" — a window forces a fake share, no window makes the account unknown
TL;DR
A provider that sells prepaid credit — a wallet — cannot be described by the current usage contract:
- With windows,
usedmust be a share of a periodic allowance. A wallet has no such denominator, so anyusedwe send is fabricated. - Without windows,
routedAllowancereturns not-ok,weighed()leavesKnownunset, and the Routing page says 「剩余额度未知」 — the account ranks after every known one (#3650). aside: truedoes not help:allowanceOf()skips those windows whole, with the same result.
What is missing is a balance-shaped reading: "this much is left", in a unit, with no percentage. Two fields would carry it — QuotaWindow.Balance and routes.Seat.Left.
The provider (real numbers, 2026-10-28)
SuperMagic (超级麦吉 / MagiCrew), community plugin magpie-magicrew-auth.
GET /api/v1/quota/points/total answers:
{"total_points": 6291,
"expiring_quota_details": [
{"remaining_points": 185, "expires_at": "2026-10-28 23:59:59"},
{"remaining_points": 100, "expires_at": "2026-11-26 16:45:13"},
{"remaining_points": 956, "expires_at": "2027-11-03 19:11:01"}],
"organization_limit_points": null,
"user_limit_points": null,
"next_cycle_grant": null}
- No total, no consumed:
*_limit_pointsarenullon personal accounts. - The ledger endpoint
POST /api/v1/quota/points/records/queriesanswers HTTP 500 on both sites (five body shapes tried), so "how much was spent" is not readable either. - The only fixed number is the daily login gift — 200 points/day (CN), 50 (intl) — which expires at 23:59:59 the same day.
What the plugin tried, and what magpie did
| plugin sends | magpie | result |
|---|---|---|
aside: true, used: 0, display: "6,291 积分" |
allowanceOf() skips Aside/Text whole; none left → routedAllowance not ok → weighed() leaves Known unset |
Routing page 「剩余额度未知」; the account ranks after every known one |
used: 0, display: "6,291 积分" (no limit) |
known, but routing's quota() shows the count only when limit > 0 |
row reads 0% used, no figure |
used: 0, amount: 0, limit: 6291 |
known, figure shown | percentage is 0 / 6291 — a tautology (denominator = remainder); the "fake share" of #3353 |
What it costs the router
routes.Seat carries Used float64 (a 0–100 share), Soon []time.Time, Lapse, Pace, … — nothing that says how much is left.
pace:(100 - used) / hours until resetsAt. A wallet has noresetsAtand itsusedis always 0, so every account of this provider gets the same pace. 6,291 points and 750 points are indistinguishable.smart: the fine tier is ordered bySoon(Allowance.Renewal, which does foldrunsOutAtin), thenLapse— it can say whose points expire first, never who has more left.
Measured on 4 accounts: 1,363 / 1,693 / 6,291 / 750 points; earliest expiries 178 / 29 / 29 / 372 days out. Under smart all four tie on Soon whenever the expiry days match; under pace they are exactly identical.
Suggested shape
QuotaWindow
// Balance is how much of this allowance is left, in Unit — a reading of a
// prepaid balance, with no share to tell (Used stays nil for it).
Balance *float64 `json:"balance,omitempty"`
allowanceOf keeps such a window (l.Balance = *w.Balance), so Known is true, without inventing a Used.
routes.Seat
// Left is the absolute remainder in the provider's own unit: comparable
// within one provider, 0 when the vendor doesn't say.
Left float64
Filled from the windows' Balance (or the fullest window's Amount/Of when the vendor does count).
Ordering: smart / pace fall back to Left (most first) when shares are unknown or equal. A prepaid provider then becomes rankable by both dimensions that matter: who runs out first (runsOutAt) and who has the most left (balance).
Today's plugin-side workaround (for reference)
Three windows, so the account is at least known and carries runsOutAt:
- 今日积分 — today's batch, real percentage (denominator = the 200/50 daily gift),
resetsAt= next midnight. - 限时积分 — the rest of the expiring batches,
used: 0,limit= current remainder,runsOutAt= earliest. - 永久积分 —
total − Σexpiring,aside, display only.
That is the best the current contract allows — and it still cannot express "how much".
Related
- #3428 — the seat knows when but not how much is lost (
w.RunsOutdropped inallowanceOf). This issue is the same gap one layer up: the seat also cannot see how much is left at all. - #3352 — a
Windows: []reading with a balance is dropped entirely, so the account is unknown. - #3353 — a window that never moves reads as
used: 0and distorts smart ordering. - #3650 — a window without
usedbecomes text + aside, no share.
Happy to send a PR for the two fields if the shape looks right — I can test it against this provider directly.
Done in 8bade6c5e, tagged v0.1.1790. It reaches users once the release builds.
A plugin's usage can now report a prepaid wallet. Send each such window with a balance and its unit, and leave out used, limit and aside:
usage: async (auth) => ({
windows: [{
name: "积分",
balance: 6291, // what is left, a number in `unit`; no total
unit: "积分",
// optional, as before: runsOutAt, runsOut, display, model / models / notModels
}],
})
- How magpie reads it:
- The window counts as a known allowance with nothing used invented.
- A balance of 0 counts as used up.
- A balance that isn't a finite number is ignored, and the window then falls back to its
displayas before.
- Routing (smart, pace and least used): among accounts of the same provider and the same unit, the one with more left goes first, where they would otherwise tie.
- Balances in different units, or from different providers, are never compared.
- An account running low or used up on another window still waits behind one with room.
- What it looks like: the Usage card, the Routing page and
magpie accountsshow "6,291 积分 left", with no percentage and no bar.
The magicrew plugin (magpie-magicrew-auth) needs to send its points this way. Until it does, its windows show as before.
Leaving this open until it works with a real SuperMagic account.
magicrew 插件已按新的 balance 形状改好(commit 2641a77,版本 0.3.21,magpie-magicrew-auth 仓库):
{ name: "积分余额", balance: 6291, unit: "积分", display: "6,291 积分", runsOutAt: "…", runsOut: 185 }
没有 used / limit / aside,整池只发一条窗口。真实两站账号读到:国内 6,291 积分(最早批次 185,2026-10-28 23:59:59 到期)、国际 750 积分(最早 50)。node ../magpie-plugin-scaffold/scripts/check.mjs . 通过 30 / 失败 0。可以拿真实 SuperMagic 账号复核这个 issue 的收尾条件。
另外 WB 插件的国内档也按同样的 balance 方法补了 CycleTotalCapacity 为空、只有 CycleRemainCapacity 的预付包窗口:magpie-community/plugins#450(bun test packages/workbuddy 185 pass)。
Shipped in v0.1.1790 (8bade6c5e). A plugin usage window can now be { name, balance: <number>, unit } with no used / limit / aside. It shows as "N
The contract here is right, but I split the UI surface off too late: the Routing page is the main screen and still shows only the wallet total, not the windows that expire first. Tracked with the concrete host-side data path in #3964. The plugin side (magpie-magicrew-auth 0.3.22) already sends 积分余额 + 今日 / 限时 / 永久; allowanceOf drops the aside rows before routing sees them.
关门依据:这一条只剩契约部分,UI 面在 #3964 里跟进;作者已在 v0.1.1790(8bade6c5e)把 {name, balance, unit} 的窗口形状放出来,路由页的「先到期的窗口」在 #3964 的 5ced5b1aa 里补上并已核过。插件侧 magpie-magicrew-auth 0.3.42 送的是 积分余额 + 今日 / 限时 / 永久 四行。