Architecture
The simulation is a pure function of its inputs
Same level, same inputs, same world, on every browser engine. Almost everything else in the design is bought with that one property.
The system
Five things run; two are always on
- The browser holds the simulation: the ported engine, the renderer, and an outbox for progress that survives a closed tab.
- The pair's own connection carries the game itself, and touches none of the servers below.
- Supabase holds identity, friendships and progress, behind row level security, with Realtime for presence and invitations.
- A CDN holds the static bytes: the bundle and the extracted art.
- A replay verifier can re-execute a submitted run in isolated worker threads, so a ranked time means something. It is built and tested, and switched off until an operator enables a build.
Determinism
What it buys
| Same inputs, same world | 3 bits | The netcode exchanges inputs, never state. |
|---|---|---|
| Replaying is cheap and exact | Rollback | Rewind, re-simulate, correct before anyone sees it. |
| A third party can re-derive a result | Verifier | And therefore a leaderboard that cannot be typed into. |
| A watcher fed the inputs sees the same world | Spectating | Watching costs the two players nothing to compute. |
| A digest pins a level | 32 digests | CI catches a physics change nobody intended. |
Four silent hazards, each with its own machinery
Each one diverges without an error, which is what makes it dangerous.
- Trigonometry.
Math.sin,cosandatan2may differ in the last bits between engines, so the physics uses its own deterministic versions. - Scenery randomness. The level calls
Math.random()for fireflies and tile variants. It never touched physics, but two peers saw different levels; it is now seeded from the level. - Float comparison. The state hash covers the exact IEEE-754 bits of every value, because rounding first would hide the one-ulp drift being hunted.
- Effects outside the simulation. Sound and save writes happen on a frame's first run only; a replayed frame must be silent.
Security
The gate is on the data, not the download
The bundle and the art are public static files. What is protected is every row of anybody's data.
- Row level security everywhere. Data policies require a profile and a satisfied assurance level, so an account that has not finished signing up, or answered its second factor, reaches no one's rows.
- Two-factor, enforced in the database. Ten single-use recovery codes, hashed and shown once.
- Per-attempt scoping. Every message is tagged with its connection attempt, so delayed input from a superseded attempt is dropped before it is decoded.
- Untrusted replays run in a sandbox. A fresh worker thread, an empty environment, a memory cap, a deadline and no database handle.
Testing
What is actually proved
| Simulation | 32 digests | Every level pinned; snapshot round-trips on each; a 640,000-frame soak run twice and compared. |
|---|---|---|
| Cross-engine | 3 engines | V8, SpiderMonkey and JavaScriptCore agree after 600 frames. |
| Netcode | 192 cases | Latency, jitter, loss, mode and input pattern; damaged, duplicated and stale packets; a hostile peer. |
| Rendering | Per level | A perceptual signature, so a mask that stops clipping is caught. |
| Database | RLS | Policies from a third account, races run in parallel, ordering fuzz. |
| The app | Browsers | Emailed links, username rules, two-factor, Google, and two people playing. |