# `Minga.RenderModel.Window.LineIdentity`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga/render_model/window/line_identity.ex#L1)

Persistent durable identity rope for logical buffer lines.

The rope is an AVL tree whose leaves are contiguous source-id runs. Nodes cache
logical size and height, so line count is O(1), rank lookup and splices are
O(log runs), and unchanged subtrees are structurally shared. Adjacent source-id
runs are coalesced after every concatenation.

# `source_id`

```elixir
@type source_id() :: non_neg_integer()
```

# `t`

```elixir
@opaque t()
```

# `transition`

```elixir
@type transition() :: {:ok, t()} | :reset_required
```

# `apply_edit`

```elixir
@spec apply_edit(t(), Minga.Buffer.EditDelta.t()) :: transition()
```

Applies one document edit to the durable identity rope.

# `apply_edits`

```elixir
@spec apply_edits(t(), [Minga.Buffer.EditDelta.t()]) :: transition()
```

Applies edits in order, stopping transactionally when reconciliation fails.

# `content_epoch`

```elixir
@spec content_epoch(t()) :: non_neg_integer()
```

Returns the content epoch owning this identity rope.

# `height`

```elixir
@spec height(t()) :: non_neg_integer()
```

Returns the cached AVL height for invariant checks.

# `line_count`

```elixir
@spec line_count(t()) :: non_neg_integer()
```

Returns the number of current logical lines in O(1).

# `new`

```elixir
@spec new(non_neg_integer(), non_neg_integer()) :: t()
```

Creates an identity rope for the current logical-line count.

# `reset`

```elixir
@spec reset(t() | nil, non_neg_integer(), non_neg_integer()) :: t()
```

Starts a new content epoch, intentionally permitting source-id reuse.

# `run_count`

```elixir
@spec run_count(t()) :: non_neg_integer()
```

Returns the number of contiguous source-id runs for invariant checks.

# `source_id`

```elixir
@spec source_id(t(), non_neg_integer()) :: {:ok, source_id()} | :error
```

Returns the durable source id at a zero-based logical-line rank.

# `source_ids`

```elixir
@spec source_ids(t()) :: [source_id()]
```

Materializes source ids in rank order for diagnostics and tests.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
