Commit Graph
1202 Commits
Author SHA1 Message Date
yetone d4f1d6480c plugin: a program a plugin starts with no folder runs in plugin-work, not beside magpie's settings
jiakun_zhao on X asked whose page_<hash>.html, magpie_home.html,
magpie_install.sh and magpie_*.md files they had found after using the
chat page plugin (Magiczerowxy/magpie-chat). That plugin starts the
user's MCP servers from the plugin host with node:child_process spawn
and no cwd, and runs their tools for a model. The host runs in magpie's
config folder (~/.config/magpie), so every file such a tool saved by a
relative name went beside settings.json and providers.json, and a tool
told to write "providers.json" would have written over magpie's.

host.js's spawn wrapper (which already hands on the proxy and keeps
programs off the host's stdio) now starts a program that names no
folder of its own in <config>/plugin-work, created on first use, with
PWD to match outside Windows. A folder the plugin gives is kept.

Not the cause of files in the user's home folder: magpie's host never
runs in ~, and no magpie code names a file page_<hash>.html or calls a
user's MCP tool itself. Files in ~ come from a process whose folder was
~: the chat's server started by hand (node serve.mjs) from ~, or
another agent run there. Filed on magpie-chat for the plugin to give
its MCP servers a workspace of its own and tell the model where it is.

Run (mote, macOS):
- TestPluginProgramsRunInTheirOwnFolder (new; testdata/clicwd checks
  child_process spawn, spawn with env, execSync and Bun.spawn, plus an
  own cwd kept): ok. Red with origin/main's host.js put back by hand
  (plugin-work not made; programs ran in the config folder).
- go test ./internal/plugin ./internal/agentplug ./internal/pluginrt
  -count=1: ok (plugin 261s).
- go test ./internal/gateway -run Plugin -count=1 at 581d64b7d: ok.
- Windows (xiaomi-gpu, win-run): TestPluginProgramsRunInTheirOwnFolder,
  TestPluginCLIHasTheProxy, TestFakePlugin: ok.
- gofmt -l: clean.
Not tried: the full go test ./... suite, the real magpie-chat plugin
with a real MCP server and model, Linux.
2026-10-28 22:20:56 +08:00
yetone ca499953e7 gui: a plugin page with a host part starts the host when it opens
guesssssssswhat on X: the Magiczerowxy/magpie-chat page ("对话") sits
on its loading text and never opens. The page says hello and then
navigates its frame to http://127.0.0.1:3477, a server the plugin's
index.mjs starts inside the Bun host. The host was started only by a
call: at launch while providers are first read, and after a Restart
(a plugin installed, updated or set, a Bun update) or a crash only once
something asked a plugin again. With the host down, WebKit (the macOS
window's WKWebView, WebKitGTK) leaves a frame whose navigation is
refused on its old document with no error, and the hello had already
cleared the 10s broken timer, so the page waits forever. Chromium shows
chrome-error instead.

Now serving the entry HTML of a page or panel whose plugin is not
page-only starts the host if none is up (plugin.Warm), waiting at most
7s, then serves the page. Page-only plugins, and the page's other files
and the bridge, don't touch the host.

Reproduced on mote (sandbox HOME, magpie web on a free port, plugin
0.1.16 from GitHub): with its 3477 listener killed, old main's page
stays on "正在连接到本地对话服务…" in Playwright WebKit (chrome-error
in Chromium); the fixed build restarts the host on open and the chat UI
loads in both engines. In the real macOS app (wails://) the frame
reaches 127.0.0.1 (seen by a logging server). TestPluginPageStartsItsHost
is red with the pageHost call removed by hand.

Run at this head (84a6a2c42 + this), on mote: gofmt -l clean; go vet,
GOOS=linux go vet -tags nogui, GOOS=windows go vet; go build,
GOOS=linux go build -tags nogui, GOOS=windows go build; go test ./...
-timeout 45m: every package ok except internal/gui's
TestMainWindowCorners/macOS_26_SDK, red on macOS 27 and filed as #3949
(titlebar, untouched here). plugin-page.test.cjs and
plugin-kinds-discover.test.cjs, Chromium and WebKit, 14/14 each.
Rebased on 29181eb78 (usage, gateway; no file here), then go vet and
go test ./internal/gui/ ./internal/plugin/ again: same, only #3949 red.
Pushed on b586fdf1e, whose two commits (app.css, usage pricing) weren't run with this.
win-run: go test -run 'TestPluginPage|TestWindowPage' ./internal/gui/
./internal/plugin/ ok.

Not tried: the reporter's OS and magpie version; the real Windows and
Linux app windows (wsl-run can't build internal/gui: no gtk4 or
webkitgtk-6.0 dev packages in magpie-desktop, internal/plugin ok); a
real Restart in the background (simulated by killing the host); the
full GUI suite (no asset changed). magpie-chat 0.1.9 to 0.1.13 had no
main or exports, so they are page-only and no host ever starts them;
0.1.14 restored main, and that's for the plugin to tell its users.
2026-10-28 21:27:47 +08:00
yetone 012c584cc1 usage: clear a model's usage, or all of it, from the Usage page
CrazyMouse_TT on X asked for a way to clear usage, all of it or one
model's, to measure a local model fresh after deploying it.

The Usage page's Models list has a "…" on each row (and a right-click
menu) with "Clear usage…", and "Clear all usage…" sits under the lists
below the "Counted from…" note. Each asks first, in a confirmation that
says what is deleted, that it can't be undone, and that key spending
limits and allowances still count the calls.

A clear is a mark in settings (usageCleared: provider, model, unix ms),
read at read time; usage.jsonl is never rewritten. The Overview hides
calls up to the mark in summarizeFrom; the Requests page, heatmap and
ledger/CSV hide them in Filter.keepsRow, their one choke point, and the
request index's meta carries the marks so its cache is dropped. Key
budgets, window holds and Codex reads go through usage.Visit and the raw
log, so a clear never resets a key's spending limit or a quota. A later
clear of the same model or of everything takes the place of an earlier
one. The marks ride the settings part of a sync (sync-backup.md) and a
save of the Settings page keeps them (api.go's keep list; the guard
test TestSettingsSaveKeepsWhatItDoesNotSend caught it missing).
gateway-sessions.md and sync-backup.md say so.

Run on mote (mote-run) at this tree, rebased on origin/main c26b2992e
(the Go packages and usage-clear.test.cjs; vet and the 68 GUI files
ran at the earlier base f835bd713, four commits behind):
- go test -tags nogui -timeout 45m ./internal/usage ./internal/settings
  ./internal/usageapi ./internal/gui: all ok after the
  keep-list fix (before it, TestSettingsSaveKeepsWhatItDoesNotSend red).
- gofmt -l: clean. GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: exit 0. (Linux vet without nogui fails in
  wails' cgo, as on main.)
- usage-clear.test.cjs: 32/32 in Chromium and WebKit, en/zh/zh-TW/ja/de,
  at 1200, 560 and 390 (web). With the old page.js/client.js/i18n.js it
  fails (TimeoutError).
- 68 GUI files the change can reach (every usage-*, gui-de/ja/zh-tw,
  i18n-keys, click-scroll, idle-ticks, mobile-web, panel-usage,
  sessions-purge): 941/980. The reds are filed and red on main
  (usage-ledger run alone at origin/main 84a6a2c42 too): i18n-keys "masking…" (#4053), mobile-web
  (#3952), usage-agents-hide (#2276, #3414), usage-ledger "newest live
  route needs no return-to-live button" (#3104, run alone at main too).
  i18n-keys first also named "Clear usage…" in Go comments of this
  change; reworded.
Broken by hand, each red: hides() always false (usage and gui tests),
keepsRow's clear check removed ("Requests after the clear: 5 rows"),
clearedKey out of the request meta ("after clearing everything: 3"),
the api.go keep line removed (UsageCleared [] after a save).

Not tried: the full go ./... suite and the whole GUI suite (mote was
busy with other sessions' full suites), the real app, a sync between
two computers. usage.jsonl doesn't shrink, and the Sessions tab's
figures are not cleared.
2026-10-28 21:13:09 +08:00
yetone 4cc331bab4 gateway: a Chat relay's text-part contents go as a string (Atria on Discord)
tim072844 on Discord: a custom provider on OpenAI compatible (Atria,
Shanghai AI Lab's Intern discovery API, model Atria-Dawn) answered
DeepSeek Harness with 238 validation errors saying `input` must be a
string. That "input" is pydantic's wording for the value it rejected,
not a Responses field: DeepSeek Harness (pi-ai's openai-completions)
sends every user message's content as a list of text parts, the gateway
relays a Chat client's body as it came, and that server's Chat schema
takes content as a string alone.

passthrough's Chat case now runs textPartsAsString: a content list made
only of {"type":"text","text":...} parts goes as their text joined by a
newline (as vLLM renders such a list). A list with an image, a file, a
thinking part, cache_control or any other key stays as it is. Every
other byte of the body stays as sent, and a body with no such list
comes back byte for byte. This covers every Chat-protocol upstream, not
Atria alone; buildChat's translated requests already sent strings.

TestChatRelayLeavesOutEmptyAssistant's "blank parts" case now expects
the joined user text as a string, since the parts are flattened before
silentAssistantsOut joins the two user turns.

Run (on mote, worktree at this commit's tree):
- go test -run 'TestChatRelayTextPartsAsString|TestTextPartsAsStringOnlyPlainText|TestChatRelayLeavesOutEmptyAssistant' ./internal/gateway: ok
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway: ok (553.6s); again after rebasing on 56d26f0bb, ok (603.4s)
- gofmt -l: clean; go vet darwin, linux (nogui), windows: ok

Broken by hand: with the textPartsAsString call commented out,
TestChatRelayTextPartsAsString is red (422 from the fake, the same
"Input should be a valid string" per list); green with it back.

Not tried: no Atria key, so no real request. The vendor answers 401
before validating a request without one, so its exact schema is
inferred from the reported error wording and pi-ai's source, not seen.
2026-10-28 20:24:00 +08:00
yetone c2aad3db02 redact: a wallet address goes as written, and an IP as a documentation address the agent can use
0x0_air on X (10-28): with masking on, the agent stopped and asked again.
Their EVM address (0x89dfBD9b…, public) went as a secret placeholder and
the vendor's model told them to rotate it in case it was a private key;
the server IP they typed went as {{IP_…}} and the model refused to ssh
to it and asked for the real host.

- model.go: the local model's SECRET/ACCOUNT span on 0x and 40 hex
  digits (evmRe) is left as written; no rule matched it, the model's
  label did (the 0x prefix and mixed case got past hexRe). A 64-hex
  private key is masked still, and so is a 40-hex value called a key
  (secretCued).
- shape.go: an IP the IP rule masks goes as an address from the
  documentation ranges (192.0.2/198.51.100/203.0.113 .101-.254, IPv6
  2001:db8::/32), stable for the value, never shared by two values
  (falls back to {{IP_…}} past 462 IPv4 ones), and put back only as a
  whole address in replies and streamed tool calls (restoreAddr).
  Preview shows the same stand-in.
- docs: gateway-routing.md, and masking.html in en/zh/ja.

Run:
- Real models through the local gateway, the screenshot's ssh prompt
  with the placeholder vs a documentation address: with
  {{IP_k3v9x2mq}}, deepseek-v4-pro, glm-5.3, kimi-k3 and
  claude-sonnet-5-5 mostly searched ~/.ssh or asked for the real IP;
  with 203.0.113.147 or 192.0.2.183 all 20 runs over 5 models ran ssh
  at once.
- New tests (internal/redact/standin_ip_test.go): the screenshot's
  message, the tool call restored whole and streamed cut at every byte,
  boundary cases, IPv6, 472 addresses never sharing, the screenshot's
  address under labels secret and account_number with every category
  on, and a 64-hex key still masked. gateway TestRedactedKinds now
  wants a documentation address upstream.
- Broken by hand: without the evmRe check TestEVMAddressGoesAsWritten
  is red for every text and label; without restoreAddr the boundary
  cases are red; without the IP stand-in all three IP tests and
  gateway TestRedactedKinds are red.
- On mote at this head (rebased on 27bf14790): gofmt -l, go vet
  ./... for darwin, linux (-tags nogui) and windows, go test -count=1 -timeout 45m
  -tags nogui ./... (and go build for
  darwin, linux -tags nogui and windows): every package ok, exit 0.
  The run before at 56602426d had TestMoreKinds red, which wanted
  {{IP_…}}; it now wants the documentation address.
- Rebased again on 56d26f0bb (two gateway commits, #4004): go vet
  and go test -tags nogui of internal/redact, internal/gateway and
  internal/maskrec on mote at this head: ok.

Not tried:
- the real AstrLink model on an EVM address (the fake model gives it
  the labels it can give);
- a host name (user@host) still goes as {{HOSTNAME_…}};
- a documentation address the user writes themselves can match a
  stand-in in a reply and be put back as the real one;
- stand-ins are not kept across a restart or once their slot is
  evicted, like every placeholder.
2026-10-28 20:23:38 +08:00
yetone 6a074fc132 pii: the default's local model reads what a request adds first, a backlog 4 KB a request, on 4 cores at most
shensmart and xinvxueyuan on Discord (10-28): with the local model on by
default, a long history kept the CPU high; the model off, 5-15%.

What was heavy (measured, TestLiveHistoryCost below): not re-reading.
A text read once is kept by hash (cache, on disk too), and a warm turn
costs what the rules alone do. The heavy case is a history the model
hasn't read (a resumed session, or one from before the model was on),
on the CPU path (Linux, Windows, Docker). Each request's 2 s wait was
spent reading that history oldest first on every core (threads =
GOMAXPROCS-1, windows at once = GOMAXPROCS), the newest turn last, and
the 12 KB chunk in flight was finished past the wait. A 32-core Linux
box spent 33-60 CPU seconds a request, 13 cores busy for as long as
requests came, and the backlog was still unread after 30 requests.
Nothing ran on after the last request (1 ms CPU in the 20 s after).

Now:
- guard.Cores: AstrLink Guard reads on half of GOMAXPROCS, 4 at most.
- backend.missing reads a request's unread texts newest first (the last
  text, a long one's last piece, first).
- AstrLink Guard's chunk is 4 KB (backend.chunk), not 12 KB, so what a
  request leaves the model finishing past its wait is about a second.
- pii.Bounded (masking's default, not a model the user turned on):
  what a request went without reading is remembered by hash
  (backend.sent); a request after it reads what it adds first, and that
  backlog backlogCap (4 KB) at most, nothing found for the rest (the
  rules mask it, as past the 2 s wait). The answer past the wait with
  what was read is 874b86653's (pii.Partial), unchanged.
- A model the user turned on (strict) still reads everything, within
  874b86653's strictWait.
- Not done: OS priority (nice) for the model's threads; the core cap
  is the bound.

Measured, TestLiveHistoryCost (internal/masking, gated on
MAGPIE_GUARD_FILES, no network): a 2,041,658-byte Codex Responses
body (2,032,267 bytes at the rebased tree), 200 turns (repo files as tool output, doc paragraphs as answers,
Chinese names and an email every 10 turns), 30 requests 3 s apart, a
turn more each, model never having read it, then 20 s idle.

WSL2 Ubuntu 24.04 on xiaomi-gpu (32 cores, CPU path):
  before: 33-60 CPU-s a request (44.0, 38.3, 50.4, 42.8, 54.3 ...),
          session 23m16.8s CPU over 1m48s (1293% of a core),
          wall median 2.759s, max 3.07s; 20 s after: 1 ms
  after:  6.3-9.2 CPU-s a request, session 4m1.5s over 1m30s (268%),
          wall median 2.389s, max 2.438s; 20 s after: 1 ms
  warm turn after a full read: 876ms wall / 5.284s CPU before; after
          the rebase the "full read" is strict and stops at 874b86653's
          15 s, so that line is not a warm turn (2.41s / 7.9s); before
          the rebase, at a full read, 1.28s / 3.04s (4 cores, not 31)
  rules alone: 394 / 384 ms CPU
mote (M5 Pro, CoreML):
  before: requests 1-3 2.2 CPU-s each, then ~0.45; session 18.7s CPU
          over 1m30s (21%); warm 396ms / 380ms
  after:  request 1 2.12 CPU-s, then 0.44-0.62; session 17.2s CPU
          (19%); wall median 562ms; warm 476ms / 465ms

On the CPU path a turn adds about 15 KB here, more than 4 cores read
in 2 s, so each request still spends its wait (now on 4 cores, newest
text first) and the backlog isn't reached until turns get shorter;
on CoreML the backlog is gone after the first request.

Tests, each red with its part of the change undone by hand:
- TestNewestTextReadFirst (pii): red on the old code as it stands
  ("read first: a a a ..."); red again with the last piece not first.
- TestBoundedReadsTheBacklogALittleARequest: backlog cap removed, the
  second request read 75169 bytes.
- TestGuardReadsShortChunks: red with guard's chunk unset (12288).
- TestReadsOnFewCores (guard): Cores at 32 and 1 procs.
- TestDefaultModelIsBounded (masking): red with the default's ctx not
  Bounded ("on by default, the model wasn't asked Bounded").
- TestJoinSplitsAtChunkSize now expects the newest-first order.

Rebased onto 874b86653 (strictWait, pii.Partial), which made the
same partial-answer change; mine was dropped for its. Everything below
was run again at the rebased tree.

Run at this tree: gofmt -l clean; go vet darwin, GOOS=linux and
GOOS=windows -tags nogui on internal/pii/..., internal/masking,
internal/redact; go test -count=1 -timeout 45m of those on mote,
wsl-run (magpie-desktop) and win-run (xiaomi-gpu), all ok; internal/gwmw ok;
-race -count=5 of the pii/masking turn, wait, partial and bounded tests
on mote ok; internal/gateway, internal/gui -run
'Mask|Redact|Privacy|PII' ok; TestLiveHistoryCost on mote and WSL. Not run: the full ./... suite.
Not tried: a real Codex session through a live gateway.
2026-10-28 19:53:35 +08:00
yetone 874b86653d masking: the model the user turned on is waited 15s at most, and what it read is kept (xRayySummers on X)
xRayySummers on X (0.1.1877, Linux, AstrLink Guard turned on in
Settings -> Privacy): in one minute masking took 1.2s to 290s, and each
request whose wait ended was "gateway: masking failed, so nothing was
sent".

Cause: the model reads on the CPU one chunk at a time on one turn,
about 6 KB a second on 8 Linux cores. A burst of requests with text it
hadn't read (new tool results, subagents at once) queued behind each
other, and the turn goes round between chunks, so all of them finished
near the end of the burst. Turned on by the user, the wait had no
bound, and when anything ended it (the client, a deadline) masking.model
panicked: the request was held back whole, and even the finds already
cached for its history were thrown away (backend.find returned nil).
Not a reload (60-90ms) and not a lock in redact.

Now:
- pii.FindContext, when the wait ends, answers with what was known of
  the texts (its cache: earlier turns' history, chunks read meanwhile)
  and a *pii.Partial saying how many it hadn't read.
- masking.model waits at most strictWait (15s) for the user's model,
  defaultWait (2s) for the default's as before. Past it, the model's
  finds mask what it read and the rules mask the rest alone; the request
  goes. Nothing the rules mask goes as written. Logged once a minute.
- A model that fails (not on disk, didn't load, held back after a
  failure) still holds the user's requests back, as before: broken, not
  busy.
- masking.find gives a model that doesn't stop for ctx 100ms (handBack)
  to hand back what it knew, so a partial answer racing ctx.Done isn't
  dropped.
- docs/subsystems/gateway-routing.md says so, with the numbers below.

Run:
- Reproduced with the real AstrLink Guard (guard-7216b6a3) on Linux
  (wsl-run, magpie-desktop, GOMAXPROCS=8), a throwaway test not
  committed: load 63-87ms, reload on a request 57ms, a 125 KB history
  20.8s first read and 66us cached; six requests at once with 67-145 KB
  of new text each took 62, 91, 92, 108, 108 and 110s on the old code.
  With this change each went at 15.0s with the history's 14 finds and
  the model's finds for 1 to 4 of its 9 texts.
- mote-run at df9376592 plus this change: gofmt -l clean; go vet of
  internal/pii, masking, gateway for darwin, GOOS=linux and
  GOOS=windows ok; go test -timeout 45m ./internal/pii/...
  ./internal/masking/... ./internal/redact/... ./internal/gwmw/...
  ./internal/gateway/ all ok (gateway 459s).
- wsl-run and win-run: go test ./internal/pii/... ./internal/masking/...
  ok.
- After the rebase onto origin/main (no overlap in these files): the
  same pii and masking tests again through mote-run, ok.

Broken by hand, each red:
- backend.partial back to `return nil, waitErr(ctx)`:
  TestStoppedRequestKeepsWhatWasRead fails (no Partial).
- strict mode waiting with no deadline:
  TestStrictModelStalledIsTheRulesForWhatItDidntRead fails at its bound
  ("held the request with no bound").
- strict mode panicking on a Partial as the old code did: the same test
  fails ("held back").

Not tried: the reporter's machine, and a real Claude Code burst through
the gateway with the model on; the reproduction called the model's
backend directly.
2026-10-28 19:17:41 +08:00
yetone 7c900f468f antigravity: a tier Google refuses in fetchAvailableModels is asked once a day and is no "Model list" row (ferock4669)
ferock4669 on Discord: with an Antigravity subscription, the Requests
page filled with "Model list" (模型列表) rows for
/v1internal:fetchAvailableModels, each answered 400.

Cause. For an account loadCodeAssist gives a paid or non-free tier,
magpie asks fetchAvailableModels first with entitlement.userTier named
(7806395c7: the paid tier, then the current tier) and, on a refusal,
again without one. The only real paid account seen (#1553, AnxForever's
log: free-tier, paid g1-pro-tier, aicode-consumers) gets 400
INVALID_ARGUMENT "Request contains an invalid argument." for the named
tier and its list from {project} alone. magpie remembered nothing, so
every list (start-up's FetchNew, the hourly relist, Refresh, sync) and
every quota reading sent that 400 first, and each list ran under a
probelog KindList mark, so the refused request was written down as a
failed model_list row (quietProbe hides only answered lists). The list
itself came from the second request. The request without a tier is
what CLIProxyAPI, sub2api and Antigravity-Manager send; the value the
official client puts in userTier for a paid account is still not known
(Antigravity isn't installed on any box here, nothing captured in the
repo), so the request isn't changed beyond not repeating the refusal.

Now:
- a tier Google answers 400 is left out of that account's
  fetchAvailableModels (lists and quota readings) for tierRefusedFor
  (24h), keyed by refresh token, project and tier, so a tier the account
  newly has is still asked; a 503 or other failure doesn't rest it;
- a request with a tier named is sent under probelog.Taken: a step
  towards the list, no row of its own; the request without one is
  written down as any list, so a list that really fails is still one
  400 row under Failed;
- googleAccount.call returns codeAssistError carrying the status, with
  the same message text as before.
Retries: FetchNew asks an account with no list at most every
newFetchRetry (1 min) while a page is open, the relist hourly; with this
a refused tier adds no extra request to either.

Docs: gateway-sessions.md (a list's step is no row) and
providers-accounts.md (askTiers, tierRefusedFor).

Tests: TestAntigravityRefusedTierAskedOnceAndNoRow (#1553's replies:
three Fetches and a quota reading name the tier once, 5 requests, no 400
row; a day later it is named again; a list refused without a tier too is
one row "400 model_list /daily/v1internal:fetchAvailableModels") and
TestAntigravityTierNotRestedForOtherFailures (a tier answered 503 is
named again). Broken by hand on mote:
- without probelog.Taken: FAIL "a refused tier written down:
  {... Kind:model_list ... Endpoint:/daily/v1internal:fetchAvailableModels
  Status:400 ...}";
- without tierRefused: FAIL "asked 8 times, 4 with the refused tier
  named; want 5 and 1".
Both pass with the change, as do the existing tier tests
(TestAntigravityTierRefusedFallsBack, ...ProInvalidTierAsksWithoutOne,
...TierFreeAndKeptProject, ...ProAccountNamesItsTier).

Run on mote (mote-run), at efb55b5c9 + this change: gofmt -l on the
changed Go files prints nothing; go vet ./..., GOOS=linux go vet -tags
nogui ./..., GOOS=windows go vet ./... exit 0; go build, GOOS=linux go
build -tags nogui, GOOS=windows go build exit 0; go test -count=1 -tags
nogui -timeout 45m ./... under a sandbox HOME with pinned caches: exit
0, 77 packages ok, no FAIL. Rebased on origin/main b3edcabf2 (no change
to google.go, probelog or usage's probes) and ran internal/provider,
internal/probelog and internal/usage again at the pushed head: ok.
GUI suite not run: no file under internal/gui changes.

Not tried: a real Google AI Pro/Ultra account (none here), so the 400
in ferock4669's rows is matched to #1553's by shape, not by their log;
the official Antigravity client's userTier value for a paid account.
2026-10-28 19:07:21 +08:00
yetone df9376592d routing: a group's member may offer several reasoning levels for the agent to pick among
Garydesu on X: "能不能让路由组里的模型设置多个可选推理强度,现在只能选一个或者整个
路由组的". A member was one fixed `:effort` or followed the group's levels.

A member's suffix may now join several levels with "+",
`provider/model:low+xhigh`, kept lowest first, each once. provider.MemberLevels
splits it into Member.Levels and leaves Effort empty, so the member isn't
fixed; one level is a fixed effort as before. The whole stays the member's
id, so rules, fast, off, weights, share and the CLI key it as any member.
The gateway fits the agent's ask to the member's own levels (groupLevels
returns the candidate's levels first; ofMember, the quiet check and the
trace see them), and the group lists them to agents (buildGroupEntries),
intersected with the other members' as usual. In the Routing page's group
editor the member's reasoning menu has "Several levels…", a menu that stays
open with each level ticked or not; a fixed level picked from the first menu
replaces the old one as before. i18n in zh, zh-TW, ja, de; CLI help and
docs/subsystems/gateway-routing.md say it.

Run on mote (mote-run). Rebased on efb55b5c9 (past e1721d640, which
changed the group editor) and run again there: provider, gateway, cli ok;
gofmt clean; GUI group-member-levels, group-member-fast,
group-member-weight, group-from-model-add and i18n-keys 53 of 54, the red
being i18n-keys' "masking…" from e296211b8, red on main (#4053). Linux
and Windows vet were clean at 7fe98c2af. Earlier, at the first base:
- go test -tags nogui -timeout 45m ./internal/provider ./internal/gateway
  ./internal/cli ./internal/tui ./internal/gui: all ok (gateway 525s).
  internal/cli again after the help wording below: ok.
- gofmt -l: nothing.
- GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., go vet
  ./...: clean (darwin prints cgo warnings only).
- Whole GUI suite (node --test "internal/gui/tests/*.test.cjs", both
  engines, load 140 at its peak): 13,931 tests, 119 red in 31 files. One
  was this change: i18n-keys' "a plugin's words are its own", because the
  CLI help said "the agent picks among them" too; reworded the help, and
  i18n-keys passes. The other 30 files, run alone at --test-concurrency=4
  at this tree and at its parent e8c7dddcb: the same files red on both
  (97 and 100 cases, the routing-rule ones a random subset each run, all
  waiting on clicks), each with an open issue (#3527 lists the pattern;
  segs-press-redraw #3922, routing-story-shrinks #3954).
  group-from-model-add, account-*, login-import and signin-* pass alone.
- group-member-levels.test.cjs: 30 of 30 (5 languages, both engines,
  1100px and 420px); group-member-fast.test.cjs 4 of 4.

Broken by hand:
- groupLevels without the member's levels: TestMemberSeveralLevelsFollowAgent
  red (asked high, sent high, not xhigh).
- buildGroupEntries without the member's levels: TestMemberSeveralLevels red
  (offered all four, not low and xhigh).
- main's routing client.js: group-member-levels red 3 of 3 (chromium en).

Not tried: a real agent picking among a member's levels against a real
vendor; the TUI (its reasoning toggle cycles a "low+high" member back to
following the group, unchanged code).
2026-10-28 18:52:39 +08:00
yetone 25df3187bf gateway: a model whose upstream says thinking.type must be "enabled" is asked again thinking
cybercaius on Discord (#help), v0.1.1862: Claude Desktop's connection
check failed with 'Gateway rejected model
"magpie-0958175816.anthropic.claude-haiku-5-5[1m]" (HTTP 400)', the body
'天翼云: {"error":{"message":"{\"code\":\"400\",\"message\":\"thinking.type
must be \\\"enabled\\\" …","type":"upstream_error",…}}'. 天翼云 is his own
provider, a relay whose message is its own upstream's whole body.

What was sent: Desktop's check ({"max_tokens":1,"messages":[{"role":
"user","content":"."}]}, raised to 16) asks for no thinking. Relayed to
a Messages provider, a vendor's model gets thinking {"type":"disabled"}
(thinkingOffUnlessAsked) and a Claude-named one none; translated to Chat
it gets no reasoning_effort. Nothing today changed that: no gateway
commit since yesterday touches what thinking is sent. What changed is
where the check goes: ee6f8866f sends it to Desktop's default (his
天翼云 group), and c30e2a645 (v0.1.1861) has it go by the group's order
instead of a classifier's pick, so the group's first member now gets
it. Why the refusal wasn't read: refusesThinkingOff knows a vendor
refusing thinking *off* (alwaysThinks, thinkingOffRefused, …), and its
retry only takes "disabled" out, which leaves thinking absent, still
not "enabled". Nothing knew an upstream that wants thinking enabled.

Now (thinking_needed.go): a 400 saying thinking.type must be enabled
(thinkingNeededRefusal, read off the reply, not the provider) is asked
again once thinking at Anthropic's least budget, 1024, max_tokens raised
past it by what was asked (16 -> 1040) and temperature/top_p/top_k
left out (withThinkingEnabled); markUnfit(thinkingNeeded) keeps the
model so until restart, so the next check or title goes thinking in
one call. Both routes: passthrough (relayed Messages), forwardTranslated
(Messages body once built; Chat/Responses at the lowest effort via
thinkingBackOn), and translate for a non-streaming client whose refusal
came in a 200 stream. forwardOnce doesn't turn such a model's enabled
into adaptive (a Claude 5.5 name would otherwise send adaptive and be
refused again). docs/subsystems/gateway-routing.md says so.

Test: TestClaudeDesktopProbeThinkingNeeded, Desktop's literal check on
the literal id through a 天翼云 group to a fake that answers the
reported body (wrapped as the relay wraps it) whenever thinking.type
isn't "enabled": a vendor model and a Claude name on Messages, Chat
with the refusal as a 400 and inside a 200 stream. Each: 200 in two
calls, the retry carrying enabled/1024 under max_tokens > 1024, then the
next check and a title in one call. TestWithThinkingEnabled.

Run (mote, at this tree): the tests above; go test -tags nogui
./internal/gateway/ (whole package): ok (537s); gofmt -l clean;
go vet ./internal/gateway/ for darwin, linux, windows: ok.
The package run was at d6df72a2b plus this change; rebased on
51247a55b (0b99b8fbe touched internal/gateway), the new tests with
-run 'Desktop|Thinking|ThinkOff|Translated|LoopGuard': ok.

Broken by hand (each red on mote):
- gateway.go as on origin/main: all four subtests 400 with the reported
  message, byte for byte in its shape;
- adaptiveThinking not skipped: the Claude-name subtest red (sent
  thinking adaptive);
- the in-stream retry in translate off: the stream subtest red;
- the memory off (upfront thinking in passthrough and
  forwardTranslated): every subtest red ("after: 200 in 2 calls", or
  400 once the retry's own fits check stops it).

Not tried: the reporter's real 天翼云 relay, or which API it is on
(Messages or Chat) — the reply shape fits both, both covered; a relay
that turns reasoning_effort into thinking (the Chat cases assume it);
a streaming client's refusal inside a 200 stream (only the
non-streaming one, Desktop's check, is asked again); a real Claude
Desktop. Not run: the full ./... suite.
2026-10-28 17:53:52 +08:00
yetone e296211b8b masking: the default's local model is waited for 2s at most, then the rules mask alone
shensmart on Discord (10-28, magpie in Docker on Linux, web UI remote):
Codex's requests sat "masking…" on the Requests page from about ten
minutes into use. ae0327945 (v0.1.1858) turned the local model on by
default: once its download finished it was recorded (RedactModelAuto)
and warmed, and every request then waited for it. Under the default
model() passed the request's own ctx to m.Find, so the wait (for the
one-at-a-time turn, the load, and a whole uncached history read 12 KB a
chunk on the CPU) lasted as long as the client did, and the unrouted
watch doesn't count masking time. AstrLink Guard is pure Go on the CPU,
so it runs in a container, slowly; a slow model was the hold, not one
that failed (that one already fell back to the rules).

- masking.model: not turned on by the user (strict false), the model
  is waited for defaultWait (2s) from the request's masking start, and
  given up even where Find doesn't stop for ctx (a goroutine and a
  select); then it finds nothing and the rules mask alone. Turned on by
  the user, unchanged: the request waits, and is held back on failure.
- pii backend.find: a caller that stopped waiting leaves the chunks
  after the one under way, instead of a select on a free turn and an
  ended ctx taking either, so a stopped read doesn't hold the turn every
  later request's 2s needs. The chunk under way is still finished and
  kept, so the next request finds it.

Run (mote, Go 1.26.8):
- gofmt -l clean; go vet of internal/masking and internal/pii, and
  GOOS=linux and GOOS=windows vet of both.
- go test -count=1 ./internal/masking ./internal/pii ./internal/redact: ok.
- At the rebased head (on 0b99b8fbe): go build -tags nogui ./..., vet
  as above, go test -count=1 of masking, pii, pii/guard, redact: ok.
- go test -count=5 for the new and nearby tests (TestDefaultModel*,
  TestNoModelYet*, TestModel*, TestStoppedRequestLeaves*): ok.
- go test -count=30 -run TestStoppedRequestLeavesTheRestOfItsChunks
  ./internal/pii: 30 of 30 ok.

Broken by hand: both new tests were run on the old masking.go and
find.go, with only a defaultWait var added so the tests compile.
TestDefaultModelHangingIsTheRules was red 20 of 20 ("on by default, a
model that never answers held the request", at its 10s bar).
TestStoppedRequestLeavesTheRestOfItsChunks was red 19 of 30: 2 or 3
chunks were read for a request that stopped after the first.

Not tried: a real Docker container with the downloaded AstrLink Guard
and a real Codex history; the reporter's machine. The masking page's
原文/对照 buttons are disabled with no word why when the original body
isn't held (a restart, over 4 MB, out of the last 100): not changed
here, filed as #4045.
2026-10-28 17:52:53 +08:00
yetone 51247a55b2 docs: one commit, one goal moves into the code standards (seen a third day)
LESSONS.md's "One commit, one goal" was seen on 10-05 and 10-06. On
10-28 6e080ca04 answered two reports in two layers under one subject:
psikent's /v1/models tools flag (gateway) and windy's routing group
Context hint (GUI, five languages), the subject naming only the first.
A revert of either takes the other with it, and the record can't say
which test guards which.

- docs/code-standards.md, Commits: a paragraph on one goal per commit,
  with 653cb8ee, 1e0829b1 and 6e080ca04.
- LESSONS.md: the lesson replaced by a pointer, and listed under Moved
  to the code standards with the 10-28 evidence.

Docs only. Checked that no test reads either file's content
(loop_guard_test.go and rtk_detect_once_test.go only name them).
2026-10-28 17:51:52 +08:00
yetone a5315c70d5 redact: the local model doesn't read an agent's tool definitions (niuniu_8964 on X)
码妞 on X: the official container on a 4-core, 8 GB server, AstrLink Guard
on, Claude Code's requests sat at 脱敏中 for minutes and timed out, load
1.78, a short conversation. aca0f0d8a made Guard read a text's windows
at once; this takes away most of what it reads.

MaskJSON asked the model about every text it masks, the tools'
descriptions and their schemas' too. On Claude Code 2.1.296's own request
(internal/gateway/testdata/workdir) that was 67,532 bytes, 52,577 of them
definitions: the agent's or a tool server's text, the same in every
request. The per-text cache only helps after the first request has been
read whole, so a fresh install (or new tools, or a Claude Code update)
paid for all of it at once, past the gateway's 2 minutes on a slow CPU.

Now what is under the request's definitions (defKeys, defItems) is never
sent to the model; it is masked as with the model off, by the rules
alone (emails, phones, keys, the user's words still are). It is masked
after the rest of the request, so a value the model found in a message
is masked in a definition too, as known. The system prompt and messages
are read as before.

Measured on magpie-desktop (WSL, Ryzen AI Max+ 395, taskset to the CPUs
named), real Guard model (rev 7216b6a3, sha256s checked), that request
through redact.MaskJSON with guardBackend, cold cache:
  4 CPUs: 129 texts, 67,532 bytes, 11.5s before; 7 texts, 14,955 bytes, 2.6s now
  2 CPUs: 20.9s before, 4.9s now
  rules alone 13-15ms; the same body warm 13ms, the next turn 36-44ms,
  before and after.
On three real Claude Code requests (claude-code-2.1.296.json,
context/claude-code.json, dsh-gateway messages-turn.json), masked with
the model at 0.8 and with the rules alone, every top-level key came out
the same: the model masked nothing in their definitions that the rules
didn't.

No time cap was added. The reporter turned the model on (the default-on
model is from today, ae0327945), so a request there is held for the
model and never falls back to the rules; a cap would only turn the wait
into an error. Less to read is the fix.

Tests:
- TestModelNotAskedAboutDefinitions (new): on Claude Code 2.1.296's and
  Codex 0.162.1's own requests no definition's text is asked about, and
  every long text said is.
- TestDefinitionMaskedAsWithoutModel (new): a tool's description and a
  schema property's come out as with no model; the email, the key and
  the phone in them are masked.
- TestModelAskedOnceForRequest: now asks about the message only, and the
  description's name is still masked (as known).

Run:
- mote-run: go vet ./internal/redact ./internal/masking, GOOS=linux and
  GOOS=windows go vet of them: ok. go test ./internal/redact/...
  ./internal/masking/... ./internal/pii/... ./internal/gwmw/...: ok.
  go test -run "Mask|Redact|Privacy|Unmasked|Masked|Placeholder"
  ./internal/gateway ./internal/middleware ./internal/gui: ok.
- wsl-run: go test ./internal/redact ./internal/masking: ok; the stage
  timings above (a scratch test, not committed).
- gofmt -l: clean.
- The vet and the test lines above ran again after rebasing onto
  d6df72a2b (its own redact change), and redact, masking and the
  gateway masking tests again on 25fc92d59: ok.

Broken by hand:
- Definitions sent to the model again: TestModelNotAskedAboutDefinitions
  red ("the model was asked about a definition's "Launch a new agent…""),
  and TestModelAskedOnceForRequest red.
- Definitions masked in the first pass, before the messages:
  TestModelAskedOnceForRequest red ("description":"find Rina Kowalczyk"
  went as written).

Not tried: the reporter's server, the Docker image itself, or a real
Claude Code session through it; a Chinese full name only in a tool's
description is no longer masked (the model was what found one; the rules
mask Chinese names only beside the model). The full go test ./... wasn't
run: mote had another session's full suite on it at load ~216, and only
internal/redact changed.
2026-10-28 17:36:40 +08:00
yetoneandtimonwong 25fc92d59a fallback: a model unchecked in its provider's list is not a fallback to go to (#3911)
The sibling of the group fix before this: a provider's Fallback list
resolved each entry with Resolve, so a fallback the user unchecked in
its own provider's list was still sent to, while the fallback editor
says "No provider serves {id} now; it is skipped". plan's fallbacks,
and the places that read the same list (carefulOf, native compaction's
carrier check, unredactedRoute, codexFallsBack), now resolve through
provider.ResolveRoute, which skips it. ResolveRoute scans the entries
once for the one model rather than building a map per request.

Test: fallback_unpicked_test.go, plan/m answering 429 with fallbacks
a/x (unchecked) and b/x goes to b and never to a.

Run (mote): red on the previous commit's tree ("from ka", a tried
[ka]); green with this one. Full suite as recorded in the previous
commit, which ran at this tree: 76 packages ok, internal/plugin's
TestGatewayHookMixedPiPackage red at load ~134 (#2865), passing alone.
go vet darwin/linux/windows clean.

Not tried: a real provider with a fallback in the app.

Co-authored-by: timonwong <timon86.wang@gmail.com>
2026-10-28 17:34:16 +08:00
yetoneandtimonwong f561cc5d9b groups: a model unchecked in its provider's list is not a member to route to (#3911)
timonwong (#3911, also on Discord #feedback): with a group of a/x and
b/x, unchecking x in provider a's model list struck a/x on the Routing
page, but group/<id> still sent requests to a. membersOff resolved each
member through resolveIn, whose provider/model step takes any model of
a provider that is on, so that a request can name a model its list
lacks.

membersOff now skips a member whose provider has picks and whose served
models lack it (unpicked), as timonwong's fork did (38615ca9). A
provider with no picks still routes a model its list lacks (#2642), a
decision model (never in the catalog) is still a decision group's, and
a request naming a/x itself still reaches a. Every route mode goes
through membersOff (ordered, weighted, rotate, manual, nested groups,
found groups, count_tokens' group lookup), so all of them get it. The
entries map is built only when a member's provider has picks.

The Routing card's memberInfo (gui/groups.go) used Resolve too, so a
manual group's pick row showed an unchecked member as ready; it now
asks provider.ResolveRoute, the same check, and the group is not ready
when its picked member was unchecked.

Tests: group_model_pick_test.go (ordered, weight, rotate; nested; a/x
named directly still served; checked again comes back; a decision
group keeps a picked decider) and gui's
TestGroupMemberUncheckedInItsProvider.

Run (mote, at this tree plus the next commit):
- Red on c30e2a645 with only the tests: the three route modes, the
  nested case and the GUI test fail ("from ka"); direct and checked
  again pass, as they should.
- Broken by hand: without len(p.Models) > 0, seven gateway tests go
  red (TestNativeCompactionWriterThroughAGroupWhoseListLacksTheModel,
  TestCodexSpentMovesToNextGroupMember, TestWeightedGroupGivesALowGroupItsShare,
  TestVideoGroupMovesOnToTheNextMember, TestPolicyRefusalMovesToNextGroupMember,
  TestCodexSealedAgentHandoffGoesToGroupsChatGPTAccount,
  TestClaudeClientCacheGroupKeyKeepsMarks); without !DecidesModel,
  TestDecisionGroupKeepsAPickedDecider goes red.
- go vet (darwin, GOOS=linux, GOOS=windows) on provider, gateway, gui:
  clean; gofmt -l clean.
- go test -tags nogui -timeout 45m ./...: 76 packages ok; one red,
  internal/plugin TestGatewayHookMixedPiPackage "starting plugins:
  context deadline exceeded" at load ~134 (#2865, filed); it passes
  alone on the same tree (26s).

Not tried: the real GUI app with a real provider; no GUI JS changed,
so the Playwright suite was not run.

Co-authored-by: timonwong <timon86.wang@gmail.com>
2026-10-28 17:34:16 +08:00
yetone d6df72a2ba redact: a disassembly's symbols (system@plt, foo@@GLIBC_2.2.5, system@got) are no email
ch35tnut_ on X: reversing, symbols like system@plt were masked as
emails, so masking had to be turned off for reverse engineering.

The rule's regexp already needs a dot and a mail TLD (mailTLD), so
system@plt, puts@got.plt and memcpy@GLIBC_2.14 went as written by it at
origin/main. The local model's EMAIL spans pass realEmail too, which
never asked for a dot: .got is an ICANN top-level domain, so a model
span on system@got (IDA's "; system@got") was masked. And a
foo@plt.got ends in .got with a dot, so the rule masked that too.

realEmail now asks mailHost first, for the rule and the model alike: the
host has a dot, every label is letters, digits and hyphens (or non-ASCII,
an IDN's), no label empty, the local part does not end in @ (foo@@VER),
and the host is not made of linker table words alone (plt, got, sec,
iplt, igot: free@plt.got, memcpy@plt.sec). A version with an underscore
(@GLIBC_2_2_5) or no dot (@Base, @GLIBC_PRIVATE) is no host.

TestSymbolIsNoEmail has objdump, readelf, nm, gdb and IDA lines as they
print them, for the rule and for a fake model flagging each symbol as
private_email, and checks that rina.k@fastmail.com in code and
ops@build01.acme.io beside a symbol are still masked by both.

Run at this head (origin/main aca0f0d8a), through mote-run:
- go test ./internal/redact ./internal/pii ./internal/masking
  -count=1 -timeout 45m: ok, ok, ok.
- gofmt -l clean; go vet of the three on darwin, GOOS=linux -tags nogui
  and GOOS=windows: clean.

Broken by hand:
- mailHost's call made `false &&`: TestSymbolIsNoEmail red, the model
  masked "; system@got" as {{EMAIL_…}}.
- linker check made `return true || !linker`: red, rule and model both
  masked <free@plt.got>.

Not tried: the real local model (AstrLink / Privacy Filter) on a
disassembly; the fake model stands in for its spans. Full go test ./...
not run; this touches internal/redact and its doc only.
2026-10-28 17:23:59 +08:00
yetone 6e080ca044 gateway: every model in /v1/models says it takes tools, a routing group too
psikent on Discord: an SSH client judges what a model can do from its
list entry, and a routing group, whose id is the user's own name, said
nothing of tools, so the client handed it none. /v1/models and
/v1/models/{id} now give every chat row models.dev's tool_call: true
(beside the reasoning it already had) and OpenRouter's
supported_parameters (tools, tool_choice, and reasoning when it thinks),
which Kilo's and Cline's list readers use (kilo.go reads the same field).
magpie has no model that takes no tools (a call written as text is read
back as one), so a group's members all take them and the group says so.
No `capabilities` key: Cursor Private Inference reads it as an object,
Ollama and LM Studio as arrays of their own words; magpie's Ollama
/api/show already says "tools". Desktop's, Science's and the decision
models' lists are unchanged.

windy on Discord: a 1M DeepSeek group with a 128K Trae member. A group's
window and output stay its largest member's, images any member's, as
#712, #756 and ARNO's truncation report decided: the gateway sends a
longer conversation only to members with room (roomy, withRoom), and
Context: Smallest model's tells agents the smallest. The editor's Context
hint now names the member a longer conversation skips when the windows
differ ("…longer than 128,000 skips Trae CN · DeepSeek-V4.1-Flash…"), in en, zh, zh-TW, ja, de.
Compaction written to agent configs follows the same window (CompactFor,
CompactSet takes the smallest threshold the user set); unchanged.

Run (mote unreachable all session, so on the other test boxes):
- TestGroupListedTakesTools on Linux (wsl-run): green; red on the old
  gateway.go (a/m, b/m, group/g and /v1/models/group/g: tool_call false,
  supported_parameters []).
- group-context.test.cjs on the Windows box, Playwright 1.62.0,
  Chromium + WebKit, en and zh: 4/4 green; 4/4 red with the old
  routing assets (the hint named neither 128,000 nor the member).
- Every GUI file that opens the group editor (56) plus i18n-keys, both
  engines, on Windows: 816 tests, 792 pass, 24 red (793/23 on the run
  before the hint named a member's provider). The red files with the old
  assets: the same tests red (25). They are #3402, #3412, #3789, #3096 and name-suffix-saved's
  WebKit provider editor, not this change.
- Full Go suite, -tags nogui -timeout 45m, on Linux: all ok but
  internal/agent (7 install-detection tests), internal/proc TestTreeRSS
  and internal/gateway TestUploadStillUnderwayIsNotCutByHealthPing; each
  red at origin/main eb6d1d8d9 on that box too (#4033, #3909).
- gofmt -l clean.
Not tried: psikent's SSH client itself (not named yet), the GUI on macOS
WebKit (mote down), a real group in the running app.
2026-10-28 17:20:24 +08:00
yetone aca0f0d8a1 guard: a long text's windows are read at once, one a core (niuniu_8964 on X)
码妞 on X: on a 4-core server in the Docker image, with AstrLink Guard,
Claude Code's requests sat at 脱敏中 for minutes, load 1.78. Guard read a
long text's 510-token windows one after another, and split only each
window's matmuls and attention over GOMAXPROCS-1 goroutines; the layer
norms, biases, GELU and quantizing between them ran on one core. A
2-CPU container got one thread for all of it.

Find now reads every window's logits first, min(GOMAXPROCS, windows) at
once, each with GOMAXPROCS/that many goroutines of its own, then merges
them in window order as before, so what it finds is the same. A window's
procs are passed down (logits, encode, matmul, attention, parallel) in
place of the package's threads. CoreML (a Mac) still reads one window at
a time.

Measured on magpie-desktop (WSL, Ryzen AI Max+ 395), 69,495 bytes of
docs, 22,488 tokens, ~59 windows:
  GOMAXPROCS=4: 23.86s before, 17.90s now
  GOMAXPROCS=2: 48.8s before, 30.50s now
  GOMAXPROCS=1: 50.0s before, 57.0s now (the same code path; noise)

Run:
- wsl-run with MAGPIE_GUARD_DIR at the pinned model (rev 7216b6a3):
  TestWindowsAtOnceReadAsOneByOne (new: 200 synthetic contact lines, over
  4 windows, read at GOMAXPROCS 1 and 4, spans DeepEqual), TestModelFinds,
  TestKernelsMatchGo, TestTokenizerMatchesHF, TestDecodeBIO: ok.
- mote-run: go vet ./internal/pii/..., GOOS=linux and GOOS=windows go vet
  of it, go test -race ./internal/pii/..., go test ./internal/pii/...
  ./internal/redact/...: ok.
- win-run go test ./internal/pii/guard: ok.

Broken by hand: swapping the first two windows' logits after the wait
made the new test red ("windows at once found 800 spans, one by one
800": the same count, different spans).

Not tried: the reporter's own server, or a real Claude Code request
through the Docker image; TestCoreMLMatchesGo (needs the model on a
Mac) was only compiled. The full suite wasn't run: nothing outside
internal/pii/guard calls what changed but Find.
2026-10-28 17:15:16 +08:00
yetone eb6d1d8d97 redact: a colour or an ordinary word is no personal name (黄绿色, 关键词)
hh05928822 on X after v0.1.1850: names were found in ordinary Chinese,
"黄绿色" the worst, with 边••, 应••, 关••, 尚• in the screenshot.
wangjunxiao128: "关键词" taken for a name.

Both ways a Chinese name is found (the model's PERSON spans in
modelSpans, and the cue rules in zhNameSpans) now go through one check,
zhWordNotName: a span that is an ordinary word is no name, unless a role
before it or a title after it says a person is meant (客户方圆, 江山老师).
A word is (zhWordShaped):
- a colour: Han colour characters alone, or anything ending in 色
  (黄绿色, 红色, 金黄色, 浅蓝色);
- a two-character word starting with a surname, from zhWords or the new
  zhDict (边界, 应该, 尚可, 关心);
- such a word with a noun ending after it (关键词, 关键字, 应用层,
  毛利率, 时间戳, 文件名).
zhDict is zhdict.txt, embedded: ~1,550 two-character words from jieba
v0.42.1's dict.txt (MIT, in THIRD_PARTY_NOTICES), the first character a
surname, frequency >= 100, tag not nr/nrt/nrfg, and a list left out by
hand (陆游, 关露, 欧阳, 司徒...) in its header. The surname list keeps
黄, 关, 边: they are real surnames, so 黄晓明, 关羽 and 毛利兰 are still
masked. modelTakes' own zhWords check moved into the shared one.

Run on mote at 761e0e010 + this change:
- go test -timeout 45m ./internal/redact/... ./internal/pii/...
  ./internal/masking/... ./internal/maskrec/...: all ok
- go test -run TestNotices . : ok
- go test -run "Mask|Redact|Privacy|Person|Name|Known" ./internal/gateway: ok
- gofmt -l internal/redact: clean
- GOOS=linux and GOOS=windows go vet of redact, pii, masking: ok

Broken by hand, each red:
- zhWordNotName returning false (at 761e0e010 too):
  TestChineseWordsAreNoNames, TestModelWordsAreNoNames,
  TestModelNamesBesideWords.
- The colour rule, zhDict and the noun-ending rule each turned off:
  TestModelWordsAreNoNames and TestModelNamesBesideWords.
- The role/title exception removed: TestModelNamesBesideWords.
- The old model.go and zhname.go with the new tests: both new tests red
  (the cue rules alone masked 请黄绿, 发给黄绿, 张伟和黄绿).

The real AstrLink Guard model on mote (MAGPIE_GUARD_DIR) found 黄晓明,
关羽, 张飞, 毛利兰 and 工藤新一 with this change, and flagged none of
long agent-style prompts with 黄绿色, 关键词, 边界线, 边距, 应用层, 尚可,
on the old code or the new.

Not tried: the reporters' own texts (not in the reports), so their
exact false positive was not reproduced with the real model; Privacy
Filter; the GUI. 高峰期 is still masked: jieba tags 高峰 as a name.
2026-10-28 17:01:49 +08:00
yetone 6aa04f6e6a provider: a keyless relay on the user's own network imports and saves, as one on 127.0.0.1 does
iSnow_999 on X: their company's internal Codex relay is at
http://<LAN IP>:8080; imported from CC Switch, Codex couldn't reach it
through magpie. A CC Switch Codex entry with no key (requires_openai_auth
= false, auth {}) at a LAN address was listed as "it has no API key"
and left out, and the same provider couldn't be saved by hand ("needs an
API key"), while the same server at 127.0.0.1 was taken keyless.

keyOptional now also takes a host on the user's own network, read from
the URL alone (ownNetwork, no lookup since Ready asks often): a private,
link-local, loopback or carrier-grade NAT (Tailscale) address, or a
.local name, as netproxy's onLAN sends around a proxy. A keyless address
on the internet still needs its key. Every importer (CC Switch, Alma,
Codex, OpenCode) goes through imported(), and the editor, CLI and TUI
through Save, so the one rule covers them.

Ruled out against the code and on mote, sandbox HOME, fake relay on
mote's LAN address 10.0.0.116 at a free port, `magpie serve --web` built
from this tree, import through POST /api/importapps:
- a CC Switch Codex entry at http://10.0.0.116:<port>/v1 with a key
  imports with port, path, key and Responses kept, and /v1/responses
  through the gateway reaches the relay (Bearer sk-corp); with
  HTTP_PROXY/HTTPS_PROXY/ALL_PROXY at a dead 127.0.0.1:9 too (onLAN);
- a request with Codex's User-Agent, originator and
  x-codex-turn-metadata reaches the relay with them (sub2api's
  codex_cli_only gate reads these; port 8080 is sub2api's default).
After the fix, the same run with a keyless entry: imported, served, the
relay sees no Authorization header.

Tests: TestKeylessRelayOnOwnNetwork (import of a keyless LAN entry,
Save + Ready at 192.168/10/172.16/100.64/.local/[fd00::] addresses, a
keyless internet address still refused) is red on the old provider.go
and green now.
Run on mote at ae0327945 plus this change: go test ./internal/provider ./internal/tui
./internal/netproxy ok (98s, 10s, 4s); the full ./... suite was not run.
gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./..., GOOS=linux go build -tags nogui and
GOOS=windows go build ok.
Not tried: the reporter's own relay and config (not given); a host
with no dot (http://relay:8080) is still refused by the import's URL
check, which this change leaves alone: filed as #4028.
2026-10-28 16:59:10 +08:00
yetone ae03279458 masking: the local model is on by default; the rules mask alone until it is downloaded
The owner's plan (10-28, after the xuanwo/_kaichen reports under the
masking demo): with AstrLink Guard picked, the Chinese-name heuristic
is off and only nicknames like 小王/老李 stay a rule; with Privacy Filter
it is as before; every format rule stays; the model is on by default,
masks with the rules alone until its download finishes, and no longer
answers 503 for it.

- masking.ModelWanted(st): on when the user turned it on, off when the
  user turned it off (new RedactModelOff, set by SetRedactModel(false),
  remove, and cancelling the default's own download), on when the
  default's download finished (RedactModelAuto). A settings file from
  before this, with a model name picked or files on disk and the model
  off, reads as the user's off: magpie's default doesn't override it.
- Until the picked model is installed, requests are masked by the rules
  alone and fetch starts its download (one try per model per hour,
  never under testing.Testing(), nothing where the model can't run).
  When it finishes, settings.UseDefaultRedactModel records the default
  (it refuses when the user has set anything) and the model warms.
- model(..., strict): a model that fails holds requests back (503)
  only when the user turned it on; under the default the rules mask
  alone. The Privacy page says which ("…the rules mask requests alone"
  in en, zh, zh-TW, ja, de; /api/privacy-model has `chosen`).
- redact.Options.NamesByModel (AstrLink Guard picked): zhNameSpans
  keeps only zhNick candidates (小/老 + a surname).
- KeepOwn and POST /api/settings keep both new fields.
- Docs: gateway-routing.md, site masking docs (en, zh, ja).

Run (mote, Go 1.26.8):
- gofmt clean; go vet of masking, settings, redact, gui; GOOS=linux go
  vet of masking, settings, redact; GOOS=windows go vet of the four.
  (GOOS=linux vet of internal/gui needs cgo, as on main.)
- go test -count=1 -timeout 45m ./... at base 7fd77a944: every package
  ok except internal/gui. Its reds: TestCoreScriptBudget (+64 bytes,
  fixed by dropping a comment, budget not raised), TestPrivacyModelPick
  and TestSettingsSaveKeepsWhatItDoesNotSend (updated for the new
  default and fields), TestMainWindowCorners (#3949, red on origin/main
  e8c7dddcb too), and three AppKit tests killed at 20-30s under load
  just before mote rebooted, which pass in the rerun.
- Rerun at base 6bec526f7: internal/gui (only #3949 red), masking,
  settings, redact ok. GUI node tests privacy-model, masking-records,
  masking-demo, routing-masking, i18n-keys, gui-zh-tw, gui-ja, gui-de:
  Chromium 199/199, WebKit 106/106.
- At the pushed base 9e33962c0: TestCoreScriptBudget, TestSettingsSave*,
  TestPrivacyModel* ok; i18n-keys and privacy-model 68/68 in both
  engines.
- At the pushed base 7fcf642ee (masking in the request archive):
  -run 'Mask|Redact|Archive|Privacy' in masking, gateway, redact ok.

Broken by hand, each red: the nick filter off
(TestChineseNamesByModelOnlyNicks), ModelWanted needing RedactModel
(TestModelOnByDefault), strict ignored (TestDefaultModelFailingIsTheRules,
TestNoModelYetMasksByTheRules).

Not tried: a real default download in a sandbox HOME (the tests fake the
model). Known limit: a user who turned the model on before model picks
existed and then deleted it has no name or files left, so reads as new
and gets the default on.
2026-10-28 16:55:24 +08:00
yetone a1f06bd780 gui: a browser tab offers the fonts of the computer it runs on (Norcleeh)
Norcleeh (Discord #general): magpie in Docker, used through the web GUI,
Settings' font menu doesn't list the fonts he installed on his own
computer; the app does. Cause, confirmed in the code: a tab's list is
/api/fonts, the server's families (none in a nogui build such as Docker)
plus commonFamilies, filtered by what the browser draws. A family that
is only on the browser's computer was never offered, and a choice the
server doesn't list was dropped by desktopFonts.available.

Now (webfonts.js, which only a browser tab loads; the app's windows are
unchanged):
- Where the Local Font Access API is (Chromium on https or localhost),
  the press that opens a family menu calls queryLocalFonts() once a
  page, and at load when the local-fonts permission is already given.
  The families join the list with their real styles ("SemiBold
  Condensed Italic" -> weight 600, 75%, italic).
- Elsewhere (Safari, Firefox, a plain-http LAN address, a refused
  permission) the menu's search says "Search or type a font name…" and
  offers Use "name" for a family the list lacks, enabled when the canvas
  probe says this browser draws it, greyed with "This browser can't find
  this font" when not; Enter takes it.
- A chosen family the server doesn't list stays in the tab's list on
  later loads while the browser draws it, so it keeps being applied.
- The app's menu (openProtoMenu), never a <select>. Strings in zh,
  zh-TW, ja and de. docs/subsystems/gui-shell.md says so.
Budget: no raise. here() moved out of fonts.js into webfonts.js, which
isn't a core script: loadFonts import()s it in a tab only (the page has
no CSP). The core is 106 bytes smaller than origin/main's.

Run (mote-run). At this head on e8c7dddcb: gofmt, go build ./... and
-tags nogui, go test -run 'Font|Budget|Boot|Asset' ./internal/gui
./internal/fonts ok; fonts, i18n-keys, web-page, settings-general,
inner-scroll-contain 114/114. Earlier, on 6af83172d (with a <script>
loader in place of the import):
- fonts, font-cascade, win-fonts, i18n-keys, settings-* (10 files),
  text-size, web-page, web-app-standalone, mobile-web, gui-de, gui-ja,
  gui-zh-tw, menu-scroll, omarchy, proto-menu-overflow: 311 tests
  before the rebase, 300 ok. Red: mobile-web's 8 "desktop
  matches origin/main" subtests (they read origin/main through git, and
  a mote-run copy has no .git), and settings-lines-wrap webkit zh 440px
  (a Models tab press timing out at 8s under load). At the rebased
  head: fonts, i18n-keys, settings-general, web-page,
  settings-lines-wrap: fonts' WebKit half and a lines-wrap zh-TW press
  timed out at mote load ~210 (the box then rebooted); rerun at load
  ~14, fonts WebKit 21/21 and settings-lines-wrap 20/20, the rest of the
  first run ok. The 8s press is filed as #4026.
- New tests in fonts.test.cjs, Chromium and WebKit, en and zh, 1000px
  and 440px: "a browser tab lists the fonts of the computer it runs on"
  (queryLocalFonts stubbed: not asked before the press, asked once in
  it, families and real styles offered, applied, no settings POST) and
  "a browser tab takes a typed font when the API is missing/refused".
  All 16 red on origin/main's assets (MAGPIE_FONT_ASSETS): this
  computer's families not offered, the search not taking a name.
- Broken by hand: merge() without the tab's own chosen families: the
  typed tests go red at "kept across a reload, though the server lists
  no such font" in all 8 cases.
- go build ./... and -tags nogui, gofmt -l, GOOS=linux go vet -tags
  nogui ./internal/gui, GOOS=windows go vet ./internal/gui ok; go test
  -tags nogui -run 'Font|Budget|Boot|Asset' ./internal/gui
  ./internal/fonts ok.
- Real use on mote: a nogui `magpie web` in a sandbox HOME (server list
  57 common families). Chromium with local-fonts granted: 204 families,
  185 only on this Mac; Baskerville picked, drawn, kept across a reload.
  WebKit (no API): typed Didot, offered and taken, kept across a reload.

Not tried: Chromium's real permission prompt (Playwright grants it),
Firefox, a browser on another computer than magpie's, a Docker image
run, the full Go suite (no Go change).
2026-10-28 16:55:01 +08:00
yetone 7fcf642eed gateway: the request archive doesn't put an unmasked route back on masking (#3973)
wangbinyq (#3973, Discord #feedback): after v0.1.1840, with the request
archive on, a request to a provider set to go unmasked was still masked
whole before it was sent. ea53eb126 skipped masking only when
bodiesKeptAway() was false (internal/gateway/redact.go:272, called at
gateway.go:1947), and that was true whenever archiveDest() was on, or an
observer wanted bodies, so the archive put the masking pass back on
every request's way, the masked copy kept only for the archive.

Now an unmasked route is never masked on its way, whatever is on:
- The archive keeps the request as it went, as the log and recent calls
  do. Its secrets are taken out by redact.ScrubJSON in the background
  upload, as every archived body's are; the reply half was already as
  the local model wrote it.
- An observer that wants bodies (OTLP export, a JS plugin's) is handed
  them masked as before, masked once when withBodies first hands them
  over after a try (Call.maskIn, laterMasked), not before the send.
- bodiesKeptAway and serve's masked/plain swap are gone. count_tokens,
  embeddings, Jev and web search never read the archive switch.

docs/subsystems/gateway-routing.md says so.

Run on mote at this tree (rebased onto 6bec526f7):
- gofmt -l internal: none. GOOS=linux/windows go vet -tags nogui
  ./internal/gateway: ok (before the rebase, no gateway change since
  but upstream's own).
- go test -tags nogui -count=1 -timeout 45m ./...: 76 ok, no FAIL.
  (A run at the older base had TestPluginStreamsPastTheBudgetWait red,
  red alone too there; fixed upstream in 7fd77a944, green at this head.)
- Rebased again onto 9e33962c0 before the push (26 files, none in
  internal/gateway): go build -tags nogui ./... ok, and
  TestUnmaskedRouteIsNotMasked, TestArchive*, TestObserver*,
  TestPromptText* ok at the pushed head.
- TestUnmaskedRouteIsNotMasked gains "the request archive is on" and
  "the archive is on, unset", and checks what the observer and the
  bucket get.
- Broken by hand: with origin/main's gateway.go, redact.go and
  capture.go, "the request archive is on" is red ("masked 1 times,
  want masking false") and the observer case red (log masked).

Not run: a real magpie serve with the archive on against a local model
(ea53eb126's sandbox benchmark covers the archive-off case); a real S3
bucket; the GUI suite (no GUI file changed).
2026-10-28 16:53:54 +08:00
vincent aba11fc4de gateway: xAI's own API takes no null required in a tool's schema (#3392, kongkongklng)
The third round of #3392, after the reporter merged the system-turn fix:
codex went through, but every Claude call still 400ed — xAI answers
'Invalid request content: Schema validation failed: [standard_violation]
/required: null is not of type "array"'. A tool's schema said
"required": null where none were (Claude Code's own tools, an MCP
server's among them; Anthropic's API takes the null, xAI validates each
schema as a JSON Schema). The relay forwarded it as sent.

The key now goes wherever a tool schema leaves magpie for api.x.ai —
input_schema (Anthropic), parameters (Responses) and function's
parameters (the translated path), at the schema's root or nested; a real
array of names stays as it came, and a body with no null required keeps
its bytes.

Replayed on a fake xAI by the reporter's wording: the claude call with a
root and a nested null required goes through, Bash's real array and the
schemas' contents beside them as they were; with the shaper off, both
new tests go red. Full nogui gateway package: the four reds
(TestClaudeClientCacheAbsentUnchanged, TestCodexFittedImagesPastTheBudget,
TestMarshalRawIsEncodingJSON, FuzzMarshalRaw) match a clean-baseline run
of the same branch in the same session; a fifth clean-baseline red
(TestHandedOverGatewayFinishesItsStream, the known flake) passed here.
gofmt / go vet clean, linux/windows/darwin nogui builds pass. Not tried
against the real xAI API: no key here.

From skygunner's branch fix/issue-batch-1024pm; kongkongklng confirmed it on 10-25.
2026-10-28 16:52:55 +08:00
vincent d8938d2f00 gateway: xAI's own API takes neither a sealed item's null content nor a system turn in messages (#3392, kongkongklng)
The follow-up to 8ecab590, after the reporter merged it: the first Codex
turn through an xAI key went through and every one after it 400ed "Could
not decode the compaction blob. Ensure it is unmodified from the compact
response." — Codex hands the sealed reasoning item back with "content":
null beside its encrypted_content, which xAI's backend can't read. The
Grok subscription's plugin already drops that null (grokShaped), but the
xai preset shapes nothing, and the custom-tool refusal had only now let
a second turn reach the API. And every Claude call 400ed "Invalid request
content: Invalid message role.": Claude Code sends a system turn
mid-conversation (Anthropic made them GA), a role xAI's Messages takes
only as the top-level system.

xaiBody (api.x.ai, shaped in passthrough and on the built body in
forwardTranslated alike — a custom-tool refusal puts a Codex request on
the translated path from the next turn on) drops a reasoning item's null
content and folds each system turn into the top-level system, its text
and blocks as they came. Nothing is learned: xAI takes neither at all.

TestXAITakesCodexsSealedReasoningBack, TestXAILearnsCustomToolsThenTakesTheReplay
and TestXAIFoldsClaudesSystemTurn replay the reporter's session on a fake
api.x.ai and are red with the shaping off; the wording comes from the
report. gofmt clean, go vet and the builds (native, linux nogui, windows)
clean; go test -tags nogui ./... in a sandbox HOME: 66 packages ok, the
same 7 test failures as the clean branch head baselined the same session
(TestWriteAtomicReadOnlyHardLink, TestClaudeClientCacheAbsentUnchanged,
TestCodexFittedImagesPastTheBudget, TestMarshalRawIsEncodingJSON,
FuzzMarshalRaw, TestPluginSOCKSProxy, TestProgram). Not tried against the
real xAI API: no key here.

From skygunner's branch fix/issue-batch-1024pm; kongkongklng confirmed it on 10-25.
2026-10-28 16:52:55 +08:00
yetone 1d7ca4c6b7 gui: every scroller in every stylesheet is held to keep the wheel; Safari 15 too
碳碳双键 (ysm119, Discord): a list scrolled to its top or foot by the
wheel went on to scroll the page, "in many places". d74ef5e04 (v0.1.1839)
already marks every box that scrolls and overflows between the pointer and
its .view (`holds`, app.js) and gives it overscroll-behavior-y: contain by
one rule in app.css. This makes that a guard and closes the one engine gap:

- inner-scroll-contain.test.cjs gains a test that reads every rule in every
  stylesheet under assets (app.css, plugins.css, context.css, omarchy.css
  and plugins/*/*.css; any not linked is added) that sets overflow or
  overflow-y to auto/scroll, builds a box from each selector (each compound
  an element; body classes put on body; @media rules tried at a size they
  hold for), fills it past its height, points at it, and requires
  overscroll-behavior-y: contain. 39 scrollers hold; .view is the one left
  to chain. A failure names the file and selector.
- compat.js: Safari 15 (macOS 12's WebKit until Safari is updated, #220)
  has no overscroll-behavior, so there a wheel over a .holds box already at
  its end in the wheel's direction is cancelled. Only where
  CSS.supports("overscroll-behavior-y", "contain") is false; Chromium,
  Safari 16+ and WebKitGTK 2.52.6 (probed on the Linux VM: true) never
  register it. There the Mac's bounce at the box's end is lost.
- app.js: the six "notice or ok" status lines share saidOk, to make room
  for compat.js under TestCoreScriptBudget (core 1,526,424 of 1,526,556 at the rebased head);
  no budget raised.

Run (mote, Playwright 1.62, Chromium and WebKit):
- inner-scroll-contain: the new guard and the Safari-15 test 4/4 alone;
  in the scroll batch 7/8, the one red a Chromium launch timeout (180s).
- Scroll batch (inner-scroll-contain, routing-scroll-end, click-scroll,
  view-wheel-*, menu-scroll, context-scroll-end, provider-levels-scroll,
  heatmap-scrollbar, ledger-hscroll*, old-webkit, view-trackpad-coast):
  195/209. Reds: 9 browser-launch timeouts (mote at load 30-60 with
  ~40 other test runners), old-webkit's ":has() in app.css" from
  c490165b1 on main (#4020, not this change), view-trackpad-coast
  chromium en ("the coast must ask for more than the 250ms": 6),
  view-wheel-unheard webkit 1 subtest, menu-scroll settings de 420px
  click timeout. None of those paths registers anything new in a modern
  engine; a rerun was cut off when mote dropped off the network.
- Agent batch (agent-connect/-disconnect/-leave-magpie/-notice-lang/
  -app-restart/-connect-no-models/-connect-all-hidden/-tweak-fold,
  claude-effort, tier-effort, subagent-effort, fast-ultra,
  hidden-agent-cleared, show-unset-agent, claude-signin, i18n-keys,
  panel-routing, routing-sessions, view-middle-autoscroll): every red
  but two a browser-launch timeout; agent-connect-all-hidden webkit zh
  and ja a click timeout under the same load.
- go test -tags nogui -count=1 ./internal/gui ok (budgets); gofmt -l clean.
Broken by hand: the :where(.holds) rule and the compat.js fallback
removed: the guard red for 25 scrollers per engine, the Safari-15 test
red in both. Fallback alone removed: only the Safari-15 test red. A rule
`.sess-new-list { max-height: 300px; overflow-y: auto; overscroll-behavior:
auto }` added to sessions.css: the guard red naming it, in both engines.
Not run: the full GUI suite; the agent batch's and scroll batch's
launch-timeout reds again (mote went down mid-rerun).
Not tried: a real Safari 15.0 WKWebView (the engine's lack is faked),
WebKitGTK and WebView2 in the app, a trackpad's momentum in the app,
plugin pages in their sandboxed frames (a plugin's own scroller is
the plugin's).
2026-10-28 16:36:28 +08:00
yetone 67c8f562cd codex: a subagent named a model goes on it with "Same as the lead" (mengxiao on Discord)
mengxiao left Codex's subagent model at "Same as the lead" in magpie,
asked the lead for a subagent on GPT-6.1 Terra, and magpie put the
subagent on the lead's model anyway. The cause was codexFollowTo
(internal/gateway/codex_follow.go): on the ChatGPT-sign-in path, a
collab_spawn request asking for one of Codex's bare models, with nothing
set in magpie or [agents] default_subagent_model, was moved onto the
model the conversation's own turns go on (a1174674d, cybercaius).

Codex starts a spawn that names no model on its lead's model (codex-rs
core/src/agent/child_config.rs: build_agent_spawn_config sets the
child's model to the step's slug; apply_requested_spawn_agent_model_
overrides takes spawn_agent's model, else default_subagent_model; a
role's config can set one too). So under a lead on a magpie model, a
bare model in a subagent's request was always named by the lead, the
config or a role: the user's or the lead's pick. The GUI already says
"Same as the lead" means "the lead's model, or another the lead picks".

- codexFollowTo now handles memory calls only; a subagent is moved only
  by the model set for Codex's subagents in magpie (codexSubagentPick,
  unchanged). codex_backend.go no longer builds a pick from it.
- Dead code out: codexSessionOf, codexLeads.of, and CodexSideSet's
  "subagent" case (its doc moved onto servedSession).
- docs/subsystems/gateway-routing.md says a subagent never follows.
- Sibling checked: Claude Code writes no CLAUDE_CODE_SUBAGENT_MODEL
  while following the main model, and Claude Code takes the Agent call's
  model first; Claude Desktop's pick acts only when a model is set.
  Neither overrides a named model under "same as lead".
- Who relied on a1174674d (a lead's own pick of a Codex model following
  the session): pick the session's model as Codex's subagent model in
  magpie, which puts every subagent on it.

Ran (mote, -tags nogui -count=1, this change on 7fd77a944; rebased after onto a57c95513, which adds only docs, LESSONS and GUI test files):
- TestCodexSubagentKeepsTheModelItWasNamed on the old code (b01193ef9
  with only the new test): FAIL, "ChatGPT was asked for []".
- go test -run 'TestCodex(Subagent|Side|Memor|AppSide|Title|Prediction)'
  ./internal/gateway ./internal/agent: ok.
- go vet (darwin nogui, GOOS=linux, GOOS=windows) on internal/gateway
  and internal/agent: ok. gofmt -l: clean.
Not run: the full go test ./... suite (started on mote, not waited on);
staticcheck (not installed on mote); a real Codex spawn_agent with a
ChatGPT sign-in and a lead on a magpie model.
2026-10-28 16:16:02 +08:00
yetone dfbd37eafc docs: a reporter's fix branch, patch or fixtures are credited in the commit
321sssrt-bit's analysis, fixtures and fix branch went into #3418, #1981
and #2033 with no co-author line. Now: a reporter's fork branch is merged
with their commits as authored, anything else we use from them gets
Co-authored-by, and a plain report is named in the body.

Docs only; nothing reads this file's text.
2026-10-28 16:13:31 +08:00
yetone 189db9ba5b redact: ids, digests and 毛利 go as written; the slider reaches known values; a user name goes as a made-up name
Reports on X under the masking demo (10-28):

_kaichen: "hash类型也会被过滤…长int,假如以1为开头的…会被当作电话被mask;
"毛利低"也会被当作人名被mask。即使把匹配拉到 0.95,也是一样行为".

- Hex digests: 16 to 31 hex digits in one case, with letters and digits
  both (a cache key, a short commit), are ids now (digestShaped in
  ids.go), like UUIDs and 32+ hex. The rules' SECRET keeps one only under
  a credential's field or a CJK/prose key with no field word (密钥为…);
  the model's SECRET is dropped under a field named for something else
  (cache_key, commit, object, blob, file, content, revision, partition,
  shard, bucket, dedup, lookup, row, sort) and on a JSON object's key
  (nameOfField). A bare `key` after api/access/secret/private/signing/
  license is still a credential (keyPhrase). The IBAN case kept its mask
  through the letter/digit minimums.
- 11-digit 1x numbers (phone.go, phoneAt): a phone with +86/86, as the
  value of a field whose name says phone (phone, mobile, tel, cell,
  contact, 手机, 电话, `number`), or in prose with no id word right
  before it (order, id, no., #, 订单号, 编号, 单号, 流水号…). Under
  order_id/uid, after 订单号, or with a letter or digit against it, it
  goes as written. PHONE and BANK_CARD are bounded by alnum, not digits,
  in the rule and in known values.
- 毛利: zhWords gained 毛利, 毛重, 毛坯, 毛巾, 毛衣, so 毛利低 (a margin)
  is no surname+name. The model still finds 毛利兰 (Guard). 毛利小五郎
  (indekkusu141209) is masked by neither model nor the rules now.
- The slider: a value masked once was masked again as known whatever the
  threshold. Each value now remembers the highest score it was found
  with (rules count as sure, ruleFound), and knownSpans skips one under
  Options.MinScore, which masking sets from pii.Threshold.

eerttreeeert: with mimo-v2.6-flash the home folder went as
C:\Users\{{USERNAME_…}}; the model took it for a temp folder and set out
to delete it. With the user name switch on, it now goes as a made-up name
of 8 lowercase letters (HMAC of the name, same every turn, standIn in
shape.go), restored in replies and tool calls like any placeholder;
Preview shows the same name.

Docs: docs/subsystems/gateway-routing.md masking bullets, and the site's
masking page (en, zh, ja) on mobile ids and the user name.

Run (mote, at this tree on base 6af83172d; rebased onto b01193ef9, which
changes nothing in redact, masking or pii, and redact, masking and
pii/... run again ok at the pushed head):
- gofmt -l clean; go vet ./... and GOOS=darwin/linux/windows go vet of
  redact, masking, pii: ok.
- go test -count=1 -timeout 45m redact, masking, pii/..., gateway, otlp,
  sessions, settings: all ok but internal/gateway's
  TestPluginStreamsPastTheBudgetWait (connection reset by peer, 183 of
  192), red the same alone at fresh origin/main b01193ef9 (169 of 192);
  #3946, commented.
- Real models on mote (AstrLink Guard and Privacy Filter, cached): the
  reporter's hashes, ids and every 毛利低 sentence kept; a prose phone
  masked; 毛利兰是谁 masked by Guard; 毛利小五郎姓什么 kept by both.

Broken by hand, each red: phoneAt off; the phone bound back to digits;
digestShaped off; "cache" out of the field list; nameOfField off; the
model's field check off; 毛利 out of zhWords; the slider check out of
knownSpans; standIn off.

Not tried: a real mimo-v2.6-flash session with the made-up name; the
Windows box; the GUI suite (no GUI file changed). 毛利小五郎 stays
unmasked by rules and both models, said in the doc.
2026-10-28 16:05:19 +08:00
yetone ee6f8866f3 gateway: Claude Desktop's connection check goes to its default model
CyberCaius on Discord, v0.1.1838, after restarting Claude Desktop: as it
starts and from Test connection (Configure third-party inference ->
Gateway), Desktop said "Gateway rejected model
magpie-0958175816.anthropic.claude-haiku-5-5[1m] (HTTP 400)", the body
"AnyRouter: bad response status code 400". His default model in Desktop
is his routing group 天翼云; Routing showed leee/claude-haiku-5-5 sent to
AnyRouter gpt-6.1-sol.

Why 02a328d86 (v0.1.1821) didn't cover it: it routed the check as a
title is, to desktopPicked, the model the last session's tool turn ran
on, kept on disk across restarts. At start and in Desktop's settings no
session is running, so that was a days-old AnyRouter session's model,
not the model he chose. Desktop names the check's model itself (YT in
its app.asar 2.7032: the shortest /v1/models id with haiku in it, here
leee's haiku), and its own settings call the first listed model the
default ("the default model (the first listed model)",
resolveDefaultSessionModel). And AnyRouter 400'd the check because a
max_tokens of 1 reaches the GPT model below OpenAI's floor of 16; the
relay passes on no floor, so tokenFloor had nothing to ask again at
(02a328d86's test faked OpenAI's own wording, which a relay hides).

Now desktopProbe (Desktop's exact body: max_tokens 1, one user message
".", no system or tools) goes to desktopDefault, the first model listed
to Desktop (its order on the Agents page), so his 天翼云 group gets it
with zero config. The check is asked for 16 tokens upstream
(desktopProbeTokens); Desktop reads only whether it is answered. Titles
still go to the session's model.

Tests: TestClaudeDesktopProbeToSessionModel becomes
TestClaudeDesktopProbeToDefaultModel, with the literal id
magpie-0958175816.anthropic.claude-haiku-5-5[1m] (leee/claude-haiku-5-5's
alias), a session turn on anyrouter/gpt-6.1-sol first, 天翼云 as a group
listed first, and a relay that answers fewer than 16 tokens with
AnyRouter's opaque 400. The check reaches 天翼云 (leee and the relay get
nothing); with the relay's model listed first it is answered there in
one call. TestDesktopProbe is back.

Run (mote, at this tree):
- go test -tags nogui ./internal/gateway/ -run 'Desktop|Title|CacheKey|
  TooFew|TokenFloor|Alias|Science': ok
- Not run to the end: the whole internal/gateway package (started on
  mote, still running when this was pushed as asked) and the full suite.
- go vet ./internal/gateway/ (darwin, GOOS=linux, GOOS=windows), go
  build ./...: ok; gofmt -l: clean

Broken by hand: the probe branch taken out of desktopTurn -> red "probe
went to leee () or the relay (1 calls), not Desktop's default 天翼云";
the 16-token room turned off -> red with his exact error, 400 "AnyRouter:
bad response status code 400".

No GUI file is reached. Not tried: a real AnyRouter account or a real
Claude Desktop (read from its 2.7032 app.asar). A user whose first
listed model is not the one they mean by default gets the check there:
it is Desktop's own definition.
2026-10-28 15:32:20 +08:00
yetone 05ed578bdc gateway: a large body whose h2 ping was lost goes again unpinged (#3909)
yxd-ym, on a 2-10KB/s uplink: every large turn to a Google upstream
(Antigravity, Vertex, AI Studio) failed with "http2: client connection
lost" after 35-45s while its body was still uploading, and the group's
failover uploaded the same ~680KB again to every member. A small turn on
the same uplink was answered in 14s.

Cause (skygunner's diagnosis): the vendor transport's HTTP/2 health check
(netproxy.HTTP2Health, #2843) pings a connection with no frame received
for 20s and drops it when no answer comes in 10s. The ping is written
behind the body's own DATA, so on a slow uplink its answer can only come
after the last byte, and the check closed a working connection.

skygunner's branch (8eaf63866) sent every body of 64KB or more, or of no
stated length, to a transport without the ping. That is most agent
traffic, and it takes #2843's protection away from it: a silent
connection whose kernel takes a body that fits the send buffer then
waits the 10-minute header wait (TestLargeBodyOnSilentConnectionIsSentAgain
below hangs to its 10s bound on that branch).

The change keeps the ping on every request by default. A large body
(uploading) whose try fails with Go's lost-ping error (lostPing,
closeForLostPing's "http2: client connection lost") is sent once more,
through GetBody (provider.SetBody keeps it until LetGo), through
uploadTransport: a new connection, no ping, given up on when a write
moves no bytes for a minute (WriteByteTimeout); the response header wait
still ends a vendor that never answers. For 30 minutes after (slowFor,
drawsApart.slow, per transport), large bodies go there at once, so a slow
uplink loses one try per half hour, not one per turn. A connection that
really was dead costs nothing more: the retry dials a new one either way.
Small bodies and drawings are unchanged.

Co-authored-by: vincent <vincent@users.noreply.github.com>
Reported-by: yxd-ym

What was run, on mote at origin/main ea53eb126 + this:
- gofmt -l internal/gateway: nothing. go vet ./internal/gateway/
  ./internal/netproxy/, and GOOS=linux / GOOS=windows go vet
  ./internal/gateway/: nothing.
- TestUploadStillUnderwayIsNotCutByHealthPing (skygunner's: 262212 bytes
  paced at 64KB/s, ping after 200ms, dropped 300ms later),
  TestSlowUplinkSkipsTheLostTry (new: the first large body reaches the
  vendor twice, the second once, body given through provider.SetBody),
  TestLargeBodyOnSilentConnectionIsSentAgain (new: 128KB body after the
  path went silent is answered on a second connection),
  TestSilentHTTP2ConnectionIsDropped, TestGroupMovesOnFromSilentHTTP2Connection:
  -race -count=5 all PASS (80s); -count=3 without -race PASS.
- Broken by hand:
  - skygunner's transport alone: TestSlowUplinkSkipsTheLostTry FAIL ("saw
    1 tries of the first body, want 2"), TestLargeBodyOnSilentConnection
    IsSentAgain FAIL (context deadline exceeded at 10.01s).
  - the retry removed: TestUploadStillUnderwayIsNotCutByHealthPing FAIL
    in 0.57s ("http2: client connection lost", vendor "client
    disconnected"), TestLargeBodyOnSilentConnectionIsSentAgain FAIL
    (client connection lost).
- go test ./internal/gateway/ ./internal/netproxy/ ./internal/provider/
  -count=1 -timeout 45m: ok
  (gateway 546s, netproxy 3.7s, provider 118s).

Rebased onto f02d92c7b (no change to these files but a doc line
elsewhere in gateway-routing.md): gofmt, go vet (darwin, linux,
windows) ./internal/gateway/, and the five tests above with
TestPromptText* and *Unmasked* -count=2: ok (32s).

Not tried: the reporter's uplink and a real Google upstream; the path is
a paced local one.
2026-10-28 15:22:31 +08:00
yetone bc3ddc661a redact: 文案 and words like it are no Chinese names (zeewell on X)
zeewell on X: tasks kept going wrong because 文案 was masked as a name,
so they turned names (and birthdays) off. 文 is a surname, and zhName
took a cue around 文案 that says nothing about a person. Probing words
that start with a surname (文档, 方案, 关键, 项目, 成本, 段落, 颜色, 查询,
时区, 简历, 林间, …, ~130 of them) in the places a prompt has 文案, about
110 were masked, through two cues:

- 一下 before it (改一下文案, 检查一下文案,) counted as "a person comes
  next". 一下 follows any verb, so it now counts only after one that asks
  a person (zhAskVerbs: 问, 找, 联系, 通知, 提醒, 回复, …): 问一下张伟
  still is one, 改一下文案 is not.
- At a sentence's start, a word after it that any subject takes (已经,
  明天, 今天, 昨天, 他, 她, 提交, 负责, 回复) counted alone: 文案已经改好了,
  文案明天给你, 文案他们说. Those (zhAnyAfter) now count only with a
  person's cue before (客户张伟已经到了). 说明, 说法, 讲解, 讲座, 讲义, 讲究
  are words, not 说 (文案说明), but for 说明天 (张伟说明天来).
- zhWords gets ~150 more common words (文案, 文风, 关键, 项目, 段落, 林间,
  …) for where a real cue is before a word (发给文案, 请文案), and is a
  set looked up by a candidate's first two characters rather than a scan.
- The model's own PERSON span that is such a word whole (文案) is
  dropped too (modelTakes), the other route a word reaches a name.

Old data: masked values are remembered in memory only, and 文案 (6
bytes) is under minKnown, so nothing stays masked after the update.

Fixtures are prompts with 文案 where the report gives no sentence (帮我
改一下这段文案, 文案:…, 把首页文案换成英文, ### 文案, 文案和图片, 文案已经改好了,
文案说明要简短, 这张图发给文案。), beside names in the same places that
still mask (问一下张伟,, 张伟说明天来, 客户张伟已经到了, 发给张伟。);
TestChineseWordsAreNoNames runs 25 listed words in 10 shapes plus the
model's label, and 5 unlisted ones (文创, 方位, 高铁, 安防, 林荫) through the
cue shapes alone. Every TestChineseNames case stays green.

Run (mote, mote-run, at this tree): go vet ./internal/redact for darwin,
linux and windows ok; gofmt clean; go test -timeout 45m of
internal/redact, masking, pii/..., otlp, sessions, settings, gateway
ok; internal/gui red on TestMainWindowCorners/macOS_26_SDK only, the
macOS 27 red filed as #3949 (no redact in it).
After rebasing onto 8edb9dbb7 (gateway, provider only): redact and
masking again ok at the pushed head.
Broken by hand, each red: the 一下 rule always true (改一下文创), the
zhAnyAfter check off (文创已经好了, 文创明天给你, 文创他们定), the 说明 words
off (文创说明), the model's word check off (the model's 文案, 文档, …), 文案
out of zhWords (发给文案, 请文案).
Not tried: the real model on zeewell's prompts (they gave none). Now
left: a two-character name at a sentence's start before only 已经/明天/
他 (张伟已经到了。), and an unlisted word after a person's verb at a
clause's end (发给文创。). Birthdays: the report names no birthday that
was masked wrongly, so they are unchanged.
2026-10-28 15:15:31 +08:00
yetone 8edb9dbb75 gateway: a compaction a model answers with a tool call is asked again as text
Lucy on Discord (v0.1.1676, Codex, group/auto-deepseek-v4-1-flash):
"compaction: group/auto-deepseek-v4-1-flash failed to summarise this
conversation 3 times in a row (last: the model wrote no summary (it
answered with reasoning, function_call exec_command))", so Codex could
not compact at all with that group.

Cause: the summary request offers no tools (tools [], f81913994), but its
history is Codex's exchange of exec_command calls, and a DeepSeek model
deep in it goes on with that exchange: it thinks, then calls exec_command
again. Nothing on magpie's side stops a call coming back: on a Messages
upstream the history's tools are declared as stubs (Anthropic requires
them, tool_choice none), an OpenAI-compatible server can read calls out
of the model's text with no tools offered, and magpie passes a call to an
undeclared tool through. codexCompact took that reply as "no summary"
and failed, three times, then held the conversation for 5 minutes.

Fix (codexCompact, every route that compacts: Lite and not, a group or a
single model, Chat, Responses and Messages upstreams): a summary reply
that called a tool (calledTool) is asked once more with the conversation
as text (plainCompact, as for a relay's 404): no exchange of calls to go
on with, no stubs, nothing found by tool_search. If that also writes no
summary, magpie compacts locally (localSummary, saying why), so Codex
goes on instead of failing. Codex's compaction prompt is unchanged.
Replies of reasoning alone or nothing fail as before.

Run on mote, the full suite at ea53eb126 + this change:
- gofmt -l: clean
- go vet ./internal/gateway: darwin, GOOS=linux, GOOS=windows (-tags nogui): clean
- set -o pipefail; go test -tags nogui -timeout 45m ./...: 76 packages ok, no FAIL
  (gateway 707s, agent 426s, provider 187s)
- new tests: TestCodexCompactToolCallAsksAgainAsText (Chat, Responses,
  Anthropic x group/auto-ds and ds/deepseek-flash; upstreams streaming
  DeepSeek-shaped reasoning + exec_command calls while the history holds
  calls) and TestCodexCompactToolCallEveryTimeCompactsLocally
- broken by hand: with codex_backend.go at origin/main both tests are red
  in all 9 cases with the reporter's message, "compaction: the model
  wrote no summary (it answered with reasoning, function_call
  exec_command)"; green with the fix
- real DeepSeek (deepseek-flash, the owner's key): Chat with no tools and
  Messages with the stub and tool_choice none/auto all summarised a short
  exec_command history (3 of 3 each), as did the text form plainCompact
  sends

Rebased onto a57ec0168 (Cursor plugin min only): go build ./... and
the gateway and provider compaction tests ok again at the pushed head.

Not tried: Lucy's own conversation and group members (the long history
that makes DeepSeek call a tool did not reproduce on a short one), and
a real Codex end to end through a sandbox gateway.
2026-10-28 15:14:31 +08:00
yetone ea53eb1262 gateway: a request to an unmasked route isn't masked first (#3973)
wangbinyq (#3973): with masking on, a request to a provider set to
go unmasked was still masked whole before routing, then sent as the
agent wrote it, so the masking was thrown away. In their log that was
97.9% of magpie's own time: median 560ms, p99 16s, max 219s.

serve now masks after Resolve/FindGroup. When unredactedRoute holds
and no body goes anywhere else (bodiesKeptAway: no observer wanting
bodies, no request archive), masking is skipped. The redact writer
goes under capture, an order that commutes with the old one. A
turned-away request is logged masked (maskedCopy). count_tokens
masks only when its route isn't unmasked. The context card's text
stays masked: the kept body is masked when PromptText first reads
it (keptBody.plain), not on the request's way. The log and recent
calls keep the body as it went.

Run on mote at this tree (base 58fb3a778, rebased onto d74ef5e04
with no internal/gateway change in between):
- gofmt -l internal/gateway: none. GOOS=linux/windows/darwin go vet
  -tags nogui ./internal/gateway: ok.
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway:
  one red, TestPluginStreamsPastTheBudgetWait (connection reset by
  peer, load ~80). That is #3946, already open. Alone with
  TestPromptTextIsWhatWasSent, -count=5: ok.
- The first full run caught TestPromptTextIsWhatWasSent red: the
  card's text held the key on an unmasked route. Fixed by the lazy
  masking above; it is green now.
- Broken by hand: on origin/main's gateway.go and redact.go, the new
  TestUnmaskedRouteIsNotMasked is red ("masked 1 times, want masking
  false", "count masked 1 times").
- Real run: old and new magpie serve in a sandbox HOME, redact on, a
  local Anthropic provider on a fake upstream, 15 requests of 1.2MB
  with emails, phone numbers and keys. Unmasked provider: median
  176ms on old, 13ms on new. Masked provider: 171ms vs 172ms.

Not tried: a real vendor account. The change sits before the
upstream call, and the fake upstream stands in for it.
2026-10-28 14:55:20 +08:00
yetone d74ef5e04c gui: an inner list wheeled to its end keeps the wheel; the page stays put
碳碳双键 (ysm119, Discord): wheeling the Usage page's request list to its
top or bottom carried on into the whole page, and "this happens in many
places". It is the class: every box that scrolls inside a scrolling page.

app.js marks such a box `.holds` while it overflows vertically, on
pointerover and on each wheel (the box under the pointer and its
ancestors up to the .view), and app.css gives `:where(.holds)`
overscroll-behavior-y: contain, which keeps the Mac's bounce on the box.
Not one CSS rule for every overflow:auto box: in Chromium `contain` holds
the wheel even in a box that doesn't overflow, or is overflow:hidden, or
only scrolls sideways, so short lists and the heatmap's and ledger's
sideways scrollers would have stopped the page. The .view itself is never
marked. :where() weighs nothing, so .mchips in a short window
(@media max-height 640px, #833) still passes the wheel on.

The new test, inner-scroll-contain.test.cjs, wheels the Routing page's
requests list past each end (en and zh, 900x560 and 1300x600, under
"By session" / 未提供会话标识), and ten kinds of inner box, and asserts
the page's scrollTop didn't move. A short list, heat-scroll, led-wrap and
snip must still pass the wheel to the page. routing-scroll-end now wheels
over the page's gutter: at its view centre the pointer sat on the
requests' list, which now keeps the wheel at its end (600 of 1066).

Run (mote, Playwright 1.62, Chromium and WebKit):
- inner-scroll-contain 40/40.
- 17 files: inner-scroll-contain, click-scroll, routing-scroll-end,
  routing-sessions, view-wheel-after-click/-after-redraw/-unheard,
  heatmap-scrollbar, ledger-hscroll, ledger-hscroll-foot,
  context-scroll-end, menu-scroll, provider-levels-scroll, panel-usage,
  panel-routing, qoder-cn-tile, agent-disconnect: 268/287. Reds were
  routing-scroll-end (this change, fixed above) and panel-usage webkit zh
  (#3311, commented). Rerun of routing-scroll-end, panel-usage and
  inner-scroll-contain: 66/66.
- go test -tags nogui ./internal/gui ok (TestCoreScriptBudget passes at the rebased head:
  core under 1,526,556, app.js under 1,310,460; no budget raised).
Broken by hand: the old app.js and app.css: the requests list and every
held box red in both engines (mchips aside, it had contain already).
Only the CSS rule removed: red, "the page didn't move" x8 plus each held
box x2. Only the overflow check removed: a short rt-reqs red (Chromium),
led-wrap and snip red in both engines.
Not run: full GUI suite (mote was busy with another session's suite).
Not tried: WebKitGTK on Linux, WebView2 on Windows, a real Mac's
trackpad rubber band and momentum in the app, older macOS WKWebView,
touch; zh-TW/ja/de (no strings changed).
2026-10-28 14:54:09 +08:00
yetone 60520ddb3b moejs: v0.1.0-alpha.11, at its new module path github.com/MoeForge/moejs
Gateway middleware and agent plugins run on moejs. alpha.11 moves the
module to github.com/MoeForge/moejs; every other API change since
alpha.4 is an addition. What magpie gets: faster calls, loops, property
lookups and JSON.parse, allocation-free await, a bytecode verifier, a
correct default.pgo, and Intl / toLocaleString in plugin code.

Checked against both tags' source: every name magpie uses (NewRuntime,
Options, Compile, Link, Hook, Value, Arg, Undefined, NativeFunc,
Referrer, the Promise results, Exception) has the same signature, and
Options' defaults (shared frozen builtins, no timers) are unchanged.
fetch, Streams, URL, node:fs and node:buffer live in the separate
webapi and node packages, installed only on request; magpie installs
neither, so a plugin still reaches no network or file.

Intl's CLDR, Unicode, ICU and V8 material is compiled into every build,
and moejs asks a program that includes it to carry sections 1 to 4 of
its notices. THIRD_PARTY_NOTICES holds them verbatim. Release archives
ship no LICENSE today either; that is not changed here.

Doc and site links (docs/, site/public/docs/{,zh/,ja/}plugins.html)
point at the new repo.

Run on mote at this tree: gofmt; go build -trimpath -s -w (60,670,658
bytes on origin/main 58fb3a778, 62,329,250 now, +1.66MB); go vet of
middleware, jsmod, agentplug for darwin, linux and windows; go test
./internal/middleware/... ./internal/jsmod/... ./internal/agentplug/...
ok; go test -run 'Middleware|Strateg|OnUsage|JSPlugin|Agentplug|AgentPlug'
./internal/gateway ./internal/provider ./internal/plugin ./internal/gui
ok.
Not run: the full suite, the GUI suite, a real request through a
middleware in a running gateway.
2026-10-28 14:36:17 +08:00
yetone 58fb3a7786 redact: 关键发现, 易触发 and 和边界 are words, not Chinese names
xuanwo on X: with the model on, a report's words were masked as names,
关键 in "### 关键发现", 易触 in "`gh pr view` 易触发" and 边界 in
"判断和边界,". Each starts with a surname (关, 易, 边), and zhName took
a cue around it that was too weak alone:

- 发 and 打 after it counted as the verb a person does. They now count
  only when no Han character follows, or one of 了个给过一 (发了个消息,
  打给他); 发现, 打开 begin a word.
- 和 and 与 before it counted as "a person comes next". They join like
  to like, so they now count only when a pronoun or what may be a name
  (a surname and 1-3 characters, no zhWords word) is before them:
  吴敏和郑浩, 我和张伟, not 判断和边界.
- A sentence started after any space or symbol. A space after a word or
  code is inside a sentence, so the start is now after punctuation (with
  spaces after it or none) or at the text's start; a backtick no longer
  counts.

The fixtures are the reporter's literal lines, beside names around the
same cues that still mask (### 张伟发了个消息, 我和张伟,, 这件事。 李娜说过).

Run (mote, mote-run): go test ./internal/redact (TestChineseNames,
TestMaskEval and the rest) ok; gofmt clean. Broken by hand, each red on
its own case: the 和/与 rule off (边界), wordAfter off (关键发现),
sentenceStart always true (易触发).
Running as this is pushed: vet (darwin, windows, linux) of
internal/redact and go test of redact, masking, pii, otlp, sessions,
settings, gui and gateway.
Not tried: the real model on the reporter's whole session; a name that
starts after a space following a Chinese word (这件事 李娜说过) is now
left, as one inside a sentence.
2026-10-28 14:27:17 +08:00
yetone a3ee00c05c codex: its own GPT models stay in Codex's list when kept for routing groups
士奇 (Discord, 10-28): with a routing group on, the Agents page's Codex
list lost its Codex provider section and models, the model dropdown still
offered GPT, but the Codex app had none; with the group off they came back.

Cause: the codex provider's "Only through routing groups" (Provider.Unlisted,
只通过路由分组使用), or a group that lists itself alone (Group.Unlists), took
the ChatGPT account's own models out of Catalog(), so out of Codex's own
list too. With no Codex section, the own options were not magpie's, so the
own-models switch showed and the picker kept offering GPT; meanwhile #1602
(125dad5cb, CodexNativeUnlisted) dropped every one of them from the list
handed to Codex (backend /models, the model_catalog_json desk file,
spawn_agent). The picker and the app disagreed.

Why the earlier fixes missed it: aa766289b only stopped the GUI folding a
provider, and 508911e43 (TestCodexOwnModelsStayWithGroupOn) only kept
Served own options in the picker. Both covered a plain group; neither
touched Catalog's unlisting for Codex or the desk list's #1602 filter, and
neither test set Unlisted or Unlists.

Fix: Codex's lists start from catalogOf("codex"), which keeps CodexOwn
entries (ListedFor/CatalogFor, CodexNativeHidden, CodexOrder), and
CodexNativeUnlisted is removed with its filters in codexMerged,
spawnChoices and the list tag. Other agents and /v1/models still don't
see unlisted GPT models (checked for Claude Code in both tests).

Behaviour change for #1602: an unlisted codex provider no longer hides GPT
from Codex. The way to hide them from Codex is Codex's own list (its Codex
section's hide / only-picked), which CodexNativeHidden still applies; the
rewritten gateway test checks that and the ETag change.

Tests:
- gateway TestCodexModelListKeepsOwnForGroups (rewrites
  TestCodexModelListUnlistedForGroups): group Unlists and provider Unlisted
  keep gpt-6-sol/gpt-5.5 in Codex's /models and spawn_agent; Claude Code
  doesn't list them; hidden in Codex's list it goes and the ETag changes.
- gui TestCodexOwnModelsListedOnlyThroughGroups: agentModelList has the
  Codex section (Own) for every model, OwnModels is false, the picker has
  them, Claude Code doesn't list the unlisted ones.

Run (mote-run, -tags nogui): go build ./...; go vet for darwin, GOOS=linux
and GOOS=windows on provider/gateway/gui/agent; gofmt -l clean; go test
./internal/provider ./internal/gateway ./internal/gui ./internal/agent: ok.
Broken by hand: the five source files reverted to f20118304 with the new
tests in place: both tests red (gateway: gpt-5.5 and every own slug gone,
spawn offers only group/mine; gui: no Codex section, own switch shown).
Real codex 0.162.1 in a sandbox CODEX_HOME: `codex debug models` with
model_catalog_json pointed at the desk file CodexDesktopCatalog wrote with
the provider Unlisted and an Unlists group lists gpt-6-sol, gpt-5.6-sol and
group/mine (the old code dropped both GPT slugs).

Not run: full suite. Not tried: GUI Playwright files (no page changed), a
live ChatGPT sign-in or the Codex desktop app itself.
2026-10-28 14:26:18 +08:00
Henry-916 824100f30f gui: keep Windows modal backdrops responsive without blur
Disable full-window modal backdrop filtering in Windows desktop windows
and tray panels, retaining the dimming veil. Browser pages and other
platforms keep their existing blur through the existing win/web markers.
Document the platform behavior in the GUI shell reference.

On an affected 0.1.1805 installation with WebView2 155.0.4283.62 and Intel
UHD D3D11, disabling the filter made provider tests visibly responsive.
The reporter confirmed the improvement. Scripted scrolling measured
roughly 67 to 165 rAF callbacks/s, not presented FPS.

Verification: modal-backdrop.test.cjs fails on the original CSS in both
Windows desktop Chromium cases (blur instead of none), with the other
10 cases passing. After the fix, 45 targeted tests pass across
Chromium and WebKit: modal-backdrop, dialog-backdrop-drag,
segment-press-dialog, gui-zh-tw, gui-ja and gui-de. node --check and
git diff --check pass. The full GUI suite, Go vet/build/test matrix and
native macOS/Linux tests were not run.
2026-10-28 14:24:40 +08:00
yetone c48fccfad7 plugin: the dist index is read from GitHub beside jsDelivr's copy, so a plugin npm doesn't have is offered its newer version
star21321321124 on Discord: CodeArts 0.2.3 showed "已自动更新", the page said
every plugin was up to date, and Update did nothing, with 0.2.4 on the
plugins repo's dist branch. npm has neither CodeArts nor River (E404), so
npmAsk's version is the dist index's latest. With the 「国内镜像」 switch on,
index.json was read from jsDelivr first, and a 200 from it was final. A
jsDelivr edge serves the branch as it was when it cached it (s-maxage=43200):
on 10-28 gcore.jsdelivr.net served the index with codearts latest 0.2.3
(age 6631s) while raw.githubusercontent.com, cdn and fastly had 0.2.4. So
the hourly update, Check for updates and Update all saw 0.2.3.

readDistIndex now asks raw.githubusercontent.com beside the mirror (with
the switch on) and merges the two copies: every version either names,
each package's newer latest. Each version keeps the sha512 its own copy of
the branch names, which installDist checks the tarball against as before.
GitHub is waited for 5s (distGrace) past the mirror's answer; unreachable,
the mirror's copy is read alone, as before. Switch off: one read, as before.

River: on dist at 0.1.0 only, nothing newer; the test holds it "current".

Run (mote, at this tree rebased on f20118304):
- go test -tags nogui ./internal/plugin ./internal/source: ok
- go build ./...; go vet (darwin, linux, windows) of both packages: ok
- gofmt -l: clean
Broken by hand: the index read mirror-first again (the old rule) turns
TestDistOnlyPluginUpdatesPastAStaleMirror red in both subtests with
"Status:current Latest:0.2.3", what the user saw. The pure no-mirror case
(npm 404, dist 0.2.3/0.2.4, 0.2.3 installed) already passed on the old code.
Not run: full suite, GUI suite.
Not tried: a real magpie with the switch on against a stale edge (tests
can't reach the network); the stale gcore edge and fresh raw copy were
checked with curl only.
2026-10-28 13:55:16 +08:00
yetone f201183047 tune: the compact window is Long conversations, one value for both agents
7eleven (Discord #help): the Usage page's "Tuned for you" compaction
value and the agents' sheet "Long conversations" window were two values
that could disagree. Codex's tune wrote model_auto_compact_token_limit
into config.toml beside the catalog's context_window that Long
conversations writes; Claude's read its own env.

One source of truth: settings.CompactAt / FullContext. Tune's compact
row for Codex and Claude Code now has source "long": its Current is
settings.Compact(), Use calls provider.SetCompactAt (Sync writes Codex's
catalog and Claude's CLAUDE_CODE_AUTO_COMPACT_WINDOW as before), Undo
puts back the CompactAt/Full it stashed under tune.long.compact. So a
value set on either page shows on the other and writes the same config.
writeCompact marks claude.compact_long when the env value came from
settings, so Claude's row reads it as ours, not as the user's.

Migration (Codex Sync, local place): an old tune.codex.compact stash
whose limit is still the one tune wrote moves into Long conversations.
At default or Full it takes tune's value; with a value the user set it
takes tune's only when smaller. config.toml gets the user's earlier
limit back or loses the key; the stash is forgotten. A limit the user
changed after tune wrote it, or wrote themselves, stays and reads
Locked. A provider's Compact at or the user's own Claude env stays
Locked too.

Run (mote, at this tree):
- go vet on agent, provider, gui, tune; GOOS=linux go vet -tags nogui
  ./...; GOOS=windows go vet ./...; go build ./... and -tags nogui: ok
- go test -tags nogui ./internal/agent ./internal/provider
  ./internal/tune ./internal/gui: ok (TestCoreScriptBudget within the
  budget, not raised; context.js is 33 bytes smaller)
- GUI: compact-one-value.test.cjs (new; Chromium and WebKit, en zh
  zh-TW ja de) and context-tune: 104/104 at the rebased head
Broken by hand: the Codex long branch, the Claude long env check and
the Sync migration call each turned red TestClaudeCompactAt,
TestCodexHomeEnvTakesThePick, TestTuneCodexCompact,
TestTuneCodexOwnLimit, TestTuneCodexMigrate (4 subtests),
TestTuneClaudeLong and TestTuneCodexMigrateOnSync. Old context.js and
i18n.js turn compact-one-value red ("You set 272K").
Not run: full suite, Go or GUI (shipped at once per owner; the GUI suite
is still running on mote, reds get their own issues).
Not tried: a real Codex or Claude Code session reading the written
config; the migration on Windows/WSL places (it runs for the local
place only).
2026-10-28 13:52:08 +08:00
yetone 8c5c83c9fc gateway: a Responses client's cache marks to Claude last an hour (#3972)
7eleven (Discord #feedback, #3972): Codex routed to a Claude model on an
Anthropic Messages upstream (an API key or a relay) had the cache marks
magpie adds at Anthropic's default five minutes. Codex's turns are often
further apart, so the thread's prompt was written again after each pause.

Decided, zero config: the marks anthropicBody adds for a Responses client
to a Claude model carry ttl 1h (addedMark, Request.hourMarks).
- Price (claude-api skill, prompt caching): a 5m write is 1.25x input, a
  1h write 2x, a read 0.1x (less on Opus 5.5 / Fable). In a busy loop the
  1h marks cost 0.75x more on each turn's new tokens only; one turn after
  a 5 to 60 minute pause reads the prefix instead of writing it again
  (1.25x of the whole prefix), which pays for dozens of turns.
- Codex's own vendor keeps a thread cached an hour (chatGPTCold); Claude
  subscriptions already go 1h through Claude Code (cacheMark1h).
- No magpie setting exists for these marks: tune's cache_ttl and
  subagent_cache_ttl write Claude Code's own settings and don't apply.
- The client's own say wins: prompt_cache_retention "in_memory" keeps
  5m; marks a client placed itself are never touched (only magpie's
  added marks change). Every added mark has the same ttl, so none follows
  a shorter one.
- A relay that answers 400 naming cache_control and ttl is asked again at
  5m and remembered in unfit (hourMarksRefused).
- Not changed: Chat clients' marks (OpenCode and one-off callers alike)
  stay 5m; left open on #3972. Non-Claude models on Messages unchanged.

Tests: TestResponsesToClaudeMarksLastAnHour, TestHourMarksRefused.
Broken by hand, each on mote:
- addedMark always 5m: the four 1h subtests and both refusal cases red.
- the refusal retry removed: "ttl refused" red (400 after 1 call).
- in_memory ignored (hourMarks = true): "in_memory asked" red.
Docs: gateway-routing.md, a bullet beside the Kiro cache marks.

Run (mote, at this commit): go build -tags nogui ./... ok;
go test -tags nogui ./internal/gateway ok (522.7s).
Not run: full suite (pushed at once per the owner's rule).
GOOS=linux and GOOS=windows go vet ./internal/gateway ok; gofmt -l clean.
Not tried: a real Anthropic key or relay (no request was sent upstream),
Bedrock or Vertex with ttl 1h (the refusal fallback covers a 400).
2026-10-28 13:12:00 +08:00
yetone 02a328d86a gateway: Claude Desktop's model check goes to the session's model again
CyberCaius on Discord, after v0.1.1819: the startup error is gone, but
Desktop's check ({"max_tokens":1,"messages":[{"role":"user",
"content":"."}]} on the first haiku it is listed) now went to leee's
claude-haiku-5-5, another provider's Claude model, and spent its quota.
He wants it on the model or group his session uses.

6e331afb4 sent the check to the model it names (desktopProbe) because,
on the session's AnyRouter gpt-6.1-sol, it failed for the
prompt_cache_key AnyRouter requires. That commit also gave such relays
the key, so the reroute isn't needed: desktopProbe is gone, and the
check is routed as a title is (desktopTurn), to the session's pick. The
cache key stays.

A floor on max_tokens (OpenAI's models refuse fewer than 16) is already
met by asking again at the floor (tokenFloor, TestTooFewTokensSaidWith-
Signs covers /v1/messages max_tokens 1 "." to a Chat upstream).

Tests: TestClaudeDesktopProbeAsked becomes TestClaudeDesktopProbeTo-
SessionModel. Its relay needs the key and refuses max_tokens < 16 as
OpenAI does. The probe of the haiku alias reaches gpt-6.1-sol on the
relay (2 calls, the floor met once), leee gets nothing, and the call
answers 200. TestDesktopProbe is removed with the function.

Run (mote):
- go test -tags nogui ./internal/gateway/ -run 'Desktop|Title|CacheKey|
  ExtraBody|UpstreamBodies|TooFew|TokenFloor|Alias': ok
- go vet ./internal/gateway/ (darwin, GOOS=linux, GOOS=windows): ok
- gofmt -l: clean

Broken by hand: 6e331afb4's desktop.go put back,
TestClaudeDesktopProbeToSessionModel red: "probe went to leee
({"model":"claude-haiku-5-5","max_tokens":1,...}), not the session's
model".

No GUI file is reached. Not run: the full suite (shipped at once, as
asked). Not tried: a real AnyRouter account or a real Claude Desktop.
2026-10-28 13:08:23 +08:00
yetone 6e331afb45 gateway: Claude Desktop's model check goes to the model it names; a relay gets a cache key
CyberCaius on Discord: Claude Desktop said at every start
'Gateway rejected model "magpie-<n>.anthropic.claude-haiku-5-5[1m]"
(HTTP 400)', body "Arouter: prompt_cache_key is required". His
Routing page showed leee/claude-haiku-5-5 served by AnyRouter's
gpt-6.1-sol, with a "." prompt.

Two causes:

- Desktop checks a gateway model as it starts (and from its settings'
  Test) with {"model":<it>,"max_tokens":1,"messages":[{"role":"user",
  "content":"."}]}, on the shortest id with haiku in it (lWt, JUt and
  YT in its app.asar, 2.7032, read from the installed app). desktopTurn
  took that small tool-less request for a session title and sent it to
  the session's model, AnyRouter's gpt-6.1-sol, so a failure there read
  as the haiku rejected. desktopProbe now knows the check, and it goes
  to the model it names. Titles still go to the session's model.
- A request translated from an Anthropic client to a Chat or Responses
  upstream never had a prompt_cache_key, and AnyRouter refuses one
  without. ownCacheKey/cacheKeyOf give it one per conversation (a
  hash, in a UUID's shape, of the client's session header, else of its
  first user message; it names nothing of magpie) on OpenAI's API with
  a key and on providers the user added by address. Presets, signed-in
  accounts, plugins, Bedrock and Vertex get nothing new, nor does a
  provider whose extraBody (#1604) names prompt_cache_key: the user's
  value is the one sent. An upstream whose 400 names the field is asked
  again without it and not sent it again (the existing path for Codex's
  key); any other 400 is not asked again for magpie's key, so an
  unrelated refusal is tried as often as before.

What is sent changes, on purpose, for those providers: the translated
bodies in testdata/upstream_bodies (anthropic-to-chat,
anthropic-to-responses, responses-to-chat and the large one's hash) now
carry the key.

Unticking AnyRouter's Claude models had no part in it: nothing went
to them. The probe was rerouted to the session's pick.

Tests: TestClaudeDesktopProbeAsked (a fake Anthropic "leee" and a fake
Chat relay that answers AnyRouter's 400 without a key: turn, probe of
the haiku alias, title, second turn keeps the key), TestDesktopProbe,
TestOwnCacheKey (scope, extraBody's key left to the user, and a relay
refusing the field asked twice once, then once).

Run (mote):
- go test -tags nogui ./internal/gateway/ -run the new tests,
  TestUpstreamBodiesUnchanged, TestExtraBody*, TestOtherBadRequestNot-
  AskedAgainAtLow, TestTranslatedEffortMinimalRefused, TestTooFew-
  TokensSaidWithSigns, TestHighRiskErrorFallsBack, TestVertex*Retries*
  and every *CacheKey* test: ok
- a full ./... run of the first draft at 98e23350f: every package ok
  but internal/gateway, whose 8 reds are the two draft faults named
  under "Broken by hand", both fixed here
- GOOS=linux and GOOS=windows go vet ./internal/gateway/: ok
- gofmt -l: clean

Broken by hand:
- desktopProbe's branch off: TestClaudeDesktopProbeAsked red, "probe
  went to the relay (1 calls)".
- own key off: TestClaudeDesktopProbeAsked red (turn 400 "prompt_cache_key
  is required"), TestOwnCacheKey red (1 upstream call, want 2).
- extraBody check off (a first draft): TestExtraBodyTranslated red,
  the user's ${sessionId} key replaced by magpie's.
- a first draft retried every 400 once without magpie's key:
  TestOtherBadRequestNotAskedAgainAtLow, TestTranslatedEffortMinimal-
  Refused, TestTooFewTokensSaidWithSigns, TestHighRiskErrorFallsBack,
  TestVertex{Minimal,}RetriesOnlyForVertex red on the extra try; now
  only a 400 naming the field drops it.

No GUI file is reached (gateway only). Not tried: a real AnyRouter
account or a real Claude Desktop against this build; the probe's bytes
come from Desktop 2.7032's app.asar.
Not run: the full suite at this head (shipped at once, as asked; it was
queued behind another session's suite on mote).
2026-10-28 12:48:21 +08:00
yetone 5ced5b1aa0 routing: a wallet's row says what of it lapses first, as the Usage card does (#3964)
MYCF711's SuperMagic plugin (magpie-magicrew-auth daca18e) sends a
balance window 积分余额 with runsOut, and 今日 / 限时 / 永久 as aside
rows. The Routing page already showed all four rows, in the stage row's
tooltip and the account list's .wins line, both through cardOf/winsOf
(the Usage page's own readings). The row's own text said only
"6,291 积分 left". For a wallet seat, quota() now adds the Usage card's
runsOutText for the card's window of the same balance and unit:
"6,291 积分 left · 185 积分 expire 23:59". It is client only. The
Go side (allowanceOf, Weighed) is unchanged, because the aside rows are
display only and routing weighs the total.

Run (mote, at 7b63feb90 + this):
- routing-wallet-lapse.test.cjs (new, the reporter's literal windows):
  chromium + webkit, en/zh/zh-TW/ja/de, 1100 and 420px, 22/22 ok.
- Broken by hand (quota without lapses): 11/11 red in chromium,
  expected '750 积分 left · 50 积分 expire Thu 02:06', actual
  '750 积分 left'.
- routing-wallet-balance, usage-wallet-balance, i18n-keys: ok.
- Every routing-*.test.cjs (124 files) + the two above: red only in 12
  files that are red the same way without this change at 4655e1659
  (83 fails there) and that have open issues: routing-intent-entry
  #3408, routing-manual #3409, routing-pause #3410, routing-rule-effort
  #3411, routing-steady #3412, routing-row-swap #3799, routing-model-rest
  #2115, routing-rule-drag #3789, routing-rule-remove #3094/#3096,
  routing-rules-line #3593, routing-story-shrinks #3954,
  routing-wb-restricted #1905. Mote was at load ~16-28 with another
  session's suites.
- go test -tags nogui ./internal/gui/ (budgets): ok.

Not run: the full Go suite and the whole GUI suite (another session's
were on mote; this commit touches no Go). Not tried: a real SuperMagic
account, or the Windows/Linux app.
2026-10-28 12:40:16 +08:00
yetone 7b63feb908 gui: a browser tab's font rows show on a nogui magpie, and Text size no longer flashes
Norcleeh (Discord #general, after v0.1.1788): in magpie's web GUI the
interface-font and code-font rows "flash once and disappear" on refresh.

Cause, reproduced on a real nogui `magpie web` on mote in Chromium and
WebKit, at 127.0.0.1, localhost and the LAN address: a nogui build
(Docker, magpie-cli) has fonts.Available false, so boot.js carried no
`fonts` flag and app.js never showed the font rows at all. What flashed
was the Text size row: index.html shows it, and renderSettings hid it
for a browser tab 40-120ms later (`#textSizeRow.hidden = web`).

Fix:
- A browser tab always gets the font rows. Its /api/fonts answers the
  server's families plus a common list (Arial, Menlo, Consolas, PingFang
  SC, Microsoft YaHei, Noto Sans CJK SC, JetBrains Mono, ...) and never
  errors for a tab; fonts.js keeps only what this browser can draw, and
  "System default" is always offered, so with nothing kept the rows still
  show with it.
- The app-only rows (Text size, tray, login, tray usage) carry
  .app-only, which `body.web .app-only` hides before first paint, so none
  of them paints in a tab.
- The boot `fonts` flag is gone. app.js and core both got smaller; no
  budget changed.
- docs/subsystems/gui-shell.md "Desktop fonts" says so.

Run (mote-run, at this head rebased on 98e23350f):
- go build ./... and -tags nogui; gofmt -l clean; GOOS=linux go vet
  -tags nogui ./internal/gui and GOOS=windows go vet ./internal/gui
  ./internal/fonts ok (at the pre-rebase head).
- go test -tags nogui -run 'Font|Budget|Boot' ./internal/gui
  ./internal/fonts ok (and with cgo before the rebase); the new
  TestBrowserTabFontsWithoutInstalledFonts covers nogui, a failed read
  and a merge with the server's own families.
- fonts, i18n-keys, settings-general, text-size, web-page: 76/76.
- Before the rebase, 20 files (fonts, font-cascade, win-fonts,
  login-allow, omarchy, settings-general/-search/-sections/-groups/
  -lines-wrap/-tabs-stick, text-size, tray-usages, web-page,
  web-app-standalone, gui-de, gui-ja, gui-zh-tw, i18n-keys) 259 tests,
  all ok but i18n-keys' "Runs as" (#3897, green now on main).
- Whole GUI suite before the rebase, --test-concurrency=4 beside other
  sessions' load: 13,626 tests, 160 red in 31 files. Those 31 files
  run alone at head and at base 0a7633136: 166 vs 157 red, the same
  tests at other widths/languages (routing-*, segs-press-redraw's
  webkit 900/440px, usage-*); mobile-web's "matches origin/main" needs
  .git, which a mote-run copy lacks; old-webkit's :has() is on base.
  segs-press-redraw alone: 7 red at head, 8 at base.
- New GUI test, both engines, en and zh: "a browser tab's font rows show
  on a nogui magpie and nothing flashes" records every rAF frame. Red on
  the old assets (uiFontRow never shows). Broken by hand: without the
  .app-only CSS rule it goes red with textSizeRow painting ~20 frames
  then going away (the reported flash); with
  `row.hidden = web && fontList?.length === 0` it goes red.
- Real servers on mote, both engines, 3 origins: nogui shows the rows
  (19 families in Chromium, 21 in WebKit), Text size never shown; a cgo
  desktop server 204/181 families.

Not tried: a Windows server with the fix (old code showed the rows),
WebKit over a LAN tunnel, Brave/Safari fingerprinting modes, the full
Go suite.
2026-10-28 12:25:39 +08:00
JoeyWu-tech 6f0e40572c gui tests: a plugin's words are its own when said as words (#3897)
yetone (#3897): i18n-keys' "a plugin's words are its own" is red on main
since 7f827b3b0, with 'plugins/library/i18n.js "Runs as":
internal/cli/claude_code_cli.go says it too'. claude_code_cli.go doesn't
say Library's "Runs as": 7f827b3b0's comment "// fetchClaudeRuns asks
the gateway at base for its Claude Code runs" holds it, across a
function's name and the next word, and the check took a key found
anywhere in a file's text, inside a longer word too, as said there.
internal/gateway/claude_runs_test.go's "listClaudeRuns asks" holds it
as well.

The check now counts a plugin's word where it stands as words: a
letter, digit or _ just before a key that starts with one, or just
after a key that ends with one, makes it part of a longer word. A key
said in a string, a comment or markup counts as before, and goes back
to i18n.js. docs/subsystems/plugin-runtime.md says so.

What was run (tree 26d67096, on origin/main e056779a, Node 22.22.1):
- i18n-keys (Node's test runner, no browser) at e056779a, twice: "a
  plugin's words are its own" red with #3897's line, the other three
  tests ok. Here, 6 runs: 4 of 4 each.
- Broken by hand in claude_code_cli.go, a line added and then removed:
  - "// Runs as the gateway asks.", the key said as words: red, with
    'plugins/library/i18n.js "Runs as": internal/cli/claude_code_cli.go
    says it too'.
  - "// fetchClaudeRuns as the gateway asks." and "// Runs asks the
    gateway.", the key glued to a longer word before it or after it:
    4 of 4.
- No Go file is changed and no other test reads this file, so the Go
  suite was not run for it.

Taken from JoeyWu-tech's patch on #3897 (fd49dcc0f; the format-patch
sha256 matches the one posted there), cherry-picked as is onto origin/main
7dcc0aedc. Run again on mote at that head: i18n-keys 4 of 4; with
"// Runs as the gateway asks." added to claude_code_cli.go by hand, red
with #3897's line.
2026-10-28 12:01:47 +08:00
yetone 5ed6669cec sync: the account an agent is kept signed in to stays each computer's own
YsiCing on X: with only the library and usage ticked, the default account
of a subscription with several followed the other computer: a personal one
at home, a work one at the office, set again every day. The providers part
always syncs, and provider.Mirror took the other computer's Provider whole,
KeepLogin, KeepLoginAs and SwitchOnly with it.

Mirror now keeps this computer's three for a provider it has, and a new one
comes without KeepLoginAs (an account signed in over there). davsync's
hashes blank the three, so changing which account is kept uploads nothing
and two computers that differ only in it don't trade the part. The sign-ins
themselves (logins.json) were never synced. A backup Restore is left as it
is: it is asked for, and brings the backup's choice.

Run on mote at this tree: go test -count=1 ./internal/provider
./internal/davsync ./internal/backup ok; go vet for darwin, linux and
windows on both packages ok. Broken by hand: with backup.go and davsync.go
reverted, TestMirrorKeepsKeepLogin and TestKeepLoginIsNoChange both fail.
Not tried: two real computers syncing through a real WebDAV folder.
2026-10-28 11:56:55 +08:00
yetone 396e0e4638 usage: a deleted provider's requests merged into another, or named, from the Requests filter
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).
2026-10-28 11:15:57 +08:00
yetone 77898391d5 code standards: a red's issue is read to its last comment, and a patch on it is taken first
Seen on 10-12 (#1794), 10-17 (#2444) and 10-28 (#3568, JoeyWu-tech's patch waited three days until 11c427eaa), so the lesson moves from LESSONS.md into the Tests table. Docs only; nothing run.
2026-10-28 10:49:39 +08:00