Documentation
¶
Overview ¶
Package snapshot captures and restores the files under a working directory for opt-in workspace snapshots (--snapshots) and --rewind.
A store lives at <root>/.tinyagent/snapshots. File contents are kept once each, by SHA-256, under objects/; each snapshot is a manifest under manifests/ listing every captured path with its type, permission bits and content hash. Nothing is ever deleted automatically.
Index ¶
Constants ¶
const DefaultMaxFileBytes = 2 << 20
DefaultMaxFileBytes is the default max_file_bytes (2 MiB).
const StoreDir = ".tinyagent/snapshots"
StoreDir is the store's location relative to the working directory.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Change ¶
type Change struct {
// Op is "M" (modified: restored to the snapshot), "A" (added since:
// removed) or "D" (deleted since: recreated).
Op string
Path string
// contains filtered or unexported fields
}
Change is one difference between the working directory and a snapshot.
type Entry ¶
type Entry struct {
Path string `json:"path"` // slash-separated, relative to the root
Type string `json:"type"` // "file" or "symlink"
Mode uint32 `json:"mode,omitempty"`
Hash string `json:"sha256,omitempty"`
Size int64 `json:"size,omitempty"`
Target string `json:"target,omitempty"` // symlink target
}
Entry is one captured path.
type Manifest ¶
type Manifest struct {
Version int `json:"version"`
ID string `json:"id"`
Root string `json:"root"`
Kind string `json:"kind"`
Step int `json:"step"`
Time string `json:"time"`
MaxFileBytes int64 `json:"max_file_bytes"`
Entries []Entry `json:"entries"`
// Dirs lists every captured directory (without the root itself).
Dirs []string `json:"dirs,omitempty"`
// Ignored lists the gitignored paths left out (an ignored directory
// once); Large lists the files over MaxFileBytes; Excluded lists the
// configured exclusions (trajectory and event log files). A rewind never
// removes any of them.
Ignored []string `json:"ignored,omitempty"`
Large []string `json:"large,omitempty"`
Excluded []string `json:"excluded,omitempty"`
}
Manifest is one snapshot.
type Options ¶
type Options struct {
// MaxFileBytes is the largest file captured; 0 means DefaultMaxFileBytes.
MaxFileBytes int64
// Exclude lists absolute paths never captured (a directory excludes
// everything under it): the trajectory and the
// event log database. A trajectory's .tinyagent-*.json save temps and
// a database's -wal, -shm and -journal files are excluded with them.
Exclude []string
}
Options configures a store.
type Plan ¶
type Plan struct {
Changes []Change
// contains filtered or unexported fields
}
Plan lists what restoring target would change, sorted by path.
type Result ¶
type Result struct {
Restored []string
// NotRestored lists the path that failed first and every planned path
// after it; the restore stops at the first failure.
NotRestored []string
Err error
}
Result reports a restore.
type Store ¶
type Store struct {
Root string // canonical working directory
Dir string // the store directory
// contains filtered or unexported fields
}
Store reads and writes one store.
func OpenExisting ¶
OpenExisting opens the store at dir for root without creating anything.
func (*Store) Apply ¶
Apply carries out plan: removals first, then directories, then writes. It stops at the first failure.
func (*Store) Load ¶
Load reads a manifest, checking it belongs to this root and that every object it needs is present.
func (*Store) PlanRestore ¶
PlanRestore compares the working directory with target. Paths target left out (gitignored, oversized or excluded) are never touched.