checkpoint

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package checkpoint stores per-turn PRE-IMAGES of files the agent edits, so a bad run can be rewound without touching git: before edit_file mutates a file, its current bytes (or its absence) are snapshotted under .memcode/checkpoints/<session>/<seq>/. Rewinding to turn N restores every touched file to its earliest pre-image from turns N..latest — the state the tree had before turn N ran. Shadow copies only: git stays untouched, and changes made OUTSIDE the agent's edit tool (bash, the user's editor) are not captured — this is the agent-edit undo, not a filesystem time machine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checkpoint

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

Checkpoint is an open checkpoint accumulating snapshots for the current turn.

func (*Checkpoint) Empty

func (cp *Checkpoint) Empty() bool

Empty reports whether the checkpoint captured nothing (no edits this turn).

func (*Checkpoint) Snapshot

func (cp *Checkpoint) Snapshot(relPath string)

Snapshot records path's current state (bytes or absence) once per checkpoint. relPath may be absolute (it is normalized against the root). Best-effort: snapshot failures never block the edit itself.

type File

type File struct {
	Path    string `json:"path"`    // repo-relative
	Existed bool   `json:"existed"` // false → the edit CREATED it (rewind deletes it)
}

File is one snapshotted pre-image.

type Log

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

Log is one session's checkpoint store.

func New

func New(root, sessionID string) *Log

New opens (or creates) the checkpoint log for a session.

func (*Log) Begin

func (l *Log) Begin(label string) *Checkpoint

Begin opens a checkpoint for one turn. Nothing is written until the first Snapshot, so turns that never edit cost nothing. Prunes old checkpoints.

func (*Log) List

func (l *Log) List() []Manifest

List returns this session's checkpoints that captured edits, oldest first.

func (*Log) Restore

func (l *Log) Restore(seq int) ([]string, error)

Restore rewinds the tree to BEFORE checkpoint seq: every file touched from seq onward is restored to its earliest pre-image (created files are deleted), and the consumed checkpoints are dropped. Returns the restored file list.

type Manifest

type Manifest struct {
	Seq   int       `json:"seq"`
	Label string    `json:"label"` // the user turn that caused the edits, trimmed
	At    time.Time `json:"at"`
	Files []File    `json:"files"`
}

Manifest describes one checkpoint (one turn that edited files).

Jump to

Keyboard shortcuts

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