A group whose members are Remote magpies, each serving a Claude
subscription signed in there, had every member "not known" (used 0 in
the routing log): weighRouted read an allowance only for this magpie's
own accounts and keys. Smart and Use before expiry went by the tokens
sent lately and stickiness alone.
A Remote magpie is weighed now by the card of the provider serving the
model there (provider.RemoteAllowance): the longest provider path of the
model with a card ("claude" for claude/claude-sonnet-5-5), of several
accounts there the one with the most left for the inner model, as last
read from it (remoteCardCache, the Usage page's read). It never waits.
When the routing weighs the remote against another and its cards are
older than 30s, they are read again in the background, one read at a
time per remote; the remote answers from the cards it keeps and asks no
vendor. Per request this costs a map lookup and allowanceOf over a few
windows per remote candidate. A request to one Remote magpie alone sends
it nothing more.
A window's json leaves out Span, Model and Aside. Without them a "7 days
· Opus" window would count against Sonnet and a 5-hour window would read
as a week. So writeCards now sends each card's `routing`
(provider.ToldRouting), and the reader lays it back on the windows
(withRouting in keepRemoteCards). A card from a magpie too old to send it
stays not known, as before. Passed-on cards keep it, so a third magpie
weighs them too. keepRemoteCards also drops a background read begun
before ForgetRemoteCardsForTest (a generation), so a late read can't
land in the next test's cache.
Not changed: candidate.allowance (cap holds, Codex credits last) still
treats a Remote magpie as no account.
Tests:
- TestRemoteAllowance (provider): an old remote isn't weighed; a read
with ask=false sends nothing; the first ask reads in the background;
Sonnet reads the 51% week and ignores the Opus 95%; the five hours is
a rate cap; the lowest-used account wins; a nested home/codex card
works; a group id and an unknown provider are not known; the remote is
asked once within 30s.
- TestRemoteMagpiesWeighedByTheirCards (gateway): two Remote magpies
(51% renewing in 117h, 25% in 44h). Under pace and Smart, B goes first
with used 51/25 and B's due at its week. This gateway's cards answer
carries routing, and a third magpie reads mac-b's Sonnet as 25.
Broken by hand: with weighRouted's remote branch turned off and writeCards
sending plain cards, TestRemoteMagpiesWeighedByTheirCards is red (mac-a
first, used 0/0, no routing in the answer). Asking from every weighing,
a single candidate included, turned four remote tests red
(TestRemoteMagpieRetryGoesToTheSavedAddress and three others counted the
extra GET), so the background read is gated on there being another to
weigh against.
Run at 4c750124d (rebased on origin/main eee217712), on mote: gofmt -l
internal clean; GOOS=linux and GOOS=windows go vet -tags nogui ./...
ok; go vet ./... ok; go test -timeout 45m ./... ok in all 101
packages, no FAIL. Rebased after onto b754cb095 (text size: app.js,
settings), which touches none of these files.
Not tried: a real pair of Remote magpies with real Claude accounts.