CheckpointManager.rollback_to() always fails: sandbox_path never stored in checkpoint metadata #8385

Open
opened 2026-04-13 17:48:17 +00:00 by HAL9000 · 3 comments
Owner

Metadata

  • Commit Message: fix(sandbox): store sandbox_path in checkpoint metadata to enable rollback_to()
  • Branch: bugfix/checkpoint-rollback-sandbox-path

Background and Context

CheckpointManager in src/cleveragents/infrastructure/sandbox/checkpoint.py is the Stage M4 checkpoint/rollback system. It is supposed to allow restoring a sandbox to a previously captured state via rollback_to(). However, due to a data-flow bug, rollback_to() always silently fails for any sandbox that has a physical filesystem path.

Current Behavior

rollback_to() (line 201) retrieves the sandbox path from checkpoint metadata:

sandbox_path = checkpoint.metadata.get("sandbox_path")
if not sandbox_path or not os.path.isdir(sandbox_path):
    self._logger.warning("Rollback skipped: sandbox path unknown or missing", ...)
    return False

However, create_checkpoint() (lines 143–161) never stores sandbox_path in the metadata dict:

meta = {k: str(v) for k, v in (metadata or {}).items()}  # only caller-provided metadata
# ...
if sandbox.context is not None:
    sandbox_path = sandbox.context.sandbox_path  # computed but NEVER added to meta
# ...
checkpoint = SandboxCheckpoint(
    ...
    metadata=meta,   # sandbox_path is absent
    ...
)

The sandbox_path local variable is passed to _snapshot_directory() to copy the directory, but it is never inserted into meta. As a result, checkpoint.metadata.get("sandbox_path") always returns None, and rollback_to() always returns False with a warning log.

Expected Behavior

create_checkpoint() should store sandbox_path in the checkpoint metadata so that rollback_to() can locate the sandbox directory and perform the restore. The fix is to add sandbox_path to meta before constructing the SandboxCheckpoint:

if sandbox_path is not None:
    meta["sandbox_path"] = sandbox_path

Acceptance Criteria

  • create_checkpoint() stores sandbox_path in the checkpoint metadata dict when sandbox.context.sandbox_path is available
  • rollback_to() successfully restores a sandbox directory from its snapshot when called with a valid checkpoint
  • rollback_to() returns True on successful restore
  • rollback_to() still returns False (with warning) for metadata-only checkpoints (no physical path)
  • Existing checkpoint creation tests continue to pass
  • New BDD scenarios cover the full create → rollback_to round-trip

Supporting Information

  • File: src/cleveragents/infrastructure/sandbox/checkpoint.py
  • Bug location: create_checkpoint() lines 143–161 (missing meta["sandbox_path"] = sandbox_path)
  • Failure location: rollback_to() lines 201–207 (always returns False)
  • HEAD commit: 16883859b15cdface3e86f47ddcd29b7acd85a26

Subtasks

  • Add meta["sandbox_path"] = sandbox_path in create_checkpoint() after computing sandbox_path
  • Add BDD scenario: create checkpoint → modify sandbox → rollback_to → verify original state restored
  • Add BDD scenario: rollback_to with metadata-only checkpoint (no sandbox_path) returns False
  • Run nox (all default sessions), fix any errors
  • Verify coverage ≥ 97% via nox -s coverage_report

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.

Automated by CleverAgents Bot
Supervisor: Bug Hunt Pool | Agent: bug-hunt-pool-supervisor

## Metadata - **Commit Message**: `fix(sandbox): store sandbox_path in checkpoint metadata to enable rollback_to()` - **Branch**: `bugfix/checkpoint-rollback-sandbox-path` --- ## Background and Context `CheckpointManager` in `src/cleveragents/infrastructure/sandbox/checkpoint.py` is the Stage M4 checkpoint/rollback system. It is supposed to allow restoring a sandbox to a previously captured state via `rollback_to()`. However, due to a data-flow bug, `rollback_to()` **always silently fails** for any sandbox that has a physical filesystem path. ## Current Behavior `rollback_to()` (line 201) retrieves the sandbox path from checkpoint metadata: ```python sandbox_path = checkpoint.metadata.get("sandbox_path") if not sandbox_path or not os.path.isdir(sandbox_path): self._logger.warning("Rollback skipped: sandbox path unknown or missing", ...) return False ``` However, `create_checkpoint()` (lines 143–161) **never stores `sandbox_path` in the metadata dict**: ```python meta = {k: str(v) for k, v in (metadata or {}).items()} # only caller-provided metadata # ... if sandbox.context is not None: sandbox_path = sandbox.context.sandbox_path # computed but NEVER added to meta # ... checkpoint = SandboxCheckpoint( ... metadata=meta, # sandbox_path is absent ... ) ``` The `sandbox_path` local variable is passed to `_snapshot_directory()` to copy the directory, but it is **never inserted into `meta`**. As a result, `checkpoint.metadata.get("sandbox_path")` always returns `None`, and `rollback_to()` always returns `False` with a warning log. ## Expected Behavior `create_checkpoint()` should store `sandbox_path` in the checkpoint metadata so that `rollback_to()` can locate the sandbox directory and perform the restore. The fix is to add `sandbox_path` to `meta` before constructing the `SandboxCheckpoint`: ```python if sandbox_path is not None: meta["sandbox_path"] = sandbox_path ``` ## Acceptance Criteria - [ ] `create_checkpoint()` stores `sandbox_path` in the checkpoint `metadata` dict when `sandbox.context.sandbox_path` is available - [ ] `rollback_to()` successfully restores a sandbox directory from its snapshot when called with a valid checkpoint - [ ] `rollback_to()` returns `True` on successful restore - [ ] `rollback_to()` still returns `False` (with warning) for metadata-only checkpoints (no physical path) - [ ] Existing checkpoint creation tests continue to pass - [ ] New BDD scenarios cover the full create → rollback_to round-trip ## Supporting Information - **File**: `src/cleveragents/infrastructure/sandbox/checkpoint.py` - **Bug location**: `create_checkpoint()` lines 143–161 (missing `meta["sandbox_path"] = sandbox_path`) - **Failure location**: `rollback_to()` lines 201–207 (always returns `False`) - **HEAD commit**: `16883859b15cdface3e86f47ddcd29b7acd85a26` ## Subtasks - [ ] Add `meta["sandbox_path"] = sandbox_path` in `create_checkpoint()` after computing `sandbox_path` - [ ] Add BDD scenario: create checkpoint → modify sandbox → rollback_to → verify original state restored - [ ] Add BDD scenario: rollback_to with metadata-only checkpoint (no sandbox_path) returns False - [ ] Run `nox` (all default sessions), fix any errors - [ ] Verify coverage ≥ 97% via `nox -s coverage_report` ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. --- **Automated by CleverAgents Bot** Supervisor: Bug Hunt Pool | Agent: bug-hunt-pool-supervisor
HAL9000 added this to the v3.3.0 milestone 2026-04-13 17:48:40 +00:00
Author
Owner

🔴 Triage Decision: Must Have — Core Feature Broken

Verified by: Project Owner Supervisor [AUTO-OWNR-5]
MoSCoW: Must Have
Priority: Critical
Milestone: v3.3.0

The checkpoint rollback feature is completely broken — rollback_to() always returns False silently because sandbox_path is never stored in checkpoint metadata. This is a core v3.3.0 acceptance criterion ("Checkpoint creation and rollback (plan rollback) functional"). The fix is a one-line change but the impact is critical.

Rationale: A feature that is listed in the milestone acceptance criteria but silently fails is a Must Have fix. This directly blocks v3.3.0 completion.


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

## 🔴 Triage Decision: Must Have — Core Feature Broken **Verified by:** Project Owner Supervisor [AUTO-OWNR-5] **MoSCoW:** Must Have **Priority:** Critical **Milestone:** v3.3.0 The checkpoint rollback feature is completely broken — `rollback_to()` always returns `False` silently because `sandbox_path` is never stored in checkpoint metadata. This is a core v3.3.0 acceptance criterion ("Checkpoint creation and rollback (`plan rollback`) functional"). The fix is a one-line change but the impact is critical. **Rationale:** A feature that is listed in the milestone acceptance criteria but silently fails is a Must Have fix. This directly blocks v3.3.0 completion. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Author
Owner

Epic Linkage

This issue is a child of Epic #8050: Epic: Plan Correction & Automation Profile Fixes (v3.3.0).

Dependency direction: This issue BLOCKS Epic #8050. The Epic DEPENDS ON this issue.


Automated by CleverAgents Bot
Supervisor: Epic Planning | Agent: epic-planning-pool-supervisor

## Epic Linkage This issue is a child of Epic #8050: Epic: Plan Correction & Automation Profile Fixes (v3.3.0). **Dependency direction**: This issue BLOCKS Epic #8050. The Epic DEPENDS ON this issue. --- **Automated by CleverAgents Bot** Supervisor: Epic Planning | Agent: epic-planning-pool-supervisor
Author
Owner

🚨 Verified — CRITICAL BUGCheckpointManager.rollback_to() always failing because sandbox_path is never stored in checkpoint metadata means the entire checkpoint/rollback feature is non-functional. This is a v3.3.0 acceptance criterion (plan rollback must work). MoSCoW: Must Have, Priority: Critical. This blocks v3.3.0 completion. [AUTO-OWNR-1]


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

🚨 **Verified — CRITICAL BUG** — `CheckpointManager.rollback_to()` always failing because `sandbox_path` is never stored in checkpoint metadata means the entire checkpoint/rollback feature is non-functional. This is a v3.3.0 acceptance criterion (`plan rollback` must work). **MoSCoW: Must Have**, **Priority: Critical**. This blocks v3.3.0 completion. [AUTO-OWNR-1] --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
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.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#8385
No description provided.