app-anything GitHub

Runtime contract

Normative. The contract binds a backend and a host; both sides are tested by the executable cases in conformance/host/. The machine-readable constants are rendered as generated/contract.json.

Environment

The host MUST pass, the backend MUST read:

Variable Meaning
PORT The port to bind; the host chose it and owns it
HOST 127.0.0.1
APP_TOKEN The one-time session token for the handshake
APP_DATA_DIR The only directory the backend may write to
APP_PARENT_PID The supervisor's pid, for backends that want a parent watch

Behaviour

Stopping

The host stops the backend in order: close stdin; wait stop_timeout; SIGTERM the process group; wait; SIGKILL the group. A backend that exits on stdin EOF never sees a signal.

A backend reading the environment sees exactly this shape:

{
  "PORT": "54321",
  "HOST": "127.0.0.1",
  "APP_TOKEN": "6f1c9a4e7b2d",
  "APP_DATA_DIR": "/run/app-anything/acme.notes/data",
  "APP_PARENT_PID": "4102"
}

Two hosts

The Python reference host and the Rust runner implement this contract independently and MUST both pass the same conformance cases; a behaviour change in one without the other is a CI failure, not an option.

Rendered from spec/contract.md on main.