callCacheVersion named every shard, so raising it for a fix to one
agent's calls threw away every agent's calls and re-read the whole
history on the next start: on a real history of ~4,700 transcripts
that is minutes of CPU and the ~310MB peak, for a change to Claude
alone.
Each agent now has its own number in callParseVersions. A shard frame
records the number its agent had when it was written (callDiskState
.Parser), and loadCalls drops a frame whose number is not the current
one, so only that agent's files are read again. CallCacheVersion()
adds the raised numbers, so the usage caches built on calls
(requestDiskBinary, heat_disk) still start again when any agent's
calls change. callCacheVersion stays for a change to every agent or to
the shards' form.
Existing shards are kept: the map is empty, gob leaves a zero Parser
out, and CallCacheVersion() is still "calls-v15".
Run on mote (zone worktree at this head):
- go vet ./internal/sessions ./internal/usage for darwin, linux and
windows: ok. go build ./...: ok.
- go test ./internal/sessions ./internal/usage: ok.
- go test -race -count=3 -run 'TestCallParseVersionRaise|Calls|Shard|Frame'
./internal/sessions: ok.
- TestCallParseVersionRaiseReadsThatAgentAlone: a Claude transcript and
a Codex rollout; raising claude scans the Claude file alone, with the
same calls, and the next start scans nothing.
- Broken by hand (the Parser check in loadCalls removed): red at
call_versions_test.go:67, "scanned map[], want Claude's file alone".
Not changed: internal/gui's TestCoveredWindowStaysUp is killed at 30s
on mote, as in #4125.