# GitBackend

**Kind:** Class

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

**Implements:** `CheckpointBackend`

## Methods

| Method | Signature | Returns |
|---|---|---|
| `isGitRepo` | `isGitRepo(dir: string)` | `boolean` |
| `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` |

## Properties

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

## Where it refuses work

- `GitBackend` stops the work with `Error` when `!this.gitDir`.
- `GitBackend` stops the work with an early return when `!entries || entries.length === 0`, in 2 places.
- `GitBackend` stops the work with an early return when `!entries`.
- `GitBackend` stops the work with an early return when `fromIndex < 0 || fromIndex >= entries.length`.

## When something fails

- `GitBackend` handles failure in 7 places: it turns it into a return value in 3, discards it silently in 3, and logs it and continues in 1. A failure discarded silently leaves no trace for whoever debugs this later.
