# `Minga.Parser.BufferRegistration`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga/parser/buffer_registration.ex#L1)

Parser synchronization state for one registered editor buffer.

All transitions live here so the manager remains the sole process owner while registration invariants stay explicit and independently testable.

# `phase`

```elixir
@type phase() ::
  :idle
  | {:awaiting_snapshot, reference()}
  | {:parsing, pos_integer(), Minga.Buffer.ChangeLog.sequence()}
```

# `t`

```elixir
@type t() :: %Minga.Parser.BufferRegistration{
  config: Minga.Parser.BufferConfig.t(),
  force_full?: boolean(),
  generation: reference(),
  id: pos_integer(),
  last_completed_version: non_neg_integer(),
  latest_dirty_sequence: Minga.Buffer.ChangeLog.sequence(),
  phase: phase(),
  synced_sequence: Minga.Buffer.ChangeLog.sequence()
}
```

# `accepts_version?`

```elixir
@spec accepts_version?(t(), pos_integer()) :: boolean()
```

Returns whether a version belongs to the current or most recently completed parse.

# `await_snapshot`

```elixir
@spec await_snapshot(t(), reference()) :: t()
```

Marks an asynchronous snapshot request as in flight.

# `awaiting?`

```elixir
@spec awaiting?(t(), reference()) :: boolean()
```

Returns whether a snapshot token belongs to the current request.

# `begin_parse`

```elixir
@spec begin_parse(t(), pos_integer(), Minga.Buffer.ChangeLog.sequence(), boolean()) ::
  t()
```

Marks a parser version and snapshot target as in flight.

# `complete_parse`

```elixir
@spec complete_parse(t(), pos_integer()) :: {:ok, t()} | :stale
```

Completes only the matching parser version.

# `complete_unchanged`

```elixir
@spec complete_unchanged(t(), Minga.Buffer.ChangeLog.sequence()) :: t()
```

Completes an unchanged snapshot without parser emission.

# `mark_dirty`

```elixir
@spec mark_dirty(t(), Minga.Buffer.ChangeLog.sequence()) :: t()
```

Records the newest observed buffer change sequence.

# `new`

```elixir
@spec new(pos_integer(), Minga.Parser.BufferConfig.t(), reference()) :: t()
```

Creates a registration that requires an initial full parse.

# `pumpable?`

```elixir
@spec pumpable?(t()) :: boolean()
```

Returns whether an idle registration has synchronization work.

# `restart`

```elixir
@spec restart(t()) :: t()
```

Resets volatile parser state and requires a fresh full snapshot.

# `snapshot_cursor`

```elixir
@spec snapshot_cursor(t()) :: :full | Minga.Buffer.ChangeLog.sequence()
```

Returns the cursor to request from the buffer.

# `synchronized?`

```elixir
@spec synchronized?(t(), Minga.Buffer.ChangeLog.sequence()) :: boolean()
```

Returns whether the parser is synchronized through the required buffer sequence.

---

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