Two hosts, one contract
The Python reference host and the Rust runner inside the desktop creator both supervise backends. They are written in different languages, run in different processes, and must behave identically where it matters — this page explains the contract both implement and how the project keeps them from drifting.
The contract, in one table
| Clause | Host side | Backend side |
|---|---|---|
| Port | chooses a free port, passes it as PORT |
reads PORT, binds 127.0.0.1 |
| Health | polls the declared path until 2xx | answers 2xx when ready |
| Token | passes a one-time token as APP_TOKEN, then fetches /?app_token=… |
redirects and sets the app_token cookie; may enforce it |
| Stop | closes stdin | exits on stdin EOF, taking its children |
| Sandbox | provides APP_DATA_DIR, isolates HOME |
writes only inside the sandbox |
| Output | drains stdout/stderr for logs | writes logs to stderr, never chatter to stdout |
| Browser | serves the frontend itself | never opens a browser |
| Survival | kills the process tree on stop | leaves no orphans behind |
Every clause maps to a rule (AA201–AA207, AA301–AA302,
AA401–AA402) and to executable cases in
conformance/host/.
Why executable cases, not prose
Prose drifts; worse, prose is read by whoever already agrees with it. A case file names a misbehaving backend and pins the observable report — ports, HTTP, exit kinds — in JSON that both hosts can be measured against. When one host changes behavior, CI fails that host's suite, and the divergence surfaces before users see it.
Why the host does the choosing
Everything host-chosen — port, token, data directory, even the frontend URL — removes a decision from the backend, which removes a bug class from every ported app: port collisions, path assumptions, cookie domains. The conformance backends demonstrate the entire backend-side duty in a few dozen lines each, which is the point: the contract is small enough to implement on a framework you already use.
Why the desktop does not reuse the Python host
The desktop creator ships to machines with no Python guarantee; its runner is Rust inside the Tauri shell. The contract — not shared code — is the compatibility guarantee. Shared code would couple every desktop release to the Python release train, and a language-neutral contract lets third hosts claim conformance the same way.
Rendered from docs/explanation/two-hosts-one-contract.md on main.