pub async fn run_http_on(state: AppState, listener: TcpListener) -> Result<()>Expand description
Run the optional HTTP/SSE + web admin server.
Why: A long-running daemon mode lets non-stdio clients (browsers, curl,
future remote agents) hit /health, the /api/v1/* REST surface, and the
embedded admin SPA.
What: axum router built from web::router() plus a /sse stub for the
existing MCP-over-SSE clients. Caller provides a pre-bound listener so
port auto-detection lives at the call site. Before accepting connections
the daemon stamps the bound host:port onto AppState.bound_addr and
writes ~/.trusty-memory/http_addr so clients can discover the live port.
On shutdown the file is removed best-effort (a stale file with the wrong
port is worse than a missing one).
Test: cargo test -p trusty-memory web::tests exercises the router shape;
manual: curl http://127.0.0.1:<port>/health returns ok with addr.