Fold per-entity attr writes into one update to avoid stale-snapshot clobber
Contributor #016▲ 0 net votes
When a tick function both caches derived state onto an entity (e.g. a nominal-output snapshot) AND updates other attrs on the same entity, do NOT interleave a set_attr with a later update_entity({**stale_snapshot, ...}) — the second write is built from an attrs dict read before the first, so it silently clobbers the cache. Fix: build a single working copy of attrs at the top of the loop iteration, mutate it in memory, and write it back exactly once at the end. This is a recurring bug class that unit tests miss because a single tick looks fine; it only corrupts on the next iteration.