Documentation
¶
Overview ¶
Package checkpoint provides session state persistence and resumption.
Saves/restores Claude session context with tiered resume levels (summary → context → full). Auto-checkpoint at configurable thresholds.
See CLAUDE.md for checkpoint schema and resume levels.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checkpoint ¶
type Checkpoint struct {
// ID is the unique identifier for this checkpoint.
ID string `json:"id"`
// SessionID is the session this checkpoint belongs to.
SessionID string `json:"session_id"`
// TenantID is the organization this checkpoint belongs to.
TenantID string `json:"tenant_id"`
// TeamID is the team this checkpoint belongs to.
TeamID string `json:"team_id"`
// ProjectID is the project identifier for this checkpoint.
ProjectID string `json:"project_id"`
// ProjectPath is the project context for this checkpoint.
ProjectPath string `json:"project_path"`
// Name is a human-readable name for the checkpoint.
Name string `json:"name"`
// Description describes what was happening at checkpoint time.
Description string `json:"description"`
// Summary is a condensed summary of the session state.
Summary string `json:"summary"`
// Context contains relevant context fragments.
Context string `json:"context"`
// FullState contains the complete session state.
FullState string `json:"full_state"`
// TokenCount is the approximate token count of full state.
TokenCount int32 `json:"token_count"`
// Threshold is the context percentage at which this was created.
Threshold float64 `json:"threshold"`
// AutoCreated indicates if this was auto-generated.
AutoCreated bool `json:"auto_created"`
// Metadata contains additional checkpoint metadata.
Metadata map[string]string `json:"metadata,omitempty"`
// CreatedAt is when this checkpoint was created.
CreatedAt time.Time `json:"created_at"`
}
Checkpoint represents a saved session state.
type Config ¶
type Config struct {
// VectorSize is the dimension of embedding vectors (default: 1536)
VectorSize uint64
// MaxCheckpointsPerSession limits checkpoints per session (default: 10)
MaxCheckpointsPerSession int
// AutoCheckpointThresholds are context % levels for auto-checkpoint.
AutoCheckpointThresholds []float64
}
Config configures the checkpoint service.
func DefaultServiceConfig ¶
func DefaultServiceConfig() *Config
DefaultServiceConfig returns sensible defaults.
type ListRequest ¶
type ListRequest struct {
SessionID string
TenantID string
TeamID string
ProjectID string
ProjectPath string
Limit int
AutoOnly bool // Only return auto-created checkpoints
}
ListRequest represents parameters for listing checkpoints.
type ResumeLevel ¶
type ResumeLevel string
ResumeLevel indicates how much context to restore.
const ( // ResumeSummary restores only the summary (minimal context). ResumeSummary ResumeLevel = "summary" // ResumeContext restores summary + relevant context. ResumeContext ResumeLevel = "context" // ResumeFull restores the complete checkpoint. ResumeFull ResumeLevel = "full" )
type ResumeRequest ¶
type ResumeRequest struct {
CheckpointID string
TenantID string
TeamID string
ProjectID string
Level ResumeLevel
}
ResumeRequest represents parameters for resuming from a checkpoint.
type ResumeResponse ¶
type ResumeResponse struct {
Checkpoint *Checkpoint
Content string // Content based on resume level
TokenCount int32
}
ResumeResponse contains the restored checkpoint data.
type SaveRequest ¶
type SaveRequest struct {
SessionID string
TenantID string
TeamID string
ProjectID string
ProjectPath string
Name string
Description string
Summary string
Context string
FullState string
TokenCount int32
Threshold float64
AutoCreated bool
Metadata map[string]string
}
SaveRequest represents parameters for saving a checkpoint.
type Service ¶
type Service interface {
// Save creates a new checkpoint.
Save(ctx context.Context, req *SaveRequest) (*Checkpoint, error)
// List retrieves checkpoints for a session or project.
List(ctx context.Context, req *ListRequest) ([]*Checkpoint, error)
// Resume restores a checkpoint at the specified level.
Resume(ctx context.Context, req *ResumeRequest) (*ResumeResponse, error)
// Get retrieves a checkpoint by ID.
Get(ctx context.Context, tenantID, teamID, projectID, checkpointID string) (*Checkpoint, error)
// Delete removes a checkpoint.
Delete(ctx context.Context, tenantID, teamID, projectID, checkpointID string) error
// Close closes the service.
Close() error
}
Service provides checkpoint management operations.
func NewService ¶
func NewService(cfg *Config, stores vectorstore.StoreProvider, logger *zap.Logger) (Service, error)
NewService creates a new checkpoint service.
func NewServiceWithStore ¶ added in v0.3.0
NewServiceWithStore creates a checkpoint service with a legacy single Store. This is for backward compatibility during migration. Deprecated: Use NewService with StoreProvider instead.