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

What determinism enables
Same inputs, same world3 bitsThe netcode exchanges inputs, never state.
Replaying is cheap and exactRollbackRewind, re-simulate, correct before anyone sees it.
A third party can re-derive a resultVerifierAnd therefore a leaderboard that cannot be typed into.
A watcher fed the inputs sees the same worldSpectatingWatching costs the two players nothing to compute.
A digest pins a level32 digestsCI 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, cos and atan2 may 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

Test coverage
Simulation32 digestsEvery level pinned; snapshot round-trips on each; a 640,000-frame soak run twice and compared.
Cross-engine3 enginesV8, SpiderMonkey and JavaScriptCore agree after 600 frames.
Netcode192 casesLatency, jitter, loss, mode and input pattern; damaged, duplicated and stale packets; a hostile peer.
RenderingPer levelA perceptual signature, so a mask that stops clipping is caught.
DatabaseRLSPolicies from a third account, races run in parallel, ordering fuzz.
The appBrowsersEmailed links, username rules, two-factor, Google, and two people playing.
← RecoveryBack to the game →