class ReferenceProjector: """Tiny transactional projection used to prove cursor/idempotency semantics.""" def __init__(self) -> None: self.cursor = 0 self.rows = {} async def load_cursor(self, application_ref, root_trace_id): del application_ref, root_trace_id return self.cursor async def project(self, event, expected_cursor): if expected_cursor != self.cursor: raise ValueError("stale projection cursor") self.rows.setdefault(event.event_key, event.payload) self.cursor = event.event_id