pub struct AppState {Show 18 fields
pub config: Arc<ProxyConfig>,
pub http: Client,
pub providers: ProviderRegistry,
pub gate_health: Arc<GateHealthRegistry>,
pub shadow_ledger: Arc<ShadowLedger>,
pub paired_ledger: Arc<ShadowLedger>,
pub experiments: Arc<ExperimentMonitor>,
pub guardrails: Arc<GuardrailRegistry>,
pub traces: TraceSender,
pub adaptive: Option<Arc<Mutex<AdaptiveConformal>>>,
pub eprocess: Option<Arc<Mutex<EProcessRiskControl>>>,
pub bandit: Option<Arc<Mutex<StartRungBandit>>>,
pub promoter: Option<Arc<SessionPromoter>>,
pub verified_cache: Option<Arc<dyn CacheStore>>,
pub predictor: Option<Arc<Mutex<PassPredictor>>>,
pub prior: Option<Arc<PriorClient>>,
pub tenant_rate_limiter: Option<Arc<DefaultKeyedRateLimiter<String>>>,
pub spill: Option<SpillHandle>,
}Expand description
Shared state handed to every request handler. Cheap to clone: an Arced config, a
pooled HTTP client, and a bounded channel sender.
Fields§
§config: Arc<ProxyConfig>Static proxy configuration.
http: ClientShared, connection-pooled HTTP client used to call upstream (observe passthrough).
providers: ProviderRegistryMulti-provider registry used by the enforce-mode escalation engine.
gate_health: Arc<GateHealthRegistry>Per-gate error budgets (auto-disable), shared across requests.
shadow_ledger: Arc<ShadowLedger>Per-(tenant, route) shadow spend for the current UTC day (ADR 0009 D2). Shadow makes real model calls, so the daily ceiling is enforced through this rather than trusted.
paired_ledger: Arc<ShadowLedger>Per-(tenant, route) paired-challenger spend for the current UTC day. Paired mode runs the challenger ladder off-path on real traffic; the daily ceiling is enforced through this.
experiments: Arc<ExperimentMonitor>Certified-selection experiments (ADR 0014), one per (tenant, route) that has a
[route.challenger]. Holds the evidence and is the halt guard the serving path consults.
guardrails: Arc<GuardrailRegistry>Per-(tenant, route) guardrail state (ADR 0009 D3): the trailing window of resolved outcomes and whether a route is currently demoted.
traces: TraceSenderFire-and-forget sender to the background trace writer.
adaptive: Option<Arc<Mutex<AdaptiveConformal>>>Optional online/adaptive conformal serve threshold (Gibbs-Candès ACI). None = fixed
serve_threshold from config (default). When present, /v1/feedback nudges it live and the
enforce path reads its current value per request — the reactive, self-tuning loop.
eprocess: Option<Arc<Mutex<EProcessRiskControl>>>Anytime-valid risk control (ADR 0011). When present AND it has certified a threshold, it
takes precedence over adaptive, because its bound holds at the round it is read rather
than in the long-run average. None, or certified-nothing, leaves existing behaviour
untouched.
bandit: Option<Arc<Mutex<StartRungBandit>>>Optional UCB1 start-rung bandit (predict-to-start, verify-to-serve). None (default) =
start every request at rung 0, byte-identical to today. When present, handle_enforce
queries it for a predicted start rung per request and feeds back gate verdicts for online
learning — all in-memory, per-process.
promoter: Option<Arc<SessionPromoter>>Optional session promotion ([escalation.session_promotion]). None (default) = every
request starts cold, byte-identical to today. When present, a session that had to escalate
starts its next turn on the rung it actually needed instead of re-paying for the rung that
already failed — with a periodic downward probe so the promotion is not one-way.
verified_cache: Option<Arc<dyn CacheStore>>Optional verified-response cache ([escalation.verified_cache]). None (default) = every
request runs the ladder. A hit replays an answer that previously PASSED a gate, and the
receipt names the decision that proved it.
predictor: Option<Arc<Mutex<PassPredictor>>>Optional per-query gate-pass predictor (ADR 0008 Phase 2). None (default) = no
prediction, byte-identical to today. When Some, handle_enforce records its
P(gate-pass) for the start rung on the receipt in shadow (never acted on) and
feeds this request’s attempts back for online learning — in-memory, per-process, warm-
started from receipts on boot.
prior: Option<Arc<PriorClient>>Optional verified predictive routing config + resolved API key ([escalation.prior]).
None (default) = off = byte-identical to today: no pre-generation call, no
decision_prior on the trace, the start-rung argmin runs exactly as before. When
Some, handle_enforce fetches a per-query prior before choosing the start rung and
feeds it into the bandit’s expected-cost argmin — the enforce gate still verifies every
output regardless of what the prior said.
tenant_rate_limiter: Option<Arc<DefaultKeyedRateLimiter<String>>>Per-tenant request rate limiter (ADR 0004 §D6). None (the default) disables rate
limiting entirely — set via build_tenant_rate_limiter from
ProxyConfig::tenant_rate_per_sec.
spill: Option<SpillHandle>Durable-receipts spill handle (FIRSTPASS_RECEIPTS=durable). None in best-effort mode
(the default) — behavior is byte-identical to before. When Some, offer_trace appends
to <db_path>.spill.jsonl on channel-full instead of dropping.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AppState
impl !UnwindSafe for AppState
impl Freeze for AppState
impl Send for AppState
impl Sync for AppState
impl Unpin for AppState
impl UnsafeUnpin for AppState
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