checkpoint

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package checkpoint persists Ralph loop state between runs so a halted loop can be resumed with `ralph resume <file>`.

The format is intentionally simple JSON; older checkpoints written by future Ralph versions remain readable as long as new fields are added (never renamed or repurposed).

Index

Constants

View Source
const CurrentVersion = 1

CurrentVersion is the schema version written into every checkpoint.

Variables

View Source
var ErrUnsupportedVersion = errors.New("unsupported checkpoint version")

ErrUnsupportedVersion is returned when Load encounters a checkpoint with a version Ralph does not understand.

Functions

func Delete

func Delete(path string) error

Delete removes a checkpoint file. Missing files are not an error.

func Save

func Save(path string, s State) error

Save writes the state atomically (write+rename) so a crash mid-write never leaves a partial file.

Types

type State

type State struct {
	Version           int       `json:"version"`
	SavedAt           time.Time `json:"saved_at"`
	Prompt            string    `json:"prompt"`
	Model             string    `json:"model"`
	WorkingDir        string    `json:"working_dir"`
	PromisePhrase     string    `json:"promise_phrase,omitempty"`
	Iteration         int       `json:"iteration"`
	MaxIterations     int       `json:"max_iterations"`
	LastSummary       string    `json:"last_summary,omitempty"`
	ConsecutiveErrors int       `json:"consecutive_errors,omitempty"`
	ConsecNoChanges   int       `json:"consecutive_no_changes,omitempty"`
}

State is the serialised loop state.

func Load

func Load(path string) (State, error)

Load reads and parses a checkpoint file.

Jump to

Keyboard shortcuts

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