pub struct ProxyConfig {Show 13 fields
pub bind: String,
pub upstream_anthropic: String,
pub upstream_openai: String,
pub db_path: String,
pub tenant_id: String,
pub require_auth: bool,
pub tenant_keys: TenantKeys,
pub prompt_salt: String,
pub mode: Mode,
pub routing: Option<Config>,
pub prices: PriceTable,
pub max_concurrency: usize,
pub tenant_rate_per_sec: Option<NonZeroU32>,
}Expand description
Runtime configuration for the proxy.
Fields§
§bind: StringAddress to bind the HTTP server to, e.g. 127.0.0.1:8080.
upstream_anthropic: StringBase URL of the upstream Anthropic-compatible API.
upstream_openai: StringBase URL of the upstream OpenAI-compatible API.
db_path: StringPath to the SQLite trace database.
tenant_id: StringTenant identifier stamped on every trace when require_auth is off (single-operator
default). When require_auth is on, the per-request tenant comes from the verified API
key instead, and this is only the fallback for operator-scoped tooling.
require_auth: boolMulti-tenant auth gate (ADR 0004 §D1). Default false — single-operator behavior is
byte-identical: no auth checks, tenant is the static Self::tenant_id. Set via
FIRSTPASS_REQUIRE_AUTH. Experimental / pre-external-review (ADR 0004 §D7).
tenant_keys: TenantKeysPer-tenant Argon2id API-key hashes (ADR 0004 §D1). Empty unless configured via
FIRSTPASS_TENANT_KEYS (path to a JSON { tenant_id: hash }) or FIRSTPASS_TENANT_KEYS_JSON
(inline JSON). Only consulted when require_auth is on.
The stored hash is the Argon2id hash of a tenant’s secret (make one with
TenantKeys::hash_key). A tenant then authenticates with the key <tenant_id>.<secret> —
the tenant id names which hash to verify, so a request does exactly one Argon2 check. Tenant
ids must not contain a . (the first . splits id from secret).
prompt_salt: StringSalt mixed into the prompt hash so raw prompt text never touches storage.
mode: ModeDefault mode when no routing config matches (observe unless overridden).
routing: Option<Config>Optional declarative routing config (§8.4). When present, its routes decide the mode, ladder, and gates per request; enforce routes activate the escalation engine.
prices: PriceTableModel pricing table used to cost each attempt.
max_concurrency: usizeMax in-flight requests before new ones queue behind the concurrency limiter
(FIRSTPASS_MAX_CONCURRENCY, default 512). A load-shed valve, not a timeout — it never
severs an in-flight SSE stream.
tenant_rate_per_sec: Option<NonZeroU32>Per-tenant request rate limit, requests/sec (ADR 0004 §D6). None (the default) means
unlimited — single-operator and existing deployments are unaffected. Set via
FIRSTPASS_TENANT_RATE_PER_SEC; only enforced when configured.
Implementations§
Source§impl ProxyConfig
impl ProxyConfig
Sourcepub fn from_env() -> Result<Self, ConfigError>
pub fn from_env() -> Result<Self, ConfigError>
Load configuration from environment variables, falling back to local defaults.
§Errors
ConfigError::UnsupportedMode for an unknown FIRSTPASS_MODE; ConfigError::Config
if the FIRSTPASS_CONFIG routing file cannot be read or parsed.
Sourcepub fn from_lookup(
lookup: impl Fn(&str) -> Option<String>,
) -> Result<Self, ConfigError>
pub fn from_lookup( lookup: impl Fn(&str) -> Option<String>, ) -> Result<Self, ConfigError>
Load configuration from an arbitrary key lookup — the seam from_env uses, exposed
so tests can exercise defaulting/validation without touching real process env vars.
The routing config is supplied inline via the FIRSTPASS_CONFIG_TOML key.
§Errors
ConfigError::UnsupportedMode for an unknown FIRSTPASS_MODE; ConfigError::Config
if the inline routing TOML fails to parse.
Trait Implementations§
Source§impl Clone for ProxyConfig
impl Clone for ProxyConfig
Source§fn clone(&self) -> ProxyConfig
fn clone(&self) -> ProxyConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ProxyConfig
impl RefUnwindSafe for ProxyConfig
impl Send for ProxyConfig
impl Sync for ProxyConfig
impl Unpin for ProxyConfig
impl UnsafeUnpin for ProxyConfig
impl UnwindSafe for ProxyConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more