gateway: Smart and Use before expiry weigh a Remote magpie by its cards (#6708, zzh11223311 on X)

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.
This commit is contained in:
yetone
2026-11-15 05:45:09 +08:00
parent b754cb0958
commit f038695208
9 changed files with 438 additions and 13 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+3 -1
View File
@@ -150,7 +150,9 @@ func writeCards(w http.ResponseWriter, r *http.Request, s *quotaScope) {
if s == nil && provider.ReckonHolds != nil {
cs = provider.ReckonHolds(cs, time.Now())
}
writeJSON(w, 200, map[string]any{"object": "list", "data": cs})
// with what routing reads of each window, so the other magpie can
// weigh this one by them (#6708)
writeJSON(w, 200, map[string]any{"object": "list", "data": provider.ToldRouting(cs)})
}
// quotas is qs as the key may be told them. A window's whole (Holds,
+122
View File
@@ -0,0 +1,122 @@
package gateway
import (
"context"
"encoding/json"
"io"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
"github.com/yetone/magpie/internal/provider"
)
// #6708 (zzh11223311 on X): a group of two Remote magpies, each serving
// a Claude subscription signed in there. Smart and Use before expiry had
// both "not known" (used 0 in the routing log) and went by tokens and
// stickiness alone. Each is weighed now by its Claude card, as last read
// from it: B, with more of a week that renews sooner, goes first. A
// magpie passes on what routing reads of the cards it has from another,
// so a third magpie weighs them too.
func TestRemoteMagpiesWeighedByTheirCards(t *testing.T) {
fresh(t)
t.Setenv("MAGPIE_ADDR", "")
provider.ForgetRemoteCardsForTest()
t.Cleanup(provider.ForgetRemoteCardsForTest)
now := time.Now()
at := func(d time.Duration) *time.Time { t := now.Add(d); return &t }
claude := func(user string, week float64, renews time.Duration) []provider.SubscriptionQuota {
return []provider.SubscriptionQuota{{Provider: "claude", Name: "Claude Code", User: user, Kind: "subscription", Windows: []provider.QuotaWindow{
{Name: "5 hours", Used: 5, ResetsAt: at(4 * time.Hour), Span: 5 * time.Hour},
{Name: "7 days", Used: week, ResetsAt: at(renews), Span: 7 * 24 * time.Hour},
{Name: "7 days · Opus", Used: 99, ResetsAt: at(renews), Span: 7 * 24 * time.Hour, Model: "opus"},
}}}
}
remote := func(key string, cards []provider.SubscriptionQuota) *httptest.Server {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("x-api-key") != key && r.Header.Get("Authorization") != "Bearer "+key {
w.WriteHeader(http.StatusUnauthorized)
return
}
if r.Method+" "+r.URL.Path != "GET "+provider.RemoteCardsPath {
w.WriteHeader(http.StatusNotFound)
return
}
json.NewEncoder(w).Encode(map[string]any{"object": "list", "data": provider.ToldRouting(cards)})
}))
t.Cleanup(srv.Close)
return srv
}
ra := remote("sk-magpie-a", claude("a@x.com", 51, 117*time.Hour))
rb := remote("sk-magpie-b", claude("b@x.com", 25, 44*time.Hour))
for _, p := range []provider.Provider{
{ID: "mac-a", Name: "Mac A", Preset: provider.RemoteMagpiePreset, Key: "sk-magpie-a", Chat: ra.URL},
{ID: "mac-b", Name: "Mac B", Preset: provider.RemoteMagpiePreset, Key: "sk-magpie-b", Chat: rb.URL},
} {
if err := provider.Save(p); err != nil {
t.Fatal(err)
}
}
// the Usage page's read, which routing goes by from then on
provider.RemoteCards(context.Background())
member := func(id string) candidate {
p, err := provider.Find(id)
if err != nil {
t.Fatal(err)
}
return candidate{p: *p, model: "claude/claude-sonnet-5-5", rest: id + "-6708"}
}
a, b := member("mac-a"), member("mac-b")
for _, routing := range []string{provider.Pace, ""} {
g := provider.Provider{ID: "auto-6708", Routing: routing}
got, wg := weigh(g, []candidate{a, b}, "claude-sonnet-5-5", provider.Anthropic)
if got[0].p.ID != "mac-b" {
t.Errorf("routing %q: %s first, want mac-b", routing, got[0].p.ID)
}
la, oka := wg.lefts[a.allowanceKey()]
lb, okb := wg.lefts[b.allowanceKey()]
if !oka || !okb || la.used != 51 || lb.used != 25 {
t.Errorf("routing %q: used a %v (%v) b %v (%v), want 51 and 25", routing, la.used, oka, lb.used, okb)
}
if !lb.due.Equal(*at(44 * time.Hour)) {
t.Errorf("routing %q: b due %v, want its week's renewal", routing, lb.due)
}
}
// this gateway tells a magpie using it what routing reads of the cards
// it has from mac-a and mac-b
gw := httptest.NewServer(lanGuard(New().Handler()))
defer gw.Close()
res, err := http.Get(gw.URL + provider.RemoteCardsPath)
if err != nil {
t.Fatal(err)
}
body, _ := io.ReadAll(res.Body)
res.Body.Close()
if res.StatusCode != 200 || !strings.Contains(string(body), `"routing"`) || !strings.Contains(string(body), `"mac-b/claude"`) {
t.Fatalf("the cards told on: %d %s", res.StatusCode, body)
}
via := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != provider.RemoteCardsPath {
w.WriteHeader(http.StatusNotFound)
return
}
w.Write(body)
}))
defer via.Close()
if err := provider.Save(provider.Provider{ID: "home", Name: "Home", Preset: provider.RemoteMagpiePreset, Key: "sk-magpie-via", Chat: via.URL}); err != nil {
t.Fatal(err)
}
provider.RemoteCards(context.Background())
home, err := provider.Find("home")
if err != nil {
t.Fatal(err)
}
if al, inner, ok := provider.RemoteAllowance(*home, "mac-b/claude/claude-sonnet-5-5", false); !ok || inner != "claude-sonnet-5-5" {
t.Errorf("a third magpie doesn't know mac-b's Claude: %v %q", ok, inner)
} else if u, _ := al.For(inner, now); u != 25 {
t.Errorf("a third magpie reads mac-b's Sonnet used %v, want 25", u)
}
}
+16 -7
View File
@@ -994,6 +994,8 @@ func narrowWhenRead(c candidate, r Rest) {
var (
keyAllowance = provider.KeyAllowance
staleKeyAllowance = provider.StaleKeyAllowance
// remoteAllowance is provider.RemoteAllowance, swapped in tests
remoteAllowance = provider.RemoteAllowance
)
// RestOf is why what rests by key — a provider's id, or its id#key — is
@@ -2560,7 +2562,14 @@ func weighRouted(p provider.Provider, cs []candidate, model string, from provide
var a provider.Allowance
var ok bool
whose := c.p.ID // whose wallet a balance is in
if c.p.Account == nil {
m := c.model // the model as its allowance counts it
if c.p.IsRemoteMagpie() {
// another magpie's: by the card of its provider serving the
// model there, as last read from it (#6708, zzh11223311 on X);
// read again in the background only when there is another to
// weigh it against
a, m, ok = remoteAllowance(c.p, c.model, len(cs) > 1)
} else if c.p.Account == nil {
// a key that reads its own windows is weighed by them as an
// account is; any other key isn't known
a, ok = keyAllowance(c.p)
@@ -2573,16 +2582,16 @@ func weighRouted(p provider.Provider, cs []candidate, model string, from provide
a, ok = known[ag][c.p.Account.User]
}
if ok {
u, r := a.For(c.model, now)
pc, due := a.Pace(c.model, now)
amt, of, unit := a.Count(c.model, now)
u, r := a.For(m, now)
pc, due := a.Pace(m, now)
amt, of, unit := a.Count(m, now)
rs := a.Restarts(now)
l := left{used: u, renews: r, fullest: a.Fullest(c.model, now), fullestName: a.FullestName(c.model, now), soon: a.Renewal(c.model, now), unreached: a.Unreached(c.model, now), lapse: a.Lapse(c.model, now), lapsing: a.Lapsing(c.model, now), pace: pc, due: due, amount: amt, of: of, unit: unit,
l := left{used: u, renews: r, fullest: a.Fullest(m, now), fullestName: a.FullestName(m, now), soon: a.Renewal(m, now), unreached: a.Unreached(m, now), lapse: a.Lapse(m, now), lapsing: a.Lapsing(m, now), pace: pc, due: due, amount: amt, of: of, unit: unit,
restarts: rs, dueRestart: !rs.IsZero() && due.Equal(rs), credits: spendsCredits(c.p, a)} // one not known counts as unused
l.dueExpiry = !l.dueRestart && !l.lapse.IsZero() && due.Equal(l.lapse)
l.weekLow = u >= lowShare && u < usedShare && a.CapUsed(c.model, now) < lowShare
l.weekLow = u >= lowShare && u < usedShare && a.CapUsed(m, now) < lowShare
l.first = l.credits && provider.CodexCreditsFirst(c.p.Account.User)
if b, bu, has := a.Left(c.model); has {
if b, bu, has := a.Left(m); has {
// a wallet's figure is weighed only against the same
// provider's in the same unit (routes.Seat.LeftIn)
l.bal, l.balUnit, l.balIn = b, bu, whose+"\x00"+bu
+155
View File
@@ -0,0 +1,155 @@
package provider
import (
"context"
"net/http"
"strings"
"sync"
"time"
)
// A Remote magpie's allowance, for routing (#6708, zzh11223311 on X): a
// group whose members are two Remote magpies, each with a Claude
// subscription signed in there, had every member "not known" (used 0 in
// the routing log), so Smart and Use before expiry went by the tokens
// sent lately and stickiness alone. The other magpie already tells its
// cards (RemoteCardsPath, read here for the Usage page): routing now goes
// by them too, as kept here, never waiting on the network.
//
// A window's json leaves out what routing reads (Span, Model, Aside), so
// a magpie tells another its cards with Routing beside the windows
// (ToldRouting), and the cards read are given them back (withRouting). A
// card from a magpie too old to tell them isn't weighed: a "7 days ·
// Opus" window would count against Sonnet, a five hours as a week.
// ToldRouting is cs, each card with its windows' Routing, for another
// magpie: the gateway's answer of RemoteCardsPath.
func ToldRouting(cs []SubscriptionQuota) []SubscriptionQuota {
out := make([]SubscriptionQuota, len(cs))
for i, q := range cs {
if len(q.Windows) > 0 {
q.Routing = make([]lastWindow, len(q.Windows))
for j, w := range q.Windows {
q.Routing[j] = lastWindow{w.Span, w.Model, w.Aside}
}
}
out[i] = q
}
return out
}
// withRouting lays each card's Routing back on its windows, as a remote
// magpie told them, and marks the card one routing may go by. A window
// whose span wasn't known there is named for it here ("7 days").
func withRouting(cs []SubscriptionQuota) []SubscriptionQuota {
out := make([]SubscriptionQuota, len(cs))
for i, q := range cs {
if len(q.Routing) == len(q.Windows) && len(q.Windows) > 0 {
ws := make([]QuotaWindow, len(q.Windows))
for j, w := range q.Windows {
r := q.Routing[j]
w.Span, w.Model, w.Aside = r.Span, r.Model, r.Aside
if w.Span == 0 {
w.Span = windowSpan(w)
}
ws[j] = w
}
q.Windows, q.routable = ws, true
}
q.Routing = nil
out[i] = q
}
return out
}
// remoteRouteReads are the remote magpies whose cards routing has asked
// for in the background, by remoteCardsID: one ask at a time each.
var remoteRouteReads struct {
sync.Mutex
m map[string]bool
}
// RemoteAllowance is what the Remote magpie p has left for model, its id
// there ("claude/claude-sonnet-5-5"), by the card of the provider serving
// it there ("claude"; "relay" for "relay/strata/m" when no card of
// relay/strata is told), as last read from p. inner is model as that
// card counts it ("claude-sonnet-5-5"). Of several accounts there, the
// one with the most left for the model: the other magpie's own routing
// sends it there. ok is false when nothing is known.
//
// It never waits. With ask, cards older than remoteCardsFor, or none, are
// asked for in the background (the other magpie answers from what it
// keeps, asking no vendor), and what was read stands meanwhile: routing
// asks only when it weighs p against another, so a request to one Remote
// magpie alone sends it nothing more.
func RemoteAllowance(p Provider, model string, ask bool) (a Allowance, inner string, ok bool) {
if !p.IsRemoteMagpie() || p.Key == "" || p.Anthropic == "" {
return nil, "", false
}
id := remoteCardsID(p)
c := &remoteCardCache
c.Lock()
r, had := c.m[id]
c.Unlock()
if ask && (!had || time.Since(r.at) >= remoteCardsFor) {
askRemoteForRouting(p, id)
}
if r.held || len(r.cards) == 0 {
return nil, "", false
}
now := time.Now()
for path := model; ; {
i := strings.LastIndex(path, "/")
if i <= 0 {
return nil, "", false
}
path = path[:i]
inner = model[len(path)+1:]
best, bestUsed := Allowance(nil), 0.0
for _, q := range r.cards {
if q.Provider != path || !q.routable || q.Error != "" || q.Held {
continue
}
qa := allowanceOf(q.Windows, now)
if len(qa) == 0 {
continue
}
if u, _ := qa.For(inner, now); best == nil || u < bestUsed {
best, bestUsed = qa, u
}
}
if best != nil {
return best, inner, true
}
}
}
// askRemoteForRouting reads p's cards in the background, unless that is
// under way.
func askRemoteForRouting(p Provider, id string) {
rr := &remoteRouteReads
rr.Lock()
if rr.m[id] {
rr.Unlock()
return
}
if rr.m == nil {
rr.m = map[string]bool{}
}
rr.m[id] = true
rr.Unlock()
c := &remoteCardCache
c.Lock()
gen := c.gen
c.Unlock()
goRead(func() {
defer func() {
rr.Lock()
delete(rr.m, id)
rr.Unlock()
}()
asked := time.Now()
cards, err := askRemote(context.Background(), p, http.MethodGet, RemoteCardsPath, remoteWait)
keepRemoteCardsOf(id, gen, asked, cards, err)
})
}
+117
View File
@@ -0,0 +1,117 @@
package provider
import (
"context"
"testing"
"time"
)
// #6708 (zzh11223311 on X): routing weighs a Remote magpie by the cards
// it tells, as last read here. Each window is read as the remote's
// routing reads it (its span, the model it alone counts), the account
// with the most left for the model when the remote has several, and
// nothing is asked of the remote again within remoteCardsFor. A remote
// too old to tell what routing reads isn't weighed.
func TestRemoteAllowance(t *testing.T) {
now := time.Now()
at := func(d time.Duration) *time.Time { t := now.Add(d); return &t }
claude := func(user string, week float64, renews time.Duration) SubscriptionQuota {
return SubscriptionQuota{Provider: "claude", Name: "Claude Code", User: user, Kind: "subscription", Windows: []QuotaWindow{
{Name: "5 hours", Used: 10, ResetsAt: at(3 * time.Hour), Span: 5 * time.Hour},
{Name: "7 days", Used: week, ResetsAt: at(renews), Span: 7 * 24 * time.Hour},
{Name: "7 days · Opus", Used: 95, ResetsAt: at(renews), Span: 7 * 24 * time.Hour, Model: "opus"},
{Name: "Extra usage", Used: 0, Aside: true},
}}
}
cards := []SubscriptionQuota{
claude("a@x.com", 51, 117*time.Hour),
claude("b@x.com", 80, 20*time.Hour),
// a card it has from a magpie behind it, by its whole path
{Provider: "home/codex", Name: "Codex · Home", User: "c@x.com", Kind: "subscription", Via: []string{"home-self"},
Windows: []QuotaWindow{{Name: "Week", Used: 30, ResetsAt: at(48 * time.Hour)}}},
}
t.Run("old remote", func(t *testing.T) {
peer := &fakePeer{cards: cards} // no Routing told
remoteQuotaHome(t, peer)
RemoteCards(context.Background())
p, err := Find("office")
if err != nil {
t.Fatal(err)
}
if a, _, ok := RemoteAllowance(*p, "claude/claude-sonnet-5-5", true); ok {
t.Errorf("a card with no routing facts is weighed: %+v", a)
}
})
peer := &fakePeer{cards: ToldRouting(cards)}
remoteQuotaHome(t, peer)
t.Cleanup(func() { endReadsOut(t, "after the test") })
p, err := Find("office")
if err != nil {
t.Fatal(err)
}
// not asked to read: nothing is sent
if _, _, ok := RemoteAllowance(*p, "claude/claude-sonnet-5-5", false); ok {
t.Fatal("known before any read")
}
endReadsOut(t, "after a weighing that doesn't ask")
peer.Lock()
asked := peer.gets
peer.Unlock()
if asked != 0 {
t.Fatalf("the remote was asked %d times by a weighing that doesn't ask", asked)
}
// nothing read yet: not known, never waited for; the read it starts
// in the background makes it known
if _, _, ok := RemoteAllowance(*p, "claude/claude-sonnet-5-5", true); ok {
t.Fatal("known before any read")
}
var a Allowance
var inner string
for deadline := time.Now().Add(20 * time.Second); ; {
var ok bool
if a, inner, ok = RemoteAllowance(*p, "claude/claude-sonnet-5-5", true); ok {
break
}
if time.Now().After(deadline) {
t.Fatal("the remote's cards were never read for routing")
}
time.Sleep(10 * time.Millisecond)
}
if inner != "claude-sonnet-5-5" {
t.Errorf("inner model %q", inner)
}
// a@x.com, the one with most left; the Opus week and the extra usage
// don't count Sonnet
if u, renews := a.For(inner, now); u != 51 || len(renews) != 2 || !renews[0].Equal(*at(117 * time.Hour)) {
t.Errorf("Sonnet: used %v, renews %v", u, renews)
}
// the five hours is a rate cap, not the week: the pace goes by the week
if _, due := a.Pace(inner, now); !due.Equal(*at(117 * time.Hour)) {
t.Errorf("pace due %v, want the week's renewal", due)
}
if a, _, ok := RemoteAllowance(*p, "claude/claude-opus-5", true); !ok {
t.Error("Opus not known")
} else if u, _ := a.For("claude-opus-5", now); u != 95 {
t.Errorf("Opus used %v, want 95", u)
}
// a third magpie's card, its span named by the window's name
if a, inner, ok := RemoteAllowance(*p, "home/codex/gpt-5.6-sol", true); !ok || inner != "gpt-5.6-sol" {
t.Errorf("home/codex: %v %q", ok, inner)
} else if _, due := a.Pace(inner, now); !due.Equal(*at(48 * time.Hour)) {
t.Errorf("home/codex pace due %v", due)
}
// a provider the remote tells no card of, and a group there
for _, m := range []string{"deepseek/deepseek-chat", "auto-claude"} {
if _, _, ok := RemoteAllowance(*p, m, true); ok {
t.Errorf("%s known", m)
}
}
peer.Lock()
gets := peer.gets
peer.Unlock()
if gets != 1 {
t.Errorf("the remote was asked %d times, want 1 within remoteCardsFor", gets)
}
}
+15 -3
View File
@@ -201,6 +201,9 @@ func ReadAllCards(ctx context.Context) {
var remoteCardCache struct {
sync.Mutex
m map[string]remoteCardsRead
// gen counts the times the cards were forgotten (a test's
// ForgetRemoteCardsForTest): a read asked before isn't kept after
gen int
}
type remoteCardsRead struct {
@@ -223,6 +226,7 @@ func ForgetRemoteCardsForTest() {
c := &remoteCardCache
c.Lock()
c.m = nil
c.gen++
c.Unlock()
k := &remoteKeyCache
k.Lock()
@@ -391,11 +395,18 @@ func refreshRemote(ctx context.Context, p Provider, card, user string) {
// that comes back after one asked later is not kept over it, so a slow
// answer from before the key was held can't bring its cards back.
func keepRemoteCards(id string, asked time.Time, cards []SubscriptionQuota, err error) remoteCardsRead {
return keepRemoteCardsOf(id, -1, asked, cards, err)
}
// keepRemoteCardsOf is keepRemoteCards for a read asked while the cards
// were of generation gen (remoteCardCache.gen; -1, whichever): one asked
// before they were forgotten isn't kept.
func keepRemoteCardsOf(id string, gen int, asked time.Time, cards []SubscriptionQuota, err error) remoteCardsRead {
c := &remoteCardCache
c.Lock()
defer c.Unlock()
r := c.m[id]
if asked.Before(r.at) {
if asked.Before(r.at) || gen >= 0 && gen != c.gen {
return r
}
r.at = asked
@@ -405,8 +416,9 @@ func keepRemoteCards(id string, asked time.Time, cards []SubscriptionQuota, err
case err != nil:
r.err = err.Error()
default:
// a card that came back round isn't kept, nor told again
r.cards, r.err, r.held = withoutLoops(cards), "", false
// a card that came back round isn't kept, nor told again; what
// the remote told for routing is laid on the windows (#6708)
r.cards, r.err, r.held = withRouting(withoutLoops(cards)), "", false
}
if c.m == nil {
c.m = map[string]remoteCardsRead{}
+8
View File
@@ -283,6 +283,14 @@ type SubscriptionQuota struct {
// this computer (#1547, remote_key_limits.go): the limit that magpie
// holds the key to, beside the windows that show it.
GatewayKey *GatewayKeyLimit `json:"gatewayKey,omitempty"`
// Routing is, on a card told another magpie (RemoteCardsPath), what
// each window's json leaves out for routing (Span, Model, Aside), in
// the windows' order: that magpie weighs its Remote magpie by the card
// (RemoteAllowance, #6708). Set only as cards are told; nil elsewhere.
Routing []lastWindow `json:"routing,omitempty"`
// routable: a remote magpie's card whose windows have Routing laid
// back on them (keepRemoteCards), so routing may go by them
routable bool
// In-process read order, separate from the vendor's ReadAt and never
// persisted: restarting starts a new sequence.
readSeq uint64