ReductionBounds.Mailbox (ReductionBounds v0.1.0)

Copy Markdown View Source

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.

Summary

Types

spec()

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

state()

@type state() :: map()

Functions

add(a, b)

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

counters()

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

counts_within?(counts, limits)

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

initial(spec, queue)

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

new(options)

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

run(spec, queue, actions)

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

step(spec, state, action)

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

validate(spec)

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

zero()

@spec zero() :: map()