state: GetSnapshot copies the state's maps (closes #261) #272

Merged
clawbot merged 1 commits from fix/261-snapshot-map-copies into next 2026-10-13 13:44:32 +02:00
1 Commits
Author SHA1 Message Date
sneak 7b1680c441 state: GetSnapshot copies the state's maps (closes #261)
check / check (push) Waiting to run
The dashboard and /api/v1/status range over the maps in the snapshot
GetSnapshot returns after the read lock is released, while the watcher
writes the same maps under the lock. Go aborts the process when a write
lands during such a range. GetSnapshot now returns copies of the four
maps.

The entries in the maps are still shared with the state. That is safe
because the watcher replaces an entry with a Set call and never changes
one in place; the comment on GetSnapshot says so.

TestGetSnapshot_WhileWritten ranges over snapshots while another
goroutine writes the state and fails under -race without the copies.
TestGetSnapshot_ReturnsCopy now checks that each map is not the state's
own.

Model: opus-5-5
2026-10-13 11:16:53 +00:00