# SemanticIndex

**Kind:** Class

**Source:** [`atloria-monorepo/libs/agent-core/src/semantic/semantic-index.ts`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/libs/agent-core/src/semantic/semantic-index.ts#L31)

## Methods

| Method | Signature | Returns |
|---|---|---|
| `index` | `index()` | `Promise<IndexStats>` |
| `reindexFiles` | `reindexFiles(files: string[])` | `Promise<void>` |
| `search` | `search(query: string, topK: number)` | `Promise<SearchResult[]>` |
| `isIndexed` | `isIndexed()` | `boolean` |

## Where it refuses work

- `SemanticIndex` stops the work with an early return when `results.length >= maxFiles`, in 2 places.
- `SemanticIndex` stops the work with an early return when `toReindex.length === 0`.
- `SemanticIndex` stops the work with an early return when `gitFiles`.
- `SemanticIndex` stops the work with an early return when `!includeExtensions.includes(ext)`.
- `SemanticIndex` stops the work with an early return when `!fs.existsSync(gitDir)`.

## When something fails

- `SemanticIndex` handles failure in 8 places: it discards it silently in 5, turns it into a return value in 2, and logs it and continues in 1.
