Skip to main content

firstpass_proxy/
lib.rs

1//! # firstpass-proxy
2//!
3//! An HTTP proxy that sits as a drop-in `base_url` in front of Anthropic/OpenAI-compatible
4//! providers. In **observe** mode it forwards each request unchanged and records a
5//! tamper-evident audit trace asynchronously (zero added latency). In **enforce** mode it runs
6//! the escalation engine — cheapest model first, gate the output, escalate one rung on failure,
7//! serve the first output that passes — with cross-provider failover (SPEC §7.1, §7.1a, §9.1).
8//!
9//! - [`config`] — [`ProxyConfig`], loaded from the environment.
10//! - [`store`] — the background SQLite trace writer.
11//! - [`calibrate`] — recalibrate the conformal serving threshold from deferred feedback.
12//! - [`upstream`] — BYOK passthrough to the upstream provider (observe mode).
13//! - [`provider`] — normalized multi-provider model access (Anthropic, OpenAI).
14//! - [`gate`] — runtime verification gates (Batch 3 inline set).
15//! - [`router`] — the enforce-mode escalation engine.
16//! - [`proxy`] — axum routing, observe passthrough, and enforce dispatch.
17//! - [`error`] — structured, no-leak error responses.
18//! - [`key_custody`] — per-tenant AES-256-GCM envelope key custody (ADR 0004 §D5, pre-review).
19//! - [`metrics`] — Prometheus recorder install + `GET /metrics`.
20//! - [`cli`] — `firstpass doctor` / `trace` logic (validate a setup, read the store).
21//! - [`mcp`] — minimal MCP stdio server so an agent can read its traces and submit feedback.
22//! - [`tenant_auth`] — experimental multi-tenant API-key auth (ADR 0004 §D1, default-off).
23//! - [`run`] — shared server bootstrap for the `firstpass` and `firstpass-proxy` binaries.
24#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used))]
25
26pub mod calibrate;
27pub mod cli;
28pub mod config;
29pub mod error;
30pub mod gate;
31pub mod judge;
32pub mod key_custody;
33pub mod mcp;
34pub mod metrics;
35pub mod onboard;
36pub mod provider;
37pub mod proxy;
38pub mod router;
39pub mod run;
40pub mod store;
41pub mod subprocess;
42pub mod tenant_auth;
43pub mod upstream;
44
45pub use config::ProxyConfig;
46pub use error::ProxyError;
47pub use proxy::{AppState, app};
48pub use store::{TraceSender, load_all_traces};
49pub use tenant_auth::{TenantId, TenantKeys};