test(a2a): cover remaining branch gaps in events.py — EventBusBridge start/stop false paths and empty-details branch #2302

Open
opened 2026-04-03 13:25:53 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: test/a2a-events-coverage-gaps
  • Commit Message: test(a2a): cover remaining branch gaps in events.py
  • Milestone: v3.4.0
  • Parent Epic: #933

Background and Context

src/cleveragents/a2a/events.py has three branch paths that are not exercised by any existing
BDD scenario. The existing coverage work (a2a_events_coverage_r3.feature,
a2a_sse_streaming.feature, security_async.feature, consolidated_misc.feature) covers the
happy paths and most error guards, but three defensive branches remain dark:

  1. EventBusBridge.start() — false branch (line 267): if hasattr(self._event_bus, "subscribe") evaluates to False when the injected bus has no subscribe attribute. This path silently no-ops, which is the correct behaviour for a bus stub, but it is never exercised.

  2. EventBusBridge.stop() — false branch (line 273): if self._subscription is not None evaluates to False when stop() is called on a bridge that was never started (subscription is None). This is a valid lifecycle path (e.g. stop called defensively in a finally block) that is currently uncovered.

  3. EventBusBridge._on_domain_event() — empty-details else branch (line 305): data=dict(details) if details else {} — the else {} branch fires when domain_event.details is falsy (None, {}, or absent). All existing scenarios supply non-empty details, leaving this branch dark.

These gaps prevent the module from reaching the project-mandated ≥97% coverage threshold.

Expected Behavior

All three branch paths are exercised by BDD scenarios in a new feature file
(features/a2a_events_coverage_gaps.feature) with corresponding step definitions in
features/steps/a2a_events_coverage_gaps_steps.py. After this issue is resolved, nox -s coverage_report must report src/cleveragents/a2a/events.py at 100% branch coverage.

Acceptance Criteria

  • A new @mock_only feature file features/a2a_events_coverage_gaps.feature contains three scenarios — one per gap — with descriptive names and correct Gherkin
  • Step definitions in features/steps/a2a_events_coverage_gaps_steps.py implement all steps with a unique step prefix (e.g. aecgap) to avoid collisions with existing step files
  • Scenario 1 exercises EventBusBridge.start() with a bus object that has no subscribe attribute, asserting the bridge starts without error and _subscription remains None
  • Scenario 2 exercises EventBusBridge.stop() called on a bridge that was never started, asserting it completes without error and _subscription remains None
  • Scenario 3 exercises EventBusBridge._on_domain_event() with a domain event whose details attribute is falsy (e.g. None or {}), asserting the published A2aEvent has an empty data dict
  • nox (all default sessions) passes with no errors
  • Coverage for src/cleveragents/a2a/events.py reaches 100% branch coverage (verified via nox -s coverage_report)
  • No production source code in src/ is modified — changes are confined to features/

Supporting Information

  • Source file: src/cleveragents/a2a/events.py
  • Existing coverage feature files for context:
    • features/a2a_events_coverage_r3.feature — covers lines 63, 73-76, 82, 91, 100, 126, 234-238, 244, 250, 258
    • features/a2a_sse_streaming.feature — covers SseEventFormatter, EventBusBridge happy paths (enum .value branch), and CHECKPOINT_RESTORED artifact path
    • features/security_async.feature — covers publish-after-close (RuntimeError), is_closed property
    • features/consolidated_misc.feature — covers unsubscribe success/failure return values
  • Parent Epic: #933 (A2A Protocol Compliance)
  • Coverage threshold: ≥97% (project-wide); this module should reach 100%

Subtasks

  • Create features/a2a_events_coverage_gaps.feature with @mock_only tag and three scenarios
  • Create features/steps/a2a_events_coverage_gaps_steps.py with all step definitions using aecgap prefix
  • Scenario 1: EventBusBridge.start() with a bus lacking subscribe attribute
  • Scenario 2: EventBusBridge.stop() called without prior start()
  • Scenario 3: EventBusBridge._on_domain_event() with falsy details (empty-data branch)
  • Run nox -s behave to confirm all new scenarios pass
  • Verify coverage ≥97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly (test(a2a): cover remaining branch gaps in events.py), followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly (test/a2a-events-coverage-gaps).
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • All nox stages pass.
  • Coverage ≥ 97%.

Automated by CleverAgents Bot
Supervisor: Unknown | Agent: ca-new-issue-creator

## Metadata - **Branch**: `test/a2a-events-coverage-gaps` - **Commit Message**: `test(a2a): cover remaining branch gaps in events.py` - **Milestone**: v3.4.0 - **Parent Epic**: #933 ## Background and Context `src/cleveragents/a2a/events.py` has three branch paths that are not exercised by any existing BDD scenario. The existing coverage work (`a2a_events_coverage_r3.feature`, `a2a_sse_streaming.feature`, `security_async.feature`, `consolidated_misc.feature`) covers the happy paths and most error guards, but three defensive branches remain dark: 1. **`EventBusBridge.start()` — false branch** (line 267): `if hasattr(self._event_bus, "subscribe")` evaluates to `False` when the injected bus has no `subscribe` attribute. This path silently no-ops, which is the correct behaviour for a bus stub, but it is never exercised. 2. **`EventBusBridge.stop()` — false branch** (line 273): `if self._subscription is not None` evaluates to `False` when `stop()` is called on a bridge that was never started (subscription is `None`). This is a valid lifecycle path (e.g. stop called defensively in a `finally` block) that is currently uncovered. 3. **`EventBusBridge._on_domain_event()` — empty-details else branch** (line 305): `data=dict(details) if details else {}` — the `else {}` branch fires when `domain_event.details` is falsy (`None`, `{}`, or absent). All existing scenarios supply non-empty details, leaving this branch dark. These gaps prevent the module from reaching the project-mandated ≥97% coverage threshold. ## Expected Behavior All three branch paths are exercised by BDD scenarios in a new feature file (`features/a2a_events_coverage_gaps.feature`) with corresponding step definitions in `features/steps/a2a_events_coverage_gaps_steps.py`. After this issue is resolved, `nox -s coverage_report` must report `src/cleveragents/a2a/events.py` at 100% branch coverage. ## Acceptance Criteria - [ ] A new `@mock_only` feature file `features/a2a_events_coverage_gaps.feature` contains three scenarios — one per gap — with descriptive names and correct Gherkin - [ ] Step definitions in `features/steps/a2a_events_coverage_gaps_steps.py` implement all steps with a unique step prefix (e.g. `aecgap`) to avoid collisions with existing step files - [ ] Scenario 1 exercises `EventBusBridge.start()` with a bus object that has **no** `subscribe` attribute, asserting the bridge starts without error and `_subscription` remains `None` - [ ] Scenario 2 exercises `EventBusBridge.stop()` called on a bridge that was **never started**, asserting it completes without error and `_subscription` remains `None` - [ ] Scenario 3 exercises `EventBusBridge._on_domain_event()` with a domain event whose `details` attribute is falsy (e.g. `None` or `{}`), asserting the published `A2aEvent` has an empty `data` dict - [ ] `nox` (all default sessions) passes with no errors - [ ] Coverage for `src/cleveragents/a2a/events.py` reaches 100% branch coverage (verified via `nox -s coverage_report`) - [ ] No production source code in `src/` is modified — changes are confined to `features/` ## Supporting Information - Source file: `src/cleveragents/a2a/events.py` - Existing coverage feature files for context: - `features/a2a_events_coverage_r3.feature` — covers lines 63, 73-76, 82, 91, 100, 126, 234-238, 244, 250, 258 - `features/a2a_sse_streaming.feature` — covers `SseEventFormatter`, `EventBusBridge` happy paths (enum `.value` branch), and `CHECKPOINT_RESTORED` artifact path - `features/security_async.feature` — covers `publish`-after-close (`RuntimeError`), `is_closed` property - `features/consolidated_misc.feature` — covers `unsubscribe` success/failure return values - Parent Epic: #933 (A2A Protocol Compliance) - Coverage threshold: ≥97% (project-wide); this module should reach 100% ## Subtasks - [ ] Create `features/a2a_events_coverage_gaps.feature` with `@mock_only` tag and three scenarios - [ ] Create `features/steps/a2a_events_coverage_gaps_steps.py` with all step definitions using `aecgap` prefix - [ ] Scenario 1: `EventBusBridge.start()` with a bus lacking `subscribe` attribute - [ ] Scenario 2: `EventBusBridge.stop()` called without prior `start()` - [ ] Scenario 3: `EventBusBridge._on_domain_event()` with falsy `details` (empty-data branch) - [ ] Run `nox -s behave` to confirm all new scenarios pass - [ ] Verify coverage ≥97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly (`test(a2a): cover remaining branch gaps in events.py`), followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly (`test/a2a-events-coverage-gaps`). - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - All nox stages pass. - Coverage ≥ 97%. --- **Automated by CleverAgents Bot** Supervisor: Unknown | Agent: ca-new-issue-creator
freemo added this to the v3.4.0 milestone 2026-04-03 13:26:26 +00:00
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.

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