checkpoint

package
v0.11.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0, MIT Imports: 19 Imported by: 0

Documentation

Overview

Package checkpoint — filesystem checkpoints (master plan §4.8).

Before any destructive write, the agent calls Checkpoint.Snapshot(paths) to copy the current contents into ~/.overkill/checkpoints/<id>/. A single `overkill rollback <id>` (or the live /rollback slash command) restores the snapshot. Checkpoints auto-prune; only the last N are kept per session.

Goals:

  • tiny — no DB; flat file copies under a content-hashed dir
  • cheap — only files about to be mutated (<= 1 MiB each)
  • safe — never overwrites an existing checkpoint id

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Path    string `json:"path"`   // original absolute path
	Sha256  string `json:"sha256"` // content hash (also the filename in the checkpoint dir)
	Size    int64  `json:"size"`
	Mode    uint32 `json:"mode,omitempty"`
	Existed bool   `json:"existed"` // false → file did not exist before; rollback removes it
}

Entry is one file captured by the checkpoint. Stored at <root>/<id>/<sha>.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager owns the checkpoint root and per-session retention.

func NewManager

func NewManager(dir string, keepPerSession int) (*Manager, error)

NewManager creates a manager rooted at dir (typically ~/.overkill/checkpoints). keepPerSession bounds the number of retained checkpoints per session. projectRoot, when non-empty, restricts snapshots and restores to files under that path.

func NewManagerWithRoot

func NewManagerWithRoot(dir string, keepPerSession int, projectRoot string) (*Manager, error)

NewManagerWithRoot creates a manager with an optional projectRoot. When projectRoot is set, all snapshotted and restored paths must be within it.

func NewSessionManager

func NewSessionManager(dir string, keep int, workspace, sessionID string) (*Manager, error)

NewSessionManager preserves the common checkpoint layout while restricting snapshots, listing and restore to one owning session and workspace.

func (*Manager) List

func (m *Manager) List(sessionID string) ([]Manifest, error)

List returns checkpoints for a session, newest first. Empty session ID returns every checkpoint.

func (*Manager) Restore

func (m *Manager) Restore(id string) ([]string, error)

Restore preflights the complete manifest and all content before changing a target. A durable checkpoint of the present files is retained first, so even a later I/O failure leaves a recovery path for every overwritten/deleted byte.

func (*Manager) Snapshot

func (m *Manager) Snapshot(sessionID, reason string, paths []string) (*Manifest, error)

Snapshot copies the current contents of the given paths into a fresh checkpoint dir and returns the manifest. Paths that do not exist are recorded with Existed=false so Restore can delete them on rollback. Any unsupported path or size limit fails without publishing a checkpoint.

type Manifest

type Manifest struct {
	Version    int       `json:"version,omitempty"`
	ID         string    `json:"id"`
	SessionID  string    `json:"session_id,omitempty"`
	Reason     string    `json:"reason,omitempty"`
	CreatedAt  time.Time `json:"created_at"`
	Entries    []Entry   `json:"entries"`
	Scope      string    `json:"scope,omitempty"`
	RecoveryOf string    `json:"recovery_of,omitempty"`
}

Manifest records the contents of one checkpoint.

Jump to

Keyboard shortcuts

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