## ADDED Requirements ### Requirement: Snapshot creation The system SHALL provide `sandbox.snapshot()` to create a point-in-time filesystem snapshot. Parameters: - `expiration?: number` — TTL in milliseconds (0 for no expiration) #### Scenario: Snapshot stops the session and returns Snapshot instance - **WHEN** `sandbox.snapshot()` is called on a running sandbox - **THEN** the current session SHALL be stopped and a `Snapshot` SHALL be returned ### Requirement: Snapshot retrieval and listing The system SHALL provide `Snapshot.get()`, `Snapshot.list()`, and `Snapshot.tree()` for managing snapshots. #### Scenario: Retrieve snapshot by ID - **WHEN** `Snapshot.get({ snapshotId: "snap_abc" })` is called - **THEN** it SHALL return the snapshot with matching ID #### Scenario: List snapshots with pagination - **WHEN** `Snapshot.list({ name: "my-sandbox" })` is called - **THEN** it SHALL return a paginated list of snapshots for that sandbox #### Scenario: Ancestry tree is accessible - **WHEN** `Snapshot.tree({ snapshotId: "snap_abc" })` is called - **THEN** it SHALL return the ancestry tree of the snapshot ### Requirement: Snapshot deletion The system SHALL provide `snapshot.delete()` to remove a snapshot. #### Scenario: Deleted snapshot is no longer listable - **WHEN** `snapshot.delete()` is called and then `Snapshot.list()` is called - **THEN** the deleted snapshot SHALL no longer appear in the list ### Requirement: Snapshot-based sandbox creation The system SHALL support creating sandboxes from snapshots via `Sandbox.create({ source: { type: "snapshot", snapshotId } })`. #### Scenario: Sandbox created from snapshot has matching filesystem - **WHEN** a sandbox is created with a snapshot source and a file is written, then another sandbox is created from the resulting snapshot - **THEN** the second sandbox SHALL contain the file from the first ### Requirement: Snapshot retention The system SHALL support `keepLastSnapshots` retention policy on sandboxes. #### Scenario: Retention evicts oldest snapshots - **WHEN** a sandbox has `keepLastSnapshots: { count: 3 }` and a 4th snapshot is created - **THEN** the oldest snapshot SHALL be evicted