# `core/quests/sources/repair.ts`

<p class="generated-note">Generated from the exports of <a href="https://github.com/altasystem-ai/alta/blob/main/core/quests/sources/repair.ts"><code>core/quests/sources/repair.ts</code></a> · <code>npm run docs:gen</code></p>

Repair quests generated from the map (PLAN-V2 §2.1, lot Q2): an entity of a repairable kind in `error` or `degraded` opens one repair quest, proven by the map itself (check `entity`, never declarable). `incomplete` opens none in v1: it is missing configuration, already covered by the campaign. Life cycle (the core's record() writes the incidents): the entity heals → the quest is done, 40 xp once per incident, and it stays shown as done for 24 h; a relapse within 24 h is the same incident (no second xp); the entity leaves the map → the quest is removed, without xp.

**Standards that cite this file**: No standard page cites this file yet.

## Exports

### `REPAIR_BRANCH` 
```ts
const REPAIR_BRANCH = "_repair"
```

### `REPAIRABLE` 
Kinds that can be repaired (PLAN-V2 §2.1).

```ts
const REPAIRABLE: readonly EntityKind[]
```

### `BROKEN` 
States that open a repair.

```ts
const BROKEN: readonly EntityState[]
```

### `HEALTHY` 
What the map shows once it is healthy again.

```ts
const HEALTHY: EntityState[]
```

### `repairUid` 
```ts
const repairUid = (entityId: string) => …
```

### `isBroken` 
```ts
const isBroken = (e: Entity) => …
```

### `repairGiver` 
Who gives the quest: the entity's own role, else the Operator for an automation, the Architect otherwise.

```ts
function repairGiver(e: Entity): string
```

### `repairQuest` 
```ts
function repairQuest(e: Entity, say: Say, since?: string): QuestDef
```

### `repairBranch` 
The repair branch for this map and this save: a quest for each broken entity, and for each entity still on the
map whose incident is open (it just healed: the core sees it done and gives the xp) or was solved within 24 h.

```ts
function repairBranch(world: WorldState, save: Save, now: number, say: Say): Branch | null
```
