A Claude history's read keeps a window of recent messages to fold
revisions together. Each message made a contribution, a branch map and
its tool and block maps, and dropped them when it left the window: on a
cold start of a real history copy that was ~750MB of message() and
~690MB of ccTool's maps. An evicted contribution and its emptied branch
map now go on a short free list (16 contributions, maps over 64 entries
dropped) and the next message takes them, cleared.
Measured on mote, cold start over a copy of real Claude and Codex
histories (acold.sh, 120s), against v0.1.3128's build:
allocated 8.96GB -> 8.79GB, GCs 277 -> 266,
footprint peak 197MB -> 189MB, heap peak 194MB -> 186MB.
message() 750MB -> 565MB, ccTool 689MB -> 466MB.
Tried and dropped: doubling the calls list by hand saved ~0.5GB of
allocation but raised the footprint peak to 265MB (lists held at up to
twice their size while read), so the calls list grows as before.
Tests:
- TestClaudeEvictedContributionsLeaveNothing: 3 windows of replies
through both reads; every live contribution holds only its own
message's tools and blocks, usage, calls, replies and output totals
are right, a replayed reply makes no call. Red by hand without the
maps' clear ("holds another message's tool") and without recycling
("nothing evicted was kept").
- TestClaudeHistoryReadAllocations: 3156 bytes a reply once the window
is full, bar 4200; 5348 without recycling (red by hand).
Full suite on mote (gofmt, vet darwin/linux/windows, go test -timeout 45m ./...):
85 packages ok; red only TestMainWindowCorners (#3949) and
TestRenewLoginsKeepsClaudeReading (#5481), both filed and red on main.
internal/sessions run again at the rebased head.