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.
Summary
Functions
Adjusts the boundary after an edit changed the line count.
Checks whether a line falls within the boundary (inclusive on both ends).
Checks whether a line range (start..end, both inclusive) falls entirely within the boundary.
Creates a new boundary for the given line range (both inclusive, 0-indexed).
Types
@type t() :: %MingaAgent.EditBoundary{ end_line: non_neg_integer(), start_line: non_neg_integer() }
A line range boundary (both inclusive, 0-indexed).
Functions
@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).
@spec contains_line?(t(), non_neg_integer()) :: boolean()
Checks whether a line falls within the boundary (inclusive on both ends).
@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.
@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.