Crate hutch

Crate hutch 

Source
Expand description

§Hutch

Checkpoint and undo system for AI agent sessions - safe burrow to return to.

This crate provides:

  • Automatic checkpoints at each turn
  • Named manual checkpoints
  • Undo/restore functionality
  • File diff tracking

§Architecture

┌──────────────────────────────────────────────────┐
│                 CheckpointManager                │
│  ┌────────────┐  ┌────────────┐  ┌────────────┐ │
│  │ Checkpoint │  │ Checkpoint │  │ Checkpoint │ │
│  │    (T0)    │  │    (T1)    │  │    (T2)    │ │
│  └────────────┘  └────────────┘  └────────────┘ │
│       │              │              │           │
│       ▼              ▼              ▼           │
│  ┌────────────────────────────────────────────┐ │
│  │              TurnTracker                   │ │
│  │   [Turn 0] → [Turn 1] → [Turn 2] → ...    │ │
│  └────────────────────────────────────────────┘ │
│                      │                          │
│                      ▼                          │
│  ┌────────────────────────────────────────────┐ │
│  │              FileTracker                   │ │
│  │   File diffs, snapshots, restore           │ │
│  └────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────┘

§Example

use hutch::{CheckpointManager, CheckpointConfig};

let config = CheckpointConfig::default();
let manager = CheckpointManager::new(config);

// Auto-checkpoint at turn boundary
let checkpoint_id = manager.checkpoint_turn(turn_number).await?;

// Manual checkpoint
let checkpoint_id = manager.save("before refactor").await?;

// Undo to last checkpoint
manager.undo().await?;

// Restore specific checkpoint
manager.restore(checkpoint_id).await?;

Re-exports§

pub use manager::CheckpointManager;
pub use checkpoint::Checkpoint;
pub use checkpoint::CheckpointData;
pub use turn_tracker::TurnTracker;
pub use file_tracker::FileTracker;
pub use error::CheckpointError;

Modules§

checkpoint
Checkpoint data structures
error
Checkpoint error types
file_tracker
File change tracking
manager
Checkpoint manager - coordinates checkpointing
storage
Checkpoint storage backend
turn_tracker
Turn tracking for conversation history

Structs§

CheckpointId
Unique identifier for a checkpoint
CheckpointMeta
Metadata for a checkpoint