UAT: CheckpointService.rollback_to_checkpoint is hardcoded to git operations — fails for non-git sandbox strategies (copy_on_write, overlay, transaction_rollback) #2979

Open
opened 2026-04-05 03:02:22 +00:00 by freemo · 2 comments
Owner

Metadata

  • Branch: fix/checkpoint-rollback-strategy-agnostic
  • Commit Message: fix(checkpoint): make rollback_to_checkpoint strategy-agnostic for non-git sandboxes
  • Milestone: v3.3.0
  • Parent Epic: #362

Description

The CheckpointService.rollback_to_checkpoint method (in src/cleveragents/application/services/checkpoint_service.py) is hardcoded to use git operations (git reset --hard, git clean -fd) and validates that the sandbox path is a git repository. This means rollback is completely broken for plans using non-git sandbox strategies such as copy_on_write, overlay, or transaction_rollback.

Expected Behavior (from spec)

The checkpoint rollback mechanism should work with all sandbox strategies. The spec defines sandbox strategies as pluggable (git_worktree, copy_on_write, transaction_rollback, snapshot, overlay) and checkpoint/rollback should be strategy-agnostic.

Actual Behavior

In src/cleveragents/application/services/checkpoint_service.py:

  1. _validate_sandbox (lines 757–776) checks for a .git directory:
def _validate_sandbox(self, sandbox_path: str) -> None:
    path = Path(sandbox_path)
    if not path.is_dir():
        raise BusinessRuleViolation(...)
    git_dir = path / ".git"
    if not git_dir.exists():
        raise BusinessRuleViolation(
            f"Cannot rollback: sandbox is not a git repository: {sandbox_path}"
        )
  1. rollback_to_checkpoint (lines 259–368) calls _git_reset_hard and _git_clean which run git reset --hard and git clean -fd.

  2. _git_changed_paths (lines 813–837) runs git diff --name-only and git ls-files --others.

If a plan uses copy_on_write or overlay sandbox strategy, the sandbox path is a regular directory (not a git repo), and _validate_sandbox will raise BusinessRuleViolation: Cannot rollback: sandbox is not a git repository.

Code Locations

  • src/cleveragents/application/services/checkpoint_service.py lines 757–776 (_validate_sandbox)
  • src/cleveragents/application/services/checkpoint_service.py lines 259–368 (rollback_to_checkpoint)
  • src/cleveragents/application/services/checkpoint_service.py lines 813–857 (git helper methods)

Steps to Reproduce

  1. Create a plan with a resource using copy_on_write sandbox strategy
  2. Create a checkpoint during execution
  3. Call CheckpointService.rollback_to_checkpoint(plan_id, checkpoint_id)
  4. Observe BusinessRuleViolation: Cannot rollback: sandbox is not a git repository

Impact

  • Checkpoint rollback is only functional for git_worktree sandbox strategy
  • Plans using copy_on_write, overlay, or transaction_rollback strategies cannot use checkpoint rollback
  • The spec's sandbox strategy abstraction is broken for rollback

Subtasks

  • Introduce a SandboxRollbackStrategy protocol/interface with a rollback(sandbox_path, checkpoint_data) method
  • Implement GitWorktreeRollbackStrategy (extract existing git-based logic from CheckpointService)
  • Implement CopyOnWriteRollbackStrategy (restore from snapshot directory stored at checkpoint time)
  • Implement OverlayRollbackStrategy (discard overlay layer and restore lower layer state)
  • Implement TransactionRollbackStrategy (issue rollback command to the underlying transaction store)
  • Refactor _validate_sandbox to be strategy-aware (remove hard .git directory check)
  • Refactor rollback_to_checkpoint to dispatch to the correct strategy based on the plan's sandbox strategy setting
  • Refactor _git_changed_paths and related git helpers to be encapsulated within GitWorktreeRollbackStrategy
  • Write BDD unit tests (Behave/Gherkin) in features/ for each rollback strategy
  • Write Robot Framework integration tests in robot/ covering rollback for all sandbox strategies
  • Update docstrings and inline documentation to reflect strategy-agnostic design
  • Verify nox passes with coverage >= 97%

Definition of Done

  • _validate_sandbox no longer hard-requires a .git directory; validation is delegated to the active strategy
  • rollback_to_checkpoint dispatches to the correct SandboxRollbackStrategy implementation based on plan configuration
  • All five sandbox strategies (git_worktree, copy_on_write, overlay, transaction_rollback, snapshot) have a corresponding rollback strategy implementation
  • BDD unit tests cover all strategy branches and edge cases
  • Robot Framework integration tests confirm rollback works end-to-end for non-git strategies
  • No # type: ignore suppressions introduced
  • All nox stages pass (nox -e lint, nox -e typecheck, nox -e unit_tests, nox -e integration_tests)
  • Coverage >= 97%

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

## Metadata - **Branch**: `fix/checkpoint-rollback-strategy-agnostic` - **Commit Message**: `fix(checkpoint): make rollback_to_checkpoint strategy-agnostic for non-git sandboxes` - **Milestone**: v3.3.0 - **Parent Epic**: #362 ## Description The `CheckpointService.rollback_to_checkpoint` method (in `src/cleveragents/application/services/checkpoint_service.py`) is hardcoded to use git operations (`git reset --hard`, `git clean -fd`) and validates that the sandbox path is a git repository. This means rollback is completely broken for plans using non-git sandbox strategies such as `copy_on_write`, `overlay`, or `transaction_rollback`. ### Expected Behavior (from spec) The checkpoint rollback mechanism should work with all sandbox strategies. The spec defines sandbox strategies as pluggable (`git_worktree`, `copy_on_write`, `transaction_rollback`, `snapshot`, `overlay`) and checkpoint/rollback should be strategy-agnostic. ### Actual Behavior In `src/cleveragents/application/services/checkpoint_service.py`: 1. `_validate_sandbox` (lines 757–776) checks for a `.git` directory: ```python def _validate_sandbox(self, sandbox_path: str) -> None: path = Path(sandbox_path) if not path.is_dir(): raise BusinessRuleViolation(...) git_dir = path / ".git" if not git_dir.exists(): raise BusinessRuleViolation( f"Cannot rollback: sandbox is not a git repository: {sandbox_path}" ) ``` 2. `rollback_to_checkpoint` (lines 259–368) calls `_git_reset_hard` and `_git_clean` which run `git reset --hard` and `git clean -fd`. 3. `_git_changed_paths` (lines 813–837) runs `git diff --name-only` and `git ls-files --others`. If a plan uses `copy_on_write` or `overlay` sandbox strategy, the sandbox path is a regular directory (not a git repo), and `_validate_sandbox` will raise `BusinessRuleViolation: Cannot rollback: sandbox is not a git repository`. ### Code Locations - `src/cleveragents/application/services/checkpoint_service.py` lines 757–776 (`_validate_sandbox`) - `src/cleveragents/application/services/checkpoint_service.py` lines 259–368 (`rollback_to_checkpoint`) - `src/cleveragents/application/services/checkpoint_service.py` lines 813–857 (git helper methods) ### Steps to Reproduce 1. Create a plan with a resource using `copy_on_write` sandbox strategy 2. Create a checkpoint during execution 3. Call `CheckpointService.rollback_to_checkpoint(plan_id, checkpoint_id)` 4. Observe `BusinessRuleViolation: Cannot rollback: sandbox is not a git repository` ### Impact - Checkpoint rollback is only functional for `git_worktree` sandbox strategy - Plans using `copy_on_write`, `overlay`, or `transaction_rollback` strategies cannot use checkpoint rollback - The spec's sandbox strategy abstraction is broken for rollback ## Subtasks - [ ] Introduce a `SandboxRollbackStrategy` protocol/interface with a `rollback(sandbox_path, checkpoint_data)` method - [ ] Implement `GitWorktreeRollbackStrategy` (extract existing git-based logic from `CheckpointService`) - [ ] Implement `CopyOnWriteRollbackStrategy` (restore from snapshot directory stored at checkpoint time) - [ ] Implement `OverlayRollbackStrategy` (discard overlay layer and restore lower layer state) - [ ] Implement `TransactionRollbackStrategy` (issue rollback command to the underlying transaction store) - [ ] Refactor `_validate_sandbox` to be strategy-aware (remove hard `.git` directory check) - [ ] Refactor `rollback_to_checkpoint` to dispatch to the correct strategy based on the plan's sandbox strategy setting - [ ] Refactor `_git_changed_paths` and related git helpers to be encapsulated within `GitWorktreeRollbackStrategy` - [ ] Write BDD unit tests (Behave/Gherkin) in `features/` for each rollback strategy - [ ] Write Robot Framework integration tests in `robot/` covering rollback for all sandbox strategies - [ ] Update docstrings and inline documentation to reflect strategy-agnostic design - [ ] Verify `nox` passes with coverage >= 97% ## Definition of Done - [ ] `_validate_sandbox` no longer hard-requires a `.git` directory; validation is delegated to the active strategy - [ ] `rollback_to_checkpoint` dispatches to the correct `SandboxRollbackStrategy` implementation based on plan configuration - [ ] All five sandbox strategies (`git_worktree`, `copy_on_write`, `overlay`, `transaction_rollback`, `snapshot`) have a corresponding rollback strategy implementation - [ ] BDD unit tests cover all strategy branches and edge cases - [ ] Robot Framework integration tests confirm rollback works end-to-end for non-git strategies - [ ] No `# type: ignore` suppressions introduced - [ ] All nox stages pass (`nox -e lint`, `nox -e typecheck`, `nox -e unit_tests`, `nox -e integration_tests`) - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.3.0 milestone 2026-04-05 03:03:09 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Confirmed
  • MoSCoW: Should Have

Valid finding verified during batch triage.


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

Issue triaged by project owner: - **State**: Verified - **Priority**: Confirmed - **MoSCoW**: Should Have Valid finding verified during batch triage. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Author
Owner

[Stale Issue Alert] This issue has been in State/In Progress for approximately 10 hours with no recent activity.

Current state: State/In Progress | Milestone: v3.3.0
Last updated: 2026-04-05T07:29:53Z

Is this blocked? If work has paused, please update the state to State/Paused. If work is complete, please transition to State/In Review.


Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: ca-backlog-groomer

**[Stale Issue Alert]** This issue has been in `State/In Progress` for approximately 10 hours with no recent activity. Current state: `State/In Progress` | Milestone: v3.3.0 Last updated: 2026-04-05T07:29:53Z Is this blocked? If work has paused, please update the state to `State/Paused`. If work is complete, please transition to `State/In Review`. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: ca-backlog-groomer
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#2979
No description provided.