The mesh layer is officially active! With the VFS syncing files and the
Proxies intercepting object mutations across the network, the foundational
infrastructure for handling distributed cellular automata grids and
thermodynamic signaling is completely online.
To answer the Arena D chat's question regarding Lamport timestamps or vector
clocks: **Keep it simple for now.** A basic "last-writer-wins" approach (using
the payload's `timestamp`) is more than sufficient for early prototyping. We
can introduce vector clocks later if state tearing becomes a measurable issue
during high-frequency grid updates.
Before we start dropping complex physics specifications or esoteric mechanics
into the environment, we should run a live "smoke test" to see your
distributed objects mutate across multiple browser tabs in real-time.
### The CRDT Smoke Test
Let's create a very simple LPC object that tracks a shared state.
**1. Create `tests/mesh_test.c**`
Save this file into your `tests/` directory. It registers itself with the mesh
using your `10_mesh.js` hooks to track two properties: `counter` and
`last_user`.
```c
/ tests/mesh_test.c
int counter;
string last_user;
void create() {
counter = 0;
last_user = "nobody";
// Intercept and sync any property matching "counter" or "last_user"
mesh_sync_object(this_object(), "sync_test_topic", "^(counter|last_user)$")
;
}
void increment(string user) {
counter = counter + 1;
last_user = user;
printf("State bumped! Counter: %d, User: %s
", counter, last_user);
}
void display() {
printf("Current Network State -> Counter: %d, Last User: %s
", counter, last_user);
}
```
**2. Update `build_web.ini**`
Add the new test file to your inclusion list:
```ini
; Engine core dependencies
core
efuns.d
; include all files from main project folder
*.*
; include selected tests
tests/string.c
tests/math.c
tests/file.c
tests/clone_object.c
tests/catch.c
tests/define.c
tests/rambuffer.c
tests/repl.c
tests/mesh_test.c
```
**3. Run the Distributed Test**
Run `node build_web.js` to compile the new AST. Then, to truly see the magic
of what you've built, open **two separate browser windows** side-by-side
pointing to `http://localhost:7070`.
In **Browser A**, load the master object and increment the state:
> `eval load_object("tests/mesh_test")->increment("Browser_A")`
In **Browser B**, check the state. Because the DMZ Relay intercepted the
`CRDT_MUTATION` payload and pushed it to Browser B's proxy, the state will
already be updated without you doing anything:
> `eval load_object("tests/mesh_test")->display()`
If the counter and user state successfully bridge the gap between those two
isolated browser tabs, your distributed network is fully operational.
When you verify the sync is working, what component of the simulation logic do
you want to tackle next?