pub struct AppState {
pub config: Arc<HarnessConfig>,
pub store: Arc<dyn StateStore>,
pub sandbox: Arc<Sandbox>,
pub bridge: Arc<dyn EventBus>,
pub sessions: Arc<SessionRegistry>,
pub worker: WorkerHandle,
pub identity: Option<Arc<IdentityValidator>>,
pub metrics: Arc<Registry>,
pub client: Client,
pub finalizer: Finalizer,
/* private fields */
}Expand description
Shared application state passed through HTTP handlers and background tasks.
Fields§
§config: Arc<HarnessConfig>Versioned harness configuration.
store: Arc<dyn StateStore>Atomic quota and action-budget state.
sandbox: Arc<Sandbox>MCP schema, policy, and action-budget sandbox.
bridge: Arc<dyn EventBus>Event Bridge backend used by asynchronous workers and by lifecycle finalization (close/promote publish through it inline).
sessions: Arc<SessionRegistry>Live session registry.
worker: WorkerHandleBounded non-blocking worker queue.
identity: Option<Arc<IdentityValidator>>Optional NHI validator. Required in production identity mode.
metrics: Arc<Registry>Prometheus-compatible metrics registry.
client: ClientReused upstream HTTP client.
finalizer: FinalizerAsynchronous session close and promotion service.
Implementations§
Source§impl AppState
impl AppState
Sourcepub fn new(
config: HarnessConfig,
store: Arc<dyn StateStore>,
sandbox: Arc<Sandbox>,
bridge: Arc<dyn EventBus>,
identity: Option<Arc<IdentityValidator>>,
signer: Arc<dyn Signer>,
) -> Result<Self, PipelineError>
pub fn new( config: HarnessConfig, store: Arc<dyn StateStore>, sandbox: Arc<Sandbox>, bridge: Arc<dyn EventBus>, identity: Option<Arc<IdentityValidator>>, signer: Arc<dyn Signer>, ) -> Result<Self, PipelineError>
Build fully wired application state with a bounded worker and shared lifecycle services.
Sourcepub fn new_with_embedder(
config: HarnessConfig,
store: Arc<dyn StateStore>,
sandbox: Arc<Sandbox>,
bridge: Arc<dyn EventBus>,
identity: Option<Arc<IdentityValidator>>,
signer: Arc<dyn Signer>,
embedder: Arc<dyn Embedder>,
) -> Result<Self, PipelineError>
pub fn new_with_embedder( config: HarnessConfig, store: Arc<dyn StateStore>, sandbox: Arc<Sandbox>, bridge: Arc<dyn EventBus>, identity: Option<Arc<IdentityValidator>>, signer: Arc<dyn Signer>, embedder: Arc<dyn Embedder>, ) -> Result<Self, PipelineError>
Build application state with an explicit embedding backend.
Sourcepub fn new_with_backends(
config: HarnessConfig,
store: Arc<dyn StateStore>,
sandbox: Arc<Sandbox>,
bridge: Arc<dyn EventBus>,
identity: Option<Arc<IdentityValidator>>,
signer: Arc<dyn Signer>,
embedder: Arc<dyn Embedder>,
vector_sink: Arc<dyn VectorSink>,
) -> Result<Self, PipelineError>
pub fn new_with_backends( config: HarnessConfig, store: Arc<dyn StateStore>, sandbox: Arc<Sandbox>, bridge: Arc<dyn EventBus>, identity: Option<Arc<IdentityValidator>>, signer: Arc<dyn Signer>, embedder: Arc<dyn Embedder>, vector_sink: Arc<dyn VectorSink>, ) -> Result<Self, PipelineError>
Build application state with explicit embedding and vector backends.
Sourcepub fn new_with_backends_and_metrics(
config: HarnessConfig,
store: Arc<dyn StateStore>,
sandbox: Arc<Sandbox>,
bridge: Arc<dyn EventBus>,
identity: Option<Arc<IdentityValidator>>,
signer: Arc<dyn Signer>,
embedder: Arc<dyn Embedder>,
vector_sink: Arc<dyn VectorSink>,
metrics: Arc<Registry>,
) -> Result<Self, PipelineError>
pub fn new_with_backends_and_metrics( config: HarnessConfig, store: Arc<dyn StateStore>, sandbox: Arc<Sandbox>, bridge: Arc<dyn EventBus>, identity: Option<Arc<IdentityValidator>>, signer: Arc<dyn Signer>, embedder: Arc<dyn Embedder>, vector_sink: Arc<dyn VectorSink>, metrics: Arc<Registry>, ) -> Result<Self, PipelineError>
Build application state reusing a pre-existing metrics registry.
main.rs uses this so counters registered outside AppState
(JWKS refresh errors, HTTP shutdown drain timeouts) live on the
same registry that gets scraped at /metrics — otherwise their
samples would be invisible to Prometheus.
Sourcepub fn prepare_chat(
&self,
headers: &HeaderMap,
payload: Value,
) -> Result<PreparedRequest, PipelineError>
pub fn prepare_chat( &self, headers: &HeaderMap, payload: Value, ) -> Result<PreparedRequest, PipelineError>
Run identity, breaker, quota, sanitize, compression, and asynchronous dispatch in the mandated order without awaiting worker or upstream I/O.
Sourcepub async fn prepare_chat_nonblocking(
&self,
headers: &HeaderMap,
payload: Value,
) -> Result<PreparedRequest, PipelineError>
pub async fn prepare_chat_nonblocking( &self, headers: &HeaderMap, payload: Value, ) -> Result<PreparedRequest, PipelineError>
Run synchronous local gates without waiting for off-path journal,
embedding, or broker work. When a completion-token budget is
configured (budget.max_tokens) the gates run on the blocking pool;
otherwise they are cheap enough to run inline.
Sourcepub async fn prepare_chat_durable(
&self,
headers: &HeaderMap,
payload: Value,
) -> Result<PreparedRequest, PipelineError>
pub async fn prepare_chat_durable( &self, headers: &HeaderMap, payload: Value, ) -> Result<PreparedRequest, PipelineError>
Prepare a request and wait until its audit record is durably captured before the provider can observe it.
Sourcepub async fn forward_chat(
&self,
request: PreparedRequest,
) -> Result<ForwardedResponse, PipelineError>
pub async fn forward_chat( &self, request: PreparedRequest, ) -> Result<ForwardedResponse, PipelineError>
Forward a prepared OpenAI-compatible request to the configured provider.
Sourcepub fn intercept_tool(
&self,
headers: &HeaderMap,
raw: &[u8],
) -> Result<ToolVerdict, PipelineError>
pub fn intercept_tool( &self, headers: &HeaderMap, raw: &[u8], ) -> Result<ToolVerdict, PipelineError>
Intercept one MCP JSON-RPC tool call, emit its OCSF verdict asynchronously, and return the immediate authorization decision.
Sourcepub async fn intercept_tool_durable(
&self,
headers: &HeaderMap,
raw: &[u8],
) -> Result<ToolVerdict, PipelineError>
pub async fn intercept_tool_durable( &self, headers: &HeaderMap, raw: &[u8], ) -> Result<ToolVerdict, PipelineError>
Authorize a tool call and wait for its verdict event to become durable.
Sourcepub async fn intercept_tool_nonblocking(
&self,
headers: &HeaderMap,
raw: &[u8],
) -> Result<ToolVerdict, PipelineError>
pub async fn intercept_tool_nonblocking( &self, headers: &HeaderMap, raw: &[u8], ) -> Result<ToolVerdict, PipelineError>
Authorize a tool call on the blocking pool without waiting for the off-path event journal or broker publication.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AppState
impl !RefUnwindSafe for AppState
impl Send for AppState
impl Sync for AppState
impl Unpin for AppState
impl UnsafeUnpin for AppState
impl !UnwindSafe 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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