# CheckpointManager

**Kind:** Class

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

## Methods

| Method | Signature | Returns |
|---|---|---|
| `createWithGit` | `createWithGit(rootDir: string, config: Omit<CheckpointManagerConfig, 'rootDir' | 'backend'> & {
      sessionId?: string;
      staleAgeDays?: number;
    })` | `CheckpointManager` |
| `snapshot` | `snapshot(relPath: string, label: string)` | `boolean` |
| `rollback` | `rollback(relPath: string, index: number)` | `string | null` |
| `getSnapshots` | `getSnapshots(relPath: string)` | `readonly Snapshot[]` |
| `getSnapshotCount` | `getSnapshotCount(relPath: string)` | `number` |
| `getTotalCount` | `getTotalCount()` | `number` |
| `getTrackedFiles` | `getTrackedFiles()` | `string[]` |
| `clear` | `clear()` | `void` |
| `getBackend` | `getBackend()` | `CheckpointBackend` |

## Where it refuses work

- `CheckpointManager` stops the work with an early return when `!absPath.startsWith(path.resolve(this.rootDir))`, in 2 places.
- `CheckpointManager` stops the work with an early return when `!fs.existsSync(absPath)`.
- `CheckpointManager` stops the work with an early return when `fileSnaps.length === 0`.
- `CheckpointManager` stops the work with an early return when `snapIndex < 0 || snapIndex >= fileSnaps.length`.

## When something fails

- `CheckpointManager` handles failure in 1 place: it turns it into a return value in all 1.
