Architecture
Overview
Section titled “Overview”Cluewren coordinates five components during a playtest run:
- Coding Agent: Claude Code or OpenAI Codex. Drives the session, reads project source code, and writes C# harness code.
- The Brain (
cluewren mcp): The MCP server started by your agent. Coordinates the run, serves MCP tools, hosts the local bridge, compilesharness.csusing Roslyn (HarnessCompiler), and handles outbound calls to Jev. - Engine Plugin: The package or addon installed in Unity, Godot, or Unreal Engine. Connects to the brain over loopback WebSocket to execute commands, inject inputs, and capture frame buffers.
- Harness Child Process: An isolated .NET 10 process spawned by the brain. The brain compiles
harness.cs, and the child process loads and executes the compiled assembly against the live game. - Decision Model (Jev): TypeSafe’s fast decision model (
jev-1.13.0) hosted atapi.typesafe.ai.
Communication diagram
Section titled “Communication diagram”+-------------------+| Coding Agent || (Claude / Codex) |+---------+---------+ | stdio (MCP)+---------v---------+ HTTPS +-----------------------+| The Brain | ----------------------> | TypeSafe Jev API || (cluewren mcp) | <---------------------- | (POST /v1/systemone) |+----+---------+----+ +-----------------------+ | | | pipes | WebSocket (127.0.0.1) | |+----v----+ +-v-------------------+| Harness | | Engine Plugin || Child | | (Unity/Godot/Unreal)|+---------+ +---------------------+Discovery and bridge security
Section titled “Discovery and bridge security”Communication between the engine plugin and the brain occurs over a local loopback WebSocket:
- Ephemeral port: The brain starts a WebSocket server listening on
127.0.0.1on a random port. - Discovery file: The brain writes
%LOCALAPPDATA%\Cluewren\brain.jsonwith owner-only access control permissions. The file containsurl,secret,pid, andstarted. - Loopback binding: Plugins only connect to
ws://endpoints on127.0.0.1or[::1]. - HMAC handshake: Both the brain and the plugin authenticate each other using HMAC-SHA256 nonces (
brain-proofandplugin-proof). The shared secret never travels across the socket. - Origin header check: The bridge server rejects any incoming connection containing an
Originheader to prevent browser cross-origin requests.
Child process isolation
Section titled “Child process isolation”The harness child process runs in an isolated environment:
- The brain compiles
harness.csusing Roslyn (HarnessCompiler) and starts the child process. The child loads and runs the compiled harness. - The child process communicates with the brain exclusively through standard input and output pipes.
- The child holds no network privileges and no API keys. When the harness queries Jev, it sends a JSON request over its pipe to the brain, which verifies decision limits and forwards the request to TypeSafe.