Skip to content

ADR-0003: Process Model

Note

One process owns every surface on every monitor and runs one tre event loop. Background work runs on other threads and hands results to the loop with LoopHandle.call_soon.

Context

tre runs on one thread, the one that created the App; every window, event handler and Python callback runs there once App.run() starts. Any thread may use App.thread_handle() and call_soon(fn) to queue work on the loop (tre threading guide). One App can hold many windows, including layer windows on several outputs (Outputs). Vault Reference > Layering principle already fixes that Python never runs in layout or paint.

Options

Option A — One Process, One Event Loop (Chosen)

  • For: one configuration, one theme, one set of services shared by all surfaces; hot reload and monitor hot-plug act in one place; the cost of tre's GPU device per window is the only duplication.
  • Against: a hang or crash in one module stops every surface. Python modules share one GIL, so a slow module delays frames for all monitors.

Option B — One Process per Surface or per Monitor

  • For: a failure stays inside one surface.
  • Against: shared state (theme, services, config) needs inter-process messaging; every process pays its own runtime and GPU memory; a bar and its popups must cooperate across processes.

Decision

Accepted 2026-10-25 by the maintainer in chat: Option A, one process owning all surfaces and one event loop.

Consequences

  • Every service spec states its thread and how it crosses into the loop (Vault Reference > Layering principle). Blocking work (D-Bus, sockets, polling, disk) never runs on the loop thread.
  • A module that blocks the loop freezes all surfaces. 60 Quality must define a watchdog and crash recovery (restart the process, restore surfaces from configuration). #tech-debt until written.
  • The shell may run under a small supervisor that restarts it. Whether it is part of v1 is open.
  • No isolation between user modules (Goals and Non-Goals N7).

Caution

Single point of failure One hung Python callback blocks every bar, OSD and widget. Add to Risk Register when it exists.