Skip to main content

Module gateway_server

Module gateway_server 

Source
Expand description

Self-hosted org gateway run-mode (gateway-server feature).

Bundles the proxy (remote bind, enterprise#8), the per-request usage store (Postgres usage_events, enterprise#17/#18) and — in later waves — the admin usage API (enterprise#20) into one deployable server.

LOCAL_OPTIONAL by classification (server_capabilities.rs): compiled in or out, never gated by account/license/plan — an org can self-host its gateway with cargo build --features gateway-server and full functionality (Local-Free Invariant; commercial enforcement lives in lean-ctx-enterprise).

Fail-open is the design rule (enterprise#12): the store subscribes to the usage stream through proxy::usage_sink and persists asynchronously; a slow or down Postgres degrades metering, never live LLM traffic.

Modules§

admin_api
Admin usage API (enterprise#20) — the self-hosted gateway’s spend/savings breakdown, straight from usage_events (Doc 08 §3.3).
admin_status
GET /api/admin/status (enterprise#46) — the gateway’s live health/config card for the admin dashboard.
admin_timeseries
GET /api/admin/timeseries (enterprise#46) — per-day usage/savings series for the admin dashboard’s trend charts.
admin_ui
Embedded admin dashboard (enterprise#45) — the org monitoring console served from the gateway’s admin port.
doctor
lean-ctx gateway doctor (enterprise#49) — go-live preflight.
evidence
Signed usage-evidence export (enterprise#36, EU-AI-Act evidence trail).
init
lean-ctx gateway init (enterprise#47) — plug-and-play gateway setup.
keys_cli
lean-ctx gateway keys (enterprise#48) — per-person key management for gateway-keys.toml, replacing the manual openssl rand | shasum dance.
report
lean-ctx gateway report (enterprise#50) — the printable CTO/value report.
security
Admin-port security hardening (#54): response headers + auth throttling.
serve
lean-ctx gateway serve (enterprise#10) — the self-hosted org gateway.
store
usage_events Postgres store (enterprise#17, baseline fields enterprise#18).
user_api
Personal usage view (/me, enterprise#64) — served on the proxy port, authenticated by the caller’s own gateway key.