Skip to main content

lean_ctx/proxy/
mod.rs

1//! LLM reverse proxy — the core of the **Gateway pillar**.
2//!
3//! Intercepts Anthropic, OpenAI, Gemini and ChatGPT traffic, compresses
4//! prompts, meters usage, and optionally translates request shapes.
5//!
6//! # TLS Requirements
7//!
8//! The proxy does NOT terminate TLS. For production/multi-tenant deployments,
9//! place behind a TLS-terminating reverse proxy (nginx, caddy, traefik).
10//! For mTLS, configure the reverse proxy with client certificates.
11//! See: <https://github.com/yvgude/lean-ctx/issues/1371>
12//!
13//! # Org gateway coupling (ADR-023)
14//!
15//! The self-hosted org gateway (lean-ctx-enterprise) extends this proxy with
16//! admin/usage-store routes. In the OSS build the proxy runs standalone.
17
18pub mod adaptive_policy;
19#[cfg(feature = "http-server")]
20pub(crate) mod admitted;
21#[cfg(feature = "http-server")]
22pub(crate) mod agent_compact;
23#[cfg(feature = "http-server")]
24pub mod anthropic;
25#[cfg(all(test, feature = "http-server"))]
26mod auth_tests;
27pub mod auto_routing;
28#[cfg(feature = "http-server")]
29pub mod bedrock;
30pub mod break_even;
31pub mod cache_aligner;
32pub mod cache_attribution;
33#[cfg(feature = "http-server")]
34pub mod cache_breakpoint;
35pub mod cache_policy;
36pub mod cache_safety;
37pub mod ccr;
38#[cfg(all(test, feature = "http-server"))]
39mod ccr_robustness_tests;
40#[cfg(feature = "http-server")]
41pub mod chatgpt;
42#[cfg(feature = "http-server")]
43pub mod chatgpt_cookies;
44#[cfg(feature = "http-server")]
45pub mod chatgpt_ws;
46pub mod circuit_breaker;
47#[cfg(feature = "http-server")]
48mod codec;
49pub mod cold_prefix;
50pub mod compress;
51pub mod compress_api;
52pub mod compress_shared;
53pub mod compression_savings;
54#[cfg(feature = "http-server")]
55mod connector;
56#[cfg(feature = "http-server")]
57pub(crate) mod conversation;
58pub mod cost;
59pub mod counterfactual;
60pub mod dedup;
61#[allow(warnings)]
62pub mod determinism_guard;
63pub mod effort;
64#[cfg(feature = "http-server")]
65mod egress_observation;
66#[cfg(feature = "http-server")]
67mod egress_target;
68pub mod eligibility;
69#[cfg(feature = "http-server")]
70pub mod forward;
71#[cfg(feature = "enterprise")]
72pub mod gateway_identity;
73#[cfg(feature = "http-server")]
74pub mod google;
75pub mod history_prune;
76pub mod holdout;
77#[cfg(all(test, feature = "http-server"))]
78mod host_journey_tests;
79#[cfg(all(test, feature = "http-server"))]
80mod integration_tests;
81#[cfg(feature = "http-server")]
82mod intent;
83pub mod introspect;
84#[cfg(feature = "http-server")]
85mod lineage;
86pub mod metrics;
87#[cfg(feature = "http-server")]
88pub mod models_api;
89#[cfg(feature = "http-server")]
90pub mod ocla_cache_bridge;
91#[cfg(feature = "http-server")]
92pub mod openai;
93#[cfg(feature = "http-server")]
94pub mod openai_responses;
95#[cfg(feature = "http-server")]
96pub mod openai_responses_ws;
97#[cfg(feature = "http-server")]
98pub mod outbound_model_policy;
99pub mod output_savings;
100pub mod pii;
101pub mod pipeline_bench;
102#[cfg(feature = "enterprise")]
103pub mod policy_gate;
104pub mod pre_optimize;
105pub mod prefix_cache_stats;
106pub mod prefix_replay;
107#[cfg(feature = "http-server")]
108pub(crate) mod project_attribution;
109pub mod prose;
110#[allow(warnings)]
111pub mod prose_compress;
112pub mod prose_patterns;
113pub mod prose_ranker;
114#[cfg(feature = "http-server")]
115pub mod providers;
116#[cfg(feature = "http-server")]
117pub mod quality_lab_api;
118#[cfg(all(test, feature = "http-server"))]
119mod reference_tests;
120pub(crate) mod request_project;
121pub mod response_optimizer;
122#[cfg(feature = "http-server")]
123pub(crate) mod response_shaper;
124pub mod rollout;
125pub mod routing;
126#[cfg(feature = "http-server")]
127pub(crate) mod sealed_origin;
128#[cfg(feature = "shape-xlat")]
129pub mod shape_xlat;
130#[cfg(feature = "http-server")]
131pub(crate) mod shaping_hook;
132#[cfg(feature = "http-server")]
133pub mod sse_keepalive;
134#[cfg(all(test, feature = "http-server"))]
135mod stats_tests;
136pub mod sticky_tools;
137pub(crate) mod store_binding;
138#[cfg(feature = "http-server")]
139pub(crate) mod tool_descriptions;
140pub mod tool_kind;
141#[cfg(feature = "http-server")]
142pub mod tool_output;
143#[cfg(all(test, feature = "http-server"))]
144mod upstream_tests;
145pub mod usage;
146#[cfg(feature = "http-server")]
147pub mod usage_accounting;
148pub mod usage_meter;
149pub mod usage_parity;
150pub mod usage_sink;
151pub mod value_gate_proxy;
152pub mod verbosity;
153#[cfg(all(test, feature = "http-server"))]
154mod via_p0_characterization_tests;
155#[cfg(feature = "http-server")]
156pub mod web_app;
157
158pub mod connector_schedule;
159#[allow(warnings)]
160pub mod live_zone;
161
162// The HTTP proxy server: state, router, middleware and handlers. Everything
163// above builds without `http-server` (#586); this half needs axum.
164#[cfg(feature = "http-server")]
165mod server;
166#[cfg(feature = "http-server")]
167pub use server::*;