feat(sandbox): add checkpoint and rollback hooks #462

Merged
freemo merged 1 commits from feature/m4-checkpoints into master 2026-02-28 00:49:46 +00:00
Owner

Summary

Adds sandbox checkpoint and rollback hooks integrated into plan execute/apply flows with metadata capture. Checkpoints preserve sandbox state at key points, and rollback restores to a specific checkpoint with metadata preserved.

Changes

SandboxCheckpoint Model & CheckpointManager

  • SandboxCheckpoint frozen Pydantic model with ULID-based checkpoint_id, sandbox_id, plan_id, phase, created_at, metadata, snapshot_path
  • CheckpointManager class managing checkpoint lifecycle: create_checkpoint, rollback_to, list_checkpoints, delete_checkpoint
  • Uses filesystem-based snapshots for state preservation

Plan Execute/Apply Integration

  • Pre-execute checkpoint creation in plan_executor.py
  • Post-execute checkpoint on success
  • Pre-apply checkpoint in plan_apply_service.py
  • Automatic rollback attempt on execute/apply failure
  • Optional injection — hooks silently skip if no CheckpointManager

Documentation

  • New docs/reference/sandbox.md with checkpoint lifecycle diagram and rollback behavior

Tests

  • Behave: 12 scenarios in features/sandbox_checkpoints.feature (all pass)
  • Robot: 5 test cases in robot/sandbox_checkpoint_smoke.robot (all pass)
  • ASV: 3 benchmarks in benchmarks/sandbox_checkpoint_bench.py

Quality Gates

  • lint: PASS
  • typecheck: PASS (0 errors, 0 warnings)
  • unit_tests: PASS
  • integration_tests: PASS

Closes #183

## Summary Adds sandbox checkpoint and rollback hooks integrated into plan execute/apply flows with metadata capture. Checkpoints preserve sandbox state at key points, and rollback restores to a specific checkpoint with metadata preserved. ## Changes ### SandboxCheckpoint Model & CheckpointManager - `SandboxCheckpoint` frozen Pydantic model with ULID-based `checkpoint_id`, `sandbox_id`, `plan_id`, `phase`, `created_at`, `metadata`, `snapshot_path` - `CheckpointManager` class managing checkpoint lifecycle: `create_checkpoint`, `rollback_to`, `list_checkpoints`, `delete_checkpoint` - Uses filesystem-based snapshots for state preservation ### Plan Execute/Apply Integration - Pre-execute checkpoint creation in `plan_executor.py` - Post-execute checkpoint on success - Pre-apply checkpoint in `plan_apply_service.py` - Automatic rollback attempt on execute/apply failure - Optional injection — hooks silently skip if no CheckpointManager ### Documentation - New `docs/reference/sandbox.md` with checkpoint lifecycle diagram and rollback behavior ### Tests - **Behave**: 12 scenarios in `features/sandbox_checkpoints.feature` (all pass) - **Robot**: 5 test cases in `robot/sandbox_checkpoint_smoke.robot` (all pass) - **ASV**: 3 benchmarks in `benchmarks/sandbox_checkpoint_bench.py` ## Quality Gates - lint: PASS - typecheck: PASS (0 errors, 0 warnings) - unit_tests: PASS - integration_tests: PASS Closes #183
freemo force-pushed feature/m4-checkpoints from 0f4eb80678 to 63e6d23946 2026-02-27 19:35:46 +00:00 Compare
freemo scheduled this pull request to auto merge when all checks succeed 2026-02-27 19:35:59 +00:00
freemo force-pushed feature/m4-checkpoints from 63e6d23946 to 8fc08d1069 2026-02-27 21:09:00 +00:00 Compare
freemo force-pushed feature/m4-checkpoints from 8fc08d1069 to 8096744b13 2026-02-27 21:34:07 +00:00 Compare
freemo force-pushed feature/m4-checkpoints from 8096744b13 to 0ca1303927 2026-02-27 23:08:57 +00:00 Compare
freemo added the
Type
Feature
label 2026-02-27 23:51:13 +00:00
freemo added a new dependency 2026-02-27 23:51:39 +00:00
freemo merged commit 0ca1303927 into master 2026-02-28 00:49:46 +00:00
freemo deleted branch feature/m4-checkpoints 2026-02-28 00:49:46 +00:00
freemo added the
State
Completed
label 2026-03-04 00:41:57 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Blocks
Reference: cleveragents/cleveragents-core#462