Package-level declarations

Types

Link copied to clipboard
interface Connection

A point-to-point, message-oriented duplex link between exactly two peers.

Link copied to clipboard

A transport-agnostic stream of inbound peer Connections — the "front door" of a hosted session. Unlike KtorServerLoom.nextLink(), which collapses each accepted session into a finished 2-peer us.tractat.kuilt.core.Seam, accept yields the raw Connection (a hub spoke) so a composer can bond many of them into one group view.

Link copied to clipboard

Raised through acceptPump's onFailure when a conn's handle does not finish within the timeout.

Link copied to clipboard
object Hello

The one-shot identity preamble: the first frame on a handshaking link.

Link copied to clipboard
fun interface LinkAdmission

Admission policy for mesh links: decides, per link, whether a handshaked connection may join the mesh.

Link copied to clipboard
class LinkRejectedException(val remoteId: PeerId, val attested: Boolean) : Exception

The per-link signal raised by Mesh.addLink when a handshaked link is rejected by the mesh's LinkAdmission policy. The offending connection is already closed and was never published.

Link copied to clipboard

A Seam over a fully-connected N-peer mesh of point-to-point Connections, with support for admitting links that arrive after construction.

Functions

Link copied to clipboard
fun CoroutineScope.acceptPump(source: ConnectionSource, handshakeTimeout: Duration, onFailure: (Throwable) -> Unit = {}, handle: suspend (Connection) -> Unit): Job

Persistent, concurrent, handshake-timed accept loop. Drains source forever; each accepted Connection is handled in its OWN child coroutine under handshakeTimeout, so one conn that connects but never completes its handshake can never starve later conns — the sequential while (isActive) { handle(source.accept()) } pattern wedges on such a conn; this replaces it.

Link copied to clipboard
suspend fun handshaking(conn: Connection, selfId: PeerId, dispatcher: CoroutineContext): Seam

A 2-peer Seam for transports that do NOT carry identity out of band. Sends a Hello preamble as the first frame, awaits the peer's preamble, then delegates to identified over the same single collection of Connection.incoming. Suspends until the peer's preamble arrives.

Link copied to clipboard
suspend fun hubMesh(selfId: PeerId, connections: List<Connection>, dispatcher: CoroutineContext, random: Random = Random.Default, policy: DeliveryPolicy = DeliveryPolicy.Reliable, admission: LinkAdmission = LinkAdmission.AcceptAll): Mesh

Build a hub-mesh Seam — the start-empty-and-grow topology (a host admitting joiners).

Link copied to clipboard
fun identified(conn: Connection, selfId: PeerId, remoteId: PeerId, dispatcher: CoroutineContext, policy: DeliveryPolicy = DeliveryPolicy.Reliable): Seam

A byte-transparent 2-peer Seam over a Connection whose two identities are known. broadcast == sendTo(remoteId). Woven at construction; Torn on conn EOF/error or close. Concurrent sends are serialized through an internal channel + single writer so wire order matches call order.

Link copied to clipboard
suspend fun meshSeam(selfId: PeerId, connections: List<Connection>, dispatcher: CoroutineContext, random: Random = Random.Default, policy: DeliveryPolicy = DeliveryPolicy.Reliable, admission: LinkAdmission = LinkAdmission.AcceptAll): Mesh

Build a fully-connected N-peer mesh Seam from a set of raw point-to-point connections.

Link copied to clipboard
suspend fun peerMesh(selfId: PeerId, connections: List<Connection>, dispatcher: CoroutineContext, random: Random = Random.Default, policy: DeliveryPolicy = DeliveryPolicy.Reliable, admission: LinkAdmission = LinkAdmission.AcceptAll): Mesh

Build a symmetric peer-mesh Seam — the contract-conforming N-peer fabric.