Deliver notifications through preferred channels and deduplicate messages by ID.
Interface
Export create_notification_router(channels), which returns async route(message). channels maps names to async handlers. A message is a dictionary with id and preferred_channels. With only email registered, ["sms", "email"] routes to email.
Implement the contract in the supplied source file using Python 3. Discuss framework integration in design.md.
Behavior
- [N1] Choose the first preferred name with a callable handler. Call it with the original message fields. Raise LookupError if no handler is supported.
- [N2] Propagate handler exceptions and clear pending state so a later call can retry. Do not fall through to another handler after an exception.
- [N3] A new success returns {"channel": name, "duplicate": false}. In-flight duplicates join the first attempt, and later duplicates reuse the successful channel. Both return duplicate true on success regardless of their preferences. Joined requests share failures.
- [N4] Raise ValueError before dispatch for a missing or empty ID or an ID that is not a string. Instances have independent state. Callers use a single event loop and do n