apply_event(state, event) builds a projection from a stream of complete put snapshots and delete events. Delivery is at-least-once: after a consumer restart the log is replayed, so events can arrive duplicated or out of order. Versions are positive integers that increase independently for each (tenant, id), and the same key/version always denotes the same event.
After a replay, records that were deleted in production sometimes reappear with stale values. In one case a record received put v1 "old" and then delete v3; when a delayed put v2 "old" arrived afterwards, the projection showed the record as live again with value "old". The same happens when a delete arrives before the record's earlier puts.