webrtc p2p agent swarm
Coordinating state across two open tabs or two collaborators usually means routing every update and note through a central backend database even when both browsers are online simultaneously. Using a server strictly for the brief WebRTC SDP handshake and pushing task state directly peer-to-peer over RTCDataChannel keeps application data off the signaling server and resilient offline in IndexedDB.
Hypothesis
Using Cloudflare Durable Objects solely for ephemeral SDP/ICE handshakes while pushing CRDT task logs directly peer-to-peer over
RTCDataChannel+ IndexedDB keeps multi-tab and collaborator state private and functional off-server.
What confirms it: Two peers exchange CRDT deltas end-to-end with zero task bytes sent to the signaling server (422 rejects payload writes on SwarmSignaling), maintaining consistent order across reconnects via navigator.locks.
What falsifies or bounds it: Restrictive NATs/firewalls block direct UDP peer connections frequently enough to require TURN relay fallback for consumer networks.
What this lab tests
WebRTC Agent Swarm (GitHub) connects two browser peers over RTCDataChannel using a Durable Object (SwarmSignaling) solely for ephemeral SDP/ICE handshakes while persisting CRDT logs locally in IndexedDB with navigator.locks leader coordination.
Open questions
- How well does
BroadcastChannel+navigator.lockshandle same-origin multi-tab election without dropping WebRTC data channels on tab close? - What compact CRDT tombstoning keeps IndexedDB storage bounded across long agent swarms?
Iteration log
- — Built Peer A/B WebRTC
RTCDataChannelCRDT workbench with SQLite Durable Object signaling (422data guard) and IndexedDB persistence. - — Reordered workbench above setup docs, added live HTTP 422 signaling-guard probe and CSP-safe DOM syntax highlighting, hardened 700px embed responsiveness, and added no-cache static headers.
Primitives tested: RTCDataChannel, IndexedDB, Web Locks API, Durable Object SDP Signaling.
This is an active lab under /labs/ and stays off the main RSS feed until graduated into a full essay.