bug(checkpoint): agents plan rollback does not reset plan processing state to execute/queued after sandbox rollback #3218

Open
opened 2026-04-05 07:55:32 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/plan-rollback-state-reset
  • Commit Message: fix(checkpoint): reset plan state to execute/queued after successful rollback
  • Milestone: (none — backlog)
  • Parent Epic: #368

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.

Description

The agents plan rollback CLI command (rollback_plan in src/cleveragents/cli/commands/plan.py) correctly restores the sandbox via git reset --hard, but does not update the plan's processing state after a successful rollback.

Expected Behavior (from spec, docs/specification.md lines 15995–15999)

Post-Rollback State:
  Phase: execute
  State: queued (awaiting input)
  Checkpoints Remaining: 2

After a successful rollback, the plan must be reset to execute/queued so that execution can resume from the rolled-back point.

Actual Behavior

checkpoint_service.pyselective_rollback / rollback_to_checkpoint:

  1. Correctly restores the sandbox via git reset --hard
  2. Does not update plan.processing_state to QUEUED
  3. Does not update plan.phase

After rollback the plan remains in whatever processing state it held before the rollback (e.g., execute/processing or execute/errored), leaving it in an inconsistent lifecycle state.

Additionally, the post_rollback_state section in the JSON output is incorrect — it shows active_checkpoint instead of the spec-required phase / state / checkpoints_remaining fields.

Impact

  • Sandbox is correctly restored
  • Plan lifecycle state is not updated
  • Users cannot resume execution from the rolled-back point without manually resetting plan state
  • JSON output for post_rollback_state does not match the spec

Steps to Reproduce

  1. Create a plan in execute/processing state
  2. Create a checkpoint
  3. Run agents plan rollback <PLAN_ID> <CHECKPOINT_ID> --yes
  4. Run agents plan status <PLAN_ID>
  5. Observe: plan is still in execute/processing (or pre-rollback state)
  6. Expected: plan should be in execute/queued

Code Locations

  • src/cleveragents/cli/commands/plan.py lines 3394–3447 — rollback_plan function
  • src/cleveragents/application/services/checkpoint_service.py lines 259–368 — rollback_to_checkpoint / selective_rollback

Subtasks

  • Add plan.processing_state = ProcessingState.QUEUED after a successful sandbox rollback in checkpoint_service.py (rollback_to_checkpoint and selective_rollback)
  • Add plan.phase = Phase.EXECUTE (or equivalent) to ensure phase is correct post-rollback
  • Update the post_rollback_state JSON output in rollback_plan CLI to include phase, state, and checkpoints_remaining fields as specified
  • Write Behave unit tests (TDD) covering the post-rollback state transition: execute/processing → execute/queued and execute/errored → execute/queued
  • Write Behave unit tests verifying the post_rollback_state JSON output matches the spec format
  • Verify no regression in existing rollback tests

Definition of Done

  • rollback_to_checkpoint and selective_rollback set plan.processing_state = QUEUED and correct plan.phase after a successful rollback
  • post_rollback_state JSON output matches spec: phase, state, checkpoints_remaining
  • All new and existing Behave unit tests pass (nox -e unit_tests)
  • All nox stages pass
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

## Metadata - **Branch**: `fix/plan-rollback-state-reset` - **Commit Message**: `fix(checkpoint): reset plan state to execute/queued after successful rollback` - **Milestone**: *(none — backlog)* - **Parent Epic**: #368 > **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. ## Description The `agents plan rollback` CLI command (`rollback_plan` in `src/cleveragents/cli/commands/plan.py`) correctly restores the sandbox via `git reset --hard`, but **does not update the plan's processing state** after a successful rollback. ### Expected Behavior (from spec, `docs/specification.md` lines 15995–15999) ``` Post-Rollback State: Phase: execute State: queued (awaiting input) Checkpoints Remaining: 2 ``` After a successful rollback, the plan must be reset to `execute/queued` so that execution can resume from the rolled-back point. ### Actual Behavior `checkpoint_service.py` → `selective_rollback` / `rollback_to_checkpoint`: 1. ✅ Correctly restores the sandbox via `git reset --hard` 2. ❌ Does **not** update `plan.processing_state` to `QUEUED` 3. ❌ Does **not** update `plan.phase` After rollback the plan remains in whatever processing state it held before the rollback (e.g., `execute/processing` or `execute/errored`), leaving it in an inconsistent lifecycle state. Additionally, the `post_rollback_state` section in the JSON output is incorrect — it shows `active_checkpoint` instead of the spec-required `phase / state / checkpoints_remaining` fields. ### Impact - Sandbox is correctly restored ✅ - Plan lifecycle state is **not** updated ❌ - Users cannot resume execution from the rolled-back point without manually resetting plan state - JSON output for `post_rollback_state` does not match the spec ### Steps to Reproduce 1. Create a plan in `execute/processing` state 2. Create a checkpoint 3. Run `agents plan rollback <PLAN_ID> <CHECKPOINT_ID> --yes` 4. Run `agents plan status <PLAN_ID>` 5. **Observe**: plan is still in `execute/processing` (or pre-rollback state) 6. **Expected**: plan should be in `execute/queued` ### Code Locations - `src/cleveragents/cli/commands/plan.py` lines 3394–3447 — `rollback_plan` function - `src/cleveragents/application/services/checkpoint_service.py` lines 259–368 — `rollback_to_checkpoint` / `selective_rollback` ## Subtasks - [ ] Add `plan.processing_state = ProcessingState.QUEUED` after a successful sandbox rollback in `checkpoint_service.py` (`rollback_to_checkpoint` and `selective_rollback`) - [ ] Add `plan.phase = Phase.EXECUTE` (or equivalent) to ensure phase is correct post-rollback - [ ] Update the `post_rollback_state` JSON output in `rollback_plan` CLI to include `phase`, `state`, and `checkpoints_remaining` fields as specified - [ ] Write Behave unit tests (TDD) covering the post-rollback state transition: `execute/processing → execute/queued` and `execute/errored → execute/queued` - [ ] Write Behave unit tests verifying the `post_rollback_state` JSON output matches the spec format - [ ] Verify no regression in existing rollback tests ## Definition of Done - [ ] `rollback_to_checkpoint` and `selective_rollback` set `plan.processing_state = QUEUED` and correct `plan.phase` after a successful rollback - [ ] `post_rollback_state` JSON output matches spec: `phase`, `state`, `checkpoints_remaining` - [ ] All new and existing Behave unit tests pass (`nox -e unit_tests`) - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
freemo added this to the v3.3.0 milestone 2026-04-05 08:12:30 +00:00
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
#368 Epic: Subplans & Parallelism
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3218
No description provided.