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//! - [`metrics`] — Prometheus recorder install + `GET /metrics`.
19//! - [`cli`] — `firstpass doctor` / `trace` logic (validate a setup, read the store).
20//! - [`mcp`] — minimal MCP stdio server so an agent can read its traces and submit feedback.
21//! - [`run`] — shared server bootstrap for the `firstpass` and `firstpass-proxy` binaries.
22#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used))]
23
24pub mod calibrate;
25pub mod cli;
26pub mod config;
27pub mod error;
28pub mod gate;
29pub mod judge;
30pub mod mcp;
31pub mod metrics;
32pub mod provider;
33pub mod proxy;
34pub mod router;
35pub mod run;
36pub mod store;
37pub mod subprocess;
38pub mod upstream;
39
40pub use config::ProxyConfig;
41pub use error::ProxyError;
42pub use proxy::{AppState, app};
43pub use store::{TraceSender, load_all_traces};