# `MingaAgent.EditBoundary`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_agent/edit_boundary.ex#L1)

Defines a line range that an agent session is allowed to edit within a buffer.

Boundaries are per-buffer, per-session. When set, agent edits outside the
boundary are rejected with a descriptive error. Boundaries adjust automatically
when edits change the line count within the bounded region or when user edits
above the boundary shift line numbers.

# `t`

```elixir
@type t() :: %MingaAgent.EditBoundary{
  end_line: non_neg_integer(),
  start_line: non_neg_integer()
}
```

A line range boundary (both inclusive, 0-indexed).

# `adjust`

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

Adjusts the boundary after an edit changed the line count.

`edit_line` is the 0-indexed line where the edit started. `line_delta` is the
number of lines added (positive) or removed (negative) by the edit.

- Edits within the boundary: the end shifts by `line_delta`.
- Edits above the boundary: both start and end shift by `line_delta`.
- Edits below the boundary: no change.

Returns `nil` if the boundary collapses to zero or negative size (e.g., the
user deleted all lines within the boundary).

# `contains_line?`

```elixir
@spec contains_line?(t(), non_neg_integer()) :: boolean()
```

Checks whether a line falls within the boundary (inclusive on both ends).

# `contains_range?`

```elixir
@spec contains_range?(t(), non_neg_integer(), non_neg_integer()) :: boolean()
```

Checks whether a line range (start..end, both inclusive) falls entirely within the boundary.

# `new`

```elixir
@spec new(non_neg_integer(), non_neg_integer()) :: {:ok, t()} | {:error, String.t()}
```

Creates a new boundary for the given line range (both inclusive, 0-indexed).

Returns `{:error, reason}` if the range is invalid.

---

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