Pi set up by hand on a provider of its own named magpie (magpie/<model>
at the gateway) read as connected in magpie: every catalog change wrote
magpie's list over that provider, RenameProvider rewrote its refs, Drift
offered Reconnect, and Disconnect took the provider out.
0911a65e7 (yyddbds, MiMo) already holds a ListOnly agent's sync until
it is Wired; that still let a hand-written config that names a magpie
model (JFunfunfun's Pi) read as Wired. Both gates now apply.
Its test's last case said a magpie model picked by hand on MiMo's own
magpie provider connects it; that is JFunfunfun's case, so it now
stays the user's until connected in magpie (listonly_test.go, and the
doc's ListOnly line says so).
An agent whose magpie is a provider of its own config (Spelled, not
Native) is now connected only when magpie set it up (setUp): a field in
applied.json, the new applied.Kept that Keep leaves instead of deleting
the record, or the <id>.connect.was stash Connect has written since
10-03. Otherwise (handWired) it isn't Wired, has no Drift, and
SyncCatalog, RenameProvider and renameRefs skip it; Disconnect is a
no-op as it is for any unwired agent. Connecting it in magpie takes it
on as before; Disconnect after that skips putting back "was" values
that were themselves magpie's (dsh errored on them). RenameLegacy
records the dial/ -> magpie/ values it writes, and moveEfforts (the
Cursor/Antigravity effort ids, at start-up) leaves a hand-written
magpie/<ref> alone. Aside keeps its own
key-based ownership. OpenCode's own-gateway-provider test now connects
through Apply as `magpie opencode` does.
Run (on mote, at this head, rebased on f2c6831a3): go test -tags nogui
-count=1 ./internal/agent ./internal/cli ./internal/library
./internal/gui; go vet darwin/linux/windows of internal/agent and
internal/cli; gofmt -l. internal/agent again after the ListOnly test
change: ok. Pushed on ceef9e943, whose five commits since touch usage,
sessions, library, provider movers and gui only.
New tests: TestPiHandWiredMagpieProviderIsTheirs (pi's literal
settings.json/models.json in a sandbox HOME, files byte-identical after
SyncCatalog, RenameProvider and Disconnect), TestPiConnectedBefore-
StaysConnected (applied record, gone model, connect.was, applied then
Keep), TestHandWiredMagpieProviderSiblings (29 Spelled agents). All fail
on the old code.
Tests that wrote a connected agent's files by hand (Pi, OpenCode,
Hermes, omp, dsh, the Kilo plugin, Cursor efforts, and the cli's
save-then-sync test) now also mark it as Connect leaves it
(setUpInMagpie, the connect.was stash); without it they read as
hand-written, which is what this change is about.
Broken by hand, each red: the Sync gate, the rename gates, the Drift
gate, Keep deleting the record, the was-skip in Disconnect, the
moveEfforts gate (TestMoveCursorEfforts' hand-wired case).
Not tried: a real pi binary against the gateway. Users connected
between 09-23 and 10-03 who pressed Keep (record deleted before this)
read as not connected; one Connect brings them back and pi keeps
working meanwhile. Agents without Spelled (Claude Code, Codex, Gemini
and others) decide by their own checks and are unchanged.
On a Windows box whose wsl.exe hangs (`wsl -l` there never answered),
every magpie command took ~20s, `magpie version` too. A goroutine dump
taken 8s in showed start-up's moves (RenameLegacy, then the Cursor and
Antigravity effort moves) walking All(), whose WSL agents list the
distros: `wsl -l -q` waited out its 10s timeout, then `wsl -l --running
-q` waited out another. `magpie providers` waited too, through Copilot's
sign-in looked for in each distro's home.
- Start-up's moves look at this machine's agents only (local()). They
came before WSL agents (the dial rename 09-23, the effort moves 09-28,
the day WSL Codex came), so a distro has nothing for them.
- A listing that failed isn't followed by the running list: no distro
was listed, so none runs. That was a second timeout under wsl's lock,
which the GUI waits on.
- A listing that hung (failed after 5s or more) is remembered in
wsl-hung beside magpie's settings for 10 minutes: a new process
doesn't list again in that time, and a listing that answers removes
it. A process that runs on (the GUI) lists again each minute as
before.
Real run on the Windows box (10.0.0.132), wsl.exe hung, sandbox
USERPROFILE, old build (main c89284ae6) against this one:
version 20.17s -> 0.12s
agents 20.29s -> 0.24s
providers 20.21s -> 10.16s the first time (it records the hang),
0.14s after
wsl-hung was written at the first run's hang.
Tests: TestStartUpMovesAskNoWSL (start-up's moves ask wsl.exe nothing,
All() still has the distro's agents), TestWSLListFailsAsksNoRunning,
TestWSLHangRememberedAcrossProcesses. The first two are red on the old
code; the third goes red with the hang check turned off by hand.
Run at this head (base b10f43e89): gofmt; GOOS=linux/windows/darwin go vet
-tags nogui ./internal/agent ./internal/cli; go test -count=1 -tags nogui
./internal/agent ./internal/cli: cli ok (38s), agent ok but one test:
TestWSLColdPlaceOpensNothing is red on main already (#3924, from
34d38ed66's Hermes profiles), with or without this change.
Not tried: a real WSL that answers slowly but under 10s; it lists as
before.
The gateway takes gateway.Token, and the keys that name an agent
(gateway.TokenFor), only from loopback. When MAGPIE_ADDR pins the
gateway to an address beyond loopback and sharing is on, keyAt gives the
LAN sharing key, and most writers use it. T3 Code's instance still wrote
gateway.Token, so every call it made got 401. Air's and OpenChamber's
Checks compared against gateway.Token, so they said the wiring Sync had
just written was off.
The same mistake was in every writer that pairs gateway.URL() or
gatewayV1() with a fixed token:
- agy, Alma, Cindy, Claude Desktop, Copilot for JetBrains, Cursor's
local agent, OpenHanako, Pencil, VS Code / Insiders / VSCodium,
WorkBuddy-family models.json, ZCode (both files), Zed's credential,
Aside's provider, and the legacy Claude token rename.
- Fix: these now take agentKey(agent) or hereKey(), which are keyAt and
agentKeyAt for gateway.URL(). On loopback they are unchanged.
- Alma re-keys a provider that holds any of magpie's keys other than the
one it should have now.
- WorkBuddy and Aside also count the new key as theirs.
- ZCode treats a saved address equal to the pinned gateway as this
machine's, not another magpie's.
What was run:
- New tests: TestT3CodeKeyBeyondLoopback and
TestAirAndOpenChamberChecksTakeTheKeyForTheGateway (from the
reporter's patch), and TestPinnedGatewayKeyForEveryWriter, which covers
the other writers.
- With the product files reverted, all three are red. The T3 token reads
"magpie", and each of the 11 writers shows its old key. They are green
with the fix.
- go test -tags nogui ./internal/agent/ is green.
- gofmt -l and go vet are clean on darwin, linux and windows.
Not tried with a real T3 Code, Air, OpenChamber or a real pinned
MAGPIE_ADDR on a second machine.
On start-up magpie now renames what dial wrote into the agents' files: a
model spelled dial/… becomes magpie/… (which also writes the magpie
provider entry), and the dial provider entry, Codex's [model_providers.dial]
table and dial-models.json, and Claude Code's bearer token go. Once nothing
says dial it changes nothing.