summaryrefslogtreecommitdiffhomepage
path: root/.agents/rules/main-thread-eval.md
blob: e8aaf9a12b717ccdb630c08f62d15930d71b7695 (plain)
1
2
3
4
5
6
7
8
9
10
11
# Rule: eval/console/bridge commands run on the main thread

All Ruby `eval` — whether from the agent bridge (TCP/WS), the in-game console,
or hot-reload — runs on the **main thread** via the frame-polled command queue
(`Jamstack::Bridge.drain`, called inside `while_window_open` before the game
block). Never call `mrb_funcall` or `eval` from a socket callback, JS callback,
or any thread other than the main loop. The mruby VM is not thread-safe.

The in-game console (`Jamstack::Console`) calls `eval` directly (not through the
queue), but it's safe because `console.update` runs on the main thread, before
`ctx.process_input`. The console and the bridge can coexist.