Turn engine

The engine is server/src/engine.rs. It runs turns in three modes: normal, build (see Plugin maker) and dreaming (see Dreaming). The step by step loop is in Turn loop.

Turns and threads

Safety Gate

Every tool call passes the Safety Gate before it runs. The gate:

  1. Finds the effective autonomy level for the tool (see API, Autonomy).
  2. Checks the call against the plugin's needs (hosts, secrets).
  3. Checks budgets (tokens, tool runs, money).
  4. For ask, builds the approval card from the real tool arguments, not from model text.
  5. Writes the decision to the action log.

The full threat list is in Threat model.

Cost limits

Set in config, enforced by the core:

When a limit is hit the turn stops with turn.error code budget_exceeded.

How turns end

Power switch

server/src/power.rs. One switch turns the whole assistant on or off (Settings, General).

Off means no jobs fire, nothing thinks, nothing is dreamed, phone uploads are refused (the phone keeps them and sends them later), and work is refused with 503 power_off. Reading still works, so the app can show settings and turn it back on.

It survives a restart. Jobs that came due while off do not all fire at once: repeating ones move to their next time. Route: GET,PUT /v1/power.