UAT: CheckpointService.rollback_to_checkpoint does not invalidate child plans, discard decisions, or undo tool calls after the checkpoint — spec requires full state reversion #2489

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

Metadata

Commit message: feat(checkpoint): implement full state reversion on rollback — invalidate child plans, discard decisions, undo tool calls
Branch: feat/checkpoint-full-state-reversion
Parent Epic: #397 (Epic: Server & Autonomy Infrastructure)

Bug Description

The CheckpointService.rollback_to_checkpoint() method only performs a filesystem-level git reset --hard on the sandbox working directory. The spec (§ agents plan rollback, lines 15952–15953) requires that rollback also: (1) invalidates child plans spawned after the checkpoint, (2) discards decisions made after the checkpoint, and (3) undoes tool calls made after the checkpoint. None of these state-level reversions are implemented.

Expected Behavior (from spec)

The spec states (line 15952–15953):

Rollback a plan sandbox to a previous checkpoint. All changes made after the target checkpoint are reverted: files are restored or removed, decisions are discarded, and tool calls are undone. Child plans spawned after the checkpoint are invalidated.

The spec's rollback output (lines 15988–15993) shows:

╭─ Impact ──────────────────────────────╮
│ Child Plans Invalidated: 2            │
│ Sandbox: restored to cp_01HXM8C2      │
│ Decisions After CP: 2 discarded       │
│ Tool Calls After CP: 5 undone         │
╰───────────────────────────────────────╯

The post-rollback state (lines 15995–15999) shows:

╭─ Post-Rollback State ──────────╮
│ Phase: execute                 │
│ State: queued (awaiting input) │
│ Checkpoints Remaining: 2       │
╰────────────────────────────────╯

Actual Behavior

CheckpointService.rollback_to_checkpoint() in src/cleveragents/application/services/checkpoint_service.py (lines ~200–280) only:

  1. Validates the sandbox path is a git repository
  2. Computes changed paths via git diff --name-only
  3. Executes git reset --hard <sandbox_ref>
  4. Executes git clean -fd
  5. Returns a RollbackResult with restored_files_count and changed_paths

It does NOT:

  • Query or invalidate child plans spawned after the checkpoint
  • Discard/supersede decisions recorded after the checkpoint
  • Undo tool call records made after the checkpoint
  • Transition the plan back to execute/queued state
  • Return counts of child plans invalidated, decisions discarded, or tool calls undone

The RollbackResult model (domain/models/core/checkpoint.py) only has restored_files_count, changed_paths, and from_checkpoint_id — it lacks fields for child_plans_invalidated, decisions_discarded, and tool_calls_undone.

Code Location

  • src/cleveragents/application/services/checkpoint_service.py, rollback_to_checkpoint() method
  • src/cleveragents/domain/models/core/checkpoint.py, RollbackResult model
  • src/cleveragents/cli/commands/plan.py, lines 3365–3398 (rollback output — also missing these fields, tracked in separate existing UAT issue)

Subtasks

  • Add child_plans_invalidated, decisions_discarded, tool_calls_undone fields to RollbackResult
  • Query DecisionService for decisions made after the checkpoint timestamp and mark them as superseded
  • Query SubplanService for child plans spawned after the checkpoint and cancel/invalidate them
  • Record tool call undo count (from decisions discarded)
  • Transition plan back to execute/queued state via PlanLifecycleService after rollback
  • Add unit tests (Behave) for full state reversion on rollback

Definition of Done

  • rollback_to_checkpoint() invalidates child plans spawned after the checkpoint
  • rollback_to_checkpoint() discards/supersedes decisions made after the checkpoint
  • rollback_to_checkpoint() records tool call undo count
  • Plan transitions back to execute/queued state after rollback
  • RollbackResult includes child_plans_invalidated, decisions_discarded, tool_calls_undone
  • Test coverage ≥ 97%

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

## Metadata **Commit message**: `feat(checkpoint): implement full state reversion on rollback — invalidate child plans, discard decisions, undo tool calls` **Branch**: `feat/checkpoint-full-state-reversion` **Parent Epic**: #397 (Epic: Server & Autonomy Infrastructure) ## Bug Description The `CheckpointService.rollback_to_checkpoint()` method only performs a filesystem-level `git reset --hard` on the sandbox working directory. The spec (§ `agents plan rollback`, lines 15952–15953) requires that rollback also: (1) invalidates child plans spawned after the checkpoint, (2) discards decisions made after the checkpoint, and (3) undoes tool calls made after the checkpoint. None of these state-level reversions are implemented. ## Expected Behavior (from spec) The spec states (line 15952–15953): > Rollback a plan sandbox to a previous checkpoint. All changes made **after** the target checkpoint are **reverted**: files are restored or removed, decisions are discarded, and tool calls are undone. Child plans spawned after the checkpoint are invalidated. The spec's rollback output (lines 15988–15993) shows: ``` ╭─ Impact ──────────────────────────────╮ │ Child Plans Invalidated: 2 │ │ Sandbox: restored to cp_01HXM8C2 │ │ Decisions After CP: 2 discarded │ │ Tool Calls After CP: 5 undone │ ╰───────────────────────────────────────╯ ``` The post-rollback state (lines 15995–15999) shows: ``` ╭─ Post-Rollback State ──────────╮ │ Phase: execute │ │ State: queued (awaiting input) │ │ Checkpoints Remaining: 2 │ ╰────────────────────────────────╯ ``` ## Actual Behavior `CheckpointService.rollback_to_checkpoint()` in `src/cleveragents/application/services/checkpoint_service.py` (lines ~200–280) only: 1. Validates the sandbox path is a git repository 2. Computes changed paths via `git diff --name-only` 3. Executes `git reset --hard <sandbox_ref>` 4. Executes `git clean -fd` 5. Returns a `RollbackResult` with `restored_files_count` and `changed_paths` It does **NOT**: - Query or invalidate child plans spawned after the checkpoint - Discard/supersede decisions recorded after the checkpoint - Undo tool call records made after the checkpoint - Transition the plan back to `execute/queued` state - Return counts of child plans invalidated, decisions discarded, or tool calls undone The `RollbackResult` model (`domain/models/core/checkpoint.py`) only has `restored_files_count`, `changed_paths`, and `from_checkpoint_id` — it lacks fields for `child_plans_invalidated`, `decisions_discarded`, and `tool_calls_undone`. ## Code Location - `src/cleveragents/application/services/checkpoint_service.py`, `rollback_to_checkpoint()` method - `src/cleveragents/domain/models/core/checkpoint.py`, `RollbackResult` model - `src/cleveragents/cli/commands/plan.py`, lines 3365–3398 (rollback output — also missing these fields, tracked in separate existing UAT issue) ## Subtasks - [ ] Add `child_plans_invalidated`, `decisions_discarded`, `tool_calls_undone` fields to `RollbackResult` - [ ] Query `DecisionService` for decisions made after the checkpoint timestamp and mark them as superseded - [ ] Query `SubplanService` for child plans spawned after the checkpoint and cancel/invalidate them - [ ] Record tool call undo count (from decisions discarded) - [ ] Transition plan back to `execute/queued` state via `PlanLifecycleService` after rollback - [ ] Add unit tests (Behave) for full state reversion on rollback ## Definition of Done - `rollback_to_checkpoint()` invalidates child plans spawned after the checkpoint - `rollback_to_checkpoint()` discards/supersedes decisions made after the checkpoint - `rollback_to_checkpoint()` records tool call undo count - Plan transitions back to `execute/queued` state after rollback - `RollbackResult` includes `child_plans_invalidated`, `decisions_discarded`, `tool_calls_undone` - Test coverage ≥ 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Medium — CheckpointService.rollback_to_checkpoint only does filesystem-level git reset. The spec requires full state reversion including invalidating child plans, discarding decisions, and undoing tool calls. This is a significant functional gap but the basic rollback works.
  • Milestone: v3.3.0 (setting — this belongs to the Corrections + Subplans + Checkpoints milestone)
  • MoSCoW: Should Have — The spec explicitly requires full state reversion on rollback. Without it, rollback only restores files but leaves stale decisions and child plans in the database. This is important for correctness but the basic checkpoint/rollback mechanism works.
  • Parent Epic: #397 (Epic: Server & Autonomy Infrastructure)

Valid UAT finding with clear code analysis showing the gap between spec requirements and implementation.


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

Issue triaged by project owner: - **State**: Verified - **Priority**: Medium — `CheckpointService.rollback_to_checkpoint` only does filesystem-level git reset. The spec requires full state reversion including invalidating child plans, discarding decisions, and undoing tool calls. This is a significant functional gap but the basic rollback works. - **Milestone**: v3.3.0 (setting — this belongs to the Corrections + Subplans + Checkpoints milestone) - **MoSCoW**: Should Have — The spec explicitly requires full state reversion on rollback. Without it, rollback only restores files but leaves stale decisions and child plans in the database. This is important for correctness but the basic checkpoint/rollback mechanism works. - **Parent Epic**: #397 (Epic: Server & Autonomy Infrastructure) Valid UAT finding with clear code analysis showing the gap between spec requirements and implementation. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
freemo added this to the v3.3.0 milestone 2026-04-05 02:36:56 +00:00
freemo removed this from the v3.3.0 milestone 2026-04-07 00:49:47 +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
#397 Epic: Server & Autonomy Infrastructure
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2489
No description provided.