8a881dc20 made TestAccountDiscoveryOffReadsNoSignIn (internal/provider) and
its sibling in internal/agent take "{}{}" and count only opens after their
own check. It waits until the watch's notes stop for 20ms, so that a note
landing after the check's read returns isn't counted as a read of a sign-in.
That is a timing guess. A watch goroutine held off for over 20ms under load
notes the test's own open late. The provider test also asks for its "own
read" before any wait at all.
openWatch and fifoWatch now count their loops. The func they return waits
until a loop that began after the call has finished, so every open the
watch found before the call is in what it returns. The 20ms quiet windows
are gone.
Ran:
- Injected 30ms between the watch's open and its note:
- origin/main's provider test: 10/10 red ("the watch saw [], want the
test's own read").
- this one: 10/10 green.
- this one with the loop wait taken out: 10/10 red.
- A real read of a sign-in after the check (cursorAuthFile) is still
reported.
- Before the rebase onto 8a881dc20, the same helpers were also run with a
5ms slow read ("{}{}"): red on the old check, green with the fix.
- -count=200 and -race -count=50 of both tests.
- go test of both packages.
- The full go test ./... under the queue lock.
- gofmt -l, go vet, GOOS=linux and GOOS=windows go vet ./... .
- The test fails ~1 in 20 from a .claude/worktrees checkout (on main
before 8a881dc20), the same rate as elsewhere. Neither the test nor the
code it reaches reads the working directory (HOME is a t.TempDir).
TestAccountDiscoveryOffReadsNoSignIn (internal/provider) is the sibling
5421f4468 left: its sanity read failed on "{}{}" when the FIFO was
answered twice under load, and 909d76747 shipped past it as "fails on
main too (1 in ~20)". It now takes one or more "{}" and counts only
opens after the check, as the agent test does.
Both tests also had a second race in that fix: a write the watch began
while the check's read was still open (after its EOF, before close) is
noted after the read returns, past `checked`, and reported as a read of
a sign-in. Each test now waits until the notes stop for 20ms before
counting.
Ran: on origin/main's provider test, a 5ms delay before the read: 3/3
red; with the fix 5/5 green. Late close (1ms after EOF) plus 3ms before
the watch notes an open: without the wait 6/10 red (".codex/auth.json"),
with it 10/10 green. A stray read of a sign-in after the check is still
reported (only that file). -count=30 of each test; go test
./internal/agent ./internal/provider; go vet and GOOS=linux go vet;
gofmt -l clean.
fifoWatch writes "{}" on every 200us loop that finds a reader still in
the FIFO, and notes each. Under a full `go test ./...` the test's own
sanity read got "{}{}" and failed ("the watch didn't answer a read"),
and the extra opens would have been counted as reads of sign-ins.
The check now takes one or more "{}", and only opens after it count.
Run: reproduced by opening the FIFO and sleeping 5ms before reading
(red on the old check, both ways); green with the fix, and -count=20
plain. Breaking the guarantee still fails: any open after the check
is reported.
What changed: Settings → Privacy → Subscription accounts (On/Off),
`magpie accounts discovery [on|off]` and MAGPIE_NO_ACCOUNTS=1 turn off
account discovery. It stays on by default. While it is off, magpie reads
none of the agents' sign-ins: ~/.claude/.credentials.json, .claude.json's
account, ~/.codex/auth.json, Copilot's, Cursor's, Devin's, Kiro's,
Gemini's, ZCode's, Command Code's and OpenCode's files. It runs no
`security` / `secret-tool` for the Keychain or Secret Service, and asks no
agent CLI who is signed in. It serves no subscription. API-key providers,
middleware plugins and Pi extensions work as before.
Why: the reporter runs magpie on machines where reading other tools'
credentials isn't wanted. The owner delegated the call.
How: settings.NoAccountDiscovery (kept per computer by KeepOwn) and
settings.AccountDiscoveryOff(). The variable only ever turns discovery
off. The gates sit at every reader (readAccountFile, discoveryOff) and at
every route that reads or writes a sign-in, so a route that skips
Accounts still reads nothing:
- Accounts, All, Logins, usage, renewal, warm-up, session identities,
check-ins;
- switching, forgetting, SetLoginOn, StartSignIn, the imports;
- moves onto plugins.
The ones that write refuse with an error that names how to turn it back
on. On the agent side, Agent.Source and OpenCode's auth.json are gated,
and Codex wiring goes by magpie's stash instead of auth.json, so a
toggle never rewires Codex. logins.json and plugin-auth.json are left
untouched and serve again when discovery is turned back on. A change
applies at once (ForgetAccounts).
Docs: providers-accounts.md, README (en, zh-CN), and the site's CLI table
(en, zh, ja).
Run:
- TestAccountDiscoveryOffReadsNoSignIn (provider) and
TestAccountDiscoveryOffAgentsReadNoSignIn (agent). Every credential
path is a FIFO that records each open, and security, secret-tool,
claude, codex, cursor-agent, devin, kiro-cli, copilot and grok are fakes
on PATH. Both fail with the gate removed: they show the opens and
`security find-generic-password -s Claude Code-credentials`, among
others. Both pass with the gate in place.
- TestAccountDiscoverySetting and TestAccountsDiscoveryCmd.
- account-discovery.test.cjs: chromium and webkit, 900 and 360 wide,
en/zh/zh-TW/ja/de, 32/32. The neighbouring privacy, redact,
settings-sections and i18n-keys GUI tests: 49/49.
- The full `go test -tags nogui ./...`, gofmt -l, and go vet for darwin,
linux and windows on the touched packages.
Not tried: a real machine under fs_usage, and Linux and Windows at
runtime. The FIFO tests are !windows.