# Concepts

> Lanes, clashes, claims and the merge plan, and how Lanekeeper decides what to tell an agent.

## Lanes

A **lane** is one git worktree, usually on its own branch, with the agents (or people) working in it. Lanekeeper
compares each lane with the base branch (`origin/HEAD`, then `origin/main`, unless you set `base`), including uncommitted and untracked
files. It reads your worktrees but never changes your index, stash, refs or config: it takes its own snapshots
through a private index.

## Changes as code, not lines

For every lane Lanekeeper works out which **symbols** changed (functions, methods, classes, types, constants,
routes, migrations, dependencies, environment variables) and which new uses each lane adds. A changed signature
is recorded with how many arguments it accepts, so a new call can be checked against it.

TypeScript, JavaScript and Python are analyzed in depth: imports, re-exports, arity and keyword arguments. Go,
Rust, Java, Kotlin, Swift, Ruby, C# and PHP are analyzed by symbol name, so their clashes are capped at warn.

## Clashes

A **clash** is a pair of lanes whose changes don't fit together. Each clash has:

- a **rule** (R1–R10) that says what kind of problem it is;
- a **severity**: `high` will break the build or lose work, `warn` needs a look;
- a **confidence** between 0 and 1. Clashes below the report threshold (0.6) are not shown;
- one instruction: what the agent should do about it.

Lanekeeper is deterministic. The same changes always give the same clashes; nothing is guessed by a language
model. When it isn't sure, it stays quiet: precision comes before recall.

## Warn and block

In **warn** mode (the default) agents are told about clashes, right after the edit that causes one, but never
stopped. In **block** mode an edit that
would create a high-severity clash is refused before it is written, and the agent gets the reason. Set it in
`.lanekeeper/config.yml`:

```yaml
mode: block
```

## Claims

A **claim** reserves code for one lane: a path glob (`src/auth/**`) or a symbol (`src/auth.ts#login`). Other lanes'
edits inside it become R5 clashes: warn for a soft claim, high for an exclusive one. Exclusive claims don't
overlap.

```sh
lk claim "src/auth/**" -m "moving sessions to cookies" --exclusive --ttl 2h
lk release --all
```

A claim lasts for its TTL (`claims.defaultTtl`, 30 minutes by default, or `--ttl`); `lk release` ends it early.

## Merge plan

`lk plan` orders the lanes so that each merge breaks as little as possible: a lane that changes an API goes before
the lanes that start using the new form, and the older of two migrations goes first. The GitHub Action prints the
same plan for open pull requests.
