ElectionLobby

interface ElectionLobby

A pre-session lobby over a symmetric mesh. Not a Room — during the lobby there is no admit handshake, no admitted roster, no heartbeat: just the live connected peers and a reactive elected host. A Room is created exactly once, at start/awaitRoom, by adopting the woven seam with a now-fixed role. See docs/host-election-design.md.

Properties

Link copied to clipboard
abstract val host: StateFlow<PeerId>

The elected host — electHost(peers) — reactive. Every peer computes the same value.

Link copied to clipboard
abstract val peers: StateFlow<Set<PeerId>>

Live set of connected peers (includes selfId). Join / leave / two-group-merge are all just set changes. Sourced from us.tractat.kuilt.core.Seam.peers — never a discovery roster such as NwLoom.visiblePeers, which accumulates and never removes.

Link copied to clipboard
abstract val selfId: PeerId

This peer's own identifier.

Link copied to clipboard
abstract val state: StateFlow<SeamState>

The underlying seam's own lifecycle — Weaving / Woven / Torn — exposed so a consumer can distinguish the two ways liveness can collapse mid-election (#1466): a transport tear (SeamState.Torn) versus a membership drain (peers shrinking while state stays SeamState.Woven). Sourced from us.tractat.kuilt.core.Seam.state — same value the lobby's own collapse detection races against.

Functions

Link copied to clipboard
abstract suspend fun awaitRoom(memberName: String? = null): ElectionOutcome

Await the session as a member: suspend until the elected host freezes the lobby, acknowledge it, and adopt the seam as us.tractat.kuilt.session.SessionRole.Joiner. (The host obtains its Room from start instead.)

Link copied to clipboard
abstract suspend fun leave()

Leave the lobby, closing the underlying seam — unless a Room has already adopted it. Idempotent.

Link copied to clipboard
abstract suspend fun start(memberName: String? = null): Room

HOST-ONLY. Close the lobby and begin the session: run the freeze/ack round, then adopt the seam as us.tractat.kuilt.session.SessionRole.Host. Retries internally while membership churns; returns the admitted Room once every member has acknowledged.