📌 Description
internal/bus/membus/membus.go is the in-memory bus implementation (used in tests/dev in place of NATS). It has a test file but reportedly lacks coverage for many concurrent publishers/subscribers racing on the same topic, which is exactly the scenario internal/bus/bus.go's interface is meant to support safely.
🧩 Requirements and context
- Add a test spinning up N goroutines publishing and M goroutines subscribing concurrently on shared topics.
- Assert no messages are dropped and no data race is reported under
-race.
- Assert subscriber removal mid-publish doesn't panic.
Non-functional requirements
- Must be secure, tested, and documented.
- Should be efficient and easy to review.
🛠️ Suggested execution
1. Fork the repo and create a branch
git checkout -b test/membus-concurrency-stress
2. Implement changes
- Modify:
internal/bus/membus/membus_test.go — add the concurrency stress test.
- Modify:
internal/bus/membus/membus.go only if a race is found.
3. Test and commit
go test ./internal/bus/membus/... -race -v
- Cover edge cases: subscriber unsubscribes while a publish is in flight, publish with zero subscribers, many topics with overlapping subscribers.
- Include test output and details in the PR description.
Example commit message
test: add concurrent publish/subscribe stress coverage for membus
✅ Acceptance criteria
🔒 Security notes
A race in the in-memory bus used for local/dev/test parity with NATS could mask concurrency bugs that only show up in production under natsbus. Validate the fix (if any) doesn't just paper over a real race with a lock that changes semantics.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
internal/bus/membus/membus.gois the in-memory bus implementation (used in tests/dev in place of NATS). It has a test file but reportedly lacks coverage for many concurrent publishers/subscribers racing on the same topic, which is exactly the scenariointernal/bus/bus.go's interface is meant to support safely.🧩 Requirements and context
-race.Non-functional requirements
🛠️ Suggested execution
1. Fork the repo and create a branch
2. Implement changes
internal/bus/membus/membus_test.go— add the concurrency stress test.internal/bus/membus/membus.goonly if a race is found.3. Test and commit
go test ./internal/bus/membus/... -race -vExample commit message
✅ Acceptance criteria
-racereports no data races under the new stress test.🔒 Security notes
A race in the in-memory bus used for local/dev/test parity with NATS could mask concurrency bugs that only show up in production under
natsbus. Validate the fix (if any) doesn't just paper over a real race with a lock that changes semantics.📋 Guidelines