Skip to main content

systemprompt_runtime/context/
services.rs

1//! Service accessors: the process-wide governance engine, AI service and
2//! artifact ingest the composition root built once.
3//!
4//! Copyright (c) systemprompt.io — Business Source License 1.1.
5//! See <https://systemprompt.io> for licensing details.
6
7use std::sync::Arc;
8
9use systemprompt_security::policy::GovernanceEngine;
10
11use super::AppContext;
12
13impl AppContext {
14    #[must_use]
15    pub fn governance(&self) -> &GovernanceEngine {
16        &self.subsystems.governance
17    }
18
19    #[must_use]
20    pub fn governance_arc(&self) -> Arc<GovernanceEngine> {
21        Arc::clone(&self.subsystems.governance)
22    }
23
24    #[must_use]
25    pub fn artifact_ingest(&self) -> &systemprompt_mcp::ArtifactIngest {
26        &self.subsystems.artifact_ingest
27    }
28
29    #[must_use]
30    pub fn artifact_ingest_arc(&self) -> Arc<systemprompt_mcp::ArtifactIngest> {
31        Arc::clone(&self.subsystems.artifact_ingest)
32    }
33
34    #[must_use]
35    pub const fn ai_service(&self) -> Option<&Arc<systemprompt_ai::AiService>> {
36        self.subsystems.ai_service.as_ref()
37    }
38
39    #[must_use]
40    pub fn ai_service_arc(&self) -> Option<Arc<systemprompt_ai::AiService>> {
41        self.subsystems.ai_service.clone()
42    }
43}