# `Tune.Ensemble`
[🔗](https://github.com/mikehostetler/tune/blob/v0.5.0/lib/tune/ensemble.ex#L1)

A program that runs compatible member programs and reduces their outputs.

Members must declare the same input and output fields. Each run calls every
member in order inside one execution, so all members share its call
allowance, step limit, and deadline. Member parameters are exposed as
`"m<index>.<name>"`, so artifacts load into a matching ensemble built by
application code.

The default reducer is a majority vote over canonical JSON outputs; ties go
to the earliest member. A custom reducer is trusted application code that
receives the ordered list of outputs and returns an output map or
`{:ok, map}` / `{:error, reason}`.

Construction makes no model calls. With `:size`, a seeded sample of that
many members is kept, as DSPy's Ensemble does.

# `t`

```elixir
@type t() :: %Tune.Ensemble{
  members: [Tune.Program.t()],
  reducer: :majority | ([map()] -&gt; term())
}
```

# `majority`

```elixir
@spec majority([map()]) :: map()
```

Majority vote with canonical equality; ties go to the earliest output.

# `new`

```elixir
@spec new([Tune.Program.t()], keyword()) :: {:ok, t()} | {:error, Exception.t()}
```

Builds an ensemble.

Options: `:reducer` (`:majority` or a 1-arity function), `:size`, `:seed`.

---

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