The summary's Claude revision window (state.Claude) was json:"-", and a
Claude file's parse with no window starts again from byte 0. So after
every restart, which is every update, the Sessions list read each grown
Claude session from its first line: the live 2 GB session on the
owner's machine took seconds of the first list.
state.Claude now goes into sessions.json as its bounded window
(claudeUsageState MarshalJSON/UnmarshalJSON, the entries in eviction
order; window() and claudeWindowOf are shared with the calls .rev
sidecar). It is bounded by claudeRevisionEntries and trimSummaryRevisions
as in memory. A sessions.json from an older magpie has no "claude" and
reads from the start as before; an entry without a contribution is
skipped, so a bad window never loses the whole index.
#697 kept message maps out of the index because they were unbounded;
the window is bounded now, so TestClaudeNativeReplayAcrossReadersAndRestart
checks the kept window's weight instead of its absence, and
TestQoderUsageAfterWindowLoss's restart case strips "claude" from
sessions.json to stand for an older index.
Real data (a sandbox HOME with the owner's real ~/.claude and ~/.codex,
read only): cold Sessions list after a restart with the live sessions
grown, 6.3s with the 2 GB file reparsed -> 0.77-0.96s over three runs,
only small subagent files reparsed. sessions.json: 7 windows, ~1 MB of
21.7 MB.
Run at this tree: go test -count=1 -timeout 45m ./internal/sessions
./internal/usage ./internal/usageapi ./internal/gui ok (sessions after
the two test updates); go test -race ./internal/sessions ok; GOOS=linux
and windows go vet -tags nogui ./internal/sessions ok; gofmt clean.
TestClaudeSummaryReadOnAfterRestart is red with the tag back at "-"
(the summary is read again from its start, its marker lost).