Commit Graph
4 Commits
Author SHA1 Message Date
yetone 0978a68681 gateway: a ZCode trial entry's 3012 rests that entry, not the account
young02036 (Discord, 11-07): on an account with a GLM Coding Plan,
GLM-5.3-Flash-Trial answered 405 code 3012 (ZCode's risk control) while
the account's paid models worked. The plugin's 3012 words read as
failRestricted, which rested the whole account for two hours
(restrictedRest), so magpie stopped sending the paid models the account
still served. A -Trial entry goes to zcode.z.ai's Start Plan, and a dual
account's plain models to its GLM Coding Plan on api.z.ai, so the 3012
is zcode.z.ai's: zcodeTrialRestricted rests the entry alone (restID),
as zcodeTrialBlocked already does for the edge block page. On a
gift-only account the plain model goes to zcode.z.ai too, gets its own
3012 and rests the account, at the cost of that one more refused
request per rest. riskRefused still walls the provider's other accounts
off for the rest of the request.

TestZCodeTrialRefusalRestsTheTrialAlone: "trial risk control" now wants
the entry's rest and the account's GLM-5.3 served after it; new cases
"plain risk control" and "another vendor's risk control" want the
account's rest. docs/subsystems/gateway-routing.md says so.

Run (mote): go test -count=1 -run 'TestZCode|TestRisk|TestRestricted|TestMovedZCode'
./internal/gateway/ ok; gofmt -l clean; GOOS=linux and GOOS=windows go
vet ./internal/gateway/ ok.
Broken by hand: the routing.go check removed, trial_risk_control red
(rested "zcode@api key", want ".../GLM-5.3-Flash-Trial"), then restored.
Not tried: a real 3012 account (the reporter's); the full suite runs
after this push.

Reported-by: young02036
2026-11-07 15:13:03 +08:00
yetone e2d52b5012 provider: ZCode's mover min is 0.1.49, whose -Trial entry is no longer answered "quota exhausted" after a free-first refusal (Can4ry_ on X)
Can4ry_ on X: GLM-5.3-Flash-Trial answered "429 · ZCode's limited quota
for glm-5.3-flash is exhausted or temporarily unavailable" in magpie while
ZCode's own app was served. The plain GLM-5.3-Flash also kept going to
the Coding Plan after the Start Plan opened at 23:00. And there was no
freeFirst under Providers › ZCode.

zcode 0.1.49 (plugins 36a017a):
- A free-first gift refusal that isn't a quota answer (405/3012) now
  rests only free first's use of the model. Before, it shared the rest a
  -Trial entry obeys, so the Trial answered a local 429 without asking
  ZCode.
- The local 429 keeps the spent words last. 0.1.48 appended "(ZCode
  answered 429 …)" after them, so zcodeSpentWords didn't match and the
  account rested whole.
- free first is a switch, "Free quota first", in the provider's editor
  under Plugin options, just above Advanced (auth.options free_first,
  on by default).
keepMovedCurrent updates every moved user to 0.1.49.

The gateway test gets 0.1.49's rested wording, which rests the Trial
entry alone, and 0.1.48's, which rested the account.

Correction to plugins 36a017a's body: its old-code block-page test
fails because the old code has no `sidelined` map. Its second plain
request did not go to the gift again.

Run on mote, at this tree (rebased on origin/main 7aff42d86, run again there):
- go vet ./internal/provider ./internal/gateway
- go test ./internal/provider -run 'Mov|Migrat|Mover|ZCode|Zcode|Plugin',
  ok
- go test ./internal/gateway -run 'ZCode|Zcode', ok, both new subtests
  pass
- gofmt -l clean
- npm view --prefer-online @magpie-community/opencode-zcode-auth version
  says 0.1.49

Broken by hand: in the plugin (see 36a017a), the new tests against the
old index.mjs, 4 fail, the reported case among them (429 for 200).

Not tried:
- the full suite. mote is running other sessions' suites, and this
  change is one string in the mover plus test cases.
- a real move to 0.1.49.
- a real Start Plan refusal: the owner's account has no live gift.
- the editor's switch in a running app. It comes from host.js optionsOf
  and app.js pluginOptionsField, unchanged.
2026-11-04 02:07:15 +08:00
yetone 394a92f0f3 gateway: a ZCode trial entry zcode.z.ai's firewall blocks rests alone
A -Trial entry goes to zcode.z.ai's Start Plan only. On an account with
a GLM Coding Plan too, the plain models go to api.z.ai, which kept
answering while zcode.z.ai served its block page (jinpy666,
plugins#545). The block page on a Trial rested the whole account, so
the coding plan's models stopped too. zcodeTrialBlocked now rests such
a refusal on the account/model, like the Trial refusals of #3661.

Unchanged: the block page on a plain model still rests the account (on
a gift-only account, windy_66454's, the plain model is the same gift on
the same host), 3012 risk control rests the account as restricted, and
another vendor's block page rests its account.

Run (mote, at this tree):
- TestZCodeTrialRefusalRestsTheTrialAlone's new "trial edge block" case:
  red without the routing.go line (rested "zcode@api key", want
  "zcode@api key/GLM-5.3-Flash-Trial"), green now; "plain edge block",
  "trial risk control" and "another vendor's block" rest the account.
- go test ./internal/gateway -run 'ZCode|Edge|Relay|Restricted|WorkBuddy|Blocked|Refusal': ok.
- gofmt -l clean; go vet darwin/linux/windows ok.
Not tried: a real dual account while zcode.z.ai blocks.
2026-10-31 11:12:56 +08:00
yetoneandvincent 65ee8c65c6 gateway: a ZCode Start Plan trial that ended or is spent rests that trial alone, not the account (#3661)
orion-nebula-dev's routing log: GLM-5.3-Flash-Trial and GLM-5.3-Trial,
whose Start Plan trial had ended, were refused by the ZCode plugin with
400 "ZCode has no active limited quota for GLM-5.3-Trial". The word
"quota" made it failQuota, and restAfterMarked rested the account
("zcode@zcode"), so the subscription's GLM-5.3 and GLM-5.3-Flash were
paused with it.

zcodeTrialRefused narrows that rest to the trial entry (restID) when the
candidate is a zcode plugin account, the model ends in -Trial, and the
refusal is the plugin's own words naming that model:
- 400 "ZCode has no active limited quota for <model>" (the trial ended);
- 429 "ZCode's limited quota for <bucket> is exhausted or temporarily
  unavailable", where the bucket is the entry less -Trial (its bucket
  spent). skygunner's patch covered the 400 only and kept this 429 as an
  account rest; it is the trial bucket's, given by the plugin before
  anything is sent, so it rests the entry too.
Another model named, a model without -Trial, the ended words on a 429,
the account's own quota (400 or 429) or key (401), and the same words
from another vendor still rest the account.

The plugin is not changed: zcode 0.1.31 already leaves ended trials out
of its model list and its two refusals are exact, and open plugins PRs
#395 and #421 hold zcode's next version. A member the user kept in a
group is still asked, refused locally, and asked again a minute on (a
guessed quota rest); the Routing page strikes such a member as
"skipped", which the gateway doesn't do: filed as #3805.

Ported from skygunner's e04a1b994 (branch
fix/r25-expired-model-not-account-fault): the test plugin's
FAKE_ZCODE_TRIAL and FAKE_NO_FREE fixture is his; the matcher, the 429
case and the test were rewritten. Reported by orion-nebula-dev.

Run:
- TestZCodeTrialRefusalRestsTheTrialAlone: 12 cases, the reporter's
  literal plugin bodies. Each posts to a group of the trial then another
  provider, checks the try's rest key, then posts to a group of the
  account's GLM-5.3 then another provider: served by the account when
  only the trial rests, by the other provider when the account does.
- Broken by hand: the routing.go hook off -> the four trial cases red
  ("refusal rested \"zcode@api key\", want \"zcode@api key/GLM-5.3-Trial\"");
  the 429 branch off -> "trial spent" red; the zcode-only check off ->
  "another vendor's words" red. Green again after each.
- gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and
  GOOS=windows; GOOS=linux go build -tags nogui ./...
- go test -timeout 45m -count=1 ./internal/gateway ./internal/plugin at
  f34a9f8cf (this change on b7d5a97fe): both ok (436s, 87s).

Not tried: a real ZCode account with an ended Start Plan trial (none to
hand); the full ./... suite (other sessions' suites were running); the
Windows box.

Co-authored-by: vincent <vincent@users.noreply.github.com>
2026-10-27 09:10:09 +08:00