UAT: execute_revert never supersedes decisions in the tree — CorrectionService not wired to DecisionService, affected decisions remain active after correction #3113

Open
opened 2026-04-05 06:23:14 +00:00 by freemo · 1 comment
Owner

Summary

CorrectionService.execute_revert() computes the affected subtree (decisions to invalidate) but never actually marks those decisions as superseded in the database. The CorrectionService is not wired to DecisionService in the DI container, so it has no way to call DecisionService.mark_superseded(). After a revert correction, all affected decisions remain active and visible in the decision tree — the correction has no effect on the tree structure.

Metadata

  • Branch: fix/correction-service-wire-decision-service-supersede
  • Commit Message: fix(correction): wire DecisionService into CorrectionService and supersede affected decisions on revert
  • Milestone: v3.2.0
  • Parent Epic: #394

Subtasks

  • Add decision_service: DecisionService parameter to CorrectionService.__init__()
  • Update DI container (application/container.py) to inject decision_service into CorrectionService
  • In execute_revert(), call decision_service.mark_superseded() for each decision in impact.affected_decisions
  • Add Behave unit test verifying decisions are marked superseded after revert
  • Add Robot Framework integration test verifying the decision tree reflects supersession after correction

Definition of Done

  • After agents plan correct <id> --mode revert --guidance "..." --yes, all affected decisions have superseded_by set in the database
  • agents plan tree <plan_id> no longer shows superseded decisions as active
  • All existing tests pass
  • All nox stages pass
  • Coverage >= 97%

Bug Details

What was tested

Code analysis of:

  • src/cleveragents/application/services/correction_service.pyexecute_revert() method
  • src/cleveragents/application/container.pyCorrectionService DI registration (lines 836–840)
  • src/cleveragents/application/services/decision_service.pymark_superseded() method (lines 644–720)

Expected behavior (from spec § Correction Flow, Revert Mode)

Supersede affected subtree: Mark the target decision and all its descendants as superseded (cascading via ADR-034). Decisions above the target remain active and unchanged.

Actual behavior

CorrectionService is registered in the DI container without DecisionService:

# application/container.py lines 836-840
correction_service = providers.Singleton(
    CorrectionService,
    checkpoint_service=checkpoint_service,
    event_bus=event_bus,
    # decision_service= is MISSING
)

execute_revert() computes impact.affected_decisions but never calls mark_superseded():

# correction_service.py lines 510-519
result = CorrectionResult(
    correction_id=correction_id,
    status=CorrectionStatus.APPLIED,
    reverted_decisions=impact.affected_decisions,  # ← computed but never persisted
    ...
)
# No call to decision_service.mark_superseded() anywhere in execute_revert()

DecisionService.mark_superseded() exists and is fully implemented (lines 644–720) but is never called by the correction flow.

Code locations

  • src/cleveragents/application/services/correction_service.py, method execute_revert(), lines 411–557
  • src/cleveragents/application/container.py, lines 836–840
  • src/cleveragents/application/services/decision_service.py, method mark_superseded(), lines 644–720

Steps to reproduce

  1. Create a plan with a multi-node decision tree
  2. Run: agents plan correct <decision_id> --mode revert --guidance "test" --yes
  3. Run: agents plan tree <plan_id>
  4. Observe that all decisions still appear as active — none are marked as superseded

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

## Summary `CorrectionService.execute_revert()` computes the affected subtree (decisions to invalidate) but never actually marks those decisions as superseded in the database. The `CorrectionService` is not wired to `DecisionService` in the DI container, so it has no way to call `DecisionService.mark_superseded()`. After a revert correction, all affected decisions remain active and visible in the decision tree — the correction has no effect on the tree structure. ## Metadata - **Branch**: `fix/correction-service-wire-decision-service-supersede` - **Commit Message**: `fix(correction): wire DecisionService into CorrectionService and supersede affected decisions on revert` - **Milestone**: v3.2.0 - **Parent Epic**: #394 ## Subtasks - [ ] Add `decision_service: DecisionService` parameter to `CorrectionService.__init__()` - [ ] Update DI container (`application/container.py`) to inject `decision_service` into `CorrectionService` - [ ] In `execute_revert()`, call `decision_service.mark_superseded()` for each decision in `impact.affected_decisions` - [ ] Add Behave unit test verifying decisions are marked superseded after revert - [ ] Add Robot Framework integration test verifying the decision tree reflects supersession after correction ## Definition of Done - [ ] After `agents plan correct <id> --mode revert --guidance "..." --yes`, all affected decisions have `superseded_by` set in the database - [ ] `agents plan tree <plan_id>` no longer shows superseded decisions as active - [ ] All existing tests pass - [ ] All nox stages pass - [ ] Coverage >= 97% ## Bug Details ### What was tested Code analysis of: - `src/cleveragents/application/services/correction_service.py` — `execute_revert()` method - `src/cleveragents/application/container.py` — `CorrectionService` DI registration (lines 836–840) - `src/cleveragents/application/services/decision_service.py` — `mark_superseded()` method (lines 644–720) ### Expected behavior (from spec § Correction Flow, Revert Mode) > **Supersede affected subtree**: Mark the target decision and all its descendants as superseded (cascading via ADR-034). Decisions above the target remain active and unchanged. ### Actual behavior `CorrectionService` is registered in the DI container **without** `DecisionService`: ```python # application/container.py lines 836-840 correction_service = providers.Singleton( CorrectionService, checkpoint_service=checkpoint_service, event_bus=event_bus, # decision_service= is MISSING ) ``` `execute_revert()` computes `impact.affected_decisions` but never calls `mark_superseded()`: ```python # correction_service.py lines 510-519 result = CorrectionResult( correction_id=correction_id, status=CorrectionStatus.APPLIED, reverted_decisions=impact.affected_decisions, # ← computed but never persisted ... ) # No call to decision_service.mark_superseded() anywhere in execute_revert() ``` `DecisionService.mark_superseded()` exists and is fully implemented (lines 644–720) but is never called by the correction flow. ### Code locations - `src/cleveragents/application/services/correction_service.py`, method `execute_revert()`, lines 411–557 - `src/cleveragents/application/container.py`, lines 836–840 - `src/cleveragents/application/services/decision_service.py`, method `mark_superseded()`, lines 644–720 ### Steps to reproduce 1. Create a plan with a multi-node decision tree 2. Run: `agents plan correct <decision_id> --mode revert --guidance "test" --yes` 3. Run: `agents plan tree <plan_id>` 4. Observe that all decisions still appear as active — none are marked as superseded --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.2.0 milestone 2026-04-05 06:23:23 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Critical (keeping existing — this directly blocks v3.2.0 acceptance criteria)
  • Milestone: v3.2.0 (already assigned, keeping)
  • MoSCoW: Must Have — v3.2.0 acceptance criteria explicitly requires "Correction in revert mode re-executes from decision point." Without decision supersession, the correction flow is non-functional.
  • Parent Epic: #394 (Decision Framework)

This is part of a cluster of critical correction-flow bugs (#3107, #3108, #3109, #3113, #3114) that collectively indicate the correction subsystem is incomplete. These should be prioritized as a group.


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

Issue triaged by project owner: - **State**: Verified - **Priority**: Critical (keeping existing — this directly blocks v3.2.0 acceptance criteria) - **Milestone**: v3.2.0 (already assigned, keeping) - **MoSCoW**: Must Have — v3.2.0 acceptance criteria explicitly requires "Correction in revert mode re-executes from decision point." Without decision supersession, the correction flow is non-functional. - **Parent Epic**: #394 (Decision Framework) This is part of a cluster of critical correction-flow bugs (#3107, #3108, #3109, #3113, #3114) that collectively indicate the correction subsystem is incomplete. These should be prioritized as a group. --- **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
#394 Epic: Decision Framework
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3113
No description provided.