# DiskBackend

**Kind:** Class

**Source:** [`atloria-monorepo/libs/agent-core/src/context/checkpoint-backend.ts`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/libs/agent-core/src/context/checkpoint-backend.ts#L188)

**Implements:** `CheckpointBackend`

## Methods

| Method | Signature | Returns |
|---|---|---|
| `save` | `save(snap: Snapshot)` | `void` |
| `load` | `load(relPath: string)` | `Snapshot[]` |
| `loadLatest` | `loadLatest(relPath: string)` | `Snapshot | null` |
| `deleteFile` | `deleteFile(relPath: string)` | `void` |
| `deleteFrom` | `deleteFrom(relPath: string, fromIndex: number)` | `void` |
| `getTrackedFiles` | `getTrackedFiles()` | `string[]` |
| `getTotalCount` | `getTotalCount()` | `number` |
| `getSnapshotCount` | `getSnapshotCount(relPath: string)` | `number` |
| `clear` | `clear()` | `void` |
| `evictOldest` | `evictOldest()` | `boolean` |
| `flush` | `flush()` | `void` |

## Properties

| Property | Type |
|---|---|
| `sessionId` | `string` |
| `sessionDir` | `string` |

## Where it refuses work

- `DiskBackend` stops the work with an early return when `!snaps || snaps.length === 0`, in 2 places.
- `DiskBackend` stops the work with an early return when `!snaps`, in 2 places.
- `DiskBackend` stops the work with an early return when `fromIndex < 0 || fromIndex >= snaps.length`.

## When something fails

- `DiskBackend` handles failure in 13 places: it discards it silently in 10, turns it into a return value in 2, and logs it and continues in 1.
