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

Review state for workspace-local agent drafts.

The state field is intentionally limited to stable states. Promote, apply, discard, and resolve are transitions, not stored states.

# `error`

```elixir
@type error() :: term()
```

# `state`

```elixir
@type state() :: :clean | :draft | :needs_review | :conflict
```

# `t`

```elixir
@type t() :: %MingaEditor.State.WorkspaceReview{
  changed_files: [Minga.Project.FileRef.t()],
  conflict_files: [Minga.Project.FileRef.t()],
  in_progress?: boolean(),
  last_error: error() | nil,
  state: state()
}
```

# `agent_completed`

```elixir
@spec agent_completed(t(), [Minga.Project.FileRef.t()]) ::
  {:ok, t()} | {:error, term()}
```

Marks draft work as ready for review, or clean when no drafts exist.

# `agent_made_more_edits`

```elixir
@spec agent_made_more_edits(t(), [Minga.Project.FileRef.t()]) ::
  {:ok, t()} | {:error, term()}
```

Records more draft edits while staying in draft mode.

# `agent_resumed`

```elixir
@spec agent_resumed(t()) :: {:ok, t()} | {:error, term()}
```

Moves review or conflict work back to draft mode when an agent resumes.

# `agent_started_editing`

```elixir
@spec agent_started_editing(t(), [Minga.Project.FileRef.t()]) ::
  {:ok, t()} | {:error, term()}
```

Moves a clean workspace into draft mode.

# `clean`

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

Clears all draft and conflict metadata and returns to clean.

# `conflict_count`

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

Returns the number of conflicting files.

# `discard`

```elixir
@spec discard(t()) :: {:ok, t()} | {:error, term()}
```

Clears drafts or conflicts without applying them.

# `discard_file`

```elixir
@spec discard_file(t(), Minga.Project.FileRef.t()) :: t()
```

Discards one file from draft and conflict metadata.

# `draft_count`

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

Returns the number of changed draft files.

# `mark_needs_review`

```elixir
@spec mark_needs_review(t(), [Minga.Project.FileRef.t()], error() | nil) :: t()
```

Marks the workspace as needing review, optionally recording an error.

# `new`

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

Creates a clean review state.

# `pending?`

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

Returns true when the review has unapplied drafts, conflicts, or a recorded error.

# `promote_found_overlaps`

```elixir
@spec promote_found_overlaps(t(), [Minga.Project.FileRef.t()], term()) ::
  {:ok, t()} | {:error, term()}
```

Marks an overlap detected during promote.

# `promote_succeeded`

```elixir
@spec promote_succeeded(t()) :: {:ok, t()} | {:error, term()}
```

Marks a successful promote as clean.

# `resolved_and_promoted`

```elixir
@spec resolved_and_promoted(t()) :: {:ok, t()} | {:error, term()}
```

Marks conflicts as resolved and promoted.

# `set_changed_files`

```elixir
@spec set_changed_files(t(), [Minga.Project.FileRef.t()]) :: t()
```

Sets changed files without changing the stable state.

---

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