UAT: AutomationProfileService missing switch() method required by spec for A2A session/set_mode operation #2097

Open
opened 2026-04-03 04:02:40 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/automation-profile-service-switch-method
  • Commit Message: fix(automation-profile-service): add switch() method for A2A session/set_mode operation
  • Milestone: v3.7.0
  • Parent Epic: #362

Background and Context

The specification maps the A2A session/set_mode operation to AutomationProfileService.switch() (see docs/specification.md line 43252, A2A Session Operations table). This method does not exist in the AutomationProfileService class, meaning the A2A session/set_mode operation cannot be routed to the service as the spec requires. Clients are therefore unable to dynamically change the automation profile for a running session via the A2A protocol.

Current Behavior

In src/cleveragents/application/services/automation_profile_service.py, the AutomationProfileService class exposes the following methods:

  • resolve_profile() — resolves profile by precedence
  • get_profile() — looks up a profile by name
  • list_profiles() — lists all profiles
  • create_profile() — creates a custom profile
  • update_profile() — updates a custom profile
  • delete_profile() — deletes a custom profile
  • evaluate_guard() — evaluates guard constraints
  • get_effective_profile() — convenience wrapper for resolve_profile
  • from_yaml() — static factory

There is no switch() method. Calling service.switch(...) raises AttributeError.

Steps to Reproduce:

from cleveragents.application.services.automation_profile_service import AutomationProfileService
service = AutomationProfileService()
# The following raises AttributeError:
service.switch("trusted", session_id="session-123")

Expected Behavior

Per docs/specification.md line 43252 (A2A Session Operations table):

| `session/set_mode` | `AutomationProfileService.switch()` |

AutomationProfileService must expose a switch() method that allows changing the active automation profile for a running session. The method should:

  1. Accept a profile name and session identifier
  2. Validate the profile exists (raise NotFoundError if not)
  3. Update the active automation profile for the specified session
  4. Return the newly active AutomationProfile

Approximate method signature:

def switch(
    self,
    profile_name: str,
    session_id: str,
) -> AutomationProfile:
    """Switch the active automation profile for a session.

    Used by the A2A session/set_mode operation.

    Args:
        profile_name: Name of the profile to switch to.
        session_id: The session identifier.

    Returns:
        The newly active AutomationProfile.

    Raises:
        NotFoundError: If the profile does not exist.
        ValidationError: If profile_name or session_id is empty.
    """

Impact

  • The A2A session/set_mode operation cannot be implemented without this method
  • Clients cannot dynamically change the automation profile for a running session via the A2A protocol
  • The server mode implementation is blocked on this missing method

Acceptance Criteria

  • AutomationProfileService.switch(profile_name, session_id) exists and is callable
  • Raises NotFoundError when the given profile name does not exist
  • Raises ValidationError when profile_name or session_id is empty/blank
  • Returns the newly active AutomationProfile on success
  • The A2A session/set_mode handler can route to AutomationProfileService.switch() without error
  • All existing AutomationProfileService tests continue to pass

Supporting Information

  • Spec reference: docs/specification.md line 43252 (A2A Session Operations table)
  • Implementation file: src/cleveragents/application/services/automation_profile_service.py
  • Parent Epic: #362 (Security & Safety Hardening)

Subtasks

  • Add switch(profile_name: str, session_id: str) -> AutomationProfile method to AutomationProfileService
  • Implement profile existence validation (raise NotFoundError if profile not found)
  • Implement input validation (raise ValidationError if profile_name or session_id is empty)
  • Wire session/set_mode A2A handler to AutomationProfileService.switch()
  • Tests (unit): Add unit tests for switch() covering happy path, NotFoundError, and ValidationError
  • Tests (Behave): Add BDD scenarios for session/set_mode routing to switch()
  • Tests (Robot): Add integration test for A2A session/set_mode end-to-end
  • 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 (fix(automation-profile-service): add switch() method for A2A session/set_mode operation), 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 (fix/automation-profile-service-switch-method).
  • 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: UAT Testing | Agent: ca-uat-tester

## Metadata - **Branch**: `fix/automation-profile-service-switch-method` - **Commit Message**: `fix(automation-profile-service): add switch() method for A2A session/set_mode operation` - **Milestone**: v3.7.0 - **Parent Epic**: #362 ## Background and Context The specification maps the A2A `session/set_mode` operation to `AutomationProfileService.switch()` (see `docs/specification.md` line 43252, A2A Session Operations table). This method does not exist in the `AutomationProfileService` class, meaning the A2A `session/set_mode` operation cannot be routed to the service as the spec requires. Clients are therefore unable to dynamically change the automation profile for a running session via the A2A protocol. ## Current Behavior In `src/cleveragents/application/services/automation_profile_service.py`, the `AutomationProfileService` class exposes the following methods: - `resolve_profile()` — resolves profile by precedence - `get_profile()` — looks up a profile by name - `list_profiles()` — lists all profiles - `create_profile()` — creates a custom profile - `update_profile()` — updates a custom profile - `delete_profile()` — deletes a custom profile - `evaluate_guard()` — evaluates guard constraints - `get_effective_profile()` — convenience wrapper for `resolve_profile` - `from_yaml()` — static factory There is **no `switch()` method**. Calling `service.switch(...)` raises `AttributeError`. **Steps to Reproduce:** ```python from cleveragents.application.services.automation_profile_service import AutomationProfileService service = AutomationProfileService() # The following raises AttributeError: service.switch("trusted", session_id="session-123") ``` ## Expected Behavior Per `docs/specification.md` line 43252 (A2A Session Operations table): ``` | `session/set_mode` | `AutomationProfileService.switch()` | ``` `AutomationProfileService` must expose a `switch()` method that allows changing the active automation profile for a running session. The method should: 1. Accept a profile name and session identifier 2. Validate the profile exists (raise `NotFoundError` if not) 3. Update the active automation profile for the specified session 4. Return the newly active `AutomationProfile` Approximate method signature: ```python def switch( self, profile_name: str, session_id: str, ) -> AutomationProfile: """Switch the active automation profile for a session. Used by the A2A session/set_mode operation. Args: profile_name: Name of the profile to switch to. session_id: The session identifier. Returns: The newly active AutomationProfile. Raises: NotFoundError: If the profile does not exist. ValidationError: If profile_name or session_id is empty. """ ``` ## Impact - The A2A `session/set_mode` operation cannot be implemented without this method - Clients cannot dynamically change the automation profile for a running session via the A2A protocol - The server mode implementation is blocked on this missing method ## Acceptance Criteria - `AutomationProfileService.switch(profile_name, session_id)` exists and is callable - Raises `NotFoundError` when the given profile name does not exist - Raises `ValidationError` when `profile_name` or `session_id` is empty/blank - Returns the newly active `AutomationProfile` on success - The A2A `session/set_mode` handler can route to `AutomationProfileService.switch()` without error - All existing `AutomationProfileService` tests continue to pass ## Supporting Information - Spec reference: `docs/specification.md` line 43252 (A2A Session Operations table) - Implementation file: `src/cleveragents/application/services/automation_profile_service.py` - Parent Epic: #362 (Security & Safety Hardening) ## Subtasks - [ ] Add `switch(profile_name: str, session_id: str) -> AutomationProfile` method to `AutomationProfileService` - [ ] Implement profile existence validation (raise `NotFoundError` if profile not found) - [ ] Implement input validation (raise `ValidationError` if `profile_name` or `session_id` is empty) - [ ] Wire `session/set_mode` A2A handler to `AutomationProfileService.switch()` - [ ] Tests (unit): Add unit tests for `switch()` covering happy path, `NotFoundError`, and `ValidationError` - [ ] Tests (Behave): Add BDD scenarios for `session/set_mode` routing to `switch()` - [ ] Tests (Robot): Add integration test for A2A `session/set_mode` end-to-end - [ ] 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 (`fix(automation-profile-service): add switch() method for A2A session/set_mode operation`), 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 (`fix/automation-profile-service-switch-method`). - 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: UAT Testing | Agent: ca-uat-tester
freemo added this to the v3.7.0 milestone 2026-04-03 04:02:48 +00:00
freemo self-assigned this 2026-04-03 16:58:07 +00:00
Author
Owner

MoSCoW classification: Should Have

Rationale: This issue addresses a spec requirement or important quality improvement. It should be included in the milestone if possible.


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

MoSCoW classification: **Should Have** Rationale: This issue addresses a spec requirement or important quality improvement. It should be included in the milestone if possible. --- **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.

Blocks
#362 Epic: Security & Safety Hardening
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2097
No description provided.