Files
magpie/internal/codexcat
yetone 78cbb711d9 agent, codexcat: a poll asks Vision once per stamp and reads Codex's cache levels once per change
A heap profile of the live magpie (v0.1.2646, 37 minutes, the owner's
real accounts) had buildModels allocate 1288MB. 553MB of it was the
gateway's seer, asked once per list build (provider.Described), and
238MB was codexEfforts -> TakesEffort -> CacheEntries, which decodes the
whole Codex models_cache.json for each model asked.

- buildModels asks describedNow(), kept per provider.StampNow() in a
  stampedLists like the lists themselves, so every agent's list of one
  stamp shares one answer, and a change (a provider saved) asks again.
- TakesEffort reads a slug's default level from cacheLevels(), a
  filememo.Read of the cache file by its stat: the decode keeps only
  each model's level, and runs again when the file changes. magpie's own
  added entries are skipped as CacheEntries skips them.

Run on mote (macOS 27.2):
- TestListsAskVisionOnce (new): pi, claude, codex, opencode, droid and
  dsh lists ask Described once; after a provider save, once more, and a
  "no" reaches the new list. With buildModels asking Described itself
  (put back by hand): red. Restored: ok.
- TestTakesEffortReadsTheCacheOnChange (new): a 300-model cache, levels
  for a slug and codex/<slug>, the default for magpie/x and an unknown
  one, 20 allocs or fewer a look, and the new level after a rewrite a
  minute later. With TakesEffort on CacheEntries again (by hand): red.
  Restored: ok.
- go test ./internal/agent ./internal/codexcat at this tree: ok (162.5s).
  ./internal/gateway and ./internal/gui at the tree before the test's
  last fix (only the new test changed since): ok but
  TestCodexPoolSaysTheClientsVersion (#4807, red in a full gateway run
  on mote, untouched here) and TestMainWindowCorners/macOS_26_SDK
  (#3949, red on macOS 27).
- gofmt -l clean; go vet, GOOS=windows and GOOS=linux go vet of both
  packages: ok.

Not tried: a heap profile of a live build with this change.
2026-11-02 06:59:17 +08:00
..
test: every package's tests pass on Windows, and none writes outside its sandbox (the user: 把 Windows 上那几个失败的测试修掉) — on a Windows box the suite failed in most packages, and the root package hung for 25 minutes. Tests set HOME, which os.UserHomeDir ignores on Windows (it reads USERPROFILE), so they read and wrote the runner's own home; each now sets USERPROFILE beside HOME, and Devin's, Goose's, Crush's and Claude Desktop's tests set APPDATA/LOCALAPPDATA, where those keep their files there. said() read the command's output only once it returned, and a pipe holds a few KB on Windows, so magpie model --help blocked forever; it reads while the command writes. Unix permission bits (the gateway key store's 0600 too), exec bits and symlinks Windows lacks are checked only off Windows; TOML strings hold Windows paths as literal strings, JSON as marshalled ones; a URL's path is compared as one. The provider and usage packages run in a home of their own (TestMain, as the gateway's already does), since a CLI's identity kept by a refresh still going when its test ended landed in the runner's ~/.config/magpie — and on a Mac in the user's own. Two product fixes came out of it: imagemcp took a file:///C:/… root or image for the path /C:/…, which doesn't exist on Windows, and now makes a Windows path of it (a host for a UNC share); and session discovery could keep a new Cowork session hidden on Linux, where a folder's mtime is a kernel tick and its size doesn't change, so an entry added within the tick of the last listing left both as they were — a listing made within 2s of its folder's last change is read again, as git does for racy files. TestFilePath and TestRacyDirectoryListedAgain fail without the change. On Windows 11 every package passes (32 of 32) and a run of each package in a fresh home leaves nothing in home, APPDATA or LOCALAPPDATA; on Linux (WSL) and macOS go test -tags nogui ./... passes. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build pass.
2026-10-01 23:15:07 +08:00