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.POST /api/webhooks/{source}— GitHub webhook ingress: verify once, spool durably, relay over UDS (#5089 step 3, ADR-0034). Mounted only bybuild_router_with_webhooks.GET /api/console/metrics/webhooks— oldest-pending spool age as a red health state.DELETE /api/console/memory/palaces/{id}— delete one palace via trusty-memory’spalace_deleteon its socket (#6360).DELETE /api/console/search/indexes/{id}— delete one index via trusty-search’s ownsearch.index.deleteon its socket (#6360, #6285).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 incrate::routes::sessions.ANY /api/search/{*path}— translate the request into a trusty-search RPC call on its socket (#6285); seecrate::search_uds.ANY /api/{service}/{*path}— reverse-proxy to live daemon via clean path (#1849 Phase 2);{service}∈ {review, mpm, agents}.ANY /proxy/{daemon}/{*path}— DEPRECATED alias; routes to the same handler with a trace-level deprecation note.GET /andGET /ui/*path— serve the embedded Svelte SPA; the handlers live incrate::console_ui(#6285, 500-SLOC split).GET /tools/search/*path— serve the embedded trusty-search SPA (#6155); seecrate::tools_ui.
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
Routerwith all routes wired, trusting only loopback as the write-origin self-origin. - build_
router_ with_ self_ origins - Build the axum
Routerwith all routes wired, additionally trusting the given bind-derived, non-loopback self-origins for the write-origin guard. - build_
router_ with_ webhooks - Build the router with the webhook ingress mounted (#5089 step 3).