CyberCaius on Discord: a deleted provider's requests sat under its old id
("<date> 已删除"), and the only way to put them under a provider they
have was renaming that provider onto the old id. Now, with a deleted
provider picked in Usage › Requests' Provider filter, a "…" beside it
offers Merge into… (an app menu of the providers there are now) and
Rename… (the filter's button turns into a name field; Enter or leaving
it saves, Escape keeps it). With the merged-into provider picked, the
same "…" lists Separate <name> for each, the undo.
Nothing in the log is rewritten. Both live on the deletion's own record
in providers.json (Deleted.Into/MergedAt, Deleted.Label), so a provider
added later under the old id inherits neither: it is a different
provider, and its record of its own is what it has. Renaming the target
carries the merge (Rename rewrites Into); deleting the target ends it.
Renames.Both(id, time) gives the id a call is shown under and the one it
was made to (Own). Listing, filtering, the summary and vias go by the
shown id; pricing (Record.priceID, block_price's as), window holds and
the gateway's loggedAnswers go by the own one, so a merge moves no cost
or token, only whose name they sit under. The target's face lists what
was merged into it (Named.Merged). Routes: GET /api/usage/deleted/into,
POST /api/usage/deleted {id, into?, name?}; a field not sent stays.
Run (mote, at this tree on d50f84c9f):
- go test -tags nogui -timeout 45m ./... : every package ok, exit 0.
- GOOS=linux and GOOS=windows go vet -tags nogui on usage, usageapi,
provider, gui, gateway: ok. gofmt -l clean.
- New: TestDeletedProviderMergedIntoAnother (usage: cost 306 before and
after the merge, 3 calls under main, coster/pricer price a relay call
at its own price, a new "relay" keeps only its own call, rename and
delete of the target, undo), TestDeletedProviderNamedAndMerged
(usageapi), TestUsageDeletedProviderRoutes (gui).
- GUI: usage-ledger-deleted-merge.test.cjs, chromium and webkit, en zh
zh-TW ja de at 1400 and 760px: ok. All 63 usage-*/ledger-* files and
i18n-keys, both engines: 923 of 954 ok. The reds are red the same on
origin/main c3b0484a9 run alone: usage-agents-hide (#3414),
usage-fold (#3415), usage-ledger's "newest live route needs no
return-to-live button" (#3104), and i18n-keys' "a plugin's words are
its own" on library's "Runs as" (#3897).
After rebasing on origin/main 3e96197da (i18n.js merged with c3b0484a9's
balance keys): go build ./..., go test of internal/usage/...,
usageapi/..., provider/..., gui/... ok; the new GUI file in both
engines and every language ok; i18n-keys only #3897's red.
Broken by hand:
- Both returning (to, to): TestDeletedProviderMergedIntoAnother red,
"cost 900, before 306".
- renamesOf not setting into: both Go tests red (relay still listed).
- ledProviderMore returning at once: the GUI test red (timeout waiting
for the …), 5 of 5 subtests in chromium.
- On the old code the new tests don't compile (no MergeDeleted).
Not tried: the real app on a real providers.json with a deleted
provider; Linux/Windows GUI. gateway_sessions still prices by the raw
id, and a deleted provider's per-provider price stops applying once its
id is reused (both before this change, unchanged by it).
ferock (Discord #general): Usage > Requests is full of rows like
"magpie · magpie's own · Remote magpie · API · Model list · 0 0 · 757 ms
· 200, GET /v1/models", which no tool of theirs sent.
Cause: ffe493773 (v0.1.1446) wrote every request magpie sends a
provider on its own into the request log (source "probe"): the editor's
Test and Detect APIs, and every model-list fetch. 0152f6696 then gave a
Remote magpie a 10-minute list schedule (KeepListsFresh), so each Remote
magpie added ~144 such rows a day. The same rows came from every other
automatic fetch: start-up's FetchNew, the panel's FetchNewSoon, the
Providers page's FetchNewBehind and any provider with a RefreshEvery.
They were already counted in no token, cost, chart, budget or quota
total, but they were listed and counted in the page's row total.
Fix: a model_list probe with a 2xx/3xx status and no error
(usage.quietProbe) is not written by usage's probelog.Sink, and is
skipped when the log's index parses one (logSnapshot.probes). This rule
covers every list fetch, whoever started it, so every sibling is
covered by one check. A list that failed is still a row (the Failed
filter finds it, and the row says why models are missing), and every
Test and Detect APIs row stays as it was. Older rows: the answered
model lists already in usage.jsonl stop being listed at the next start
of the index, with no rewrite. The lines stay in the file and nothing
reads them. Quota and usage polls and health checks were never written
there (only Test, Detect and list are marked by probelog), so nothing
else needed changing. The TUI and CLI have no request list. The heatmap,
Summarize, Load and the exports skipped probes already.
Tests:
- usage TestAnsweredModelListIsNoRow (new): 200 and 304 lists aren't
written; a 503 and a connection-refused list are listed and Failed
finds both; a 200 Test is listed; an old answered list line in the log
is not listed, and Total is 3.
- TestProbeRowsListedNotCounted and the rename tests now use a failed
list (a 200 one would no longer be a row).
Broken by hand, each red: quietProbe returning false (the 200 list
written and listed); the index's skip removed, Sink's kept (the old line
listed, total 4).
Run, on mote:
- go test -tags nogui -timeout 45m ./... at the pre-rebase head
(b4f2fa9d3 on 0a7633136): every package ok, 76 ok, exit 0 (gateway
547s, agent 298s, provider 167s, usage 48s).
- After rebase on origin/main 9ba3f049e (which touched neither usage
nor probelog): go build ./...; go vet for darwin, GOOS=linux and
GOOS=windows on usage and probelog; go test usage, probelog,
usageapi, and provider -run Probe|Detect|TestTestWrites: ok. gofmt
-l clean.
- GUI (no asset changed): usage-ledger*.test.cjs, ledger-*.test.cjs and
own-requests.test.cjs, chromium and webkit, each file's languages:
381 tests, 375 pass. The 6 reds are usage-ledger's "newest live route
needs no return-to-live button" (en, zh, both engines), which is
already filed as #3104. usage-ledger-probe passed in every language.
Not tried: a real Remote magpie over a day. The row filter was not
checked on a real usage.jsonl.
cybercaius (Discord): after deleting a provider and adding a new one
that took the same id, the old provider's usage showed under the new one.
Delete now records the provider in providers.json ("deleted": id, name,
icon, when, its Was and Gave). UsageRenames gives a deleted id to
<id>~<when> only once something reuses it (a live provider, a later
deleted record, or a later Was), so a deleted provider nobody replaced
keeps its raw id and the existing probe/usage tests stay as they were.
/api/usage's provider faces name a deleted id from its record and set
Named.deleted; the Usage provider picker notes "Deleted {date}" (zh, zh-TW,
ja, de translated). Old deletes, made before this, have no record and
stay merged: nothing tells their calls apart now.
Run (mote): go test -tags nogui -run 'Deleted|Rename|NotSetUp|Probe'
./internal/usage ./internal/usageapi ./internal/provider ok; gofmt -l
clean; go vet -tags nogui ok.
Broken by hand: dropping the f.Deleted append turns
TestDeletedProviderKeepsItsCallsFromOneAddedUnderItsID and
TestDeletedProviderListedApartAndMarked red; restored, green.
Not tried: a real delete-and-re-add in the GUI app.
CyberCaius on Discord, on the latest release: the Usage page's provider
filter listed Leee and leee.baby, and leee.baby's rows were the model
lists ("模型列表", magpie 自身, 200) asked while Leee was being added.
In the first report the same shape was example on api.example.me with
example.me in the filter, which we had put down to another address typed.
The Add sheet's model list runs before the provider has an id, so
probelog records it under the host asked. 8e2ba36de (v0.1.1697) and
94c2aaecb (v0.1.1726) give such a row to the provider saved on that
exact host, or to the one the log's calls to it went to. The reporter
asks a relay's bare domain (leee.baby, example.me), which answers
/v1/models, and saves the provider on another host of it
(api.example.me). No provider is on leee.baby, no call went there, so
the row stayed the host.
Now a probe recorded under a host no provider is on, and no call went
to, goes by the host's site: its registrable domain (provider.SiteOf,
publicsuffix eTLD+1, port and case aside). The one provider saved on a
host of that site takes it (Renames.OnSite), and with none saved there,
the one the log's calls to that site went to (sitesOf over
logSnapshot.hosts), so it stays with a deleted provider too. A site two
providers are on stays the host; a tenant of a hosting suffix
(x.vercel.app), an address and a bare name (localhost) have no site and
stay as they were. It is done when the log is read: rows written before
this release, the reporter's 16:57 and 17:32 ones, are listed under the
provider too, with nothing to migrate and nothing to set.
Run (rebased on 97332140a):
- go test -tags nogui ./internal/usage ./internal/usageapi
./internal/probelog: ok.
- ./internal/provider -skip TestUnreadLoginsWriteErrorsKeepCredentials
(#3632 crashes the binary): ok but TestFetchAsksASharedBaseOnce,
TestFetchAsksOneListOnceForTwoBasesOfIt and
TestFetchUnionsProtocolListsWithoutChat, open as #3854.
- New TestProbesOfAProviderOnAnotherHostOfItsSiteListIt: model lists at
leee.baby, Leee.Baby and www.leee.baby:443 before Add on
api.leee.baby; two providers on *.two.example, mine.vercel.app beside
theirs.vercel.app, 127.0.0.1:7 beside 127.0.0.1:8. Providers are
[127.0.0.1:7 leee mine.vercel.app two.example] with no call made,
after a call, and after Delete; leee's filter has its 4 rows.
- New TestSiteOf.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows for
internal/provider and internal/usage.
- Sandbox HOME, real binary, `magpie web`: POST /api/provider/list at
http://leee.localhost:3488/v1 (a fake OpenAI-compatible server), then
/api/provider/save on http://api.leee.localhost:3488/v1 as Leee2.
Built at e54a7d50b, /api/usage/requests listed leee and
leee.localhost:3488; the fixed build, over the same usage.jsonl, lists
leee and leee2 with the row under leee2.
Broken by hand: probeProvider without the saved-site branch fails the
new test at "no calls" with [127.0.0.1:7 leee.baby mine.vercel.app
two.example www.leee.baby:443]; without the log-site branch it fails at
"deleted" with leee.baby and www.leee.baby:443 back. On e54a7d50b the
test fails with those two names, the reporter's extra entry.
Not tried: the reporter's own usage.jsonl and providers.json (Leee's
saved host is inferred from the example.me report, not seen); a
reporter whose two providers share one site (stays the host, by
design); the GUI suite (no GUI file changed); the full go test ./...
cybercaius on Discord: one custom provider (example, on api.example.me)
was listed in the Requests page's provider filter under its id and its
host, and the host stayed after the provider was deleted.
The Add sheet's Detect, model-list and Test requests are sent before the
provider has an id, so probelog records them under the host asked
("a provider being added has no id yet"). 8e2ba36de (v0.1.1697, yyddbds)
lists those under the provider saved on that host now (Renames.ProbeOf),
but a deleted provider is on no host any more, so its probes went back
to the host beside the id its calls are kept under.
Now the log's index notes, as it reads each line, the provider each
host's calls went to (logSnapshot.hosts; "" once two providers were on
one host). probeProvider lists a probe recorded under its host by the
provider saved on that host, and with none there, by the one the log's
calls to that host were made under. A host two providers are or were
on, or none, stays the host, lowercased, so one typed in two cases is
listed once. It is done when the log is read, so rows written before
this release are merged too. Renames.OnHost tells "no provider on this
host" from "two providers on it", so a host shared now is never given
to a deleted one.
Not added: deleting a provider's usage rows. usage.jsonl is the record
budgets, windows and totals are read from, and probe rows are counted in
none of them; with them under one name there is nothing left to clean.
Run:
- go test -tags nogui ./internal/usage ./internal/usageapi
./internal/probelog: ok, at the pushed head (rebased on 56de2d192).
- ./internal/provider, skipping the reds open on main
(TestUnreadLoginsWriteErrorsKeepCredentials #3632, TestFetchAsksASharedBaseOnce
and its two siblings #3854): the disk was full from other sessions'
temp files, and TestLoginUsageEachAccount failed on "no space left on
device"; it and the Rename tests passed on a rerun.
- New TestProbesOfADeletedProviderStayWithIt: probes under
api.example.me and API.example.me before provider.Add, a Test after,
a gateway call with the provider's Where, and twice.example used by two
providers; after provider.Delete the list is [example one
twice.example two] and example's filter has its 4 rows.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
Broken by hand: probeProvider without the log's hosts fails it with
"deleted: providers [API.example.me api.example.me example one
twice.example two]", the reporter's extra names.
Not tried: the reporter's own usage.jsonl; a host typed in the Add sheet
and changed before saving (its probes went to another host and stay
under it); the GUI suite (no GUI file changed; the filter lists what
QueryPage returns); the full go test ./... (disk full).
yyddbds on Discord added one custom provider, 大灰狼 on dahuilang.best,
and the Usage page's provider filter listed it twice: 大灰狼 and
dahuilang.best. The Add sheet's Detect and model-list requests run
before the provider has an id, so probelog records them under the host
asked (probelog.Note: "a provider being added has no id yet"). Those
rows are listed on the Requests page, and their provider went into the
page's provider list as a provider of its own.
Renames now also knows each provider by the hosts of its URLs, and
probeChunk reads a probe row through Renames.ProbeOf: a host exactly
one provider is on is that provider's id. It is done when the log is
read, so rows written before this release are merged too. A host no
provider is on (an Add given up) or two providers share stays as it
was recorded; a provider id is never taken for a host.
Run:
- go test -tags nogui ./internal/usage ./internal/usageapi
./internal/probelog ./internal/provider (-skip
TestUnreadLoginsWriteErrorsKeepCredentials, #3632) ./internal/gui:
ok.
- New TestProbesOfAProviderBeingAddedListItOnce: Detect rows written
through probelog.Note under dahuilang.best and DaHuiLang.best before
provider.Add("大灰狼"), plus a gateway call under its id; providers
are [dahuilang other.example shared.example:8443], and the filter on
dahuilang has its 3 rows.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
Broken by hand: probeChunk back on Renames.Of fails it with providers
[DaHuiLang.best dahuilang dahuilang.best other.example
shared.example:8443], the reporter's two entries.
Not tried: the reporter's own usage.jsonl; the full go test ./...
(other sessions' suites were on this machine).
cybercaius on Discord (#help, 10-25): "已经更改供应商 id 的也没有变更过来反而
分开显示了". Reproduced in a sandbox HOME (magpie web on 3582, fake upstream
on 3583): after renaming myrelay to newrelay in the editor, the Requests
page's provider list had both myrelay and newrelay, each named "myrelay",
because the model-list probe row was still under myrelay. The summary was
already folded; the probe chunk, the Sessions tab's vias and the gateway's
loggedAnswers (lead-first routing) were not renamed at all.
What changed
- provider.Renames (UsageRenames): Of(id, time) is the id a call recorded
under id at that time belongs to now. Every usage reader goes through it:
summarizeFrom (and its historical-key set), ledgerMatched, NewPricer,
NewCoster, the Requests page's gateway blocks, probe rows and other
computers' days, window holds and their history, buildVias, and
gateway loggedAnswers. Visit stays as recorded so Of is taken once.
The summary, Requests and vias caches key on Renames.Key.
- An id reused by another provider no longer pulls the new one's calls
into the old one. Rename onto, or Save of a new provider under, an id in
another's Was moves it into that one's Gave with the time (giveID):
calls before then stay the old provider's. freeID treats Was ids as
taken, so adding the vendor again gets "-2". Renamed() (refs) skips ids
a provider or subscription holds now.
- A providers.json that can't be read keeps the last renames read instead
of none (a failed read is unknown), so usage doesn't split meanwhile.
- History: nothing in usage.jsonl is rewritten. Calls from before this
release under a renamed id show under the new id at once. An id that was
reused before this release has no hand-over time, so its calls show under
whoever holds the id now, as before.
Siblings checked: budget keys by caller key; per-key limits, RPM and
concurrency count live requests by the current id; tray totals go through
QueryPage; codex_memory reads Requested refs. None needed a change.
Run at the tree before the rebase; rebased onto 894603bcd (GUI-only,
none of these files) and provider, usage, usageapi, the build and the
Rename/Answer/Lead tests of gateway and gui run again there: ok.
- TestRenamesByWhenTheIDWasTaken (provider), TestRenamedProviderShownOnce
(usage), TestRenamedProviderAnsweredItsLead (gateway): each red with its
piece broken by hand (Save's giveID, freeID's Was, the last-good renames,
probe rename, vias rename, block pricer's timed path, summarize's time,
loggedAnswers' rename), green with it.
- go test -timeout 45m provider usage usageapi budget middleware cli agent
gui gateway sessions profile tui: all ok.
- gofmt -l, go vet ./internal/..., GOOS=linux/windows -tags nogui vet of
provider/usage/gateway and build of the binary: clean.
- Sandbox: rebuilt binary on the same HOME; /api/usage/requests lists only
newrelay, the probe row included.
Not tried: the GUI suite (no JS or asset changed; /api/providers gains an
omitempty "gave"), Windows tests run on the Windows box, a real account,
and the full ./... suite (other sessions' suites were running).