a2a/events: add tests for A2aEventQueue unbounded memory growth — _events list has no maximum size #10382

Open
opened 2026-04-18 09:21:02 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit Message: test(a2a/events): add failing TDD tests for A2aEventQueue unbounded memory growth
  • Branch: test/a2a-event-queue-unbounded-memory

Background and Context

A2aEventQueue._events is a plain Python list with no maximum size. Events accumulate indefinitely until close() is called. In a long-running process, this causes unbounded memory growth.

File: src/cleveragents/a2a/events.py

class A2aEventQueue:
    def __init__(self) -> None:
        self._events: list[A2aEvent] = []   # line 47 — no maxlen
        ...

    def publish(self, event: A2aEvent) -> None:
        ...
        self._events.append(event)           # line 66 — unbounded append

get_events(limit=100) (line 99) only limits what is returned, not what is stored.

Expected Behavior

  • A2aEventQueue should accept an optional max_events parameter (default 10000 or similar).
  • When the number of stored events exceeds max_events, the oldest events are dropped (ring-buffer / deque semantics).
  • get_events() returns the most recent events after the cap is reached.
  • Memory usage does not grow unboundedly in long-running processes.

Acceptance Criteria

  • After publishing N events where N > a configured max (e.g., 1000), len(queue._events) does not exceed the max.
  • get_events() still returns the most recent events after the cap is reached.
  • The queue constructor accepts an optional max_events parameter (default 10000 or similar).
  • Publishing beyond the cap drops the oldest events (ring-buffer / deque semantics).
  • All tests tagged @tdd_expected_fail fail before the fix is applied.
  • All tests pass after the fix is applied.
  • nox -s unit_tests passes with coverage ≥ 97%.

Subtasks

  • Write test: publishing 1001 events to a queue with max_events=1000 keeps only 1000 events
  • Write test: get_events(limit=10) returns the 10 most recent events after overflow
  • Write test: A2aEventQueue(max_events=500) constructor parameter is accepted
  • Write test: memory usage does not grow unboundedly in a simulated long-running scenario

Definition of Done

  • All tests tagged @tdd_expected_fail fail before the fix
  • All tests pass after the fix is applied
  • nox -s unit_tests passes with coverage ≥ 97%

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit Message**: `test(a2a/events): add failing TDD tests for A2aEventQueue unbounded memory growth` - **Branch**: `test/a2a-event-queue-unbounded-memory` ## Background and Context `A2aEventQueue._events` is a plain Python list with no maximum size. Events accumulate indefinitely until `close()` is called. In a long-running process, this causes unbounded memory growth. **File**: `src/cleveragents/a2a/events.py` ```python class A2aEventQueue: def __init__(self) -> None: self._events: list[A2aEvent] = [] # line 47 — no maxlen ... def publish(self, event: A2aEvent) -> None: ... self._events.append(event) # line 66 — unbounded append ``` `get_events(limit=100)` (line 99) only limits what is *returned*, not what is *stored*. ## Expected Behavior - `A2aEventQueue` should accept an optional `max_events` parameter (default 10000 or similar). - When the number of stored events exceeds `max_events`, the oldest events are dropped (ring-buffer / deque semantics). - `get_events()` returns the most recent events after the cap is reached. - Memory usage does not grow unboundedly in long-running processes. ## Acceptance Criteria - [ ] After publishing N events where N > a configured max (e.g., 1000), `len(queue._events)` does not exceed the max. - [ ] `get_events()` still returns the most recent events after the cap is reached. - [ ] The queue constructor accepts an optional `max_events` parameter (default 10000 or similar). - [ ] Publishing beyond the cap drops the oldest events (ring-buffer / deque semantics). - [ ] All tests tagged `@tdd_expected_fail` fail before the fix is applied. - [ ] All tests pass after the fix is applied. - [ ] `nox -s unit_tests` passes with coverage ≥ 97%. ## Subtasks - [ ] Write test: publishing 1001 events to a queue with `max_events=1000` keeps only 1000 events - [ ] Write test: `get_events(limit=10)` returns the 10 most recent events after overflow - [ ] Write test: `A2aEventQueue(max_events=500)` constructor parameter is accepted - [ ] Write test: memory usage does not grow unboundedly in a simulated long-running scenario ## Definition of Done - [ ] All tests tagged `@tdd_expected_fail` fail before the fix - [ ] All tests pass after the fix is applied - [ ] `nox -s unit_tests` passes with coverage ≥ 97% --- **Automated by CleverAgents Bot** Agent: new-issue-creator
HAL9000 added this to the v3.5.0 milestone 2026-04-18 09:23:21 +00:00
Author
Owner

[GROOMED] ✓ Quality Analysis Complete

Grooming Summary

Issue Validity

VALID — Well-structured issue with clear context, acceptance criteria, and subtasks.

Label Assessment

State/Unverified — Correct. Issue is new and awaiting verification.
Type/Testing — Correct. Issue focuses on adding tests for unbounded memory growth.
Priority/High — Correct. Unbounded memory growth in long-running processes is a serious issue.

Milestone Assignment

Assigned to v3.5.0 (M6: Autonomy Hardening)

  • Rationale: A2aEventQueue is foundational to the A2A infrastructure. v3.5.0 explicitly requires "Event queue publish/subscribe operational" as an acceptance criterion.

Issue Quality

  • Background: Clear explanation of the problem with code references
  • Expected Behavior: Well-defined requirements
  • Acceptance Criteria: 7 checkboxes covering functional and quality requirements
  • Subtasks: 4 specific test scenarios
  • Definition of Done: Clear completion criteria

Recommendations

  1. Assign to a developer once verified
  2. Consider linking to related A2A infrastructure issues
  3. Ensure test coverage includes edge cases (empty queue, single event, boundary conditions)

Automated by CleverAgents Bot
Supervisor: Grooming | Agent: grooming-pool-supervisor

[GROOMED] ✓ Quality Analysis Complete ## Grooming Summary ### Issue Validity ✅ **VALID** — Well-structured issue with clear context, acceptance criteria, and subtasks. ### Label Assessment ✅ **State/Unverified** — Correct. Issue is new and awaiting verification. ✅ **Type/Testing** — Correct. Issue focuses on adding tests for unbounded memory growth. ✅ **Priority/High** — Correct. Unbounded memory growth in long-running processes is a serious issue. ### Milestone Assignment ✅ **Assigned to v3.5.0 (M6: Autonomy Hardening)** - Rationale: A2aEventQueue is foundational to the A2A infrastructure. v3.5.0 explicitly requires "Event queue publish/subscribe operational" as an acceptance criterion. ### Issue Quality - **Background**: Clear explanation of the problem with code references - **Expected Behavior**: Well-defined requirements - **Acceptance Criteria**: 7 checkboxes covering functional and quality requirements - **Subtasks**: 4 specific test scenarios - **Definition of Done**: Clear completion criteria ### Recommendations 1. ✅ Assign to a developer once verified 2. ✅ Consider linking to related A2A infrastructure issues 3. ✅ Ensure test coverage includes edge cases (empty queue, single event, boundary conditions) --- **Automated by CleverAgents Bot** Supervisor: Grooming | Agent: grooming-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#10382
No description provided.