# `ReductionBounds.Mailbox`
[🔗](https://github.com/zacky1972/reduction_bounds/blob/v0.1.0/lib/reduction_bounds/mailbox.ex#L1)

Executable ordinary-message selective receive, with finite supplied conditions.

`:begin_receive` restarts at the oldest retained message. `:inspect` tests the
next message against ordered clauses and guards, retaining misses. Arrivals
append; a suspended receive resumes at its cursor. `:timeout` is an observation
allowed only for a finite timeout after all present messages were rejected.
Its numeric value is not a cost or elapsed-time guarantee. Selection removes
only the first eligible message. Post-return arrivals remain in the queue.

Conditions bound all initial/arriving messages, including unrelated messages,
and total counters across repeated receives. No receive optimization or
inference from initial queue length is used. Checks remain supplied-model
evidence, not source correspondence or a cost/progress theorem.

# `spec`

```elixir
@type spec() :: %{
  clauses: list(),
  message_size: ReductionBounds.RpcTerm.Size.t(),
  limits: map(),
  timeout: non_neg_integer() | :infinity
}
```

# `state`

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

# `add`

```elixir
@spec add(map(), map()) :: map()
```

# `counters`

```elixir
@spec counters() :: [atom()]
```

# `counts_within?`

```elixir
@spec counts_within?(map(), map()) :: boolean()
```

# `initial`

```elixir
@spec initial(spec(), list()) :: {:ok, state()} | {:error, term()}
```

# `new`

```elixir
@spec new(keyword()) :: {:ok, spec()} | {:error, term()}
```

# `run`

```elixir
@spec run(spec(), list(), list()) :: {:ok, map()} | {:error, term()}
```

# `step`

```elixir
@spec step(spec(), state(), term()) :: {:ok, state(), map()} | {:error, term()}
```

# `validate`

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

# `zero`

```elixir
@spec zero() :: map()
```

---

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