UAT: CheckpointManager.create_checkpoint does not store sandbox_path in checkpoint metadata — rollback_to silently returns False #2461

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

Metadata

  • Branch: fix/checkpoint-manager-sandbox-path-metadata
  • Commit Message: fix(checkpoint): store sandbox_path in checkpoint metadata so rollback_to can restore files
  • Milestone: v3.3.0
  • Parent Epic: #362

Description

CheckpointManager.create_checkpoint computes the sandbox_path from sandbox.context.sandbox_path during snapshot creation, but does NOT store it in the checkpoint's metadata dict. The rollback_to method then tries to retrieve sandbox_path from checkpoint.metadata.get("sandbox_path"), which returns None, causing rollback to silently return False without restoring any files.

Expected Behavior

create_checkpoint should automatically store sandbox_path in the checkpoint metadata so that rollback_to can find it and perform the actual filesystem restore.

Actual Behavior

In src/cleveragents/infrastructure/sandbox/checkpoint.py:

create_checkpoint (lines 117–174):

if sandbox.context is not None:
    sandbox_path = sandbox.context.sandbox_path  # computed but NOT stored in metadata
snapshot_path = self._snapshot_directory(sandbox_path, checkpoint_id)
checkpoint = SandboxCheckpoint(
    ...
    metadata=meta,  # sandbox_path is NOT in meta
    snapshot_path=snapshot_path,
)

rollback_to (lines 176–240):

sandbox_path = checkpoint.metadata.get("sandbox_path")  # always None
if not sandbox_path or not os.path.isdir(sandbox_path):
    self._logger.warning("Rollback skipped: sandbox path unknown or missing", ...)
    return False  # silently fails every time

Unless the caller explicitly passes {"sandbox_path": "..."} in the metadata parameter, every rollback_to call will silently return False without restoring any files.

Code Locations

  • src/cleveragents/infrastructure/sandbox/checkpoint.py lines 117–174 (create_checkpoint)
  • src/cleveragents/infrastructure/sandbox/checkpoint.py lines 176–240 (rollback_to)

Proposed Fix

In create_checkpoint, after computing sandbox_path, add it to meta:

if sandbox.context is not None:
    sandbox_path = sandbox.context.sandbox_path
    meta["sandbox_path"] = sandbox_path or ""

Steps to Reproduce

  1. Create a CheckpointManager
  2. Call create_checkpoint(sandbox, plan_id, "pre_execute") without passing sandbox_path in metadata
  3. Call rollback_to(checkpoint) — it returns False without restoring any files

Subtasks

  • Write a TDD issue-capture Behave scenario in features/ that demonstrates rollback_to returning False when sandbox_path is not in metadata (red test)
  • Fix create_checkpoint in src/cleveragents/infrastructure/sandbox/checkpoint.py to store sandbox_path in meta after computing it from sandbox.context.sandbox_path
  • Verify the TDD scenario now passes (green test)
  • Add/update unit tests in features/ to cover the case where sandbox.context is None (ensure sandbox_path defaults to "" or is omitted gracefully)
  • Run nox -e typecheck to confirm no type errors are introduced
  • Run nox -e unit_tests to confirm all scenarios pass
  • Run nox -e coverage_report to confirm coverage ≥ 97%

Definition of Done

  • create_checkpoint stores sandbox_path in checkpoint metadata whenever sandbox.context is not None
  • rollback_to successfully restores files when called after create_checkpoint without explicit metadata
  • TDD issue-capture scenario exists and passes
  • No regressions in existing checkpoint-related Behave scenarios
  • All nox stages pass
  • Coverage >= 97%

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

## Metadata - **Branch**: `fix/checkpoint-manager-sandbox-path-metadata` - **Commit Message**: `fix(checkpoint): store sandbox_path in checkpoint metadata so rollback_to can restore files` - **Milestone**: v3.3.0 - **Parent Epic**: #362 ## Description `CheckpointManager.create_checkpoint` computes the `sandbox_path` from `sandbox.context.sandbox_path` during snapshot creation, but does NOT store it in the checkpoint's `metadata` dict. The `rollback_to` method then tries to retrieve `sandbox_path` from `checkpoint.metadata.get("sandbox_path")`, which returns `None`, causing rollback to silently return `False` without restoring any files. ### Expected Behavior `create_checkpoint` should automatically store `sandbox_path` in the checkpoint metadata so that `rollback_to` can find it and perform the actual filesystem restore. ### Actual Behavior In `src/cleveragents/infrastructure/sandbox/checkpoint.py`: **`create_checkpoint` (lines 117–174):** ```python if sandbox.context is not None: sandbox_path = sandbox.context.sandbox_path # computed but NOT stored in metadata snapshot_path = self._snapshot_directory(sandbox_path, checkpoint_id) checkpoint = SandboxCheckpoint( ... metadata=meta, # sandbox_path is NOT in meta snapshot_path=snapshot_path, ) ``` **`rollback_to` (lines 176–240):** ```python sandbox_path = checkpoint.metadata.get("sandbox_path") # always None if not sandbox_path or not os.path.isdir(sandbox_path): self._logger.warning("Rollback skipped: sandbox path unknown or missing", ...) return False # silently fails every time ``` Unless the caller explicitly passes `{"sandbox_path": "..."}` in the `metadata` parameter, every `rollback_to` call will silently return `False` without restoring any files. ### Code Locations - `src/cleveragents/infrastructure/sandbox/checkpoint.py` lines 117–174 (`create_checkpoint`) - `src/cleveragents/infrastructure/sandbox/checkpoint.py` lines 176–240 (`rollback_to`) ### Proposed Fix In `create_checkpoint`, after computing `sandbox_path`, add it to `meta`: ```python if sandbox.context is not None: sandbox_path = sandbox.context.sandbox_path meta["sandbox_path"] = sandbox_path or "" ``` ### Steps to Reproduce 1. Create a `CheckpointManager` 2. Call `create_checkpoint(sandbox, plan_id, "pre_execute")` without passing `sandbox_path` in metadata 3. Call `rollback_to(checkpoint)` — it returns `False` without restoring any files ## Subtasks - [ ] Write a TDD issue-capture Behave scenario in `features/` that demonstrates `rollback_to` returning `False` when `sandbox_path` is not in metadata (red test) - [ ] Fix `create_checkpoint` in `src/cleveragents/infrastructure/sandbox/checkpoint.py` to store `sandbox_path` in `meta` after computing it from `sandbox.context.sandbox_path` - [ ] Verify the TDD scenario now passes (green test) - [ ] Add/update unit tests in `features/` to cover the case where `sandbox.context` is `None` (ensure `sandbox_path` defaults to `""` or is omitted gracefully) - [ ] Run `nox -e typecheck` to confirm no type errors are introduced - [ ] Run `nox -e unit_tests` to confirm all scenarios pass - [ ] Run `nox -e coverage_report` to confirm coverage ≥ 97% ## Definition of Done - [ ] `create_checkpoint` stores `sandbox_path` in checkpoint metadata whenever `sandbox.context` is not `None` - [ ] `rollback_to` successfully restores files when called after `create_checkpoint` without explicit metadata - [ ] TDD issue-capture scenario exists and passes - [ ] No regressions in existing checkpoint-related Behave scenarios - [ ] 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-03 18:30:17 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: Should Have — Important spec requirement or quality improvement. Should be included in the milestone if possible.

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

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: Should Have — Important spec requirement or quality improvement. Should be included in the milestone if possible. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
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#2461
No description provided.