Skip to main content

agentic_reality/engine/query/
deployment.rs

1//! Deployment query operations.
2
3use crate::engine::query::QueryEngine;
4use crate::engine::ContextSummary;
5use crate::types::deployment::*;
6use crate::types::error::{RealityError, RealityResult};
7impl<'a> QueryEngine<'a> {
8    pub fn get_soul(&self) -> RealityResult<&DeploymentSoul> {
9        self.engine
10            .deployment_store
11            .soul
12            .as_ref()
13            .ok_or_else(|| RealityError::NotInitialized("deployment soul".into()))
14    }
15
16    pub fn get_birth_context(&self) -> RealityResult<&BirthContext> {
17        Ok(&self.get_soul()?.birth)
18    }
19
20    pub fn get_substrate(&self) -> RealityResult<&PhysicalSubstrate> {
21        Ok(&self.get_soul()?.substrate)
22    }
23
24    pub fn get_vitals(&self) -> RealityResult<&SoulVitals> {
25        Ok(&self.get_soul()?.vitals)
26    }
27
28    pub fn get_lineage(&self) -> RealityResult<&DeploymentLineage> {
29        Ok(&self.get_soul()?.lineage)
30    }
31
32    pub fn get_incarnation_memory(&self) -> RealityResult<&IncarnationMemory> {
33        self.engine
34            .deployment_store
35            .incarnation_memory
36            .as_ref()
37            .ok_or_else(|| RealityError::NotInitialized("incarnation memory".into()))
38    }
39
40    pub fn get_wisdom(&self) -> RealityResult<&[IncarnationWisdom]> {
41        Ok(&self.get_soul()?.lineage.wisdom)
42    }
43
44    pub fn get_karma(&self) -> RealityResult<&IncarnationKarma> {
45        Ok(&self.get_soul()?.lineage.karma)
46    }
47
48    pub fn get_nature(&self) -> RealityResult<&ExistentialNature> {
49        Ok(&self.get_soul()?.nature)
50    }
51
52    pub fn get_context_summary(&self) -> ContextSummary {
53        let soul = self.engine.deployment_store.soul.as_ref();
54        let env = self.engine.environment_store.medium.as_ref();
55        let stakes = self.engine.stakes_store.consequences.as_ref();
56        let coherence = self.engine.coherence_store.state.as_ref();
57        let resource = self.engine.resource_store.pressure_gradient.as_ref();
58
59        ContextSummary {
60            incarnation_id: soul.map(|s| s.incarnation_id),
61            substrate_tier: soul.map(|s| format!("{:?}", s.substrate.tier)),
62            environment_type: env.map(|e| format!("{:?}", e.environment_type)),
63            environment_mood: env.map(|e| e.current_state.mood.to_string()),
64            resource_bottleneck: resource.and_then(|r| r.bottleneck.map(|b| b.to_string())),
65            stakes_level: stakes.map(|s| s.stakes.to_string()),
66            coherence_level: coherence.map(|c| c.level.to_string()),
67            uptime_secs: soul.map(|s| s.vitals.uptime_secs),
68        }
69    }
70}