Skip to main content

Module server

Module server 

Source
Expand description

Axum HTTP server for the trusty-console.

Why: The console needs a lightweight HTTP server that serves the embedded SPA, a JSON API route for service status, and a reverse-proxy layer for all daemon sub-paths. What: Builds an axum Router with:

  • GET /health — liveness probe.
  • GET /api/console/services — return cached snapshot (background poll).
  • GET /api/console/metrics/{analyze,memory,search,review,mpm} — MCP-polled metrics.
  • GET /api/console/metrics/analyze/indexes — analyze index list via stdio MCP.
  • GET /api/console/metrics/analyze/visualize?index=<id> — graph+entities+clusters.
  • …/api/console/sessions/* — the single HTTP front door for the trusty-mpm session manager (#1222); handlers live in crate::routes::sessions.
  • ANY /proxy/{daemon}/{*path} — reverse-proxy to live daemon (mpm is NOT in the proxy allowlist — operators use /api/console/sessions/* instead).
  • GET / and GET /ui/*path — serve the embedded Svelte SPA.

All logs go to stderr; stdout is clean.

Test: The tests module starts the router in a real axum test client.

Structs§

AppState
Shared application state injected into every route handler.

Functions§

build_router
Build the axum Router with all routes wired.