Skip to content

core(mailbox): principal-grade redesign — evaluate channel primitive + composable API #133

Description

@joeldsouzax

Follows #112 (PR #132, not merged — we redesign before it lands). The v1 mailbox shipped missing two things its own rigor contract required, and the API is not principal-grade.

The gaps (why this card exists)

  1. No channel-primitive evaluation — the survey core(mailbox): rebuild from kameo reference — queue + Signal + backpressure #112 explicitly required was skipped. core(mailbox): rebuild from kameo reference — queue + Signal + backpressure #112 mandated: "Existing crates: tokio::sync::mpsc, flume, thingbuf, async-channel, crossbeam-channel… Decide the primitive" and "Research — Vyukov intrusive MPSC, LMAX Disruptor, thingbuf design. No commitment before the survey." v1 defaulted to tokio::sync::mpsc with zero measured comparison. That is a skipped part of the contract, not a justified default.
  2. The API does not compose. bounded() is a free-floating function; Capacity is a separate value that doesn't flow into construction. The surface is procedural, not composable/functional.
  3. Not principal-grade cohesion across the Signal / error / weak-sender / construction surface.

Scope

A. Channel-primitive evaluation (measured, evidence-first)

Criterion benchmarks of the candidates under the mailbox's actual access pattern (bounded MPSC, Signal<A> element by value, 1 consumer + N contended producers), on the axes that matter here:

Candidates: tokio::sync::mpsc, flume, thingbuf, async-channel, crossbeam-channel (+ the Vyukov-intrusive / LMAX-disruptor designs as reference). Pick on the numbers; document the decision + the table. If the winner isn't tokio, it lands behind a small channel seam (which also unblocks the deferred loom/shuttle DST).

B. Composable / functional API

Rework construction so capacity and mailbox compose rather than sit as free primitives — e.g. Capacity::new(n)?.bounded::<A>() or a Mailbox::builder() — method-based, no free-floating bounded(), combinators where they genuinely fit. Principal-grade naming + cohesion.

C. Keep (this is an upgrade, not a teardown)

The #112 test net (17 tests), the criterion harness, the reproducible nix build .#mutants gate, Capacity boundary-safety, the large-variant discipline + size_of guards, and the fat-variant macro-enforcement plan (#114).

Rigor (same contract)

TDD; the 4 cross-cutting categories; proptest; mutation zero-survivors; criterion bench; god-level bar; everything reproducible via the pinned flake.

Related

Supersedes the mailbox impl from #112 / PR #132 · epic #122 · #19 (channel-handler strategy) · #55 (cancellation) · unblocks the loom/shuttle DST deferred from #112.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions