UAT: agents plan rollback restores sandbox but does NOT reset plan phase/state, leaving plan in inconsistent state #3716

Open
opened 2026-04-05 22:17:22 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/plan-rollback-state-reset
  • Commit Message: fix(plan): reset plan phase/state to Execute/QUEUED after sandbox rollback
  • Milestone: None (Backlog)
  • Parent Epic: #362

Background and Context

The agents plan rollback <PLAN_ID> <CHECKPOINT_ID> CLI command (implemented in src/cleveragents/cli/commands/plan.py lines 3533–3795) calls checkpoint_service.selective_rollback() which restores the sandbox state to the checkpoint. However, it does NOT call any PlanLifecycleService method to reset the plan's phase/processing_state.

The specification (docs/specification.md line 16087–16091) shows that after a successful rollback, the plan should be in:

Phase: execute
State: queued (awaiting input)

But the current implementation leaves the plan in whatever phase/state it was in before the rollback (e.g., Apply/PROCESSING, Apply/QUEUED, Execute/PROCESSING). This creates an inconsistency between the sandbox state (rolled back to checkpoint) and the plan's lifecycle state (not reset).

This was discovered during UAT testing of the Plan Lifecycle feature area.

Current Behavior

After agents plan rollback PLAN_ID CHECKPOINT_ID:

  1. checkpoint_service.selective_rollback() restores sandbox files to checkpoint state ✓
  2. The CLI renders "Rollback Summary", "Changes Reverted", "Impact", "Post-Rollback State" panels ✓
  3. BUT: The plan's phase and processing_state are NOT updated
  4. The plan remains in its pre-rollback state (e.g., Apply/PROCESSING)
  5. The "Post-Rollback State" panel shows phase = getattr(result, "phase", None) or "execute" — this is a fallback default, not the actual plan state

The RollbackResult object from selective_rollback does not contain phase or state attributes, so the CLI always falls back to displaying "execute" and "queued" — but these are not the actual plan states.

Expected Behavior

After agents plan rollback:

  1. Sandbox is restored to checkpoint state ✓
  2. Plan's phase is reset to PlanPhase.EXECUTE (or the phase at checkpoint time)
  3. Plan's processing_state is reset to ProcessingState.QUEUED
  4. The plan's decision_root_id and related fields are reset to checkpoint state
  5. The "Post-Rollback State" panel shows the actual plan state, not a hardcoded fallback

Steps to Reproduce

  1. Create a plan and run it through Execute phase
  2. Create a checkpoint during Execute
  3. Continue execution to Apply phase
  4. Run agents plan rollback <PLAN_ID> <CHECKPOINT_ID>
  5. Observe: CLI reports "Phase: execute, State: queued" but plan.phase is still APPLY

Code Location

  • File: src/cleveragents/cli/commands/plan.py
  • Lines: 3671–3795 (rollback_plan CLI handler)
  • Related: src/cleveragents/application/services/checkpoint_service.py (selective_rollback)
  • Related: src/cleveragents/application/services/plan_lifecycle_service.py (revert_plan)

Subtasks

  • After selective_rollback succeeds, call lifecycle_service.revert_plan(plan_id, PlanPhase.EXECUTE) to reset plan state
  • Update RollbackResult to include actual post-rollback phase and state
  • Update CLI to display actual plan state from lifecycle service, not hardcoded fallback
  • Add/update unit test in features/ to verify plan state is reset after rollback
  • Verify nox -e unit_tests passes
  • Verify nox -e typecheck passes

Definition of Done

  • After agents plan rollback, plan phase/state is reset to Execute/QUEUED
  • "Post-Rollback State" panel shows actual plan state
  • Unit test coverage for post-rollback state reset
  • All nox quality gates pass (nox -e lint, nox -e typecheck, nox -e unit_tests, nox -e coverage_report ≥ 97%)
  • PR merged

Backlog note: This issue was discovered during autonomous operation
on milestone v3.3.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


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

## Metadata - **Branch**: `fix/plan-rollback-state-reset` - **Commit Message**: `fix(plan): reset plan phase/state to Execute/QUEUED after sandbox rollback` - **Milestone**: None (Backlog) - **Parent Epic**: #362 ## Background and Context The `agents plan rollback <PLAN_ID> <CHECKPOINT_ID>` CLI command (implemented in `src/cleveragents/cli/commands/plan.py` lines 3533–3795) calls `checkpoint_service.selective_rollback()` which restores the sandbox state to the checkpoint. However, it does NOT call any `PlanLifecycleService` method to reset the plan's phase/processing_state. The specification (docs/specification.md line 16087–16091) shows that after a successful rollback, the plan should be in: ``` Phase: execute State: queued (awaiting input) ``` But the current implementation leaves the plan in whatever phase/state it was in before the rollback (e.g., Apply/PROCESSING, Apply/QUEUED, Execute/PROCESSING). This creates an inconsistency between the sandbox state (rolled back to checkpoint) and the plan's lifecycle state (not reset). This was discovered during UAT testing of the Plan Lifecycle feature area. ## Current Behavior After `agents plan rollback PLAN_ID CHECKPOINT_ID`: 1. `checkpoint_service.selective_rollback()` restores sandbox files to checkpoint state ✓ 2. The CLI renders "Rollback Summary", "Changes Reverted", "Impact", "Post-Rollback State" panels ✓ 3. **BUT**: The plan's `phase` and `processing_state` are NOT updated 4. The plan remains in its pre-rollback state (e.g., Apply/PROCESSING) 5. The "Post-Rollback State" panel shows `phase = getattr(result, "phase", None) or "execute"` — this is a fallback default, not the actual plan state The `RollbackResult` object from `selective_rollback` does not contain `phase` or `state` attributes, so the CLI always falls back to displaying `"execute"` and `"queued"` — but these are not the actual plan states. ## Expected Behavior After `agents plan rollback`: 1. Sandbox is restored to checkpoint state ✓ 2. Plan's `phase` is reset to `PlanPhase.EXECUTE` (or the phase at checkpoint time) 3. Plan's `processing_state` is reset to `ProcessingState.QUEUED` 4. The plan's `decision_root_id` and related fields are reset to checkpoint state 5. The "Post-Rollback State" panel shows the actual plan state, not a hardcoded fallback ## Steps to Reproduce 1. Create a plan and run it through Execute phase 2. Create a checkpoint during Execute 3. Continue execution to Apply phase 4. Run `agents plan rollback <PLAN_ID> <CHECKPOINT_ID>` 5. Observe: CLI reports "Phase: execute, State: queued" but `plan.phase` is still APPLY ## Code Location - **File**: `src/cleveragents/cli/commands/plan.py` - **Lines**: 3671–3795 (rollback_plan CLI handler) - **Related**: `src/cleveragents/application/services/checkpoint_service.py` (selective_rollback) - **Related**: `src/cleveragents/application/services/plan_lifecycle_service.py` (revert_plan) ## Subtasks - [ ] After `selective_rollback` succeeds, call `lifecycle_service.revert_plan(plan_id, PlanPhase.EXECUTE)` to reset plan state - [ ] Update `RollbackResult` to include actual post-rollback phase and state - [ ] Update CLI to display actual plan state from lifecycle service, not hardcoded fallback - [ ] Add/update unit test in `features/` to verify plan state is reset after rollback - [ ] Verify `nox -e unit_tests` passes - [ ] Verify `nox -e typecheck` passes ## Definition of Done - [ ] After `agents plan rollback`, plan phase/state is reset to Execute/QUEUED - [ ] "Post-Rollback State" panel shows actual plan state - [ ] Unit test coverage for post-rollback state reset - [ ] All nox quality gates pass (`nox -e lint`, `nox -e typecheck`, `nox -e unit_tests`, `nox -e coverage_report` ≥ 97%) - [ ] PR merged > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.3.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
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#3716
No description provided.