Files
piik/docs/research/channel-network-design.md
T

55 KiB

Piik 3.0 Channels, Rooms And Networking

Accepted direction 2026-10-27. This document owns the isolated 3.0 responsibility and networking design. The prototype README describes running behavior; TODO owns implementation and decisions. The 2.x routing contract remains unchanged.

Accepted Direction

The owner defines the room owner as the user who actually operates the room: its detailed state, management and distribution belong together. A separate configurable file-storage service is not wanted. Ordinary URLs and manual bookmarks remain the entry model; automatic address discovery is not planned. Both Browser pages and App processes may host rooms. Hosting follows the actual runtime: closing its Browser page ends Browser hosting; an App-owned room runs until hosting is stopped or the App process ends. Server remains the explicitly started service for unattended operation.

Use one room routing owner: a base tree carries conversation, voice and files. Pictures start on usable existing paths, then converge locally towards source-rooted delivery through bounded background transitions. All authorized, capable room peers can be relay candidates; only viewers and necessary transit nodes receive the picture. Both stages use the same route state and transports. The owner accepted this routing foundation and durable room records with cached attachments. The room-data model owns simple shared file delivery on those same paths. Browser and Native room owners run the shared Rust core with local confirmation/storage. Their base paths carry authenticated chat/history, voice and verified file ranges; TODO owns remaining route and platform integration.

Terminology And Roles

English Chinese Meaning
User 用户 Every participant, including domain owners, room owners and sharers.
Domain 域 The top-level container for users, roles and rooms; named Channel in the current code.
Domain owner 域主 The user operating the channel's directory, membership and role authority.
Room 房间 A conversation, history and media scope within a channel.
Room owner 房主 The user operating that room's state, management and base distribution network.
Role 身份组 A domain-scoped permission group; a user may have several roles.
Sharer 分享者 The user originating a particular screen, voice publication or file offer.

Management identities and activities overlap. A room owner can share, watch or forward, and an ordinary user can publish without becoming the room owner. A file sender supplies that file; sending never transfers room management to them. On P2P room paths, a relay is a participating endpoint doing forwarding work, not a separately deployed relay server. Sending, receiving and forwarding can coexist on the same user endpoint.

The activity model separates personal page activities from Browser, App and Server hosting lifetimes. Moving a room requires explicit transfer of its operation and saved state; automatic takeover is not selected.

Authority And Information Boundaries

Owner Its authoritative state and work
Domain runtime Domain identity, users, roles, room-to-owner bindings and authorized room-directory summaries; initial contact and signaling rendezvous.
Room runtime, operated by its room owner Detailed room metadata, room admission and grants, confirmed conversation, file descriptions/available holders, base-tree planning and screen-route scheduling.
Participant runtime Local captures, playback, file copies and the actual peer transports/forwarding work it has admitted.

The domain directory is a projection of room details. It does not become a second writer of the room name, private-room policy or history. Domain membership and role policy place the upper bound on access; the room runtime applies its room policy within that bound. Removing global membership cannot be overridden by a local room grant. Use the same typed permission rules and authenticated identity facts across both scopes, rather than unrelated permission engines.

Directory visibility and access remain separate. Public rooms admit channel users; private rooms require their room admission. Hidden private rooms expose neither directory details nor activity to unauthorized users. A nickname is not identity, and an invitation establishes admission rather than proving that two visitors are the same user.

The domain directory binds each room to its owner's current authenticated runtime connection, separately from the owner's persistent user identity. With no runtime, the room is unavailable. One room has one current runtime binding; reconnecting replaces that binding without granting a stale session authority over its successor. Room admission, initial offer/answer and broken-tree repair instructions travel through this existing domain rendezvous to the room runtime; establishing or repairing the tree cannot depend on that tree already working. The domain forwards these envelopes; the room owner decides room actions. WebRTC leaves the signaling carrier to the application (W3C connection establishment).

The room owner needs no separate public URL. The App creates these runtimes through normal create/join actions; users do not configure a second daemon or storage server. Peer delivery preserves this authority and recovery path without adding another permission owner.

When B joins A's domain and creates a room, B's actual Browser or App runtime operates that room. B needs no new domain, and A's domain service does not take over its execution or history.

After room admission, the room owner confirms room changes and message order. Chat and history requests use the base paths after room admission. Use short-lived session signing keys, bound to admitted sessions and the current room-host binding through authenticated domain rendezvous. Sign the original payload bytes with a maintained Ed25519 implementation, verify before parsing, and resolve the author and permissions from current trusted domain facts. A relay cannot substitute its identity or supply its own permission snapshot. Long-lived admission credentials never enter the peer carrier.

Peer requests use the same room authorization and storage operations as local execution. They run in the room owner's existing serialized turn without changing its routing state or becoming domain-issued turns. Their confirmations return to the request; domain revisions retain their authority/reply-fencing purpose. Projection order and request authority remain separate: an older room snapshot cannot replace newer routes, but an earlier authorized action can still complete. Successful room actions are acknowledged after the domain has installed a projection covering that turn. Until then, the existing pending request retains its result; explicit failures do not wait for a projection. Confirmation follows the requester's current session and permission facts; another participant leaving or changing roles cannot invalidate it. Invitation verification follows the invited user's known permissions, not an online-session requirement for someone who has not joined yet. The room-data model owns persistence, chat retry identity, history correlation/complete pages, file copies and manual address replacement. Live results are room-host signed without a permanent signed history log; bounded queued output rechecks current authority. File delivery consumes the shared control transport rather than owning unrelated room commands. Domain and room data may reside on different devices; an App may compose both runtimes locally. The domain's public listener serves its Web UI and signaling; local approval and App control stay on a separate loopback listener. Local and public entries address the same domain, but only the local launcher receives its owner bootstrap. Invitations use the domain's advertised public entry, not the administrator's loopback address. Stopping that domain leaves unrelated approved sites running. The App's own domain keeps one local identity and storage namespace independent of its listener port and temporary public URL. Only its currently bound local entry receives automatic App access; this does not merge external site approvals.

A user and a live endpoint are different concepts. An App's Native participant and a Browser page are distinct endpoints of the same authenticated user, with their own signing identities, transports and activities. One App uses one Native endpoint for its rooms in a domain; each room retains its own authority and data. An online hosting endpoint proves availability, not that the person is reading, watching or participating in voice. Reconnect preserves identity rather than matching a nickname or treating a shared invitation as a shared user. Domain bookmarks connect independent domains; they do not introduce federation or shared authority between those domains.

Peer media forwarding terminates hop encryption at admitted relays. Room access must cover every relay; this model does not add end-to-end encryption against those forwarding endpoints.

Routing Foundation

Choice And Cost

Model Benefit Cost and choice
One tree for every kind of traffic One stable set of paths; any connected members can exchange data. Some pictures incur extra hops. Use established paths as the baseline; a non-viewing relay can still be essential for connectivity.
A new distribution plan for every source or transfer Paths can follow each source's recipients. Repeats planning for room-wide voice and ordinary files. Keep source-specific demand only where it changes useful forwarding work.
Base paths for startup, then selective source-rooted convergence Reuses room connectivity where media can be admitted; improves affected paths while preserving playback. Needs distinct viewing/transit demand and temporary transition resources. Selected; both stages use the same admission and transition owner.

This compares topology and work, not measured performance. A routing root owns coordination; it need not forward every media byte. Only nodes on an admitted path incur that path's forwarding work. A star still places that work on its root.

One Base Tree Per Participating Room

The room owner maintains one committed, bounded tree among admitted room participants. Its root identifies the coordination owner; data may travel in both directions. A connected tree already provides a unique path between any two members. Room entry can establish this base path before microphone or screen sharing begins; browsing the channel directory does not connect every room. The base tree also considers better edges after relevant connectivity or capacity changes, using the same bounded admission and transition rules as screen plans. Replacing a base edge preserves its admitted flows until their replacement paths are ready; an open candidate DataChannel alone does not retire active media work.

Traffic Route and lifecycle
Room commands and confirmed chat Send to the room owner for authorization/confirmation, then distribute confirmed changes to authorized room participants.
Voice Project each joined source to its listeners over the base tree's unique paths; send each source at most once over a required directed edge.
File bytes Use the existing base paths; the room-data model develops shared range delivery and cached-source selection without another topology planner.
Screen picture and source audio One distribution plan per publication: start on usable existing paths, then improve affected branches while preserving selected viewers and necessary relays.

Chat and files use reliable DataChannels; voice stays on WebRTC media tracks. Using one tree does not mean putting voice into an ordered file stream. The data stack is SCTP over DTLS over ICE/UDP. Configure ordered, fully reliable DataChannels for file delivery; SCTP supplies retransmission without adding a TCP file connection. Under BUNDLE, data and media can share the selected ICE transport for a compatible peer pair, as described in RFC 8831. An additional logical DataChannel does not require another exposed file port. Different peer connections can still use different UDP sockets; this is transport reuse within a connection, not a promise of one global socket for the room. Web delivery and HTTPS/WSS signaling retain their existing control transport; UDP-only refers to the selected peer media/data path, not every service in Piik. Receivers do not get their own microphone back. Muting local listening does not discard an admitted downstream flow; authorized forwarding need not activate the local microphone or loudspeaker.

A file hop needs application-level forwarding, finite buffers, cancellation and content verification. DataChannel itself joins two endpoints, not a whole tree. A forwarding node need not save the complete file. Use negotiated message limits, bufferedAmount and bufferedamountlow for bounded sending under the WebRTC DataChannel API. Participant cooperation distributes transfer load and permits path/source repair where alternatives exist. Room confirmation and authority still belong to the room owner; replicated file bytes do not introduce automatic room-owner takeover.

Screen Demand Uses Reachable Paths

Viewers are a publication's destinations, not the complete set of eligible relays. Start with usable established paths and project source-to-viewer demand onto them. On the base tree this is the union of the unique paths to those viewers; retain every required intermediate node. Prune only branches with no downstream demand. Stopping local playback removes local viewing demand, not an admitted forwarding duty. A relay receives the needed stream without presenting it locally; Browser relaying can still require decode/re-encode work.

Do not add a shortest-path optimizer above the existing router or derive an edge from a pair of nicknames on a diagram. A reachable A-B and B-C do not prove A-C. New candidates follow the same availability/direct-convergence rules, ICE checks, source-path admission, capacity reservation and commit proof. A healthy route stays until an admitted replacement is proved. Optional optimization without overlap capacity waits or stops; it cannot interrupt working playback. Viewing changes alone do not trigger a global rewire or remove a needed bridge.

The room runtime owns one routing controller. Its base topology, voice/file flows and screen subscriptions share connection facts, edge admission and repair. Each flow retains its own replacement and completion state; it does not get its own probing, reconnection or optimization subsystem. The sharer owns capture and declares publication demand, while this controller selects distribution. An ICE timeout for one picture cannot block another picture or ordinary chat.

The relay candidate pool may include every authorized room participant with the required capability and capacity. This does not deliver video to all of them. Publication metadata can advertise a share without its bytes, as illustrated by LiveKit's publication/subscription model. For a fixed A-B-C-D tree, if A sends 4 Mbps and only B watches, the needed edge carries 4 Mbps; broadcasting to C and D as well adds two copies, making 12 Mbps of summed hop traffic. This is an arithmetic example, not a measurement. When D also watches, C is necessary transit even if C never displays the picture.

For example, a room's base tree may be:

Room owner B ── C ── D
           └── E

C sends a file to E through C-B-E. C and E need not establish a new direct path for that transfer. If E shares a picture only with D, E-D can be a shorter screen candidate when reachable, rather than a requirement to bypass C or B. If it fails, keep the working admitted path. Every admitted hop must have the source and enough actual capacity; an existing control link alone does not prove this.

The source and viewers determine a screen plan, while the room owner manages the plan's lifecycle. Different publications can reuse a physical pair. Stopping one publication removes its work, not an unrelated call, file transfer or base link.

App-Assisted Viewing

A Browser may attach its currently approved App's live endpoint to its own screen subscription. The existing App hosting description supplies that endpoint; do not infer it from a same-user participant list. The room validates that the helper is an admitted endpoint of the same user with room access. The Browser remains the real viewer and supplies decoded and presentation proof; the App receives and forwards without adding a fictitious watch or reading activity.

For that publication, the Browser becomes a presentation leaf. Replacing parent → Browser → children with parent → App → {Browser, children} uses the same prepared branch operation, retaining old playback until affected viewers prove the replacement. The exact App-to-Browser presentation edge does not consume WAN fanout; its PeerConnection, media output and overlap resources still use normal admission. Same-user endpoints alone do not qualify for this exception. Native capture preview follows this same presentation-edge rule.

The association belongs to the Browser's live watch. Unwatch, access removal or session expiry removes it. Losing App control clears the helper while retaining ordinary viewing when domain signaling is writable; otherwise the existing authority-recovery window applies. Necessary transit for other viewers and App room hosting retain their own lifetimes. Failed assistance keeps healthy playback and uses the existing candidate-failure memory, rather than a second retry loop.

Start On Existing Paths, Then Converge

The room tree's root owns coordination. Its edges are bidirectional, so projecting a flow from its sharer already makes that sharer the logical media source; no new PeerConnection or change of room owner is needed merely to reverse flow direction. Renaming the root cannot shorten the tree's unique paths. A shorter path requires different, actually usable edges. Reverse flow may use all three neighbors of an internal base node; the small fanout policy for new branches is a topology choice, not device capacity.

  1. A new viewer first attaches to a usable existing publication branch or an admitted source-to-viewer path on the base tree, installing only its missing suffix on ready room paths. Prove picture readiness; an open control DataChannel is not a decoded frame.
  2. While that path plays, the same availability/direct-convergence/quality owner may prepare a bounded alternative parent or branch using room-wide eligible peers; there is no separate fallback or shortest-path router.
  3. Reserve the actual overlap resources, prepare the candidate, and require its media proof and the applicable non-regression evidence before committing. Replace one affected branch, then release only its old media work. The player renders one committed input; source sound switches with its picture.
  4. Keep the base connections needed by conversation, voice, files or other publications. They remain available to attempt media recovery, but do not continuously carry a second copy of an already-converged picture.

These are stages of one publication plan, not two complete live video networks. Fallback after a later failure still needs media preparation on its selected path; keeping the base connection is not a promise of instant hot-standby video. If a base path lacks the capability or capacity for that picture, retain its control traffic and let the same availability planner seek another admitted media path. Successful base-path playback is not a prerequisite for trying an alternative. A viewer remains connecting until a selected path proves ready.

Reconcile on relevant demand, connectivity or capacity changes. A new viewer adds a branch; stopping viewing removes only demand that no downstream still needs; a departed relay repairs only affected paths. Preserve healthy unrelated branches. Each admitted session gets one direct attempt per publication. Viewing toggles and unrelated membership updates must not reset spent candidate opportunities. Once useful attempts finish, keep the working route rather than probing periodically for a mathematical global optimum. Repairing a base edge reconciles only flows using that edge. An independent, healthy screen branch stays in place while room authority remains valid; a change in the base plan does not reset every publication to its startup path.

Availability work takes priority over optional optimization. Without overlap capacity, leave healthy playback in place and defer or finish the optional attempt. A bounded-gap change belongs only to necessary availability repair, under the existing transition rules. Source generation, current route and operation identity fence late callbacks; new work cannot inherit completion from a retired candidate.

Screen preparation also has a finite lifetime when its shared connection is already connected. Each publication waits on one unproved frontier edge whose parent has the source; downstream nodes waiting for that parent are not blamed for missing frames. Reconciliation does not extend the current wait. Expiry retires that media attempt through the same plan, preserving unrelated flows and base paths. Lower candidate quality keeps the change uncommitted under that same deadline; it is not evidence that the media path has failed. Transport, track and render failure retain their existing immediate retirement paths. The room owns the deadline and the domain's existing clock wakes a remote room only when it is due; Browser and Native hosting do not add separate routing timers.

A publication prepares one alternative branch, including its transit nodes. First-picture viewers need decoded proof; pure transit proves forwarding, not decoding. Existing viewers keep their decoded input while the candidate passes shared quality comparison and supplies a prewarmed player frame. Selection retains prepared inputs/outputs before retiring old leases. Source sound, volume, pause and container fullscreen follow player handover; native element fullscreen defers it. Preparation/switching share one finite operation: first-viewer approval bounds the remaining wait to the quality-evidence lifetime. Failure or changed viewing demand cancels the candidate while preserving required old paths.

One Owner For Actual Connections

A participant's transport runtime owns its PeerConnections, negotiation, ICE recovery and final close. Base-tree and screen plans request admitted flows; they cannot independently close or mutate a connection another flow still uses. The combined physical graph may contain cycles while each forwarding plan remains acyclic and each publication has one committed input at a receiver.

Reusable Browser media transceivers retain bidirectional intent, including outputs with encoding declarations. Removing an outgoing source must leave the carrier able to receive its replacement; the standard track-removal semantics preserve reception from sendrecv, while sendonly becomes inactive.

Reuse is conditional on the same domain, compatible peer/session/authority identity and capacity. Do not share transports across unrelated domains. Reusing code is not one global operation queue: serialize changes to a physical connection, but let independent room/publication operations progress independently. Source replacement keeps its publication and changes its source generation; callbacks, input grants and reservations retain their original ownership.

The room runtime gives each publication's directed media work its own live identity and exact input. Both stay stable while the work remains needed, including non-viewing transit. Replacing its input creates new downstream work even on the same physical connection. A prepared branch keeps those identities when selected, so its senders and players can adopt the already-proven media. Transport aggregation, proof and cleanup retain the same ownership; a retired callback cannot act on its successor.

A channel has no fixed media allowance divided among rooms. The participant runtime counts its actual connections, forwarded copies, encoders/decoders and transition overlap. Watching more pictures creates real additional work; being present alone does not allocate a fraction of an invented room-wide bitrate pool. One edge can carry several voices or pictures, so an edge-count cap alone is not a bound on bytes or encoding work. Admission accounts for the actual flows on it.

File transfer and realtime traffic compete for real resources even when assigned different DataChannels or PeerConnections. Apply bounded file concurrency and backpressure, and use existing WebRTC priority controls where supported. Leave congestion control to the transport. RFC 8831 explains shared SCTP congestion, while RFC 8835 describes media/data prioritization.

Browser media relays decode received tracks; eligible ordinary outputs reuse node-local encoding groups under ADR-0014. Forwarding owns input consumption until its last output retires, independently of local watching. Do not budget Browser relays as packet-only SFUs. The WebRTC relay sample demonstrates forwarding, not unlimited inexpensive multi-hop video. Keep paths short and validate simultaneous voice/video/file work on actual endpoints.

Reachability And Repair

A user needs an admitted path into the room tree, not a direct connection to every other user. Joining or repairing a tree uses mature ICE/STUN handling and the existing bounded retry principles. Reuse reachable participants as relays; do not add an all-pairs probe, full mesh or periodic topology rebalance. With unchanged authority and demand, an exhausted required path becomes eligible again after the room's five-second repair cooldown. The existing room wake-up schedules missing paths while retaining healthy branches, their failed-shortcut history and running screen-operation deadlines. Required leases on a retired physical pair receive a new pair identity. Each admitted physical pair acquires its connection resources once. Terminal failure releases those resources; if signaling is interrupted, the still-current lease reports that failure when signaling resumes instead of recreating the pair. Base reconciliation retains proved edges and re-evaluates unproved reservations against the ready tree, preferring shallower ready parents. Equally deep choices retain the current eligible parent. Unchanged edges keep their physical leases and endpoint acknowledgements. A complete ready base path can replace an unproved screen fallback; proved media branches remain installed. Confirmed physical-pair failure informs both directions in every affected plan, including candidates first tried by another activity. A publication's media failure remains local to that publication. Base failure history retires when neither current demand nor an installed transit path needs it. Required-path retries reopen exhausted choices while preserving other active connection attempts and their leases. Each attempt retains its transport-owned deadline; another path's repair wake does not restart or cancel it.

App Local discovers addresses through Binding-only STUN on its selected LAN interface, without contacting public STUN services. That listener belongs to the local domain's lifetime; Browser and Native participants receive the same discovery configuration. Public invitations and approved external sites retain their domain's configured ICE servers. An individual rejected ICE candidate does not retire the connection or its other candidate paths. Ordinary Native peers gather IPv4 and IPv6 through the same RTC transport owner; an unavailable address family does not disable the other. Wildcard listeners exclude loopback interfaces from ICE/STUN discovery. Explicit loopback listeners remain available for a configured local forwarding backend.

The coordinated UDP candidate keeps preparation inside one authorized physical pair attempt. The domain's existing transport book issues its replacement UUID; logical room/media leases and operation deadlines stay unchanged. Only currently capable Native endpoints participate. The prepared socket transfers to the ordinary PC after mutual completion, with no competing reader or separate route graph.

Server shares fixed UDP listeners across its peer connections. Piik's socket owner dispatches packets through str0m's public Rtc::accepts and handle_input interfaces; the SDK owns ICE and media demultiplexing. The Server entry binds both address families on the actual HTTP port by default, before opening domain data. Configured listeners must all bind successfully; IPv6 sockets are v6-only so both families can use that port. Local binding and an optional public IP/port mapping are separate facts. An FRP backend on loopback requires an explicit loopback bind; wildcard enumeration advertises real interfaces. Candidate availability is evaluated across the bound listeners: a family without an advertisable address does not invalidate another family's usable candidates. The service owns these sockets until its peer connections retire. App peers keep their exclusive sockets, gateway mapping and coordinated preparation; a shared Server listener does not advertise preparation capability.

Each Native pair may map its actual default-gateway IPv4 socket using the released portmapper client. Its background probe, protocol selection and renewal stay with that library; mapping does not delay ICE or replace IPv6 and STUN candidates. Mapped addresses use the existing candidate signaling. Pair retirement joins the address watcher and requests best-effort deactivation through the library's existing lifecycle.

Prepare a replacement, prove it usable, commit, then release old work. A base edge requires both endpoints to confirm an installed open control DataChannel before bidirectional voice, not merely a connected PeerConnection. DataChannel failure repairs base paths while preserving the pair's healthy media leases. Silent voice uses transport/forwarding readiness rather than waiting for audible speech. Picture availability requires a decoded frame. Shared link failure reconciles all affected flows through the same transport owner. Retiring room-data work ends its queued and waiting sends while preserving the pair's picture and input work. A new room-data lease may acquire fresh channels on that same pair. Temporary ICE disconnection retains its Pair; confirmed failure retires it and allows the room to establish a replacement. Signaling resynchronization replays current connection, base and media facts alongside unfinished negotiation. A local report does not confirm that the room received it. Use these existing events; add no periodic probe protocol.

A tree cannot connect two groups when no permitted, reachable edge joins them. An available participant relay or an accepted external fallback is needed in that case; changing the graph algorithm cannot manufacture connectivity. The App P2P mode therefore retains initial signaling/rendezvous and connectivity helpers without requiring a separately rented media server. WebRTC transport requirements distinguish direct connectivity from relay support. A successful public webpage request does not prove a WebRTC media path.

Activity And Lifecycle

Room browsing, voice, screen sharing and watching remain independent activities. Opening another view does not retarget a microphone or stop another room's media. A participant retains the room connection while an admitted activity, transfer or forwarding duty needs it; changing the highlighted sidebar item is not a global media shutdown. Joining voice can be listen-only; opening a room never grants microphone capture. The source owner and controlled device authorize remote input for a publication, source generation and controller session. Domain/room administration alone grants no desktop control. Changing the focused picture never retargets an input grant.

Input follows the committed screen flow back to its source, using a separate encrypted logical DataChannel on the same peer connection. Room conversation and file readiness keep their base-path scope; input failure does not retire those consumers. A failed route trial preserves current grants, while replacing the selected flow retires the affected grants and held input. Native input uses the existing capture-source identity and page-owned capture lifetime. One App process owns the physical desktop executor across its approved sites; hosting a room does not extend a closed page's permission to control that desktop. The domain admits controller registrations against the selected subscription and delivers their keys only to the source endpoint. Room operators and relays do not receive them. A lost input channel propagates retirement along the remaining selected hops without closing media. Transport retirement releases held input; removing or replacing an authenticated registration also retires its cipher. The App's global stop returns active sources to explicit approval. Its key is a Browser preference; the App holds only the current process registration.

Event Outcome
Room owner changes views, minimizes the window or closes an in-page panel Keep the hosting session and its room running. Visibility is not authority.
A Browser page closes End its personal voice, shares and watches. Its Browser-hosted rooms stop; App-hosted rooms continue without handoff.
A hosting runtime loses domain signaling while it remains alive Retain the existing session recovery window; expiry pauses its live rooms.
A Browser's local App control connection ends End native activities owned by that control connection. Browser media and App hosting keep their own lifetimes.
App hosting stops or its process ends Pause its hosted rooms and release that runtime's activities and connections; saved room data remains.
An administration page closes while Server owns the runtime The deliberately running service continues; its lifetime is independent of that page.
Browser-owned room runtime closes or expires The room pauses; Browser hosting must not silently move to the domain owner's device.
Room owner stops the hosting runtime The room becomes unavailable; saved data remains. No automatic replacement is selected.
Same owner restarts using saved room data Restore room identity/history and establish new live sessions. Captures require explicit activation; reopening data does not resume a saved call.
Sharer stops or leaves End that publication, preserving other sources and the room base tree.
A relay leaves Repair affected paths through the same route owners; keep unrelated flows.
File's original sender leaves Another online admitted holder may supply its copy. With no holder, the file is unavailable until a source returns.
Room access is removed Stop that user's affected activities and new delivery; local downloaded bytes cannot be recalled.
Domain authority connection is lost First phase retains the existing bounded authority-recovery rule; do not silently operate indefinitely with an old global permission snapshot.

Start with the current 20-second signaling recovery policy. Failure to replace a socket does not extend its deadline; successful authenticated reconciliation ends it. Local stop takes effect immediately. One scope's retirement cannot release another room's healthy source or transport lease. Within that window the retained room binding still owns existing captures; temporary unavailability rejects new room operations without retiring that binding.

App sharing uses a page-owned, non-cloneable capture lease from the initial request; dropping it stops the producer even while signaling reconnects. Native Driver owns worker completion. Room admission precedes capture, and the first AU completes startup; Native preview uses an ordinary subscription. Source audio shares that page lease with separate outputs. WASAPI timestamps and Rust Opus use the video's source-time mapping; silence does not block picture startup, and audio failure retires only audio outputs. Stereo receive negotiation stays with the transport, including retained connections that change SDP roles.

An unfinished SDP exchange belongs to its physical connection. On resume, retransmit its original offer or cached answer with the same exchange identity; an answer from an older exchange cannot complete a newer one. Keep that protocol exchange separate from current publication authority: retransmission may remove revoked track bindings, but never insert a new binding into an old description. Finish the pending exchange, then let normal WebRTC negotiation apply current senders. A unilateral rollback is not a synchronization protocol: the other endpoint may already have accepted the offer. The WebRTC negotiation model owns sender updates; RFC 3264 defines an answer's independent SDP origin/version.

Implementation Boundary

Browser/WASM and Native/SQLite adapters execute the shared room core. The domain projects their authorized summaries; a failed directory save cannot undo a room policy commit. The Server/App compositions and Native participant own runtime setup; an OS file lock excludes simultaneous writers of a saved room.

App control authenticates the Browser account against domain admission and opens rooms through the Native participant. Browser activities and existing hosted rooms keep their own endpoint and storage. Approval grants one exact Web origin its own data namespace; supplied domain/user IDs select data only after Native verifies admission. Revocation stops that site's hosting without deleting data or affecting other sites. For an approved external site, a replacement origin needs approval and does not inherit the previous origin's data. The App's own domain retains its saved identity and room-data namespace across port or invitation-address changes. URLs provide discovery, never App permission.

Keep platform FFI narrow: a Rust wrapper does not make foreign code memory-safe (safe abstractions). The engineering map owns module boundaries; versioning separates builds, wire, storage and live generations. Published cutover still requires a handshake/data-upgrade decision.

Transport And Encoded Supply

The Native pump drives str0m socket input and deadlines through public APIs. The SDK owns ICE, DTLS/SRTP, SCTP, congestion control, probing, pacing and retransmission; Driver/Core retain room/flow authority. STUN/TURN clients use that same socket owner. Exact pins and removal boundaries belong to the Native dependency owner. Piik owns encoder demand, complete-AU assembly/admission and source-time mapping; public depacketizers do not own those assembly semantics or require a feature fork.

One SDK GCC target budgets a physical connection, not each outbound track. Allocate before encoders, using the SDK's built-in BWE without a second congestion controller. Independent constraints require actual rate-controlled outputs, not copies of one encoding. Each connection aggregates known source configuration ceilings separately from usage/allocation; unknown received ceilings remain unbounded, with measured source cost informing allocation. Selected original supply sets minimum transmit demand within the SDK estimate; overuse suppresses padding. Desired capacity stays separate, idle/withdrawn supply contributes no minimum, and unknown cost never becomes a guessed rate.

Selected demand precedes optional flows after accounting for other RTP. A trial's picture and sound are admitted together; unknown cost waits on the existing Driver tick. Pending selected video reserves capacity before its sender is ready. An empty connection can start ordinary forwarding: the initial estimate is not measured capacity. A trial that no longer fits retires its outputs, preserving selected media and the connection. Before signaling, a stable local offer failure withdraws only unconfirmed additions. Normal sender retirement lets rejected companion audio retry once; rollback is not a new opportunity, unchanged projections do not retry, and retired failed flows do not revive.

A participant accounts only for its own work, not unrelated tabs/apps. One producer reconciles actual output demand, reusing a warm baseline at full demand and an independent encoding per constrained output. Zero allocation pauses that output; restoration adopts a newer baseline keyframe before retiring its encoder. An unused baseline rests on its bounded AU queue. Original/Limited describe feed reuse/independent encoding, not delivered quality; observations own delivered size, cadence and quality. A lower supplied encoding does not permanently cap an outgoing RID's geometry. Each publication carries accepted source size/FPS/bitrate ceilings to relays; local encoder policy and source audio keep their controls. Quality edits preserve publication/routes and are acknowledged after producer and room acceptance; rejected publication updates restore the still-live producer.

Control turns and real-time packet writers remain separate. Each output uses its negotiated codec mapping and complete-AU queue; overflow drops unsent AUs and resumes at a keyframe without blocking siblings. Completeness spans reception, expiry and delivery: expired fragments never enter a decoder. Metadata that produces no RTP keeps the sender and its last clock correlation alive. Retiring a flow ends its unsent payload/retransmission state independently of a later SDP exchange. Opaque RTP cost is measured once before fanout, even without outputs. Ingress deduplicates primary sequence numbers after RTX repair while retaining first late repairs/out-of-order packets; each downstream owns its retransmissions. Audio/video have separate source identities. Capture presentation time owns RTP and Sender Report correlation; encoding/delivery delay must not shift them independently. Replacing an incoming source creates a new sender/SSRC; changing a local encoding keeps capture identity, output sender/SSRC and packetizer, committing on a newer keyframe. Refresh demand remains until that keyframe, not merely an RTCP request.

Required lower-rate replacement releases the incumbent and queued frames immediately, retaining last emitted source time; its delayed IDR crosses a fixed boundary. Optional restoration keeps the incumbent until the new IDR. Small encoding skew uses source-switch RTP mapping without changing capture timestamps/NTP correlation. Each encoding has a feed identity: failure applies atomically to current/required pending feeds, while an optional-upgrade failure preserves the incumbent. Driver consumes latest targets without queuing intermediate values. The existing WebRTC FrameDropper admits raw frames from actual encoded bytes/input cadence; dropped raw frames retain time, and encoded reference frames remain intact. The encoder assessment owns measurements.

Default Server adaptation remains forwarding-only under ADR-0013. Simulcast encodings represent one source/flow, not extra publications or operations. Session receive capabilities go only to assigned peers. Producers order encodings low to high; measured bitrate decides fit, not quality order. Each RID maps RTP/SR to one source timeline. Forwarding preserves downstream supply and needs no Server codec runtime. Received tracks keep physical readers/clocks across codec changes; feed replacement changes encoded format without replacing their route or reader. H264 shares complete AUs between forwarding and one demand-driven decoder; platform adapters feed the shared derived producer. Windows VP8 uses stock libvpx/owned NV12 frames. Derived outputs keep source presentation/RTP/SR time, adopt a replacement keyframe before retiring old encoding, and release only their own derivation. Removing the last incoming demand releases its reader even while metadata remains.

Registered capabilities, SDP and actual SPS remain distinct. The SDK matches H264 profiles/packetization; the encoded-input boundary checks SPS. Chromium's fixed decoder advertisement is not a forwarding ceiling or decoding proof. Retain actual decoded-frame proof; metadata alone cannot retire a working connection or permanently reject its flow.

Capture And Platform Lifetimes

Local capture has no incoming route lease; publication authority supplies its outputs. Each encoding fits natural source pixels within the requested ceiling, without upscaling. Encoders own conversion, bitrate, keyframe requests and bounded AU queues; only unencoded work may be replaced. One blocked/failed encoding affects only its outputs; stopping capture ends all encodings and source sound.

Windows shares owned GPU textures and source time across its independent worker processes. The child copies to private resources before releasing the shared lock and encoding. Cancelling a read preserves its pending result. Size changes drain old AUs and reconfigure the same MFT, preserving bitrate/clock/output identity and resuming at a keyframe (MFT drain, Chromium reconfiguration). Display changes replace WGC resources without resetting encoders/routes/time. D3D11 device removal joins/replaces affected capture/child resources while retaining source clock, audio, bitrate and logical feed; replacement needs a newer independent AU. Failure before usable output preserves the original device error; unrelated errors stay terminal. The process boundary contains observed NVIDIA callbacks using a destroyed transform after ShutdownObject returned, without idle retention/shutdown delays. Auto selects hardware H264 then software VP8 after failed/timed-out first independent AU, stopping the failed encoder before replacement on the same capture/clock. The admitted codec stays fixed for source changes/derived outputs; manual selection rejects unsupported codecs before capture permission. Fidelity owns colour/tone mapping.

macOS dimensions follow backing pixels/frame metadata. The SCStream synchronization clock maps original sample time to host time. One completed image copy leaves the finite ScreenCaptureKit pool; encoders share only that immutable copy. Stop the stream, drain callbacks, then release conversion resources. Each VideoToolbox encoder owns its size/bitrate/AU queue and native input pool; output callbacks do not authorize overwriting retained input. Source-sound/video streams have independent stop lifetimes and use the same selected-window/application filter, without another display choice or video dimensions.

Linux's ScreenCast Portal owns selection, PipeWire authorization and revocation. Copy each image out of the pool once for independent GStreamer encodings. Pipeline segment running time removes codec offsets in the shared system/source clock. Portal closure stops the source/all encodings; system sound keeps its separate PulseAudio monitor pipeline. Server forwarding has no desktop capture dependency.

Android's MediaProjection owns one VirtualDisplay/image source; independent MediaCodec outputs consume owned immutable snapshots without retaining reusable projection images or blocking siblings. Optional playback sound uses that same capture authorization. Java owns consent/foreground service/platform callbacks; Rust owns capture/encoding. Pending permission/first-frame waits leave App commands available, and the same stop retires pending and active capture.

Input And Sound Boundaries

Linux input adds a RemoteDesktop Portal session beside the current capture. Commit only with selected monitor, EIS devices and first image ready; cancellation closes the candidate and preserves the share. Close a pending Portal Request before session cleanup, including superseded pre-commit consent. One local presentation requests a keyframe at handoff without replacing producer/encoders/time. EIS region mapping binds input to the selected monitor; paused/removed devices use neutral-state releases without blocking another source. Text follows actual device capability.

The optional GlobalShortcuts Portal uses an installed desktop identity via the host Registry. Desktop owns one process binding; source consent closes pending registration's Request/candidate session on cancellation. Actual system description/changes/closure, not the preferred Browser chord, report binding. Activation revokes input through the same executor without stopping capture. Linux prefers Super + Alt + Fn; GNOME uses Ctrl + Alt + Fn for virtual terminals.

GNOME Portal 50.0/control-center 50.3 leave cancelled shortcut consent visible after Piik releases its Request/session: the backend marks cancellation, but the provider has no external-dialog cancellation. Piik adds no provider workaround. This UX limitation is separate from Mutter's unstarted-session leak: its !started Stop branch returns without closing an object, even after system-UI cancellation. Piik releases its own Portal/PipeWire resources and must not start unapproved sessions. The same branch remained in 50.5 and upstream main on 2026-10-31. The isolated repair is local; TODO owns publication and verification status owns runtime acceptance.

Room voice plays in the Browser. Native system-output capture can recapture remote voices even with headphones; Browser restrictOwnAudio does not control Native capture. Windows process loopback excludes an entire Browser tree, including its other sound. App-sink playback would remove voice from ordinary Chromium's echo reference. Explicit all echo cancellation needs actual device support and can add mic latency. The owner retains Browser playback for first internal testing; automatic exclusion stays separate later work. Processing the whole Native mix would change unprocessed source sound.

The Native participant owns platform setup; verification status and the linked media assessments own measured results and remaining physical acceptance.

Design References

These references support individual boundaries. The accepted room-owner-operated base tree and selective screen plans are Piik's design choice, to be checked against its existing routing behavior and actual runtime costs.