checkpoint

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package checkpoint provides session checkpointing for crash recovery. When a polecat session dies (context limit, crash, timeout), checkpoints allow the next session to recover state and resume work.

Index

Constants

View Source
const Filename = ".polecat-checkpoint.json"

Filename is the checkpoint file name within the polecat directory.

Variables

This section is empty.

Functions

func Path

func Path(polecatDir string) string

Path returns the checkpoint file path for a given polecat directory.

func Remove

func Remove(polecatDir string) error

Remove deletes the checkpoint file.

func Write

func Write(polecatDir string, cp *Checkpoint) error

Write saves a checkpoint to the polecat directory.

Types

type Checkpoint

type Checkpoint struct {
	// MoleculeID is the current molecule being worked.
	MoleculeID string `json:"molecule_id,omitempty"`

	// CurrentStep is the step ID currently in progress.
	CurrentStep string `json:"current_step,omitempty"`

	// StepTitle is the human-readable title of the current step.
	StepTitle string `json:"step_title,omitempty"`

	// ModifiedFiles lists files modified since the last commit.
	ModifiedFiles []string `json:"modified_files,omitempty"`

	// LastCommit is the SHA of the last commit.
	LastCommit string `json:"last_commit,omitempty"`

	// Branch is the current git branch.
	Branch string `json:"branch,omitempty"`

	// HookedBead is the bead ID on the agent's hook.
	HookedBead string `json:"hooked_bead,omitempty"`

	// Timestamp is when the checkpoint was written.
	Timestamp time.Time `json:"timestamp"`

	// SessionID identifies the session that wrote the checkpoint.
	SessionID string `json:"session_id,omitempty"`

	// Notes contains optional context from the session.
	Notes string `json:"notes,omitempty"`
}

Checkpoint represents a session recovery checkpoint.

func Capture

func Capture(polecatDir string) (*Checkpoint, error)

Capture creates a checkpoint by capturing current git and work state.

func Read

func Read(polecatDir string) (*Checkpoint, error)

Read loads a checkpoint from the polecat directory. Returns nil, nil if no checkpoint exists.

func (*Checkpoint) Age

func (cp *Checkpoint) Age() time.Duration

Age returns how long ago the checkpoint was written.

func (*Checkpoint) IsStale

func (cp *Checkpoint) IsStale(threshold time.Duration) bool

IsStale returns true if the checkpoint is older than the threshold.

func (*Checkpoint) Summary

func (cp *Checkpoint) Summary() string

Summary returns a concise summary of the checkpoint.

func (*Checkpoint) WithHookedBead

func (cp *Checkpoint) WithHookedBead(beadID string) *Checkpoint

WithHookedBead adds hooked bead context to a checkpoint.

func (*Checkpoint) WithMolecule

func (cp *Checkpoint) WithMolecule(moleculeID, stepID, stepTitle string) *Checkpoint

WithMolecule adds molecule context to a checkpoint.

func (*Checkpoint) WithNotes

func (cp *Checkpoint) WithNotes(notes string) *Checkpoint

WithNotes adds context notes to a checkpoint.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL