Coverage gap in src/cleveragents/a2a/models.py — validators, factories, and model-validators uncovered (67.7%) #2311

Open
opened 2026-04-03 13:48:54 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: test/a2a-models-coverage
  • Commit Message: test(a2a): add BDD scenarios covering models.py validators, factories, and model-validators
  • Milestone: v3.8.0
  • Parent Epic: #933

Background and Context

A coverage analysis of src/cleveragents/a2a/models.py reveals that the file sits at 67.7% line coverage (63 covered, 30 missing out of 93 executable lines), well below the project-mandated threshold of ≥ 97%. The uncovered lines span three categories:

  1. Helper factories (_ulid_factory, _iso_now_factory) — lines 47, 52 — never exercised directly.
  2. Field validators — the @field_validator bodies for A2aErrorDetail, A2aRequest, A2aResponse, and A2aEvent that raise ValueError on invalid input are never triggered by any existing scenario (lines 76–78, 104–106, 111–113, 145–147, 173–175).
  3. Model validators — the @model_validator bodies for A2aRequest._default_id, A2aResponse._result_xor_error, and A2aEvent._set_defaults are not exercised for their branching paths (lines 117–119, 152–156, 179–183).

The models.py module is the foundational wire-format layer for the entire A2A protocol stack (spec §Overview — A2A Standard, §Glossary — A2A). Every other A2A component (facade, transport, events, errors) depends on these models. Leaving their validation logic untested creates a silent risk of regressions in the JSON-RPC 2.0 compliance layer.

Current Behavior

Running nox -s coverage_report reports src/cleveragents/a2a/models.py at 67.74% coverage. The following lines are not executed by any test scenario:

Lines Description
47, 52 _ulid_factory() and _iso_now_factory() helper bodies
76–78 A2aErrorDetail._must_be_non_empty — empty-string rejection branch
104–106 A2aRequest._jsonrpc_must_be_2_0 — wrong-version rejection branch
111–113 A2aRequest._method_non_empty — empty/whitespace method rejection branch
117–119 A2aRequest._default_id — auto-ULID assignment when id is empty
145–147 A2aResponse._jsonrpc_must_be_2_0 — wrong-version rejection branch
152–156 A2aResponse._result_xor_error — both-None and both-set rejection branches
173–175 A2aEvent._event_type_non_empty — empty/whitespace event_type rejection branch
179–183 A2aEvent._set_defaults — auto-ULID and auto-timestamp assignment branches

Expected Behavior

src/cleveragents/a2a/models.py must reach ≥ 97% line coverage with all validator and model-validator branches exercised by BDD scenarios in Gherkin/Behave.

Acceptance Criteria

  • All @field_validator error branches in A2aErrorDetail, A2aRequest, A2aResponse, and A2aEvent are exercised by dedicated BDD scenarios that assert the correct ValueError is raised.
  • Both branches of A2aResponse._result_xor_error (neither set, both set) are covered.
  • The auto-ULID path in A2aRequest._default_id (empty id on construction) is covered.
  • The auto-ULID and auto-timestamp paths in A2aEvent._set_defaults (empty event_id and empty timestamp on construction) are covered.
  • The _ulid_factory() and _iso_now_factory() helper functions are exercised.
  • nox -s coverage_report reports src/cleveragents/a2a/models.py at ≥ 97%.
  • All nox default sessions pass without error.

Subtasks

  • Create features/a2a_models_coverage.feature with Gherkin scenarios for all uncovered branches
  • Implement step definitions in features/steps/a2a_models_coverage_steps.py
  • Scenario: A2aErrorDetail rejects empty code field
  • Scenario: A2aErrorDetail rejects empty message field
  • Scenario: A2aRequest rejects non-"2.0" jsonrpc value
  • Scenario: A2aRequest rejects empty method
  • Scenario: A2aRequest rejects whitespace-only method
  • Scenario: A2aRequest auto-assigns a ULID id when constructed without one
  • Scenario: A2aResponse rejects non-"2.0" jsonrpc value
  • Scenario: A2aResponse raises when both result and error are None
  • Scenario: A2aResponse raises when both result and error are set
  • Scenario: A2aEvent rejects empty event_type
  • Scenario: A2aEvent rejects whitespace-only event_type
  • Scenario: A2aEvent auto-assigns event_id and timestamp when constructed without them
  • Verify nox -s coverage_report shows src/cleveragents/a2a/models.py ≥ 97%
  • Run nox (all default sessions) and fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • src/cleveragents/a2a/models.py reports ≥ 97% line coverage via nox -s coverage_report.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, 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.
  • 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-models-coverage` - **Commit Message**: `test(a2a): add BDD scenarios covering models.py validators, factories, and model-validators` - **Milestone**: v3.8.0 - **Parent Epic**: #933 ## Background and Context A coverage analysis of `src/cleveragents/a2a/models.py` reveals that the file sits at **67.7% line coverage** (63 covered, 30 missing out of 93 executable lines), well below the project-mandated threshold of **≥ 97%**. The uncovered lines span three categories: 1. **Helper factories** (`_ulid_factory`, `_iso_now_factory`) — lines 47, 52 — never exercised directly. 2. **Field validators** — the `@field_validator` bodies for `A2aErrorDetail`, `A2aRequest`, `A2aResponse`, and `A2aEvent` that raise `ValueError` on invalid input are never triggered by any existing scenario (lines 76–78, 104–106, 111–113, 145–147, 173–175). 3. **Model validators** — the `@model_validator` bodies for `A2aRequest._default_id`, `A2aResponse._result_xor_error`, and `A2aEvent._set_defaults` are not exercised for their branching paths (lines 117–119, 152–156, 179–183). The `models.py` module is the foundational wire-format layer for the entire A2A protocol stack (spec §Overview — A2A Standard, §Glossary — A2A). Every other A2A component (`facade`, `transport`, `events`, `errors`) depends on these models. Leaving their validation logic untested creates a silent risk of regressions in the JSON-RPC 2.0 compliance layer. ## Current Behavior Running `nox -s coverage_report` reports `src/cleveragents/a2a/models.py` at **67.74%** coverage. The following lines are not executed by any test scenario: | Lines | Description | |---|---| | 47, 52 | `_ulid_factory()` and `_iso_now_factory()` helper bodies | | 76–78 | `A2aErrorDetail._must_be_non_empty` — empty-string rejection branch | | 104–106 | `A2aRequest._jsonrpc_must_be_2_0` — wrong-version rejection branch | | 111–113 | `A2aRequest._method_non_empty` — empty/whitespace method rejection branch | | 117–119 | `A2aRequest._default_id` — auto-ULID assignment when `id` is empty | | 145–147 | `A2aResponse._jsonrpc_must_be_2_0` — wrong-version rejection branch | | 152–156 | `A2aResponse._result_xor_error` — both-None and both-set rejection branches | | 173–175 | `A2aEvent._event_type_non_empty` — empty/whitespace event_type rejection branch | | 179–183 | `A2aEvent._set_defaults` — auto-ULID and auto-timestamp assignment branches | ## Expected Behavior `src/cleveragents/a2a/models.py` must reach **≥ 97% line coverage** with all validator and model-validator branches exercised by BDD scenarios in Gherkin/Behave. ## Acceptance Criteria - [ ] All `@field_validator` error branches in `A2aErrorDetail`, `A2aRequest`, `A2aResponse`, and `A2aEvent` are exercised by dedicated BDD scenarios that assert the correct `ValueError` is raised. - [ ] Both branches of `A2aResponse._result_xor_error` (neither set, both set) are covered. - [ ] The auto-ULID path in `A2aRequest._default_id` (empty `id` on construction) is covered. - [ ] The auto-ULID and auto-timestamp paths in `A2aEvent._set_defaults` (empty `event_id` and empty `timestamp` on construction) are covered. - [ ] The `_ulid_factory()` and `_iso_now_factory()` helper functions are exercised. - [ ] `nox -s coverage_report` reports `src/cleveragents/a2a/models.py` at **≥ 97%**. - [ ] All nox default sessions pass without error. ## Subtasks - [ ] Create `features/a2a_models_coverage.feature` with Gherkin scenarios for all uncovered branches - [ ] Implement step definitions in `features/steps/a2a_models_coverage_steps.py` - [ ] Scenario: `A2aErrorDetail` rejects empty `code` field - [ ] Scenario: `A2aErrorDetail` rejects empty `message` field - [ ] Scenario: `A2aRequest` rejects non-`"2.0"` `jsonrpc` value - [ ] Scenario: `A2aRequest` rejects empty `method` - [ ] Scenario: `A2aRequest` rejects whitespace-only `method` - [ ] Scenario: `A2aRequest` auto-assigns a ULID `id` when constructed without one - [ ] Scenario: `A2aResponse` rejects non-`"2.0"` `jsonrpc` value - [ ] Scenario: `A2aResponse` raises when both `result` and `error` are `None` - [ ] Scenario: `A2aResponse` raises when both `result` and `error` are set - [ ] Scenario: `A2aEvent` rejects empty `event_type` - [ ] Scenario: `A2aEvent` rejects whitespace-only `event_type` - [ ] Scenario: `A2aEvent` auto-assigns `event_id` and `timestamp` when constructed without them - [ ] Verify `nox -s coverage_report` shows `src/cleveragents/a2a/models.py` ≥ 97% - [ ] Run `nox` (all default sessions) and fix any errors ## Definition of Done This issue is complete when: - [ ] All subtasks above are completed and checked off. - [ ] `src/cleveragents/a2a/models.py` reports ≥ 97% line coverage via `nox -s coverage_report`. - [ ] A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, 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. - [ ] 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.8.0 milestone 2026-04-03 13:49:07 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Medium (confirmed) — 67.7% coverage on the A2A models wire-format layer.
  • Milestone: v3.8.0 (confirmed)
  • MoSCoW: Could Have — Coverage gap for A2A models. Important for quality but not blocking current milestones.
  • Parent Epic: #933 (confirmed correct)

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **Priority**: Medium (confirmed) — 67.7% coverage on the A2A models wire-format layer. - **Milestone**: v3.8.0 (confirmed) - **MoSCoW**: Could Have — Coverage gap for A2A models. Important for quality but not blocking current milestones. - **Parent Epic**: #933 (confirmed correct) --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
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#2311
No description provided.