Commit Graph
2 Commits
Author SHA1 Message Date
yetone 6e0b8113dd gateway tests: a rest one test records is let go when it ends (#6717)
restingUntil is package-global. Six tests leave a Codex usage-limit rest
behind (TestAccountProxy, TestCodexOwnModelMovesToNextAccount,
TestCodexSwitchedAccountRestsAsItself, TestCodexPausedOwnAccountPassedOver,
TestCodexPoolForwardsCodexHeaders, TestCodexSocketErrorIsItsStatus), and
TestEffortChangeKeepsTheCache, whose effortCodexAccount sets its home
without fresh(t), started held by it whenever the chunking put them in one
process: its first turn was refused in 15ms with "The usage limit has been
reached". Red in Race at 6e6a18eda and in Test at 0dbdc7481.

The class, both sides:
- fresh(t) clears the rests through noRests() and again when the test
  ends (t.Cleanup), so a test that comes through fresh leaves none.
- noRests() clears restingUntil.lifted too, not only m and note.
- The helpers that set a home without fresh (effortCodexAccount,
  leadSignIn, claudeMadeFirst, piTwoTurns) call noRests first and when
  they end, as b64Home already did.

Run on mote, at 6af327e2b plus this change:
- Broken by hand: each test of the eleven files whose fakes answer a
  usage limit, run with TestEffortChangeKeepsTheCache in one process
  (-test.run '^(T|TestEffortChangeKeepsTheCache)$'). Before: red with the
  six tests above. After: none red.
- internal/gateway plain, sharded as CI does (build/race-shards.sh, 12
  workers): 4300 tests, shards_rc=0.
- internal/gateway -race, sharded: one red, TestBurstTellsNoSpeed/
  responses_from_chat_burst (839ms burst read as 5959 tok/s), a timing
  red with its issue, #2719 (output recorded there); every other test ok.
- gofmt -l internal/gateway: clean.

Not run: the other packages (test files of internal/gateway only).

Fixes #6717
2026-11-15 08:45:42 +08:00
yetone 223b57ffa3 gateway: a turn waiting for its account's turn near a usage cap says queued, not routing (tmr11235 on X)
tmr11235 (Pi, Codex subscription, gpt-6.1-sol): the second request sat in
"routing" until the one before it was answered. Two Pi turns at once on a
Codex sign-in are both out at the vendor at once (HTTP and websocket
upstream, TestPiTwoTurnsOnCodexAreOutTogether, green on the old code too),
and no concurrency cap is set for Codex by default. What does hold a
second turn is an account within 5 points of a usage cap the user set
(nearCaps, one turn at a time). That wait comes before the first try is
begun, so the row had no try and read "routing", and the wait wasn't a
known one for the unrouted watch either (it could end the request as
unknown after 30s).

The wait now sets the route's Phase to "queue" and the request's phase
(notePhase, so it is a known wait). The Routing page says "queued…" and
its explanation says what it waits for, in en, zh, zh-TW, ja, de.
The one-turn rule itself is unchanged: it protects a cap the user set.

Run (mote): TestNearCap*, TestNearCapWaitSaysQueued, TestPiTwoTurns*,
go test ./internal/gui, routing-queued/routing-masking/routing-wait-dot
in chromium, routing-queued in webkit, i18n-keys, i18n-en-no-cjk, gofmt,
go vet darwin/linux nogui/windows of internal/gateway.
Broken by hand: showQueued replaced by a no-op, TestNearCapWaitSaysQueued
red ("never: the waiting turn's route says queued").
Not tried: a real Codex account near a real cap; full suite is started
after the tag.
2026-11-12 16:02:11 +08:00