forge-reasoning
Temporal Checkpointing for Forge Agent Reasoning Tools
Overview
This crate implements the Temporal Checkpointing reasoning tool from the Forge Reasoning Tools suite. It provides:
- Automatic checkpointing - Throttled state capture during long operations
- Manual checkpointing - Explicit state snapshots via user request
- State restoration - Roll back to previous checkpoint
- Session management - Group checkpoints by session
- Tag-based filtering - Organize checkpoints with tags
- WebSocket API - Real-time remote access to checkpoints
- Global sequences - Monotonic ordering across all sessions
- Data integrity - SHA-256 checksums for corruption detection
Quick Start
use *;
use Arc;
Features
Core Checkpointing
- Create, query, restore checkpoints
- Automatic and manual checkpoint triggers
- Session-based organization
- Tag-based filtering
Persistence
- SQLiteGraph backend for durability
- In-memory backend for testing
- Export/import to JSON
Concurrency
- Thread-safe operations
- Concurrent session support
- Atomic sequence numbers
Real-Time API
- WebSocket server for remote access
- Event broadcasting to subscribers
- JSON-RPC protocol
Data Integrity
- SHA-256 checksums on all checkpoints
- Validation on restore
- Health checks with integrity verification
Testing
All tests use TDD (Test-Driven Development):
# Run all tests (110 tests)
# Run specific test file
# Run with output
# Run benchmarks
Architecture
┌─────────────────────────────────────────────────────────┐
│ CheckpointService │
│ ┌─────────────┐ ┌─────────────┐ ┌────────────┐ │
│ │ Storage │ │ Global │ │ Event │ │
│ │ (Trait) │ │ Sequence │ │ Broadcast │ │
│ └─────────────┘ └─────────────┘ └────────────┘ │
└─────────────────────────────────────────────────────────┘
│
┌───────────┼───────────┐
▼ ▼ ▼
┌───────────────┐ ┌───────────┐ ┌────────────────┐
│ InMemory │ │ SQLite │ │ WebSocket │
│ Storage │ │ Storage │ │ Server │
└───────────────┘ └───────────┘ └────────────────┘
Backends
- ThreadSafeStorage - Thread-safe wrapper around any storage
- SqliteGraphStorage - SQLiteGraph-based, persistent
API Examples
Session Management
let service = new;
let session = service.create_session?;
// Enable auto-checkpointing
let config = default;
service.enable_auto_checkpoint?;
Checkpoint Operations
// Create checkpoint
let id = service.checkpoint?;
// With tags
let id = service.execute?;
// Restore
let state = service.restore?;
Data Integrity
// Validate single checkpoint
let valid = service.validate_checkpoint?;
// Validate all checkpoints
let report = service.validate_all_checkpoints?;
println!;
// Health check with validation
let health = service.health_check_with_validation?;
Export/Import
// Export all checkpoints
let json = service.export_all_checkpoints?;
// Import to another service
let result = new_service.import_checkpoints?;
println!;
Design Docs
See docs/ for full documentation:
TDD_WAVE_01.mdthroughTDD_WAVE_10.md- Implementation wavesPROJECT_LOG.md- Complete project history07_TEMPORAL_CHECKPOINTING.md- Design specification
Status
✅ Production Ready
- 110 tests passing (10 waves + E2E)
- 11 Criterion benchmarks
- ~6,350 lines of production code
License
MIT - See Forge project license