Commit Graph
1163 Commits
Author SHA1 Message Date
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
yetone e29ddc407f library: a Pi in WSL is given MCP servers, and so are seven more WSL agents
leokon on Discord (#help): the Library's MCP section listed only the
Windows Pi, never a Pi installed in WSL. wslTargetOf left pi@wsl's MCP
out because its version wasn't known, and Pi's MCP file depends on the
version: 0.99+ reads mcp.json itself; before that, pi-mcp-adapter 3 reads
mcp-adapter.json and 2 reads mcp.json.

- The WSL probe now asks the distro's pi for --version (wslKind
  version: true). The answer is stored as the agent's wslVersion, and
  InstalledVersion returns it for an agent in WSL.
- pi@wsl:<distro> gets piMCP. The file is chosen as on this computer,
  with the distro's npm roots for the adapter (~/.npm-global,
  /usr/local/lib and /usr/lib node_modules): wslPiRoots, piDetectIn.
- Siblings: every agent with a local MCP target and no WSL one now
  has one, in its own file under the distro's home. These are Gemini
  CLI, Antigravity CLI, Crush, Cline, CodeBuddy Code, Kimi Code and
  Goose.
- Every WSL MCP file is marked WSL with its distro, so a Windows
  program (C:\...\npx.cmd) is refused, as for claude/codex@wsl.
- Not fixed: Kimi Code's and Goose's skills in WSL. On this computer
  they get the shared ~/.agents/skills, but the distro's needs that
  folder's sharing rule (#3966).

Run (at d8c70504d + this commit; rebased on d50f84c9f, two mover mins):
- go test -tags nogui ./internal/agent ./internal/library on mote: ok.
- GOOS=windows and GOOS=linux go vet ./internal/agent ./internal/library:
  ok.
- gofmt -l: clean.
- New tests:
  - TestWSLPiMCP covers three fake distros: Pi 1.2 gets mcp.json
    (native); Pi 0.98 with no extension gets mcp-adapter.json; Pi 0.98
    with adapter 2 in ~/.npm-global gets mcp.json (fmtPi). Each is in
    the page's view, and is written to its distro and not this
    computer's Pi. A Windows program is refused.
  - TestWSLMCPSiblings covers the 7 siblings: path, WSL mark, writes,
    and refusal. The OS switch is forced with agent.FakeWSL.
- GUI, on mote: library-*.test.cjs, wsl-agents-setting and i18n-keys
  (Chromium and WebKit, every language): 769 of 770 pass. The red is
  i18n-keys "a plugin's words are its own" ("Runs as" in
  claude_code_cli.go), red on main since 7f827b3b0, #3897.
- Full suite on mote (go test -tags nogui -timeout 45m ./...) at
  d8c70504d + this change: 76 packages ok, no FAIL, exit 0.
- Real run, on the Windows box: magpie built on Windows, run in a
  sandbox USERPROFILE. `magpie library mcp add wslfetch uvx
  mcp-server-fetch agents=pi@wsl:magpie-desktop` wrote the server into
  magpie-desktop's ~/.pi/agent/mcp-adapter.json. The distro has pi
  0.73.0 from npm, which the probe asked; it is before 0.99 and has no
  extension. A C:\Program Files\nodejs\npx.cmd server was refused for
  pi@wsl. Both files were then removed.

Broken by hand, each turned the new tests red:
1. pi@wsl with no MCP: TestWSLPiMCP.
2. The version not passed: Debian got mcp.json.
3. No distro roots: Arch got mcp-adapter.json.
4. No WSL mark on the file: the Windows program was written.
5. The gemini case removed: TestWSLMCPSiblings.

Not tried:
- A real Pi 1.x in WSL. magpie-desktop's own pi is 0.73 and was left
  as it is. The 1.x choice (mcp.json) is covered by the test only.
  @earendil-works/pi-coding-agent 1.4.0 answered `--version` with "1.4.0"
  on the box.
- The seven siblings with real installs in WSL.
- A distro that is stopped. Its saved probe from before this release
  has no pi version, so the file is chosen as for an unknown version
  (mcp.json), until the distro is probed while it runs.
- The GUI on Windows. Its MCP list shows any agent whose view has an MCP
  file, unchanged.
2026-10-28 10:37:13 +08:00
JoeyWu-tech 11c427eaa6 gateway: a handed-off gateway stops accepting at once and answers every connection it took (#3568)
On a restart to update the old magpie hands its listening socket to the
new one (Inherit, then HandOff once the new one serves on it). HandOff
only marked the drain, so the old one went on accepting from the shared
socket beside the new one until its end's Shutdown closed its copy.
net/http's conn.serve returns without an answer when it reads a request
after Shutdown began (go1.26.8 net/http/server.go:1994), so a connection
the old one took in the moment before its Shutdown, whose request it
read a moment after, was closed unanswered. The agent got EOF on a fresh
connection, which Go's client doesn't retry for a POST. That is CI's red
at 81a58d2f (run 40210740758, ubuntu-latest):
  handover_test.go:142: request 0 during the handover: Post
  "http://127.0.0.1:.../v1/chat/completions": EOF
`make dev`'s handover (Handover) ends through the same drain and lost
such a connection the same way.

Now:
- HandOff lets this process's copy of the socket go at once
  (stopAccepting). The new one's copy keeps the socket open, so every
  connection from then on waits in its queue for the new one, and none
  is refused. A `make dev` backend lets its own listener go as its end
  begins; the one started beside it has the port on a socket of its own.
- Before Shutdown, a handover's end waits until Serve has returned and
  each connection it took has had its first request read (unreadConns,
  the server's ConnState), unreadWait (5s) at most: a connection that
  sends nothing for 5s is idle to Shutdown too. Serve returning counts
  because net/http notes a connection (StateNew) on the goroutine that
  took it, after Accept and before Serve can return; Shutdown marks the
  server shutting down before it waits for Serve, so one noted after
  that would have its request cut too.
- Serve ending because its listener was let go waits for the drain, as
  an end through Shutdown does.
An ordinary quit and a restart that waits are unchanged: no wait, the 2s
drain. Documented in docs/subsystems/gui-shell.md (the handover's step
3) and gateway-routing.md.

Not changed:
- With TLS on, tlsListener has a connection from this computer wait for
  its first byte (sniff) before handing it to the server, and closes one
  still waiting when the listener closes (hand, tls.go:288). Such a
  connection is still closed unanswered, at HandOff now and at Shutdown
  before (#3647).
- `make dev`'s own backend server (dev_on.go, dev builds only), which
  serves the page rather than agents, still calls Shutdown at once as
  its handover begins: the same drop for the page's requests (noted on
  #3568).
- An idle keep-alive connection is closed by Shutdown, as HTTP/1.1 lets
  a server do; a client sending on it in that moment sees it closed.
- What waits in `make dev`'s own SO_REUSEPORT queue when it closes is
  reset by the kernel, at its end's start now and at Shutdown before.

What was run (tree e1968b96, on origin/main 9fc382e6, go1.26.8; Linux,
outside graftcp, umask 077; line numbers at this tree):
  TestHandedOverGatewayFinishesItsStream as it is, -count=200: 3 of 200
  red at origin/main with CI's message (handover_test.go:142 there),
  0 of 200 with this change
  with the drain injected 50ms late and a connection taken once handed
  off served 100ms late (scratch, env-gated), -count=20: 10 of 20 red at
  origin/main's gateway, handover_test.go:144: request 0 during the
  handover: Post "http://127.0.0.1:.../v1/chat/completions": EOF; 0 of
  20 with this change. The drain 50ms late alone: 9 of 20 red there,
  handover_test.go:153: the new one answered 0 of the 5 requests after
  the handover; 0 of 20 with it
  the new tests on origin/main's gateway.go and handover.go, -count=20:
    TestHandedOffGatewayTakesNoNewConnection 20 of 20 red:
      handover_test.go:275: the old one answered 1 request(s) made once
      it had handed the gateway off
    TestHandedOffGatewayAnswersAConnectionItTook, both subtests 20 of
      20 red: handover_test.go:335: a request on a connection the old
      one took, sent once its end began: "" unexpected EOF
    TestHandedOffGatewayAnswersAConnectionNotedLate, both subtests 20
      of 20 red: handover_test.go:435: a request on a connection the old
      one took, noted once its end began: "" unexpected EOF
  with this change, -race -count=20 of those four, TestSameAddr,
  TestInheritedForAnotherAddressIsLetGo,
  TestToolCallOfTheMagpieBeforeGoesToIt,
  TestCallbacksSocketServesOnlyToolCalls and TestBridgeTurnsCount: ok,
  no race (load 94)
  broken by hand, with this change, -count=20 each:
    HandOff not letting its listener go:
      TestHandedOffGatewayTakesNoNewConnection 20 of 20 (:275), and
      TestHandedOverGatewayFinishesItsStream 1 of 20,
      handover_test.go:153: the new one answered 1 of the 5 requests
      after the handover
    Serve's end once its listener is let go not waiting for the drain:
      TestHandedOverGatewayFinishesItsStream 20 of 20,
      handover_test.go:159: the old one ended with a stream in flight:
      accept tcp 127.0.0.1:...: use of closed network connection; the
      four subtests above 20 of 20 with the same error (:342, :440)
    no wait before Shutdown: the four subtests 20 of 20 (:335, :435)
    the wait not waiting for Serve to return: both subtests of
      ...NotedLate 20 of 20 (:435)
    a `make dev` end keeping its listener: both make dev subtests 20 of
      20, handover_test.go:345: the old one never ended once its
      connections were answered (it waits out unreadWait's 5s; the
      tests give it 3s, against the ~0.1s it takes)
    the end's steps for a handed-off gateway only: both make dev
      subtests 20 of 20 (:335, :435)
  internal/gui TestRestartHandsTheGatewayOver -count=20, the other gui
  handover tests -count=3 and internal/handoff -count=3: ok, as at
  origin/main
  -run TestTLS ./internal/gateway -count=3: ok
  gofmt -l: nothing. GOOS=linux and darwin go vet -tags nogui ./...,
  GOOS=windows go vet ./...: exit 0. GOOS=linux and darwin go build
  -tags nogui ., GOOS=windows go build .: exit 0
  full suite, go test -tags nogui -count=1 -timeout 45m ./... (302 s,
  load 76 to 97): 64 packages ok, internal/gateway among them. 14 reds
  in 7 packages, none in a file this change touches:
    internal/agent TestCursorFolderFromTheEditorIsNotTheCLI,
    TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
    TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
    TestOmpDetectedWithPiDir: proc.Look keeps "not found" for a tool
    written in the tick of its folder's last change (#3141).
    internal/agent TestReasonixCLIRequiresSupportedNativeVersion and
    TestReasonixCLIRecoversAfterProbeTimeout: their fixture build under
    /tmp meets a /tmp/.git that isn't a repository of this user's
    ("error obtaining VCS status: exit status 128").
    internal/davsync TestSync and TestSyncTeraCloudStillSeesOtherWrites:
    the local save lands in the push's clock tick (#3420).
    internal/edit TestWriteAtomicReadOnlyHardLink and internal/testenv
    TestProgram: umask 077 here; the fixtures' own modes go through it.
    internal/gui TestGatewayHeldByAContainer and
    TestGatewayFixQuitsOnlyAMagpie: proc.ListeningOn reads every fd this
    user can, 19.7M on this machine (other projects' processes leak
    them), which takes 1m30s against the 30s the take-over gives it;
    both pass in a fresh pid namespace.
    internal/netproxy TestBunProxyLoginWithReservedCharacters: Bun
    1.3.11 on PATH (#3397).
    internal/provider: fatal error: close of synctest channel from
    outside bubble, in TestUnreadLoginsWriteErrorsKeepCredentials
    (#3632).
  (A first suite run under systemd's own PATH, node v12 and no Bun, had
  four more in internal/plugin, "Cannot find module
  'node:assert/strict'"; with the user's PATH, node v22, it is ok.)
Not tried: a real restart to update on Linux or macOS (the tests hand
the socket over within one process), and macOS at all; Windows, which
doesn't hand over (vet and build only); a Relisten reaching the old one
after HandOff, whose window is withdrawn by then.

Ported from JoeyWu-tech's fix/3568-handoff-stops-accepting (56c67ad2,
posted on #3568 on 10-25) after it went red on ubuntu CI again at
0a7633136 (run 40614167541, handover_test.go:142 EOF). Cherry-picked
unchanged onto origin/main.

Run again by the porter (mote-run, at a05b37353 + this; at the pushed
head 69626580b + this, go build ./... and the handover set -count=10 ok;
7bdefe212 since then changes only the Routing page's JS, CSS and GUI tests):
- the three new tests on the old gateway.go/handover.go, -count=5: 15 of
  15 red; with this change, with TestHandedOverGatewayFinishesItsStream,
  TestSameAddr and TestInherited*, -count=20: ok.
- the same set plus TestRestartHands*, -race -count=10: ok.
- GOOS=windows and GOOS=linux go vet ./internal/gateway: ok. gofmt -l clean.
- go test -timeout 45m ./internal/gateway: ok (510s). ./internal/gui/...:
  TestMainWindowCorners/macOS_26_SDK red on mote's macOS 27, #3949, not
  touched here.
Not tried: a real update restart.
2026-10-28 10:17:14 +08:00
yetone a05b373538 checkin: a plugin's until is when its answer stops holding (Qoder's 10:00 UTC+8)
sdytman on Discord: Qoder's daily credits start at 10:00, can the plugin's
check-in follow it? Qoder's /me/campaigns opens each day's CLAIM_BENEFIT
campaign at 10:00 and closes it at 09:59 the next day, UTC+8 (startAt and
endAt, read with a real account on 10-28; Qoder.app polls the list every 5
minutes). A check-in before 10:00 meets the day before's campaign. Since
#2696 the Qoder plugins are asked again every 30 minutes, so today's was
claimed somewhere between 10:00 and 10:30; a plain plugin was settled for
the Beijing day.

auth.checkin may now answer until (RFC 3339 or epoch ms); host.js passes
it as RFC 3339 (plugin.Checkin.Until), kept as ValidUntil. settled holds
an answer only until then, whatever its outcome; the loop wakes at it
instead of its next 30-minute look; an early done that carries it is not
provisional (#3326), as the vendor said when its day turns. Instants
throughout, so the machine's zone doesn't matter. The Qoder plugins send
until from 0.2.43 (plugins fd40b20): the check-in now lands at 10:01.

Run (mote): TestPluginCheckinAsksAgainAtUntil, minute by minute from
09:27 Beijing to the next day's 10:30, with time.Local UTC, UTC-8 and
Beijing: asks at 09:27, 10:01, 00:00 (the Beijing day), 10:01; a failure
in the 09:59 gap asked at 10:01:00 only. GOOS=linux and windows go vet;
go test -tags nogui -timeout 45m ./... all ok (76 packages). gofmt -l
clean.
Broken by hand, each red: settled ignoring ValidUntil (no 10:01 asks);
tick not waking at it (10:27 instead); provisional ignoring it (asked
every 30 minutes from 00:00 to 10:00); host.js dropping until (ValidUntil
zero).
Not tried: the Qoder plugin's recheck path with until (the fake plugin
is fakeco; the tick and settled it goes through are the same); a GUI
change (none: until isn't shown).
2026-10-28 09:51:43 +08:00
yetone f39fc3ac8b usage: a model list that was answered is no row of Requests (ferock on Discord)
ferock (Discord #general): Usage > Requests is full of rows like
"magpie · magpie's own · Remote magpie · API · Model list · 0 0 · 757 ms
· 200, GET /v1/models", which no tool of theirs sent.

Cause: ffe493773 (v0.1.1446) wrote every request magpie sends a
provider on its own into the request log (source "probe"): the editor's
Test and Detect APIs, and every model-list fetch. 0152f6696 then gave a
Remote magpie a 10-minute list schedule (KeepListsFresh), so each Remote
magpie added ~144 such rows a day. The same rows came from every other
automatic fetch: start-up's FetchNew, the panel's FetchNewSoon, the
Providers page's FetchNewBehind and any provider with a RefreshEvery.
They were already counted in no token, cost, chart, budget or quota
total, but they were listed and counted in the page's row total.

Fix: a model_list probe with a 2xx/3xx status and no error
(usage.quietProbe) is not written by usage's probelog.Sink, and is
skipped when the log's index parses one (logSnapshot.probes). This rule
covers every list fetch, whoever started it, so every sibling is
covered by one check. A list that failed is still a row (the Failed
filter finds it, and the row says why models are missing), and every
Test and Detect APIs row stays as it was. Older rows: the answered
model lists already in usage.jsonl stop being listed at the next start
of the index, with no rewrite. The lines stay in the file and nothing
reads them. Quota and usage polls and health checks were never written
there (only Test, Detect and list are marked by probelog), so nothing
else needed changing. The TUI and CLI have no request list. The heatmap,
Summarize, Load and the exports skipped probes already.

Tests:
- usage TestAnsweredModelListIsNoRow (new): 200 and 304 lists aren't
  written; a 503 and a connection-refused list are listed and Failed
  finds both; a 200 Test is listed; an old answered list line in the log
  is not listed, and Total is 3.
- TestProbeRowsListedNotCounted and the rename tests now use a failed
  list (a 200 one would no longer be a row).

Broken by hand, each red: quietProbe returning false (the 200 list
written and listed); the index's skip removed, Sink's kept (the old line
listed, total 4).

Run, on mote:
- go test -tags nogui -timeout 45m ./... at the pre-rebase head
  (b4f2fa9d3 on 0a7633136): every package ok, 76 ok, exit 0 (gateway
  547s, agent 298s, provider 167s, usage 48s).
- After rebase on origin/main 9ba3f049e (which touched neither usage
  nor probelog): go build ./...; go vet for darwin, GOOS=linux and
  GOOS=windows on usage and probelog; go test usage, probelog,
  usageapi, and provider -run Probe|Detect|TestTestWrites: ok. gofmt
  -l clean.
- GUI (no asset changed): usage-ledger*.test.cjs, ledger-*.test.cjs and
  own-requests.test.cjs, chromium and webkit, each file's languages:
  381 tests, 375 pass. The 6 reds are usage-ledger's "newest live route
  needs no return-to-live button" (en, zh, both engines), which is
  already filed as #3104. usage-ledger-probe passed in every language.

Not tried: a real Remote magpie over a day. The row filter was not
checked on a real usage.jsonl.
2026-10-28 09:42:21 +08:00
yetone 08b02cf18c providers: a pool stops at its caps and reads usage again near them (plugins#349)
What was adopted on magpie-community/plugins#349 (1939869736luosi): one
place, in the GUI and the CLI, for a subscription's account pool, and an
opt-in conservative mode.

- Stop at the caps (Provider.CapStop, off by default): once every account
  in use is held at its cap, the request is answered 429 rather than going
  on to the provider's fallbacks (plan returns restLast). Off, as before.
- Check usage again near a cap (Provider.CapCareful, off by default,
  internal/gateway/cap_careful.go): before planning, a capped account's
  usage is read again when its reading is over 15s old within 5 points of
  a cap, or over 5m old at all; the request waits at most 10s, and a
  failed account is asked again at most every 15s. An account whose usage
  was never read, whose last read failed, or whose reading is still that
  old is then held as one at its cap is (capHold "unread", traced as
  Weighed.Unread, named in the 429 with "--careful off"). Generic: it
  goes by provider.UsageRead/ReadUsageNow, so every subscription that
  reports usage windows (Codex, Claude, plugins) gets it.
- provider: usedCache records each account's read state; a failed read
  keeps the last good reading's time. ReadUsageNow no longer reports
  false when the read had already finished on the first ask.
- GUI: under the provider's account list, once an account has a cap (or
  either is on), two ticks for the above, and a note naming the accounts
  in use with no cap ("used to 100% of each window"). Accounts, order and
  caps stay where they were in that list. zh, zh-TW, ja, de added.
  app.js 1,309,658 within its 1,310,460 budget, unraised: addRow and a
  per-row forgetOf replace 3 add-button and 5 Remove-button builds.
- CLI: magpie provider pool <id> [--accounts a,b,…] [--cap percent|off]
  [--stop on|off] [--careful on|off] shows and sets the whole pool.
- docs: gateway-routing.md and providers-accounts.md.

Run (mote, before the rebase at 8bade6c5e + this change):
- go test -tags nogui -timeout 45m ./...: exit 0, 76 packages ok, no
  FAIL (log grepped).
- GOOS=linux and GOOS=windows go vet of cli, gateway, provider, gui: ok.
- pool-ends.test.cjs: 32/32, Chromium and WebKit, en zh ja de, 1100 and
  420 wide.
- The 81 GUI files whose fixtures have accounts or caps, plus i18n*,
  6 at a time at load ~130: 76 pass. i18n-keys is red on the base too
  (#3897). account-mask (#3951), account-alias (#2984),
  signin-closes-sheet and signin-again timed out under load and pass
  run again, as on the base; signin-again filed as #3960.
- Real plugin host: TestPluginCarefulPool runs the fake plugin under Bun
  as Factory with two accounts capped at 90%: a failing usage call gives
  429 with nothing sent upstream while careful is on, the last reading
  is used with it off, a good read sends to A again, and with both at
  their caps the fallback serves unless Stop is on.
- CLI binary in a sandbox HOME on mote: unknown provider, a bad --stop
  value and no id each refuse and change nothing.
At the rebased head (0a7633136 + this): gofmt -l
clean, go build ./..., the new Go tests and the budget tests, and
pool-ends.test.cjs 32/32.

Broken by hand, each seen red, then restored:
- the CapStop line in plan: TestCapStopSkipsTheFallbacks and
  TestPluginCarefulPool red;
- the careful hold in capHeld: the three careful tests and
  TestPluginCarefulPool red;
- careful always on: TestCarefulOffByDefault red;
- readCareful not called: the failed, never-read, stale and re-read
  subtests red;
- a failed read not keeping the good time, or not counted as failed,
  and ReadUsageNow's early return forced false: TestUsageReadAndReadAgain
  red;
- the ticks' onchange emptied: pool-ends.test.cjs 16 of 16 red.

Not tried: a real Factory or any real account (fake plugin only); the
whole GUI suite (932 files, ~5h at this load), only the 81 files that
reach the account list; Linux WebKitGTK and Windows; the 15s/5m/5-point
figures against a real vendor's usage endpoint latency.
2026-10-28 09:29:44 +08:00
yetone 8bade6c5e2 provider: a plugin's usage window can be a prepaid wallet's balance (#3950)
SuperMagic's accounts (mycf_711's magicrew plugin) are prepaid wallets of
points with no total. A plugin can now send a usage window as
{name, balance: 6291, unit: "积分"} with no used or limit.

- host.js passes a finite balance on (at least 0), anything else as null.
  plugin.UsageWindow.Balance and provider.QuotaWindow.Balance are *float64.
- quotaOfPlugin keeps the figure and does not make the window Text or
  Aside, so routing knows the account with no Used invented. allowanceOf
  copies it into Limit.Balance; an empty wallet counts as used up.
  Allowance.Left(model) is the least balance of the windows that count
  the model.
- weighRouted fills routes.Seat.Left and Seat.LeftIn (the account's
  provider and unit). Smart, pace and usage (least used) put the seat
  with more left first where they would otherwise tie (byLeft), only
  when every seat with a balance shares one LeftIn: balances in two
  units or two providers are never compared. Tiers still come first.
- The Usage card, the Routing page (Weighed.Balance: the small row's
  text, no bar, a why sentence, the account list), magpie accounts and
  the status line show the figure, "6,291 积分 left", never a share.
- Docs: provider-plugins (new section), gateway-routing,
  providers-accounts, plugin-runtime, host.js typings and the site's
  plugins page (en, zh, ja).

Run, at base f13aafa87, on mote:
- go test -tags nogui -timeout 45m ./...: 72 packages ok; red were
  TestQuotaSpanCarriesEveryWindowField (this change's: its fixture now
  sets Balance, green after), and on the unchanged base too
  TestWSLColdPlaceOpensNothing (#3924), TestFetchAsksASharedBaseOnce and
  two siblings (#3854), TestTUIFetchesSubscriptionModels (#3919), all
  fixed on main since and run again after the rebase; and
  TestPluginStreamsPastTheBudgetWait (#3946), green alone on both.
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/..., go
  build ./..., gofmt -l: clean.
- New tests: TestPluginWalletBalanceIsAReading, TestAllowanceLeftIsTheLeastBalance,
  TestPluginHostPassesABalanceOn (through real Bun and host.js),
  TestWalletsGoByWhatTheyHaveLeft, TestWalletLeftWithinItsTier,
  TestWalletWithMoreLeftGoesFirst, TestQuotaCell's balance cases;
  usage-wallet-balance.test.cjs and routing-wallet-balance.test.cjs,
  34 of 34 in Chromium and WebKit, en zh zh-TW ja de, 1100/900/420/390px.
- GUI: every quota*, usage*, panel*, routing*, i18n* and tray* file (220
  files, 2928 tests), concurrency 4: 130 red, in 21 files. Those 21 files
  run again on an unchanged base copy and on this change, concurrency 2:
  the same 19 files red on both (126 and 131), the differing subtests
  being routing-rule-remove / rules-line / intent-entry flaps that go
  both ways. Each is filed (#3679, #2115, #3410, #3404, #3411, #3897,
  #1905, #3096, #3593, #3408, #3409, #3799, #3789, #3412, #3947, #3415,
  #3414, #1345); routing-story-shrinks had none and is #3954.

After rebasing on origin/main 833f51adc, on mote: Linux and Windows vet,
go build, gofmt clean; go test -tags nogui of internal/routes, provider,
gateway, cli, plugin, gui (the script budgets), agent and tui: all ok;
the two wallet GUI files and i18n-keys: 37 of 38, the red being
i18n-keys' "Runs as" (#3897, not this change).

Broken by hand, each red then restored: quotaReport's Balance copy
removed (TestQuotaSpanCarriesEveryWindowField red); byLeft always nil (routes and
gateway tests red); host.js's balance line removed (host test red);
quotaOfPlugin's balance copy removed (provider tests red); app.js and
client.js at base (both GUI files 34 of 34 red, "0% used" / "已用 0%").

Not tried: a real SuperMagic account or the magicrew plugin (it isn't
in the community repo; it needs to send balance), Windows and Linux
GUI apps, and the WebKitGTK app.
2026-10-28 08:28:56 +08:00
yetone 833f51adcf gui: a browser tab has the font rows too, with its own choice
Norcleeh on Discord: magpie opened in a browser had no font setting in
Settings > General, while the app does. The rows were hidden on purpose:
/api/fonts answered 404 to a browser page and boot sent it no choice,
since the list is the fonts of the computer magpie runs on and the tab
can be on another one.

Now a browser tab (magpie web, or the app's page in a browser) has both
rows wherever magpie can read its fonts (boot's fonts; a nogui build
can't, and keeps them hidden). Its list is /api/fonts less the families
this browser doesn't draw (fonts.js here(): text in the family measures
apart from monospace's or serif's on a canvas), so another computer's
fonts and Safari's user-installed ones aren't offered. The choice is the
browser's own, in localStorage (magpie.fonts), applied by fonts.js
before the first paint; it neither changes nor takes the app's
settings.UIFont/CodeFont, and a settings save from a browser still
keeps the app's.

Run on mote at this tree (on b90e81da1), also GOOS=linux (nogui) and
GOOS=windows go vet ./internal/gui/..., go build, gofmt -l:
- fonts.test.cjs, font-cascade.test.cjs, win-fonts.test.cjs, i18n-keys
  and the 42 drag/arrange GUI files, Chromium and WebKit, en and zh (and
  ja/de where a file has them). The reds are 32 subtests in 4 files
  that fail the same on origin/main b90e81da1 run alone (and one from
  a stray path in the run command): i18n-keys "a
  plugin's words are its own" (#3897), routing-rule-drag webkit de
  (#3789), segs-press-redraw webkit (#3922), usage-agents-hide (#3414).
- go test -tags nogui ./internal/gui (TestCoreScriptBudget and
  TestFontSettingsAPIAndBoot included) ok; go test ./internal/gui -run
  Font (cgo, CoreText) ok.
- Real use: magpie built on mote, `magpie web` in a sandbox HOME, real
  /api/fonts (204 families). Chromium offered 204, WebKit 179; Georgia
  picked in each, the body drew it and kept it across a reload, and no
  settings.json was written.
Broken by hand: fontsOn = !web (rows hidden as before): the new test
red in all four engine/language cases; here() returning the list
unfiltered: red with "a family this browser doesn't draw isn't
offered".
Not tried: a browser on a different computer from magpie (the canvas
filter is what covers it, checked with a family the test machine
lacks), Firefox, the Windows and Linux apps' pages in a browser.
Budget: not raised; the previous commit's 1,097 bytes cover it.
2026-10-28 08:01:46 +08:00
yetone a1222c539f LESSONS: a mover's min moves to the code standards (third day), and red issues' patches sat unowned on 10-27
- A plugin version published with no mover min raised was seen on 10-16,
  10-18 (zed 0.1.9) and 10-24 (factory 0.1.38, raised four days later
  in 490c0a4ad). It moves to the code standards' release rules: the min
  is raised the same day the plugin version is published.
- 10-27 is the third day of the #1794 pattern: #3632 (internal/provider
  dies on main since 10-25, two complete patches, no owner), #3919 and
  #3924 (JoeyWu-tech's patches since 10-27) and #3854.

Checked: every mover's min against `npm view --prefer-online` (factory
was the only one behind; grok 0.1.16 was raised two hours after its
publish, cc8e8e3bd, so it is not evidence). #3632 red 2 of 2 on mote at
4b0a32e0f. TestLoopGuard* (reads both docs) ok on mote at this tree.
2026-10-28 06:28:17 +08:00
yetone 88466f8bf2 provider: a ChatGPT account whose usage read says OpenAI signed it out reads as signed out, with Sign in again (charliepu on Discord)
charliepu (#general): a ChatGPT account sometimes shows no allowance;
OpenAI had signed it out, and it needed signing in again. The row said
nothing of that. 86b2f4d05 (#1793) marks a revoked sign-in, but only
from a gateway request: the usage read never reached it. /wham/usage
answering 401 token_revoked ("invalidated oauth token") was taken as a
bare "Unauthorized", with no refresh tried, and the refused refresh of
the account Codex is signed in to said "run codex login" on the
allowance line and nothing on the row.

Now, in the usage read (loginQuota -> codexSignInRead):
- a 401 with revokedWords is refreshed once, as a token_expired one
  already was (codexWindowsRenewing); a refresh that goes through is
  read again and marks nothing;
- the refreshed token turned away the same (revoked, or still called
  expired) is codexSignInGone, and the account is marked revoked for
  that token (markRevoked, split out of NoteRevokedSignIn);
- Codex's own account's refused refresh marks it the same; a saved
  account's refused refresh is savedRefreshFailed's lapse, as before;
- a read that goes through clears a mark (ServedSignIn);
- a plain 401, a 403, a 5xx or a network error is unknown and marks
  nothing, with no refresh.
The row's existing Sign-in required / Sign in again (revoked-signin-
account) then shows. Sign in again runs magpie's own sign-in for that
account (addLogin), which replaces its tokens, in Codex's auth.json too
when Codex is signed in to it; no second account is added.
No GUI change: the row reads l.lapsed, which this now sets.
docs/subsystems/providers-accounts.md updated.

What was run (mote, sandbox HOME per test, fake usage and token servers;
no live ~/.codex or Keychain):
- go test provider: new TestCodexUsageRevokedRefreshedFirst,
  TestCodexUsageRevokedSignedOutTillSignedInAgain (refused refresh, both
  rows signed out, the gateway would pass over the token, signed in
  again through addLogin: same two accounts, auth.json replaced, mark
  gone, read works), TestCodexUsageRevokedAfterRefreshSignedOut,
  TestCodexUsageOtherFailuresMarkNobody (plain 401, 403, 502, network);
  TestCodexUsageExpiredOnce updated (Codex's own refused refresh and a
  still-expired refreshed token now say sign in again); the #1793 and
  #2973 tests pass.
- Broken by hand, each red: codexSignInRead skipped (3 tests red), the
  revoked case dropped from the renew condition (3 red), the
  ServedSignIn clear dropped (AfterRefresh red).
- GUI (Chromium + WebKit, every language the files cover, en and zh
  included): revoked-signin-account, codex-*, signin-*, usage-accounts*:
  583 of 583 pass.
- gofmt; go vet provider darwin/linux/windows; go build darwin,
  linux and windows (nogui).
- go test -tags nogui -timeout 45m ./... at 82299480a (this change on
  7f32f0ec9): every package ok but agent, gateway, gui, tui and
  provider. Each red fails the same at a fresh origin/main f6ed2c99b
  (ran there alone), and each is filed: TestWSLColdPlaceOpensNothing
  #3924, TestPluginStreamsPastTheBudgetWait #3946,
  TestRestartHandsTheGatewayOver #3451, TestTUIFetchesSubscriptionModels
  #3919, provider's synctest crash in TestUnreadLoginsWriteErrorsKeep-
  Credentials #3632. With that test skipped, provider at the rebased
  head f6ed2c99b+1: only TestFetchAsksASharedBaseOnce and its two
  siblings red, the same on f6ed2c99b (#3854); cli ok.

Not tried: a real revoked ChatGPT account (none to hand); the words are
#1793's revokedWords, taken from real replies there. The Codex card's own line
(codexSubscriptionUsage) still says "codex login"; the account row is
where Sign in again is. The TUI has no per-account allowance rows;
`magpie accounts` already prints Lapsed, now for Codex's own too.
2026-10-28 05:02:12 +08:00
yetone f6ed2c99bc effort: a vendor's light and extra_high are low and xhigh, in dsh, Pi and the gateway
nianshou5 (Discord) runs Trae's DeepSeek V4.1 Flash through the Our Free
Model plugin (github:mu-zi-lee/magpie-our-free-model). Its variants are
Trae's own names, light, high and extra_high, and dsh offered only
default and high: dshModelLevels (and Pi's piThinkingLevels) matched a
model's efforts to pi-ai's level names only, so light and extra_high
were dropped. The gateway dropped them too: effortOf read "light" as no
effort, and NearestEffort fitted an agent's low or xhigh to the plugin's
high.

catalog.EffortAliases names light as low and extra_high as xhigh
(EffortLevel). NearestEffort places a model's levels by the level they
name and returns the model's own word; the gateway's effortOf reads an
alias as its level. dsh's reasoningEfforts and Pi's thinkingLevelMap map
dsh's low/xhigh to the model's own word (modelEffort), which llm-pi-ai
sends on the wire as written (resolveModelReasoning in dsh-llm-pi-ai
reads each value as "the spelling dispatch sends"). Levels a user kept
are untouched: only the names a model lists are mapped.

Tests: TestDshOffersTraeNamedLevels (agent), TestNearestEffortTakesVendorWords
(catalog), TestPluginThinkingOff's new fake-trae subtests (gateway, a
real plugin host with the fake plugin listing light/high/extra_high).
Broken by hand: modelEffort without the alias, dsh levels [high] (the
report's picker); NearestEffort without EffortLevel, low/xhigh sent as
high; effortOf without the alias, light/extra_high sent as nothing.

Run on mote at this tree (base e4ccf67b1): go build, GOOS=linux and
GOOS=windows go vet -tags nogui ./... ok; go test -tags nogui -timeout 45m
./... : 73 packages ok, three red that are red the same on origin/main
7f32f0ec9 run alone: internal/agent TestWSLColdPlaceOpensNothing (#3924),
internal/tui TestTUIFetchesSubscriptionModels (#3919), internal/provider
synctest crash in TestUnreadLoginsWriteErrorsKeepCredentials (#3632), so
the rest of internal/provider didn't run. No GUI file changed.
Rebased on 7f32f0ec9 (one agent file changed there): go build ./...,
internal/catalog whole and gateway/agent -run Effort|Dsh|Pi|ThinkingOff|Level
ok at this head.

Not tried: a real dsh session against the user's plugin (no Our Free
Model account here); dsh's parsing of a non-pi-ai wire value was read
from its source, not run.
2026-10-28 04:34:45 +08:00
yetone 3e22123c9c usage: a deleted provider's calls stay apart from a new one under its id
cybercaius (Discord): after deleting a provider and adding a new one
that took the same id, the old provider's usage showed under the new one.

Delete now records the provider in providers.json ("deleted": id, name,
icon, when, its Was and Gave). UsageRenames gives a deleted id to
<id>~<when> only once something reuses it (a live provider, a later
deleted record, or a later Was), so a deleted provider nobody replaced
keeps its raw id and the existing probe/usage tests stay as they were.
/api/usage's provider faces name a deleted id from its record and set
Named.deleted; the Usage provider picker notes "Deleted {date}" (zh, zh-TW,
ja, de translated). Old deletes, made before this, have no record and
stay merged: nothing tells their calls apart now.

Run (mote): go test -tags nogui -run 'Deleted|Rename|NotSetUp|Probe'
./internal/usage ./internal/usageapi ./internal/provider ok; gofmt -l
clean; go vet -tags nogui ok.
Broken by hand: dropping the f.Deleted append turns
TestDeletedProviderKeepsItsCallsFromOneAddedUnderItsID and
TestDeletedProviderListedApartAndMarked red; restored, green.
Not tried: a real delete-and-re-add in the GUI app.
2026-10-28 04:18:21 +08:00
yetone 8fff54dab7 routing: a group in a group left on Smart is routed as the outer one (#3847)
mycf_711 (#3847): an outer group set to Free first held a group whose
routing was left blank (Smart); the inner group's free seat was tried
after its paid one, as if Free first stopped at the inner group.

provider.Group.Within: in membersOff's walk, a nested group with no
routing of its own takes the outer group's when the outer one pools its
members (Smart, Free first, Fastest, ... ; not In order, By weight or
Manual, which try each member whole by its own order, #576). A group
that sets a routing keeps it. The gateway, the trace's Subs and the
Routing page all read membersOff, so they agree; GROUP_NEST's help
sentence says so (zh, zh-TW, ja, de).

Run (mote): go test -tags nogui -run 'FreeFirst|Group' ./internal/gateway
./internal/provider ok; GOOS=linux and GOOS=windows go vet -tags nogui
on both packages ok; go build -tags nogui ./... ok; gofmt -l clean.
Broken by hand: without the Within call
TestFreeFirstReachesAGroupInItLeftOnTheDefault is red (paid seat first),
green with it.
Not tried: the reporter's own groups in the real app.
2026-10-28 04:18:21 +08:00
yetone c544789047 agent, gui: the Codex takeover names browser use and offers Keep on ChatGPT
eddie.zhan on Discord (10-27): once Codex's allowance ran out, magpie
took it over and "many features stop working, browser use is blocked,
the agent says it has no permission".

Cause, from openai/codex 5a361b5: under the takeover magpie is Codex's
model provider without requires_openai_auth, so app-server's
getAuthStatus hands the app no auth token. The Codex app's Chrome
control needs that token, so browser use is off till the reset, with
cloud tasks, the usage meter and Log out. Image generation (actor
authorization header) and web search (provider default) stay. Bringing
requires_openai_auth back would bring back the greyed Send the takeover
exists to avoid, so it can't be kept by config.

The off switch existed (sign-in > Always ChatGPT, `magpie codex login
chatgpt`) but nothing under the takeover pointed to it. The default is
kept; the opened Codex row's takeover note now names browser use and has
a Keep on ChatGPT button (login=chatgpt) on its own line. In every
language.

Also fixed: Always ChatGPT picked while Codex was taken over on one of
its own models left model_provider = "magpie" for good. set now puts it
back on the sign-in as Join leaves it.

Run (on mote, at this tree):
- go test ./internal/agent ./internal/gui: ok except
  TestWSLColdPlaceOpensNothing (#3924) and TestMainWindowCorners/macOS_26
  (#2645), both red on origin/main f2b4b9894 too.
- TestCoreScriptBudget ok; app.js 1,310,432 under 1,310,460, not raised.
- GUI codex-app-out, codex-signin-always, i18n-keys in chromium and
  webkit at 980 and 440, every language: 95 pass, 1 red is #3897
  (i18n-keys plugin words, red on main).
- gofmt -l clean; go vet darwin, linux (nogui), windows on internal/agent
  and internal/gui.
Broken by hand: TestCodexOwnModelOutThenKeptOnChatGPT red on the old
set (model_provider = "magpie" left); codex-app-out red with origin's
app.js/i18n.js (no browser use in the note).
Not tried: the real Codex app, a real used-up account, the Windows box
and the Linux app.
2026-10-28 03:36:13 +08:00
ggbdpq ff7048dece provider: a Command Code plan key's Credits window renews at the plan's period end (#2454)
#2451 drew a plan key's month of credits as a Credits meter beside the
5-hour and weekly windows. Those two say when they start again; the
Credits one said nothing, though cmdKeyPlanID already asks
billing/subscriptions for the plan id and threw its currentPeriodEnd
away. cmdKeyPlanID now keeps the period end beside the plan id (cached
the same ten minutes, and the pair read before kept while the endpoint
can't be read), and cmdQuotaOf puts it on the Credits window's
ResetsAt. No new request. The signed-in subscription's card is the
plugin's since be62bcf79; the plugin sets the same reset from
commandcode-auth 0.1.13.

Patch by ggbdpq (Discord gua2100), as rebased in #2454. Added in
review: a period end already past is dropped, so a pair kept while the
endpoint fails, or a renewal its reply doesn't show yet, never puts a
reset in the past on the card; the test has a case for it.

Run (sandbox HOME, at origin/main 85b45b4d7 plus this):
- go test -tags nogui -run 'CommandCode|KeyQuotas' ./internal/provider/: ok
- Broken by hand: ResetsAt: until taken out -> "the key card's credits
  have no reset" (ResetsAt nil); the past-end guard taken out -> "the
  key card's credits reset in the past". Each restored: ok.
- go test -tags nogui ./internal/provider/: two known reds on main,
  both filed and both red at 85b45b4d7 without this change:
  TestUnreadLoginsWriteErrorsKeepCredentials crashes the binary (#3632),
  and with it skipped the rest pass except TestFetchAsksASharedBaseOnce
  and two siblings (#3854).
- gofmt -l internal/provider: clean. go vet ./internal/provider/ on
  darwin, GOOS=windows, GOOS=linux: ok.
Not tried: a real Command Code plan key (none here), the GUI card, a
period that renews while the card is open; go test ./... (one suite per
machine). The key card only learns the period end when billing/credits
leaves the plan id out, which is what it does today; if it starts
sending the plan id, the reset is not read.
2026-10-28 00:58:06 +08:00
ggbdpq 85b45b4d71 usage: a window's dollar whole prices the model the reply named (#2488)
The ledger prices a call whose own id has no price as the model the
reply named (Served, #1498). A window's whole priced through apiPricer,
which looked only at Record.Model, so one such call in a window had no
API price, the window counted as unpriced and its dollar whole was left
out while its tokens stayed. apiPricer now tries Served through the same
chain (maker, the provider's list, Same as) when the asked id has none.
The asked id keeps its own price when it has one; a price the user set
or a rate still never enters the whole. Past cycles use the same
apiPricer and take it too.

Patch by ggbdpq (Discord gua2100), as posted in #2488. Review: the
pricer is a closure built once per query with its own cache, keyed now
on (provider, model, served); no shared or stateful call added. The
only conflict on current main was the test file, where the Antigravity pools test
(TestWindowHoldsReckonsAntigravityPools) landed in the same spot; both
tests are kept.

Run (sandbox HOME, at this tree on origin/main 02cbdf5bd):
- go test -tags nogui -count=1 ./internal/usage/: ok
- Broken by hand: window_holds.go put back to origin/main, test kept:
  TestHoldsPriceTheModelTheReplyNamed FAIL "the model the reply named
  wasn't its API price: <nil>". Restored: ok.
- gofmt -l internal/usage: clean. go vet ./internal/usage/ on darwin,
  GOOS=windows, GOOS=linux: ok.
Not tried: the GUI's Usage page with a real relay account whose reply
names another model; go test ./... (one suite per machine).
2026-10-28 00:51:58 +08:00
yetone 02cbdf5bdc pii: pf-serve-vulkan keeps the engine's 4096-token MoE chunk; 2048 was slower (#3682)
7279bdc28 gave pf-serve-vulkan PF_MOE_CHUNK=2048 on the strength of a
1.77x speed-up yunwang2442-creator measured on an RX 470 (Windows,
Vulkan). Their re-test on 0.1.1696 found that number came from runs
hours apart: the same version read the same 480 KB text in 67s at 07:44
and 128-135s after 16:00. Interleaved A/B in one session, same text,
4096 was faster every time:
  96 KB in pieces  2048 25.4-25.8s   4096 24.0-24.2s
  24 KB in pieces  2048 6.2-6.5s     4096 6.0s
  96 KB whole      2048 36.1-36.7s   4096 32.7-33.8s
  480 KB whole     2048 175.6s       4096 161.6s
with the same spans either way. On Metal 2048 was ~6% slower already
(7279bdc28's own numbers). So no pf-serve gets a PF_MOE_CHUNK from
magpie now; one the user set is still inherited through os.Environ,
as before.

moeChunk and vulkanMoEChunk are gone. TestVulkanServeGetsMoEChunk is
now TestServeKeepsMoEChunkUnlessUserSets: pf-serve-vulkan sees no
PF_MOE_CHUNK, and a user's 3072 reaches both.
docs/subsystems/gateway-routing.md says the same.

Run at this head (on 90258cf20):
- gofmt -l internal/pii: clean
- go vet -tags nogui ./internal/pii/ for GOOS linux, windows, darwin: ok
- go test -timeout 45m ./internal/pii/: ok (25.2s)
- Broken by hand: with HEAD's serve.go and the new test,
  TestServeKeepsMoEChunkUnlessUserSets/vulkan fails ("moechunk
  pf-serve-vulkan 2048", want no value); green with this serve.go.

Not tried: a Vulkan GPU here (none on this machine); the numbers above
are the reporter's, from their RX 470. Other GPUs aren't measured;
PF_MOE_CHUNK stays the override for one where 2048 is faster.
2026-10-28 00:50:09 +08:00
ggbdpq 90258cf20a agent: a Codex in a WSL distro stands in for a model it names from its own config.toml (#2198)
StandIn("codex", …) read this machine's ~/.codex/config.toml alone, so a
Codex wired in a WSL distro (model_provider = "magpie", the only shape a
distro under NAT is wired in since #2145) naming a model magpie doesn't
serve (codex -m <unserved>) was answered 404, where this machine's Codex
goes to its config's model and a Claude Code in the same distro goes to
the stand-in its settings name (wslClaudeStandIn, #254). On Windows, when
this machine's Codex names none, StandIn now asks wslCodexStandIn: the
first distro running now whose config.toml has magpie as its provider,
read as codexStandIn reads it. The collecting of running distros the
probe found a kind in is shared with wslClaudeStandIn (wslReady); a
stopped distro is never opened. Off Windows nothing changes.

Reported with a patch by ggbdpq (gua2100 on Discord), independently
re-run by Edward4226. Taken as written except: the distro's config path
comes from the place's codexHome (where magpie writes it) rather than a
spelled-out ~/.codex; wslClaudeClassifier, which landed since with the
same loop, is left as it is (no test covers it); and TestWSLCodexStandIn
now also calls StandIn itself, so the Windows-only wiring is tested.

Run (sandbox HOME, caches pinned):
- go test -tags nogui -run 'TestWSLCodexStandIn|TestWSLClaude|TestCodexStandIn|TestClaudeStandIn' ./internal/agent: ok.
- Broken by hand: wslCodexStandIn returning "" fails TestWSLCodexStandIn
  ("stand-in: \"\""); wslReady without the running filter fails
  TestWSLCodexStandInSkipsStopped ("stand-in from a stopped distro:
  \"stopped/model\""). Restored: ok.
- On the Windows box (agent test binary built GOOS=windows): the same
  five tests pass; built with StandIn's codex branch put back,
  TestWSLCodexStandIn fails "StandIn on windows: \"\", want \"relay/main\"".
- go test -tags nogui -run 'WSL|StandIn|Wsl' ./internal/agent: one red,
  TestWSLColdPlaceOpensNothing (Hermes profiles of a stopped distro),
  red the same at origin/main 7f0f71a0e and filed as #3924.
- gofmt -l clean; go vet darwin, GOOS=windows, GOOS=linux -tags nogui on
  ./internal/agent: clean.

Not tried: a real Codex in a real WSL distro naming an unserved model
(the distros are fakes, on the Windows box too); a Windows Codex wired to
another model still wins over the distro's, as for Claude Code; the full
./... suite (one suite per machine, others running).
2026-10-28 00:47:44 +08:00
yetoneandggbdpq 7f0f71a0ef gateway: a refused or empty-failed Codex relay's call carries its route (#2481)
The Routing page's "Request and response" finds a request's call by its
route (RouteCall). Of codexUpstreamOn's three record exits only the
success one set Call.Route, so a turn whose API key OpenAI refused (401)
or that the backend failed with nothing said opened as "the request is
gone" though its call was one of the last 40. Both failure exits now
carry the route through routeOf, which is 0 for a compaction: both exits
are reached by /responses/compact too, where no route opens.

Reported with a patch by ggbdpq (gua2100 on Discord). The patch set
Route: tr.ID unguarded on the empty-failure exit; since the
outrageous_piglet change that exit also takes a compaction, where tr is
nil, so that line panics on a compaction failed with an empty body.
routeOf guards both exits. gui-shell.md says which Codex exits carry
the route.

Run (sandbox HOME, caches pinned):
- TestCodexKeyRefusedCarriesItsRoute, TestCodexEmptyFailureCarriesItsRoute
  (ggbdpq's, the asserts moved into routeHasItsCall) and the new
  TestCodexCompactEmptyFailureRecordsNoRoute: ok.
- Broken by hand: with both exits back to no Route, the first two fail
  "route N: no call in the ring, so Request and response says the
  request is gone"; with the patch's unguarded tr.ID on the empty exit,
  the compaction test panics (nil pointer dereference). Restored: ok.
- go test -tags nogui -run 'TestCodex|TestRouting|TestArchive|TestRouteCall'
  ./internal/gateway: ok (31s).
- gofmt -l clean; go vet darwin, GOOS=windows, GOOS=linux -tags nogui on
  ./internal/gateway: clean.

Not tried: a real OpenAI 401 or a real empty ChatGPT backend failure
(fake upstreams); the GUI's routing-bodies test (the GUI is unchanged);
the full ./... suite (one suite per machine, others running).

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-28 00:41:37 +08:00
yetone 84ef22dd3b gateway: another magpie's rate-limited model sinks alone, not the whole remote (#2167)
restAfterMarked sank a rate-limited candidate by its rest key, so one
of a remote magpie's models answering 429 with quota left sent the
remote's other models, never limited, to the back of every Sink order
too, while the rest itself was the model's alone (remoteModelRest).
The sink now keeps the rest's scope: such a model sinks by restID, and
sunkAt reads a candidate's restID before its restKey.

Patch by ggbdpq (#2167): the routing.go change and
TestRemoteMagpieRateLimitSinksTheModel are theirs. Changed from it:
- their sunkAt read restID only for the Remote Magpie preset, while
  remoteModelRest also holds for a magpie added by hand as a plain
  endpoint (its reply names the provider, answeredThereHeader,
  4e5b2ad81). Such a model sank under restID and was then never found,
  so it sank nowhere. sunkAt now reads restID for every candidate.
- UnrestAll lifts a key's rest and each of its models' but unsank only
  the key, so a model sunk alone stayed at the back after Try now.
  It calls unsinkAll (the key and key/…).
Doc: the Sink row in gateway-routing.md.

Run (rebased on origin/main):
- TestRemoteMagpieRateLimitSinksTheModel: red on origin/main's
  routing.go and sink.go ("the remote was asked [], other [ko]"),
  green now.
- TestMagpieAddedByHandRateLimitSinksTheModel (new): red on main (kimi
  sank with glm), red with the patch's preset-only sunkAt put back by
  hand ("glm didn't sink ... the remote was asked [glm/glm-5]"), green
  now.
- TestUnrestAllUnsinksTheModels (new): red with UnrestAll calling
  unsink(key) ("office/glm/glm-5 still sunk"), green now.
- Sink|Sunk|Unrest|TryNow|RemoteMagpie|AnotherMagpie ok; the whole
  internal/gateway package (-tags nogui -count=1 -timeout 45m) ok in 502s
  at 56ea00d9c.
- gofmt -l clean; go vet ./internal/gateway for darwin, GOOS=windows,
  GOOS=linux -tags nogui clean.
Not tried: two real magpies with Sink on and a real vendor 429.
2026-10-28 00:37:04 +08:00
yetone b10f43e899 gateway: another magpie's key limit rests that magpie whole when relayed, and its marker stays here (#2791)
restAfterMarked reads a failed try's held header, which keepRetry
fills from the upstream's reply. keepRetry kept Retry-After and the
rate-limit reset headers but not X-Magpie-Limit-Reset
(remoteKeyLimitHeader), so a remote magpie's gateway key over its own
limit read as that one model's rate limit (remoteModelRest): the model
rested alone and the remote's other models were asked into the same
refusal.

Patch by ggbdpq (#2791): their test and the cause are theirs. Changed
from it: the patch whitelisted the raw marker into the held header,
and holdWriter passes that header on to the client, so the marker
reached the agent and, in a chain, a magpie asking this one, which
would rest all of this magpie for one key there. keepRetry now sets
an internal note (keyLimitThereHeader) that remoteModelRest reads and
holdWriter drops, with answeredThereHeader. The two keepRetry sites
that write to the client directly (count_tokens, decide_group) go
through keepRetryOut, which drops both notes; answeredThereHeader
leaked there before too. Doc sentence in gateway-routing.md.

Run (rebased on origin/main):
- TestRemoteMagpieKeyLimitRestsTheRemote (theirs): red with the note
  taken out of keepRetry by hand (rested office/glm/glm-5 and kimi, not
  office), green now.
- TestRemoteMagpieKeyLimitMarkerStaysHere (new): red with the patch's
  raw marker copy ("the agent's reply carries X-Magpie-Limit-Reset"),
  and red with keyLimitThereHeader taken out of pass()'s strip list
  ("carries X-Magpie-Key-Limit-There"), green now.
- RemoteMagpie|AnotherMagpie|KeyLimit ok; the whole internal/gateway
  package (-tags nogui -count=1 -timeout 45m) ok in 476s at fc860f2e6.
- gofmt -l clean; go vet ./internal/gateway for darwin, GOOS=windows,
  GOOS=linux -tags nogui clean.
Not tried: two real magpies over a network with a key limit hit.
2026-10-28 00:27:02 +08:00
yetone 791e27ec34 agent: the Codex app's Restart restarts only its app-server, its window stays
yoshi037070 (Discord, 10-27): when magpie restarted Codex, a new Codex
window opened. The switch paths (Connect, Disconnect, failover) already end
only the app's own app-server (codexAppStep, proc.End: SIGTERM on macOS,
exit 0 on Windows), and the app starts another and keeps its window. The
Agents row's Restart beside a Codex app left on the old list did not: on
macOS ReopenCodexApp ran osascript "quit" and then `open` on the bundle,
and that open is what brought up a new window.

Now ReopenCodexApp keeps its check (only a bundle the row lists as left on
the old list) and calls provider.RestartCodexApp, which ends each process
whose command line starts with <bundle>/Contents/ and is the app's own
app-server (isCodexAppOwnServer: an app-server, not --listen), waits up to
10s for them to be gone, and errs when none ran. The app, its window and
another program's --listen server are left alone. The confirm says only the
app-server restarts and the window stays; the status says "Codex app-server
restarted" (zh, zh-TW, ja, de). app.js stays under its budget, with no raise (1,310,458 of 1,310,460
after rebasing on 97332140a): the "asked first" comment went and
appReopen's shrank. The
agent-wiring page says the same.

The model picker: the app's restart recovery doesn't refetch its models
query; it refetches on the next window focus once the list is over 5
minutes old (staleTime), or when the picker is mounted again.

Run (rebased on origin/main, at this commit's tree):
- go test ./internal/agent: ok (280s).
- go test ./internal/provider -run 'Codex|Restart': ok. Before the rebase,
  the whole package with -skip TestUnreadLoginsWriteErrorsKeepCredentials
  (#3632 crashes the binary) was ok except TestFetchAsksASharedBaseOnce and
  its two siblings (#3854).
- go test ./internal/gui -run TestCoreScriptBudget: ok.
- GUI: agent-stale-copies in chromium and webkit, 5 languages, 980/440px:
  80 pass. i18n-keys: its only red is #3897 ("Runs as"). Before the
  rebase codex-app-stale passed too.
- gofmt -l clean; go vet darwin and windows for agent, provider, gui;
  linux for agent and provider (gui's linux vet needs wails' cgo here).
- Real app: a clone of ChatGPT.app 26.1021.31345 (APFS clone in a sandbox
  HOME, so the bundle is unique to it) run under that HOME. The real
  RestartCodexApp ended its app-server 32922 in 3.1s; the same main
  process (31894) started app-server 34143, and its one window (2273016)
  stayed the only window. The user's own ChatGPT was untouched.

Broken by hand:
- reopenApp back to appQuit + appOpen: TestCodexAppReopen red ("did quit
  …, open …").
- isCodexAppServer in place of isCodexAppOwnServer: TestRestartCodexApp…
  red (ended [2 3], the --listen one too).
- the bundle prefix dropped: red (ended [2 4], another bundle's).

Not tried: the picker refreshing in a signed-in app (the sandbox app isn't
signed in); Windows has no such Restart (the row's Restart for the Codex
app is macOS only; Windows switches already end codex.exe with exit 0 and
the app keeps its window, 3aead9c62).
2026-10-28 00:20:30 +08:00
yetone 34d38ed669 hermes: each profile picks its own model on the Agents page
dongshanfengdongshizhcn on Discord: "我的 hermes 有多个 profile,但现在
agent 的配置里面,似乎只能配置默认的 profile". magpie gave Hermes one model
picker, for the connected profile's config.yaml. A bot under
<root>/profiles/<name> could only follow it or keep its own model.

Hermes's layout comes from its own source (hermes-agent e5ea5fd9,
hermes_cli/profiles.py and main.py): named profiles live in
<root>/profiles/<name> (PROFILE_ID_RE, a .deleted tombstone, the identity
files), active_profile is the sticky one, "default" is the root, and a
profile's model is model.default/model.model under model.provider. magpie
already found these profiles (hermesProfiles/hermesOthers).

Now each profile other than the connected one has a field,
"profile:<name>" (hermesProfileFields). The opened Hermes row draws them as
Other profiles, one line per profile: its name, the app's model picker, and
`hermes -p <name>`. They are never a square of the row's own, and with one
profile only nothing new shows. Nothing needs setting up:
- a magpie model stashes the profile's own provider and model, then puts
  magpie's provider and the model into that profile only;
- a model of its own is written as model.default and gives back the stashed
  provider;
- Default puts back the profile's model from before magpie, or keeps the one
  it has. Disconnect sends the same empty value, so a profile never loses
  its model;
- a bot picked there is recorded (hermes:<path>:picked) and doesn't follow
  the connected config's next model (hermesFollow);
- a sync keeps magpie's provider current in a bot on magpie while the
  connected config isn't on it.
app.js stays under its budget through the previous commit; no budget was
raised. New string: "Other profiles" (zh, zh-TW, ja, de).

Run:
- go test ./internal/agent ./internal/gui ./internal/profile ./internal/tui
  ./internal/cli (-count=1). gui, profile and cli are ok. Two reds were already
  filed: TestFolderVarsAreListed (CARGO_HOME, fixed on main by 3116b8f58,
  which this is rebased on) and TestTUIFetchesSubscriptionModels/agent
  (#3919). Neither touches Hermes.
- TestHermes* ok after the rebase. gofmt -l is clean. go vet and GOOS=windows
  go vet pass on agent, gui and profile. GOOS=linux go vet passes on agent and
  profile; gui needs cgo for wails and doesn't cross-vet from macOS.
- GUI: new hermes-profiles.test.cjs (en, zh, zh-TW, ja, de; 1100px and 560px;
  chromium and webkit; 20/20) plus i18n-keys, claude-auto-mode,
  claude-subagents-pick, claude-subagent-effort-row, tier-effort,
  click-scroll, every agent-*.test.cjs, and the previous commit's Settings
  files: 899 of 900. The one red is the known #3897.

Broken by hand:
- origin/main's hermes.go fails TestHermesProfileModels ("pickers []").
- Without the picked guard in hermesFollow, coder followed main to
  deepseek/max.
- With Default deleting model.default, writer lost gpt-5.5.
- With the sync of bots on magpie turned off, writer's provider lacked a new
  model.
- origin/main's app.js fails hermes-profiles.test.cjs 10 of 10 in chromium.

Not tried: a real Hermes. By rule it isn't run under a sandbox
HERMES_HOME, since that rewrites the live ~/.hermes launcher. The layout was
read from Hermes's source, and the configs were written as its
_seed_model_config does. profile.yaml's display_name is not used; the line
shows the folder name, which is what `hermes -p` takes.
2026-10-28 00:17:40 +08:00
yetone fff05e55d8 gateway: Codex's compaction trigger is summarised, not refused, when no key that lists the model can carry it (#2725)
nativeCompactionFor kept Codex's compaction_trigger whenever the
provider asked had native compaction on and could be asked it on
Responses. When the vendor's lists held the model to a key that speaks
no Responses there (a key set to Chat), compactionCarriers then cleared
every candidate and Codex got 400 carrierError, with no upstream asked:
the dead end #2725 reports. The trigger is now kept only when a key or
account the request would go over (the provider's and its fallbacks',
or a group's members', held and capped ones too, not one whose own
list lacks the model) carries it (plannedCarrier). Otherwise
codexCompact gives magpie's summary through the listed key, as with
native compaction off.

Patch by ggbdpq (#2725): route (a) and both tests are theirs. Changed
from it: their planCarries ran s.plan / s.planGroup, which weighs the
keys, and a provider routed in turn moves its turn along there
(routes.Rotate). nativeCompactionFor runs on every Codex turn (handle,
codexBackend), so each decision would have skipped a key. plannedCarrier
reads perKeyBarred without weighing. Doc sentence in
docs/subsystems/gateway-routing.md.

Run (worktree at e54a7d50b):
- TestNativeCompactionTriggerSummarisedWhenNoListedKeyCarriesIt: red
  on the old native_compaction.go ("400, the relay asked 0 times ...
  none of the keys or accounts that serve fake/m1 now can be asked it
  on the Responses"), green now.
  TestNativeCompactionTriggerThroughTheListedKeyThatCarriesIt green.
- TestNativeCompactionDecisionLeavesTheTurnsAlone (new, three keys,
  Rotate): red with the patch's planCarries ("a turn began at k2, the
  next at k1"), green with plannedCarrier.
- -race -count=3 on those three; NativeCompaction|Compact|Checkpoint|
  CodexBackend ok; the whole internal/gateway package
  (-tags nogui -count=1 -timeout 45m) ok in 609s.
- gofmt -l clean; go vet ./internal/gateway for darwin, GOOS=windows,
  GOOS=linux -tags nogui clean.
Not tried: a real relay whose vendor lists a model to a Chat-only key.
2026-10-28 00:16:48 +08:00
yetone d83f887a74 gateway: a 429 per minute that calls itself a quota rests as a rate limit
monater.114514 on Discord: an upstream's TPM 429 was read as out of
quota, and the key rested 15 minutes with balance left.

Cause: failure() read a 429 with rate words as a rate limit only when
plannedWords didn't match, and plannedWords matches the bare word
"quota". Vendors word per-minute limits as quotas: Gemini's "You
exceeded your current quota ... quotaId ...PerMinute", Vertex's "Quota
exceeded for ...requests_per_minute...", Azure's token rate limit whose
link is aka.ms/oai/quotaincrease. Each became failQuota and quotaRest
(15m) when no Retry-After came with it. DashScope (help.aliyun.com
error-code list) words its TPM/TPS limit "Allocated quota exceeded,
please increase your quota limit." and, in OpenAI's shape,
insufficient_quota, which read as quota and credit (30m).

Fix: minuteLimit: a 429 naming a minute-or-less window (per minute,
per second, TPM/RPM, PerMinute, token/call rate limit) and no longer
window, plan limit or money spent is failRate (a minute, or the
vendor's Retry-After / x-ratelimit-reset, via rateRest). Words in a
link no longer turn a rate limit into a plan used up. DashScope's two
TPM wordings are failRate from a DashScope provider only (failureOf);
its "Free allocated quota exceeded." and Coding Plan hour/week/month
stay quota, OpenAI's insufficient_quota stays credit, Zhipu 1113 stays
credit, per-day limits (TPD, PerDay, free-models-per-day) stay quota.

Run at this head: go test ./internal/gateway -count=1 -timeout 45m ok
(550s); new tests TestMinuteLimitIsNotQuota, TestMinuteLimitRestsAMinute,
TestDashScopeAllocationQuotaIsRate with literal vendor bodies; gofmt -l
clean; go vet, GOOS=windows and GOOS=linux go vet ./internal/gateway ok.
Broken by hand: routing.go put back to origin/main (dashScopeRate
stubbed false): all three new tests red, the Vertex 429 rested
14m59s as quota with no header, and as quota (not rate) with
Retry-After 20 or x-ratelimit-reset-tokens 45s.
Not tried: a real vendor 429 (the reporter's upstream and body are not
known yet); the full ./... suite (one suite per machine).
2026-10-27 23:49:33 +08:00
yetone 2b0387574e draw: an OpenAI-compatible plugin's image models draw (SenseNova's sensenova-u1.5-lite)
01huadalang (Discord, #feedback): SenseNova's sensenova-u1.5-lite can
draw, but magpie's image generation picker doesn't list it.
ab546a4ee (v0.1.1707) covered SenseNova added as a key provider. The
SenseNova plugin (aqiu817/magpie-sensenova, @ai-sdk/openai-compatible at
token.sensenova.cn/v1) lists the model from SenseNova's /models too, but
Drawers returned nothing for any plugin provider (p.Account != nil), so
neither the picker nor generate_image could reach it there.

- provider.PluginOpenAICompatible: the plugin speaks the model on
  @ai-sdk/openai-compatible.
- Drawers: a plugin provider's listed model that DrawsID and ImagesAPI
  and is spoken on openai-compatible is a drawer; drawImages sends it to
  /images/generations or /images/edits under the plugin's base, through
  its fetch (pluginFetch maps /v1/... onto the loader's base), in the
  shape ab546a4ee sends SenseNova (b64_json, JSON edits). An image model
  on another package (a vendor's own API) is not listed. Grok's and
  WorkBuddy's drawers are unchanged (checked before this branch).
- Fake plugin: $FAKE_SENSENOVA adds sensenova-u1.5-lite and a flux-2 on
  @ai-sdk/anthropic.
- docs/subsystems/provider-plugins.md says it.

Test: TestSenseNovaPluginDraws (internal/gateway) installs the fake
plugin as "sensenova" in a real Bun host in front of the fake SenseNova
of TestSenseNovaU1Draws: Drawers lists sensenova-u1.5-lite alone, a
generation and an edit come back through the plugin (b64, JSON images,
chat never asked). Broken by hand: without the plugin branch it is red
(drawers []); without the openai-compatible check it is red (drawers
[sensenova-u1.5-lite flux-2]).

Run at this head: gofmt -l, go vet, GOOS=windows go vet, GOOS=linux go
vet -tags nogui on internal/gateway and internal/provider (clean); go
test -tags nogui -timeout 45m ./internal/gateway ./internal/provider
./internal/plugin ./internal/catalog: gateway (716s), plugin, catalog
ok; provider crashes in TestUnreadLoginsWriteErrorsKeepCredentials
(#3632, open), and with it skipped fails TestFetchAsksASharedBaseOnce,
TestFetchAsksOneListOnceForTwoBasesOfIt and
TestFetchUnionsProtocolListsWithoutChat, red the same at the base
a47596ea6 without this change (#3854, open). Neither touched here.
After the rebase onto origin/main b103ed058: gofmt, vet (three OSes),
internal/gateway -run 'SenseNova|Draw|Image|Edit|GrokPlugin|Plugin',
internal/catalog, internal/provider -run Plugin: ok.

Not tried: a real SenseNova account or the real plugin (none here); the
images API shape is from SenseTime's launch post as ab546a4ee read it.
Not run: the full ./... suite and the GUI suite (no GUI file changed).

Reported by 01huadalang (Discord).
2026-10-27 23:45:57 +08:00
yetone 24fab123bb provider, gateway: a Remote magpie's model it offers Fast on can be picked fast
littlekk88 on Discord (#feedback): Claude Code on one computer, wired to
its magpie, which has another magpie as a Remote magpie. The remote's
/v1/models listed service_tiers [{id:"priority",name:"Fast"}] on
gateway/cursor/grok-4.6 (#1234), but the local picker showed no bolt on
it, SetFastPick refused it, and tier_sent was empty on both computers.

Two causes, both on the local magpie:
- provider.CanFast had no case for a Remote magpie, so it was false for
  every remote model. It now reads the tiers the remote's list gives the
  model (new provider.RemoteTiers) and is true where they hold priority.
  UltraOn offers Ultrafast where they also hold ultrafast. The picker,
  SetFastPick, routing groups and Codex's catalog all go through CanFast.
- A fast pick from an agent on Anthropic's Messages API carries Claude's
  speed "fast". Translated to the remote's Chat Completions or Responses,
  nothing turned that into service_tier. forwardTranslated now sets the
  tier the remote offers (priority, or ultrafast for an Ultrafast pick
  where offered) when the request is fast and names no tier. A request
  that names a tier is sent as before.
The remote side already serves a Chat request's service_tier priority to
Codex and to the Cursor plugin (TestChatFastTier,
TestPluginServiceTierReachesFetch), so a remote on an older version works
once the local magpie is updated.

Docs: the remote magpie service tiers row in
docs/subsystems/providers-accounts.md.

Run at this tree (rebased on origin/main):
- New TestRemoteMagpieFastPick: two httptest servers (the remote gateway
  and a Chat-only vendor, as the report's native_endpoints). Claude Code
  on /v1/messages and a Chat client both reach the remote with priority,
  and the remote sends its vendor priority. A model offered no tier
  can't be picked, and another agent's request goes without a tier.
- go test ./internal/gateway -run 'Fast|Tier|RemoteMagpie|Remote': ok.
- go test ./internal/codexcat: ok.
- go test ./internal/provider, ./internal/agent, ./internal/gui: the only
  reds are already filed and unrelated to this change:
  - #3632: the synctest crash in TestUnreadLoginsWriteErrorsKeepCredentials.
    Skipped on the rerun; everything else in provider passes except the
    three below.
  - #3854: TestFetchAsksOneListOnceForTwoBasesOfIt,
    TestFetchUnionsProtocolListsWithoutChat and TestFetchAsksASharedBaseOnce.
    Also red 3 of 3 at a fresh origin/main 6c063ac1b without this change.
  - #3884: TestFolderVarsAreListed (gui).
  - #3451: TestRestartHandsTheGatewayOver (agent).
- gofmt -l and go vet (darwin, linux, windows) on provider and gateway:
  clean.

Broken by hand: CanFast's remote case returning false turns the new test
red (SetFastPick refused, CanFast false). Turning off the
forwardTranslated block turns it red for /v1/messages (the remote got no
service_tier).

Not tried: a real Cursor or Codex account behind a real second magpie,
and the picker's bolt in a browser. GUI tests were not run, since no
GUI file changed.
2026-10-27 23:35:08 +08:00
yetone 67b12956ac sessions: a Codex rollout magpie rewrites keeps every line where it was
xybio (Discord #feedback): the Codex app often wouldn't reopen recent
threads: "invalid paginated history lineage for <id>: cutoff byte offset
is past the source rollout". Codex 0.162 keeps a fork's place in its
parent by byte (session_meta.history_base.end_byte_offset, checked by
rollout_lineage.rs validate_cutoff_bounds), and its state database keeps
turns and how far it has read by byte too. PortCodexRollouts (since
4896fc3ba, 10-21) wrote magpie's compaction item as Codex's summary
message, and since 79c8667c9 dropped Claude's sealed reasoning: both
shorter lines, so a parent shrank and every fork made before the pass
named a byte past its end.

Now every rewritten line keeps its length (fitLine): a shorter one is
padded with spaces after its JSON, which serde_json skips; a longer one
(a short summary under Codex's prefix) is left as it was in a paginated
rollout, and written as before in a legacy one, where Codex keeps no
place by byte. MoveCodexProvider, the sibling that rewrites session_meta,
pads the same way and refuses a longer provider id for a paginated
rollout. Forks already broken are repaired once per Codex home
(repairLineages): every line kept its count, and Codex names each line's
ordinal, so a fork's end_byte_offset is set again to where its parent's
line end_ordinal_exclusive-1 ends now, in a first line kept as long.

Run, at a47596ea6 plus this change:
- go test -count=1 ./internal/sessions/ ./internal/codexsummary/: ok;
  ./internal/agent/ -run 'Codex|Port|Move|Session': ok.
- gofmt -l internal/ clean; go vet ./internal/sessions/ ./internal/agent/,
  GOOS=windows and GOOS=linux go vet ./internal/sessions/: clean.
- Real, Codex 0.162.1 in a sandbox CODEX_HOME against a local mock
  Responses server that returns a magpie-claude1: reasoning item: codex
  exec made a paginated thread (50877 bytes), app-server thread/fork
  forked it, then a port pass. Old code: the parent went to 70570 bytes
  from 82912 and thread/resume and thread/read of the fork gave the
  reporter's exact error. New code: the parent kept 82912 bytes with no
  magpie-claude1: left, the fork resumed and read, the parent resumed,
  and codex exec resume ran a turn on the fork. A new-code pass over the
  old-code home repaired the fork (82912 -> 70570 in its history_base),
  after which it resumed and read.

Broken by hand:
- fitLine returning the rewrite as it is:
  TestPortCodexRolloutsKeepsBytePlaces red ("lines end at [... 11329],
  were at [... 14362]", the fork's offset past the end),
  TestPortCodexRolloutsLongerLine and TestMoveCodexProviderKeepsBytePlaces
  red.
- repairLineages a no-op: TestPortCodexRolloutsRepairsForks red.

Not tried: the Codex desktop app itself (the app-server it runs was);
a .zst parent against real Codex (the Go tests cover zst ports); Codex in
WSL, which the pass skips as before. The state database's turn offsets
for a parent already shrunk are left as they are; Codex 0.162.1 resumed
and forked such a parent in the sandbox.
2026-10-27 23:33:26 +08:00
yetone a47596ea61 privacy: AstrLink Guard is the default local model; its menu stands apart from the switch
Settings > Privacy's "Find with a local model" row put the model menu 2px
from the Off/On switch (.prefs .val's gap): two bordered boxes touching.
The row's .val now has an 8px gap.

With no model picked, pii.Choose is AstrLink Guard. Before, it was Privacy
Filter whenever the model was on or Privacy Filter was on disk. Now
Privacy Filter is chosen only while the model is on, Privacy Filter is
downloaded and AstrLink Guard isn't, so a request isn't held back. In
that case masking.picked starts AstrLink Guard's 38 MB download
(toGuard, tried again an hour after a failure). Once it is on disk,
AstrLink Guard is saved as the pick, unless the user picked a model in
between, and Privacy Filter is let go.

Existing users:
- Privacy Filter on with no pick: moved to AstrLink Guard after the
  download. Privacy Filter stays on disk and can be picked again.
- Privacy Filter explicitly picked: unchanged.
- Model off: the menu now shows AstrLink Guard.

Run at this tree, on origin/main:
- go test ./internal/pii ./internal/masking: ok. TestChoose is updated,
  with Privacy Filter on disk both off (Guard) and on (PF).
- go test ./internal/gui -run 'Budget|I18n': ok.
- privacy-model.test.cjs, chromium + webkit, every language, 1100/640:
  64/64. The new gap check fails with the CSS line removed (gap 2).
- gofmt, vet (darwin, linux nogui, windows), linux and windows builds:
  ok.

Not tried: toGuard's real download and switch-over. It needs the
network, and no test covers it.
2026-10-27 23:18:24 +08:00
yetone df8e9de3f1 redact: a masked word that is a date matches that date however it is written
JackyCcao on X turned birthday masking off (old dates in logs and tasks
after a birthday's word were still taken) and put their own birthday in
Masked words instead. A word matched only as typed, so 1990-05-12 let
1990/5/12, 1990.05.12, 1990年5月12日 and 19900512 go as written.

A masked word that is all of a date (dateword.go: year-month-day with
- / . 、 or a space, 年月日 or 년월일, a month's English name, or
day/month/year where only one reading is a date) now matches that
calendar date in each of those forms, with or without leading zeros,
as eight digits, and day-first or month-first only where the day is
over 12 or equals the month: for 1990-05-12 neither 05/12/1990 nor
12/05/1990, which reads as December 5th too. A word like 05/12/1990
is no date and matches only as written. Eight digits alone are not
taken for a date word (as likely an id) and match as before. A date
match never has a digit, or a dot and a digit, beside it, whatever
Whole words only says, so 1990.5.12.1, 3.1990.5.12 and 11990-05-12
are no match; this is a change for a date word without Whole words,
which matched inside such numbers before.

The birthday rule is not changed. It takes a date only right after a
birthday's word (生日, DOB, born...), so a log line's, a file name's
or a task's own date is never one, however old. What is left (生日:
2019-03-02 in a task log about a party) has the same shape as a real
date of birth, and a time beside the date doesn't tell them apart: a
date of birth stored as a time (1990-05-11T16:00:00.000Z, midnight in
UTC+8, as JavaScript writes it) is the commonest way one reaches an
agent in JSON. TestBirthdayLogDates pins both sides; #3878 tracks
fixed-shape false alarms.

Tests: TestDateWordEveryForm (22 forms x 5 words x 6 contexts, each
restored as written), TestDateWordDayMonthOrder, TestDateWordNotAnotherDate
(another date, 1990.5.12.1, longer numbers), TestDateWordOnlyADate.
Broken by hand: with the dateSpans hook in mask turned off, EveryForm,
DayMonthOrder and NotAnotherDate fail; OnlyADate and BirthdayLogDates
pin behaviour that was already right and pass on both.

Docs: gateway-routing.md, masking.html en/zh/ja.

Run on origin/main 94c2aaecb, sandbox HOME and GOCACHE, then rebased
onto 841bcf8da (its changes are in usage and gateway/history.go, none
in redact) and the vet and the four packages run again there; on e056779a6
(a GUI change, nothing in redact) redact, masking and settings again:
- gofmt -l clean; go vet clean on macOS, GOOS=linux -tags nogui and
  GOOS=windows (internal/redact).
- go test -count=1 ./internal/redact/... ./internal/masking/...
  ./internal/pii/... ./internal/settings/...: ok. The date tests also
  with TZ=UTC and TZ=Pacific/Kiritimati: ok.
- go test -count=1 -timeout 100m ./internal/gateway (at 94c2aaecb):
  every test ok
  but TestPluginToldWhereTheAgentWorks, which failed only because the
  run's TMPDIR was inside this git worktree (its "not in a repo"
  folder was in one, git "yes"). Run alone with TMPDIR outside the
  repo it is ok; with TMPDIR inside it fails at this head too.
Not run: the full ./... suite (another session's full suite holds the
machine, load ~100-140). No GUI asset changed, so no GUI run.
2026-10-27 22:44:52 +08:00
yetone e056779a67 gui: the app serves its page to a browser, behind its key (Settings › Browser access)
jiakun_zhao on X ran `magpie web` in a terminal beside the desktop app,
to manage it through a Cloudflare tunnel. Settings › Network and sharing ›
Browser access now has the app serve the same page itself: Off, This
computer (127.0.0.1, for a tunnel or SSH forward) or Local network.

Access is magpie web's, unchanged: the key in the link is traded for the
cookie (webGuard), the allow list holds, and the gateway's client routes
on the page's port need a gateway key (onePort). A rebound Host and
Origin: null get no cookie. There is no way to serve it without the key.
The key and choice live in web-page.json (0600) beside settings.json, so
a sync never carries them. GET/POST /api/web-page are the app windows'
alone: a browser on the page can't read the key or turn the page off. A
busy port (magpie web, the magpie before an update) is tried every 4s;
`magpie web` on the same port opens the app's link instead.

Run at d43b7c40d (this change on ef155a5ca), then rebased onto the four
newer main commits, which touch gateway, usage, proc and library only:
- gofmt -l internal/gui internal/cli: nothing. go vet, GOOS=linux go vet
  -tags nogui and GOOS=windows go vet of internal/gui and internal/cli:
  clean. go build: ok.
- go test -timeout 45m ./internal/gui/ ./internal/cli/: ok (180s, 70s).
- GUI, alone: browser-access.test.cjs and model-test-one.test.cjs pass in
  both engines; i18n-keys 23 of 24, its red is #3897 ("Runs as" from
  7f827b3b0), not this change. agent-stale-copies.test.cjs 80 of 80 at
  8d343a811 (this change before the rebase).
- Full GUI suite at 8d343a811: cut short. The disk filled (708MB free):
  browsers failed to launch with ENOSPC in agent-stale-copies, which then
  passed 80 of 80 alone, and node ended with exit 7 before the rest of
  the files ran. There is no full GUI record for this change.

Not tried: a real Cloudflare tunnel to the page, and Local network from
another machine.
2026-10-27 18:58:16 +08:00
yetone 28f3c4d7fd codex: the Codex app's first 100 models hold the ones used, hidden ones last
@ZhenLuoTTAWDTT on X: with Codex on magpie the model list stops short,
and the models past it can't be chosen.

Cause, from the clients' own code: the Codex app (ChatGPT.app
26.1013.40934, app-initial-90eb42395b7d.js) and the VS Code extension
(openai.chatgpt 26.51021.22027, model-queries-667cf4bd657d.js) both ask
their app-server for model/list with includeHidden, cursor null and
limit 100 (e?.limit??100) and never ask for nextCursor. codex-rs's
list_models pages the list sorted by priority, hidden entries counted,
so anything past the 100th is in no picker there. The CLI's /model
(tui model_popups.rs) lists every preset in a scrolling popup and has no
cap. magpie truncated nothing; its models are numbered after the
account's own, so a user with many models lost everything past ~100 in
the app, while hidden entries (codex-auto-review and the like) took
slots at the top.

Fix: codexcat.Fit ranks the list last of all, on every route magpie
hands Codex a list (/backend-api/codex/models after the user's own
order, /v1/codex/models before its 1 MiB cut, and the
model_catalog_json file via CatalogUsed): hidden entries go after every
listed one, and with more than 100 listed, the models Codex used in the
last 30 days (usage.CodexUsed, most recent first, at most 100; on
/v1/codex/models only the asking key's, CodexUsedBy) are brought into
the first 100 in the order they stood. The rest keep their order. The
list's ETag and X-Models-Etag carry a tag of the used set
(codexcat.UsedTag), so Codex asks again when it uses a model it hadn't;
CodexUsed is read at most once a minute, or at once when Append writes a
Codex call to a model it doesn't hold. Documented in
docs/subsystems/gateway-routing.md.

Tests (each red on the old code, broken by hand: Fit a no-op, the gateway
calls and the used tag removed, Append's codexUsedNew removed):
TestFitKeepsUsedModelsWhereTheCodexAppReads, TestFitLeavesAShortListsOrder,
TestCatalogUsedFits, TestUsedTagIsTheSet (codexcat), TestCodexUsed
(usage), TestCodexModelListKeepsUsedModelsInTheAppsHundred and
TestCodexCatalogKeepsTheKeysUsedModelsFirst (gateway).

Real run: codex-cli 0.162.1's app-server in a sandbox CODEX_HOME (never
~/.codex) with a model_catalog_json of 3 hidden entries at priority 1-3
and 150 listed models, driven over stdio with the app's own request
(model/list includeHidden, limit 100). Before: page 1 held 100 of 153,
3 of them hidden, the last many/model-096, nextCursor "100". The same
catalog put through Fit with many/model-140 used: page 1 has no hidden
entry and ends with many/model-140. The TUI's /model scrolled to all
150 (tmux).

Run with this change on e4ca47b0f: gofmt -l clean; go vet
-tags nogui with GOOS=linux and GOOS=windows on codexcat, usage, gateway
and agent clean. go test -count=1 -timeout 45m: codexcat ok, usage ok;
-run 'Codex|Fit|Used|ModelList|Catalog' on gateway, usage and agent ok
(122s, 11s, 80s). The whole gateway and agent packages ran too, but the
machine's disk was full under other sessions' runs (209M to 2.5G free),
and 959 lines of that log are "no space left on device". Of the reds,
three are not that: TestFolderVarsAreListed is #3884 (CARGO_HOME, red on
main since e4552cca9); TestHistoryKeepsDaysAndDropsOld (gateway) and
TestSuffixModesReachAgentFiles (agent) failed beside half-written
settings files and pass alone 3 of 3 at this commit. Not run: the full
./... suite (no room on the disk); the Codex app and VS Code extension
themselves against a magpie with this change (their request was read
from their bundles and replayed against a real app-server).

Rebased on ca8a6f346 (agent rename and Codex app route, claude_runs in
gateway) and run again: GOOS=windows go vet on agent
and gateway clean; -run 'Codex|Fit|Used|ModelList|Catalog' ok on
codexcat, usage and gateway (75s), and with |Rename ok on agent (68s).
Then rebased on 94c2aaecb (usage rename) and usage run whole again: ok
(88s).
2026-10-27 18:37:16 +08:00
yetone 94c2aaecba usage: a deleted provider's tests stay listed under it, not its host (cybercaius)
cybercaius on Discord: one custom provider (example, on api.example.me)
was listed in the Requests page's provider filter under its id and its
host, and the host stayed after the provider was deleted.

The Add sheet's Detect, model-list and Test requests are sent before the
provider has an id, so probelog records them under the host asked
("a provider being added has no id yet"). 8e2ba36de (v0.1.1697, yyddbds)
lists those under the provider saved on that host now (Renames.ProbeOf),
but a deleted provider is on no host any more, so its probes went back
to the host beside the id its calls are kept under.

Now the log's index notes, as it reads each line, the provider each
host's calls went to (logSnapshot.hosts; "" once two providers were on
one host). probeProvider lists a probe recorded under its host by the
provider saved on that host, and with none there, by the one the log's
calls to that host were made under. A host two providers are or were
on, or none, stays the host, lowercased, so one typed in two cases is
listed once. It is done when the log is read, so rows written before
this release are merged too. Renames.OnHost tells "no provider on this
host" from "two providers on it", so a host shared now is never given
to a deleted one.

Not added: deleting a provider's usage rows. usage.jsonl is the record
budgets, windows and totals are read from, and probe rows are counted in
none of them; with them under one name there is nothing left to clean.

Run:
- go test -tags nogui ./internal/usage ./internal/usageapi
  ./internal/probelog: ok, at the pushed head (rebased on 56de2d192).
- ./internal/provider, skipping the reds open on main
  (TestUnreadLoginsWriteErrorsKeepCredentials #3632, TestFetchAsksASharedBaseOnce
  and its two siblings #3854): the disk was full from other sessions'
  temp files, and TestLoginUsageEachAccount failed on "no space left on
  device"; it and the Rename tests passed on a rerun.
- New TestProbesOfADeletedProviderStayWithIt: probes under
  api.example.me and API.example.me before provider.Add, a Test after,
  a gateway call with the provider's Where, and twice.example used by two
  providers; after provider.Delete the list is [example one
  twice.example two] and example's filter has its 4 rows.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.

Broken by hand: probeProvider without the log's hosts fails it with
"deleted: providers [API.example.me api.example.me example one
twice.example two]", the reporter's extra names.

Not tried: the reporter's own usage.jsonl; a host typed in the Add sheet
and changed before saving (its probes went to another host and stay
under it); the GUI suite (no GUI file changed; the filter lists what
QueryPage returns); the full go test ./... (disk full).
2026-10-27 18:32:44 +08:00
yetone ca8a6f346a agent: a renamed routing group moves its agents, and the Codex app reloads a changed catalog
lucis0116 on X: renaming a provider or a group in magpie didn't reach
every agent.

Display names already reached the agents' files: store and SaveGroup
drop the catalog, and SyncCatalog writes the new "<model> · <name>" and
"<group> · routing group" labels into Codex's model_catalog_json, Claude
Code's picker, OpenCode and Pi (checked in a sandbox HOME). Two gaps
were left:

- A routing group given another id (Routing page, `magpie groups
  rename`, TUI) left every agent on group/<old>, which magpie no longer
  has. The CLI even said "agents set to group/from need group/to now".
  agent.RenameGroup now moves each agent field on group/<old> to
  group/<new>, spelled as the agent spells it. It goes through
  renameRefs, the move RenameProvider already made, now shared by both,
  then SyncCatalog. The GUI, CLI and TUI call it in place of
  provider.RenameGroup.
- The Codex app's own app-server reads model_catalog_json only as it
  starts, and KeepCodexAppOnItsProvider restarts it only when
  codexAppRoute changes. The route named the catalog's path, not what
  the file holds, so a renamed provider or group, or a model added,
  stayed on the old list until the user quit the app. The route now
  carries a hash of the catalog's bytes (codexCatalogTag, read again
  only when the file's size or time changes). The restart goes through
  the existing idle gate: no Codex request in flight, 10s idle, no turn
  open. A write of the same bytes is no change.

Run, in a sandbox HOME only:
- TestRenameGroupMovesTheAgentsOnIt (new): Codex, Claude Code, OpenCode
  and Pi on group/smart, renamed to clever: each said moved and each
  file on group/clever, none naming group/smart.
- TestCodexAppRouteFollowsTheCatalog (new): the route changes when a
  renamed provider rewrites the catalog, and stays put when the same
  bytes are written again.
- Broken by hand: RenameGroup's match turned off makes the first test
  red (no agent moved, every file on group/smart). The catalog line
  dropped from codexAppRoute makes the second red ("a provider renamed
  left the Codex app's route as it was").
- At aded9beea (base ad3833512): go test -tags nogui -timeout 45m
  ./internal/agent ./internal/cli ./internal/gui ./internal/tui
  ./internal/provider -count=1: cli, gui and tui ok. agent red on
  TestFolderVarsAreListed (#3884, red on main since e4552cca9) and
  TestCodexDisconnectStaysWithAccountsOn/login=api, which passed 3 of 3
  alone and isn't on this path (filed #3891). provider crashed in
  TestUnreadLoginsWriteErrorsKeepCredentials with "close of synctest
  channel from outside bubble" in filememo.Forget (#3632, open on main).
- Rebased on 56de2d192 (a312bf3e3 adds a switched account's app-server
  to the same stale set; no overlap): go test -tags nogui -count=1
  ./internal/agent -run 'Rename|CodexApp|Sync|Group|Codex|Hermes' ok
  at this head; ./internal/provider -run
  'CodexApp|Group' ok at a312bf3e3 + this change. The disk was full (other sessions' suites), so the
  whole of each package wasn't run again at this head.
- GUI: group-id-dots, group-morph, agent-model-groups and i18n-keys,
  32 of 32. No GUI script changed, and the GUI tests answer the API in
  memory.
- gofmt -l clean. go vet -tags nogui on agent, cli, gui and tui for
  darwin, linux and windows: ok.

Not covered:
- Claude Desktop reads the gateway's model list only as it starts. It
  still needs its Restart button (AppBehind) after a rename, as after
  any other catalog change.
- Pi, omp and StepCode enabledModels: RenameRefs renames magpie/<old>/
  provider entries only. A group's magpie/group/<old> entry goes as
  scope-gone, and the pick of group/<new> is added again. Not checked
  entry by entry.
- Codex signed in beside magpie (models_cache.json aged by the catalog
  tag) was not run again here.
- No real Codex app restart was watched. The reporter's agent isn't
  named.
2026-10-27 18:22:29 +08:00
yetone 7f827b3b0b claude: magpie claude-code runs lists the Claude Code processes and says what they are
@Candydidi3 on X: with Opus in Claude Code, "magpie里拉起很多子进程". On a
Claude account each conversation is answered by a real Claude Code
(`claude -p`) with magpie's MCP helper (`magpie claude-mcp-helper`) as its
child. Claude Code's parallel subagents are conversations of their own,
so a session that starts N of them has N pairs running. idleMost (6)
pairs are kept for an hour so the next turn reads the prompt cache, and
runs waiting on tool calls stay up to 30 minutes. On macOS and Windows
nothing bounds the total unless the user sets `magpie claude-code runs N`.
A task manager names them "2.1.311" (Claude Code's binary is named by its
version) and "magpie", and nothing told the user what they were.

No leak was found. With the bridge's fakes, 12 concurrent conversations
left 6 runs when they ended their turns, 12 when they were parked on
tool calls and never answered (bounded by the 30-minute timer), and 0
right after they were cancelled. Real Claude Code 2.1.311, run with the
bridge's args, exits within 0.1s of stdin EOF and when its parent is
killed, and its helper exits with it.

So nothing about which processes run changes. They become visible
instead:
- GET /v1/magpie/claude-runs (claude_runs.go) lists each run with its pid,
  model, account, state (answering, idle for its next turn, or waiting on
  tools), since when, when magpie lets it go, and its RSS, plus
  claudeRoom's live count. It is loopback only, refused like the heap
  profile, and served no-store.
- `magpie claude-code runs` prints that list under the bound and says
  what the processes are and how long they are kept.
- runs record when they started, when the current turn began, and the
  timer's deadline (endIn wraps every timer.Reset). The literal 30-minute
  timeouts become runTimeout.

Tests:
- TestClaudeRunsNamesEachProcess: idle, tools and answering runs are
  listed with the pids that are alive, and dropped once they end; every
  caller profileCallersRefused lists is refused. It went red with the
  route taken out (404), and with the guard off 3 callers got the list.
- TestClaudeCodeRunsListsTheProcesses covers the CLI's lines and the case
  with no magpie running. The existing CLI test now stubs the gateway, so
  it never asks the live magpie on :3425.
- oneport_test knows ClaudeRunsPath.

Real run (10-27): a sandbox HOME with a made-up Claude sign-in in its own
CLAUDE_CONFIG_DIR (no keychain item was written for it), `magpie serve`
on 127.0.0.1:47820, and a `claude` wrapper that exec'd real Claude Code
2.1.311 against a mock Anthropic API. 8 concurrent subagent-like
requests left 6 Claude Code, each with its helper. `magpie claude-code
runs` listed the same 6 pids ps showed, idle, ends in 59m, about 160 MB
each. SIGTERM to the sandbox serve ended all 12 within a second.

Run (go1.26.8, -tags nogui, private GOCACHE):
- At 184b4b8ba (this change on origin/main 5a3292354): gofmt clean; vet
  for darwin, linux and windows; `go test -count=1 -timeout 45m` of
  internal/cli ok (88s) and internal/gateway FAIL (1079s). Of the 118
  tests that failed, 117 failed on "no space left on device" (other
  sessions filled the disk to 0 bytes free mid-run), and
  TestHistoryKeepsDaysAndDropsOld failed because its big writes were cut
  short. All 118 run again with -count=1: ok (153s). The history test
  -count=3: ok.
- At this commit, rebased on origin/main 56de2d192 (Kiro's and Qoder's
  mins, plugin options, Codex app-server restarts and Hermes, none of it in these
  files): gofmt clean; vet for darwin, linux and windows; `go build
  -tags nogui .`; TestClaudeRunsNamesEachProcess, TestClientPathCoversHandler
  and TestClaudeCodeRuns* ok. The GUI build and a full gateway run there
  didn't fit on the disk (about 500 MB free).
Not run: the full ./... suite, Windows or Linux, a real Anthropic account,
and the GUI suite (no GUI change).
2026-10-27 18:22:01 +08:00
yetone 56de2d1928 hermes: a model picked in magpie reaches the profile hermes starts in, and Off then On leaves every bot a model (tjhhhh)
tjhhhh on Discord (0.1.1673): switching the model of a Hermes profile
other than the default didn't take, and turning magpie's takeover Off and
On again lost the default model, so the hermes CLI failed at start.

Causes, read from Hermes' source (hermes_cli/main.py
_apply_profile_override, profiles.py):
- `hermes profile use X` writes <root>/active_profile, and every later
  `hermes` runs profiles/X. magpie always wrote <root>/config.yaml, the
  profile hermes no longer started in.
- At Off, hermesUnwireProfile deleted model.provider and model.default
  from every profile on magpie and put nothing back. On rewrote only the
  connected config, so the profile hermes ran had no model.

Now:
- hermesActive: the config magpie connects is the profile hermes starts
  in: HERMES_HOME when it names a profile, else active_profile's (BOM and
  whitespace trimmed) when it is a live profile (not "default", a valid
  name, no tombstone, its folder there), else the root.
- Off leaves each bot on magpie on a model it can start with: its own
  stashed model if it had one, else the connected config's own model,
  with that provider's providers.<name> entry copied in when the bot
  lacks it. What magpie put there is kept as hermes:<path>:off.
- On puts magpie back on each bot still on what Off left (hermesBack); a
  bot the user moved while Off keeps theirs; a bot with no model at all
  gets magpie's.
- Bots on the model magpie or hermes last picked follow a new pick
  (hermesFollow now also follows the connected config's current default).
- gone.go: a profile folder's Agent finds the root's hermes-agent
  checkout, so it counts as installed.

Run:
- go test -tags nogui -count=1 -run 'CLIMissingHermes|Hermes'
  ./internal/agent: ok.
- New tests red on the old code: TestHermesStickyProfile
  (hermes_test.go:811 'active_profile "coder\n": connects .../.hermes,
  want .../.hermes/profiles/coder'), TestHermesOffAndOnKeepsEveryBotsModel
  (hermes_test.go:698 'off: writer is on {Provider: Default:}, want
  {Provider:mine Default:kimi-k3}'), TestHermesBotsFollowTheModelHermesPicked
  (hermes_test.go:768 'writer stayed'); TestHermesProfiles' writer after
  disconnect now expects the root's own model, not nothing.
- Whole internal/agent (-timeout 45m, logged): the disk filled (other
  sessions' temp files, under 1 GB free) and 43 tests failed on "no space
  left on device"; each of them, and every Hermes test, passed on a rerun
  (131s). TestFolderVarsAreListed is red on main since e4552cca9 (#3884),
  not touched here.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
  ./internal/agent: clean.

Broken by hand: without the hermesBack call TestHermesOffAndOn fails at
hermes_test.go:716 'on: writer is on {mine kimi-k3}, want {magpie
deepseek/pro}'; following only the recorded pick fails
TestHermesBotsFollow at 768; gone.go reverted fails TestCLIMissingHermes
at install_missing_test.go:132.

Not tried: the real hermes binary (it rewrites the live ~/.hermes launcher
under a temp HERMES_HOME); a real Off/On in the reporter's setup; the full
go test ./... (disk full).
2026-10-27 18:15:16 +08:00
yetone 9bfe680481 plugin: a changed plugin option lists the providers again (plugins#430)
WorkBuddy's plugin 0.1.38 adds a "Free models only" switch (a plugin option)
that lists only WorkBuddy's free models and refuses any other before it is
sent. Its list goes by the switch, but SetProviderOptions only handed the
values over: the host cleared its infos while Go kept provCache, so the
Providers page and /v1/models showed the old list until something else
re-read it. SetProviderOptions now forgets the kept providers (whether the
host runs or not), so the next Cached() lists them again. Nothing else runs
on a change. The workbuddy mover's min is 0.1.38 (npm view --prefer-online
at landing: 0.1.38).

Run:
- go test ./internal/plugin ./internal/provider -count=1 -timeout 45m at
  this head (5a3292354 + this): internal/plugin ok (389s); internal/provider
  FAIL on TestUnreadLoginsWriteErrorsKeepCredentials, "close of synctest
  channel from outside bubble" in filememo.Forget, which is #3632 (open, on
  main since 091153bf, nothing here touches it). TestPluginOptions now lists
  a model only while its option is on, and only base-model after it is off.
- Rebased onto 3aead9c62 after the run; its new commits touch only
  internal/provider/codex_daemon*.go and codex_app_server_test.go. go vet
  ./internal/plugin ./internal/provider ok there; a rebuild to test again
  failed to link for a full disk (291MB free).
- gofmt -l clean; GOOS=linux and GOOS=windows go vet ./internal/plugin
  ./internal/provider ok.
- Real accounts, sandbox HOME, dev build of this tree on 3516/3517 with the
  plugin added by path: POST /api/settings/plugin-option free_only on for
  workbuddy-ai took its list from 26 to 2 (hy3, deepseek-v4.1-flash) within
  2s with no restart; workbuddy kept 19. gpt-5.4 got the plugin's 404 and
  was not sent; hy3 and deepseek-v4.1-flash answered. Off: 26 again, and
  gpt-6-luna and gpt-5.4 answered.
Broken by hand: without forgetProviders in SetProviderOptions,
TestPluginOptions fails ("with beta on, optco lists "base-model"").
Not tried: the switch clicked in the GUI window (the API it calls was);
Windows and Linux apps.
2026-10-27 17:44:02 +08:00
yetone e96a8d2d40 privacy: the local model's threshold defaults stay, measured on real traffic
Yayoi_no_yume (X) asked for 0.85-0.95, ~0.88, over a hardcoded 0.5.
The threshold is the user's per model since v0.1.1689 (Settings >
Privacy > Confidence threshold, 0.5-0.95). This measures whether a
different default would be better, and keeps the defaults.

Corpora: 2000 segments of the owner's real Codex and Claude Code
sessions (prompts, tool arguments and results; 550 with CJK), kept
local; and 101 labelled cases (the 72 eval cases incl. #3029,
#3143, #3144, plus 30 new), 64 values that must be masked, 188 that
must not. Both real models, in a scratch cache: Privacy Filter q8
GGUF via pf-v2, AstrLink Guard rev 7216b6a3b897 (sha256 checked).
Rules alone mask 16 of 64.

  model  thr   labelled masked/64  labelled FP/188  real model masks
  Guard  0.5   60                  0                34
  Guard  0.8*  57                  0                20
  Guard  0.88  56                  0                12
  Guard  0.95  54                  0                 6
  PF     0.5*  59                  2                31
  PF     0.8   57                  1                19
  PF     0.88  56                  1                13
  PF     0.95  56                  0                12

Guard 0.8 -> 0.88 drops 3 false alarms (a model id, a sandbox path
word, a token counter) and lets a real colleague's name and a
labelled signed name through. PF 0.5 -> 0.88 drops 11 (timestamps
in paths, log lines, a plugin id) and lets 6 names and a phone
through, 4 of the names in real traffic. A higher default sends
real names unmasked; the false alarms left are shapes (ISO
timestamps in paths, Claude Code's <total_tokens> counter, base64)
that a check can turn away. The docs now say what the threshold
trades, en/zh/ja masking pages and gateway-routing.md.

Run at this head (and 89ef90356 under it), rebased on e7f21dba5:
gofmt -l, go vet (darwin), GOOS=linux -tags nogui and GOOS=windows
vet of redact (+gateway on linux), go build: clean. go test -count=1
internal/redact, masking, pii/..., settings, otlp, sessions: ok.
Not run before push: internal/gateway and internal/gui (both import
redact) and the full ./... suite, the machine at load ~138 with other
sessions' suites; running after. No GUI asset changed. Eval
recordings (testdata/eval-*.json) not re-recorded; TestMaskEval ok.
2026-10-27 17:10:20 +08:00
yetone b5582912af gateway: a conversation on a ChatGPT account stays on it for an hour unread, not five minutes (leelantao)
leelantao on X: two Plus accounts on in magpie lost 90%+ of their
allowance in a day. Affinity let a conversation leave its account after
cacheCold, five minutes, for every vendor. Under Smart the other account
then had more left and went first, so after any pause over five minutes
the next turn went to the other account. That account read none of the
conversation from cache and refused the reasoning the first had sealed.
Each time, the whole context was paid again uncached, on whichever
account was fuller.

Measured on a real ChatGPT account (Pro, gpt-5.6-terra, low effort,
sandbox HOME, Codex 4-turn task): a thread left 7, 12, 25, 45 and 60
minutes still read everything it had sent before from cache (17152 of
21514, 21248 of 21532, 21248 of 21550, 17152 of 17291, 20224 of 20953).
So the ChatGPT backend keeps it at least the hour measured. coldAfter
gives a ChatGPT account (Account.Agent "codex") chatGPTCold, an hour;
every other vendor keeps cacheCold. A group's rules read the same window
for keepsEffort (turnRule.cold, set from the answering candidate in
ruleAnswered), so they don't drop a ChatGPT conversation's effort after
five minutes and lose its cache that way either.

Also measured: the same task direct, through magpie's relay (Codex's
own sign-in) and through the pool path (codex/gpt-5.6-terra). Direct
and relay send 10 requests each, with 166.7k/166.2k input and
154.1k/148.0k cached. The pool path sends 11 requests: 223.1k input,
196.1k cached. Its requests are ~3.5k larger and its first one reads
nothing from cache. usage.jsonl matches the rollouts one for one. No
hidden retries, titles or warmups were sent.

Run, at 8bd300399 plus this change:
- go test -tags nogui ./internal/gateway -run
  'Affinity|Stick|Effort|Rule|ChatGPT|Cold|Cache|Lone|Rotat|Weight|Smart|Seal|Codex'
  -count=1: ok, 80s.
- GOOS=linux and GOOS=windows go vet ./internal/gateway: ok.
- gofmt -l: clean.
Broken by hand: with coldAfter returning cacheCold and keepsEffort reading
cacheCold, both new tests fail ("ChatGPT, 6 minutes on: why "cold"",
"a ChatGPT conversation 12 minutes on dropped its effort").

Not run: the whole gateway package (another session's gateway run held
the machine); I run it next and file anything red. Not tried: two real
ChatGPT accounts moving a conversation. The second saved account here is
lapsed, so the move's cost is reasoned from the code and the one-account
cache measurements.
2026-10-27 16:40:30 +08:00
yetone d71362afcd gateway: a Gemini tool schema with items is an array, not its enum's string, and Antigravity gets items only on arrays (ferock)
ferock on Discord: Claude Code, model group/gemini-3-8-flash on a local
magpie whose group is served by a remote magpie's Antigravity, 400
"Remote magpie: Antigravity: GenerateContentRequest.tools[0].
function_declarations[19].parameters.properties[display].items: field
predicate failed: $type == Type.ARRAY". It worked in the morning and
broke after updating. The tool's literal schema wasn't posted, and no
Claude Code 2.1.311 built-in has a display property with items (searched
the binary), so it is an MCP tool of theirs.

Cause: geminiToolTypes (68ee4117a, v0.1.1624, 10-27 01:26) runs in
forwardOnce for any body whose model names Gemini, the local magpie's
forward to a remote magpie included. geminiSchemaType typed an untyped
schema from its enum/const values before its keywords, so
{"items":{...},"enum":["a","b"]} went on as type "string" with items
beside it. The remote's plainSchema kept the explicit type and the
items, and Google refused the whole turn. Before 68ee4117a the same node
reached plainSchema untyped and was inferred an array.

- geminiSchemaType: an object's or array's keywords (properties, items
  and the rest, keywordType, split out of schemaTypes unchanged) decide
  before enum/const values.
- plainSchema (the remote's Antigravity side, so a local magpie from
  before is served too): items/minItems/maxItems are kept only on an
  array and properties/required/min-maxProperties/propertyOrdering only
  on an object, as JSON Schema reads them; of a type list it takes the
  type its items or properties are for (["string","array"] with items is
  an array, not a string with items).
- docs/subsystems/gateway-routing.md says both.
- Sibling not changed: kimiSchemaType/collectUntypedEnums still type
  such a node from its enum; whether Kimi refuses items on a string is
  unknown, filed as #3867.

Tests (antigravity_display_items_test.go): the shape the error points to
(an untyped display with items and a string enum, plus properties with a
const) through geminiToolTypes, and through parseAnthropic +
buildCodeAssist(antigravity) as Claude Code sent it, as this version's
local passes it on, and as an older local passes it on (display typed
"string", type lists, a string with object/array keywords); every node
sent has items only as an array and properties only as an object.

Run, in a worktree at origin/main 32ea16c5a:
- go test -tags nogui ./internal/gateway -run 'CodeAssist|Codeassist|
  Gemini|Schema|Antigravity|Kimi|Plain|Grok|OneOf|Tool|Vertex|Google|
  Shape|Enum' -count=1: ok (60s)
- gofmt -l internal/gateway: clean; go vet -tags nogui (darwin),
  GOOS=linux go vet -tags nogui, GOOS=windows go vet on internal/gateway:
  clean
Broken by hand: gemini_schema.go back to origin/main,
TestGeminiToolTypesItemsBeforeEnum and TestAntigravityItemsOnlyOnArrays
FAIL (display typed "string"); codeassist.go back to origin/main,
TestAntigravityItemsOnlyOnArrays FAILs (items, minItems, properties on
type "string").

Not tried: the reporter's literal tool schema (not posted; the fixture is
the shape the error and the update point to), a real Antigravity
account, and a real two-magpie setup. Not run: the whole gateway
package or ./... (another session's full internal/gateway run was on the
machine, load ~60-75).
2026-10-27 16:34:19 +08:00