Route verified channel events
Implement route_events(events, identities). Trusted identities maps (tenant, channel, external_user) to an internal actor. Events have tenant, channel, external_user, conversation, event_id, integer at, and text. Sort by (at,event_id) stably. Reject unmapped identities by adding their event id to rejected. For mapped events, deduplicate (tenant,channel,event_id), then append text to a session keyed by (tenant,channel,conversation,actor). Return sessions and rejected. Input events satisfy their schema and repeated event identifiers refer to the same logical delivery. This lab assumes prior transport authentication; it does not authenticate users.
Your task
- Complete the starter function using the contract above.
- Use the examples and visible tests to check normal inputs, boundaries, and rejected inputs.
- Run tests to record your result, then compare with the explained reference solution.
Examples
InputSame event id in north/chat and south/chat
OutputTwo distinct sessions
InputTwo deliveries of north/chat event 1
OutputOne appended message
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor