/// Main-actor reentrancy can interleave two async publication sequences even /// though each individual operation is actor-isolated. Coalesce requests while /// retaining one owner of source retirement, snapshot creation and publication. @MainActor final class DocumentPublication { private var running = false private var requested = false func run(_ operation: @MainActor () async -> Void) async { requested = true guard !running else { return } running = true defer { running = false } while requested { requested = false await operation() } } }