Bug: _cleveragents/plan/correct A2A handler is a stub — always returns "status": "corrected" without calling CorrectionService #2527

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

Metadata

  • Branch: fix/a2a-plan-correct-stub
  • Commit Message: fix(a2a): implement _cleveragents/plan/correct handler via CorrectionService
  • Milestone: v3.8.0
  • Parent Epic: #399

Background and Context

The _cleveragents/plan/correct A2A extension method is part of the A2A facade layer that exposes plan lifecycle operations to A2A clients. Per spec §43268, this method must map to CorrectionFlow.correct(), delegating to CorrectionService.request_correction() and CorrectionService.execute_correction() to apply targeted corrections to the decision tree.

The CLI counterpart (agents plan correct) correctly calls CorrectionService.request_correction() and CorrectionService.execute_correction(). However, the A2A facade handler _handle_plan_correct in src/cleveragents/a2a/facade.py (lines 528–530) is a complete stub that bypasses CorrectionService entirely.

Current Behavior

The handler always returns a hardcoded stub response regardless of input:

{
  "plan_id": "...",
  "status": "corrected",
  "stub": true
}

No correction is applied. CorrectionService (available via container.correction_service()) is never called. The stub code:

def _handle_plan_correct(self, params: dict[str, Any]) -> dict[str, Any]:
    plan_id = params.get("plan_id", "")
    return {"plan_id": plan_id, "status": "corrected", "stub": True}

Location: src/cleveragents/a2a/facade.py, method _handle_plan_correct (lines 528–530)

Expected Behavior

Per spec §43268, the _cleveragents/plan/correct A2A extension method must:

  1. Extract plan_id, target_decision_id, mode (revert or append), and guidance from params
  2. Call CorrectionService.request_correction(plan_id, target_decision_id, mode, guidance) to register the correction intent
  3. Call CorrectionService.execute_correction(correction_id, decision_tree, influence_edges) to apply the correction to the decision tree
  4. Return a result including correction_id, status, new_decisions, and reverted_decisions

The CorrectionService is available at src/cleveragents/application/services/correction_service.py and is accessible via container.correction_service().

Acceptance Criteria

  • _handle_plan_correct extracts all required params: plan_id, target_decision_id, mode, and guidance
  • CorrectionService.request_correction() is called with the correct arguments
  • CorrectionService.execute_correction() is called with the correct arguments
  • The response includes correction_id, status, new_decisions, and reverted_decisions
  • The "stub": True field is removed from the response
  • Both revert and append correction modes work correctly end-to-end via A2A
  • Invalid or missing params raise appropriate A2A error responses
  • All nox stages pass with coverage >= 97%

Supporting Information

  • Related CLI implementation: src/cleveragents/cli/commands/plan.pyagents plan correct command (correct reference implementation)
  • CorrectionService: src/cleveragents/application/services/correction_service.py
  • A2A Facade: src/cleveragents/a2a/facade.py
  • Spec reference: §43268 — _cleveragents/plan/correct extension method mapping
  • Parent Epic: #399 (Epic: Post-MVP Server & Clients)

Subtasks

  • Write TDD issue-capture Behave scenario (@tdd_expected_fail) proving the stub bug exists
  • Implement _handle_plan_correct to extract plan_id, target_decision_id, mode, and guidance from params
  • Call container.correction_service().request_correction(plan_id, target_decision_id, mode, guidance)
  • Call container.correction_service().execute_correction(correction_id, decision_tree, influence_edges)
  • Return response with correction_id, status, new_decisions, and reverted_decisions; remove "stub": True
  • Add argument validation (fail-fast) for required params per project error-handling standards
  • Tests (Behave): Add/update unit scenarios for _handle_plan_correct covering revert mode, append mode, and invalid params
  • Tests (Robot): Add integration test verifying _cleveragents/plan/correct A2A call applies a real correction
  • Verify coverage >= 97% via nox -s coverage_report
  • 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.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly (fix(a2a): implement _cleveragents/plan/correct handler via CorrectionService), 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/a2a-plan-correct-stub).
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • All nox stages pass (nox -e lint, nox -e typecheck, nox -e unit_tests, nox -e integration_tests).
  • Coverage >= 97% confirmed via nox -e coverage_report.
  • The _cleveragents/plan/correct A2A handler no longer returns a stub response and correctly delegates to CorrectionService.

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

## Metadata - **Branch**: `fix/a2a-plan-correct-stub` - **Commit Message**: `fix(a2a): implement _cleveragents/plan/correct handler via CorrectionService` - **Milestone**: v3.8.0 - **Parent Epic**: #399 ## Background and Context The `_cleveragents/plan/correct` A2A extension method is part of the A2A facade layer that exposes plan lifecycle operations to A2A clients. Per spec §43268, this method must map to `CorrectionFlow.correct()`, delegating to `CorrectionService.request_correction()` and `CorrectionService.execute_correction()` to apply targeted corrections to the decision tree. The CLI counterpart (`agents plan correct`) correctly calls `CorrectionService.request_correction()` and `CorrectionService.execute_correction()`. However, the A2A facade handler `_handle_plan_correct` in `src/cleveragents/a2a/facade.py` (lines 528–530) is a complete stub that bypasses `CorrectionService` entirely. ## Current Behavior The handler always returns a hardcoded stub response regardless of input: ```json { "plan_id": "...", "status": "corrected", "stub": true } ``` No correction is applied. `CorrectionService` (available via `container.correction_service()`) is never called. The stub code: ```python def _handle_plan_correct(self, params: dict[str, Any]) -> dict[str, Any]: plan_id = params.get("plan_id", "") return {"plan_id": plan_id, "status": "corrected", "stub": True} ``` **Location**: `src/cleveragents/a2a/facade.py`, method `_handle_plan_correct` (lines 528–530) ## Expected Behavior Per spec §43268, the `_cleveragents/plan/correct` A2A extension method must: 1. Extract `plan_id`, `target_decision_id`, `mode` (`revert` or `append`), and `guidance` from `params` 2. Call `CorrectionService.request_correction(plan_id, target_decision_id, mode, guidance)` to register the correction intent 3. Call `CorrectionService.execute_correction(correction_id, decision_tree, influence_edges)` to apply the correction to the decision tree 4. Return a result including `correction_id`, `status`, `new_decisions`, and `reverted_decisions` The `CorrectionService` is available at `src/cleveragents/application/services/correction_service.py` and is accessible via `container.correction_service()`. ## Acceptance Criteria - [ ] `_handle_plan_correct` extracts all required params: `plan_id`, `target_decision_id`, `mode`, and `guidance` - [ ] `CorrectionService.request_correction()` is called with the correct arguments - [ ] `CorrectionService.execute_correction()` is called with the correct arguments - [ ] The response includes `correction_id`, `status`, `new_decisions`, and `reverted_decisions` - [ ] The `"stub": True` field is removed from the response - [ ] Both `revert` and `append` correction modes work correctly end-to-end via A2A - [ ] Invalid or missing params raise appropriate A2A error responses - [ ] All nox stages pass with coverage >= 97% ## Supporting Information - **Related CLI implementation**: `src/cleveragents/cli/commands/plan.py` — `agents plan correct` command (correct reference implementation) - **CorrectionService**: `src/cleveragents/application/services/correction_service.py` - **A2A Facade**: `src/cleveragents/a2a/facade.py` - **Spec reference**: §43268 — `_cleveragents/plan/correct` extension method mapping - **Parent Epic**: #399 (Epic: Post-MVP Server & Clients) ## Subtasks - [ ] Write TDD issue-capture Behave scenario (`@tdd_expected_fail`) proving the stub bug exists - [ ] Implement `_handle_plan_correct` to extract `plan_id`, `target_decision_id`, `mode`, and `guidance` from `params` - [ ] Call `container.correction_service().request_correction(plan_id, target_decision_id, mode, guidance)` - [ ] Call `container.correction_service().execute_correction(correction_id, decision_tree, influence_edges)` - [ ] Return response with `correction_id`, `status`, `new_decisions`, and `reverted_decisions`; remove `"stub": True` - [ ] Add argument validation (fail-fast) for required params per project error-handling standards - [ ] Tests (Behave): Add/update unit scenarios for `_handle_plan_correct` covering `revert` mode, `append` mode, and invalid params - [ ] Tests (Robot): Add integration test verifying `_cleveragents/plan/correct` A2A call applies a real correction - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] 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. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly (`fix(a2a): implement _cleveragents/plan/correct handler via CorrectionService`), 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/a2a-plan-correct-stub`). - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - All nox stages pass (`nox -e lint`, `nox -e typecheck`, `nox -e unit_tests`, `nox -e integration_tests`). - Coverage >= 97% confirmed via `nox -e coverage_report`. - The `_cleveragents/plan/correct` A2A handler no longer returns a stub response and correctly delegates to `CorrectionService`. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.8.0 milestone 2026-04-03 18:48:30 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: Should Have — Spec compliance or quality improvement.

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

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: Should Have — Spec compliance or quality improvement. --- **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
#399 Epic: Post-MVP Server & Clients
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2527
No description provided.