# `MingaEditor.State.Operation`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_editor/state/operation.ex#L1)

Serializable semantic feedback for one correlated asynchronous operation.

# `active_status`

```elixir
@type active_status() :: :pending | :queued | :running
```

# `id`

```elixir
@type id() :: pos_integer()
```

# `kind`

```elixir
@type kind() ::
  :external_format
  | :git_stage
  | :git_unstage
  | :git_discard
  | :git_stage_all
  | :git_unstage_all
  | :git_commit
  | :lsp_references
  | :lsp_rename
```

# `resource`

```elixir
@type resource() :: String.t()
```

# `status`

```elixir
@type status() :: active_status() | terminal_status()
```

# `t`

```elixir
@type t() :: %MingaEditor.State.Operation{
  cancelable?: boolean(),
  id: id(),
  kind: kind(),
  message: String.t(),
  order: pos_integer(),
  progress: MingaEditor.State.OperationProgress.t() | nil,
  queue: MingaEditor.State.OperationQueue.t() | nil,
  resource: resource(),
  status: status()
}
```

# `terminal_status`

```elixir
@type terminal_status() :: :success | :error | :timeout | :canceled | :stale
```

# `active?`

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

Returns whether the operation can still receive lifecycle updates.

# `finish`

```elixir
@spec finish(t(), terminal_status(), String.t()) :: t()
```

Finishes an active operation and clears active-only queue and cancellation state.

# `new`

```elixir
@spec new(id(), kind(), resource(), String.t(), boolean(), pos_integer()) :: t()
```

Builds a pending operation with stable identity and deterministic order.

# `queued`

```elixir
@spec queued(t(), String.t(), MingaEditor.State.OperationQueue.t()) :: t()
```

Marks an active operation queued with scheduler-authored metadata.

# `report_progress`

```elixir
@spec report_progress(t(), MingaEditor.State.OperationProgress.t()) :: t()
```

Records valid domain-authored progress on an active operation.

# `running`

```elixir
@spec running(t(), String.t()) :: t()
```

Marks an active operation running and clears queue metadata.

# `terminal?`

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

Returns whether the operation has reached a semantic terminal status.

---

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