Files
cleveragents-core/features
HAL9000 4e982a0366
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 1m7s
CI / typecheck (pull_request) Successful in 1m2s
CI / quality (pull_request) Successful in 49s
CI / benchmark-regression (pull_request) Failing after 57s
CI / helm (pull_request) Successful in 31s
CI / push-validation (pull_request) Successful in 32s
CI / build (pull_request) Successful in 36s
CI / security (pull_request) Successful in 1m21s
CI / integration_tests (pull_request) Successful in 4m3s
CI / unit_tests (pull_request) Successful in 4m32s
CI / e2e_tests (pull_request) Successful in 4m40s
CI / docker (pull_request) Successful in 1m35s
CI / coverage (pull_request) Failing after 16m53s
CI / status-check (pull_request) Has been cancelled
fix(a2a/events): guard A2aEventQueue with threading.Lock to prevent concurrent iteration crash
Fix a critical concurrency bug in A2aEventQueue.publish() where the method
iterates over _subscriptions without holding a lock. This causes RuntimeError:
dictionary changed size during iteration when subscribe_local/unsubscribe are
called concurrently from other threads.

The fix introduces a threading.Lock to protect all state mutations and
dictionary access in the A2aEventQueue class, while carefully ensuring callbacks
are invoked outside the lock to prevent potential deadlocks.

Changes:
- src/cleveragents/a2a/events.py: Added _lock attribute, protected
  __init__, is_closed, publish, subscribe_local, unsubscribe, get_events,
  and close methods with threading.Lock snapshot pattern for callbacks.

- features/a2a_event_queue_concurrency.feature: BDD feature file with 6
  scenarios covering concurrent publish/subscribe/unsubscribe safety.

- features/steps/a2a_event_queue_concurrency_steps.py: Step definitions
  implementing multi-threaded concurrency test harness.

ISSUES CLOSED: #7604
2026-05-08 15:05:49 +00:00
..