# Operating APEX TWIN This is the run book: how to install it, what it writes, how the scope behaves, how to run the proxy and the webhook, how to back up and upgrade, and what to check when something refuses. ## What runs | Mode | Command | Listener | |---|---|---| | MCP over stdio | `apex-twin` | none | | MCP over HTTP | `apex-twin --http 8797` | 127.0.0.1:8797, `POST /mcp` | | Forward proxy | `apex-twin --proxy 8798` | 127.0.0.1:8798 | | Diagnostics | `apex-twin --check` | none, prints JSON and exits | Both listeners bind loopback only on purpose. Reach them through an SSH tunnel or a VPN; never put them on a LAN interface. The HTTP face serves at most `APEX_HTTP_MAX_CHILDREN` connections at once (503 beyond) and closes a request whose head or body does not arrive within `APEX_HTTP_HEAD_TIMEOUT_MS`. ## Install ```sh make # build, zero warnings under -Werror make test # 298 end-to-end checks make install # binary, README and both systemd units make install DESTDIR=/tmp/pkg PREFIX=/usr ``` `make install` writes: ``` $PREFIX/bin/apex-twin $PREFIX/share/doc/apex-twin/{README,CHANGELOG,SECURITY,LICENSE,operations,artex-port}.md $PREFIX/share/man/man1/apex-twin.1 $PREFIX/lib/systemd/system/apex-twin.service $PREFIX/lib/systemd/system/apex-twin-proxy.service ``` The units hardcode `User=lotherk` and `APEX_HOME=/home/lotherk/stack/data/apex-twin`; edit them before installing for another account. `EnvironmentFile=-/home/lotherk/.config/apex-twin/env` is optional and is the right place for `APEX_WEBHOOK`, `APEX_REWRITE` and the time outs — keep secrets out of the unit file. The radio unit adds `SupplementaryGroups=dialout`; the proxy unit does not, and neither unit gets `CAP_NET_RAW` (connect scans need no privilege). ```sh systemctl daemon-reload systemctl enable --now apex-twin.service apex-twin-proxy.service journalctl -u apex-twin -f ``` ## State Everything lives under `$APEX_HOME` (default `~/.local/state/apex-twin`), created 0700: ``` scope.json the rules of engagement audit.log one JSON line per decision, append-only findings/f0001.json one finding per file, rewritten atomically on update evidence/-