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;
10use systemprompt_traits::CacheEpochs;
11
12use super::AppContext;
13
14impl AppContext {
15    pub fn config_planes(
16        &self,
17    ) -> systemprompt_provider_contracts::ConfigPlaneResult<crate::ConfigPlaneSet> {
18        crate::ConfigPlaneSet::new(
19            self.extension_registry().all_config_planes(),
20            self.config().planes.clone(),
21            std::path::PathBuf::from(&self.config().services_path),
22        )
23    }
24
25    #[must_use]
26    pub fn governance(&self) -> &GovernanceEngine {
27        &self.subsystems.governance
28    }
29
30    #[must_use]
31    pub fn governance_arc(&self) -> Arc<GovernanceEngine> {
32        Arc::clone(&self.subsystems.governance)
33    }
34
35    #[must_use]
36    pub const fn cache_epochs(&self) -> &CacheEpochs {
37        &self.subsystems.cache_epochs
38    }
39
40    #[must_use]
41    pub fn artifact_ingest(&self) -> &systemprompt_mcp::ArtifactIngest {
42        &self.subsystems.artifact_ingest
43    }
44
45    #[must_use]
46    pub fn artifact_ingest_arc(&self) -> Arc<systemprompt_mcp::ArtifactIngest> {
47        Arc::clone(&self.subsystems.artifact_ingest)
48    }
49
50    #[must_use]
51    pub const fn ai_service(&self) -> Option<&Arc<systemprompt_ai::AiService>> {
52        self.subsystems.ai_service.as_ref()
53    }
54
55    #[must_use]
56    pub fn ai_service_arc(&self) -> Option<Arc<systemprompt_ai::AiService>> {
57        self.subsystems.ai_service.clone()
58    }
59}