Welcome to the team that runs the internal message bus. Subscribers register a topic pattern and a callback; publishing a message delivers it to every matching subscriber. A pattern is an exact topic ("px.AAPL"), a trail…
Welcome to the team that runs the internal message bus. Subscribers register a topic pattern and a callback; publishing a message delivers it to every matching subscriber. A pattern is an exact topic ("px.AAPL"), a trailing one-segment wildcard ("px.*"), or the match-all pattern ("*").
This repository has three reported problems, listed below as tickets. Fix as many tickets as you can in 45 minutes. Each ticket is checked separately, and you are not expected to finish every one.
You may use the AI assistant and normal repository tools. Treat the assistant like a junior developer: establish a plan, inspect its work, run the tests, and retain ownership of the result.
bus/
models.py domain types (Subscription)
errors.py BusError
topics.py TopicMatcher: pattern/topic matching
subscriptions.py SubscriptionRegistry: add / remove / all
router.py Router: publish -> match -> deliver
service.py MessageBus: subscribe / unsubscribe / publish
tests/visible/ shipped regression tests
conftest.py puts the repository root on the import path for pytest
"a.*"), or match-all ("*").Subscribers using "px.*" or "*" receive nothing. Only exact-topic subscriptions get messages, so every wildcard consumer is silently broken.
"px.*" matches "px.AAPL" and any single trailing segment under px."*" matches every topic."px.*" and asserts delivery of a "px.AAPL" message.Do not change the subscription registry or the router loop as part of this ticket.
After a client unsubscribes it keeps receiving messages. The registry's remove path compares the wrong fields, so nothing is ever removed and subscriptions leak.
unsubscribe(token), that subscription no longer receives messages.Do not change topic matching or the router loop as part of this ticket.
If one subscriber's callback raises, the subscribers after it on the same topic receive nothing. A single bad consumer is breaking fan-out for everyone.
Do not change topic matching or the subscription registry as part of this ticket.
pytest tests/visible. Every shipped test fails on the starter code and passes once the bugs it covers are fixed.bus/ are submitted; the shipped tests in tests/visible run as they are.MessageBus.subscribe, unsubscribe and publish, and count subscriptions with registry.all(), so keep those in place.Adapted from treasure567/bloomberg-practice (round-2/galena @ 8de07d5), used with the author's permission.
Visible test command
pytest tests/visibleThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
message-bus-wildcards-unsubscribe-and-failing-subscribers
Changes under src/ are evaluated.