agora.matrix.sync

Event stream → domain-event dispatcher.

Components register async handlers for specific domain events. EventDispatcher.handle() takes a raw Matrix event dict, parses it, and fans out to all registered handlers.

The dispatcher intentionally does not own a sync loop — Sprint 2 keeps the surface small. A production sync loop is wired up by the orchestrator (Sprint 3), which calls handle for each event yielded by AsyncClient.sync_forever.

Classes

EventDispatcher

Routes parsed Agora events (and a few Matrix-native ones we care about).

ReactionEvent

Parsed m.reaction pointing at a target message.

ReplyEvent

A m.room.message that carries m.in_reply_to to another event.

class agora.matrix.sync.ReactionEvent[source]

Bases: object

Parsed m.reaction pointing at a target message.

event_id: str
target_event_id: str
key: str
sender: str
__init__(event_id, target_event_id, key, sender)
class agora.matrix.sync.ReplyEvent[source]

Bases: object

A m.room.message that carries m.in_reply_to to another event.

event_id: str
target_event_id: str
body: str
sender: str
__init__(event_id, target_event_id, body, sender)
class agora.matrix.sync.EventDispatcher[source]

Bases: object

Routes parsed Agora events (and a few Matrix-native ones we care about).

Components register async handlers for specific event types via the on_* methods; handle() takes a raw Matrix event dict, parses it into the matching domain type (Task, TaskResult, PhaseChange, Learning, ReactionEvent, ReplyEvent, plus MSC3381 poll responses and /agora commands), and fans out to every registered handler in registration order.

Idempotency: every parsed event is keyed by its Matrix event_id and duplicate deliveries (which Conduit can produce on reconnect) are silently skipped. Handlers run sequentially within a single event; parallelism between distinct events is the caller’s responsibility.

The dispatcher does not own a sync loop — the orchestrator wires one up via agora.observe.sync_service.SyncService, which calls handle() for each event yielded by AsyncClient.sync_forever.

__init__()[source]
on_task_event(handler)[source]
on_task_result(handler)[source]
on_phase_change(handler)[source]
on_learning(handler)[source]
on_poll_response(handler)[source]
on_command(handler)[source]
on_reaction(handler)[source]

Fires when a user reacts to a message with an emoji.

on_reply(handler)[source]

Fires when a user replies to a message (m.in_reply_to relation).

on_raw_event(handler)[source]

Fires for every event seen, after type-specific handlers.

async handle(room_id, event)[source]

Parse one Matrix event dict and dispatch to handlers. Unknown types are ignored.