The four-layer rule, and the seam that enforces it

The four-layer rule, and the seam that enforces it An architecture diagram generated by Archify. @farm/client · WebGL2 renderer, DOM panels · Architecture component · layer 1 @farm/client WebGL2 renderer, DOM panels layer 1 @engine/ui · in-canvas UI toolkit · reusable — no game may be imported from here · Hollow opts out @engine/ui in-canvas UI toolkit Hollow opts out @farm/sim-core · deterministic sim, Node + browser safe · Architecture component · layer 2 @farm/sim-core deterministic sim, Node + browser safe layer 2 @farm/server · Node ws host, one sim per connection · Architecture component @farm/server Node ws host, one sim per connection @engine/core · ecs · sim · render · input · assets · reusable — no game may be imported from here · layer 3 @engine/core ecs · sim · render · input · assets layer 3 @engine/wasm-modules · pathfinding.wasm (AssemblyScript) · reusable — no game may be imported from here · layer 4 @engine/wasm-modules pathfinding.wasm (AssemblyScript) layer 4 Citadel · Hollow · MateQuest · same shape, own sim-core + client · Architecture component Citadel · Hollow · MateQuest same shape, own sim-core + client snapshot + message types ecs, sim loop native-speed kernels text, icons, widgets WebSocket frames hosts the sim same four layers reusable — no game may be imported from here

The rule, and the test that enforces it

  • • Engine never imports game. sim-core never imports the renderer.
  • • The renderer depends on sim-core for logic and the message contract
  • • This is checked by a test, not by convention — which is why it has held

Sim and render are separated by a transport

  • • Farm hosts its sim in a Node process and speaks WebSocket frames
  • • The in-browser Worker is gone; SimClient's public API was preserved
  • • The other three games still run their sim in a Web Worker

Determinism is the point

  • • sim-core is Node-safe and browser-safe, so the same tick runs in a test
  • • WASM artifacts are committed, so a fresh clone runs without build-wasm
  • • One sim per connection, with drop-stale snapshot backpressure