Count unique unfinished events for EventBus capacity - #36
sarath-menon wants to merge 3 commits into
Conversation
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
1 similar comment
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude finished @sarath-menon's task —— View job PR Review: Count unique unfinished events for EventBus capacityTasks:
SummaryThis PR correctly fixes two related bugs in EventBus capacity tracking:
The fix introduces Overall the approach is sound. A few observations below. Issues and Observations1. Race / stale-key accumulation in the admission filter (medium)
self._outstanding_events = {
key: value for key, value in self._outstanding_events.items() if value.event_status in ('pending', 'started')
}This replaces the whole dict on every A minor alternative would be to remove completed entries lazily in 2.
3.
def __str__(self) -> str:
icon = '🟢' if self._is_running else '🔴'
return f'{self.name}{icon}(⏳ {len(self.events_pending or [])} | ▶️ {len(self.events_started or [])} | ✅ {len(self.events_completed or [])} ➡️ {len(self.handlers)} 👂)'
4. Capacity error message: "Processing" count can be misleading (low)
f'Queue: {queue_size}, Processing: {max(0, total_pending - queue_size)}. '
5. Admitted event mutation before capacity check (acknowledged limitation) The PR description already calls this out: Test CoverageThe new test file
One scenario that could be worth adding (or documenting as a known gap): dispatching the same object instance more than once currently adds two queue entries but only one Code Quality
Overall verdict: The fix is correct, well-motivated, and the tests cover the core edge cases. The observations above are mostly low-severity or cosmetic. The acknowledged limitation around path mutation before failed admission is the most impactful remaining gap, and the PR description is appropriately transparent about it. |
bubus36.mp4
EventBus capacity double-counts queued events that also appear in history and can lose track of unfinished work when history evicts it. This change tracks unique unfinished event objects independently of history, preserving the 50-entry queue limit and 100-event capacity while allowing existing RuntimeError and QueueFull handlers to catch capacity failures. All 69 focused tests pass, including history eviction, distinct objects sharing an event ID, and repeated dispatch of the same object. This dependency-only draft leaves Cloud pinned to bubus 1.5.6, so package publication and Cloud adoption remain separate steps; the animation illustrates local tests. The pre-existing mutation of parent/path metadata before failed admission remains a limitation and should be addressed separately before broad overload rollout.
The automated-review credential was repaired and the validated Sonnet 4.6 workflow setting adopted through #37; all checks on this head, including automated review, now pass.