Files
magpie/internal/gateway
yetone 34916c9fde catalog: a model whose id names videos is no image model; xAI's own grok-imagine-video makes videos
iceloon on X: a Grok channel's fetched list put Grok Imagine Video and
Video 1.5 under Image models, where nothing could mark them Video.
"imagine" is in DrawsID's and ImagesAPI's words, so grok-imagine-video
was drawn as an image. Every provider had the same class: wanx2.1-t2v,
wan2.5-i2v, *-video ids.

- namesVideo: an id with the word video, t2v or i2v is no image model
  (DrawsID, ImagesAPI). cogvideox stays as it was.
- #1399 holds: a relay's model is not a video model by its name. A
  relay's grok-imagine-video now lands among its chat models, where
  right-click Makes… -> Video model already marks it.
- xAI's own list (api.x.ai) is the one whose grok-imagine-video* is a
  video model (xaiFilms), and the gateway makes it at xAI's API:
  POST /v1/videos/generations, then GET /v1/videos/<request_id>, as a
  Grok subscription's backend does. xAI has no OpenAI-shaped
  POST /v1/videos, so filmsOpenAI leaves an xAI key out.
- A list saved before this is mended when read (mendKinds), so an old
  grok-imagine-video saved as an image model moves without a fetch.

Run (mica, mica-run, at ac0b5c287 + this change):
- gofmt -l: clean. go vet (darwin, the changed packages), GOOS=linux
  go vet -tags nogui ./..., GOOS=windows go vet ./..., linux and windows
  builds, go build ./...: ok.
- go test -tags nogui -count=1 -timeout 45m ./internal/catalog
  ./internal/provider ./internal/gateway .: ok (gateway 1012s).
- Broken by hand, each red, then restored: namesVideo returning false
  (TestVideoNamedIsNoImageModel, TestFetchRelayGrokVideoIsNoDrawer,
  TestSavedGrokVideoMended), xaiFilms returning false (TestXAIFilms,
  TestSavedGrokVideoMended), the mend in mendKinds removed
  (TestSavedGrokVideoMended), filmsXAI returning false
  (TestXAIKeyMakesGrokVideo).

Not run: the full go test ./... (both machines' suite.lock queues were
hours deep). Not tried: a real xAI API key (none here); the xAI path is
held to docs.x.ai's /v1/videos/generations and GET /v1/videos/<id> by a
fake in TestXAIKeyMakesGrokVideo.
2026-11-13 23:02:39 +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