# ContextResolver

**Kind:** Class

**Source:** [`atloria-monorepo/packages/doc-automation/src/v2/stages/stage-10-generation/context-resolver.ts`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/packages/doc-automation/src/v2/stages/stage-10-generation/context-resolver.ts#L38)

ContextResolver - Resolves cross-chunk entity references

When generating documentation for a document, we may need entities
that exist in OTHER chunks. This resolver fetches them from the
global entity map without loading everything into memory.

## Methods

| Method | Signature | Returns |
|---|---|---|
| `setEntityMap` | `setEntityMap(entityMap: Map<string, Entity>)` | `void` |
| `resolveForPlan` | `resolveForPlan(plan: DocumentPlan)` | `Promise<Entity[]>` |
| `resolveByName` | `resolveByName(entityName: string)` | `Entity | undefined` |
| `resolveById` | `resolveById(entityId: string)` | `Entity | undefined` |
| `handleDeepLoadRequest` | `handleDeepLoadRequest(request: DeepLoadRequest)` | `Promise<DeepLoadResponse>` |
| `getByFilePath` | `getByFilePath(pattern: string)` | `Entity[]` |
| `getByType` | `getByType(type: Entity['type'])` | `Entity[]` |
| `clearCache` | `clearCache()` | `void` |
| `getCacheStats` | `getCacheStats()` | `{ size: number; hits: string[] }` |
| `hasEntity` | `hasEntity(entityId: string)` | `boolean` |
| `getEntityCount` | `getEntityCount()` | `number` |

## Where it refuses work

- `ContextResolver` stops the work with an early return when `cached?.found`.
- `ContextResolver` stops the work with an early return when `entity.name === entityName`.
- `ContextResolver` stops the work with an early return when `this.deepLoadedCache.has(cacheKey)`.
