# `core/universe/contract.ts`

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

The universe contract: what a universe folder (universes/&lt;id&gt;/) must provide, and how the core reads it. A universe gives words, colours, texts and a renderer. It never changes the state, the quests or the rules.

**Standards that cite this file**: [alta.universe/0.1: universe packs](https://docs.altasystem.ai/reference/advanced/specs/alta-universe-0.1)

## Exports

### `Term` 
```ts
interface Term { label: string; gloss?: string }
```

### `UniverseManifest` 
```ts
interface UniverseManifest {
  id: string;
  /** Position in the switcher; the lowest opens first. */
  order: number;
  name: string;
  tagline: string;
  version: string;
  languages: string[];
  fonts: { display: string; body: string };
  /** Words that only this universe uses. The core, the content and the client must never contain them (tested). */
  distinctive: string[];
}
```

### `Vocabulary` 
```ts
interface Vocabulary {
  kinds: Record<EntityKind, Term>;
  roles: Record<AgentRole, Term & { creature: string }>;
  /** Name of the player's avatar when it has no name yet, and of a level and of xp. */
  avatar: Term;
  level: Term;
  xp: Term;
  /** The edge of the world where devices and accounts sit, and the whole world. */
  edge: Term;
  world: Term;
}
```

### `Palette` 
```ts
type Palette = Record<"bg" | "bg2" | "ink" | "muted" | "accent" | "ok" | "warn" | "bad" | "mock" | "panel" | "panelInk" | "line", string>;
```

### `Copy` 
```ts
type Copy = Record<string, string | string[]>;
```

### `Camera` 
```ts
interface Camera { x: number; y: number; w: number; h: number; zoom: number }
```

### `Draw` 
```ts
interface Draw {
  ctx: CanvasRenderingContext2D;
  /** Seconds since start. */
  t: number;
  palette: Palette;
}
```

### `Renderer` 
```ts
interface Renderer {
  /** Draws the ground of the world, in world coordinates (the camera transform is already applied). */
  background(d: Draw, cam: Camera, layout: Layout, world: WorldState): void;
  link(d: Draw, a: Placed, b: Placed, kind: "flow" | "cycle" | "control"): void;
  /** Draws one entity at (p.x, p.y). `pulse` is 0..1, the phase of its rhythm for automations. */
  entity(d: Draw, p: Placed, focus: boolean, pulse: number): void;
  avatar(d: Draw, x: number, y: number, facing: number, moving: boolean): void;
  /** Optional layer above everything (light, fog, particles), in world coordinates. */
  foreground?(d: Draw, cam: Camera, layout: Layout): void;
}
```

### `Universe` 
```ts
interface Universe {
  manifest: UniverseManifest;
  vocabulary: Vocabulary;
  palette: Palette;
  copy: Record<string, Copy>;
  renderer: Renderer;
  /** Optional stylesheet for the interface, applied only while the universe is active. */
  skin?: string;
  /** Optional guided onboarding of this world (alta.onboarding/0.1, see core/onboarding). */
  onboarding?: unknown;
  /** Optional scenes of this world (alta.cinematics/0.1, see core/cinematics). */
  cinematics?: unknown;
}
```

### `UniverseError` 
```ts
class UniverseError extends Error { … }
```

### `checkUniverse` 
Checks a universe against the contract; returns the list of problems (empty when it holds).

```ts
function checkUniverse(u: Universe): string[]
```

### `text` 
A text of the active universe, else the neutral text, else the key itself (visible, so a gap is never hidden).

```ts
function text(key: string, universe: Copy | undefined, neutral: Copy, vars: Record<string, string> = {}): string
```
