MuxSeam
N-way multiplexer over a Seam.
Produces independent Seam views — one per channel tag — that share a single upstream collection of delegate's Seam.incoming. This satisfies the kuilt contract that Seam.incoming is single-collection: only MuxSeam ever collects from delegate; each channel view subscribes to the internally-shared flow.
Framing
Every outbound frame is prefixed with a 1-byte channel tag. Every inbound frame is filtered by its first byte and delivered to the matching channel view with the tag byte stripped. Frames with no matching channel are silently discarded.
Late-subscriber semantics
Each view subscribes before channel returns and buffers frames in its reliable spool, so the caller can send immediately and collect the reply later. The shared upstream uses replay = 0: frames emitted before the matching channel is created are still discarded. Each view's spool holds DeliveryPolicy.DEFAULT_CAPACITY frames with Overflow.SUSPEND. An unread or slow view can fill its spool and the shared buffer, stalling all channels on this mux. Consume created views promptly; the per-view bound is in frames, not bytes.
Channel identity
channel is idempotent: calling it twice with the same tag returns the same Seam instance. Thread-safe: concurrent channel calls are serialised by an internal reentrant lock so the backing map is never raced.
Per-channel close
Closing a channel view ends that view only: its Seam.incoming completes, its Seam.state latches SeamState.Torn and its Seam.peers collapses to { selfId }, so a holder reading either learns the channel is gone. The base Seam remains live for all other channel views. The base closes only when the owner calls closeBase (or closes the delegate directly). This deliberate owner-driven design avoids fragile last-channel reference-counting and keeps lifecycle ownership clear: the entity that opened the delegate is the entity that closes it.
A send on a closed view is refused with an IllegalStateException, as Seam requires of any torn seam — it used to be swallowed, which was only defensible while the view still claimed to be SeamState.Woven (#2372).
Parameters
the underlying Seam whose Seam.incoming this class owns.
a CoroutineScope for the shared upstream collector and per-view pipes.