Skip to main content

clawft_kernel/infer_proxy/
mod.rs

1//! Stable inference address, proxy and resolution (card mesh-placement-19;
2//! ADR-101 section 5).
3//!
4//! - [`table`]: the [`PlacementTable`], role to serving node, fed by the
5//!   card-18 adapters (local) and `infer.<role>` [`ServiceAdvertisement`]s
6//!   of admitted peers (remote). Resolution for in-process consumers
7//!   (`base_url_for_role`, wired to `clawft_llm::PlacementResolver`).
8//! - [`listener`]: [`InferProxy`], the loopback endpoint proxy that keeps
9//!   `127.0.0.1:<role port>` stable while the instance moves.
10//! - [`mesh_forward`] / [`wire`]: forwarding over the authenticated mesh
11//!   (frame types `InferRequest` / `InferResponse`).
12//! - [`http`] / [`upstream`]: the HTTP edge and the loopback client.
13//!
14//! The proxy is not a general proxy. It binds loopback only, takes the
15//! destination from the placement table and never from the request, allows
16//! GET and POST on an inference path allowlist, refuses a non-loopback
17//! `Host` and a cross-origin `Origin`, and bounds sizes and times
18//! ([`ProxyLimits`]). Mesh forwarding reaches only admitted, verified peers
19//! and only roles a node chose to expose.
20//!
21//! [`ServiceAdvertisement`]: crate::mesh_service_adv::ServiceAdvertisement
22
23pub mod http;
24pub mod hub;
25pub mod listener;
26pub mod mesh_forward;
27pub mod mesh_policy;
28pub mod table;
29pub mod types;
30pub mod upstream;
31pub mod wire;
32
33#[cfg(test)]
34mod support;
35#[cfg(test)]
36mod tests_expose;
37#[cfg(test)]
38mod tests_http;
39#[cfg(test)]
40mod tests_hub;
41#[cfg(test)]
42mod tests_mesh;
43#[cfg(test)]
44mod tests_mesh_serve;
45#[cfg(test)]
46mod tests_proxy;
47
48#[cfg(feature = "exochain")]
49pub use types::ChainAudit;
50pub use hub::InferHub;
51pub use listener::{ExposureAuth, ExposurePermit, InferProxy, OccupiedPolicy, ProxyStats, Started, check_bind};
52pub use mesh_forward::{InferPeer, ServeGate, ServePolicy, Served, forward_remote, serve_infer};
53pub use table::{DEFAULT_ADVERT_TTL, MeshLocal, PlacementTable, SERVICE_PREFIX, SyncOutcome};
54pub use types::{
55    MeshDialer, Method, ProxyAudit, ProxyError, ProxyLimits, ProxyRequest, ResponseSink, Target,
56};
57pub use upstream::Upstream;