# Lanes

How rapid shares one machine between many nodes, and how to set slots per lane.

Every node runs through a lane with a fixed number of slots. A ready node queues until a slot frees, so twenty scenes don't start twenty Chrome renders at once. Each node records `wait_ms` and `run_ms`, so the bottleneck shows.

| Lane | Default slots | For |
|---|---|---|
| `think` | 8 | agent nodes: storyboards, builds, reviews. Limited by tokens, not compute |
| `gpu` | 1 | GPU work, such as Blender shots; one process already fills the GPU |
| `web` | 3 | renders, checks, and contact sheets: Chrome pages |
| `encode` | 2 | ffmpeg joins, muxes, and phone copies |
| `cpu` | 6 | mixes, hearing a track, scans, image batches, and approvals |

Defaults (`DEFAULT_SLOTS` in `contracts/src/graph.ts`) were measured on one Apple silicon laptop.

## Setting slots

`slots` in `$RAPID_HOME/config.json`; lanes left out keep their defaults, and each value is a whole number of at least 1:

```json
{
  "slots": { "think": 4, "web": 2 }
}
```

The daemon reads it at start: `rapid daemon stop`, then `rapid daemon ensure`.

## Queue order

A higher `priority` in the node's spec starts first, then first come, first served. Priority never changes what a node makes.

## Running your own command in a lane

`rapid lane` runs a command as a one-node job through a lane, streams its output, and exits with its code:

```sh
rapid lane encode -- ffmpeg -i in.mov -c:v libx264 out.mp4
```

Ctrl-C cancels the job (exit 130). The node shows in the pane and the screening page like any other.

## Seeing the lanes

```sh
rapid lanes
```

```text
think   0/8 running, 0 queued
gpu     0/1 running, 0 queued
web     2/3 running, 0 queued
encode  0/2 running, 1 queued
cpu     0/6 running, 0 queued
```

The pane draws a live row per lane with each running and queued node.
