# `ReqManagedAgents.OutcomeResult`
[🔗](https://github.com/cash-mckeeman/req_managed_agents/blob/v0.16.0/req_managed_agents/lib/req_managed_agents/outcome_result.ex#L1)

What a session's accepted events show for one outcome.

`evaluations` holds only completed `OutcomeEvaluation` values for this
outcome. `new/1` is the only place that derives `status` and the order of
`evaluations`, and it recomputes both for an existing struct, so neither is
accepted as input. Evaluations are ordered by iteration (nil iterations
last, input order for ties). `status` is `:unknown` when an iteration is nil or
shared or `issues` holds a poisoning issue (see `poisoning_issues/0`);
otherwise `:pending` with no evaluations; otherwise the verdict at the
greatest iteration. `:pending` is not an active-evaluation state.

# `definition`

```elixir
@type definition() :: map()
```

The provider's first definition echo, verbatim; its keys and values are not interpreted here.

# `issue`

```elixir
@type issue() ::
  :unknown_result
  | :missing_event_id
  | :invalid_iteration
  | :invalid_description
  | :invalid_explanation
  | :invalid_processed_at
  | :invalid_start_event_id
  | :invalid_evaluation
  | :invalid_outcome
  | :conflicting_event_id
  | :conflicting_evaluation
  | :conflicting_definition
```

# `status`

```elixir
@type status() :: :pending | ReqManagedAgents.OutcomeEvaluation.result()
```

# `t`

```elixir
@type t() :: %ReqManagedAgents.OutcomeResult{
  definition: definition() | nil,
  description: String.t() | nil,
  evaluations: [ReqManagedAgents.OutcomeEvaluation.t()],
  issues: [issue()],
  outcome_id: String.t(),
  status: status()
}
```

# `issues`

```elixir
@spec issues() :: [issue()]
```

The closed set of diagnostic atoms an outcome may carry.

# `new`

```elixir
@spec new(map() | t()) :: {:ok, t()} | {:error, {:invalid_outcome_result, atom()}}
```

Validates a closed atom-keyed attribute map or an existing struct, then
derives `status` and the order of `evaluations`.

Nested evaluations must be `OutcomeEvaluation` structs for this outcome;
each is re-validated.

# `poisoning_issues`

```elixir
@spec poisoning_issues() :: [issue()]
```

The issues that make `status` `:unknown` whatever the evaluations say.

---

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