# Codemode execution model Status: accepted ## Context The model writes JS run in QuickJS; only script output reaches the model. QuickJS values are not Send. The interrupt handler only fires while JS runs, not while awaiting tools. ## Decision Inner calls go through `Registry::call` so the permission gate and shared State (read-before-edit, edit log) apply. Each script runs on its own thread with a local runtime. Waiting for a free worker counts toward the timeout; time spent awaiting tools is bounded separately. The run stops when the script settles and unawaited calls are cancelled. Store writes apply only to successful scripts. MCP tools are listed first so builtins cannot push them out of the listing budget. ## Consequences Scripts cannot bypass permissions; failed scripts leave no partial store state. Code: crates/hx-tools/src/codemode.rs (module, run, tool listing, store handling)