Skip to main content
The snapshot system provides content-addressable filesystem state capture with Merkle-committed integrity. Take a baseline before an agent runs, detect changes incrementally, and roll back to any previous state.

SnapshotManager

Each tracked path gets its own exclusion filter, so .gitignore rules are interpreted relative to their own root directory.

Methods

create_baseline() -> SnapshotManifest

Capture the initial filesystem state. Must be called before create_incremental().

create_incremental() -> tuple[SnapshotManifest, list[Change]]

Capture current state and return changes since the last snapshot. Uses mtime/size as a fast check, then hashes changed files.

restore_to(snapshot_number: int) -> list[Change]

Restore the filesystem to a previous snapshot. Retrieves file content from the object store, deletes files created after that snapshot. Returns the list of changes applied.

compute_restore_diff(snapshot_number: int) -> list[Change]

Dry-run: compute what restore_to() would change without modifying the filesystem.

load_manifest(number: int) -> SnapshotManifest

Load a snapshot manifest from disk by number.

save_session_metadata(meta: SessionMetadata) -> None

Save session metadata to the session directory.

snapshot_count() -> int

Number of snapshots taken (including resumed sessions).

load_session_metadata(session_dir: str) -> SessionMetadata (static)

Load session metadata from a session directory without creating a full manager.

Example

Resuming Sessions

A new SnapshotManager pointed at an existing session_dir automatically loads the latest manifest from disk. This means create_incremental() works without calling create_baseline() again, and snapshot_count() returns the correct value.

ExclusionConfig


SnapshotManifest

A snapshot recording the state of all tracked files. Returned by create_baseline() and create_incremental().

ContentHash

SHA-256 content hash. Immutable and hashable.

FileState

State of a single file within a snapshot.

Change

A filesystem change detected between snapshots.

SessionMetadata

Metadata for a sandboxed session. Ties together the snapshot chain, network audit trail, and execution context.
Constructor arguments (read-only after creation): Mutable properties (set after the session runs): Read-only introspection properties:

Security Properties

  • Merkle commitment: Single root hash commits to the entire filesystem state
  • Content-addressable dedup: Identical file content stored once
  • APFS clonefile: Copy-on-write on macOS for efficient snapshots
  • Atomic writes: Temp file + rename for all persistent state
  • TOCTOU protection: File content verified after storage