What you're looking at
Each browser tab runs 64 fully simulated drones under the control of a live RuvonEdgeAgent — the same Python runtime that powers payment terminals and industrial IoT gateways — compiled to WebAssembly via Pyodide.
Open multiple tabs from the same sovereign link and the tabs form a private fog network: they elect a leader, divide the formation space, and render a unified swarm with each browser contributing its own slice. Close any tab and the remaining nodes re-elect a new sovereign and recompute the fleet in under a second.
Architecture at a glance
How to use the demo
- Open the demo in any Chrome or Edge browser (WebGPU required). Firefox support coming when WebGPU ships in stable.
- Click Launch Drones. 64 drones spool up and fly to the default Ruvon-R formation. This tab is the sovereign — it controls the swarm.
- Copy the Sovereign Link shown in the top-left panel and paste it into a second tab or window. The second tab joins the mesh as a follower.
- On the follower tab, click Join Formation. The sovereign expands the fleet to 128 drones and each tab renders its own 64-drone slice of the formation.
- Add more tabs from the same link. Each adds another 64-drone squad. The formation math scales deterministically — no extra network traffic per drone.
- Try the 3D Formations panel: Sphere, Helix, DNA, Torus, Vortex, Wave, Cube.
- Type a command in the Command box (e.g. "form a sphere", "scatter", "land all"). MiniLM matches it to the nearest preset; complex prompts escalate to wllama/Ollama.
- Close the sovereign tab. The remaining tab detects the departure via GOODBYE broadcast, re-elects itself sovereign, and recomputes the fleet — all in under one second.
Key technology
ruvon-edge in the browser
RuvonEdgeAgent runs via Pyodide (CPython → WASM). The full DroneCommand and SwarmFormation workflows execute as real Python — same code that runs on hardware edge devices.
BroadcastChannel + PeerJS mesh
Tabs on the same device gossip via BroadcastChannel. Tabs on different devices connect via PeerJS/WebRTC — no signaling server needed beyond the free PeerJS cloud. A scored capability-vector election picks the sovereign; FOUNDING_BIAS + stable pod_id prevent split-brain.
SharedArrayBuffer physics
Four Web Workers share a SAB (64 drones × 16 f32 = 4 KB). Reynolds flocking + PID altitude run in parallel threads with zero serialization overhead. When SAB is unavailable (non-isolated context), physics falls back to an inline requestAnimationFrame loop on the main thread.
WebGPU renderer
Instanced drone meshes with LED glow, motion trails, and rotor animation. Ghost dots show remote squads. The camera is fully independent per tab — orbit, zoom, pan freely.
Deterministic sync
Formation changes broadcast a seed + preset name (not coordinates). Each tab independently computes its own index slice using mulberry32 PRNG — bitwise-identical in JS and Python.
Instant Pyodide warm-up
The full Pyodide runtime (~35 MB) is bundled as same-origin static assets in pyodide-cache/. A cache-first service worker stores everything on first load — subsequent page refreshes skip the network entirely and boot in under 2 s.
92% less CO₂
Computation stays on the device. No round-trips to a cloud inference server. The green energy estimate in the HUD is calculated from active drone count and idle power displacement.
Sovereignty election
Every tab runs a gossip heartbeat every ~2 s, broadcasting a capability vector (battery, CPU load, RAM, task queue). The mesh scores all pods and elects the highest-scoring one as sovereign.
How split-brain is prevented
- Stable tiebreaker: scores are sorted by
(score DESC, pod_id ASC)— all pods converge to the same winner even at identical scores. - FOUNDING_BIAS (+0.40): the first tab opened gets a score bonus so it naturally stays sovereign while it's alive.
- Fresh election on conflict: if two pods simultaneously claim sovereignty (race after founder closes), both run a hysteresis-free election and the lower-ranking one yields immediately.
- Instant GOODBYE: closing a tab sends a GOODBYE directly on the BroadcastChannel (synchronous, main-thread), so peers re-elect in <1 s instead of waiting for a 15 s stale timeout.
Sovereignty transfer
When a follower is elected sovereign it:
- Resets its slot to 0 (sovereign is always slot 0).
- Adopts all currently flying pods as active fleet members.
- Rebroadcasts the current formation with the corrected slot map.
ruvon-swarm package
The Python workflow logic is packaged as ruvon-swarm — a local wheel bundled with the demo and installed inside Pyodide at startup via micropip. It provides:
- SwarmFormationState — Pydantic state model for formation commands
- DroneCommand workflow — 5-step YAML: ParseCommand → ValidateFormation → BuildIntent → LogFormation → ExecuteFormation
- build_intent step — returns a deterministic seed derived from the workflow ULID, which JS uses to compute formation slices without broadcasting coordinates
- mulberry32 PRNG — bitwise-identical implementation in both JS and Python so formation math can be validated server-side
# The wheel is served alongside the demo — no PyPI installation needed
# pyodide_worker.js installs it automatically at startup:
await micropip.install("./ruvon_swarm-0.1.0-py3-none-any.whl")
Run locally
git clone https://github.com/KamikaziD/ruvon-swarm cd ruvon-swarm/examples/swarm_studio python serve.py # serves on http://localhost:8080
The local server adds the COOP/COEP/CORP headers required for SharedArrayBuffer. The full Pyodide runtime is bundled in pyodide-cache/ and served locally — no CDN download needed. No installation beyond Python 3.9+.
For cross-device testing: open http://<your-lan-ip>:8080 on two devices. PeerJS will connect them directly via WebRTC.