Files
magpie/internal/gateway
yetone a0993ed71d gateway keys: a key held to some models can be given a decision group (Kautism on Discord)
Kautism on Discord, after making a group of Clef and Jev models: "group
似乎不能在閘道金鑰上使用?我翻不到。" The key editor's model list comes from
GET /api/caller-keys/models, which is built from provider.Catalog, and
Catalog keeps decision groups out (no agent chats with one). The gateway
already serves a key that names one (serveDecisionGroup's groupGiven at
/v1/systemone), so a key held to some models could only reach a
decision group through All models.

Now the list puts the decision groups after the chat groups, marked
Group and Decides: only those the gateway serves (not hidden, not
switched off, found by FindGroup), and none twice.

Tests:
- TestCallerKeyModelsOfferDecisionGroups: a decision group is listed
  after the chat group; a switched-off one is not. It fails with the
  new block taken out by hand ("groups offered [group/chat], want the
  chat group and the decision group").
- TestGatewayKeyNamingADecisionGroup: a key given only the decision
  group reaches it at /v1/systemone, and a key given another model is
  refused. This is a guard on gateway behaviour that is already there;
  the gateway code is unchanged.

Run (worktree base 223b900b4, rebased onto 169446a1d, which changes
only the tray files):
- mote: go test -count=1 -timeout 45m ./internal/gui/ ./internal/gateway/
  ok (199s, 988s); go vet for darwin, GOOS=linux -tags nogui and
  GOOS=windows: ok; gofmt clean.
- node --test internal/gui/tests/gateway-key-*.test.cjs: 363 pass,
  11 fail. 10 of the fails are gateway-key-arrange's "dragged into
  order" at 420px, both engines and every language, which are #6268.
  On mica, at load ~5, those two files fail the same 10 at this branch
  and at a fresh origin/main 169446a1d. The 11th (limit-off, chromium
  de 420) passed in the rerun of both files.

Not tried: the editor in the real app with the reporter's group.
2026-11-18 03:48:29 +08:00
..
gateway tests: a Chat client's reply translated from Anthropic's Messages streams as the vendor sends it — the first chunk when its first event comes, each word as it is written, never the whole reply held to the stream's end — and now a test holds it to that. A reporter's OpenAI-format client on Z.ai's GLM saw the opposite for a while (every event of a reply in one burst once the stream ended, while the same provider's Messages replies streamed fine), and it measured out to be the vendor's doing, not the gateway's: the reporter's own request bodies, replayed at full size against the vendor's chat and Messages endpoints through the gateway's build and beside it, streamed both ways on the day. Nothing locked the translation's pacing, though, so a future hold would read as the vendor's again. TestChatFromAnthropicStreamsAsItComes paces a Messages upstream at 200ms a word — glm-5.3 at an Anthropic-only provider, and a Claude model where Chat and Anthropic URLs both sit, which the Messages redirect takes there anyway — and wants the client's first chunk before the upstream has written its last word (relative to the upstream, not the wall clock, so a loaded runner's setup time is not held against it), at least two of the five pauses reaching it, and one ask on /v1/messages; holding every event of the chat encoder until finish (as the report read) fails it on both branches with the first chunk at the stream's end. And the keepalive table that walks every protocol's quiet stream (TestQuietStreamsKeptAliveEveryProtocol) had responses, anthropic, chat and anthropic from chat; chat from anthropic, the path a chat client on a Messages-only provider takes, was the row missing, and it keeps alive the same as the rest. go test -race -count=2 on the two tests, go vet and the nogui build pass. (#1310)
2026-10-14 15:28:27 +08:00
wip
2026-11-12 12:45:39 +08:00
wip
2026-11-12 12:45:39 +08:00
gateway tests: TestRestingKeyReadAgainInAnOrderedGroup has the relay hold a reading made after the key refused until the test has raised its limit (red on ubuntu CI -race at d7bdb076: "its limit raised: still rests by window till …, its windows read 3 times") — the third order 3e38bd76 didn't cover. The planning's reading, still out as the key refused, came back between the refusal and the test raising the limit; ee2588c2's re-read that follows it at once reached the relay first too, read the week still used up, and was trusted for its minute, so the planning after the raise didn't ask again and nothing lifted the rest within the test's 5 s. That is the app as designed (a key's windows are read at most once a minute; a reading made after the refusal is a true one), so the test was wrong: it assumed no reading could land between restAfter and the raise. It now models the owner raising the limit before magpie reads again: a reading that reaches the relay after the refusal waits until the limit is raised. Red before: with the first reading held 100 ms and 300 ms between the refusal and the raise (a preempted test goroutine), the old test fails 3 of 5 with CI's message ("… its windows read 3 times"); the new one passes 10 of 10, and 10 of 10 with each delay alone. Still guards ee2588c2: with the planning's reading held until after the refusal and the re-read taken out of readKeyAllowance, the new test fails 3 of 3 ("still rests by window …, read 2 times"), and passes 3 of 3 with it. go test -race -count=40 -cpu 1,2,4 -run 'TestRestingKey|TestKey|Lone|Allowance' ./internal/gateway at load average ~124, go test -race ./internal/provider, go test -race ./internal/gateway, go vet (darwin, GOOS=linux, GOOS=windows) and gofmt -l pass.
2026-10-08 18:54:59 +08:00