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 ¶
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 ¶
NewManagerWithRoot creates a manager with an optional projectRoot. When projectRoot is set, all snapshotted and restored paths must be within it.
func NewSessionManager ¶
NewSessionManager preserves the common checkpoint layout while restricting snapshots, listing and restore to one owning session and workspace.
func (*Manager) List ¶
List returns checkpoints for a session, newest first. Empty session ID returns every checkpoint.
func (*Manager) Restore ¶
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 ¶
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.